Skip to content

Commit

Permalink
refine view of indicator_lorawan demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Love4yzp committed Jan 5, 2024
1 parent dd1b127 commit 11bf616
Show file tree
Hide file tree
Showing 13 changed files with 199 additions and 87 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

## 2024-01-05

### Added
- Add a terminal png on indicator_lorawan demo

### Changed
- change button title

## 2023-12-18
### Changed
- Update indicator_lorawan demo README
Expand Down Expand Up @@ -152,4 +160,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## 2023-04-18
### Added
- Initial commit of the project (97479ad).
- Initial commit of the project (97479ad).
18 changes: 15 additions & 3 deletions examples/indicator_lorawan/main/lorawan/lorawan_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static void __view_event_handler(void *arg, esp_event_base_t event_base, int32_t
lv_obj_add_state(ui_toTerminal, LV_STATE_CHECKED);
lv_obj_clear_flag(ui_toTerminal, LV_OBJ_FLAG_CLICKABLE);

lv_label_set_text(ui_LblLoRaWANStatus, "START");
lv_label_set_text(ui_LblLoRaWANStatus, "Join");
lv_obj_add_flag(ui_SwClass, LV_OBJ_FLAG_CLICKABLE);
lv_obj_add_flag(ui_DdFreq, LV_OBJ_FLAG_CLICKABLE);
lv_obj_add_flag(ui_SwActivation, LV_OBJ_FLAG_CLICKABLE);
Expand Down Expand Up @@ -279,19 +279,22 @@ static void update_panel_network_cfg(struct view_data_lorawan_basic_cfg *cfg)
}
lv_port_sem_give();
}

static bool allow_monitor = false;
static void update_lorawan_network_status(enum view_data_lorawan_join status)
{
lv_img_dsc_t *p_img = &ui_img_lora_disconnect_png;
switch (status) {
case LORAWAN_JOIN_ST_OK:
p_img = &ui_img_lora_connected_png;
allow_monitor = true;
break;
case LORAWAN_JOIN_ST_FAIL:
p_img = &ui_img_lora_disconnect_png;
allow_monitor = false;
break;
case LORAWAN_JOIN_ST_PROCEED:
p_img = &ui_img_lora_ing_png;
allow_monitor = true;
break;
default:
break;
Expand All @@ -300,4 +303,13 @@ static void update_lorawan_network_status(enum view_data_lorawan_join status)
lv_img_set_src(ui_LblLoRaStatus1, p_img);
lv_img_set_src(ui_LblLoRaStatus2, p_img);
lv_port_sem_give();
}
}

void check_if_lorawan_connected(lv_event_t * e)
{
if(allow_monitor){
_ui_screen_change(&ui_ScreenMonitor, LV_SCR_LOAD_ANIM_MOVE_BOTTOM, 200, 0, &ui_ScreenMonitor_screen_init);
}else{
ESP_LOGI(TAG, "Join LoRaWAN Network First!");
}
}
6 changes: 0 additions & 6 deletions examples/indicator_lorawan/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ void app_main(void)
.task_core_id = tskNO_AFFINITY};
ESP_ERROR_CHECK(esp_event_loop_create(&view_event_task_args, &view_event_handle));

lv_port_sem_take();
/* (must be 480*800, set LCD_EVB_SCREEN_ROTATION_90 in menuconfig)*/
ui_init();

lv_port_sem_give();

indicator_view_init();

