Skip to content

Commit 8405415

Browse files
committed
Add ability to flash LED at a particular TC, rather than every second
``` # example for 'flashtime' in the future xc = timecode() xc.fps = eng.tc.fps xc.from_raw(eng.tc.to_raw()) # note: this has DF flag included for i in range(69): xc.next_frame() eng.flashframe = -1 # turn off the 1pps flash eng.set_flashtime(xc) print(eng.tc.to_ascii(), xc.to_ascii()) ```
1 parent 96290e5 commit 8405415

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

pico_timecode.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ class engine(object):
702702
def __init__(self):
703703
self.mode = RUN
704704
self.flashframe = 0
705+
self.flashtime = 0 # 'raw' TC
705706
self.dlock = _thread.allocate_lock()
706707

707708
self.tc = timecode()
@@ -871,6 +872,12 @@ def micro_adjust(self, duty, period=0):
871872
self.timer1 = Timer()
872873
self.timer1.init(period=self.period - part, mode=Timer.ONE_SHOT, callback=timer_sched)
873874

875+
876+
def set_flashtime(self, ft):
877+
self.dlock.acquire()
878+
self.flashtime = (ft.df << 31) + (ft.hh << 24) + (ft.mm << 16) + (ft.ss << 8) + ft.ff
879+
self.dlock.release()
880+
874881
#-------------------------------------------------------
875882

876883
def pico_timecode_thread(eng, stop):
@@ -972,10 +979,16 @@ def pico_timecode_thread(eng, stop):
972979

973980
# Does the LED flash for this frame?
974981
eng.tc.acquire()
975-
if eng.tc.ff == eng.flashframe:
976-
eng.sm[1].put((210 << 16)+ 509) # '209' duration of flash
982+
if eng.flashframe >= 0:
983+
if eng.tc.ff == eng.flashframe:
984+
eng.sm[1].put((210 << 16)+ 509) # '209' duration of flash
985+
else:
986+
eng.sm[1].put(509) # '509' is complete cycle length
977987
else:
978-
eng.sm[1].put(509) # '509' is complete cycle length
988+
if eng.raw1 == eng.flashtime:
989+
eng.sm[1].put((210 << 16)+ 509) # '209' duration of flash
990+
else:
991+
eng.sm[1].put(509) # '509' is complete cycle length
979992
eng.tc.release()
980993

981994
if not start_sent:

0 commit comments

Comments
 (0)