Update main.py

change function ordering for better legibility
This commit is contained in:
Collin Cunningham 2017-12-18 23:45:25 -05:00 committed by GitHub
parent ad27c0f517
commit f70e6d47a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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))