todbot / blink1-tool

Command-line tools and C library for blink(1) USB RGB LED
https://blink1.thingm.com/
Other
84 stars 15 forks source link

Fixed LED selection problem in blink1-tool --writepattern #45

Closed ChrMa closed 3 years ago

ChrMa commented 3 years ago

To recreate the problem, I first clear the pattern memory

$ blink1-tool --clearpattern
clearing pattern...done
$ blink1-tool --readpattern
read pattern:
{0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0}

Then I add a short pattern which includes selecting individual LEDs.

$ blink1-tool --writepattern 0,#ff0000,2,1,#00ff00,2,2,#0000ff,2,0
write pattern: 0,#ff0000,2,1,#00ff00,2,2,#0000ff,2,0
writing line 0: ff,00,00 : 2000 : 1
writing line 1: 00,ff,00 : 2000 : 2
writing line 2: 00,00,ff : 2000 : 0

However when I read back the pattern, the entry number 2 is incorrectly addressing LED 2 instead of LED 0 (i.e. both LEDs)

$ blink1-tool --readpattern
read pattern:
{0,#ff0000,1.00,1,#00ff00,1.00,2,#0000ff,1.00,2,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0}
$ blink1-tool --getpattline 2
reading rgb at pos  2: r,g,b = 0x00,0x00,0xff (2) ms:1000

Doing the same test with my proposed change yields the expected result:

$ blink1-tool --readpattern
read pattern:
{0,#ff0000,1.00,1,#00ff00,1.00,2,#0000ff,1.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0,#000000,0.00,0}
$ blink1-tool --getpattline 2
reading rgb at pos  2: r,g,b = 0x00,0x00,0xff (0) ms:1000
todbot commented 3 years ago

Looks good to me. Thanks!