Updated all the settings callbacks to be compatible with the new setting system
This commit is contained in:
parent
4c1f1e168a
commit
d05aa72135
@ -41,67 +41,157 @@ struct bma456w_wrist_wear_wakeup_params setting;
|
|||||||
struct bma4_int_pin_config pin_config;
|
struct bma4_int_pin_config pin_config;
|
||||||
uint16_t int_status;
|
uint16_t int_status;
|
||||||
|
|
||||||
static void setBrightness(uint8_t brightness)
|
static void setGetBrightnessCb(uint8_t *brightness, SettingMode_e mode)
|
||||||
{
|
{
|
||||||
extern LCDConfig_t LCDConfig;
|
if(SETTING_MODE_GET == mode)
|
||||||
lcd_set_backlight(&LCDConfig, brightness);
|
{
|
||||||
|
*brightness = persistency_get_settings()->display.display_brightness;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
persistency_get_settings()->display.display_brightness = *brightness;
|
||||||
|
watch_peripherals_set_brightness(*brightness);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setBrightnessCb(uint8_t brightness)
|
static void setTimeCb(uint8_t *hour, uint8_t *minute, uint8_t *second, uint8_t *day, uint8_t *month, uint8_t *year, SettingMode_e mode)
|
||||||
{
|
|
||||||
|
|
||||||
persistency_get_settings()->display.brightness = brightness;
|
|
||||||
setBrightness(brightness);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setTimeCb(uint8_t hour, uint8_t minute, uint8_t second, uint8_t day, uint8_t month, uint8_t year)
|
|
||||||
{
|
{
|
||||||
struct tm timeToSet;
|
struct tm timeToSet;
|
||||||
|
|
||||||
//First we get the current time from the RTC
|
//First we get the current time from the RTC
|
||||||
tls_get_rtc(&timeToSet);
|
tls_get_rtc(&timeToSet);
|
||||||
|
|
||||||
if(hour != 0xFF)
|
if(SETTING_MODE_GET == mode)
|
||||||
timeToSet.tm_hour = hour;
|
{
|
||||||
|
*hour = timeToSet.tm_hour;
|
||||||
|
*minute = timeToSet.tm_min;
|
||||||
|
*second = timeToSet.tm_sec;
|
||||||
|
*day = timeToSet.tm_mday;
|
||||||
|
*month = timeToSet.tm_mon;
|
||||||
|
*year = timeToSet.tm_year-100;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(*hour != 0xFF)
|
||||||
|
timeToSet.tm_hour = *hour;
|
||||||
|
|
||||||
if(minute != 0xFF)
|
if(*minute != 0xFF)
|
||||||
timeToSet.tm_min = minute;
|
timeToSet.tm_min = *minute;
|
||||||
|
|
||||||
if(second != 0xFF)
|
if(*second != 0xFF)
|
||||||
timeToSet.tm_sec = second;
|
timeToSet.tm_sec = *second;
|
||||||
|
|
||||||
if(day != 0xFF)
|
if(*day != 0xFF)
|
||||||
timeToSet.tm_mday = day;
|
timeToSet.tm_mday = *day;
|
||||||
|
|
||||||
if(month != 0xFF)
|
if(*month != 0xFF)
|
||||||
timeToSet.tm_mon = month;
|
timeToSet.tm_mon = *month;
|
||||||
|
|
||||||
if(year != 0xFF)
|
if(*year != 0xFF)
|
||||||
timeToSet.tm_year = year + 100;
|
timeToSet.tm_year = *year + 100;
|
||||||
|
|
||||||
tls_set_rtc(&timeToSet);
|
tls_set_rtc(&timeToSet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setTimeoutCb(uint8_t timeout)
|
static void setDisplayVibrationDuration(uint8_t *duration, SettingMode_e mode)
|
||||||
{
|
{
|
||||||
persistency_get_settings()->display.sleep_delay = timeout;
|
if(SETTING_MODE_GET == mode)
|
||||||
|
{
|
||||||
|
*duration = persistency_get_settings()->display.display_vibrate_on_touch_duration;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
persistency_get_settings()->display.display_vibrate_on_touch_duration = *duration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setOrientationCb(uint8_t orientation)
|
static void setDisplayVibrationStrength(uint8_t *strength, SettingMode_e mode)
|
||||||
{
|
{
|
||||||
extern LCDConfig_t LCDConfig;
|
if(SETTING_MODE_GET == mode)
|
||||||
lcd_orientation(&LCDConfig, orientation);
|
{
|
||||||
persistency_get_settings()->display.orientation = orientation;
|
*strength = persistency_get_settings()->display.display_vibrate_on_touch_strength;
|
||||||
// Forces to redraw the full screen to avoid strange artifact
|
}
|
||||||
lv_obj_invalidate(lv_scr_act());
|
else
|
||||||
|
{
|
||||||
|
persistency_get_settings()->display.display_vibrate_on_touch_strength = *strength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setTimeoutCb(uint8_t *timeout, SettingMode_e mode)
|
||||||
|
{
|
||||||
|
if(SETTING_MODE_GET == mode)
|
||||||
|
{
|
||||||
|
*timeout = persistency_get_settings()->display.display_delay_before_sleep;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
persistency_get_settings()->display.display_delay_before_sleep = *timeout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setOrientationCb(uint8_t *orientation, SettingMode_e mode)
|
||||||
|
{
|
||||||
|
if(SETTING_MODE_GET == mode)
|
||||||
|
{
|
||||||
|
*orientation = persistency_get_settings()->display.display_orientation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
persistency_get_settings()->display.display_orientation = *orientation;
|
||||||
|
watch_peripherals_set_orientation(*orientation);
|
||||||
|
// Forces to redraw the full screen to avoid strange artifacts
|
||||||
|
lv_obj_invalidate(lv_scr_act());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setBLEEnabledCb(bool *enabled, SettingMode_e mode)
|
||||||
|
{
|
||||||
|
if(SETTING_MODE_GET == mode)
|
||||||
|
{
|
||||||
|
*enabled = persistency_get_settings()->connectivity.connectivity_ble_enabled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
persistency_get_settings()->connectivity.connectivity_ble_enabled = *enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setWiFiEnabledCb(bool *enabled, SettingMode_e mode)
|
||||||
|
{
|
||||||
|
if(SETTING_MODE_GET == mode)
|
||||||
|
{
|
||||||
|
*enabled = persistency_get_settings()->connectivity.connectivity_wifi_enabled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
persistency_get_settings()->connectivity.connectivity_wifi_enabled = *enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setLanguageCb(uint8_t *language, SettingMode_e mode)
|
||||||
|
{
|
||||||
|
if(SETTING_MODE_GET == mode)
|
||||||
|
{
|
||||||
|
*language = persistency_get_settings()->languageAndUI.language;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
persistency_get_settings()->languageAndUI.language = *language;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsScreenAPIInterface_t settingsScreenAPIInterface =
|
SettingsScreenAPIInterface_t settingsScreenAPIInterface =
|
||||||
{
|
{
|
||||||
.setBrightnessSettingsCb = setBrightnessCb,
|
|
||||||
.setTimeSettingsCb = setTimeCb,
|
.setTimeSettingsCb = setTimeCb,
|
||||||
|
.setBrightnessSettingsCb = setGetBrightnessCb,
|
||||||
.setTimeoutSettingsCb = setTimeoutCb,
|
.setTimeoutSettingsCb = setTimeoutCb,
|
||||||
|
.setDisplayVibrationDurationSettingsCb = setDisplayVibrationDuration,
|
||||||
|
.setDisplayVibrationStrengthSettingsCb = setDisplayVibrationStrength,
|
||||||
.setOrientationSettingsCb = setOrientationCb,
|
.setOrientationSettingsCb = setOrientationCb,
|
||||||
|
.setBLEEnabledSettingsCb = setBLEEnabledCb,
|
||||||
|
.setWiFiEnabledSettingsCb = setWiFiEnabledCb,
|
||||||
|
.setLanguageSettingsCb = setLanguageCb,
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint16_t angle_with_offset(uint16_t angle, uint16_t offset)
|
static uint16_t angle_with_offset(uint16_t angle, uint16_t offset)
|
||||||
@ -174,6 +264,17 @@ void gfx_task(void *param)
|
|||||||
{
|
{
|
||||||
APP_LOG_TRACE("starting");
|
APP_LOG_TRACE("starting");
|
||||||
|
|
||||||
|
/* Init and load watch settings using the persistency layer */
|
||||||
|
persistency_init();
|
||||||
|
|
||||||
|
/* Check whether the RTC is running or not, if not, then the board was reset
|
||||||
|
So we start the RTC */
|
||||||
|
if(!tls_is_rtc_running())
|
||||||
|
{
|
||||||
|
struct tm curr_time = {0};
|
||||||
|
tls_set_rtc(&curr_time);
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize the lvgl library and peripherals (display and input device)*/
|
/* Initialize the lvgl library and peripherals (display and input device)*/
|
||||||
lv_init();
|
lv_init();
|
||||||
|
|
||||||
@ -299,13 +400,13 @@ void gfx_task(void *param)
|
|||||||
/* Let's init the watch peripherals driver (vibration motor + battery voltage sense) */
|
/* Let's init the watch peripherals driver (vibration motor + battery voltage sense) */
|
||||||
watch_peripherals_init(27);
|
watch_peripherals_init(27);
|
||||||
/* Make the first battery voltage reading here */
|
/* Make the first battery voltage reading here */
|
||||||
uint16_t battery_voltage = watch_peripherals_get_battery_voltage(Battery_Unit_mV);
|
uint16_t battery_voltage = watch_peripherals_get_battery_voltage(battery_unit_mv);
|
||||||
battery_percentage = battery_voltage_to_percentage(battery_voltage);
|
battery_percentage = battery_voltage_to_percentage(battery_voltage);
|
||||||
watch_face_set_battery_indicator(&watchFace, battery_percentage);
|
watch_face_set_battery_indicator(&watchFace, battery_percentage);
|
||||||
|
|
||||||
/* Once we are done with the initializing steps we
|
/* Once we are done with the initializing steps we
|
||||||
don't forget to turn the backlight on ! */
|
don't forget to turn the backlight on ! */
|
||||||
setBrightness(persistency_get_settings()->display.brightness);
|
watch_peripherals_set_brightness(persistency_get_settings()->display.display_brightness);
|
||||||
|
|
||||||
/* Enable WiFi hotspot scanning for antenna performance test purposes */
|
/* Enable WiFi hotspot scanning for antenna performance test purposes */
|
||||||
tls_wifi_scan_result_cb_register(&(scan_result_cb));
|
tls_wifi_scan_result_cb_register(&(scan_result_cb));
|
||||||
@ -349,7 +450,7 @@ void gfx_task(void *param)
|
|||||||
{
|
{
|
||||||
pressure = BMP280_get_pressure(&temperature);
|
pressure = BMP280_get_pressure(&temperature);
|
||||||
BMP280_trigger_measurement();
|
BMP280_trigger_measurement();
|
||||||
battery_voltage = watch_peripherals_get_battery_voltage(Battery_Unit_mV);
|
battery_voltage = watch_peripherals_get_battery_voltage(battery_unit_mv);
|
||||||
battery_percentage = battery_voltage_to_percentage(battery_voltage);
|
battery_percentage = battery_voltage_to_percentage(battery_voltage);
|
||||||
APP_LOG_DEBUG("GFX thread, temp : %0.2f °C, press : %0.2f hPa, bat(%d) : %u mV <-> %u %%",
|
APP_LOG_DEBUG("GFX thread, temp : %0.2f °C, press : %0.2f hPa, bat(%d) : %u mV <-> %u %%",
|
||||||
temperature,
|
temperature,
|
||||||
@ -364,11 +465,11 @@ void gfx_task(void *param)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Handle inactivity periods : */
|
/* Handle inactivity periods : */
|
||||||
if( persistency_get_settings()->display.sleep_delay != 0 &&
|
if( persistency_get_settings()->display.display_delay_before_sleep != 0 &&
|
||||||
lv_disp_get_inactive_time(NULL) > (persistency_get_settings()->display.sleep_delay * 1000))
|
lv_disp_get_inactive_time(NULL) > (persistency_get_settings()->display.display_delay_before_sleep * 5 * 1000))
|
||||||
{
|
{
|
||||||
// First, we disable the display backlight and we set all the peripherals in their low power mode
|
// First, we disable the display backlight and we set all the peripherals in their low power mode
|
||||||
setBrightness(0);
|
watch_peripherals_set_brightness(0);
|
||||||
//lcd_on(&LCDConfig, false);
|
//lcd_on(&LCDConfig, false);
|
||||||
lcd_sleep(&LCDConfig, true);
|
lcd_sleep(&LCDConfig, true);
|
||||||
QMC5883L_set_power_mode(Standby);
|
QMC5883L_set_power_mode(Standby);
|
||||||
@ -385,7 +486,7 @@ void gfx_task(void *param)
|
|||||||
QMC5883L_set_power_mode(Continuous);
|
QMC5883L_set_power_mode(Continuous);
|
||||||
//lcd_on(&LCDConfig, true);
|
//lcd_on(&LCDConfig, true);
|
||||||
lcd_sleep(&LCDConfig, false);
|
lcd_sleep(&LCDConfig, false);
|
||||||
setBrightness(persistency_get_settings()->display.brightness);
|
watch_peripherals_set_brightness(persistency_get_settings()->display.display_brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Throttle CPU freq down when inactive to save power or to increase responsiveness */
|
/* Throttle CPU freq down when inactive to save power or to increase responsiveness */
|
||||||
|
Loading…
Reference in New Issue
Block a user