Skip to content

Commit

Permalink
update lvgl submodule. add theme example
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteYuan committed Oct 24, 2018
1 parent ed44c69 commit f977eef
Show file tree
Hide file tree
Showing 19 changed files with 1,177 additions and 190 deletions.
2 changes: 1 addition & 1 deletion components/component_conf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# LVGL_COMPONENT_PATH ?= $(abspath $(shell pwd)/../)

LVGL_COMPONENT_DIRS += $(LVGL_COMPONENT_PATH)/components
LVGL_COMPONENT_DIRS += $(LVGL_COMPONENT_DIRS)/components/general
LVGL_COMPONENT_DIRS += $(LVGL_COMPONENT_PATH)/components/general
LVGL_COMPONENT_DIRS += $(LVGL_COMPONENT_PATH)/components/spi_devices
LVGL_COMPONENT_DIRS += $(LVGL_COMPONENT_PATH)/components/i2c_devices
LVGL_COMPONENT_DIRS += $(LVGL_COMPONENT_PATH)/components/i2c_devices/sensor
Expand Down
3 changes: 2 additions & 1 deletion components/gdrivers/gdisp/ILI9341/ILI9341_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void ex_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_
lcd_obj->drawBitmap((int16_t)x1, (int16_t)y1, (const uint16_t *)color_p, (int16_t)(x2 - x1 + 1), (int16_t)(y2 - y1 + 1));
}

void lvgl_lcd_display_init()
lv_disp_drv_t lvgl_lcd_display_init()
{
/*Initialize LCD*/
lcd_conf_t lcd_pins = {
Expand Down Expand Up @@ -285,6 +285,7 @@ void lvgl_lcd_display_init()

/* Finally register the driver */
lv_disp_drv_register(&disp_drv);
return disp_drv;
}

#endif /* CONFIG_LVGL_GUI_ENABLE */
3 changes: 2 additions & 1 deletion components/gdrivers/gdisp/NT35510/NT35510_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void ex_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_
iot_nt35510_draw_bmp(nt35510_handle, (uint16_t *)color_p, (uint16_t)x1, (uint16_t)y1, (uint16_t)(x2 - x1 + 1), (uint16_t)(y2 - y1 + 1));
}

void lvgl_lcd_display_init()
lv_disp_drv_t lvgl_lcd_display_init()
{
/*Initialize LCD*/
i2s_lcd_config_t i2s_lcd_pin_conf = {
Expand Down Expand Up @@ -247,6 +247,7 @@ void lvgl_lcd_display_init()

/* Finally register the driver */
lv_disp_drv_register(&disp_drv);
return disp_drv;
}

#endif /* CONFIG_LVGL_GUI_ENABLE */
23 changes: 2 additions & 21 deletions components/gdrivers/gdisp/SSD1306/SSD1306_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void ex_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_
lcd_obj->draw_bitmap((uint8_t)x1, (uint8_t)y1, (uint8_t *)color_p, (uint8_t)(x2 - x1 + 1), (uint8_t)(y2 - y1 + 1));
}

void lvgl_lcd_display_init()
lv_disp_drv_t lvgl_lcd_display_init()
{
/*Initialize LCD*/
i2c_bus = new CI2CBus((i2c_port_t)CONFIG_LVGL_LCD_IIC_NUM, (gpio_num_t)CONFIG_LVGL_LCD_SCL_GPIO, (gpio_num_t)CONFIG_LVGL_LCD_SDA_GPIO);
Expand All @@ -182,26 +182,6 @@ void lvgl_lcd_display_init()
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/

// switch(CONFIG_LVGL_DISP_ROTATE){
// default:
// case 0:
// lcd_obj->writeCmd(0x36);
// lcd_obj->writeData(0x00|0x00);
// break;
// case 1:
// lcd_obj->writeCmd(0x36);
// lcd_obj->writeData(0xA0|0x00);
// break;
// case 2:
// lcd_obj->writeCmd(0x36);
// lcd_obj->writeData(0xC0|0x00);
// break;
// case 3:
// lcd_obj->writeCmd(0x36);
// lcd_obj->writeData(0x60|0x00);
// break;
// }

/* Set up the functions to access to your display */
if (LV_VDB_SIZE != 0) {
disp_drv.disp_flush = ex_disp_flush; /*Used in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/
Expand All @@ -212,6 +192,7 @@ void lvgl_lcd_display_init()

/* Finally register the driver */
lv_disp_drv_register(&disp_drv);
return disp_drv;
}

#endif /* CONFIG_LVGL_GUI_ENABLE */
3 changes: 2 additions & 1 deletion components/gdrivers/gdisp/ST7789/ST7789_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void ex_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_
lcd_obj->drawBitmap((int16_t)x1, (int16_t)y1, (const uint16_t *)color_p, (int16_t)(x2 - x1 + 1), (int16_t)(y2 - y1 + 1));
}

