loboris / ESP32_TFT_library

Full featured TFT library for ESP32 with demo application
564 stars 219 forks source link

Is the function TFT_invertDisplay() missing the disp_select() ? #45

Open Francois-Belanger opened 6 years ago

Francois-Belanger commented 6 years ago

Great library :-) Just that I had to invert the colour for a new LCD and that function didn't work. I had to change to this.

void TFT_invertDisplay(const uint8_t mode) { if (disp_select() != ESP_OK) { printf("TFT_invertDisplay ERROR !!!!\n"); return; }

if ( mode == INVERT_ON ) disp_spi_transfer_cmd(TFT_INVONN); else disp_spi_transfer_cmd(TFT_INVOFF);

disp_deselect(); }

Is it ok ?

Thanks for the great work.

jas39 commented 5 years ago

Adding disp_select() to TFT_invertDisplay solved my problem. Likely also needed for TFT_setGammaCurve

// Send the command to invert all of the colors. // Input: i 0 to disable inversion; non-zero to enable inversion //========================================== void TFT_invertDisplay(const uint8_t mode) { if (disp_select() == ESP_OK) { if ( mode == INVERT_ON ) disp_spi_transfer_cmd(TFT_INVONN); else disp_spi_transfer_cmd(TFT_INVOFF); disp_deselect(); } }

// Select gamma curve // Input: gamma = 0~3 //================================== void TFT_setGammaCurve(uint8_t gm) { uint8_t gamma_curve = 1 << (gm & 0x03); if (disp_select() == ESP_OK) { disp_spi_transfer_cmd_data(TFT_CMD_GAMMASET, &gamma_curve, 1); disp_deselect(); } }