Skip to content

Commit

Permalink
Merge pull request #775 from MichaelBell/cosmic-ghost-fix
Browse files Browse the repository at this point in the history
Ghosting fix for Cosmic
  • Loading branch information
Gadgetoid authored May 12, 2023
2 parents 89699fd + 5b31e01 commit ec205fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
19 changes: 10 additions & 9 deletions libraries/cosmic_unicorn/cosmic_unicorn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
// for each row:
// for each bcd frame:
// 0: 00111111 // row pixel count (minus one)
// 1 - 64: xxxxxbgr, xxxxxbgr, xxxxxbgr, ... // pixel data
// 65 - 67: xxxxxxxx, xxxxxxxx, xxxxxxxx // dummy bytes to dword align
// 68: xxxxrrrr // row select bits
// 69 - 71: tttttttt, tttttttt, tttttttt // bcd tick count (0-65536)
// 1: xxxxrrrr // row select bits
// 2 - 65: xxxxxbgr, xxxxxbgr, xxxxxbgr, ... // pixel data
// 66 - 67: xxxxxxxx, xxxxxxxx, // dummy bytes to dword align
// 68 - 71: tttttttt, tttttttt, tttttttt // bcd tick count (0-65536)
//
// .. and back to the start

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

p[ 0] = 64 - 1; // row pixel count
p[68] = row; // row select
p[ 1] = row; // row select

// set the number of bcd ticks for this frame
uint32_t bcd_ticks = (1 << frame);
p[69] = (bcd_ticks & 0xff) >> 0;
p[70] = (bcd_ticks & 0xff00) >> 8;
p[71] = (bcd_ticks & 0xff0000) >> 16;
p[68] = (bcd_ticks & 0xff) >> 0;
p[69] = (bcd_ticks & 0xff00) >> 8;
p[70] = (bcd_ticks & 0xff0000) >> 16;
p[71] = (bcd_ticks & 0xff000000) >> 24;
}
}

Expand Down Expand Up @@ -491,7 +492,7 @@ namespace pimoroni {

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

uint8_t red_bit = gamma_r & 0b1;
uint8_t green_bit = gamma_g & 0b1;
Expand Down
15 changes: 7 additions & 8 deletions libraries/cosmic_unicorn/cosmic_unicorn.pio
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
; for each row:
; for each bcd frame:
; 0: 00111111 // row pixel count (minus one)
; 1 - 64: xxxxxbgr, xxxxxbgr, xxxxxbgr, ... // pixel data
; 65 - 67: xxxxxxxx, xxxxxxxx, xxxxxxxx // dummy bytes to dword align
; 68: xxxxrrrr // row select bits
; 69 - 71: tttttttt, tttttttt, tttttttt // bcd tick count (0-65536)
; 1: xxxxrrrr // row select bits
; 2 - 65: xxxxxbgr, xxxxxbgr, xxxxxbgr, ... // pixel data
; 66 - 67: xxxxxxxx, xxxxxxxx // dummy bytes to dword align
; 68 - 71: tttttttt, tttttttt, tttttttt // bcd tick count (0-65536)
;
; .. and back to the start

Expand All @@ -33,6 +33,7 @@

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

; red bit
Expand Down Expand Up @@ -63,15 +64,13 @@ pixels:

jmp y-- pixels

out null, 24 ; discard dummy bytes

out pins, 8 ; output row select
out null, 16 ; discard dummy bytes

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

; loop over bcd delay period
out y, 24 ; get bcd delay counter value
out y, 32 ; get bcd delay counter value
bcd_delay:
jmp y-- bcd_delay

Expand Down

0 comments on commit ec205fb

Please sign in to comment.