Hi
I can get my SH1107 to display text by just using LovyanGFX on my ESP32 custom PCB.
I now wish to add lvgl to my project to take advantage of other features it provides. I have searched the forum and other locations on the internet with no luck, my display just sits there displaying a blank screen. Is there a trick I am over looking. I know this works…
Here is my LovyanGFX config settings
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_SH110x _panel_instance; //SH1107
lgfx::Bus_I2C _bus_instance;
public:
LGFX(void)
{
{
auto cfg = _bus_instance.config();
// I2C
cfg.i2c_port = 0;
cfg.freq_write = 400000;
cfg.freq_read = 400000;
cfg.pin_sda = SDA;
cfg.pin_scl = SCL;
cfg.i2c_addr = 0x3D;
_bus_instance.config(cfg);
_panel_instance.setBus(&_bus_instance);
}
{
auto cfg = _panel_instance.config();
cfg.memory_width = 128;
cfg.panel_width = 128;
cfg.memory_height = 128;
cfg.panel_height = 128;
cfg.bus_shared = false;
cfg.offset_rotation = 0;
_panel_instance.config(cfg);
}
setPanel(&_panel_instance);
}
};
my ino that I cannot get working…
/*Set to your screen resolution and rotation*/
#define TFT_HOR_RES 128
#define TFT_VER_RES 128
#define TFT_ROTATION LV_DISPLAY_ROTATION_0
LGFX tft;
#define DRAW_BUF_SIZE (TFT_HOR_RES * TFT_VER_RES)
uint32_t draw_buf[DRAW_BUF_SIZE / 8];
unsigned long lastTickMillis = 0;
// Display flushing
void my_disp_flush(lv_display_t *disp, const lv_area_t *area, uint8_t *px_map) {
lv_disp_flush_ready(disp);
}
// Read the touchpad
void my_touchpad_read( lv_indev_t * indev, lv_indev_data_t * data )
{
// No touch screen
}
void display_init() {
tft.begin();
tft.setRotation(TFT_ROTATION);
tft.setBrightness(255);
}
void ui_init() {
static lv_style_t text_style;
lv_style_init(&text_style);
lv_style_set_text_font(&text_style, &lv_font_montserrat_14);
lv_style_set_text_color(&text_style, lv_color_white());
lv_style_set_bg_color(&text_style, lv_color_black());
lv_obj_t *hello_world_label = lv_label_create( lv_screen_active() );
lv_obj_add_style(hello_world_label, &text_style, 0);
lv_obj_refresh_style(hello_world_label, LV_PART_ANY, LV_STYLE_PROP_ANY);
lv_label_set_text(hello_world_label, "Hello world!");
lv_obj_align(hello_world_label, LV_ALIGN_CENTER, 0, 0);
Serial.println("UI DRAW Done");
}
void setup() {
Serial.begin(115200);
Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2);
lv_init();
display_init();
lv_display_t *disp = lv_display_create(TFT_HOR_RES, TFT_VER_RES);
lv_display_set_flush_cb(disp, my_disp_flush);
lv_display_set_buffers(disp, draw_buf, NULL, sizeof(draw_buf), LV_DISPLAY_RENDER_MODE_PARTIAL);
/*Initialize the (dummy) input device driver*/
lv_indev_t * indev = lv_indev_create();
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(indev, my_touchpad_read);
ui_init();
Serial.println("Setup DONE....");
}
void loop() {
unsigned int tickPeriod = millis() - lastTickMillis;
lv_tick_inc(tickPeriod);
lastTickMillis = millis();
}
Any guidance or assistance will be greatly appreciated.
Kind Regards
Paul