kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Inky Frame: Add wakeup SR to lib, fix wakeup bug.
rodzic
ba100ae069
commit
f1e9e00cd5
|
@ -41,10 +41,10 @@ namespace {
|
|||
|
||||
uint8_t state = 0u;
|
||||
for(auto i = 0u; i < 8; i++) {
|
||||
gpio_put(WAKEUP_SHIFT_REG_CLK, true);
|
||||
if(gpio_get(WAKEUP_SHIFT_REG_DATA)) {
|
||||
state |= (0b1 << i);
|
||||
}
|
||||
gpio_put(WAKEUP_SHIFT_REG_CLK, true);
|
||||
gpio_put(WAKEUP_SHIFT_REG_CLK, false);
|
||||
}
|
||||
shift_register_state = state;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from pimoroni import ShiftRegister
|
||||
from machine import Pin
|
||||
from wakeup import get_shift_state
|
||||
import time
|
||||
|
||||
|
||||
|
@ -13,10 +14,13 @@ LED_C = 13
|
|||
LED_D = 14
|
||||
LED_E = 15
|
||||
|
||||
SHIFT_STATE = get_shift_state()
|
||||
|
||||
|
||||
class Button:
|
||||
def __init__(self, sr, idx, led, debounce=50):
|
||||
self.sr = sr
|
||||
self.startup_state = bool(SHIFT_STATE & (1 << idx))
|
||||
self.led = Pin(led, Pin.OUT) # LEDs are just regular IOs
|
||||
self.led.off()
|
||||
self._idx = idx
|
||||
|
@ -33,6 +37,9 @@ class Button:
|
|||
return False
|
||||
|
||||
def raw(self):
|
||||
if self.startup_state:
|
||||
self.startup_state = False
|
||||
return True
|
||||
return self.sr[self._idx] == 1
|
||||
|
||||
@property
|
||||
|
|
Ładowanie…
Reference in New Issue