Implemented the newly created settings_screen interface callbacks and freeing the default LVGL screen when loading the first screen
This commit is contained in:
parent
f352d498f4
commit
204c2442e1
@ -6,6 +6,8 @@
|
|||||||
#include "lv_port_indev.h"
|
#include "lv_port_indev.h"
|
||||||
#include "lv_port_tick.h"
|
#include "lv_port_tick.h"
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
|
/* Needed to retrieve FreeRTOS version */
|
||||||
|
#include "task.h"
|
||||||
#include "wm_include.h"
|
#include "wm_include.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "watch_face.h"
|
#include "watch_face.h"
|
||||||
@ -379,12 +381,51 @@ static void getBatteryVoltageCb(uint16_t *battery_voltage)
|
|||||||
|
|
||||||
static void getMagnetometerRawDataCb(int16_t *field_x, int16_t *field_y, int16_t *field_z, float *temperature)
|
static void getMagnetometerRawDataCb(int16_t *field_x, int16_t *field_y, int16_t *field_z, float *temperature)
|
||||||
{
|
{
|
||||||
QMC5883L_MData_t raw_data = watch_peripherals_magnetometer_raw_data_read();
|
if(field_x && field_y && field_z)
|
||||||
*field_x = raw_data.MFieldX;
|
{
|
||||||
*field_y = raw_data.MFieldY;
|
watch_peripherals_axes_t axes = watch_peripherals_magnetometer_raw_data_read();
|
||||||
*field_z = raw_data.MFieldZ;
|
*field_x = axes.mag.x;
|
||||||
|
*field_y = axes.mag.y;
|
||||||
|
*field_z = axes.mag.z;
|
||||||
|
}
|
||||||
|
|
||||||
*temperature = watch_peripherals_magnetometer_temperature_read();
|
if(temperature)
|
||||||
|
*temperature = watch_peripherals_magnetometer_temperature_read();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void getAccelerometerRawDataCb(int16_t *accel_x, int16_t *accel_y, int16_t *accel_z, float *temperature, uint32_t *step_count)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(accel_x && accel_y && accel_z)
|
||||||
|
{
|
||||||
|
watch_peripherals_axes_t axes;
|
||||||
|
if(!watch_peripherals_accelerometer_accel_read(&axes))
|
||||||
|
{
|
||||||
|
APP_LOG_DEBUG("Failed to read accelerations");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*accel_x = axes.accel.x;
|
||||||
|
*accel_y = axes.accel.y;
|
||||||
|
*accel_z = axes.accel.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(temperature)
|
||||||
|
{
|
||||||
|
if(!watch_peripherals_accelerometer_temperature_read(temperature))
|
||||||
|
{
|
||||||
|
APP_LOG_DEBUG("Failed to read accelerometer's temperature");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(step_count)
|
||||||
|
{
|
||||||
|
if(!watch_peripherals_accelerometer_step_count_read(step_count))
|
||||||
|
{
|
||||||
|
APP_LOG_DEBUG("Failed to read step counts");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getBMP280DataCb(float *temperature, float *pressure)
|
static void getBMP280DataCb(float *temperature, float *pressure)
|
||||||
@ -393,6 +434,21 @@ static void getBMP280DataCb(float *temperature, float *pressure)
|
|||||||
*pressure = watch_peripherals_pressure_sensor_get_pressure(temperature) / 100.0;
|
*pressure = watch_peripherals_pressure_sensor_get_pressure(temperature) / 100.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void getComponentVersionCb(const char **version, ComponentVersion_e component)
|
||||||
|
{
|
||||||
|
switch(component)
|
||||||
|
{
|
||||||
|
case COMPONENT_FREERTOS:
|
||||||
|
*version = (const char *)STRINGIFY_VALUE(tskKERNEL_VERSION_MAJOR)"."STRINGIFY_VALUE(tskKERNEL_VERSION_MINOR)"."STRINGIFY_VALUE(tskKERNEL_VERSION_BUILD);
|
||||||
|
break;
|
||||||
|
case COMPONENT_LVGL:
|
||||||
|
*version = (const char *)STRINGIFY_VALUE(LVGL_VERSION_MAJOR)"."STRINGIFY_VALUE(LVGL_VERSION_MINOR)"."STRINGIFY_VALUE(LVGL_VERSION_PATCH);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void saveSettingsToFlashCb(void)
|
static void saveSettingsToFlashCb(void)
|
||||||
{
|
{
|
||||||
// Only enable the settings save feature if we compile in SMART_WATCH_PCB_RELEASE mode
|
// Only enable the settings save feature if we compile in SMART_WATCH_PCB_RELEASE mode
|
||||||
@ -451,7 +507,9 @@ SettingsScreenAPIInterface_t settingsScreenAPIInterface =
|
|||||||
.getBLEDevicePairingKeyCb = &(getBLEDevicePairingKeyCb),
|
.getBLEDevicePairingKeyCb = &(getBLEDevicePairingKeyCb),
|
||||||
.getBatteryVoltageCb = &(getBatteryVoltageCb),
|
.getBatteryVoltageCb = &(getBatteryVoltageCb),
|
||||||
.getMagnetometerRawDataCb = &(getMagnetometerRawDataCb),
|
.getMagnetometerRawDataCb = &(getMagnetometerRawDataCb),
|
||||||
|
.getAccelerometerRawDataCb = &(getAccelerometerRawDataCb),
|
||||||
.getBMP280DataCb = &(getBMP280DataCb),
|
.getBMP280DataCb = &(getBMP280DataCb),
|
||||||
|
.getComponentVersionCb = &(getComponentVersionCb),
|
||||||
.saveSettingsCb = &(saveSettingsToFlashCb),
|
.saveSettingsCb = &(saveSettingsToFlashCb),
|
||||||
.factoryResetCb = &(performFactoryResetCb),
|
.factoryResetCb = &(performFactoryResetCb),
|
||||||
};
|
};
|
||||||
@ -632,13 +690,13 @@ static void settings_screen_on_state_change_cb(SettingsScreenState_e settingsScr
|
|||||||
switch(settingsScreenState)
|
switch(settingsScreenState)
|
||||||
{
|
{
|
||||||
case SETTINGS_SCREEN_STATE_OPENED:
|
case SETTINGS_SCREEN_STATE_OPENED:
|
||||||
if(settingsScreenCategory == SETTINGS_SCREEN_CATEGORY_ABOUT)
|
if(settingsScreenCategory == SETTINGS_SCREEN_CATEGORY_SENSORS)
|
||||||
{
|
{
|
||||||
watch_peripherals_magnetometer_power_mode_set(QMC5883L_Mode_Control_Continuous);
|
watch_peripherals_magnetometer_power_mode_set(QMC5883L_Mode_Control_Continuous);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SETTINGS_SCREEN_STATE_CLOSED:
|
case SETTINGS_SCREEN_STATE_CLOSED:
|
||||||
if(settingsScreenCategory == SETTINGS_SCREEN_CATEGORY_ABOUT)
|
if(settingsScreenCategory == SETTINGS_SCREEN_CATEGORY_SENSORS)
|
||||||
{
|
{
|
||||||
watch_peripherals_magnetometer_power_mode_set(QMC5883L_Mode_Control_Standby);
|
watch_peripherals_magnetometer_power_mode_set(QMC5883L_Mode_Control_Standby);
|
||||||
}
|
}
|
||||||
@ -817,7 +875,8 @@ void gfx_task(void *param)
|
|||||||
watch_face_register_step_counter_indicator_cb(&watchFace, &(step_count_cb));
|
watch_face_register_step_counter_indicator_cb(&watchFace, &(step_count_cb));
|
||||||
watch_face_create(&watchFace);
|
watch_face_create(&watchFace);
|
||||||
|
|
||||||
lv_scr_load(watchFace.display);
|
/* Using this function to load the first screen allows to free the default screen obj */
|
||||||
|
lv_scr_load_anim(watchFace.display, LV_SCR_LOAD_ANIM_NONE, 0U, 0U, true);
|
||||||
|
|
||||||
//QMC5883L_set_calibration_data(-900, 2500, -1400, 1400, 2300, 7500, 0.0);
|
//QMC5883L_set_calibration_data(-900, 2500, -1400, 1400, 2300, 7500, 0.0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user