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;
uint8_t MADCtl, PageSize;
uint8_t Model;
bool Invert;
};
// 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 );
// no Display Inversion
Device->WriteCommand( Device, Private->Model == ST7735 ? 0x20 : 0x21 );
Device->WriteCommand( Device, Private->Invert ? 0x21 : 0x20 );
// gone with the wind
Device->DisplayOn( Device );
@@ -298,6 +299,7 @@ struct GDS_Device* ST77xx_Detect(char *Driver, struct GDS_Device* Device) {
Device->Update = Update24;
}
if (Model == ST7789 || strcasestr(Driver, "invert")) Private->Invert = true;
if (Model == ST7789) Device->SetContrast = SetContrast;
return Device;

View File

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

View File

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

View File

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