indicator_model_init();
Expand Down
5 changes: 3 additions & 2 deletions examples/indicator_lorawan/main/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ SET(SOURCES components/ui_comp_btnwifi1.c
screens/ui_ScreenSensor.c
screens/ui_ScreenBulb.c
screens/ui_ScreenSetting.c
screens/ui_ScreenCharts.c
screens/ui_ScreenLoRaWAN.c
screens/ui_ScreenMonitor.c
screens/ui_ScreenWIFI.c
screens/ui_ScreenDisplay.c
screens/ui_ScreenDatetime.c
screens/ui_ScreenConsole.c
screens/ui_ScreenCharts.c
ui.c
components/ui_comp_hook.c
ui_helpers.c
Expand All @@ -27,6 +27,7 @@ SET(SOURCES components/ui_comp_btnwifi1.c
images/ui_img_back_png.c
images/ui_img_bulb_dark_png.c
images/ui_img_bulb_light_png.c
images/ui_img_terminal_png.c
images/ui_img_setting_png.c
images/ui_img_datacloud_png.c
images/ui_img_wifi_setting_png.c
Expand Down
5 changes: 3 additions & 2 deletions examples/indicator_lorawan/main/ui/filelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ screens/ui_ScreenTime.c
screens/ui_ScreenSensor.c
screens/ui_ScreenBulb.c
screens/ui_ScreenSetting.c
screens/ui_ScreenCharts.c
screens/ui_ScreenLoRaWAN.c
screens/ui_ScreenMonitor.c
screens/ui_ScreenWIFI.c
screens/ui_ScreenDisplay.c
screens/ui_ScreenDatetime.c
screens/ui_ScreenConsole.c
screens/ui_ScreenCharts.c
ui.c
components/ui_comp_hook.c
ui_helpers.c
Expand All @@ -27,6 +27,7 @@ images/ui_img_temp_2_png.c
images/ui_img_back_png.c
images/ui_img_bulb_dark_png.c
images/ui_img_bulb_light_png.c
images/ui_img_terminal_png.c
images/ui_img_setting_png.c
images/ui_img_datacloud_png.c
images/ui_img_wifi_setting_png.c
Expand Down
44 changes: 44 additions & 0 deletions examples/indicator_lorawan/main/ui/images/ui_img_terminal_png.c

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions examples/indicator_lorawan/main/ui/screens/ui_ScreenBulb.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,26 @@ void ui_ScreenBulb_screen_init(void)
lv_label_set_text(ui_LblTime3, "00:00");
lv_obj_set_style_text_font(ui_LblTime3, &ui_font_SmallTitle, LV_PART_MAIN | LV_STATE_DEFAULT);

ui_BtnLoRa3 = lv_btn_create(ui_ScreenBulb);
lv_obj_set_width(ui_BtnLoRa3, 54);
lv_obj_set_height(ui_BtnLoRa3, 52);
lv_obj_set_x(ui_BtnLoRa3, 405);
lv_obj_set_y(ui_BtnLoRa3, 9);
lv_obj_add_flag(ui_BtnLoRa3, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags
lv_obj_clear_flag(ui_BtnLoRa3, LV_OBJ_FLAG_SCROLLABLE); /// Flags
lv_obj_set_style_bg_color(ui_BtnLoRa3, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_BtnLoRa3, 0, LV_PART_MAIN | LV_STATE_DEFAULT);

ui_LblLoRaStatus3 = lv_img_create(ui_BtnLoRa3);
lv_img_set_src(ui_LblLoRaStatus3, &ui_img_terminal_png);
lv_obj_set_align(ui_LblLoRaStatus3, LV_ALIGN_CENTER);
lv_obj_add_flag(ui_LblLoRaStatus3, LV_OBJ_FLAG_ADV_HITTEST); /// Flags
lv_obj_clear_flag(ui_LblLoRaStatus3, LV_OBJ_FLAG_SCROLLABLE); /// Flags
lv_img_set_zoom(ui_LblLoRaStatus3, 190);

lv_obj_add_event_cb(ui_BtnBackSBulb, ui_event_BtnBackSBulb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(ui_SwitchBulb, ui_event_SwitchBulb, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(ui_BtnLoRa3, ui_event_BtnLoRa3, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(ui_ScreenBulb, ui_event_ScreenBulb, LV_EVENT_ALL, NULL);

}
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ void ui_ScreenLoRaWAN_screen_init(void)
lv_obj_set_width(ui_Label3, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_Label3, LV_SIZE_CONTENT); /// 1
lv_obj_set_align(ui_Label3, LV_ALIGN_CENTER);
lv_label_set_text(ui_Label3, "Console");
lv_label_set_text(ui_Label3, "Monitor");

ui_BtnLoRaWANStatus = lv_btn_create(ui_ScreenLoRaWAN);
lv_obj_set_width(ui_BtnLoRaWANStatus, 100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

#include "../ui.h"

void ui_ScreenConsole_screen_init(void)
void ui_ScreenMonitor_screen_init(void)
{
ui_ScreenConsole = lv_obj_create(NULL);
lv_obj_clear_flag(ui_ScreenConsole, LV_OBJ_FLAG_SCROLLABLE); /// Flags
ui_ScreenMonitor = lv_obj_create(NULL);
lv_obj_clear_flag(ui_ScreenMonitor, LV_OBJ_FLAG_SCROLLABLE); /// Flags

ui_BtnBackSConsole = lv_btn_create(ui_ScreenConsole);
ui_BtnBackSConsole = lv_btn_create(ui_ScreenMonitor);
lv_obj_set_width(ui_BtnBackSConsole, 100);
lv_obj_set_height(ui_BtnBackSConsole, 50);
lv_obj_set_x(ui_BtnBackSConsole, 10);
Expand All @@ -21,21 +21,22 @@ void ui_ScreenConsole_screen_init(void)
lv_obj_set_style_bg_opa(ui_BtnBackSConsole, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_img_src(ui_BtnBackSConsole, &ui_img_back_png, LV_PART_MAIN | LV_STATE_DEFAULT);

ui_LblTitleConsole = lv_label_create(ui_ScreenConsole);
ui_LblTitleConsole = lv_label_create(ui_ScreenMonitor);
lv_obj_set_width(ui_LblTitleConsole, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_LblTitleConsole, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_LblTitleConsole, 1);
lv_obj_set_y(ui_LblTitleConsole, 50);
lv_obj_set_align(ui_LblTitleConsole, LV_ALIGN_TOP_MID);
lv_label_set_text(ui_LblTitleConsole, "Console");
lv_label_set_text(ui_LblTitleConsole, "Monitor");
lv_obj_set_style_text_font(ui_LblTitleConsole, &ui_font_HeadTitle, LV_PART_MAIN | LV_STATE_DEFAULT);

ui_PnlConsole = lv_obj_create(ui_ScreenConsole);
ui_PnlConsole = lv_obj_create(ui_ScreenMonitor);
lv_obj_set_width(ui_PnlConsole, 480);
lv_obj_set_height(ui_PnlConsole, 380);
lv_obj_set_x(ui_PnlConsole, 0);
lv_obj_set_y(ui_PnlConsole, -1);
lv_obj_set_align(ui_PnlConsole, LV_ALIGN_BOTTOM_MID);
lv_obj_clear_flag(ui_PnlConsole, LV_OBJ_FLAG_SCROLL_ELASTIC); /// Flags
lv_obj_set_style_bg_color(ui_PnlConsole, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_PnlConsole, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(ui_PnlConsole, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
Expand Down
100 changes: 57 additions & 43 deletions examples/indicator_lorawan/main/ui/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ lv_obj_t * ui_PnlDot3;
lv_obj_t * ui_PnlDot2;
lv_obj_t * ui_PnlDot4;
lv_obj_t * ui_LblTime3;
void ui_event_BtnLoRa3(lv_event_t * e);
lv_obj_t * ui_BtnLoRa3;
lv_obj_t * ui_LblLoRaStatus3;


// SCREEN: ui_ScreenSetting
Expand Down Expand Up @@ -123,21 +126,6 @@ lv_obj_t * ui_PnlDot8;
lv_obj_t * ui_PnlDot6;


// SCREEN: ui_ScreenCharts
void ui_ScreenCharts_screen_init(void);
lv_obj_t * ui_ScreenCharts;
void ui_event_BtnBackSHistory(lv_event_t * e);
lv_obj_t * ui_BtnBackSHistory;
lv_obj_t * ui_LblTitleHistory;
lv_obj_t * ui_PnlHistory;
void ui_event_TabView2(lv_event_t * e);
lv_obj_t * ui_TabView2;
lv_obj_t * ui_TabPageDay;
lv_obj_t * ui_ChartDay;
lv_obj_t * ui_TabPageWeek;
lv_obj_t * ui_ChartWeek;


// SCREEN: ui_ScreenLoRaWAN
void ui_ScreenLoRaWAN_screen_init(void);
lv_obj_t * ui_ScreenLoRaWAN;
Expand Down Expand Up @@ -208,6 +196,15 @@ lv_obj_t * ui_BtnLoRaWANStatus;
lv_obj_t * ui_LblLoRaWANStatus;


// SCREEN: ui_ScreenMonitor
void ui_ScreenMonitor_screen_init(void);
lv_obj_t * ui_ScreenMonitor;
void ui_event_BtnBackSConsole(lv_event_t * e);
lv_obj_t * ui_BtnBackSConsole;
lv_obj_t * ui_LblTitleConsole;
lv_obj_t * ui_PnlConsole;


// SCREEN: ui_ScreenWIFI
void ui_ScreenWIFI_screen_init(void);
lv_obj_t * ui_ScreenWIFI;
Expand Down Expand Up @@ -270,13 +267,19 @@ lv_obj_t * ui_BtnBackSDateTime;
lv_obj_t * ui_LblTitleDateTime;


// SCREEN: ui_ScreenConsole
void ui_ScreenConsole_screen_init(void);
lv_obj_t * ui_ScreenConsole;
void ui_event_BtnBackSConsole(lv_event_t * e);
lv_obj_t * ui_BtnBackSConsole;
lv_obj_t * ui_LblTitleConsole;
lv_obj_t * ui_PnlConsole;
// SCREEN: ui_ScreenCharts
void ui_ScreenCharts_screen_init(void);
lv_obj_t * ui_ScreenCharts;
void ui_event_BtnBackSHistory(lv_event_t * e);
lv_obj_t * ui_BtnBackSHistory;
lv_obj_t * ui_LblTitleHistory;
lv_obj_t * ui_PnlHistory;
void ui_event_TabView2(lv_event_t * e);
lv_obj_t * ui_TabView2;
lv_obj_t * ui_TabPageDay;
lv_obj_t * ui_ChartDay;
lv_obj_t * ui_TabPageWeek;
lv_obj_t * ui_ChartWeek;
lv_obj_t * ui____initial_actions0;
const lv_img_dsc_t * ui_imgset_co[1] = {&ui_img_co2_png};
const lv_img_dsc_t * ui_imgset_humidity_[2] = {&ui_img_humidity_1_png, &ui_img_humidity_2_png};
Expand Down Expand Up @@ -403,6 +406,9 @@ void ui_event_ScreenBulb(lv_event_t * e)
lv_indev_wait_release(lv_indev_get_act());
_ui_screen_change(&ui_ScreenSensor, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 200, 0, &ui_ScreenSensor_screen_init);
}
if(event_code == LV_EVENT_SCREEN_LOAD_START) {
fn_save_pre_screen(e);
}
}
void ui_event_BtnBackSBulb(lv_event_t * e)
{
Expand All @@ -425,6 +431,14 @@ void ui_event_SwitchBulb(lv_event_t * e)
_ui_image_set_property(ui_ImgBulb, _UI_IMAGE_PROPERTY_IMAGE, & ui_img_bulb_light_png);
}
}
void ui_event_BtnLoRa3(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
lv_obj_t * target = lv_event_get_target(e);
if(event_code == LV_EVENT_CLICKED) {
check_if_lorawan_connected(e);
}
}
void ui_event_ScreenSetting(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
Expand Down Expand Up @@ -473,22 +487,6 @@ void ui_event_BtnDateTime1(lv_event_t * e)
_ui_screen_change(&ui_ScreenDatetime, LV_SCR_LOAD_ANIM_FADE_ON, 200, 0, &ui_ScreenDatetime_screen_init);
}
}
void ui_event_BtnBackSHistory(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
lv_obj_t * target = lv_event_get_target(e);
if(event_code == LV_EVENT_CLICKED) {
_ui_screen_change(&ui_ScreenSensor, LV_SCR_LOAD_ANIM_FADE_ON, 200, 0, &ui_ScreenSensor_screen_init);
}
}
void ui_event_TabView2(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
lv_obj_t * target = lv_event_get_target(e);
if(event_code == LV_EVENT_VALUE_CHANGED) {
TabviewChanged(e);
}
}
void ui_event_BtnBackSLoRaWAN(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
Expand Down Expand Up @@ -560,7 +558,7 @@ void ui_event_toTerminal(lv_event_t * e)
lv_event_code_t event_code = lv_event_get_code(e);
lv_obj_t * target = lv_event_get_target(e);
if(event_code == LV_EVENT_CLICKED) {
_ui_screen_change(&ui_ScreenConsole, LV_SCR_LOAD_ANIM_FADE_ON, 300, 0, &ui_ScreenConsole_screen_init);
_ui_screen_change(&ui_ScreenMonitor, LV_SCR_LOAD_ANIM_FADE_ON, 300, 0, &ui_ScreenMonitor_screen_init);
}
}
void ui_event_BtnLoRaWANStatus(lv_event_t * e)
Expand All @@ -572,6 +570,14 @@ void ui_event_BtnLoRaWANStatus(lv_event_t * e)
fn_LoRaWANStatus_clicked(e);
}
}
void ui_event_BtnBackSConsole(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
lv_obj_t * target = lv_event_get_target(e);
if(event_code == LV_EVENT_CLICKED) {
Back2PreScreen(e);
}
}
void ui_event_BtnBackSWifi(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
Expand Down Expand Up @@ -667,12 +673,20 @@ void ui_event_BtnBackSDateTime(lv_event_t * e)
Back2PreScreen(e);
}
}
void ui_event_BtnBackSConsole(lv_event_t * e)
void ui_event_BtnBackSHistory(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
lv_obj_t * target = lv_event_get_target(e);
if(event_code == LV_EVENT_CLICKED) {
_ui_screen_change(&ui_ScreenLoRaWAN, LV_SCR_LOAD_ANIM_FADE_ON, 200, 0, &ui_ScreenLoRaWAN_screen_init);
_ui_screen_change(&ui_ScreenSensor, LV_SCR_LOAD_ANIM_FADE_ON, 200, 0, &ui_ScreenSensor_screen_init);
}
}
void ui_event_TabView2(lv_event_t * e)
{
lv_event_code_t event_code = lv_event_get_code(e);
lv_obj_t * target = lv_event_get_target(e);
if(event_code == LV_EVENT_VALUE_CHANGED) {
TabviewChanged(e);
}
}

Expand All @@ -690,12 +704,12 @@ void ui_init(void)
ui_ScreenSensor_screen_init();
ui_ScreenBulb_screen_init();
ui_ScreenSetting_screen_init();
ui_ScreenCharts_screen_init();
ui_ScreenLoRaWAN_screen_init();
ui_ScreenMonitor_screen_init();
ui_ScreenWIFI_screen_init();
ui_ScreenDisplay_screen_init();
ui_ScreenDatetime_screen_init();
ui_ScreenConsole_screen_init();
ui_ScreenCharts_screen_init();
ui____initial_actions0 = lv_obj_create(NULL);
lv_disp_load_scr(ui_ScreenTime);
}
Loading

0 comments on commit 11bf616

Please sign in to comment.