Skip to content

Commit 11bf616

Browse files
committed
refine view of indicator_lorawan demo
1 parent dd1b127 commit 11bf616

File tree

13 files changed

+199
-87
lines changed

13 files changed

+199
-87
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Fixed
1313

14+
## 2024-01-05
15+
16+
### Added
17+
- Add a terminal png on indicator_lorawan demo
18+
19+
### Changed
20+
- change button title
21+
1422
## 2023-12-18
1523
### Changed
1624
- Update indicator_lorawan demo README
@@ -152,4 +160,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
152160

153161
## 2023-04-18
154162
### Added
155-
- Initial commit of the project (97479ad).
163+
- Initial commit of the project (97479ad).

examples/indicator_lorawan/main/lorawan/lorawan_view.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static void __view_event_handler(void *arg, esp_event_base_t event_base, int32_t
9999
lv_obj_add_state(ui_toTerminal, LV_STATE_CHECKED);
100100
lv_obj_clear_flag(ui_toTerminal, LV_OBJ_FLAG_CLICKABLE);
101101

102-
lv_label_set_text(ui_LblLoRaWANStatus, "START");
102+
lv_label_set_text(ui_LblLoRaWANStatus, "Join");
103103
lv_obj_add_flag(ui_SwClass, LV_OBJ_FLAG_CLICKABLE);
104104
lv_obj_add_flag(ui_DdFreq, LV_OBJ_FLAG_CLICKABLE);
105105
lv_obj_add_flag(ui_SwActivation, LV_OBJ_FLAG_CLICKABLE);
@@ -279,19 +279,22 @@ static void update_panel_network_cfg(struct view_data_lorawan_basic_cfg *cfg)
279279
}
280280
lv_port_sem_give();
281281
}
282-
282+
static bool allow_monitor = false;
283283
static void update_lorawan_network_status(enum view_data_lorawan_join status)
284284
{
285285
lv_img_dsc_t *p_img = &ui_img_lora_disconnect_png;
286286
switch (status) {
287287
case LORAWAN_JOIN_ST_OK:
288288
p_img = &ui_img_lora_connected_png;
289+
allow_monitor = true;
289290
break;
290291
case LORAWAN_JOIN_ST_FAIL:
291292
p_img = &ui_img_lora_disconnect_png;
293+
allow_monitor = false;
292294
break;
293295
case LORAWAN_JOIN_ST_PROCEED:
294296
p_img = &ui_img_lora_ing_png;
297+
allow_monitor = true;
295298
break;
296299
default:
297300
break;
@@ -300,4 +303,13 @@ static void update_lorawan_network_status(enum view_data_lorawan_join status)
300303
lv_img_set_src(ui_LblLoRaStatus1, p_img);
301304
lv_img_set_src(ui_LblLoRaStatus2, p_img);
302305
lv_port_sem_give();
303-
}
306+
}
307+
308+
void check_if_lorawan_connected(lv_event_t * e)
309+
{
310+
if(allow_monitor){
311+
_ui_screen_change(&ui_ScreenMonitor, LV_SCR_LOAD_ANIM_MOVE_BOTTOM, 200, 0, &ui_ScreenMonitor_screen_init);
312+
}else{
313+
ESP_LOGI(TAG, "Join LoRaWAN Network First!");
314+
}
315+
}

examples/indicator_lorawan/main/main.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,6 @@ void app_main(void)
6868
.task_core_id = tskNO_AFFINITY};
6969
ESP_ERROR_CHECK(esp_event_loop_create(&view_event_task_args, &view_event_handle));
7070

71-
lv_port_sem_take();
72-
/* (must be 480*800, set LCD_EVB_SCREEN_ROTATION_90 in menuconfig)*/
73-
ui_init();
74-
75-
lv_port_sem_give();
76-
7771
indicator_view_init();
7872

7973
indicator_model_init();

