shurillu / CTBot

A simple (and easy to use) Arduino Telegram BOT Library for ESP8266/ESP32
MIT License
147 stars 34 forks source link

why flickered my led matrix at telegram #32

Open Nuries opened 4 years ago

Nuries commented 4 years ago

Hi,

I have a P3 RGB 64x32 l led matrix and the telegram library as soon as I embed a certain part of the telegram library flickers the matrix. Why is that?

`

include "CTBot.h" // Telegramm

include "PxMatrix.h" // LED Matrix / P3 64x32 RGB Display

include // Intervall for Display refresh

Ticker display_ticker;

define P_LAT 16

define P_A 5

define P_B 4

define P_C 15

define P_D 12

define P_E 0

define P_OE 9

PxMATRIX display(64, 32, P_LAT, P_OE, P_A, P_B, P_C, P_D, P_E);

CTBot myBot;

void display_updater() { display.display(10); // Display Refresh }

void setup() {

Serial.begin(9600);

display.begin(16);

myBot.wifiConnect("qwertx", "1234@@5678");

myBot.setTelegramToken("640083020:AAEyK6UhUybfzuPcxYSgg0DXxYPH2FqYgHs");

display_ticker.attach(0.002, display_updater); }

void loop() {

display.setCursor(0, 0); display.print("HI"); // this text flickers

TBMessage msg;

if (myBot.getNewMessage(msg)) {} // if I comment that out, the flickering is gone

} `

shurillu commented 4 years ago

Hello Nurries, the RGB Matrixes are bad beast to deal with the ESP8266 hardware. Keep in mind that 2dom (the PxMatrix author) use a clever way to bypass the lack of pin in the ESP8266 by "serializing" all the RGB data (six pin) in only one ESP8266 pin (so a bunch of work for the SOC!). Basically, I guess the problem is related to the Telegram library fetching data (that is not asynchronous) -> they maybe blocks the execution waiting the telegram server response -> some flicker effect appears. You can try overclocking the ESP8266 from 80MHz to 160MHz (you can do that in the "Tools" menu of Arduino IDE and choosing "CPU Frequency -> 160MHz)

In the past, when I did some projects with RGB matrixes and NodeMCUs, doubling the frequency sometimes saves me ;-)

So try and let me know!

Ceers,

Stefano

shurillu commented 4 years ago

I forgot, one more thing: download the master branch version, because it have some upgrades not published yet as official release.

Nuries commented 4 years ago

Hello, Stefano,

Thanks for the answer. I increased the CPU frequency to 160MHz but the flickering is still there. Do you have a link to the possibility to bypass the pin shortage?

Do you happen to know what happens when a telegram waits for an answer and if you can bypass what is blocked there?

downloaded the new version :)

Thanks for your help!

Greetings from Germany

shurillu commented 4 years ago

The RGB matrices needs a lot of pin to work: you need at least:

Going back to your questions, at this moment I can't work on a "non blocking" member functions that interact with Telegram server.

A possible solution could be using another device (an Arduino Nano) as frame buffer: this device handle the matrix refreshing procedure and the ESP8266 handle all other tasks. Every time the ESP8266 need to change the data on the RGB Matrix, it sends the data (pixels) to the Arduino Nano and the Arduino use the new data for refreshing the RGB Matrix. There is a bit of work to do, but you could reuse some projects already done! Good luck ;-)

Stefano

CCERocks commented 3 years ago

Hi Stefano, so technically dont use 1 device ie WemosD1 mini with LED Dot Matrix directly with CTBot ?

id saw one sample that use ESP01 & to send text to Uno using blynk serial (connected to LED Dot Matrix)...

i wonder that still the proper method right ? Wemos -> serial link -> Uno -> LED Dot Matrix

regards

shurillu commented 3 years ago

Hello CCERocks, exactly! You can:

Driving LED matrices requires a good timing.

Cheers,

Stefano