tweak muse color + add "invert" option

This commit is contained in:
philippe44
2022-02-26 17:37:08 -08:00
parent 72b66054b1
commit 23a5f7fbe4
4 changed files with 18 additions and 11 deletions

View File

@@ -34,6 +34,7 @@ struct PrivateSpace {
} Offset; } Offset;
uint8_t MADCtl, PageSize; uint8_t MADCtl, PageSize;
uint8_t Model; uint8_t Model;
bool Invert;
}; };
// Functions are not declared to minimize # of lines // Functions are not declared to minimize # of lines
@@ -255,7 +256,7 @@ static bool Init( struct GDS_Device* Device ) {
else WriteByte( Device, Device->Depth == 24 ? 0x06 : 0x05 ); else WriteByte( Device, Device->Depth == 24 ? 0x06 : 0x05 );
// no Display Inversion // no Display Inversion
Device->WriteCommand( Device, Private->Model == ST7735 ? 0x20 : 0x21 ); Device->WriteCommand( Device, Private->Invert ? 0x21 : 0x20 );
// gone with the wind // gone with the wind
Device->DisplayOn( Device ); Device->DisplayOn( Device );
@@ -286,7 +287,7 @@ struct GDS_Device* ST77xx_Detect(char *Driver, struct GDS_Device* Device) {
struct PrivateSpace* Private = (struct PrivateSpace*) Device->Private; struct PrivateSpace* Private = (struct PrivateSpace*) Device->Private;
Private->Model = Model; Private->Model = Model;
if (Model == ST7735) { if (Model == ST7735) {
sscanf(Driver, "%*[^:]%*[^x]%*[^=]=%hu", &Private->Offset.Height); sscanf(Driver, "%*[^:]%*[^x]%*[^=]=%hu", &Private->Offset.Height);
sscanf(Driver, "%*[^:]%*[^y]%*[^=]=%hu", &Private->Offset.Width); sscanf(Driver, "%*[^:]%*[^y]%*[^=]=%hu", &Private->Offset.Width);
@@ -298,6 +299,7 @@ struct GDS_Device* ST77xx_Detect(char *Driver, struct GDS_Device* Device) {
Device->Update = Update24; Device->Update = Update24;
} }
if (Model == ST7789 || strcasestr(Driver, "invert")) Private->Invert = true;
if (Model == ST7789) Device->SetContrast = SetContrast; if (Model == ST7789) Device->SetContrast = SetContrast;
return Device; return Device;

View File

@@ -462,7 +462,8 @@ const display_config_t * config_display_get(){
.hflip = false, .hflip = false,
.type = NULL, .type = NULL,
.speed = 0, .speed = 0,
.rotate = false .rotate = false,
.invert = false,
}; };
char *config = config_alloc_get(NVS_TYPE_STR, "display_config"); char *config = config_alloc_get(NVS_TYPE_STR, "display_config");
if (!config) { if (!config) {
@@ -482,7 +483,6 @@ const display_config_t * config_display_get(){
PARSE_PARAM(config, "address", '=', dstruct.address); PARSE_PARAM(config, "address", '=', dstruct.address);
PARSE_PARAM(config, "cs", '=', dstruct.CS_pin); PARSE_PARAM(config, "cs", '=', dstruct.CS_pin);
PARSE_PARAM(config, "speed", '=', dstruct.speed); PARSE_PARAM(config, "speed", '=', dstruct.speed);
PARSE_PARAM(config, "back", '=', dstruct.back);
if (strstr(config, "I2C") ) dstruct.type=i2c_name_type; if (strstr(config, "I2C") ) dstruct.type=i2c_name_type;
if (strstr(config, "SPI") ) dstruct.type=spi_name_type; if (strstr(config, "SPI") ) dstruct.type=spi_name_type;
@@ -490,6 +490,7 @@ const display_config_t * config_display_get(){
dstruct.hflip= strcasestr(config, "HFlip") ? true : false; dstruct.hflip= strcasestr(config, "HFlip") ? true : false;
dstruct.vflip= strcasestr(config, "VFlip") ? true : false; dstruct.vflip= strcasestr(config, "VFlip") ? true : false;
dstruct.rotate= strcasestr(config, "rotate") ? true : false; dstruct.rotate= strcasestr(config, "rotate") ? true : false;
dstruct.rotate= strcasestr(config, "invert") ? true : false;
return &dstruct; return &dstruct;
} }

View File

@@ -31,6 +31,7 @@ typedef struct {
int depth; int depth;
const char *type; const char *type;
bool rotate; bool rotate;
bool invert;
} display_config_t; } display_config_t;
typedef struct eth_config_struct { typedef struct eth_config_struct {

View File

@@ -7,7 +7,6 @@
#include <esp_system.h> #include <esp_system.h>
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <freertos/task.h> #include <freertos/task.h>
//#include <driver/adc.h>
#include "driver/rmt.h" #include "driver/rmt.h"
#include "monitor.h" #include "monitor.h"
#include "targets.h" #include "targets.h"
@@ -24,14 +23,18 @@
// These values are determined by measuring pulse timing with logic analyzer and adjusting to match datasheet. // These values are determined by measuring pulse timing with logic analyzer and adjusting to match datasheet.
#define T0H 14 // 0 bit high time #define T0H 14 // 0 bit high time
#define T1H 52 // 1 bit high time #define T1H 52 // 1 bit high time
#define TL 52 // low time for either bit #define TL 52 // low time for either bit
#define GREEN 0xFF0000 // sets a color based on RGB from 0..255 and a brightness in % from 0..100
#define RED 0x00FF00 #define RGB(R,G,B,BR) (((G*BR)/100) << 16) | (((R*BR)/100) << 8) | ((B*BR)/100)
#define BLUE 0x0000FF
#define WHITE 0xFFFFFF #define RED RGB(255,0,0,10)
#define YELLOW 0xE0F060 #define GREEN RGB(0,255,0,10)
#define BLUE RGB(0,0,255,10)
#define WHITE RGB(255,255,255,10)
#define YELLOW RGB(255,118,13,10)
struct led_state { struct led_state {
uint32_t leds[NUM_LEDS]; uint32_t leds[NUM_LEDS];
}; };