void lvgl_lcd_display_init()
lv_disp_drv_t lvgl_lcd_display_init()
{
/*Initialize LCD*/
lcd_conf_t lcd_pins = {
Expand Down Expand Up @@ -277,6 +277,7 @@ void lvgl_lcd_display_init()

/* Finally register the driver */
lv_disp_drv_register(&disp_drv);
return disp_drv;
}

#endif /* CONFIG_LVGL_GUI_ENABLE */
55 changes: 33 additions & 22 deletions components/gdrivers/ginput/FT5X06/lvgl_indev_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
#include "iot_i2c_bus.h"

/* lvgl includes */
#include "lvgl_indev_config.h"
#include "iot_lvgl.h"

/* lvgl calibration includes */
#include "lv_calibration.h"

/* FT5x06 Include */
#include "FT5x06.h"

Expand Down Expand Up @@ -59,35 +61,44 @@ static uint16_t read_word(uint8_t reg)
}

/*Function pointer to read data. Return 'true' if there is still data to be read (buffered)*/
bool ex_tp_read(lv_indev_data_t *data)
static bool ex_tp_read(lv_indev_data_t *data)
{
int16_t t;
static lv_coord_t x = 0xFFFF, y = 0xFFFF;
data->state = LV_INDEV_STATE_REL;
// please be sure that your touch driver every time return old (last clcked) value.
data->point.x = x;
data->point.y = y;
// Only take a reading if we are touched.
if ((read_byte(FT5x06_TOUCH_POINTS) & 0x07)) {

/* Get the X, Y, values */
data->point.x = (int16_t)(read_word(FT5x06_TOUCH1_XH) & 0x0fff);
data->point.y = (int16_t)read_word(FT5x06_TOUCH1_YH);
data->point.x = (lv_coord_t)(read_word(FT5x06_TOUCH1_XH) & 0x0fff);
data->point.y = (lv_coord_t)read_word(FT5x06_TOUCH1_YH);
data->state = LV_INDEV_STATE_PR;

// Rescale X,Y if we are using self-calibration

#ifdef CONFIG_LVGL_DISP_ROTATE_0
data->point.x = data->point.x;
data->point.y = data->point.y;
#elif defined(CONFIG_LVGL_DISP_ROTATE_90)
t = data->point.x;
data->point.x = LV_HOR_RES - 1 - data->point.y;
data->point.y = t;
#elif defined(CONFIG_LVGL_DISP_ROTATE_180)
data->point.x = LV_HOR_RES - 1 - data->point.x;
data->point.y = LV_VER_RES - 1 - data->point.y;
#elif defined(CONFIG_LVGL_DISP_ROTATE_270)
t = data->point.y;
data->point.y = LV_VER_RES - 1 - data->point.x;
data->point.x = t;
#endif
// Apply calibration, rotation
// Transform the co-ordinates
if (lvgl_calibration_transform(&(data->point))) {
lv_coord_t t;
// Rescale X,Y if we are using self-calibration
#ifdef CONFIG_LVGL_DISP_ROTATE_0
data->point.x = data->point.x;
data->point.y = data->point.y;
#elif defined(CONFIG_LVGL_DISP_ROTATE_90)
t = data->point.x;
data->point.x = LV_HOR_RES - 1 - data->point.y;
data->point.y = t;
#elif defined(CONFIG_LVGL_DISP_ROTATE_180)
data->point.x = LV_HOR_RES - 1 - data->point.x;
data->point.y = LV_VER_RES - 1 - data->point.y;
#elif defined(CONFIG_LVGL_DISP_ROTATE_270)
t = data->point.y;
data->point.y = LV_VER_RES - 1 - data->point.x;
data->point.x = t;
#endif
x = data->point.x;
y = data->point.y;
}
}
return false;
}
Expand Down
155 changes: 35 additions & 120 deletions components/gdrivers/ginput/XPT2046/XPT2046_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,118 +78,43 @@ int board_touch_get_position(int port)
/* lvgl include */
#include "lvgl_indev_config.h"

