Torch/Beacon (with keydown)
Choice of Blink/Steady Choice of White/Red/Green/Blue/dimred
Use can have medical or legal consequences, liability not accepted
"""Torch (Torch with buttons) This version is suitable for devices with keydown such as Numworks on Chromebook Cursor keys: Select colour EXE/ENTER: Spare SHIFT: BLINK/Beacon Tab(TOOLBOX): OFF Responsiveness to keys depends on blink time """ __version__="0.1" #try: from ion import * from kandinsky import * from math import * from time import * #except: # print("may be useful in a powercut") #screensize (317*191) common, (320*240) some w=317 h=191 h=320-1 h=240-1 #customise ask=False #ask for info 1st (else use defaults) show=True #show keyboard instructions #blinking blinking=False blink1=1 #each blink sleep dimred=[128,0,0] #preserves night vision colors=["white","red","green","blue",dimred] color="white" #default until asked #end custom crid="Torch\n© 2024 SteveG1CMZ" def about(): print("Use can have medical or legal consequences") print("Liability disclaimed") if __name__=="__main__" or True: print(crid) if show: print("Esc/BACK: OFF") #interrupts print("tab/TOOLBOX: OFF") print("SHIFT: Blink/Beacon") print("Cursors: Colour") sleep(2*blink1) if ask: #only used on platforms without keydown pass fill_rect(0,0,w,h,color) draw_string("SHIFT:Blink Cursor: Colour \nTab: OFF",0,0) t0=monotonic() goon=True st="momentarily" #until time acquired while goon: if keydown(KEY_TOOLBOX): print(crid) print(st) goon=False if keydown(KEY_LEFT): color="white" if keydown(KEY_RIGHT): #if your priority is dimred, swap these around if color=="red": color=dimred #toggle else: color="red" if keydown(KEY_UP): color="blue" if keydown(KEY_DOWN): color="green" if keydown(KEY_SHIFT): blinking=not(blinking) #toggle fill_rect(0,0,w,h,color) t=int(monotonic()-t0) mins=floor(t/60) hrs=floor(mins/60) #dont use h st=str(t)+" s\n"+str(mins)+"\n"+str(hrs)+" h" draw_string(st,0,0) sleep(blink1) if blinking: fill_rect(0,0,w,h,"black") sleep(1) fill_rect(0,0,w,h,"black") draw_string(crid+"\nUsed longer than: \n"+st,0,0)