Skip to content

Commit e51c4aa

Browse files
committed
Merge branch 'whitestar_testing' into patch-1
2 parents 9172a26 + 0b6b0cb commit e51c4aa

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

src/dmd_interface_whitestar.pio

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

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

13-
; initialize y with 8192 = number of pixels (128x32x2)
13+
; initialize y with 8192 = number of pixels ((128 x LSB + 128 x MSB) x 32)
1414
set x, 1
1515
in x, 1
1616
in null, 14
@@ -24,26 +24,28 @@
2424
irq clear 4
2525
wait irq 4
2626

27+
wait 1 gpio RDATA ; raising edge indicates a new frame
28+
2729
dotloop:
2830
wait 0 gpio DOTCLK ; falling edge
31+
in null 1 ; left padding
2932
wait 1 gpio DOTCLK ; raising edge
30-
in null 1 ; pad with a zero
31-
in pins 1 ; right padding
32-
33-
33+
in pins 1 ; read pin data
3434
jmp x-- dotloop
3535

36-
; There's an empty line between LSB and HSB plane
37-
wait 1 gpio RDATA
36+
;mov x, y ; load number of pixels
37+
;mov isr, null ; reset shift counter
3838

3939

40+
; There's an empty row with 256 gots at the end of a frame.
41+
; it is ignored because we already read the specified amount of dots and now wait for a new frame.
4042
.wrap
4143

4244
.program dmd_framedetect_whitestar
4345

4446
.wrap_target
4547

46-
; synchronize on the least significant plane
48+
; synchronize on a new frame
4749
wait 0 gpio RDATA
4850
wait 1 gpio RDATA
4951
irq 4
@@ -59,11 +61,11 @@ static inline void dmd_reader_whitestar_program_init(PIO pio, uint sm, uint offs
5961
sm_config_set_in_pins(&c, 2); // SDATA
6062

6163
// Set the pin direction at the PIO
62-
pio_sm_set_consecutive_pindirs(pio, sm, 5, 1, false); // RCLK
64+
pio_sm_set_consecutive_pindirs(pio, sm, 6, 1, false); // RDATA
6365
pio_sm_set_consecutive_pindirs(pio, sm, 2, 2, false); // SDATA, DOTCLK
6466

6567
// Connect these GPIOs to this PIO block
66-
pio_gpio_init(pio, 5); // RCLK
68+
pio_gpio_init(pio, 6); // RDATA
6769
pio_gpio_init(pio, 3); // DOTCLK
6870
pio_gpio_init(pio, 2); // SDATA
6971

@@ -96,4 +98,4 @@ static inline void dmd_framedetect_whitestar_program_init(PIO pio, uint sm, uint
9698
// Load our configuration, do not yet start the program
9799
pio_sm_init(pio, sm, offset, &c);
98100
}
99-
%}
101+
%}

src/dmd_reader.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ typedef struct __attribute__((__packed__)) block_pix_crc_header_t
9898

9999
// Line oversampling
100100
#define LINEOVERSAMPLING_NONE 1
101-
#define LINEOVERSAMPLING_WHITESTAR 2
102-
#define LINEOVERSAMPLING_SAM 4
101+
#define LINEOVERSAMPLING_2X 2
102+
#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

@@ -125,7 +126,7 @@ uint16_t lcd_wordsperframe;
125126
uint16_t lcd_bytesperframe;
126127
uint16_t lcd_lineoversampling;
127128
uint16_t lcd_wordsperline;
128-
uint8_t lcd_mergeplanes=MERGEPLANES_ADD;
129+
uint8_t lcd_mergeplanes;
129130

130131
// raw data read from DMD
131132
uint8_t planebuf1[MAX_WIDTH * MAX_HEIGHT * MAX_BITSPERPIXEL * MAX_PLANESPERFRAME / 8];
@@ -486,7 +487,7 @@ void dmd_dma_handler() {
486487
}
487488

