Open Wer-Wolf opened 3 years ago
Hi @Wer-Wolf Thank you for this issue. Until now I haven't tested the library with sleep modes very much. Basically the SPI needs to be re-initialized after the sleep. I will investigate further and come back to you.
@generationmake Hi , i would like to use this on an attiny85 also in low power mode ( sleeping between screen updates ) were you able to check low power mode with your library?
When using LowPower.attachAdcInterrupt from Adruino LowPower on the Adafruit Feather M0 LoRaWAN, the devices freezes after wakeup from LowPower.sleep() upon calling any draw function unless begin() is called again. However when using the RTC instead of the ADC as wakeup source (with LowPower.sleep(2000) and attachAdcInterrupt() commented out), the problem does not occur. Source code:
include
include
DogGraphicDisplay DOG;
// Pin used to trigger a wakeup
define VUSBPIN A0
// How sensitive to be to changes in voltage const int margin = 100;
void adc_wakeup() { return; }
void setup() { pinMode(LED_BUILTIN, OUTPUT); pinMode(VUSBPIN, INPUT); DOG.begin(17, 0, 0, 19, 18, DOGM128); //CS = 17, 0,0= use Hardware SPI, A0 = 19, RESET = 18, EA DOGM128-6 (=128x64 dots) DOG.clear(); }
void loop() { DOG.createCanvas(128, 64, 0, 0); DOG.drawLine(0, 0, 127, 63); DOG.drawCircle(50, 30, 20, false); DOG.drawCircle(20, 20, 10, true); DOG.drawRect(60, 20, 20, 10, true); DOG.drawRect(80, 40, 10, 20, false); DOG.drawCross(90, 20, 10, 10); DOG.deleteCanvas();
digitalWrite(LED_BUILTIN, HIGH); delay(500); digitalWrite(LED_BUILTIN, LOW); delay(500); // Read the voltage at the ADC pin int value = analogRead(VUSBPIN);
// Define a window around that value uint16_t lo = max(value - margin, 0); uint16_t hi = min(value + margin, UINT16_MAX);
LowPower.attachAdcInterrupt(VUSBPIN, adc_wakeup, ADC_INT_OUTSIDE, lo, hi);
LowPower.sleep();
LowPower.detachAdcInterrupt(); DOG.begin(17, 0, 0, 19, 18, DOGM128); //CS = 17, 0,0= use Hardware SPI, A0 = 19, RESET = 18, EA DOGM128-6 (=128x64 dots) }