From eacd82f8858cba4b5d46f90b3dcd29b28046f334 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Tue, 23 Jan 2024 11:28:20 +0100 Subject: [PATCH] add i2c RGB init --- lib/lib_display/UDisplay/uDisplay.cpp | 31 +++++++++++++++++++++------ lib/lib_display/UDisplay/uDisplay.h | 1 + 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/lib_display/UDisplay/uDisplay.cpp b/lib/lib_display/UDisplay/uDisplay.cpp index cd671c65972a..147ed3da65f4 100755 --- a/lib/lib_display/UDisplay/uDisplay.cpp +++ b/lib/lib_display/UDisplay/uDisplay.cpp @@ -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; @@ -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); @@ -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); @@ -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) { @@ -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); diff --git a/lib/lib_display/UDisplay/uDisplay.h b/lib/lib_display/UDisplay/uDisplay.h index 9878e865dbde..40d576ba6ca8 100755 --- a/lib/lib_display/UDisplay/uDisplay.h +++ b/lib/lib_display/UDisplay/uDisplay.h @@ -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;