Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - digit

#1
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
#2
I think it should be possible to trigger interrupts using the four buttons on the TinyScreen+.

attachInterrupt(digitalPinToInterrupt( ??? ), callback, LOW);

Has anyone done this? I'm not sure what the pins would be  :-\

Thanks
Digit
SMF spam blocked by CleanTalk