488489
// deal with whitestar line oversampling directly within framebuf
489-
if (lcd_lineoversampling==LINEOVERSAMPLING_WHITESTAR) {
490+
if (lcd_lineoversampling==LINEOVERSAMPLING_2X) {
490491
uint16_t i=0;
491492
uint32_t *dst, *src1, *src2;
492493
dst=src1=framebuf;
@@ -495,15 +496,14 @@ 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]*1+src2[w]*2;
499+
v = src1[w]*2 + src2[w];
499500
dst[w]=v;
500501
}
501502
src1 += lcd_wordsperline*2; // source skips 2 lines forward
502503
src2 += lcd_wordsperline*2;
503504
dst += lcd_wordsperline; // destination skips only one line
504505
}
505-
506-
} else if (lcd_lineoversampling==LINEOVERSAMPLING_SAM) {
506+
} else if (lcd_lineoversampling==LINEOVERSAMPLING_4X) {
507507
uint16_t i=0;
508508
uint32_t *dst, *src1, *src2, *src3, *src4;
509509
dst=src1=framebuf;
@@ -578,6 +578,7 @@ bool init()
578578
lcd_pixelsperbyte = 8 / lcd_bitsperpixel;
579579
lcd_planesperframe = 3;
580580
lcd_lineoversampling = LINEOVERSAMPLING_NONE;
581+
lcd_mergeplanes = MERGEPLANES_ADD;
581582
} else if (dmd_type == DMD_WHITESTAR) {
582583
dmd_pio = pio0;
583584
offset = pio_add_program(dmd_pio, &dmd_reader_whitestar_program);
@@ -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 = 1; // in Whitestar, there's a MSB and a LSB plane
601-
lcd_lineoversampling = LINEOVERSAMPLING_WHITESTAR; // in Whitestar each line is sent twice
602-
lcd_mergeplanes = MERGEPLANES_ADD; // required for correct 2bpp merge
601+
lcd_planesperframe = 1; // in Whitestar, there's only one plane, containg one LSB row followed by one MSB row and so on
602+
lcd_lineoversampling = LINEOVERSAMPLING_2X; // in Whitestar each line is sent twice
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);
@@ -620,7 +621,7 @@ bool init()
620621
lcd_bitsperpixel = 4;
621622
lcd_pixelsperbyte = 8 / lcd_bitsperpixel;
622623
lcd_planesperframe = 4; // in Spike there are 4 planes
623-
lcd_lineoversampling =LINEOVERSAMPLING_NONE; // no line oversampling
624+
lcd_lineoversampling = LINEOVERSAMPLING_NONE; // no line oversampling
624625
lcd_mergeplanes = MERGEPLANES_ADDSHIFT;
625626

626627
} else if (dmd_type == DMD_SAM) {
@@ -642,8 +643,8 @@ bool init()
642643
lcd_height = 32;
643644
lcd_bitsperpixel = 4;
644645
lcd_pixelsperbyte = 8 / lcd_bitsperpixel;
645-
lcd_planesperframe = 1; // in SAM there is one planes
646-
lcd_lineoversampling = LINEOVERSAMPLING_SAM; // with 4x line oversampling
646+
lcd_planesperframe = 1; // in SAM there is one plane
647+
lcd_lineoversampling = LINEOVERSAMPLING_4X; // with 4x line oversampling
647648
lcd_mergeplanes = MERGEPLANES_ADD;
648649
} else if (dmd_type == DMD_DESEGA) {
649650
dmd_pio = pio0;
@@ -665,7 +666,7 @@ bool init()
665666
lcd_bitsperpixel = 2; // Data East/ Sega is 2bpp
666667
lcd_pixelsperbyte = 8 / lcd_bitsperpixel;
667668
lcd_planesperframe = 2; // in DE/Sega, there's a MSB and a LSB plane
668-
lcd_lineoversampling = LINEOVERSAMPLING_WHITESTAR; // in DE/Sega each line is sent twice
669+
lcd_lineoversampling = LINEOVERSAMPLING_2X; // in DE/Sega each line is sent twice
669670
lcd_mergeplanes = MERGEPLANES_ADDSHIFT; // required for correct 2bpp merge
670671
} else {
671672
printf("Unknown DMD type, aborting\n");
@@ -676,9 +677,9 @@ bool init()
676677
lcd_bytes = lcd_width * lcd_height * lcd_bitsperpixel / 8;
677678
lcd_pixelsperframe = lcd_width * lcd_height;
678679
lcd_wordsperplane = lcd_bytes / 4;
679-
if (lcd_lineoversampling == LINEOVERSAMPLING_WHITESTAR) {
680+
if (lcd_lineoversampling == LINEOVERSAMPLING_2X) {
680681
lcd_wordsperplane *= 2;
681-
} else if (lcd_lineoversampling == LINEOVERSAMPLING_SAM) {
682+
} else if (lcd_lineoversampling == LINEOVERSAMPLING_4X) {
682683
lcd_wordsperplane *= 4;
683684
}
684685
lcd_bytesperplane = lcd_bytes;

0 commit comments

Comments
 (0)