In an effort to try and get familiar with the display I modified the example program to change the display when a pin goes from low to high and vice versa.
But, the issue I'm running into is that when it switches. The previous display isn't cleared and the new display jumbles with the first. I tried 'display.refresh but there's not effect. I also tried display.clearDisplay, but that produces a bad blink without any delay statements.
The program just displays some text on one line when low. When high. the program displays different text on the same line. But, it appears the previous text does not clear.
As I mentioned above, the 'display.clearDisplay' work but the flicker is very noticeable.
The program is listed below.
Code: Select all
#include <Adafruit_GFX.h>
#include <Adafruit_SharpMem.h>
// any pins can be used
#define SHARP_SCK 13
#define SHARP_MOSI 11
#define SHARP_SS 10
#define button 6
Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS);
#define BLACK 0
#define WHITE 1
int buttonState = 0;
void setup(void)
{
Serial.begin(9600);
Serial.println(buttonState);
pinMode(button, INPUT);
// start & clear the display
display.begin();
display.clearDisplay();
}
void loop () {
buttonState = digitalRead(button);
if (buttonState == HIGH) {
Serial.println("HIGH");
display.refresh();
menu2();
}else{
Serial.println("LOW");
display.refresh();
menu1();
}
}
void menu1() {
//display.refresh
//display.clearDisplay();
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(16,5);
display.println("First_Page 1");
}
void menu2() {
//display.refresh
//display.clearDisplay();
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(16,5);
display.println("Second_Page 2");
}