Update main.py
change function ordering for better legibility
This commit is contained in:
parent
ad27c0f517
commit
f70e6d47a9
1 changed files with 13 additions and 13 deletions
|
|
@ -34,19 +34,6 @@ class MorseFlasher:
|
|||
pixels.fill((0,0,0))
|
||||
pixels.show()
|
||||
|
||||
def display(self, code=".-.-.- "):
|
||||
# iterate through morse code symbols
|
||||
for c in code:
|
||||
# show a dot
|
||||
if c == ".":
|
||||
self.showDot()
|
||||
# show a dash
|
||||
elif c == "-":
|
||||
self.showDash()
|
||||
# show a gap
|
||||
elif c == " ":
|
||||
time.sleep(character_gap)
|
||||
|
||||
def showDot(self):
|
||||
self.light(True)
|
||||
time.sleep(dot_length)
|
||||
|
|
@ -73,6 +60,19 @@ class MorseFlasher:
|
|||
#save complete morse code output to display
|
||||
self.display(output)
|
||||
|
||||
def display(self, code=".-.-.- "):
|
||||
# iterate through morse code symbols
|
||||
for c in code:
|
||||
# show a dot
|
||||
if c == ".":
|
||||
self.showDot()
|
||||
# show a dash
|
||||
elif c == "-":
|
||||
self.showDash()
|
||||
# show a gap
|
||||
elif c == " ":
|
||||
time.sleep(character_gap)
|
||||
|
||||
# Initialize NeoPixels
|
||||
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, auto_write=False)
|
||||
pixels.fill((0, 0, 0))
|
||||
|
|
|
|||
Loading…
Reference in a new issue