examples/indicator_lorawan/main/ui/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ SET(SOURCES components/ui_comp_btnwifi1.c
66
screens/ui_ScreenSensor.c
77
screens/ui_ScreenBulb.c
88
screens/ui_ScreenSetting.c
9-
screens/ui_ScreenCharts.c
109
screens/ui_ScreenLoRaWAN.c
10+
screens/ui_ScreenMonitor.c
1111
screens/ui_ScreenWIFI.c
1212
screens/ui_ScreenDisplay.c
1313
screens/ui_ScreenDatetime.c
14-
screens/ui_ScreenConsole.c
14+
screens/ui_ScreenCharts.c
1515
ui.c
1616
components/ui_comp_hook.c
1717
ui_helpers.c
@@ -27,6 +27,7 @@ SET(SOURCES components/ui_comp_btnwifi1.c
2727
images/ui_img_back_png.c
2828
images/ui_img_bulb_dark_png.c
2929
images/ui_img_bulb_light_png.c
30+
images/ui_img_terminal_png.c
3031
images/ui_img_setting_png.c
3132
images/ui_img_datacloud_png.c
3233
images/ui_img_wifi_setting_png.c

examples/indicator_lorawan/main/ui/filelist.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ screens/ui_ScreenTime.c
66
screens/ui_ScreenSensor.c
77
screens/ui_ScreenBulb.c
88
screens/ui_ScreenSetting.c
9-
screens/ui_ScreenCharts.c
109
screens/ui_ScreenLoRaWAN.c
10+
screens/ui_ScreenMonitor.c
1111
screens/ui_ScreenWIFI.c
1212
screens/ui_ScreenDisplay.c
1313
screens/ui_ScreenDatetime.c
14-
screens/ui_ScreenConsole.c
14+
screens/ui_ScreenCharts.c
1515
ui.c
1616
components/ui_comp_hook.c
1717
ui_helpers.c
@@ -27,6 +27,7 @@ images/ui_img_temp_2_png.c
2727
images/ui_img_back_png.c
2828
images/ui_img_bulb_dark_png.c
2929
images/ui_img_bulb_light_png.c
30+
images/ui_img_terminal_png.c
3031
images/ui_img_setting_png.c
3132
images/ui_img_datacloud_png.c
3233
images/ui_img_wifi_setting_png.c

examples/indicator_lorawan/main/ui/images/ui_img_terminal_png.c

Lines changed: 44 additions & 0 deletions
Large diffs are not rendered by default.

examples/indicator_lorawan/main/ui/screens/ui_ScreenBulb.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,26 @@ void ui_ScreenBulb_screen_init(void)
102102
lv_label_set_text(ui_LblTime3, "00:00");
103103
lv_obj_set_style_text_font(ui_LblTime3, &ui_font_SmallTitle, LV_PART_MAIN | LV_STATE_DEFAULT);
104104

105+
ui_BtnLoRa3 = lv_btn_create(ui_ScreenBulb);
106+
lv_obj_set_width(ui_BtnLoRa3, 54);
107+
lv_obj_set_height(ui_BtnLoRa3, 52);
108+
lv_obj_set_x(ui_BtnLoRa3, 405);
109+
lv_obj_set_y(ui_BtnLoRa3, 9);
110+
lv_obj_add_flag(ui_BtnLoRa3, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags
111+
lv_obj_clear_flag(ui_BtnLoRa3, LV_OBJ_FLAG_SCROLLABLE); /// Flags
112+
lv_obj_set_style_bg_color(ui_BtnLoRa3, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
113+
lv_obj_set_style_bg_opa(ui_BtnLoRa3, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
114+
115+
ui_LblLoRaStatus3 = lv_img_create(ui_BtnLoRa3);
116+
lv_img_set_src(ui_LblLoRaStatus3, &ui_img_terminal_png);
117+
lv_obj_set_align(ui_LblLoRaStatus3, LV_ALIGN_CENTER);
118+
lv_obj_add_flag(ui_LblLoRaStatus3, LV_OBJ_FLAG_ADV_HITTEST); /// Flags
119+
lv_obj_clear_flag(ui_LblLoRaStatus3, LV_OBJ_FLAG_SCROLLABLE); /// Flags
120+
lv_img_set_zoom(ui_LblLoRaStatus3, 190);
121+
105122
lv_obj_add_event_cb(ui_BtnBackSBulb, ui_event_BtnBackSBulb, LV_EVENT_ALL, NULL);
106123
lv_obj_add_event_cb(ui_SwitchBulb, ui_event_SwitchBulb, LV_EVENT_ALL, NULL);
124+
lv_obj_add_event_cb(ui_BtnLoRa3, ui_event_BtnLoRa3, LV_EVENT_ALL, NULL);
107125
lv_obj_add_event_cb(ui_ScreenBulb, ui_event_ScreenBulb, LV_EVENT_ALL, NULL);
108126

109127
}

examples/indicator_lorawan/main/ui/screens/ui_ScreenLoRaWAN.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ void ui_ScreenLoRaWAN_screen_init(void)
577577
lv_obj_set_width(ui_Label3, LV_SIZE_CONTENT); /// 1
578578
lv_obj_set_height(ui_Label3, LV_SIZE_CONTENT); /// 1
579579
lv_obj_set_align(ui_Label3, LV_ALIGN_CENTER);
580-
lv_label_set_text(ui_Label3, "Console");
580+
lv_label_set_text(ui_Label3, "Monitor");
581581

582582
ui_BtnLoRaWANStatus = lv_btn_create(ui_ScreenLoRaWAN);
583583
lv_obj_set_width(ui_BtnLoRaWANStatus, 100);

examples/indicator_lorawan/main/ui/screens/ui_ScreenConsole.c renamed to examples/indicator_lorawan/main/ui/screens/ui_ScreenMonitor.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
#include "../ui.h"
77

8-
void ui_ScreenConsole_screen_init(void)
8+
void ui_ScreenMonitor_screen_init(void)
99
{
10-
ui_ScreenConsole = lv_obj_create(NULL);
11-
lv_obj_clear_flag(ui_ScreenConsole, LV_OBJ_FLAG_SCROLLABLE); /// Flags
10+
ui_ScreenMonitor = lv_obj_create(NULL);
11+
lv_obj_clear_flag(ui_ScreenMonitor, LV_OBJ_FLAG_SCROLLABLE); /// Flags
1212

13-
ui_BtnBackSConsole = lv_btn_create(ui_ScreenConsole);
13+
ui_BtnBackSConsole = lv_btn_create(ui_ScreenMonitor);
1414
lv_obj_set_width(ui_BtnBackSConsole, 100);
1515
lv_obj_set_height(ui_BtnBackSConsole, 50);
1616
lv_obj_set_x(ui_BtnBackSConsole, 10);
@@ -21,21 +21,22 @@ void ui_ScreenConsole_screen_init(void)
2121
lv_obj_set_style_bg_opa(ui_BtnBackSConsole, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
2222
lv_obj_set_style_bg_img_src(ui_BtnBackSConsole, &ui_img_back_png, LV_PART_MAIN | LV_STATE_DEFAULT);
2323

24-
ui_LblTitleConsole = lv_label_create(ui_ScreenConsole);
24+
ui_LblTitleConsole = lv_label_create(ui_ScreenMonitor);
2525
lv_obj_set_width(ui_LblTitleConsole, LV_SIZE_CONTENT); /// 1
2626
lv_obj_set_height(ui_LblTitleConsole, LV_SIZE_CONTENT); /// 1
2727
lv_obj_set_x(ui_LblTitleConsole, 1);
2828
lv_obj_set_y(ui_LblTitleConsole, 50);
2929
lv_obj_set_align(ui_LblTitleConsole, LV_ALIGN_TOP_MID);
30-
lv_label_set_text(ui_LblTitleConsole, "Console");
30+
lv_label_set_text(ui_LblTitleConsole, "Monitor");
3131
lv_obj_set_style_text_font(ui_LblTitleConsole, &ui_font_HeadTitle, LV_PART_MAIN | LV_STATE_DEFAULT);
3232

33-
ui_PnlConsole = lv_obj_create(ui_ScreenConsole);
33+
ui_PnlConsole = lv_obj_create(ui_ScreenMonitor);
3434
lv_obj_set_width(ui_PnlConsole, 480);
3535
lv_obj_set_height(ui_PnlConsole, 380);
3636
lv_obj_set_x(ui_PnlConsole, 0);
3737
lv_obj_set_y(ui_PnlConsole, -1);
3838
lv_obj_set_align(ui_PnlConsole, LV_ALIGN_BOTTOM_MID);
39+
lv_obj_clear_flag(ui_PnlConsole, LV_OBJ_FLAG_SCROLL_ELASTIC); /// Flags
3940
lv_obj_set_style_bg_color(ui_PnlConsole, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
4041
lv_obj_set_style_bg_opa(ui_PnlConsole, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
4142
lv_obj_set_style_border_color(ui_PnlConsole, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);

examples/indicator_lorawan/main/ui/ui.c

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ lv_obj_t * ui_PnlDot3;
9191
lv_obj_t * ui_PnlDot2;
9292
lv_obj_t * ui_PnlDot4;
9393
lv_obj_t * ui_LblTime3;
94+
void ui_event_BtnLoRa3(lv_event_t * e);
95+
lv_obj_t * ui_BtnLoRa3;
96+
lv_obj_t * ui_LblLoRaStatus3;
9497

9598

9699
// SCREEN: ui_ScreenSetting
@@ -123,21 +126,6 @@ lv_obj_t * ui_PnlDot8;
123126
lv_obj_t * ui_PnlDot6;
124127

125128

126-
// SCREEN: ui_ScreenCharts
127-
void ui_ScreenCharts_screen_init(void);
128-
lv_obj_t * ui_ScreenCharts;
129-
void ui_event_BtnBackSHistory(lv_event_t * e);
130-
lv_obj_t * ui_BtnBackSHistory;
131-
lv_obj_t * ui_LblTitleHistory;
132-
lv_obj_t * ui_PnlHistory;
133-
void ui_event_TabView2(lv_event_t * e);
134-
lv_obj_t * ui_TabView2;
135-
lv_obj_t * ui_TabPageDay;
136-
lv_obj_t * ui_ChartDay;
137-
lv_obj_t * ui_TabPageWeek;
138-
lv_obj_t * ui_ChartWeek;
139-
140-
141129
// SCREEN: ui_ScreenLoRaWAN
142130
void ui_ScreenLoRaWAN_screen_init(void);
143131
lv_obj_t * ui_ScreenLoRaWAN;
@@ -208,6 +196,15 @@ lv_obj_t * ui_BtnLoRaWANStatus;
208196
lv_obj_t * ui_LblLoRaWANStatus;
209197

210198

199+
// SCREEN: ui_ScreenMonitor
200+
void ui_ScreenMonitor_screen_init(void);
201+
lv_obj_t * ui_ScreenMonitor;
202+
void ui_event_BtnBackSConsole(lv_event_t * e);
203+
lv_obj_t * ui_BtnBackSConsole;
204+
lv_obj_t * ui_LblTitleConsole;
205+
lv_obj_t * ui_PnlConsole;
206+
207+
211208
// SCREEN: ui_ScreenWIFI
212209
void ui_ScreenWIFI_screen_init(void);
213210
lv_obj_t * ui_ScreenWIFI;
@@ -270,13 +267,19 @@ lv_obj_t * ui_BtnBackSDateTime;
270267
lv_obj_t * ui_LblTitleDateTime;
271268

272269

273-
// SCREEN: ui_ScreenConsole
274-
void ui_ScreenConsole_screen_init(void);
275-
lv_obj_t * ui_ScreenConsole;
276-
void ui_event_BtnBackSConsole(lv_event_t * e);
277-
lv_obj_t * ui_BtnBackSConsole;
278-
lv_obj_t * ui_LblTitleConsole;
279-
lv_obj_t * ui_PnlConsole;
270+
// SCREEN: ui_ScreenCharts
271+
void ui_ScreenCharts_screen_init(void);
272+
lv_obj_t * ui_ScreenCharts;
273+
void ui_event_BtnBackSHistory(lv_event_t * e);
274+
lv_obj_t * ui_BtnBackSHistory;
275+
lv_obj_t * ui_LblTitleHistory;
276+
lv_obj_t * ui_PnlHistory;
277+
void ui_event_TabView2(lv_event_t * e);
278+
lv_obj_t * ui_TabView2;
279+
lv_obj_t * ui_TabPageDay;
280+
lv_obj_t * ui_ChartDay;
281+
lv_obj_t * ui_TabPageWeek;
282+
lv_obj_t * ui_ChartWeek;
280283
lv_obj_t * ui____initial_actions0;
281284
const lv_img_dsc_t * ui_imgset_co[1] = {&ui_img_co2_png};
282285
const lv_img_dsc_t * ui_imgset_humidity_[2] = {&ui_img_humidity_1_png, &ui_img_humidity_2_png};
@@ -403,6 +406,9 @@ void ui_event_ScreenBulb(lv_event_t * e)
403406
lv_indev_wait_release(lv_indev_get_act());
404407
_ui_screen_change(&ui_ScreenSensor, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 200, 0, &ui_ScreenSensor_screen_init);
405408
}
409+
if(event_code == LV_EVENT_SCREEN_LOAD_START) {
410+
fn_save_pre_screen(e);
411+
}
406412
}
407413
void ui_event_BtnBackSBulb(lv_event_t * e)
408414
{
@@ -425,6 +431,14 @@ void ui_event_SwitchBulb(lv_event_t * e)
425431
_ui_image_set_property(ui_ImgBulb, _UI_IMAGE_PROPERTY_IMAGE, & ui_img_bulb_light_png);
426432
}
427433
}
434+
void ui_event_BtnLoRa3(lv_event_t * e)
435+
{
436+
lv_event_code_t event_code = lv_event_get_code(e);
437+
lv_obj_t * target = lv_event_get_target(e);
438+
if(event_code == LV_EVENT_CLICKED) {
439+
check_if_lorawan_connected(e);
440+
}
441+
}
428442
void ui_event_ScreenSetting(lv_event_t * e)
429443
{
430444
lv_event_code_t event_code = lv_event_get_code(e);
@@ -473,22 +487,6 @@ void ui_event_BtnDateTime1(lv_event_t * e)
473487
_ui_screen_change(&ui_ScreenDatetime, LV_SCR_LOAD_ANIM_FADE_ON, 200, 0, &ui_ScreenDatetime_screen_init);
474488
}
475489
}
476-
void ui_event_BtnBackSHistory(lv_event_t * e)
477-
{
478-
lv_event_code_t event_code = lv_event_get_code(e);
479-
lv_obj_t * target = lv_event_get_target(e);
480-
if(event_code == LV_EVENT_CLICKED) {
481-
_ui_screen_change(&ui_ScreenSensor, LV_SCR_LOAD_ANIM_FADE_ON, 200, 0, &ui_ScreenSensor_screen_init);
482-
}
483-
}
484-
void ui_event_TabView2(lv_event_t * e)
485-
{
486-
lv_event_code_t event_code = lv_event_get_code(e);
487-
lv_obj_t * target = lv_event_get_target(e);
488-
if(event_code == LV_EVENT_VALUE_CHANGED) {
489-
TabviewChanged(e);
490-
}
491-
}
492490
void ui_event_BtnBackSLoRaWAN(lv_event_t * e)
493491
{
494492
lv_event_code_t event_code = lv_event_get_code(e);
@@ -560,7 +558,7 @@ void ui_event_toTerminal(lv_event_t * e)
560558
lv_event_code_t event_code = lv_event_get_code(e);
561559
lv_obj_t * target = lv_event_get_target(e);
562560
if(event_code == LV_EVENT_CLICKED) {
563-
_ui_screen_change(&ui_ScreenConsole, LV_SCR_LOAD_ANIM_FADE_ON, 300, 0, &ui_ScreenConsole_screen_init);
561+
_ui_screen_change(&ui_ScreenMonitor, LV_SCR_LOAD_ANIM_FADE_ON, 300, 0, &ui_ScreenMonitor_screen_init);
564562
}
565563
}
566564
void ui_event_BtnLoRaWANStatus(lv_event_t * e)
@@ -572,6 +570,14 @@ void ui_event_BtnLoRaWANStatus(lv_event_t * e)
572570
fn_LoRaWANStatus_clicked(e);
573571
}
574572
}
573+
void ui_event_BtnBackSConsole(lv_event_t * e)
574+
{
575+
lv_event_code_t event_code = lv_event_get_code(e);
576+
lv_obj_t * target = lv_event_get_target(e);
577+
if(event_code == LV_EVENT_CLICKED) {
578+
Back2PreScreen(e);
579+
}
580+
}
575581
void ui_event_BtnBackSWifi(lv_event_t * e)
576582
{
577583
lv_event_code_t event_code = lv_event_get_code(e);
@@ -667,12 +673,20 @@ void ui_event_BtnBackSDateTime(lv_event_t * e)
667673
Back2PreScreen(e);
668674
}
669675
}
670-
void ui_event_BtnBackSConsole(lv_event_t * e)
676+
void ui_event_BtnBackSHistory(lv_event_t * e)
671677
{
672678
lv_event_code_t event_code = lv_event_get_code(e);
673679
lv_obj_t * target = lv_event_get_target(e);
674680
if(event_code == LV_EVENT_CLICKED) {
675-
_ui_screen_change(&ui_ScreenLoRaWAN, LV_SCR_LOAD_ANIM_FADE_ON, 200, 0, &ui_ScreenLoRaWAN_screen_init);
681+
_ui_screen_change(&ui_ScreenSensor, LV_SCR_LOAD_ANIM_FADE_ON, 200, 0, &ui_ScreenSensor_screen_init);
682+
}
683+
}
684+
void ui_event_TabView2(lv_event_t * e)
685+
{
686+
lv_event_code_t event_code = lv_event_get_code(e);
687+
lv_obj_t * target = lv_event_get_target(e);
688+
if(event_code == LV_EVENT_VALUE_CHANGED) {
689+
TabviewChanged(e);
676690
}
677691
}
678692

@@ -690,12 +704,12 @@ void ui_init(void)
690704
ui_ScreenSensor_screen_init();
691705
ui_ScreenBulb_screen_init();
692706
ui_ScreenSetting_screen_init();
693-
ui_ScreenCharts_screen_init();
694707
ui_ScreenLoRaWAN_screen_init();
708+
ui_ScreenMonitor_screen_init();
695709
ui_ScreenWIFI_screen_init();
696710
ui_ScreenDisplay_screen_init();
697711
ui_ScreenDatetime_screen_init();
698-
ui_ScreenConsole_screen_init();
712+
ui_ScreenCharts_screen_init();
699713
ui____initial_actions0 = lv_obj_create(NULL);
700714
lv_disp_load_scr(ui_ScreenTime);
701715
}

0 commit comments

Comments
 (0)