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

@ -33,19 +33,6 @@ class MorseFlasher:
else:
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)
@ -72,6 +59,19 @@ class MorseFlasher:
output += " "
#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)