-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from emfcamp/thinkl33t/disable_patterns
Add events to enable / disable the pattern generator
- Loading branch information
Showing
4 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import asyncio | ||
import app | ||
|
||
from events.input import Buttons, BUTTON_TYPES | ||
from system.eventbus import eventbus | ||
from system.patterndisplay.events import * | ||
|
||
from tildagonos import tildagonos | ||
|
||
|
||
class PatternInhibit(app.App): | ||
def __init__(self): | ||
self.button_states = Buttons(self) | ||
eventbus.emit(PatternDisable()) | ||
self._make_red() | ||
self._inhibiting = True | ||
|
||
def _make_red(self): | ||
asyncio.sleep(0.5) | ||
for i in range(1, 13): | ||
tildagonos.leds[i] = (int(i * (255/12)), 0, 0) | ||
tildagonos.leds.write() | ||
|
||
def update(self, delta): | ||
if self.button_states.get(BUTTON_TYPES["CANCEL"]): | ||
eventbus.emit(PatternDisable()) | ||
self._inhibiting = True | ||
self._make_red() | ||
elif self.button_states.get(BUTTON_TYPES["CONFIRM"]): | ||
eventbus.emit(PatternEnable()) | ||
self._inhibiting = False | ||
|
||
def draw(self, ctx): | ||
ctx.save() | ||
ctx.font_size = 20 | ||
ctx.text_align = ctx.CENTER | ||
ctx.text_baseline = ctx.MIDDLE | ||
if self._inhibiting: | ||
ctx.rgb(0.2, 0, 0).rectangle(-120, -120, 240, 240).fill() | ||
ctx.rgb(1, 0, 0).move_to(0, 0).text("Inhibiting LEDs") | ||
else: | ||
ctx.rgb(0, 0.2, 0).rectangle(-120, -120, 240, 240).fill() | ||
ctx.rgb(0, 1, 0).move_to(0, 0).text("Not Inhibiting LEDs") | ||
ctx.restore() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from events import Event | ||
|
||
|
||
class PatternEnable(Event): ... | ||
|
||
|
||
class PatternDisable(Event): ... |