Skip to content

Commit d692ddf

Browse files
committed
tweak timings of ip address flash and add option to only flash last section
1 parent e6dc2d8 commit d692ddf

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

gurgleapps_webserver.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,22 +250,22 @@ def get_content_type(self,file_path):
250250
}
251251
return content_type_map.get(extension, 'text/plain')
252252

253-
# long pause for dots 3quick blinks for zero 2 quick for a dot
254-
async def blink_ip(self, led_pin, ip = None, repeat=2, delay_between_digits=0.8):
253+
# long pause for dots 4 quick blinks for zero 2 quick for a dot
254+
async def blink_ip(self, led_pin, ip = None, repeat=2, delay_between_digits=0.9, last_only = False):
255255
delay_between_repititions = 2
256256
if ip == None:
257257
ip = self.ip_address
258258
print("blink_ip: " + str(ip))
259259

260-
def blink_element(element, pin, duration=0.2):
260+
def blink_element(element, pin, duration=0.27):
261261
if element == '-':
262262
blinks = 9
263263
duration = 0.1
264264
elif element == '.':
265265
blinks = 2
266266
duration = 0.1
267267
elif element == 0:
268-
blinks = 3
268+
blinks = 4
269269
duration = 0.1
270270
else:
271271
blinks = element
@@ -277,7 +277,11 @@ def blink_element(element, pin, duration=0.2):
277277
time.sleep(duration)
278278

279279
ip_digits_and_dots = []
280-
for part in ip.split('.'):
280+
ip_parts = ip.split('.')
281+
if last_only:
282+
ip_parts = [ip_parts[-1]] # Only blink the last part of the IP address
283+
284+
for part in ip_parts:
281285
for digit in part:
282286
ip_digits_and_dots.append(int(digit))
283287
ip_digits_and_dots.append('.') # Add a dot to the list to represent the separator

main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,16 @@ async def background_task():
8787

8888

8989
async def run():
90-
await(server.blink_ip(led_pin=led))
90+
#await(server.blink_ip(led_pin=led))
91+
await(server.blink_ip(led_pin = led, last_only = True))
9192
await asyncio.gather(main(), background_task())
9293

9394
server = GurgleAppsWebserver(config.WIFI_SSID, config.WIFI_PASSWORD, port=80, timeout=20, doc_root="/www", log_level=2)
9495
server.add_function_route("/set-delay/<delay>", set_delay)
95-
server.add_function_route("/set-blink-pattern/<on_time>/<off_time>", set_blink_pattern)
96+
server.add_function_route(
97+
"/set-blink-pattern/<on_time>/<off_time>",
98+
set_blink_pattern
99+
)
96100
server.add_function_route("/stop", stop_flashing)
97101
server.add_function_route("/start", start_flashing)
98102
server.add_function_route("/status", send_status)

0 commit comments

Comments
 (0)