static const char *TAG = "TOUCH_SCREEN";

//calibration parameters
float xFactor, yFactor;
int _offset_x, _offset_y;
int m_width, m_height;
// #define NEED_CALI

void touch_calibration(int width, int height, int rotation)
{
uint16_t px[2], py[2], xPot[4], yPot[4];

m_width = width;
m_height = height;

ESP_LOGD(TAG, "please input top-left button...");

while (!xpt->is_pressed()) {
vTaskDelay(50 / portTICK_RATE_MS);
};
xPot[0] = xpt->get_raw_position().x;
yPot[0] = xpt->get_raw_position().y;
ESP_LOGD(TAG, "X:%d; Y:%d.", xPot[0], yPot[0]);

vTaskDelay(500 / portTICK_RATE_MS);
ESP_LOGD(TAG, "please input top-right button...");

while (!xpt->is_pressed()) {
vTaskDelay(50 / portTICK_RATE_MS);
};
xPot[1] = xpt->get_raw_position().x;
yPot[1] = xpt->get_raw_position().y;
ESP_LOGD(TAG, "X:%d; Y:%d.", xPot[1], yPot[1]);

vTaskDelay(500 / portTICK_RATE_MS);
ESP_LOGD(TAG, "please input bottom-right button...");

while (!xpt->is_pressed()) {
vTaskDelay(50 / portTICK_RATE_MS);
};
xPot[2] = xpt->get_raw_position().x;
yPot[2] = xpt->get_raw_position().y;
ESP_LOGD(TAG, "X:%d; Y:%d.", xPot[2], yPot[2]);

vTaskDelay(500 / portTICK_RATE_MS);
ESP_LOGD(TAG, "please input bottom-left button...");

while (!xpt->is_pressed()) {
vTaskDelay(50 / portTICK_RATE_MS);
};
xPot[3] = xpt->get_raw_position().x;
yPot[3] = xpt->get_raw_position().y;
ESP_LOGD(TAG, "X:%d; Y:%d.", xPot[3], yPot[3]);

px[0] = (xPot[0] + xPot[1]) / 2;
py[0] = (yPot[0] + yPot[3]) / 2;

px[1] = (xPot[2] + xPot[3]) / 2;
py[1] = (yPot[2] + yPot[1]) / 2;
ESP_LOGD(TAG, "X:%d; Y:%d.", px[0], py[0]);
ESP_LOGD(TAG, "X:%d; Y:%d.", px[1], py[1]);

xFactor = (float)m_height / (px[1] - px[0]);
yFactor = (float)m_width / (py[1] - py[0]);

_offset_x = (int16_t)m_height - ((float)px[1] * xFactor);
_offset_y = (int16_t)m_width - ((float)py[1] * yFactor);

ESP_LOGD(TAG, "xFactor:%f, yFactor:%f, Offset X:%d; Y:%d.", xFactor, yFactor, _offset_x, _offset_y);
}

position get_screen_position(position pos)
{
position m_pos;
int x = _offset_x + pos.x * xFactor;
int y = _offset_y + pos.y * yFactor;

if (x > m_height) {
x = m_height;
} else if (x < 0) {
x = 0;
}
if (y > m_width) {
y = m_width;
} else if (y < 0) {
y = 0;
}

#ifdef CONFIG_LVGL_DISP_ROTATE_0
m_pos.x = LV_HOR_RES - x;
m_pos.y = y;
#elif defined(CONFIG_LVGL_DISP_ROTATE_90)
m_pos.x = LV_HOR_RES - y;
m_pos.y = LV_VER_RES - x;
#elif defined(CONFIG_LVGL_DISP_ROTATE_180)
m_pos.x = x;
m_pos.y = LV_VER_RES - y;
#elif defined(CONFIG_LVGL_DISP_ROTATE_270)
m_pos.x = y;
m_pos.y = x;
#endif

return m_pos;
}

