Pico fixes
This commit is contained in:
@@ -57,6 +57,7 @@ def refresh_display(message=None):
|
||||
DISPLAY.text(rating_text, 60, 30)
|
||||
|
||||
DISPLAY.show()
|
||||
print("Updating screen.")
|
||||
|
||||
# initialize a specific Pin as Input with a pull-down resistor
|
||||
def initialize_pin(pin_number:int):
|
||||
@@ -66,6 +67,9 @@ def initialize_pin(pin_number:int):
|
||||
# Hardware Interrupt: rate button is pressed
|
||||
def rate_button_pressed(pin:Pin) -> None:
|
||||
global pending_rate_button, last_interrupt_time
|
||||
|
||||
print("rate button pressed:", pin)
|
||||
|
||||
|
||||
current_time = time.ticks_ms()
|
||||
# Simple software debounce
|
||||
@@ -80,6 +84,8 @@ def rate_button_pressed(pin:Pin) -> None:
|
||||
# Hardware Interrupt: Send/Confirm button is pressed
|
||||
def sendButton_pressed(pin:Pin) -> None:
|
||||
global pending_send_button, last_interrupt_time
|
||||
|
||||
print("send button pressed:", pin)
|
||||
|
||||
current_time = time.ticks_ms()
|
||||
if time.ticks_diff(current_time, last_interrupt_time) > DEBOUNCE_MS:
|
||||
@@ -89,6 +95,7 @@ def sendButton_pressed(pin:Pin) -> None:
|
||||
# Process the rate button press (Called from the main loop)
|
||||
def process_rate_button(button_index: int):
|
||||
global USER_ID, RATING, CURRENT_STATE
|
||||
|
||||
|
||||
if CURRENT_STATE == STATE_USER_ID:
|
||||
bit_pos = 4 - button_index
|
||||
@@ -126,6 +133,7 @@ def process_send_button():
|
||||
refresh_display("Success")
|
||||
else:
|
||||
refresh_display("Error")
|
||||
print("Error sending rating.")
|
||||
|
||||
time.sleep(3) # Display status for 3 seconds
|
||||
|
||||
@@ -146,6 +154,7 @@ def start_rating(rate_button_pins:list, button_send_pin:int, oled_display=None)
|
||||
RATE_BUTTONS = []
|
||||
for pin_num in rate_button_pins:
|
||||
button = initialize_pin(pin_num)
|
||||
print("Setting up pin:", pin_num)
|
||||
button.irq(trigger=Pin.IRQ_RISING, handler=rate_button_pressed)
|
||||
RATE_BUTTONS.append(button)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user