Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LCD Display retains contents from previous sketch, until touch event #6

Open
aliphys opened this issue Jun 13, 2024 · 1 comment
Open

Comments

@aliphys
Copy link

aliphys commented Jun 13, 2024

Reported and triaged by @jojo1212

When using the arduino-libraries/Arduino_GigaDisplayTouch and Arduino_GigaDisplay_GFX libraries together, the GIGA Display Shield shows the previously uploaded sketch content, until you touch the display.

Steps to recreate the issue

  1. Upload pixels and shape example sketch from GIGA Display shield GFX guide. Four shapes appear on the GIGA Display Shield
#include "Arduino_GigaDisplay_GFX.h"

GigaDisplay_GFX display;

#define WHITE 0xffff
#define BLACK 0x0000

void setup() {
  display.begin();
  display.fillScreen(WHITE);
  display.drawTriangle(100, 200, 300, 400, 300, 600, BLACK);
  display.drawCircle(100, 100, 50, BLACK);
  display.drawRect(10, 650, 300, 80, BLACK);
  display.drawRoundRect(300, 50, 100, 100, 30, BLACK);
}
void loop() {}
  1. Upload the GFX and Touch example from GIGA Display shield GFX guide
#include "Arduino_GigaDisplay_GFX.h"
#include "Arduino_GigaDisplayTouch.h"

Arduino_GigaDisplayTouch touchDetector;
GigaDisplay_GFX display;

#define WHITE 0xffff
#define BLACK 0x0000

#define screen_size_x 480
#define screen_size_y 800

int touch_x;
int touch_y;

//increase or decrease the sensitivity of the touch.
int trigger_sensitivity = 5;
bool switch_1;
int counter;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  display.begin();

  if (touchDetector.begin()) {
    Serial.print("Touch controller init - OK");
  } else {
    Serial.print("Touch controller init - FAILED");
    while (1)
      ;
  }
}

void loop() {
  uint8_t contacts;
  GDTpoint_t points[5];
  contacts = touchDetector.getTouchPoints(points);
  
  if (contacts > 0) {
    Serial.print("Contacts: ");
    Serial.println(contacts);

    counter++;

    //record the x,y coordinates 
    for (uint8_t i = 0; i < contacts; i++) {
      touch_x = points[i].x;
      touch_y = points[i].y;
    }

    //as the display is 480x800, any time you touch the screen it will trigger
    //the trigger sensitivity is set to "5". 
    if (touch_x < screen_size_x && touch_y < screen_size_y && counter > trigger_sensitivity) {
      switch_1 = !switch_1;
      Serial.println("switched");
      changeSwitch();
      delay(250);
    }
  }
}

void changeSwitch() {
  if (switch_1) {
    display.fillScreen(BLACK);
    display.setTextColor(WHITE);
  } else {
    display.fillScreen(WHITE);
    display.setTextColor(BLACK);
  }
  display.setCursor(50, screen_size_y/2);
  display.setTextSize(5);
  display.print("Switched");
  counter = 0;
}
  1. Output IS still displayed from the previously uploaded sketch (four shapes).
  2. Touch the display to get the output (SWITCHED white text on a white background).
Giga.display.mp4

Workaround

Adding the following section to the setup() function. Suggested by @facchinm

display.begin();
display.startWrite();
display.fillScreen(YELLOW);
display.endWrite();

Note: YELLOW needs to be defined.

@aliphys
Copy link
Author

aliphys commented Jun 13, 2024

Possibly fixed by gilesp1729@58e5a92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant