Skip to content

Commit 2fe4050

Browse files
committed
Handle LSB and MSB rows
1 parent ecd0e28 commit 2fe4050

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

src/dmd_interface_whitestar.pio

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
; Send using an external clock on the SPI interface
1212

13-
; initialize y with 4096 = number of pixels (128x32)
13+
; initialize y with 8192 = number of pixels ((128 x LSB + 128 x MSB) x 32)
1414
set x, 1
1515
in x, 1
16-
in null, 13
16+
in null, 14
1717
mov y, isr
1818

1919
.wrap_target
@@ -24,39 +24,27 @@
2424
irq clear 4
2525
wait irq 4
2626

27+
wait 1 gpio RDATA ; raising edge indicates a new frame
2728

28-
; this is the loop for the most significant bit
29-
dotloop1:
29+
dotloop:
3030
wait 0 gpio DOTCLK ; falling edge
31+
in null 1 ; left padding
3132
wait 1 gpio DOTCLK ; raising edge
3233
in pins 1 ; read pin data
33-
in null 1 ; right padding
34-
jmp x-- dotloop1
34+
jmp x-- dotloop
3535

3636
mov x, y ; load number of pixels
3737
mov isr, null ; reset shift counter
3838

39-
; There's an empty line between LSB and HSB plane
40-
wait 0 gpio RCLK
41-
wait 1 gpio RCLK
42-
43-
; this is the loop for the least significant bit
44-
; in this loop, the bit value is multipled by 2 by shiting it one bit
45-
dotloop2:
46-
wait 0 gpio DOTCLK ; falling edge
47-
in null 1 ; left padding
48-
wait 1 gpio DOTCLK ; raising edge
49-
in pins 1 ; read pin data
50-
jmp x-- dotloop2
51-
52-
39+
; There's an empty row with 256 gots at the end of a frame.
40+
; it is ignored because we already read the specified amount of dots and now wait for a new frame.
5341
.wrap
5442

5543
.program dmd_framedetect_whitestar
5644

5745
.wrap_target
5846

59-
; synchronize on the least significant plane
47+
; synchronize on a new frame
6048
wait 0 gpio RDATA
6149
wait 1 gpio RDATA
6250
irq 4
@@ -109,4 +97,4 @@ static inline void dmd_framedetect_whitestar_program_init(PIO pio, uint sm, uint
10997
// Load our configuration, do not yet start the program
11098
pio_sm_init(pio, sm, offset, &c);
11199
}
112-
%}
100+
%}

src/dmd_reader.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ typedef struct __attribute__((__packed__)) block_pix_crc_header_t
102102
#define LINEOVERSAMPLING_4X 4
103103

104104
// Merging multiple planes
105+
#define MERGEPLANES_NONE 0
105106
#define MERGEPLANES_ADD 0
106107
#define MERGEPLANES_ADDSHIFT 1
107108

@@ -495,7 +496,7 @@ void dmd_dma_handler() {
495496

496497
for (int l=0; l<lcd_height; l++) {
497498
for (int w=0; w<lcd_wordsperline; w++) {
498-
v = (src1[w] + src2[w]) >> 1;
499+
v = src1[w] + src2[w]*2;
499500
dst[w]=v;
500501
}
501502
src1 += lcd_wordsperline*2; // source skips 2 lines forward
@@ -597,9 +598,9 @@ bool init()
597598
lcd_height = 32;
598599
lcd_bitsperpixel = 2; // Whitestar is 2bpp
599600
lcd_pixelsperbyte = 8 / lcd_bitsperpixel;
600-
lcd_planesperframe = 2; // in Whitestar, there's a MSB and a LSB plane
601+
lcd_planesperframe = 1; // in Whitestar, there's only one plane, containg one LSB row followed by one MSB row and so on
601602
lcd_lineoversampling = LINEOVERSAMPLING_2X; // in Whitestar each line is sent twice
602-
lcd_mergeplanes = MERGEPLANES_ADD; // Shifting happen in pio code
603+
lcd_mergeplanes = MERGEPLANES_NONE;
603604
} else if (dmd_type == DMD_SPIKE1) {
604605
dmd_pio = pio0;
605606
offset = pio_add_program(dmd_pio, &dmd_reader_spike_program);

0 commit comments

Comments
 (0)