[WelcomeScreen.py] Added support for interrupting while cycling
This commit is contained in:
parent
e5f45ff593
commit
12e8fa43ab
@ -37,6 +37,7 @@ class WelcomeScreen:
|
||||
self.lines = self.lcd.num_lines
|
||||
|
||||
self.interrupt_pins = interrupt_pins
|
||||
|
||||
self.subtitle = subtitle
|
||||
self.starting_msg = starting_msg
|
||||
self.started_msg = started_msg
|
||||
@ -71,6 +72,13 @@ class WelcomeScreen:
|
||||
self.lcd.move_to(0,4)
|
||||
self.lcd.putstr(padding_hyphen)
|
||||
|
||||
# get the current pin values (only if there are pins specified) (when something changes, the interrupt happens and the cycle stops)
|
||||
if self.interrupt_pins:
|
||||
break_flag = False
|
||||
pin_values = []
|
||||
for p in self.interrupt_pins:
|
||||
pin_values.append(p.value())
|
||||
# cycle the text 'cycles' times and listen for changes on interrupt pins (if any given)
|
||||
for i in range(cycles):
|
||||
line1 = padding + self.starting_msg + padding
|
||||
line2 = self.subtitle.center(self.columns)
|
||||
@ -80,6 +88,12 @@ class WelcomeScreen:
|
||||
self.lcd.move_to(0,y_offset+1)
|
||||
self.lcd.putstr(line2[0:self.columns])
|
||||
line1 = line1[1:]
|
||||
if self.interrupt_pins:
|
||||
for i, p in enumerate(self.interrupt_pins):
|
||||
if pin_values[i] != p.value():
|
||||
break_flag = True
|
||||
if break_flag:
|
||||
break
|
||||
|
||||
self.lcd.move_to(0,y_offset)
|
||||
self.lcd.putstr(self.started_msg.center(16))
|
||||
|
Loading…
Reference in New Issue
Block a user