Skip to content

Commit ec205fb

Browse files
authored
Merge pull request #775 from MichaelBell/cosmic-ghost-fix
Ghosting fix for Cosmic
2 parents 89699fd + 5b31e01 commit ec205fb

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

libraries/cosmic_unicorn/cosmic_unicorn.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
// for each row:
3232
// for each bcd frame:
3333
// 0: 00111111 // row pixel count (minus one)
34-
// 1 - 64: xxxxxbgr, xxxxxbgr, xxxxxbgr, ... // pixel data
35-
// 65 - 67: xxxxxxxx, xxxxxxxx, xxxxxxxx // dummy bytes to dword align
36-
// 68: xxxxrrrr // row select bits
37-
// 69 - 71: tttttttt, tttttttt, tttttttt // bcd tick count (0-65536)
34+
// 1: xxxxrrrr // row select bits
35+
// 2 - 65: xxxxxbgr, xxxxxbgr, xxxxxbgr, ... // pixel data
36+
// 66 - 67: xxxxxxxx, xxxxxxxx, // dummy bytes to dword align
37+
// 68 - 71: tttttttt, tttttttt, tttttttt // bcd tick count (0-65536)
3838
//
3939
// .. and back to the start
4040

@@ -154,13 +154,14 @@ namespace pimoroni {
154154
uint8_t *p = &bitstream[row * ROW_BYTES + (BCD_FRAME_BYTES * frame)];
155155

156156
p[ 0] = 64 - 1; // row pixel count
157-
p[68] = row; // row select
157+
p[ 1] = row; // row select
158158

159159
// set the number of bcd ticks for this frame
160160
uint32_t bcd_ticks = (1 << frame);
161-
p[69] = (bcd_ticks & 0xff) >> 0;
162-
p[70] = (bcd_ticks & 0xff00) >> 8;
163-
p[71] = (bcd_ticks & 0xff0000) >> 16;
161+
p[68] = (bcd_ticks & 0xff) >> 0;
162+
p[69] = (bcd_ticks & 0xff00) >> 8;
163+
p[70] = (bcd_ticks & 0xff0000) >> 16;
164+
p[71] = (bcd_ticks & 0xff000000) >> 24;
164165
}
165166
}
166167

@@ -491,7 +492,7 @@ namespace pimoroni {
491492

492493
// set the appropriate bits in the separate bcd frames
493494
for(uint8_t frame = 0; frame < BCD_FRAME_COUNT; frame++) {
494-
uint8_t *p = &bitstream[y * ROW_BYTES + (BCD_FRAME_BYTES * frame) + 1 + x];
495+
uint8_t *p = &bitstream[y * ROW_BYTES + (BCD_FRAME_BYTES * frame) + 2 + x];
495496

496497
uint8_t red_bit = gamma_r & 0b1;
497498
uint8_t green_bit = gamma_g & 0b1;

libraries/cosmic_unicorn/cosmic_unicorn.pio

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
; for each row:
2222
; for each bcd frame:
2323
; 0: 00111111 // row pixel count (minus one)
24-
; 1 - 64: xxxxxbgr, xxxxxbgr, xxxxxbgr, ... // pixel data
25-
; 65 - 67: xxxxxxxx, xxxxxxxx, xxxxxxxx // dummy bytes to dword align
26-
; 68: xxxxrrrr // row select bits
27-
; 69 - 71: tttttttt, tttttttt, tttttttt // bcd tick count (0-65536)
24+
; 1: xxxxrrrr // row select bits
25+
; 2 - 65: xxxxxbgr, xxxxxbgr, xxxxxbgr, ... // pixel data
26+
; 66 - 67: xxxxxxxx, xxxxxxxx // dummy bytes to dword align
27+
; 68 - 71: tttttttt, tttttttt, tttttttt // bcd tick count (0-65536)
2828
;
2929
; .. and back to the start
3030

@@ -33,6 +33,7 @@
3333

3434
; loop over row pixels
3535
out y, 8 ; get row pixel count (minus 1 because test is pre decrement)
36+
out pins, 8 ; output row select
3637
pixels:
3738

3839
; red bit
@@ -63,15 +64,13 @@ pixels:
6364

6465
jmp y-- pixels
6566

66-
out null, 24 ; discard dummy bytes
67-
68-
out pins, 8 ; output row select
67+
out null, 16 ; discard dummy bytes
6968

7069
set pins, 0b110 [5] ; latch high, blank high
7170
set pins, 0b000 ; blank low (enable output)
7271

7372
; loop over bcd delay period
74-
out y, 24 ; get bcd delay counter value
73+
out y, 32 ; get bcd delay counter value
7574
bcd_delay:
7675
jmp y-- bcd_delay
7776

0 commit comments

Comments
 (0)