Skip to content

Commit a7bce36

Browse files
feat: add bluetooth button and remove wifi one
1 parent d87a67e commit a7bce36

File tree

10 files changed

+103
-57
lines changed

10 files changed

+103
-57
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This file was generated by SquareLine Studio
2-
// SquareLine Studio version: SquareLine Studio 1.3.3
3-
// LVGL version: 8.2.0
2+
// SquareLine Studio version: SquareLine Studio 1.4.0
3+
// LVGL version: 8.3.6
44
// Project name: smart_watch_ui
55

src/user_interface/screens/ui_CalenderScreen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file was generated by SquareLine Studio
2-
// SquareLine Studio version: SquareLine Studio 1.3.3
3-
// LVGL version: 8.2.0
2+
// SquareLine Studio version: SquareLine Studio 1.4.0
3+
// LVGL version: 8.3.6
44
// Project name: smart_watch_ui
55

66
#include "../ui.h"

src/user_interface/screens/ui_HomeScreen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file was generated by SquareLine Studio
2-
// SquareLine Studio version: SquareLine Studio 1.3.3
3-
// LVGL version: 8.2.0
2+
// SquareLine Studio version: SquareLine Studio 1.4.0
3+
// LVGL version: 8.3.6
44
// Project name: smart_watch_ui
55

66
#include "../ui.h"

src/user_interface/screens/ui_SettingsScreen.c

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file was generated by SquareLine Studio
2-
// SquareLine Studio version: SquareLine Studio 1.3.3
3-
// LVGL version: 8.2.0
2+
// SquareLine Studio version: SquareLine Studio 1.4.0
3+
// LVGL version: 8.3.6
44
// Project name: smart_watch_ui
55

