]>
git.zerfleddert.de Git - fnordlicht-mini/blob - firmware/tests/lib/fnordlicht.rb
10 def fade_rgb(addr
, r
, g
, b
, step
, delay
)
18 $dev.write
"\x00\x00\x00\x00\x00"
19 $dev.write
"\x00\x00\x00"
23 def fade_hsv(addr
, h
, s
, v
, step
, delay
)
28 $dev.write
[h
].pack('v')
31 $dev.write
"\x00\x00\x00\x00\x00"
36 def save_rgb(addr
, slot
, r
, g
, b
, step
, delay
, pause
)
42 $dev.write
[pause
].pack('S')
46 $dev.write
"\x00\x00\x00\x00\x00"
50 def save_hsv(addr
, slot
, h
, s
, v
, step
, delay
, pause
)
56 $dev.write
[pause
].pack('S')
57 $dev.write
[h
].pack('v')
60 $dev.write
"\x00\x00\x00\x00"
64 def save_current(addr
, slot
, step
, delay
, pause
)
70 $dev.write
[pause
].pack('S')
71 $dev.write
"\x00\x00\x00\x00"
72 $dev.write
"\x00\x00\x00\x00"
76 def config_offsets(addr
, step
, delay
, h
, s
, v
)
79 $dev.write
[step
].pack('c')
80 $dev.write
[delay
].pack('c')
81 $dev.write
[h
].pack('v')
84 $dev.write
"\x00\x00\x00\x00\x00\x00\x00"
88 def start_program(addr
, program
, params
)
91 $dev.write program
.chr
92 rest
= 12-params
.length
93 puts
"rest: %u" % rest
if $verbose
103 def stop(addr
, fading
= 1)
106 $dev.write fading
.chr
107 $dev.write
"\x00\x00\x00\x00"
108 $dev.write
"\x00\x00\x00\x00\x00"
109 $dev.write
"\x00\x00\x00"
113 def modify_current(addr
, step
, delay
, r
, g
, b
, h
, s
, v
)
118 $dev.write
[r
].pack('c')
119 $dev.write
[g
].pack('c')
120 $dev.write
[b
].pack('c')
121 $dev.write
[h
].pack('v')
122 $dev.write
[s
].pack('c')
123 $dev.write
[v
].pack('c')
124 $dev.write
"\x00\x00\x00\x00"
128 def pull_int(addr
, delay
)
133 $dev.write
"\x00\x00"
134 $dev.write
"\x00\x00\x00\x00\x00"
135 $dev.write
"\x00\x00\x00\x00\x00"
139 def config_startup_nothing(addr
)
140 mode
= 0 # do nothing
146 $dev.write
"\x00\x00"
147 $dev.write
"\x00\x00\x00\x00\x00"
148 $dev.write
"\x00\x00\x00\x00\x00"
152 def config_startup_program(addr
, program
, params
)
153 mode
= 1 # start program
158 $dev.write program
.chr
160 rest
= 11-params
.length
161 puts
"rest: %u" % rest
if $verbose
174 $dev.write("\x00"*13)
178 # secondary functions
179 def fade_updown_rgb(addr
, r
, g
, b
, step
, delay
, sleep_time
)
180 fade_rgb(addr
, r
, g
, b
, step
, delay
)
182 fade_rgb(addr
, 0, 0, 0, step
, delay
)
186 def fade_updown_hsv(addr
, h
, s
, v
, step
, delay
, sleep_time
)
187 fade_hsv(addr
, h
, s
, v
, step
, delay
)
189 fade_hsv(addr
, h
, s
, 0, step
, delay
)
193 # bootloader functions
194 def start_bootloader(addr
)
197 $dev.write("\x6b\x56\x27\xfc")
198 $dev.write("\x00\x00\x00\x00\x00\x00\x00\x00\x00")
202 def boot_config(addr
, start_addr
)
205 $dev.write
[start_addr
].pack('v')
206 $dev.write("\x00"*11)
213 $dev.write("\xff" * 13)
217 def boot_data(addr
, data)
221 # just write the first 13 bytes
225 $dev.write("\xff" * (13-data.length
))
229 def boot_crc_check(addr
, len
, checksum
, delay
)
232 $dev.write
[len
].pack('v')
233 $dev.write
[checksum
].pack('v')
239 def boot_crc_flash(addr
, start
, len
, checksum
, delay
)
242 $dev.write
[start
].pack('v')
243 $dev.write
[len
].pack('v')
244 $dev.write
[checksum
].pack('v')
253 $dev.write("\x00"*13)
257 def boot_enter_application(addr
)
260 $dev.write("\x00"*13)