I'll do some more tests but here is a quick result, wake up tested on pin 9. I use the test sketch at the end of this post. To wake up the device, I pull INT1 to ground.
- When the Z-Uno goes to sleep, state is preserved.
- When the Z-Uno wakes up, the pin goes to weak pull-up mode after some time. I did a quick test and from triggering INT to pull-up was about 20 ms
- Then your setup routine runs, so it depends on where and when you set the pin state of the device... Then it goes back to the state you want. But there is always a short delay, so it will always "flap" as you call it.
For Example, In my test sketch, it takes 7 seconds before I drive the test pin high. There is a 1k resistor from pin 9 to GND, so this pulls the pin low even when there is a weak pull-up. This is the result on my logic analyzer:
Top = pin 9
Bottom = INT1 (wake up trigger)
EDIT: I am unable to attach 2 pictures... Oh. Well. You just see pin 9 is low for 7 seconds after wake up.
If I zoom in, you can see when the pin goes to pull-up after waking up:
- WakeUpZoom.png (4.62 KiB) Viewed 7359 times
Code: Select all
/*
// WAKEUP REASONS, number of blinks
1 ZUNO_WAKEUP_REASON_HARDRESET
2 ZUNO_WAKEUP_REASON_WUT,
3 ZUNO_WAKEUP_REASON_RADIO,
4 ZUNO_WAKEUP_REASON_SOFTRESET,
5 ZUNO_WAKEUP_REASON_INT1,
6 ZUNO_WAKEUP_REASON_POR,
7 ZUNO_WAKEUP_REASON_USBSUSPEND
*/
#define TEST_PIN 9
int BlinkCount;
void setup() {
delay(1500);
BlinkCount = zunoGetWakeReason() + 1;
while (BlinkCount != 0) {
BlinkCount--;
digitalWrite(LED_BUILTIN, 1);
delay(50);
digitalWrite(LED_BUILTIN, 0);
delay(750);
}
delay(1500);
pinMode(TEST_PIN, OUTPUT);
digitalWrite(TEST_PIN, 1);
}
void loop() {
BlinkCount = 5;
while (BlinkCount != 0) {
BlinkCount--;
digitalWrite(LED_BUILTIN, 1);
delay(1500);
digitalWrite(LED_BUILTIN, 0);
delay(1500);
}
BlinkCount = 10;
while (BlinkCount != 0) {
BlinkCount--;
digitalWrite(LED_BUILTIN, 1);
delay(50);
digitalWrite(LED_BUILTIN, 0);
delay(50);
}
zunoSendDeviceToSleep();
}
void setter(uint8_t value) {
}
uint8_t getter() {
return 42;
}
// Set Sleeping Mode to ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE = FLiRS
ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE);
// Set Channel to either Siren of Flowstop for FLiRS
//ZUNO_SETUP_CHANNELS(ZUNO_SIREN(getter, setter));
ZUNO_SETUP_CHANNELS(ZUNO_FLOWSTOP(getter, setter));