ImpulseAdventure / GUIslice

GUIslice drag & drop embedded GUI in C for touchscreen TFT on Arduino, Raspberry Pi, ARM, ESP8266 / ESP32 / M5stack using Adafruit-GFX / TFT_eSPI / UTFT / SDL
https://www.impulseadventure.com/elec/guislice-gui.html
MIT License
1.17k stars 209 forks source link

GUIslice_drv_adagfx.cpp is missing button support for Adafruit 1.8" TFT Shield with Joystick (code in description) #527

Closed Dowster64 closed 7 months ago

Dowster64 commented 8 months ago

Describe the bug

Please describe what you observe on the display or any error messages When running ex40_ard_ctrls_small.ino and changing input mapping to use the buttons instead of the joystick there is no response.

Device hardware

Checklist to try first

Most display/touch issues can be identified by working through the steps in the Configuring GUIslice guide.

Please confirm whether:

Expected behavior

A description of what you expected to happen Button A,B,C and longpress ABC should work.

Initialization messages

Please copy any startup messages / errors reported to the serial monitor window here. You can enable all error messages by setting DEBUG_ERR 2 in the GUIslice config file.

Additional info

Add any other context about the problem here. I apologise but I don't know how to do a pull request, but modifiying GUIslice_drv_adagfx.cpp section starting lin 2924:

#ifdef DRV_DISP_ADAGFX_SEESAW
//and extending the switch debounce code with:
else if ((nButtonsLast & TFTSHIELD_BUTTON_1) && !(nButtonsCur & TFTSHIELD_BUTTON_1)) {
      *peInputEvent = GSLC_INPUT_PIN_ASSERT;
      *pnInputVal = GSLC_PIN_BTN_A;
    } else if (!(nButtonsLast & TFTSHIELD_BUTTON_1) && (nButtonsCur & TFTSHIELD_BUTTON_1)) {
      *peInputEvent = GSLC_INPUT_PIN_DEASSERT;
      *pnInputVal = GSLC_PIN_BTN_A;
    } else if ((nButtonsLast & TFTSHIELD_BUTTON_2) && !(nButtonsCur & TFTSHIELD_BUTTON_2)) {
      *peInputEvent = GSLC_INPUT_PIN_ASSERT;
      *pnInputVal = GSLC_PIN_BTN_B;
    } else if (!(nButtonsLast & TFTSHIELD_BUTTON_2) && (nButtonsCur & TFTSHIELD_BUTTON_2)) {
      *peInputEvent = GSLC_INPUT_PIN_DEASSERT;
      *pnInputVal = GSLC_PIN_BTN_B;
    } else if ((nButtonsLast & TFTSHIELD_BUTTON_3) && !(nButtonsCur & TFTSHIELD_BUTTON_3)) {
      *peInputEvent = GSLC_INPUT_PIN_ASSERT;
      *pnInputVal = GSLC_PIN_BTN_C;
    } else if (!(nButtonsLast & TFTSHIELD_BUTTON_3) && (nButtonsCur & TFTSHIELD_BUTTON_3)) {
      *peInputEvent = GSLC_INPUT_PIN_DEASSERT;
      *pnInputVal = GSLC_PIN_BTN_C;
    }

works for the standard press. I don't know how to code for the longpress enumerations but I hope this helps someone.

Dowster64 commented 7 months ago

Just a comment about longpress of buttons. Paul has solutions for this (or ones to modify) and other examples here: https://github.com/Pconti31/GUIslice-Solutions/tree/main/apps/Longpress-Btn

ImpulseAdventure commented 7 months ago

Hi @Dowster64 -- thank you for pointing this out!

I had been testing the Adafruit seesaw with the joystick control, but you are right in that the standard button mappings (A/B/C) should be offered too.

I am in the process of getting my regression environment up & running again (I had to freeze my focus on the repo for an extended period due to work), and then should be able to merge the updates that you suggested here.

thanks!

ImpulseAdventure commented 7 months ago

Add any other context about the problem here. I apologise but I don't know how to do a pull request, but modifiying GUIslice_drv_adagfx.cpp section starting lin 2924:

@Dowster64 If you'd like to try a simple approach to submitting a request (since these changes are quite limited), you may be able to navigate to the file in the GUIslice_drv_adagfx.cpp file in the GitHub repo and click on the Edit icon (a pencil). Make your changes to the code and then click Commit Changes. From there, you should be given the option to Create a new branch for this commit and start a pull request.

Dowster64 commented 7 months ago

@ImpulseAdventure - Thanks for taking the time to explain how the process of creating a pull request works. I can see the reason for the fork and the branch, it makes sense once you explained it. I've submitted the request, I just hope I haven't missed any curly brackets! :-)

ImpulseAdventure commented 7 months ago

Great, thanks for giving it a try! It has been merged now.