Skip to content

Crash after low power adc sleep #6

@Wer-Wolf

Description

@Wer-Wolf

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 <ArduinoLowPower.h>
#include <DogGraphicDisplay.h>

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)
}

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions