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;
|
||||
uint16_t int_status;
|
||||
|
||||
static void setBrightness(uint8_t brightness)
|
||||
static void setGetBrightnessCb(uint8_t *brightness, SettingMode_e mode)
|
||||
{
|
||||
extern LCDConfig_t LCDConfig;
|
||||
lcd_set_backlight(&LCDConfig, brightness);
|
||||
}
|
||||
|
||||
static void setBrightnessCb(uint8_t brightness)
|
||||
{
|
||||
|
||||
persistency_get_settings()->display.brightness = brightness;
|
||||
setBrightness(brightness);
|
||||
if(SETTING_MODE_GET == mode)
|
||||
{
|
||||
*brightness = persistency_get_settings()->display.display_brightness;
|
||||
}
|
||||
else
|
||||
{
|
||||
persistency_get_settings()->display.display_brightness = *brightness;
|
||||
watch_peripherals_set_brightness(*brightness);
|
||||
}
|
||||
}
|
||||
|
||||
static void setTimeCb(uint8_t hour, uint8_t minute, uint8_t second, uint8_t day, uint8_t month, uint8_t year)
|
||||
static void setTimeCb(uint8_t *hour, uint8_t *minute, uint8_t *second, uint8_t *day, uint8_t *month, uint8_t *year, SettingMode_e mode)
|
||||
{
|
||||
struct tm timeToSet;
|
||||
|
||||
//First we get the current time from the RTC
|
||||
tls_get_rtc(&timeToSet);
|
||||
|
||||
if(hour != 0xFF)
|
||||
timeToSet.tm_hour = hour;
|
||||
if(SETTING_MODE_GET == mode)
|
||||
{
|
||||
*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)
|
||||
timeToSet.tm_min = minute;
|
||||
if(*minute != 0xFF)
|
||||
timeToSet.tm_min = *minute;
|
||||
|
||||
if(second != 0xFF)
|
||||
timeToSet.tm_sec = second;
|
||||
if(*second != 0xFF)
|
||||
timeToSet.tm_sec = *second;
|
||||
|
||||
if(day != 0xFF)
|
||||
timeToSet.tm_mday = day;
|
||||
if(*day != 0xFF)
|
||||
timeToSet.tm_mday = *day;
|
||||
|
||||
if(month != 0xFF)
|
||||
timeToSet.tm_mon = month;
|
||||
if(*month != 0xFF)
|
||||
timeToSet.tm_mon = *month;
|
||||
|
||||
if(year != 0xFF)
|
||||
timeToSet.tm_year = year + 100;
|
||||
if(*year != 0xFF)
|
||||
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;
|
||||
lcd_orientation(&LCDConfig, orientation);
|
||||
persistency_get_settings()->display.orientation = orientation;
|
||||
// Forces to redraw the full screen to avoid strange artifact
|
||||
lv_obj_invalidate(lv_scr_act());
|
||||
if(SETTING_MODE_GET == mode)
|
||||
{
|
||||
*strength = persistency_get_settings()->display.display_vibrate_on_touch_strength;
|
||||
}
|
||||
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 =
|
||||
{
|
||||
.setBrightnessSettingsCb = setBrightnessCb,
|
||||
.setTimeSettingsCb = setTimeCb,
|
||||
.setBrightnessSettingsCb = setGetBrightnessCb,
|
||||
.setTimeoutSettingsCb = setTimeoutCb,
|
||||
.setDisplayVibrationDurationSettingsCb = setDisplayVibrationDuration,
|
||||
.setDisplayVibrationStrengthSettingsCb = setDisplayVibrationStrength,
|
||||
.setOrientationSettingsCb = setOrientationCb,
|
||||
.setBLEEnabledSettingsCb = setBLEEnabledCb,
|
||||
.setWiFiEnabledSettingsCb = setWiFiEnabledCb,
|
||||
.setLanguageSettingsCb = setLanguageCb,
|
||||
};
|
||||
|
||||
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");
|
||||
|
||||
/* 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)*/
|
||||
lv_init();
|
||||
|
||||
@ -299,13 +400,13 @@ void gfx_task(void *param)
|
||||
/* Let's init the watch peripherals driver (vibration motor + battery voltage sense) */
|
||||
watch_peripherals_init(27);
|
||||
/* 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);
|
||||
watch_face_set_battery_indicator(&watchFace, battery_percentage);
|
||||
|
||||
/* Once we are done with the initializing steps we
|
||||
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 */
|
||||
tls_wifi_scan_result_cb_register(&(scan_result_cb));
|
||||
@ -349,7 +450,7 @@ void gfx_task(void *param)
|
||||
{
|
||||
pressure = BMP280_get_pressure(&temperature);
|
||||
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);
|
||||
APP_LOG_DEBUG("GFX thread, temp : %0.2f °C, press : %0.2f hPa, bat(%d) : %u mV <-> %u %%",
|
||||
temperature,
|
||||
@ -364,11 +465,11 @@ void gfx_task(void *param)
|
||||
}
|
||||
|
||||
/* Handle inactivity periods : */
|
||||
if( persistency_get_settings()->display.sleep_delay != 0 &&
|
||||
lv_disp_get_inactive_time(NULL) > (persistency_get_settings()->display.sleep_delay * 1000))
|
||||
if( persistency_get_settings()->display.display_delay_before_sleep != 0 &&
|
||||
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
|
||||
setBrightness(0);
|
||||
watch_peripherals_set_brightness(0);
|
||||
//lcd_on(&LCDConfig, false);
|
||||
lcd_sleep(&LCDConfig, true);
|
||||
QMC5883L_set_power_mode(Standby);
|
||||
@ -385,7 +486,7 @@ void gfx_task(void *param)
|
||||
QMC5883L_set_power_mode(Continuous);
|
||||
//lcd_on(&LCDConfig, true);
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user