Skip to content

Commit e6dc2d8

Browse files
committed
9 flashes on end of showing up
1 parent c1ab184 commit e6dc2d8

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

gurgleapps_webserver.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -251,32 +251,42 @@ def get_content_type(self,file_path):
251251
return content_type_map.get(extension, 'text/plain')
252252

253253
# long pause for dots 3quick blinks for zero 2 quick for a dot
254-
async def blink_ip(self, led_pin, repeat=2, delay_between_digits=0.5):
254+
async def blink_ip(self, led_pin, ip = None, repeat=2, delay_between_digits=0.8):
255255
delay_between_repititions = 2
256-
print("blink_ip: "+str(self.ip_address))
257-
def blink_number(number, pin, duration=0.2):
258-
if number == 0:
256+
if ip == None:
257+
ip = self.ip_address
258+
print("blink_ip: " + str(ip))
259+
260+
def blink_element(element, pin, duration=0.2):
261+
if element == '-':
262+
blinks = 9
263+
duration = 0.1
264+
elif element == '.':
265+
blinks = 2
266+
duration = 0.1
267+
elif element == 0:
259268
blinks = 3
260269
duration = 0.1
261270
else:
262-
blinks = number
271+
blinks = element
272+
263273
for _ in range(blinks):
264274
pin.on()
265275
time.sleep(duration)
266276
pin.off()
267277
time.sleep(duration)
268278

269279
ip_digits_and_dots = []
270-
for part in self.ip_address.split('.'):
280+
for part in ip.split('.'):
271281
for digit in part:
272282
ip_digits_and_dots.append(int(digit))
273283
ip_digits_and_dots.append('.') # Add a dot to the list to represent the separator
284+
ip_digits_and_dots.pop() # Remove the last dot
285+
ip_digits_and_dots.append('-') # Add a dash to the list to represent the end of the IP address
274286

275287
for _ in range(repeat):
276288
for element in ip_digits_and_dots:
277-
if element == '.':
278-
await asyncio.sleep(2 * delay_between_digits) # Longer pause for the dot
279-
else:
280-
blink_number(element, led_pin)
281-
await asyncio.sleep(delay_between_digits)
289+
blink_element(element, led_pin)
290+
await asyncio.sleep(delay_between_digits if element != '.' else 2 * delay_between_digits)
282291
await asyncio.sleep(delay_between_repititions)
292+

0 commit comments

Comments
 (0)