Skip to content

Commit

Permalink
Change 1.91 & 2.41 inch lvgl to use partial refresh, contribution from
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Jan 30, 2024
1 parent 08b737d commit 497ff9b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
19 changes: 18 additions & 1 deletion src/LV_Helper.cpp
Expand Up @@ -56,6 +56,19 @@ void lv_log_print_g_cb(const char *buf)
}
#endif

static void lv_rounder_cb(lv_disp_drv_t *disp_drv, lv_area_t *area)
{
// make sure all coordinates are even
if (area->x1 & 1)
area->x1--;
if (!(area->x2 & 1))
area->x2++;
if (area->y1 & 1)
area->y1--;
if (!(area->y2 & 1))
area->y2++;
}

void beginLvglHelper(LilyGo_Display &board, bool debug)
{

Expand All @@ -80,8 +93,12 @@ void beginLvglHelper(LilyGo_Display &board, bool debug)
disp_drv.ver_res = board.height();
disp_drv.flush_cb = disp_flush;
disp_drv.draw_buf = &draw_buf;
disp_drv.full_refresh = 1;
bool full_refresh = board.needFullRefresh();
disp_drv.full_refresh = full_refresh;
disp_drv.user_data = &board;
if (!full_refresh) {
disp_drv.rounder_cb = lv_rounder_cb;
}
lv_disp_drv_register( &disp_drv );

if (board.hasTouch()) {
Expand Down
7 changes: 7 additions & 0 deletions src/LilyGo_AMOLED.cpp
Expand Up @@ -941,3 +941,10 @@ uint8_t LilyGo_AMOLED::getRotation()
return (_rotation);
}

bool LilyGo_AMOLED::needFullRefresh()
{
if(boards){
return boards->display.fullRefresh;
}
return false;
}
12 changes: 9 additions & 3 deletions src/LilyGo_AMOLED.h
Expand Up @@ -80,6 +80,7 @@ typedef struct __DisplayConfigure {
uint16_t width;
uint16_t height;
uint32_t frameBufferSize;
bool fullRefresh;
} DisplayConfigure_t;

typedef struct __BoardTouchPins {
Expand Down Expand Up @@ -142,7 +143,8 @@ static const DisplayConfigure_t SH8501_AMOLED = {
SH8501_INIT_SEQUENCE_LENGHT,
SH8501_WIDTH, //width
SH8501_HEIGHT, //height
SH8501_WIDTH *SH8501_HEIGHT * sizeof(uint16_t) //frameBufferSize
SH8501_WIDTH *SH8501_HEIGHT * sizeof(uint16_t), //frameBufferSize
true //fullRefresh
};

static const int AMOLED_147_BUTTONTS[2] = {0, 21};
Expand Down Expand Up @@ -173,7 +175,8 @@ static const DisplayConfigure_t RM67162_AMOLED = {
RM67162_INIT_SEQUENCE_LENGHT,
RM67162_WIDTH,//width
RM67162_HEIGHT,//height
0//frameBufferSize
0,//frameBufferSize
false //fullRefresh
};


Expand All @@ -197,7 +200,8 @@ static const DisplayConfigure_t RM690B0_AMOLED = {
RM690B0_INIT_SEQUENCE_LENGHT,
RM690B0_WIDTH,//width
RM690B0_HEIGHT,//height
0//frameBufferSize
0,//frameBufferSize
false //fullRefresh
};
static const int AMOLED_241_BUTTONTS[1] = {0};
static const BoardPmuPins_t AMOLED_241_PMU_PINS = {6/*SDA*/, 7/*SCL*/, 5/*IRQ*/};
Expand Down Expand Up @@ -332,6 +336,8 @@ class LilyGo_AMOLED:
void sleep();
void wakeup();
bool hasTouch();

bool needFullRefresh();
private:
bool initBUS();
bool initPMU();
Expand Down
2 changes: 2 additions & 0 deletions src/LilyGo_Display.h
Expand Up @@ -30,6 +30,8 @@ class LilyGo_Display
virtual uint8_t getPoint(int16_t *x, int16_t *y, uint8_t get_point ) = 0;
virtual bool hasTouch() = 0;

virtual bool needFullRefresh() = 0;

protected:
uint16_t _offset_x = 0;
uint16_t _offset_y = 0;
Expand Down
5 changes: 4 additions & 1 deletion src/LilyGo_Wristband.cpp
Expand Up @@ -554,4 +554,7 @@ void LilyGo_Wristband::vibration(uint8_t duty, uint32_t delay_ms)
#endif
}


bool LilyGo_Wristband::needFullRefresh()
{
return true;
}
1 change: 1 addition & 0 deletions src/LilyGo_Wristband.h
Expand Up @@ -92,6 +92,7 @@ class LilyGo_Wristband :
void enableTouchWakeup(int threshold = 2000);
void sleep();
void wakeup();
bool needFullRefresh();
private:
bool initBUS();
void writeCommand(uint32_t cmd, uint8_t *pdat, uint32_t lenght);
Expand Down

0 comments on commit 497ff9b

Please sign in to comment.