Thanks Ben!
Some simple test code here to check the button interrupts:
#include <TinyScreen.h>
TinyScreen display = TinyScreen(TinyScreenPlus);
void setup() {
display.begin();
display.setBrightness(12); //valid levels are 0-15
pinMode(TSP_PIN_BT1, INPUT_PULLUP);
pinMode(TSP_PIN_BT2, INPUT_PULLUP);
pinMode(TSP_PIN_BT3, INPUT_PULLUP);
pinMode(TSP_PIN_BT4, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(TSP_PIN_BT1), fillScreen, RISING);
attachInterrupt(digitalPinToInterrupt(TSP_PIN_BT2), fillScreen, RISING);
attachInterrupt(digitalPinToInterrupt(TSP_PIN_BT3), fillScreen, RISING);
attachInterrupt(digitalPinToInterrupt(TSP_PIN_BT4), fillScreen, RISING);
randomSeed(analogRead(0));
}
void loop() {
//Other code here....
delay(1000);
}
void fillScreen() {
// Draw a rectangle the same size as the screen and fill it with a color.
// drawRect(x, y, w, h, fill (0 or 1), r, g, b)
display.drawRect(0, 0, display.xMax, display.yMax, 1,random(255),random(255),random(255));
}
I'm not sure if the internal pullups are completely necessary, or that display.xMax and display.yMax is the best way to set the screen size. But this might be useful for someone.
Also, I'm surprised there isn't a display.getWidth() and display.getHeight() method in TinyScreen.h. It could be quite useful.
Thanks
Digit