/*Function pointer to read data. Return 'true' if there is still data to be read (buffered)*/
bool ex_tp_read(lv_indev_data_t *data)
static bool ex_tp_read(lv_indev_data_t *data)
{
data->state = xpt->is_pressed() ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
position pos = get_screen_position(xpt->get_raw_position());
data->point.x = pos.x;
data->point.y = pos.y;
static lv_coord_t x = 0xFFFF, y = 0xFFFF;
data->state = LV_INDEV_STATE_REL;
// please be sure that your touch driver every time return old (last clcked) value.
data->point.x = x;
data->point.y = y;
if (xpt->is_pressed()) {
position pos = xpt->get_raw_position();
data->point.x = pos.x;
data->point.y = pos.y;
data->state = LV_INDEV_STATE_PR;
// Apply calibration, rotation
// Transform the co-ordinates
if (lvgl_calibration_transform(&(data->point))) {
lv_coord_t t;
// Rescale X,Y if we are using self-calibration
#ifdef CONFIG_LVGL_DISP_ROTATE_0
data->point.x = data->point.x;
data->point.y = data->point.y;
#elif defined(CONFIG_LVGL_DISP_ROTATE_90)
t = data->point.x;
data->point.x = LV_HOR_RES - 1 - data->point.y;
data->point.y = t;
#elif defined(CONFIG_LVGL_DISP_ROTATE_180)
data->point.x = LV_HOR_RES - 1 - data->point.x;
data->point.y = LV_VER_RES - 1 - data->point.y;
#elif defined(CONFIG_LVGL_DISP_ROTATE_270)
t = data->point.y;
data->point.y = LV_VER_RES - 1 - data->point.x;
data->point.x = t;
#endif
x = data->point.x;
y = data->point.y;
}
}
return false;
}

Expand All @@ -211,16 +136,6 @@ lv_indev_drv_t lvgl_indev_init()
if (xpt == NULL) {
xpt = new CTouchAdapter(&xpt_conf, 0);
}
#ifdef NEED_CALI
touch_calibration(320, 240, 1);
#else
xFactor = 0.070651;
yFactor = 0.089435;
_offset_x = -17;
_offset_y = -26;
m_width = 320;
m_height = 240;
#endif

lv_indev_drv_t indev_drv; /*Descriptor of an input device driver*/
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
Expand Down
2 changes: 1 addition & 1 deletion components/gdrivers/include/lvgl_disp_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern "C"
/**
* @brief Initialize display
*/
void lvgl_lcd_display_init();
lv_disp_drv_t lvgl_lcd_display_init();

#ifdef __cplusplus
}
Expand Down
6 changes: 3 additions & 3 deletions components/lvgl_gui/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COMPONENT_SRCDIRS := . \
$(LVGLLIB)/lv_draw \
$(LVGLLIB)/lv_hal \
$(LVGLLIB)/lv_misc \
$(LVGLLIB)/lv_misc/lv_fonts \
$(LVGLLIB)/lv_fonts \
$(LVGLLIB)/lv_objx \
$(LVGLLIB)/lv_themes \

Expand All @@ -27,7 +27,7 @@ COMPONENT_ADD_INCLUDEDIRS := . \
$(LVGLLIB)/lv_draw \
$(LVGLLIB)/lv_hal \
$(LVGLLIB)/lv_misc \
$(LVGLLIB)/lv_misc/lv_fonts \
$(LVGLLIB)/lv_fonts \
$(LVGLLIB)/lv_objx \
$(LVGLLIB)/lv_themes \

Expand All @@ -38,7 +38,7 @@ COMPONENT_PRIV_INCLUDEDIRS += . \
$(LVGLLIB)/lv_draw \
$(LVGLLIB)/lv_hal \
$(LVGLLIB)/lv_misc \
$(LVGLLIB)/lv_misc/lv_fonts \
$(LVGLLIB)/lv_fonts \
$(LVGLLIB)/lv_objx \
$(LVGLLIB)/lv_themes \

Expand Down
Loading

0 comments on commit f977eef

Please sign in to comment.