Skip to content

Commit

Permalink
Fixed esp32 3.0.0 aplha2 compile error #195
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Oct 13, 2023
1 parent 4b8e1ee commit 0cc4b3a
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 137 deletions.
12 changes: 6 additions & 6 deletions example/factory/factory.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "esp_lcd_panel_vendor.h"
#include "factory_gui.h"
#include "pin_config.h"
#include "sntp.h"
#include "esp_sntp.h"
#include "time.h"

#include "zones.h"
Expand Down Expand Up @@ -170,6 +170,8 @@ void setup()
},
.bus_width = 8,
.max_transfer_bytes = LVGL_LCD_BUF_SIZE * sizeof(uint16_t),
.psram_trans_align = 0,
.sram_trans_align = 0
};
esp_lcd_new_i80_bus(&bus_config, &i80_bus);

Expand All @@ -195,6 +197,7 @@ void setup()
.reset_gpio_num = PIN_LCD_RES,
.color_space = ESP_LCD_COLOR_SPACE_RGB,
.bits_per_pixel = 16,
.vendor_config = NULL
};
esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle);
esp_lcd_panel_reset(panel_handle);
Expand Down Expand Up @@ -343,14 +346,12 @@ void wifi_test(void)
}
}

wifi_config_t current_conf = {0};
wifi_config_t current_conf;
esp_wifi_get_config(WIFI_IF_STA, &current_conf);
if (strlen((const char *)current_conf.sta.ssid) == 0) {
// Just for testing.
Serial.println("Use default WiFi SSID & PASSWORD!!");
strncpy((char *)(current_conf.sta.ssid), WIFI_SSID, strlen(WIFI_SSID));
strncpy((char *)(current_conf.sta.password), WIFI_PASSWORD, strlen(WIFI_PASSWORD));
WiFi.begin((char *)(current_conf.sta.ssid), (char *)(current_conf.sta.password));
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
} else {
Serial.println("Begin WiFi");
WiFi.begin();
Expand All @@ -367,7 +368,6 @@ void wifi_test(void)
// WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

uint32_t last_tick = millis();
uint32_t i = 0;
bool is_smartconfig_connect = false;
lv_label_set_long_mode(log_label, LV_LABEL_LONG_WRAP);
while (WiFi.status() != WL_CONNECTED) {
Expand Down
267 changes: 136 additions & 131 deletions example/factory/factory_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,147 +12,152 @@ static void update_touch_point_subscriber_cb(lv_event_t *e);
static void timer_task(lv_timer_t *t);
static lv_obj_t *dis;

void ui_switch_page(void) {
static uint8_t n;
n++;
lv_obj_set_tile_id(dis, 0, n % UI_PAGE_COUNT, LV_ANIM_ON);
void ui_switch_page(void)
{
static uint8_t n;
n++;
lv_obj_set_tile_id(dis, 0, n % UI_PAGE_COUNT, LV_ANIM_ON);
}

void ui_begin() {

dis = lv_tileview_create(lv_scr_act());
lv_obj_align(dis, LV_ALIGN_TOP_RIGHT, 0, 0);
lv_obj_set_size(dis, LV_PCT(100), LV_PCT(100));
lv_obj_remove_style(dis, 0, LV_PART_SCROLLBAR);

lv_obj_t *tv1 = lv_tileview_add_tile(dis, 0, 0, LV_DIR_VER);
lv_obj_t *tv2 = lv_tileview_add_tile(dis, 0, 1, LV_DIR_VER);
lv_obj_t *tv3 = lv_tileview_add_tile(dis, 0, 2, LV_DIR_VER);
/* page 1 */
lv_obj_t *main_cout = lv_obj_create(tv1);
lv_obj_set_size(main_cout, LV_PCT(100), LV_PCT(100));
lv_obj_clear_flag(main_cout, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_style_border_width(main_cout, 0, 0);
lv_obj_set_style_bg_color(main_cout, UI_BG_COLOR, 0);

lv_obj_t *hour_cout = lv_obj_create(main_cout);
lv_obj_set_size(hour_cout, 140, 140);
lv_obj_align(hour_cout, LV_ALIGN_CENTER, -85, 0);
lv_obj_set_style_bg_color(hour_cout, UI_FRAME_COLOR, 0);
lv_obj_clear_flag(hour_cout, LV_OBJ_FLAG_SCROLLABLE);

lv_obj_t *min_cout = lv_obj_create(main_cout);
lv_obj_set_size(min_cout, 140, 140);
lv_obj_align(min_cout, LV_ALIGN_CENTER, 85, 0);
lv_obj_set_style_bg_color(min_cout, UI_FRAME_COLOR, 0);
lv_obj_clear_flag(min_cout, LV_OBJ_FLAG_SCROLLABLE);

lv_obj_t *seg_text = lv_label_create(main_cout);
lv_obj_align(seg_text, LV_ALIGN_CENTER, 0, -10);
lv_obj_set_style_text_font(seg_text, &font_Alibaba, 0);
lv_label_set_text(seg_text, ":");
lv_obj_set_style_text_color(seg_text, UI_FONT_COLOR, 0);

lv_obj_t *hour_text = lv_label_create(hour_cout);
lv_obj_center(hour_text);
lv_obj_set_style_text_font(hour_text, &font_Alibaba, 0);
lv_label_set_text(hour_text, "12");
lv_obj_set_style_text_color(hour_text, UI_FONT_COLOR, 0);
lv_obj_add_event_cb(hour_text, update_text_subscriber_cb, LV_EVENT_MSG_RECEIVED, NULL);
lv_msg_subsribe_obj(MSG_NEW_HOUR, hour_text, (void *)"%02d");

lv_obj_t *min_text = lv_label_create(min_cout);
lv_obj_center(min_text);
lv_obj_set_style_text_font(min_text, &font_Alibaba, 0);
lv_label_set_text(min_text, "34");
lv_obj_set_style_text_color(min_text, UI_FONT_COLOR, 0);
lv_obj_add_event_cb(min_text, update_text_subscriber_cb, LV_EVENT_MSG_RECEIVED, NULL);
lv_msg_subsribe_obj(MSG_NEW_MIN, min_text, (void *)"%02d");

static lv_style_t style_line;
lv_style_init(&style_line);
lv_style_set_line_width(&style_line, 4);
lv_style_set_line_color(&style_line, UI_BG_COLOR);
lv_style_set_line_rounded(&style_line, true);

lv_obj_t *line;
line = lv_line_create(main_cout);
lv_line_set_points(line, line_points, 2);
lv_obj_add_style(line, &style_line, 0);
lv_obj_center(line);

/* page 2 */
lv_obj_t *logo_img = lv_gif_create(tv2);
lv_obj_center(logo_img);
lv_gif_set_src(logo_img, &lilygo1_gif);

/* page 3 */
lv_obj_t *debug_label = lv_label_create(tv3);
String text;
esp_chip_info_t t;
esp_chip_info(&t);
text = "chip : ";
text += ESP.getChipModel();
text += "\n";
text += "psram size : ";
text += ESP.getPsramSize() / 1024;
text += " KB\n";
text += "flash size : ";
text += ESP.getFlashChipSize() / 1024;
text += " KB\n";

extern bool inited_sd;
if (inited_sd) {
text += "SD card found\r\nSize : ";
text += SD_MMC.cardSize() / 1024;
text += " kb";
} else {
text += "SD card not found";
}

lv_label_set_text(debug_label, text.c_str());
lv_obj_align(debug_label, LV_ALIGN_TOP_LEFT, 0, 0);

lv_obj_t *bat_label = lv_label_create(tv3);
lv_obj_align_to(bat_label, debug_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
lv_obj_add_event_cb(bat_label, update_text_subscriber_cb, LV_EVENT_MSG_RECEIVED, NULL);
lv_msg_subsribe_obj(MSG_NEW_VOLT, bat_label, (void *)"VOLT : %d mV");

lv_obj_t *touch_label = lv_label_create(tv3);
lv_obj_align_to(touch_label, bat_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
lv_obj_add_event_cb(touch_label, update_touch_point_subscriber_cb, LV_EVENT_MSG_RECEIVED, NULL);
lv_label_set_text_fmt(touch_label, "");
lv_msg_subsribe_obj(MSG_NEW_TOUCH_POINT, touch_label, (void *)"%s");

lv_timer_t *timer = lv_timer_create(timer_task, 500, seg_text);
void ui_begin()
{

dis = lv_tileview_create(lv_scr_act());
lv_obj_align(dis, LV_ALIGN_TOP_RIGHT, 0, 0);
lv_obj_set_size(dis, LV_PCT(100), LV_PCT(100));
lv_obj_remove_style(dis, 0, LV_PART_SCROLLBAR);

lv_obj_t *tv1 = lv_tileview_add_tile(dis, 0, 0, LV_DIR_VER);
lv_obj_t *tv2 = lv_tileview_add_tile(dis, 0, 1, LV_DIR_VER);
lv_obj_t *tv3 = lv_tileview_add_tile(dis, 0, 2, LV_DIR_VER);
/* page 1 */
lv_obj_t *main_cout = lv_obj_create(tv1);
lv_obj_set_size(main_cout, LV_PCT(100), LV_PCT(100));
lv_obj_clear_flag(main_cout, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_style_border_width(main_cout, 0, 0);
lv_obj_set_style_bg_color(main_cout, UI_BG_COLOR, 0);

lv_obj_t *hour_cout = lv_obj_create(main_cout);
lv_obj_set_size(hour_cout, 140, 140);
lv_obj_align(hour_cout, LV_ALIGN_CENTER, -85, 0);
lv_obj_set_style_bg_color(hour_cout, UI_FRAME_COLOR, 0);
lv_obj_clear_flag(hour_cout, LV_OBJ_FLAG_SCROLLABLE);

lv_obj_t *min_cout = lv_obj_create(main_cout);
lv_obj_set_size(min_cout, 140, 140);
lv_obj_align(min_cout, LV_ALIGN_CENTER, 85, 0);
lv_obj_set_style_bg_color(min_cout, UI_FRAME_COLOR, 0);
lv_obj_clear_flag(min_cout, LV_OBJ_FLAG_SCROLLABLE);

lv_obj_t *seg_text = lv_label_create(main_cout);
lv_obj_align(seg_text, LV_ALIGN_CENTER, 0, -10);
lv_obj_set_style_text_font(seg_text, &font_Alibaba, 0);
lv_label_set_text(seg_text, ":");
lv_obj_set_style_text_color(seg_text, UI_FONT_COLOR, 0);

lv_obj_t *hour_text = lv_label_create(hour_cout);
lv_obj_center(hour_text);
lv_obj_set_style_text_font(hour_text, &font_Alibaba, 0);
lv_label_set_text(hour_text, "12");
lv_obj_set_style_text_color(hour_text, UI_FONT_COLOR, 0);
lv_obj_add_event_cb(hour_text, update_text_subscriber_cb, LV_EVENT_MSG_RECEIVED, NULL);
lv_msg_subsribe_obj(MSG_NEW_HOUR, hour_text, (void *)"%02d");

lv_obj_t *min_text = lv_label_create(min_cout);
lv_obj_center(min_text);
lv_obj_set_style_text_font(min_text, &font_Alibaba, 0);
lv_label_set_text(min_text, "34");
lv_obj_set_style_text_color(min_text, UI_FONT_COLOR, 0);
lv_obj_add_event_cb(min_text, update_text_subscriber_cb, LV_EVENT_MSG_RECEIVED, NULL);
lv_msg_subsribe_obj(MSG_NEW_MIN, min_text, (void *)"%02d");

static lv_style_t style_line;
lv_style_init(&style_line);
lv_style_set_line_width(&style_line, 4);
lv_style_set_line_color(&style_line, UI_BG_COLOR);
lv_style_set_line_rounded(&style_line, true);

lv_obj_t *line;
line = lv_line_create(main_cout);
lv_line_set_points(line, line_points, 2);
lv_obj_add_style(line, &style_line, 0);
lv_obj_center(line);

/* page 2 */
lv_obj_t *logo_img = lv_gif_create(tv2);
lv_obj_center(logo_img);
lv_gif_set_src(logo_img, &lilygo1_gif);

/* page 3 */
lv_obj_t *debug_label = lv_label_create(tv3);
String text;
esp_chip_info_t t;
esp_chip_info(&t);
text = "chip : ";
text += ESP.getChipModel();
text += "\n";
text += "psram size : ";
text += ESP.getPsramSize() / 1024;
text += " KB\n";
text += "flash size : ";
text += ESP.getFlashChipSize() / 1024;
text += " KB\n";

extern bool inited_sd;
if (inited_sd) {
text += "SD card found\r\nSize : ";
text += SD_MMC.cardSize() / 1024;
text += " kb";
} else {
text += "SD card not found";
}

lv_label_set_text(debug_label, text.c_str());
lv_obj_align(debug_label, LV_ALIGN_TOP_LEFT, 0, 0);

lv_obj_t *bat_label = lv_label_create(tv3);
lv_obj_align_to(bat_label, debug_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
lv_obj_add_event_cb(bat_label, update_text_subscriber_cb, LV_EVENT_MSG_RECEIVED, NULL);
lv_msg_subsribe_obj(MSG_NEW_VOLT, bat_label, (void *)"VOLT : %d mV");

lv_obj_t *touch_label = lv_label_create(tv3);
lv_obj_align_to(touch_label, bat_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
lv_obj_add_event_cb(touch_label, update_touch_point_subscriber_cb, LV_EVENT_MSG_RECEIVED, NULL);
lv_label_set_text(touch_label, "");
lv_msg_subsribe_obj(MSG_NEW_TOUCH_POINT, touch_label, (void *)"%s");

lv_timer_create(timer_task, 500, seg_text);
}

static void timer_task(lv_timer_t *t) {
lv_obj_t *seg = (lv_obj_t *)t->user_data;
static bool j;
if (j)
lv_obj_add_flag(seg, LV_OBJ_FLAG_HIDDEN);
else
lv_obj_clear_flag(seg, LV_OBJ_FLAG_HIDDEN);
j = !j;
static void timer_task(lv_timer_t *t)
{
lv_obj_t *seg = (lv_obj_t *)t->user_data;
static bool j;
if (j)
lv_obj_add_flag(seg, LV_OBJ_FLAG_HIDDEN);
else
lv_obj_clear_flag(seg, LV_OBJ_FLAG_HIDDEN);
j = !j;
}

static void update_text_subscriber_cb(lv_event_t *e) {
lv_obj_t *label = lv_event_get_target(e);
lv_msg_t *m = lv_event_get_msg(e);
static void update_text_subscriber_cb(lv_event_t *e)
{
lv_obj_t *label = lv_event_get_target(e);
lv_msg_t *m = lv_event_get_msg(e);

const char *fmt = (const char *)lv_msg_get_user_data(m);
const int32_t *v = (const int32_t *)lv_msg_get_payload(m);
const char *fmt = (const char *)lv_msg_get_user_data(m);
const int32_t *v = (const int32_t *)lv_msg_get_payload(m);

lv_label_set_text_fmt(label, fmt, *v);
lv_label_set_text_fmt(label, fmt, *v);
}

static void update_touch_point_subscriber_cb(lv_event_t *e) {
lv_obj_t *label = lv_event_get_target(e);
lv_msg_t *m = lv_event_get_msg(e);
static void update_touch_point_subscriber_cb(lv_event_t *e)
{
lv_obj_t *label = lv_event_get_target(e);
lv_msg_t *m = lv_event_get_msg(e);

const char *fmt = (const char *)lv_msg_get_user_data(m);
const char *t = (const char *)lv_msg_get_payload(m);
const char *fmt = (const char *)lv_msg_get_user_data(m);
const char *t = (const char *)lv_msg_get_payload(m);

lv_label_set_text_fmt(label, fmt, t);
lv_label_set_text_fmt(label, fmt, t);
}

0 comments on commit 0cc4b3a

Please sign in to comment.