66
#include "../ui.h"
@@ -41,19 +41,6 @@ lv_obj_set_style_shadow_spread(ui_BrightnessSlider, 1, LV_PART_KNOB| LV_STATE_DE
4141
lv_obj_set_style_shadow_ofs_x(ui_BrightnessSlider, 2, LV_PART_KNOB| LV_STATE_DEFAULT);
4242
lv_obj_set_style_shadow_ofs_y(ui_BrightnessSlider, 2, LV_PART_KNOB| LV_STATE_DEFAULT);
4343

44-
ui_WiFiSettings = lv_dropdown_create(ui_SettingsScreen);
45-
lv_dropdown_set_options( ui_WiFiSettings, "Przystan na Kawe\nKOCMARLI\nTest" );
46-
lv_dropdown_set_text( ui_WiFiSettings, "None");
47-
lv_obj_set_width( ui_WiFiSettings, 100);
48-
lv_obj_set_height( ui_WiFiSettings, LV_SIZE_CONTENT); /// 1
49-
lv_obj_set_x( ui_WiFiSettings, 50 );
50-
lv_obj_set_y( ui_WiFiSettings, 1 );
51-
lv_obj_set_align( ui_WiFiSettings, LV_ALIGN_CENTER );
52-
lv_obj_add_flag( ui_WiFiSettings, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags
53-
lv_obj_clear_flag( ui_WiFiSettings, LV_OBJ_FLAG_CLICKABLE ); /// Flags
54-
55-
56-
5744
ui_BrightnessLabel = lv_label_create(ui_SettingsScreen);
5845
lv_obj_set_width( ui_BrightnessLabel, LV_SIZE_CONTENT); /// 1
5946
lv_obj_set_height( ui_BrightnessLabel, LV_SIZE_CONTENT); /// 1
@@ -62,13 +49,13 @@ lv_obj_set_y( ui_BrightnessLabel, -35 );
6249
lv_obj_set_align( ui_BrightnessLabel, LV_ALIGN_CENTER );
6350
lv_label_set_text(ui_BrightnessLabel,"Brightness");
6451

65-
ui_WiFiLabel = lv_label_create(ui_SettingsScreen);
66-
lv_obj_set_width( ui_WiFiLabel, LV_SIZE_CONTENT); /// 1
67-
lv_obj_set_height( ui_WiFiLabel, LV_SIZE_CONTENT); /// 1
68-
lv_obj_set_x( ui_WiFiLabel, -38 );
69-
lv_obj_set_y( ui_WiFiLabel, 0 );
70-
lv_obj_set_align( ui_WiFiLabel, LV_ALIGN_CENTER );
71-
lv_label_set_text(ui_WiFiLabel,"WiFi");
52+
ui_BLELabel = lv_label_create(ui_SettingsScreen);
53+
lv_obj_set_width( ui_BLELabel, LV_SIZE_CONTENT); /// 1
54+
lv_obj_set_height( ui_BLELabel, LV_SIZE_CONTENT); /// 1
55+
lv_obj_set_x( ui_BLELabel, -56 );
56+
lv_obj_set_y( ui_BLELabel, 0 );
57+
lv_obj_set_align( ui_BLELabel, LV_ALIGN_CENTER );
58+
lv_label_set_text(ui_BLELabel,"Bluetooth");
7259

7360
ui_VersionText = lv_label_create(ui_SettingsScreen);
7461
lv_obj_set_width( ui_VersionText, LV_SIZE_CONTENT); /// 1
@@ -78,8 +65,16 @@ lv_obj_set_y( ui_VersionText, 72 );
7865
lv_obj_set_align( ui_VersionText, LV_ALIGN_CENTER );
7966
lv_label_set_text(ui_VersionText,"Version: 0.1.0");
8067

68+
ui_BluetoothSwitch = lv_switch_create(ui_SettingsScreen);
69+
lv_obj_set_width( ui_BluetoothSwitch, 54);
70+
lv_obj_set_height( ui_BluetoothSwitch, 25);
71+
lv_obj_set_x( ui_BluetoothSwitch, 49 );
72+
lv_obj_set_y( ui_BluetoothSwitch, -1 );
73+
lv_obj_set_align( ui_BluetoothSwitch, LV_ALIGN_CENTER );
74+
75+
8176
lv_obj_add_event_cb(ui_BrightnessSlider, ui_event_BrightnessSlider, LV_EVENT_ALL, NULL);
82-
lv_obj_add_event_cb(ui_WiFiSettings, ui_event_WiFiSettings, LV_EVENT_ALL, NULL);
77+
lv_obj_add_event_cb(ui_BluetoothSwitch, ui_event_BluetoothSwitch, LV_EVENT_ALL, NULL);
8378
lv_obj_add_event_cb(ui_SettingsScreen, ui_event_SettingsScreen, LV_EVENT_ALL, NULL);
8479

8580
}

src/user_interface/ui.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file was generated by SquareLine Studio
2-
// SquareLine Studio version: SquareLine Studio 1.3.3
3-
// LVGL version: 8.2.0
2+
// SquareLine Studio version: SquareLine Studio 1.4.0
3+
// LVGL version: 8.3.6
44
// Project name: smart_watch_ui
55

66
#include "ui.h"
@@ -25,13 +25,13 @@ void ui_event_SettingsScreen( lv_event_t * e);
2525
lv_obj_t *ui_SettingsScreen;
2626
lv_obj_t *ui_SettingsTitle;
2727
lv_obj_t *ui_BackgroundPanel;
28-
void ui_event_BrightnessSlider(lv_event_t *e);
28+
void ui_event_BrightnessSlider( lv_event_t * e);
2929
lv_obj_t *ui_BrightnessSlider;
30-
void ui_event_WiFiSettings( lv_event_t * e);
31-
lv_obj_t *ui_WiFiSettings;
3230
lv_obj_t *ui_BrightnessLabel;
33-
lv_obj_t *ui_WiFiLabel;
31+
lv_obj_t *ui_BLELabel;
3432
lv_obj_t *ui_VersionText;
33+
void ui_event_BluetoothSwitch( lv_event_t * e);
34+
lv_obj_t *ui_BluetoothSwitch;
3535

3636

3737
// SCREEN: ui_CalenderScreen
@@ -70,16 +70,16 @@ lv_indev_wait_release(lv_indev_get_act());
7070
_ui_screen_change( &ui_HomeScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, &ui_HomeScreen_screen_init);
7171
}
7272
}
73-
void ui_event_BrightnessSlider(lv_event_t * e) {
73+
void ui_event_BrightnessSlider( lv_event_t * e) {
7474
lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e);
7575
if ( event_code == LV_EVENT_VALUE_CHANGED) {
76-
brightness_changed_callback(target, e);
76+
brightness_changed_callback( e );
7777
}
7878
}
79-
void ui_event_WiFiSettings( lv_event_t * e) {
79+
void ui_event_BluetoothSwitch( lv_event_t * e) {
8080
lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e);
8181
if ( event_code == LV_EVENT_VALUE_CHANGED) {
82-
wifi_value_changed( e );
82+
ble_switch_callback( e );
8383
}
8484
}
8585
void ui_event_CalenderScreen( lv_event_t * e) {

src/user_interface/ui.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file was generated by SquareLine Studio
2-
// SquareLine Studio version: SquareLine Studio 1.3.3
3-
// LVGL version: 8.2.0
2+
// SquareLine Studio version: SquareLine Studio 1.4.0
3+
// LVGL version: 8.3.6
44
// Project name: smart_watch_ui
55

66
#ifndef _SMART_WATCH_UI_UI_H
@@ -24,6 +24,7 @@ extern "C" {
2424

2525
#include "ui_helpers.h"
2626
#include "ui_events.h"
27+
2728
// SCREEN: ui_HomeScreen
2829
void ui_HomeScreen_screen_init(void);
2930
void ui_event_HomeScreen( lv_event_t * e);
@@ -38,13 +39,13 @@ void ui_event_SettingsScreen( lv_event_t * e);
3839
extern lv_obj_t *ui_SettingsScreen;
3940
extern lv_obj_t *ui_SettingsTitle;
4041
extern lv_obj_t *ui_BackgroundPanel;
41-
void ui_event_BrightnessSlider(lv_event_t * e);
42+
void ui_event_BrightnessSlider( lv_event_t * e);
4243
extern lv_obj_t *ui_BrightnessSlider;
43-
void ui_event_WiFiSettings( lv_event_t * e);
44-
extern lv_obj_t *ui_WiFiSettings;
4544
extern lv_obj_t *ui_BrightnessLabel;
46-
extern lv_obj_t *ui_WiFiLabel;
45+
extern lv_obj_t *ui_BLELabel;
4746
extern lv_obj_t *ui_VersionText;
47+
void ui_event_BluetoothSwitch( lv_event_t * e);
48+
extern lv_obj_t *ui_BluetoothSwitch;
4849
// SCREEN: ui_CalenderScreen
4950
void ui_CalenderScreen_screen_init(void);
5051
void ui_event_CalenderScreen( lv_event_t * e);
@@ -55,6 +56,7 @@ extern lv_obj_t *ui____initial_actions0;
5556

5657

5758

59+
5860
void ui_init(void);
5961

6062
#ifdef __cplusplus

src/user_interface/ui_events.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,38 @@
99
#include <zephyr/devicetree.h>
1010
#include <zephyr/logging/log.h>
1111
#include <zephyr/drivers/pwm.h>
12-
#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL
12+
13+
#include "../bluetooth/bluetooth_infra.h"
14+
1315
LOG_MODULE_REGISTER(LVGL_Callbacks, LOG_LEVEL_INF);
1416

1517

16-
void wifi_value_changed(lv_event_t * e)
17-
{
18-
// Your code here
18+
void ble_switch_callback(lv_event_t * e) {
19+
int8_t ret;
20+
lv_event_code_t code = lv_event_get_code(e);
21+
lv_obj_t * obj = lv_event_get_target(e);
22+
if(lv_obj_has_state(obj, LV_STATE_CHECKED)) {
23+
// Enable Bluetooth and start advertisement.
24+
ret = enable_bluetooth_and_start_advertisement();
25+
if (ret < 0) LOG_ERR("Failed to enable Bluetooth and start advertisement, exiting...");
26+
else LOG_INF("Bluetooth enabled and advertisement started.");
27+
} else {
28+
// Disable Bluetooth and stop advertisement.
29+
ret = disable_bluetooth_and_stop_advertisement();
30+
if (ret < 0) LOG_ERR("Failed to disable Bluetooth and stop advertisement, exiting...");
31+
else LOG_INF("Bluetooth disabled and advertisement stopped.");
32+
}
1933
}
2034

21-
void brightness_changed_callback(lv_obj_t * target, lv_event_t * e) {
35+
void brightness_changed_callback(lv_event_t * e) {
36+
lv_obj_t * obj = lv_event_get_target(e);
2237
const struct pwm_dt_spec backlight = PWM_DT_SPEC_GET_BY_IDX(DT_NODELABEL(pwm_lcd0), 0);
2338
if (!pwm_is_ready_dt(&backlight)) {
2439
LOG_ERR("PWM device is not ready, exiting...");
2540
}
2641

2742
// Normalize the slider value from 0-100 to 100-1000 range.
28-
int value = lv_slider_get_value(target);
43+
int value = lv_slider_get_value(obj);
2944
value = (value * 9) + 100;
3045

3146
// Change the PWM pulse width according to slider value.

src/user_interface/ui_events.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
extern "C" {
1111
#endif
1212

13-
void brightness_changed_callback(lv_obj_t * target, lv_event_t * e);
14-
void wifi_value_changed(lv_event_t * e);
13+
void brightness_changed_callback(lv_event_t * e);
14+
void ble_switch_callback(lv_event_t * e);
1515

1616
#ifdef __cplusplus
1717
} /*extern "C"*/

src/user_interface/ui_helpers.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file was generated by SquareLine Studio
2-
// SquareLine Studio version: SquareLine Studio 1.3.3
3-
// LVGL version: 8.2.0
2+
// SquareLine Studio version: SquareLine Studio 1.4.0
3+
// LVGL version: 8.3.6
44
// Project name: smart_watch_ui
55

66
#include "ui_helpers.h"
@@ -108,6 +108,15 @@ void _ui_state_modify( lv_obj_t *target, int32_t state, int value)
108108
else lv_obj_clear_state(target,state);
109109
}
110110

111+
void _ui_textarea_move_cursor(lv_obj_t * target, int val)
112+
{
113+
if (val==UI_MOVE_CURSOR_UP) lv_textarea_cursor_up(target);
114+
if (val==UI_MOVE_CURSOR_RIGHT) lv_textarea_cursor_right(target);
115+
if (val==UI_MOVE_CURSOR_DOWN) lv_textarea_cursor_down(target);
116+
if (val==UI_MOVE_CURSOR_LEFT) lv_textarea_cursor_left(target);
117+
lv_obj_add_state(target, LV_STATE_FOCUSED);
118+
}
119+
111120
void scr_unloaded_delete_cb(lv_event_t * e)
112121
{
113122
lv_obj_t ** var = lv_event_get_user_data(e);
@@ -244,3 +253,18 @@ void _ui_checked_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *txt_o
244253
else lv_label_set_text(trg,txt_off);
245254
}
246255

256+
void _ui_spinbox_step(lv_obj_t * target, int val)
257+
{
258+
if(val > 0) lv_spinbox_increment(target);
259+
else lv_spinbox_decrement(target);
260+
261+
lv_event_send(target,LV_EVENT_VALUE_CHANGED, 0);
262+
}
263+
264+
void _ui_switch_theme(int val)
265+
{
266+
#ifdef UI_THEME_ACTIVE
267+
ui_theme_set(val);
268+
#endif
269+
}
270+

src/user_interface/ui_helpers.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file was generated by SquareLine Studio
2-
// SquareLine Studio version: SquareLine Studio 1.3.3
3-
// LVGL version: 8.2.0
2+
// SquareLine Studio version: SquareLine Studio 1.4.0
3+
// LVGL version: 8.3.6
44
// Project name: smart_watch_ui
55

66
#ifndef _SMART_WATCH_UI_UI_HELPERS_H
@@ -62,6 +62,12 @@ void _ui_flag_modify( lv_obj_t *target, int32_t flag, int value);
6262
#define _UI_MODIFY_STATE_TOGGLE 2
6363
void _ui_state_modify( lv_obj_t *target, int32_t state, int value);
6464

65+
#define UI_MOVE_CURSOR_UP 0
66+
#define UI_MOVE_CURSOR_RIGHT 1
67+
#define UI_MOVE_CURSOR_DOWN 2
68+
#define UI_MOVE_CURSOR_LEFT 3
69+
void _ui_textarea_move_cursor(lv_obj_t * target, int val);
70+
6571
void scr_unloaded_delete_cb(lv_event_t * e);
6672

6773
void _ui_opacity_set( lv_obj_t *target, int val);
@@ -113,6 +119,10 @@ void _ui_slider_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *prefix
113119

114120
void _ui_checked_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *txt_on, const char *txt_off);
115121

122+
void _ui_spinbox_step(lv_obj_t * target, int val);
123+
124+
void _ui_switch_theme(int val);
125+
116126
#ifdef __cplusplus
117127
} /*extern "C"*/
118128
#endif

0 commit comments

Comments
 (0)