Description
I’m pretty new the the hole subject, so please be patient.
I designed a Odometer with Speed / RPM Sprites. afte a lot of work its running good.
But maybe due to insufficient memory it only runs on 2-bit colors. Can anyone help me?
What MCU/Processor/Board and compiler are you using?
ESP32-S3 with Display 800x480 guess China Version
ArduinoIDE 1.8.19
What do you want to achieve?
I would like to change it to 4-bit for more flexibility.
What have you tried so far?
by changing canvas and Sprites to 4-bit it shows nothing at all.
Code to reproduce
canvas.setColorDepth(lgfx::palette_2bit);
base.setColorDepth(lgfx::palette_2bit);
Speed_Needle.setColorDepth(lgfx::palette_2bit); RPM_Needle.setColorDepth(lgfx::palette_2bit);
The code block(s) should be between ```c
and ```
tags:
// 4.65 Bugfixes Strecke, KmH
#include <LovyanGFX.hpp>
#include <lgfx/v1/platforms/esp32s3/Panel_RGB.hpp>
#include <lgfx/v1/platforms/esp32s3/Bus_RGB.hpp>
#define GFX_BL 2
#define LGFX_USE_V1
class LGFX : public lgfx::LGFX_Device{
public:
lgfx::Bus_RGB _bus_instance;
lgfx::Panel_RGB _panel_instance;
lgfx::Light_PWM _light_instance;
//lgfx::Touch_GT911 _touch_instance;
LGFX(void){
{ auto cfg = _panel_instance.config();
cfg.memory_width = 800; cfg.memory_height = 480;
cfg.panel_width = 800; cfg.panel_height = 480;
cfg.offset_x = 0; cfg.offset_y = 0;
_panel_instance.config(cfg); }
{ auto cfg = _panel_instance.config_detail(); cfg.use_psram = 1;
_panel_instance.config_detail(cfg); }
{ auto cfg = _bus_instance.config(); cfg.panel = &_panel_instance;
cfg.pin_d0 = GPIO_NUM_8; /* B0 */ cfg.pin_d1 = GPIO_NUM_3; /* B1 */ cfg.pin_d2 = GPIO_NUM_46; /* B2 */ cfg.pin_d3 = GPIO_NUM_9; /* B3 */
cfg.pin_d4 = GPIO_NUM_1; /* B4 */ cfg.pin_d5 = GPIO_NUM_5; /* G0 */ cfg.pin_d6 = GPIO_NUM_6; /* G1 */ cfg.pin_d7 = GPIO_NUM_7; /* G2 */
cfg.pin_d8 = GPIO_NUM_15; /* G3 */ cfg.pin_d9 = GPIO_NUM_16; /* G4 */ cfg.pin_d10 = GPIO_NUM_4; /* G5 */ cfg.pin_d11 = GPIO_NUM_45; /* R0 */
cfg.pin_d12 = GPIO_NUM_48; /* R1 */ cfg.pin_d13 = GPIO_NUM_47; /* R2 */ cfg.pin_d14 = GPIO_NUM_21; /* R3 */ cfg.pin_d15 = GPIO_NUM_14; /* R4 */
cfg.pin_henable = GPIO_NUM_40; cfg.pin_vsync = GPIO_NUM_41; cfg.pin_hsync = GPIO_NUM_39; cfg.pin_pclk = GPIO_NUM_42;
cfg.freq_write = 13000000; //16
cfg.hsync_polarity = 0; cfg.hsync_front_porch = 8; cfg.hsync_pulse_width = 4; cfg.hsync_back_porch = 8;
cfg.vsync_polarity = 0; cfg.vsync_front_porch = 8; cfg.vsync_pulse_width = 4; cfg.vsync_back_porch = 8;
cfg.pclk_idle_high = 1;
_bus_instance.config(cfg);
} _panel_instance.setBus(&_bus_instance);
{ auto cfg = _light_instance.config();
cfg.pin_bl = GPIO_NUM_2;
_light_instance.config(cfg);
}
_panel_instance.light(&_light_instance);
setPanel(&_panel_instance); } };
static LGFX lcd;
static LGFX_Sprite canvas(&lcd);
static LGFX_Sprite base(&canvas);
static LGFX_Sprite RPM_Needle(&canvas);
static LGFX_Sprite Speed_Needle(&canvas);
static auto transpalette = 0; //Das kann doch weg....
static float zoom;
int Angle;
void setup(void)
{ //Start Setup
pinMode(GFX_BL, OUTPUT); analogWrite(GFX_BL, 250);
lcd.init();
lcd.setRotation(0);
lcd.setPivot(400, 360);
lcd.setColorDepth(4); lcd.setFont(&fonts::DejaVu9);
canvas.setColorDepth(lgfx::palette_2bit);
base.setColorDepth(lgfx::palette_2bit);
Speed_Needle.setColorDepth(lgfx::palette_2bit);
RPM_Needle.setColorDepth(lgfx::palette_2bit);
canvas.createSprite(400 * 2, 360 * 2); //mal in 240 ändern!
base.createSprite(800, 480);
Speed_Needle.createSprite(11, 110);
RPM_Needle.createSprite(11, 100);
//Farben...0 = Transparent
canvas.setPaletteColor(1, 0, 0, 10); //Black
canvas.setPaletteColor(2, 250, 240, 191); //Creme White
canvas.setPaletteColor(3, 20, 255, 20); //Green
canvas.setPaletteColor(4, 255, 20, 20); //RED
canvas.setPaletteColor(5, 20, 20, 255); //BLUE
canvas.setPaletteColor(6, 255, 255, 255); //WHITE
// Zeiger
Speed_Needle.setPivot(5, 320);
Speed_Needle.fillRoundRect(0, 0, 11, 100, 5, 2);
Speed_Needle.fillRoundRect(3, 3, 5, 90, 3, 3);
RPM_Needle.setPivot(5, 190);
RPM_Needle.fillRoundRect(0, 0, 11, 80, 5, 3);
RPM_Needle.fillRoundRect(3, 3, 5, 70, 5, 0);
// Skalen bauen
base.setFont(&fonts::Roboto_Thin_24); base.setTextSize(1); base.setTextColor(3); base.fillSprite(1);
base.fillArc(400, 360, 310, 312, 160, 329, 2);
base.fillArc(400, 360, 307, 302, 290, 329, 3);
base.fillArc(400, 360, 200, 199, 160, 329, 2);
base.fillArc(400, 360, 200, 195, 210, 329, 3);
base.fillArc(400, 360, 195, 185, 300, 329, 3);
base.setCursor(540, 290); base.print(" RPM"); base.setCursor(540, 315); base.print("x 1000"); base.setCursor(640, 230); base.print("km/h");
//Skalenteiler
for (Angle = 161; Angle <= 329; Angle = Angle + 1)
{ if (Angle % 2 == 0) { base.fillArc(400, 360, 300, 290, Angle, Angle, 2); }
if (Angle % 10 == 0) { base.fillArc(400, 360, 320, 310, Angle, Angle, 2); }
if (Angle % 20 == 0) { base.fillArc(400, 360, 320, 310, Angle - 1, Angle + 1, 2);
base.fillArc(400, 360, 200, 200 - 20, Angle, Angle, 2);
float rad = Angle * 0.0174532925; float Ty = sin(rad) * (320 + 20); float Tx = cos(rad) * (320 + 20);
base.setCursor(400 + Tx - 10, 360 + Ty - 10); base.print(((Angle - 160) / 2),0);
rad = Angle * 0.0174532925; Ty = sin(rad) * 160; Tx = cos(rad) * 160;
base.setCursor(400 + Tx - 10, 360 + Ty - 10); base.print(((Angle - 160) / 20),0); } } }
void loop(void) { //Start Loop
for (Angle = 250; Angle <= 410; Angle++) {
base.pushSprite(0, 0);
Speed_Needle.pushRotateZoom(Angle, 1, 1, 0);
RPM_Needle.pushRotateZoom(Angle, 1, 1, 0);
canvas.pushRotateZoom(0, 1, 1, 0);
delay(5); }
for (Angle = 410; Angle >= 250; Angle--) {
base.pushSprite(0, 0);
Speed_Needle.pushRotateZoom(Angle, 1, 1, 0);
RPM_Needle.pushRotateZoom(Angle, 1, 1, 0);
canvas.pushRotateZoom(0, 1, 1, 0);
delay(5); }
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.