Skip to content

Commit

Permalink
add i2c RGB init
Browse files Browse the repository at this point in the history
  • Loading branch information
gemu2015 committed Jan 23, 2024
1 parent 48113c8 commit eacd82f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
31 changes: 25 additions & 6 deletions lib/lib_display/UDisplay/uDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) {
lutftime = 350;
lut3time = 10;
busy_pin = -1;
spec_init = -1;
ep_mode = 0;
fg_col = 1;
bg_col = 0;
Expand Down Expand Up @@ -186,6 +187,7 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) {
// collect line and send directly
lp1++;
spi_nr = 4;
spec_init = _UDSP_SPI;
spi_dc = -1;
spi_miso = -1;
spi_clk = next_val(&lp1);
Expand Down Expand Up @@ -215,8 +217,26 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) {
Serial.printf("DSP RESET : %d\n", reset);
#endif
}
}

} else if (*lp1 == 'I') {
// pecial case RGB with i2c init, bus nr, i2c addr
lp1++;
if (interface == _UDSP_RGB) {
// collect line and send directly
lp1++;
wire_n = next_val(&lp1);
i2caddr = next_hex(&lp1);
#ifdef UDSP_DEBUG
Serial.printf("I2C_INIT bus : %d\n", wire_n);
Serial.printf("I2C_INIT addr : %02x\n", i2caddr);
#endif
if (wire_n == 1) {
wire = &Wire;
} else {
wire = &Wire1;
}
spec_init = _UDSP_I2C;
}
}
} else if (section == 'L') {
if (*lp1 >= '1' && *lp1 <= '5') {
lut_num = (*lp1 & 0x07);
Expand Down Expand Up @@ -347,8 +367,8 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) {
break;
case 'I':
// init data
if (interface == _UDSP_RGB && spi_nr == 4) {
// special case RGB with SPI init
if (interface == _UDSP_RGB && spec_init > 0) {
// special case RGB with SPI or I2C init
// collect line and send directly
dsp_ncmds = 0;
while (1) {
Expand All @@ -359,10 +379,9 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) {
break;
}
}
interface = _UDSP_SPI;
interface = spec_init;
send_spi_icmds(dsp_ncmds);
interface = _UDSP_RGB;

} else {
if (interface == _UDSP_I2C) {
dsp_cmds[dsp_ncmds++] = next_hex(&lp1);
Expand Down
1 change: 1 addition & 0 deletions lib/lib_display/UDisplay/uDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ class uDisplay : public Renderer {
uint8_t interface;
uint8_t i2caddr;
int8_t i2c_scl;
int8_t spec_init;
TwoWire *wire;
int8_t wire_n;
int8_t i2c_sda;
Expand Down

0 comments on commit eacd82f

Please sign in to comment.