Added new setting to choose the screen's orientation + some other modifications

This commit is contained in:
Th3maz1ng 2023-01-22 21:18:12 +01:00
parent 562114814e
commit c9d01ef022
4 changed files with 28 additions and 10 deletions

View File

@ -6,13 +6,12 @@
static const char *day_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31";
static const char *month_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12";
static const char *year_options = "22\n23\n24\n25\n26\n27\n28\n29\n30";
static const char *hour_options = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23";
static const char *second_minute_options = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59";
static const char *date_format = "dd/mm/yyyy\ndd/mm/yy\nyyyy/mm/dd\nyy/mm/dd";
static const char *timeout_options = "0\n5\n10\n15\n20\n25\n30\n35\n40\n45\n50\n55\n60";
const char *date_format = "dd/mm/yyyy\ndd/mm/yy\nyyyy/mm/dd\nyy/mm/dd";
static const char *orientation_format = "Default\n90°\n180°\n270°";
static void gesture_event_cb(lv_event_t * e)
{
@ -106,6 +105,18 @@ static void timeout_roller_cb(lv_event_t * e)
settingsScreen->settingsScreenAPIInterface.setTimeoutSettingsCb(timeout);
}
static void orientation_dropdown_cb(lv_event_t * e)
{
SettingsScreen_t *settingsScreen = e->user_data;
if(!settingsScreen->settingsScreenAPIInterface.setOrientationSettingsCb) return;
lv_obj_t *dropdown = lv_event_get_target(e);
uint8_t orientation = lv_dropdown_get_selected(dropdown);
settingsScreen->settingsScreenAPIInterface.setOrientationSettingsCb(orientation);
}
static lv_obj_t* add_sidebar_entry_to_menu(lv_obj_t *parent, const char *title, lv_obj_t *menu, lv_obj_t *pageToShow)
{
lv_obj_t *container = lv_menu_cont_create(parent);
@ -288,7 +299,6 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen)
lv_obj_t *date_dropdown = lv_dropdown_create(container);
lv_dropdown_set_options_static(date_dropdown, date_format);
//We create the menu page for the display settings
lv_obj_t *menu_page_2 = lv_menu_page_create(menu, NULL);
@ -317,6 +327,14 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen)
lv_label_set_text_static(timeout_label, "Second(s)");
lv_obj_set_style_pad_top(timeout_label, 25, LV_PART_MAIN);
menu_page_label = lv_label_create(section);
lv_label_set_text_static(menu_page_label, "Orientation :");
container = create_section_container(section);
lv_obj_t *orientation_dropdown = lv_dropdown_create(container);
lv_dropdown_set_options_static(orientation_dropdown, orientation_format);
lv_obj_add_event_cb(orientation_dropdown, &(orientation_dropdown_cb), LV_EVENT_VALUE_CHANGED, settingsScreen);
//We create the side bar page
lv_obj_t *sidebar_page = lv_menu_page_create(menu, NULL);
lv_obj_t *settings_section_1 = lv_menu_section_create(sidebar_page);

View File

@ -8,6 +8,7 @@ typedef struct SettingsScreenAPIInterface
void (*setBrightnessSettingsCb)(uint8_t brightness);
void (*setTimeSettingsCb)(uint8_t hour, uint8_t minute, uint8_t second, uint8_t day, uint8_t month, uint8_t year);
void (*setTimeoutSettingsCb)(uint8_t timeout);
void (*setOrientationSettingsCb)(uint8_t orientation);
} SettingsScreenAPIInterface_t;
typedef struct SettingsScreen

View File

@ -3,7 +3,7 @@
/* WatchSetting object with default values */
static WatchSettings_t watchSettings =
{
.timeAndDate = {.config = 0},
.timeAndDate = {.hour_format = 0, .date_format = 0, .automatic_time_and_date = 0},
.display = {.brightness = 255, .sleep_timeout = 0,},
};

View File

@ -3,14 +3,12 @@
#include "wm_type_def.h"
#define HOUR_FORMAT(X) ((X) & 0x01)
#define DATE_FORMAT(X) (((X) & 0x0E) >> 1)
#define AUTOMATIC_TIME_AND_DATE(X) (((X) & 0x10) >> 4)
/* Time and Date Settings */
typedef struct TimeAndDate
{
uint32_t config;
uint32_t hour_format:1;
uint32_t date_format:2;
uint32_t automatic_time_and_date:1;
} TimeAndDate_t;
/* Display Settings */
@ -18,6 +16,7 @@ typedef struct Display
{
uint8_t brightness;
uint8_t sleep_timeout;
uint8_t orientation:2;
} Display_t;
/* Connectivity Settings */