@felmue no problem. thanks for your help and time :)
Latest posts made by albertlt
-
RE: touch stopped working
Hi @felmue. I have a quick question. I tried to encapsulate the GUI function in a class named M5GUI. I moved the tapEvent into M5GUI.h as follow:
private: void tapEvent(Event& e);
Then in M5GUI.cpp:
void M5GUI::begin(){ M5.Buttons.addHandler(tapEvent, E_RELEASE); } void M5GUI::tapEvent(Event& e){ Serial.print("Button: "); Serial.println(e.objName()); }
The M5.Buttons.addHandler(tapEvent, E_RELEASE); is giving me this error:
argument of type "void (M5GUI::)(Event &e)" is incompatible with parameter of type "void ()(Event &)"
How do I integrate that event handler function properly into class method?
-
RE: touch stopped working
@felmue okay will do. thanks a lot felmue for your help. have a nice day
-
RE: touch stopped working
@felmue Thanks a lot for pointing out the static on the button. So I am planning to place a couple buttons on the screen and put all the codes in the tapEvent() method and filter by e.objName(). Is it the correct way to do it? or is there alternative similar to: M5.BtnA.wasPressed() ? Also, how do I clear the static button when changing screen to preserve ram?
Yes, I also realized Wire.requestFrom(); is causing the block. Is there any way to get around this issue? This make the device's UI not very user friendly when i2c is used and without i2c, this device is not very useful as a lot of modules depend on i2c :(
-
RE: touch stopped working
@felmue , here is the code:
String wireData; unsigned long prevReadMillis; int READ_DELAY = 100; void setup() { M5.begin(); Serial.begin(115200); Wire.begin(32, 33); //Init GUI myGUI.begin(); myGUI.ShowScreen(); } void loop() { myGUI.loop(); I2CLoop(); } void I2CLoop(){ if((millis() - prevReadMillis) > READ_DELAY){ //Read 20 bytes from the slave length = Wire.requestFrom(I2C_ADDR, I2C_LENGTH); if(length == I2C_LENGTH){ //in test environment, codes inside this if statement are never executed because I have not connected any external I2C device but the touch is already not responsive. wireData = ""; wireData = Wire.readStringUntil('!'); Wire.flush(); Serial.print(millis()); Serial.print(" - "); Serial.print("Wire Data: "); Serial.println(wireData); }else{ wireData = ""; } prevReadMillis = millis(); } }
GUI class codes:
void M5GUI::begin(){ //Setup touch buttons M5.Buttons.addHandler(tapEvent, E_RELEASE); } void tapEvent(Event& e){ Serial.print("Button: "); Serial.println(e.objName()); } void M5GUI::loop(){ M5.update(); } void M5GUI::ShowScreen{ //Create Touch Button ButtonColors on_clrs = {RED, WHITE, WHITE}; ButtonColors off_clrs = {BLACK, WHITE, WHITE}; Button btn1(BTN1_POS_X, BTN1_POS_Y, BTN_WIDTH, BTN_HEIGHT, false ,"btn1", off_clrs, on_clrs, CC_DATUM); }
Another issue is, whenever I touch the screen, the source is always "background" even though I clicked on the "btn1" coordinate. How do I make the virtual touch button to work? The only working sources are: background, physical btnA, physical btnB, and physical btnC. I can't get any virtual button to work. I plan to put several virtual button and execute different code when each button is tapped, so I need to be able to identify the correct source of event.
-
RE: touch stopped working
Hello. I have Core 2 that is continuously scanning external i2c every 100ms in loop. I noticed the touch event is very unresponsive. For example: every 10 touch, only 1 or 2 was detected. However, if I disable the external i2c in loop, the touch become responsive again. Is there any way to mitigate this issue? I tried increasing the external scan delay (non blocking) to every 250ms but the result is the same.
-
Unit RS232 issue
Hello. I am using the rs232 unit module to read data from a device. The device will output continuous data via it's rs232 port once turned on. The issue is when I turn off the device and turn back on, the rs232 unit stopped reading the data until the rs232 cable is disconnected and reconnected. This is certainly not ideal in real world application. Does anybody know what cause the issue and how to fix it?