Compare commits

..

1 Commits

1364 changed files with 8786 additions and 34331 deletions

View File

@ -309,10 +309,8 @@ sets a white background, be able to make it also flash with a red background.
* Write an alarm app which set an RTC alarm to vibrate the watch.
* Write a timer app with countdown and lap functionality.
* Implement a battery saving mode activated on low batterie (ie <= 10 %).
* This mode would :
* turn bluetooth off.
* set the screen brightness to 50 %.
* throttle the MCU frequency down to 80 or 40 Mhz.
* This mode would turn bluetooth off
* This mode would set the screen brightness to 50 %
## Done List :

View File

@ -1,13 +1,3 @@
/**
* @file BMP280.c
* @author Anatole SCHRAMM-HENRY
* @brief BMP280 pressure and temperature bosch sensor functions implementation source file.
* @version 0.1
* @date 2025-04-29
*
* @copyright MIT
*/
#include <math.h>
#include "i2c.h"
#include "BMP280.h"

View File

@ -1,13 +1,3 @@
/**
* @file BMP280.h
* @author Anatole SCHRAMM-HENRY
* @brief BMP280 pressure and temperature bosch sensor functions API header file.
* @version 0.1
* @date 2025-04-29
*
* @copyright MIT
*/
#ifndef BMP280_H
#define BMP280_H
@ -102,7 +92,7 @@ float BMP280_get_temperature(void);
/**
* @brief Returns the previously sampled pressure in Pa.
*
* @param temperature the address of a float which will contain the measured temperature in °C. If not needed, can be NULL.
* @param temperature the address of a float which will contain the measured temperature. If not needed, can be NULL.
* @return float the value of the pressure in Pa
*/
float BMP280_get_pressure(float * const temperature);

View File

@ -1,13 +1,3 @@
/**
* @file QMC5883L.c
* @author Anatole SCHRAMM-HENRY
* @brief QMC5883L magnetometer functions implementation source file.
* @version 0.1
* @date 2025-03-17
*
* @copyright MIT
*/
#include <math.h>
#include "i2c.h"
#include "QMC5883L.h"
@ -55,17 +45,18 @@ bool QMC5883L_software_reset(void)
float QMC5883L_get_temperature(void)
{
uint8_t data[2];
uint8_t data;
int16_t raw_temp;
float temperature = 0.0F;
if(i2c_read(QMC5883L_I2C_ADDR, QMC5883L_TEMP_LSB_REG, data, sizeof data))
{
raw_temp = (data[1] << 8) | data[0];
temperature = (float)raw_temp / 100.0F + _calibration_data.temperature_offset;
}
i2c_read_reg(QMC5883L_I2C_ADDR, QMC5883L_TEMP_MSB_REG, &data);
return temperature;
raw_temp = data << 8;
i2c_read_reg(QMC5883L_I2C_ADDR, QMC5883L_TEMP_LSB_REG, &data);
raw_temp |= data;
return (float) raw_temp / 100.0 + _calibration_data.temperature_offset;
}
bool QMC5883L_is_data_available(void)
@ -105,10 +96,15 @@ QMC5883L_MData_t QMC5883L_get_MFields_raw(void)
QMC5883L_MData_calibrated_t QMC5883L_get_MFields_calibrated(void)
{
/* Read the raw magnetic field values first */
QMC5883L_MData_t raw_data = QMC5883L_get_MFields_raw();
uint8_t data[6];
QMC5883L_MData_calibrated_t Mdata = {.MFieldX = -1, .MFieldY = -1, .MFieldZ = -1};
QMC5883L_MData_calibrated_t Mdata = {.MFieldX = raw_data.MFieldX, .MFieldY = raw_data.MFieldY, .MFieldZ = raw_data.MFieldZ};
if(i2c_read(QMC5883L_I2C_ADDR, QMC5883L_DATA_X_LSB_REG, data, sizeof data))
{
Mdata.MFieldX = (data[1] << 8) | data[0];
Mdata.MFieldY = (data[3] << 8) | data[2];
Mdata.MFieldZ = (data[5] << 8) | data[4];
}
int x_offset = (_calibration_data.x_min + _calibration_data.x_max) / 2;
int y_offset = (_calibration_data.y_min + _calibration_data.y_max) / 2;

View File

@ -1,13 +1,3 @@
/**
* @file QMC5883L.h
* @author Anatole SCHRAMM-HENRY
* @brief QMC5883L magnetometer functions API header file.
* @version 0.1
* @date 2025-03-17
*
* @copyright MIT
*/
#ifndef QMC5883L_H
#define QMC5883L_H

View File

@ -1,14 +1,3 @@
/**
* @file watch_peripherals.c
* @author Anatole SCHRAMM-HENRY
* @brief Defines various functions to interract with some of the watch's
* peripherals like : reading the battery voltage, using the vibration motor etc.
* @version 0.1
* @date 2025-04-29
*
* @copyright MIT
*/
#include "watch_peripherals.h"
#include "app_config.h"
#include "app_log.h"
@ -24,7 +13,6 @@
#include "CST816D.h"
#include "app_utils.h"
#include "watch_settings.h"
#include "FreeRTOS.h"
#define INTERRUPT_POLICY (0)
#define POLL_POLICY (1)
@ -58,10 +46,8 @@ static battery_controller_status_e _battery_fsm = BATTERY_CONTROLLER_STATUS_DISC
static BatteryControllerStatusChangeCb_t _BatteryControllerStatusChangeCb = NULL;
/* Wakeup source boolean */
static struct
{
bool is_io:1, is_timer:1, is_rtc_alarm:1;
} _wakeup_src = {false, false, false};
static bool _wakeup_is_io = false;
static bool _wakeup_is_timer = false;
/* BMA456 structure */
static struct
@ -201,25 +187,17 @@ typedef enum wakeup_source
{
WAKEUP_SOURCE_IO = 0,
WAKEUP_SOURCE_TIMER,
WAKEUP_SOURCE_RTC_ALARM,
} wakeup_source_e;
static void pmu_wakeup_source_irq_cb(void *arg)
{
wakeup_source_e wakeup_source = (wakeup_source_e)arg;
switch(wakeup_source)
{
case WAKEUP_SOURCE_IO:
_wakeup_src.is_io = true;
break;
case WAKEUP_SOURCE_TIMER:
_wakeup_src.is_timer = true;
break;
case WAKEUP_SOURCE_RTC_ALARM:
_wakeup_src.is_rtc_alarm = true;
break;
}
if(wakeup_source == WAKEUP_SOURCE_IO)
_wakeup_is_io = true;
if(wakeup_source == WAKEUP_SOURCE_TIMER)
_wakeup_is_timer = true;
}
static void watch_peripherals_io_init(void)
@ -248,7 +226,6 @@ static void watch_peripherals_io_init(void)
/* We register the IRQs needed to determine the watch wake up source/reason */
tls_pmu_gpio_isr_register(&(pmu_wakeup_source_irq_cb), (void *)WAKEUP_SOURCE_IO);
tls_pmu_timer0_isr_register(&(pmu_wakeup_source_irq_cb), (void *)WAKEUP_SOURCE_TIMER);
tls_rtc_isr_register(&(pmu_wakeup_source_irq_cb), (void *)WAKEUP_SOURCE_RTC_ALARM);
}
#ifndef CASE_RETURN_STR
@ -487,9 +464,9 @@ void watch_peripherals_set_orientation(LCDOrientation_e orientation)
bool watch_peripherals_wakeup_source_is_user(void)
{
if(_wakeup_src.is_io)
if(_wakeup_is_io)
{
_wakeup_src.is_io = false;
_wakeup_is_io = false;
return true;
}
return false;
@ -497,19 +474,9 @@ bool watch_peripherals_wakeup_source_is_user(void)
bool watch_peripherals_wakeup_source_is_timer(void)
{
if(_wakeup_src.is_timer)
if(_wakeup_is_timer)
{
_wakeup_src.is_timer = false;
return true;
}
return false;
}
bool watch_peripherals_wakeup_source_is_rtc_alarm(void)
{
if(_wakeup_src.is_rtc_alarm)
{
_wakeup_src.is_rtc_alarm = false;
_wakeup_is_timer = false;
return true;
}
return false;
@ -572,12 +539,9 @@ uint16_t watch_peripherals_magnetometer_azimuth_read(bool *is_data_available)
return QMC5883L_get_azimuth(MData);
}
watch_peripherals_axes_t watch_peripherals_magnetometer_raw_data_read(void)
QMC5883L_MData_t watch_peripherals_magnetometer_raw_data_read(void)
{
QMC5883L_MData_t MData = QMC5883L_get_MFields_raw();
watch_peripherals_axes_t axes = {.mag.x = MData.MFieldX, .mag.y = MData.MFieldY, .mag.z = MData.MFieldZ};
return axes;
return QMC5883L_get_MFields_raw();
}
float watch_peripherals_magnetometer_temperature_read()
@ -627,8 +591,7 @@ bool watch_peripherals_pressure_sensor_select_profile(watch_peripherals_pressure
float watch_peripherals_pressure_sensor_get_pressure(float * const temperature)
{
BMP280_trigger_measurement();
/* Not great but needed to avoid an I2C wait ack err */
tls_os_time_delay(pdMS_TO_TICKS(2));
while(BMP280_is_measuring());
return BMP280_get_pressure(temperature);
@ -823,41 +786,6 @@ bool watch_peripherals_accelerometer_step_count_reset(void)
return true;
}
bool watch_peripherals_accelerometer_temperature_read(float *temperature)
{
if(!temperature) return false;
int32_t raw_temperature;
if(bma4_get_temperature(&raw_temperature, BMA4_DEG, &_bma456.bma) != BMA4_OK)
{
APP_LOG_ERROR("Failed to read temperature");
return false;
}
*temperature = raw_temperature / 1000.0F;
return true;
}
bool watch_peripherals_accelerometer_accel_read(watch_peripherals_axes_t *axes)
{
if(!axes)
return false;
struct bma4_accel acceleration = { .x = -1, .y = -1, .z = -1};
if(bma4_read_accel_xyz(&acceleration, &_bma456.bma) != BMA4_OK)
{
APP_LOG_ERROR("Failed to read the acceleration");
return false;
}
axes->accel.x = acceleration.x;
axes->accel.y = acceleration.y;
axes->accel.z = acceleration.z;
return true;
}
void watch_peripherals_watch_sleep(void)
{
extern LCDConfig_t LCDConfig;

View File

@ -1,14 +1,7 @@
/**
* @file watch_peripherals.h
* @author Anatole SCHRAMM-HENRY
* @brief Declares various functions to interract with some of the watch's
* peripherals like : reading the battery voltage, using the vibration motor etc.
* @version 0.1
* @date 2025-04-29
*
* @copyright MIT
* Declares various functions to interract with some of the watch's
* peripherals like : reading the battery voltage, using the vibration motor etc.
*/
#ifndef WATCH_PERIPHERALS_H
#define WATCH_PERIPHERALS_H
@ -32,23 +25,6 @@ typedef enum battery_controller_status
BATTERY_CONTROLLER_STATUS_ERROR
} battery_controller_status_e;
typedef union watch_peripherals_axes
{
struct
{
int16_t x;
int16_t y;
int16_t z;
} accel;
struct
{
int16_t x;
int16_t y;
int16_t z;
} mag;
} watch_peripherals_axes_t;
typedef void (*BatteryControllerStatusChangeCb_t)(battery_controller_status_e old, battery_controller_status_e new);
/**
@ -166,7 +142,6 @@ void watch_peripherals_set_orientation(LCDOrientation_e orientation);
/**
* @brief Check if the watch woke up because of the user(trigger on the wakeup pin : wrist tilt or touch screen).
* Calling this function clears the wakeup source flag.
*
* @return true if the source of the wakeup is the user
* @return false otherwise
@ -175,22 +150,12 @@ bool watch_peripherals_wakeup_source_is_user(void);
/**
* @brief Check if the watch woke up because of a timed event (timer 0 of the PMU module).
* Calling this function clears the wakeup source flag.
*
* @return true if the source of the wake up is the timer 0
* @return false otherwise
*/
bool watch_peripherals_wakeup_source_is_timer(void);
/**
* @brief Check if the watch woke up because of a RTC alarm event.
* Calling this function clears the wakeup source flag.
*
* @return true if the source of the wake up is the RTC alarm
* @return false otherwise
*/
bool watch_peripherals_wakeup_source_is_rtc_alarm(void);
bool watch_peripherals_magnetometer_init(void);
void watch_peripherals_magnetometer_calibration_data_set(
@ -201,7 +166,7 @@ void watch_peripherals_magnetometer_calibration_data_set(
uint16_t watch_peripherals_magnetometer_azimuth_read(bool *is_data_available);
watch_peripherals_axes_t watch_peripherals_magnetometer_raw_data_read(void);
QMC5883L_MData_t watch_peripherals_magnetometer_raw_data_read(void);
float watch_peripherals_magnetometer_temperature_read();
@ -217,12 +182,6 @@ typedef enum watch_peripherals_pressure_sensor_profile
bool watch_peripherals_pressure_sensor_select_profile(watch_peripherals_pressure_sensor_profile_e profile);
/**
* @brief Returns the measured pressure by the sensor in Pa and temperature in °C.
*
* @param temperature the address of a float which will contain the measured temperature in °C. If not needed, can be NULL.
* @return float the value of the pressure in Pa
*/
float watch_peripherals_pressure_sensor_get_pressure(float * const temperature);
bool watch_peripherals_accelerometer_init(void);
@ -237,24 +196,6 @@ bool watch_peripherals_accelerometer_step_count_read(uint32_t *step_count);
bool watch_peripherals_accelerometer_step_count_reset(void);
/**
* @brief Reads the accelerometer's temperature in °C.
*
* @param temperature the address of a float which will contain the measured temperature in °C.
* @return true if the temperature could be retrieved
* @return false otherwise
*/
bool watch_peripherals_accelerometer_temperature_read(float *temperature);
/**
* @brief Reads the accelerometer's acceleration on the X,Y and Z axes.
*
* @param axes the address of an union of type @ref watch_peripherals_axes_t used to store the values.
* @return true if the acceleration could be retrieved
* @return false otherwise
*/
bool watch_peripherals_accelerometer_accel_read(watch_peripherals_axes_t *axes);
void watch_peripherals_watch_sleep(void);
#endif //WATCH_PERIPHERALS_H

View File

@ -2,6 +2,7 @@
#include "app_utils.h"
#include "app_log.h"
#include "wm_crypto_hard.h"
#include "wm_regs.h"
static uint32_t _elapsed_ms = 0;
@ -91,3 +92,21 @@ uint32_t random_gen_6_digit(void)
return output_num;
}
static void print_reg_full(const char * reg_name, unsigned int addr, uint8_t size)
{
unsigned int *reg_addr = (unsigned int *)addr;
printf("%s :"NEW_LINE, reg_name);
for(uint8_t i = 0; i < size; i++)
{
printf("[0x%08X] => 0x%08X"NEW_LINE, (unsigned int)reg_addr, tls_reg_read32((unsigned int)reg_addr));
reg_addr++;
}
}
void register_dump(void)
{
print_reg_full("PMU REG", HR_PMU_BASE_ADDR, 64);
print_reg_full("CLK REG", HR_CLK_BASE_ADDR, 64);
print_reg_full("BT MODEM", 0x40012200,128);
}

View File

@ -3,17 +3,6 @@
#include "wm_include.h"
/**
* @brief Macro used to stringify the value of a define.
*/
#define STRINGIFY_VALUE(x) STRINGIFY(x)
/**
* @brief Macro used to stringify a define.
*/
#define STRINGIFY(x) #x
/**
* @brief Wait for the specified time in micro seconds. This is a blocking function !
*
@ -49,4 +38,10 @@ uint32_t elapsed_ms(void);
*/
uint32_t random_gen_6_digit(void);
/**
* @brief Debug function used to dump register values
*
*/
void register_dump(void);
#endif //APP_UTILS_H

View File

@ -75,9 +75,6 @@ bool ble_modem_off(void)
}
};
// Don't forget to set the rf bt mode to it's default config
tls_rf_bt_mode(false);
status = tls_bt_deinit();
if((status != BLE_HS_ENOERR) && (status != BLE_HS_EALREADY)) {
@ -86,8 +83,8 @@ bool ble_modem_off(void)
if(status != BLE_HS_EALREADY)
{
// Starting a wifi scan really stops the BT modem ?? Why ? I don't know
tls_wifi_passive_scan();
//Starting a wifi scan really stops the BT modem ?? Why ? I don't know
tls_wifi_scan();
}
return ((status == BLE_HS_ENOERR || status == BLE_HS_EALREADY) && serviceStopSuccess) ? true : false;

View File

@ -36,22 +36,12 @@
/**
* @brief Reworked the altimeter app to display the time and date on the altitude screen,
* Added a PMU related function to start the 32k OSC calibration routine.
* added a PMU related function to start the 32k OSC calibration routine.
* Added 'û' and 'Û' characters to the LVGL font.
* Other minor changes.
*
*/
//#define FIRMWARE_VERSION "0.0.6"
/**
* @brief Improved BLE start and stop handling (unidentified current leak of 1mA when BLE is turned off fixed)
* Added a 3 second timer to show the watch minute and hour hands again after the user decided to hide them.
* Reworked the settings screen : added a new sensor category displaying sensor data.
* Reworked the settings screen : removed displayed sensor data in the about section and added components versions.
* Other minor improvements : some i2c driver enhancement.
*
*/
#define FIRMWARE_VERSION "0.0.7"
#define FIRMWARE_VERSION "0.0.6"
#define FIRMWARE_COMPILATION_TIME_DATE (__TIME__" "__DATE__)

View File

@ -6,8 +6,6 @@
#include "lv_port_indev.h"
#include "lv_port_tick.h"
#include "FreeRTOS.h"
/* Needed to retrieve FreeRTOS version */
#include "task.h"
#include "wm_include.h"
#include "lcd.h"
#include "watch_face.h"
@ -331,6 +329,7 @@ static void setBLEEnabledCb(bool *enabled, SettingMode_e mode)
music_player_screen_notify_BLE_connection_state(&musicPlayerScreen, false);
}
}
register_dump();
}
}
@ -381,51 +380,12 @@ static void getBatteryVoltageCb(uint16_t *battery_voltage)
static void getMagnetometerRawDataCb(int16_t *field_x, int16_t *field_y, int16_t *field_z, float *temperature)
{
if(field_x && field_y && field_z)
{
watch_peripherals_axes_t axes = watch_peripherals_magnetometer_raw_data_read();
*field_x = axes.mag.x;
*field_y = axes.mag.y;
*field_z = axes.mag.z;
}
QMC5883L_MData_t raw_data = watch_peripherals_magnetometer_raw_data_read();
*field_x = raw_data.MFieldX;
*field_y = raw_data.MFieldY;
*field_z = raw_data.MFieldZ;
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");
}
}
*temperature = watch_peripherals_magnetometer_temperature_read();
}
static void getBMP280DataCb(float *temperature, float *pressure)
@ -434,21 +394,6 @@ static void getBMP280DataCb(float *temperature, float *pressure)
*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)
{
// Only enable the settings save feature if we compile in SMART_WATCH_PCB_RELEASE mode
@ -507,9 +452,7 @@ SettingsScreenAPIInterface_t settingsScreenAPIInterface =
.getBLEDevicePairingKeyCb = &(getBLEDevicePairingKeyCb),
.getBatteryVoltageCb = &(getBatteryVoltageCb),
.getMagnetometerRawDataCb = &(getMagnetometerRawDataCb),
.getAccelerometerRawDataCb = &(getAccelerometerRawDataCb),
.getBMP280DataCb = &(getBMP280DataCb),
.getComponentVersionCb = &(getComponentVersionCb),
.saveSettingsCb = &(saveSettingsToFlashCb),
.factoryResetCb = &(performFactoryResetCb),
};
@ -690,13 +633,13 @@ static void settings_screen_on_state_change_cb(SettingsScreenState_e settingsScr
switch(settingsScreenState)
{
case SETTINGS_SCREEN_STATE_OPENED:
if(settingsScreenCategory == SETTINGS_SCREEN_CATEGORY_SENSORS)
if(settingsScreenCategory == SETTINGS_SCREEN_CATEGORY_ABOUT)
{
watch_peripherals_magnetometer_power_mode_set(QMC5883L_Mode_Control_Continuous);
}
break;
case SETTINGS_SCREEN_STATE_CLOSED:
if(settingsScreenCategory == SETTINGS_SCREEN_CATEGORY_SENSORS)
if(settingsScreenCategory == SETTINGS_SCREEN_CATEGORY_ABOUT)
{
watch_peripherals_magnetometer_power_mode_set(QMC5883L_Mode_Control_Standby);
}
@ -875,8 +818,7 @@ void gfx_task(void *param)
watch_face_register_step_counter_indicator_cb(&watchFace, &(step_count_cb));
watch_face_create(&watchFace);
/* 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);
lv_scr_load(watchFace.display);
//QMC5883L_set_calibration_data(-900, 2500, -1400, 1400, 2300, 7500, 0.0);
@ -896,6 +838,8 @@ void gfx_task(void *param)
uint32_t ble_info_update_ms = 0;
uint32_t main_data_update = 0;
register_dump();
for(;;)
{

View File

@ -6,31 +6,19 @@
#include "translation.h"
#include "firmware_version.h"
/**
* @brief Defines the visual spacing between lines of setting members in a category.
*/
#define SETTINGS_SCREEN_CATEGORY_SPACING_INNER (3)
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\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40";
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";
/**
* @brief Defines the visual spacing between different setting categories.
*/
#define SETTINGS_SCREEN_CATEGORY_SPACING_OUTER (10)
static const char *timeout_options = "Off\n5 seconds\n10 seconds\n15 seconds\n20 seconds\n25 seconds\n30 seconds\n35 seconds\n40 seconds\n45 seconds\n50 seconds\n55 seconds\n60 seconds";
static const char *orientation_format = "Default\n90°\n180°\n270°";
static const char* vibration_duration = "None\n100 ms\n150 ms\n200 ms\n250 ms\n300 ms\n350 ms\n400 ms";
static const char* vibration_strength = "1\n2\n3\n4\n5\n6\n7\n8";
static const char * const 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 * const month_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12";
static const char * const year_options = "22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40";
static const char * const 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 * const 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 * const date_format = "dd/mm/yyyy\ndd/mm/yy\nyyyy/mm/dd\nyy/mm/dd";
static const char * const timeout_options = "Off\n5 seconds\n10 seconds\n15 seconds\n20 seconds\n25 seconds\n30 seconds\n35 seconds\n40 seconds\n45 seconds\n50 seconds\n55 seconds\n60 seconds";
static const char * const orientation_format = "Default\n90°\n180°\n270°";
static const char * const vibration_duration = "None\n100 ms\n150 ms\n200 ms\n250 ms\n300 ms\n350 ms\n400 ms";
static const char * const vibration_strength = "1\n2\n3\n4\n5\n6\n7\n8";
static const char * const language_options = "Francais\nDeutsch\nEnglish";
static const char * const default_version = "NaN";
static const char* language_options = "Francais\nDeutsch\nEnglish";
typedef enum roller_id
{
@ -54,17 +42,12 @@ typedef enum switch_id
static lv_obj_t *add_menu_list_item(lv_obj_t *list, const char *text, lv_event_cb_t event_cb, void *user_data, SettingsScreenCategory_e category);
static void update_menu_list_item_text(lv_obj_t *menu_list_item, const char *text);
static void _simulate_side_screen_item_click(SettingsScreen_t * const settingsScreen, lv_obj_t *item);
/* Helper functions used to update sensor label data */
static void _simulate_side_screen_item_click(SettingsScreen_t * const settingsScreen, lv_obj_t *item);
static void _set_rtc_time_to_label(SettingsScreen_t * const settingsScreen);
static void _set_battery_voltage_to_label(SettingsScreen_t * const settingsScreen);
static void _set_magnetometer_axes_to_label(SettingsScreen_t * const settingsScreen);
static void _set_magnetometer_temperature_to_label(SettingsScreen_t * const settingsScreen);
static void _set_accelerometer_axes_to_label(SettingsScreen_t * const settingsScreen);
static void _set_accelerometer_steps_and_temperature_to_label(SettingsScreen_t * const settingsScreen);
static void _set_pressure_sensor_to_label(SettingsScreen_t * const settingsScreen);
static void _set_magnetometer_data_to_label(SettingsScreen_t * const settingsScreen);
static void _set_bmp280_data_to_label(SettingsScreen_t * const settingsScreen);
static void _enable_time_and_date_rollers(bool enabled, SettingsScreen_t * const settingsScreen);
static void _show_ble_pairing_key(SettingsScreen_t * const settingsScreen, bool show);
@ -79,7 +62,6 @@ static void _settings_screen_update_labels_language(SettingsScreen_t * const set
update_menu_list_item_text(settingsScreen->display_item, translation_get_word(TRANSLATION_DISPLAY));
update_menu_list_item_text(settingsScreen->notifications_item, translation_get_word(TRANSLATION_NOTIFICATIONS));
update_menu_list_item_text(settingsScreen->connectivity_item, translation_get_word(TRANSLATION_CONNECTIVITY));
update_menu_list_item_text(settingsScreen->sensors_item, translation_get_word(TRANSLATION_SENSORS));
update_menu_list_item_text(settingsScreen->language_item, translation_get_word(TRANSLATION_LANGUAGE));
update_menu_list_item_text(settingsScreen->about_item, translation_get_word(TRANSLATION_ABOUT));
}
@ -97,7 +79,7 @@ static void gesture_event_cb(lv_event_t *e)
case LV_DIR_RIGHT:
LV_LOG_USER("GESTURE : RIGHT");
// We delete the timer if it was created
if(settingsScreen->sensors_refresh_timer)lv_timer_del(settingsScreen->sensors_refresh_timer);
if(settingsScreen->about_refresh_timer)lv_timer_del(settingsScreen->about_refresh_timer);
// We create the menu screen and switch to it
extern MenuScreen_t menuScreen;
menu_screen_create(&menuScreen);
@ -324,26 +306,21 @@ static void factory_reset_cb(lv_event_t *e)
if(settingsScreen->settingsScreenAPIInterface.factoryResetCb) settingsScreen->settingsScreenAPIInterface.factoryResetCb();
}
static void sensors_refresh_timer_cb(lv_timer_t *timer)
static void about_refresh_timer_cb(lv_timer_t *timer)
{
SettingsScreen_t *settingsScreen = timer->user_data;
/* Timer callback is called every 150 ms,
some data don't need that update rate */
static uint8_t timer_divider = 6;
if(!settingsScreen->about_refresh_timer) return;
static uint8_t timer_divider = 6;
if(timer_divider++ == 6)
{
_set_rtc_time_to_label(settingsScreen);
_set_battery_voltage_to_label(settingsScreen);
_set_pressure_sensor_to_label(settingsScreen);
_set_magnetometer_temperature_to_label(settingsScreen);
_set_accelerometer_steps_and_temperature_to_label(settingsScreen);
_set_bmp280_data_to_label(settingsScreen);
timer_divider = 0;
}
_set_magnetometer_axes_to_label(settingsScreen);
_set_accelerometer_axes_to_label(settingsScreen);
_set_magnetometer_data_to_label(settingsScreen);
}
static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen)
@ -357,7 +334,7 @@ static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen)
lv_obj_t *switch_obj = lv_switch_create(settingsScreen->side_screen);
lv_obj_set_user_data(switch_obj, (void *)SWITCH_ID_AUTOMATIC_TIME_ENABLE);
lv_obj_align_to(switch_obj, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(switch_obj, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
bool auto_set_enable = false;
if(settingsScreen->settingsScreenAPIInterface.setAutomaticTimeSettingsCb)settingsScreen->settingsScreenAPIInterface.setAutomaticTimeSettingsCb(&auto_set_enable, SETTING_MODE_GET);
if(auto_set_enable)
@ -372,7 +349,7 @@ static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen)
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Time :");
lv_obj_align_to(label, switch_obj, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(label, switch_obj, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
settingsScreen->hour_roller = lv_roller_create(settingsScreen->side_screen);
settingsScreen->minute_roller = lv_roller_create(settingsScreen->side_screen);
@ -398,14 +375,14 @@ static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen)
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Time Format :");
lv_obj_align_to(label, settingsScreen->hour_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(label, settingsScreen->hour_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
bool is_24H_format = true;
if(settingsScreen->settingsScreenAPIInterface.setTimeFormatSettingsCb)settingsScreen->settingsScreenAPIInterface.setTimeFormatSettingsCb(&is_24H_format, SETTING_MODE_GET);
settingsScreen->checkbox_time_12H = lv_checkbox_create(settingsScreen->side_screen);
lv_checkbox_set_text(settingsScreen->checkbox_time_12H, "12H");
lv_obj_set_style_radius(settingsScreen->checkbox_time_12H, LV_RADIUS_CIRCLE, LV_PART_INDICATOR);
lv_obj_align_to(settingsScreen->checkbox_time_12H, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(settingsScreen->checkbox_time_12H, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_obj_add_event_cb(settingsScreen->checkbox_time_12H, &(time_format_cb), LV_EVENT_CLICKED, settingsScreen);
settingsScreen->checkbox_time_24H = lv_checkbox_create(settingsScreen->side_screen);
@ -427,14 +404,14 @@ static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen)
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Date :");
lv_obj_align_to(label, settingsScreen->checkbox_time_12H, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(label, settingsScreen->checkbox_time_12H, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
settingsScreen->day_roller = lv_roller_create(settingsScreen->side_screen);
settingsScreen->month_roller = lv_roller_create(settingsScreen->side_screen);
settingsScreen->year_roller = lv_roller_create(settingsScreen->side_screen);
lv_roller_set_options(settingsScreen->day_roller, day_options, LV_ROLLER_MODE_NORMAL);
lv_obj_align_to(settingsScreen->day_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(settingsScreen->day_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_roller_set_visible_row_count(settingsScreen->day_roller, 2);
lv_roller_set_selected(settingsScreen->day_roller, day-1, LV_ANIM_OFF);
lv_obj_add_event_cb(settingsScreen->day_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen);
@ -455,11 +432,11 @@ static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen)
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Date Format :");
lv_obj_align_to(label, settingsScreen->day_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(label, settingsScreen->day_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_obj_t *date_dropdown = lv_dropdown_create(settingsScreen->side_screen);
lv_dropdown_set_options_static(date_dropdown, date_format);
lv_obj_align_to(date_dropdown, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(date_dropdown, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
}
static void load_display_side_screen(SettingsScreen_t *settingsScreen)
@ -468,7 +445,7 @@ static void load_display_side_screen(SettingsScreen_t *settingsScreen)
lv_label_set_text_static(label, "Brightness :");
lv_obj_t *slider = lv_slider_create(settingsScreen->side_screen);
lv_obj_align_to(slider, label, LV_ALIGN_OUT_BOTTOM_LEFT, 10, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(slider, label, LV_ALIGN_OUT_BOTTOM_LEFT, 10, 10);
lv_obj_clear_flag(slider, LV_OBJ_FLAG_GESTURE_BUBBLE);
lv_obj_set_width(slider, lv_pct(90));
lv_slider_set_range(slider, 1, 255);
@ -479,10 +456,10 @@ static void load_display_side_screen(SettingsScreen_t *settingsScreen)
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Display Off After :");
lv_obj_align_to(label, slider, LV_ALIGN_OUT_BOTTOM_LEFT, -10, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(label, slider, LV_ALIGN_OUT_BOTTOM_LEFT, -10, 10);
lv_obj_t *timeout_roller = lv_roller_create(settingsScreen->side_screen);
lv_obj_align_to(timeout_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 10, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(timeout_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 10, 10);
lv_roller_set_options(timeout_roller, timeout_options, LV_ROLLER_MODE_NORMAL);
lv_roller_set_visible_row_count(timeout_roller, 2);
uint8_t timeout = 0;
@ -492,10 +469,10 @@ static void load_display_side_screen(SettingsScreen_t *settingsScreen)
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Screen Orientation :");
lv_obj_align_to(label, timeout_roller, LV_ALIGN_OUT_BOTTOM_LEFT, -10, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(label, timeout_roller, LV_ALIGN_OUT_BOTTOM_LEFT, -10, 10);
lv_obj_t *orientation_dropdown = lv_dropdown_create(settingsScreen->side_screen);
lv_obj_align_to(orientation_dropdown, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(orientation_dropdown, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_dropdown_set_options_static(orientation_dropdown, orientation_format);
uint8_t orientation = 0;
if(settingsScreen->settingsScreenAPIInterface.setOrientationSettingsCb)settingsScreen->settingsScreenAPIInterface.setOrientationSettingsCb(&orientation, SETTING_MODE_GET);
@ -504,14 +481,14 @@ static void load_display_side_screen(SettingsScreen_t *settingsScreen)
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Wakeup :");
lv_obj_align_to(label, orientation_dropdown, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(label, orientation_dropdown, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_obj_t *switch_obj = lv_switch_create(settingsScreen->side_screen);
lv_obj_set_user_data(switch_obj, (void *)SWITCH_ID_WRIST_TILT_ENABLE);
bool toggled = false;
if(settingsScreen->settingsScreenAPIInterface.setWristTiltSettingsCb)settingsScreen->settingsScreenAPIInterface.setWristTiltSettingsCb(&toggled, SETTING_MODE_GET);
if(toggled)lv_obj_add_state(switch_obj, LV_STATE_CHECKED);
lv_obj_align_to(switch_obj, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(switch_obj, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_obj_add_event_cb(switch_obj, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen);
label = lv_label_create(settingsScreen->side_screen);
@ -520,10 +497,10 @@ static void load_display_side_screen(SettingsScreen_t *settingsScreen)
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Vibrate On Touch :");
lv_obj_align_to(label, switch_obj, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(label, switch_obj, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_obj_t *on_touch_vibration_duration_roller = lv_roller_create(settingsScreen->side_screen);
lv_obj_align_to(on_touch_vibration_duration_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(on_touch_vibration_duration_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_roller_set_options(on_touch_vibration_duration_roller, vibration_duration, LV_ROLLER_MODE_NORMAL);
lv_obj_set_user_data(on_touch_vibration_duration_roller, (void *)ROLLER_ID_TOUCH_VIBRATION_DURATION);
lv_roller_set_visible_row_count(on_touch_vibration_duration_roller, 2);
@ -537,7 +514,7 @@ static void load_display_side_screen(SettingsScreen_t *settingsScreen)
lv_obj_align_to(label, on_touch_vibration_duration_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
lv_obj_t *on_touch_vibration_strength_roller = lv_roller_create(settingsScreen->side_screen);
lv_obj_align_to(on_touch_vibration_strength_roller, on_touch_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(on_touch_vibration_strength_roller, on_touch_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_roller_set_options(on_touch_vibration_strength_roller, vibration_strength, LV_ROLLER_MODE_NORMAL);
lv_obj_set_user_data(on_touch_vibration_strength_roller, (void *)ROLLER_ID_TOUCH_VIBRATION_STRENGTH);
lv_roller_set_visible_row_count(on_touch_vibration_strength_roller, 2);
@ -565,7 +542,7 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen)
if(settingsScreen->settingsScreenAPIInterface.setNotificationEnabledSettingsCb)
settingsScreen->settingsScreenAPIInterface.setNotificationEnabledSettingsCb(&toggled, SETTING_MODE_GET);
if(toggled)lv_obj_add_state(notification_enable_switch, LV_STATE_CHECKED);
lv_obj_align_to(notification_enable_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(notification_enable_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_obj_add_event_cb(notification_enable_switch, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen);
label = lv_label_create(settingsScreen->side_screen);
@ -574,7 +551,7 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen)
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Vibrate On\nNotifications :");
lv_obj_align_to(label, notification_enable_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(label, notification_enable_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_obj_t *on_notification_vibration_duration_roller = lv_roller_create(settingsScreen->side_screen);
lv_obj_align_to(on_notification_vibration_duration_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
@ -592,7 +569,7 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen)
lv_obj_align_to(label, on_notification_vibration_duration_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
lv_obj_t *on_notification_vibration_strength_roller = lv_roller_create(settingsScreen->side_screen);
lv_obj_align_to(on_notification_vibration_strength_roller, on_notification_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(on_notification_vibration_strength_roller, on_notification_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_roller_set_options(on_notification_vibration_strength_roller, vibration_strength, LV_ROLLER_MODE_NORMAL);
lv_obj_set_user_data(on_notification_vibration_strength_roller, (void *)ROLLER_ID_NOTIFICATION_VIBRATION_STRENGTH);
lv_roller_set_visible_row_count(on_notification_vibration_strength_roller, 2);
@ -610,7 +587,7 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen)
//Calls notification header text
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Calls\nNotifications :");
lv_obj_align_to(label, on_notification_vibration_strength_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(label, on_notification_vibration_strength_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
// Call enable switch
lv_obj_t *call_enable_switch = lv_switch_create(settingsScreen->side_screen);
@ -619,7 +596,7 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen)
if(settingsScreen->settingsScreenAPIInterface.setCallEnabledSettingsCb)
settingsScreen->settingsScreenAPIInterface.setCallEnabledSettingsCb(&toggled, SETTING_MODE_GET);
if(toggled)lv_obj_add_state(call_enable_switch, LV_STATE_CHECKED);
lv_obj_align_to(call_enable_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(call_enable_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_obj_add_event_cb(call_enable_switch, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen);
label = lv_label_create(settingsScreen->side_screen);
@ -628,10 +605,10 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen)
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Vibrate On Calls :");
lv_obj_align_to(label, call_enable_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(label, call_enable_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_obj_t *on_call_vibration_duration_roller = lv_roller_create(settingsScreen->side_screen);
lv_obj_align_to(on_call_vibration_duration_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(on_call_vibration_duration_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_roller_set_options(on_call_vibration_duration_roller, vibration_duration, LV_ROLLER_MODE_NORMAL);
lv_obj_set_user_data(on_call_vibration_duration_roller, (void *)ROLLER_ID_CALL_VIBRATION_DURATION);
lv_roller_set_visible_row_count(on_call_vibration_duration_roller, 2);
@ -646,7 +623,7 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen)
lv_obj_align_to(label, on_call_vibration_duration_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
lv_obj_t *on_call_vibration_strength_roller = lv_roller_create(settingsScreen->side_screen);
lv_obj_align_to(on_call_vibration_strength_roller, on_call_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(on_call_vibration_strength_roller, on_call_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_roller_set_options(on_call_vibration_strength_roller, vibration_strength, LV_ROLLER_MODE_NORMAL);
lv_obj_set_user_data(on_call_vibration_strength_roller, (void *)ROLLER_ID_CALL_VIBRATION_STRENGTH);
lv_roller_set_visible_row_count(on_call_vibration_strength_roller, 2);
@ -664,41 +641,45 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen)
static void load_connectivity_side_screen(SettingsScreen_t *settingsScreen)
{
lv_obj_t *label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Connectivity :");
settingsScreen->ble_switch = lv_switch_create(settingsScreen->side_screen);
lv_obj_set_user_data(settingsScreen->ble_switch, (void *)SWITCH_ID_BLE_ENABLE);
lv_obj_align_to(settingsScreen->ble_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
bool ble_toggled = false;
if(settingsScreen->settingsScreenAPIInterface.setBLEEnabledSettingsCb)settingsScreen->settingsScreenAPIInterface.setBLEEnabledSettingsCb(&ble_toggled, SETTING_MODE_GET);
if(ble_toggled) lv_obj_add_state(settingsScreen->ble_switch, LV_STATE_CHECKED);
lv_obj_add_event_cb(settingsScreen->ble_switch, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen);
lv_obj_t *label = lv_label_create(settingsScreen->side_screen);
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Bluetooth");
lv_obj_align_to(label, settingsScreen->ble_switch, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
settingsScreen->ble_pairing_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(settingsScreen->ble_pairing_label, "Pairing Code :");
lv_obj_align_to(settingsScreen->ble_pairing_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(settingsScreen->ble_pairing_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_add_flag(settingsScreen->ble_pairing_label, LV_OBJ_FLAG_HIDDEN);
settingsScreen->ble_pairing_key.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->ble_pairing_key.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->ble_pairing_key.label, settingsScreen->ble_pairing_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
lv_obj_align_to(settingsScreen->ble_pairing_key.label, settingsScreen->ble_pairing_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_add_flag(settingsScreen->ble_pairing_key.label, LV_OBJ_FLAG_HIDDEN);
settingsScreen->ble_dev_name_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(settingsScreen->ble_dev_name_label, "Device Name :");
lv_obj_align_to(settingsScreen->ble_dev_name_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(settingsScreen->ble_dev_name_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
settingsScreen->ble_dev_name_value = lv_label_create(settingsScreen->side_screen);
const char * ble_dev_name = NULL;
if(settingsScreen->settingsScreenAPIInterface.getBLEDeviceNameCb) settingsScreen->settingsScreenAPIInterface.getBLEDeviceNameCb(&ble_dev_name);
lv_label_set_text_static(settingsScreen->ble_dev_name_value, ble_dev_name);
lv_obj_set_style_text_color(settingsScreen->ble_dev_name_value, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->ble_dev_name_value, settingsScreen->ble_dev_name_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
lv_obj_align_to(settingsScreen->ble_dev_name_value, settingsScreen->ble_dev_name_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
settingsScreen->ble_dev_mac_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(settingsScreen->ble_dev_mac_label, "Device MAC :");
lv_obj_align_to(settingsScreen->ble_dev_mac_label, settingsScreen->ble_dev_name_value, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(settingsScreen->ble_dev_mac_label, settingsScreen->ble_dev_name_value, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
settingsScreen->ble_mac_addr.label = lv_label_create(settingsScreen->side_screen);
const uint8_t *ble_dev_mac = NULL;
@ -714,11 +695,11 @@ static void load_connectivity_side_screen(SettingsScreen_t *settingsScreen)
}
lv_label_set_text_static(settingsScreen->ble_mac_addr.label, settingsScreen->ble_mac_addr.text);
lv_obj_set_style_text_color(settingsScreen->ble_mac_addr.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->ble_mac_addr.label, settingsScreen->ble_dev_mac_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
lv_obj_align_to(settingsScreen->ble_mac_addr.label, settingsScreen->ble_dev_mac_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
settingsScreen->wifi_switch = lv_switch_create(settingsScreen->side_screen);
lv_obj_set_user_data(settingsScreen->wifi_switch, (void *)SWITCH_ID_WIFI_ENABLE);
lv_obj_align_to(settingsScreen->wifi_switch, settingsScreen->ble_mac_addr.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(settingsScreen->wifi_switch, settingsScreen->ble_mac_addr.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
bool wifi_toggled = false;
if(settingsScreen->settingsScreenAPIInterface.setWiFiEnabledSettingsCb)settingsScreen->settingsScreenAPIInterface.setWiFiEnabledSettingsCb(&wifi_toggled, SETTING_MODE_GET);
if(wifi_toggled) lv_obj_add_state(settingsScreen->wifi_switch, LV_STATE_CHECKED);
@ -733,119 +714,13 @@ static void load_connectivity_side_screen(SettingsScreen_t *settingsScreen)
_show_ble_pairing_key(settingsScreen, ble_toggled);
}
static void load_sensors_side_screen(SettingsScreen_t *settingsScreen)
{
/* First, display the RTC time */
lv_obj_t *rtc_time = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(rtc_time, "System Clock :");
settingsScreen->sensors_labels.clock.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.clock.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.clock.label, rtc_time, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
_set_rtc_time_to_label(settingsScreen);
/* Let's display the magnetometer data */
lv_obj_t *magnetometer_data = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(magnetometer_data, "Magnetometer :");
lv_obj_align_to(magnetometer_data, settingsScreen->sensors_labels.clock.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
settingsScreen->sensors_labels.magnetometer.x.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.magnetometer.x.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.magnetometer.x.label, magnetometer_data, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 3);
settingsScreen->sensors_labels.magnetometer.y.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.magnetometer.y.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.magnetometer.y.label, settingsScreen->sensors_labels.magnetometer.x.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
settingsScreen->sensors_labels.magnetometer.z.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.magnetometer.z.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.magnetometer.z.label, settingsScreen->sensors_labels.magnetometer.y.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
settingsScreen->sensors_labels.magnetometer.temperature.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.magnetometer.temperature.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.magnetometer.temperature.label, settingsScreen->sensors_labels.magnetometer.z.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
_set_magnetometer_axes_to_label(settingsScreen);
_set_magnetometer_temperature_to_label(settingsScreen);
lv_obj_update_layout(settingsScreen->sensors_labels.magnetometer.temperature.label);
lv_obj_t *magnetometer_cal_btn = lv_btn_create(settingsScreen->side_screen);
lv_obj_align(magnetometer_cal_btn, LV_ALIGN_TOP_MID, 0, lv_obj_get_y(settingsScreen->sensors_labels.magnetometer.temperature.label) + lv_obj_get_height(settingsScreen->sensors_labels.magnetometer.temperature.label) + SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
lv_obj_t *magnetometer_cal_btn_label = lv_label_create(magnetometer_cal_btn);
lv_label_set_text_static(magnetometer_cal_btn_label, "Calibrate");
lv_obj_center(magnetometer_cal_btn_label);
lv_obj_update_layout(magnetometer_cal_btn);
/* Let's display the accelerometer data */
lv_obj_t *accelerometer_data = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(accelerometer_data, "Accelerometer :");
lv_obj_align(accelerometer_data, LV_ALIGN_TOP_LEFT, 0, lv_obj_get_y(magnetometer_cal_btn) + lv_obj_get_height(magnetometer_cal_btn) + SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
settingsScreen->sensors_labels.accelerometer.x.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.accelerometer.x.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.accelerometer.x.label, accelerometer_data, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
settingsScreen->sensors_labels.accelerometer.y.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.accelerometer.y.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.accelerometer.y.label, settingsScreen->sensors_labels.accelerometer.x.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
settingsScreen->sensors_labels.accelerometer.z.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.accelerometer.z.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.accelerometer.z.label, settingsScreen->sensors_labels.accelerometer.y.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
settingsScreen->sensors_labels.accelerometer.temperature.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.accelerometer.temperature.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.accelerometer.temperature.label, settingsScreen->sensors_labels.accelerometer.z.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
settingsScreen->sensors_labels.accelerometer.steps.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.accelerometer.steps.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.accelerometer.steps.label, settingsScreen->sensors_labels.accelerometer.temperature.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
_set_accelerometer_axes_to_label(settingsScreen);
_set_accelerometer_steps_and_temperature_to_label(settingsScreen);
/* Let's display the pressure sensor data */
lv_obj_t *bmp280_data = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(bmp280_data, "Pressure &\nTemperature :");
lv_obj_align_to(bmp280_data, settingsScreen->sensors_labels.accelerometer.steps.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
settingsScreen->sensors_labels.pressure.pressure.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.pressure.pressure.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.pressure.pressure.label, bmp280_data, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
settingsScreen->sensors_labels.pressure.temperature.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.pressure.temperature.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.pressure.temperature.label, settingsScreen->sensors_labels.pressure.pressure.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
_set_pressure_sensor_to_label(settingsScreen);
/* Let's display the battery voltage */
lv_obj_t *battery_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(battery_label, "Battery Voltage :");
lv_obj_align_to(battery_label, settingsScreen->sensors_labels.pressure.temperature.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
settingsScreen->sensors_labels.battery_voltage.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->sensors_labels.battery_voltage.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->sensors_labels.battery_voltage.label, battery_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
_set_battery_voltage_to_label(settingsScreen);
/* Create and start the refresh timer */
if(settingsScreen->sensors_refresh_timer)
{
LV_LOG_ERROR("sensors_refresh_timer should be NULL here !");
lv_timer_del(settingsScreen->sensors_refresh_timer);
settingsScreen->sensors_refresh_timer = NULL;
}
settingsScreen->sensors_refresh_timer = lv_timer_create(&(sensors_refresh_timer_cb), 150, settingsScreen);
}
static void load_language_side_screen(SettingsScreen_t *settingsScreen)
{
settingsScreen->language_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(settingsScreen->language_label, translation_get_word(TRANSLATION_LANGUAGE_2));
lv_obj_t *language_dropdown = lv_dropdown_create(settingsScreen->side_screen);
lv_obj_align_to(language_dropdown, settingsScreen->language_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(language_dropdown, settingsScreen->language_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_dropdown_set_options_static(language_dropdown, language_options);
uint8_t language = 0;
if(settingsScreen->settingsScreenAPIInterface.setLanguageSettingsCb)settingsScreen->settingsScreenAPIInterface.setLanguageSettingsCb(&language, SETTING_MODE_GET);
@ -860,64 +735,97 @@ static void load_about_side_screen(SettingsScreen_t *settingsScreen)
lv_obj_t *firmware_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(firmware_label, "Firmware :");
lv_obj_align_to(firmware_label, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(firmware_label, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_obj_t *version_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(version_label, FIRMWARE_VERSION);
lv_obj_set_style_text_color(version_label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(version_label, firmware_label, LV_ALIGN_OUT_RIGHT_MID, 7, 0);
lv_obj_t *compile_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(compile_label, "Compile Date :");
lv_obj_align_to(compile_label, firmware_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_t* compile_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(compile_label, "Compile date :");
lv_obj_align_to(compile_label, firmware_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_t *compile_date_label = lv_label_create(settingsScreen->side_screen);
lv_obj_t* compile_date_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(compile_date_label, FIRMWARE_COMPILATION_TIME_DATE);
lv_obj_set_style_text_color(compile_date_label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(compile_date_label, compile_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
lv_obj_align_to(compile_date_label, compile_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
/* Display other firmware component's versions */
lv_obj_t *freertos_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(freertos_label, "FreeRTOS Version :");
lv_obj_align_to(freertos_label, compile_date_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_t* rtc_time = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(rtc_time, "RTC :");
lv_obj_align_to(rtc_time, compile_date_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_t *freertos_version_label = lv_label_create(settingsScreen->side_screen);
/* Display current time and date with refresh */
settingsScreen->currentTime.current_time_label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->currentTime.current_time_label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->currentTime.current_time_label, rtc_time, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
_set_rtc_time_to_label(settingsScreen);
const char *freertos_version = default_version;
if(settingsScreen->settingsScreenAPIInterface.getComponentVersionCb)
settingsScreen->settingsScreenAPIInterface.getComponentVersionCb(&freertos_version, COMPONENT_FREERTOS);
lv_obj_t *magnetometer_data = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(magnetometer_data, "Magnetometer :");
lv_obj_align_to(magnetometer_data, settingsScreen->currentTime.current_time_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_label_set_text_static(freertos_version_label, freertos_version);
/* Display the magnetometer raw data with refresh */
settingsScreen->magnetometer_x.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->magnetometer_x.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->magnetometer_x.label, magnetometer_data, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_set_style_text_color(freertos_version_label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(freertos_version_label, freertos_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
settingsScreen->magnetometer_y.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->magnetometer_y.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->magnetometer_y.label, settingsScreen->magnetometer_x.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_t *lvgl_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(lvgl_label, "LVGL Version :");
lv_obj_align_to(lvgl_label, freertos_version_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
settingsScreen->magnetometer_z.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->magnetometer_z.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->magnetometer_z.label, settingsScreen->magnetometer_y.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_t *lvgl_version_label = lv_label_create(settingsScreen->side_screen);
settingsScreen->magnetometer_temperature.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->magnetometer_temperature.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->magnetometer_temperature.label, settingsScreen->magnetometer_z.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
_set_magnetometer_data_to_label(settingsScreen);
const char *lvgl_version = default_version;
if(settingsScreen->settingsScreenAPIInterface.getComponentVersionCb)
settingsScreen->settingsScreenAPIInterface.getComponentVersionCb(&lvgl_version, COMPONENT_LVGL);
lv_obj_t *bmp280_data = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(bmp280_data, "Pressure & temp :");
lv_obj_align_to(bmp280_data, settingsScreen->magnetometer_temperature.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_label_set_text_static(lvgl_version_label, lvgl_version);
/* Display pressure and temperature sensor data with refresh */
settingsScreen->bmp280_pressure.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->bmp280_pressure.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->bmp280_pressure.label, bmp280_data, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_set_style_text_color(lvgl_version_label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(lvgl_version_label, lvgl_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
settingsScreen->bmp280_temperature.label = lv_label_create(settingsScreen->side_screen);
lv_obj_set_style_text_color(settingsScreen->bmp280_temperature.label, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->bmp280_temperature.label, settingsScreen->bmp280_pressure.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
_set_bmp280_data_to_label(settingsScreen);
lv_obj_t *battery_label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(battery_label, "Battery Voltage :");
lv_obj_align_to(battery_label, settingsScreen->bmp280_temperature.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
settingsScreen->batteryVoltage.batteryVoltageLabel = lv_label_create(settingsScreen->side_screen);
_set_battery_voltage_to_label(settingsScreen);
lv_obj_set_style_text_color(settingsScreen->batteryVoltage.batteryVoltageLabel, lv_color_make(130, 130, 130), LV_PART_MAIN);
lv_obj_align_to(settingsScreen->batteryVoltage.batteryVoltageLabel, battery_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
label = lv_label_create(settingsScreen->side_screen);
lv_label_set_text_static(label, "Factory Reset :");
lv_obj_align_to(label, lvgl_version_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(label, settingsScreen->batteryVoltage.batteryVoltageLabel, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_t *factory_rst_btn = lv_btn_create(settingsScreen->side_screen);
lv_obj_align_to(factory_rst_btn, label, LV_ALIGN_OUT_BOTTOM_MID, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(factory_rst_btn, label, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
lv_obj_add_event_cb(factory_rst_btn, &(factory_reset_cb), LV_EVENT_CLICKED, settingsScreen);
label = lv_label_create(factory_rst_btn);
lv_label_set_text_static(label, "Reset");
lv_obj_center(label);
/* Create and start the refresh timer */
if(settingsScreen->about_refresh_timer)
{
LV_LOG_ERROR("about_refresh_timer should be NULL here !");
lv_timer_del(settingsScreen->about_refresh_timer);
settingsScreen->about_refresh_timer = NULL;
}
settingsScreen->about_refresh_timer = lv_timer_create(&(about_refresh_timer_cb), 150, settingsScreen);
}
static void menu_list_item_event_handler(lv_event_t * e)
@ -1010,7 +918,6 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen)
lv_obj_set_style_radius(settingsScreen->side_screen, 0, LV_PART_MAIN);
lv_obj_set_style_border_width(settingsScreen->side_screen, 0, LV_PART_MAIN);
lv_obj_set_style_pad_left(settingsScreen->side_screen, 5, LV_PART_MAIN);
// Add some padding to make the settings page scroll longer
lv_obj_set_style_pad_bottom(settingsScreen->side_screen, 70, LV_PART_MAIN);
lv_obj_set_scroll_dir(settingsScreen->side_screen, LV_DIR_VER);
@ -1019,7 +926,6 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen)
settingsScreen->display_item = add_menu_list_item(menu_list, translation_get_word(TRANSLATION_DISPLAY), &(menu_list_item_event_handler), settingsScreen, SETTINGS_SCREEN_CATEGORY_DISPLAY);
settingsScreen->notifications_item = add_menu_list_item(menu_list, translation_get_word(TRANSLATION_NOTIFICATIONS), &(menu_list_item_event_handler), settingsScreen, SETTINGS_SCREEN_CATEGORY_NOTIFICATION);
settingsScreen->connectivity_item = add_menu_list_item(menu_list, translation_get_word(TRANSLATION_CONNECTIVITY), &(menu_list_item_event_handler), settingsScreen, SETTINGS_SCREEN_CATEGORY_CONNECTIVITY);
settingsScreen->sensors_item = add_menu_list_item(menu_list, translation_get_word(TRANSLATION_SENSORS), &(menu_list_item_event_handler), settingsScreen, SETTINGS_SCREEN_CATEGORY_SENSORS);
settingsScreen->language_item = add_menu_list_item(menu_list, translation_get_word(TRANSLATION_LANGUAGE), &(menu_list_item_event_handler), settingsScreen, SETTINGS_SCREEN_CATEGORY_LANGUAGE);
settingsScreen->about_item = add_menu_list_item(menu_list, translation_get_word(TRANSLATION_ABOUT), &(menu_list_item_event_handler), settingsScreen, SETTINGS_SCREEN_CATEGORY_ABOUT);
@ -1046,26 +952,26 @@ void settings_screen_destroy(SettingsScreen_t * const settingsScreen)
settingsScreen->settingsScreenOnStateChangeCb(SETTINGS_SCREEN_STATE_CLOSED, (SettingsScreenCategory_e)lv_obj_get_user_data(settingsScreen->last_selected_item));
}
settingsScreen->hour_roller = NULL;
settingsScreen->minute_roller = NULL;
settingsScreen->second_roller = NULL;
settingsScreen->day_roller = NULL;
settingsScreen->month_roller = NULL;
settingsScreen->year_roller = NULL;
settingsScreen->display = NULL;
settingsScreen->sensors_refresh_timer = NULL;
settingsScreen->last_selected_item = NULL;
settingsScreen->language_label = NULL;
settingsScreen->hour_roller = NULL;
settingsScreen->minute_roller = NULL;
settingsScreen->second_roller = NULL;
settingsScreen->day_roller = NULL;
settingsScreen->month_roller = NULL;
settingsScreen->year_roller = NULL;
settingsScreen->display = NULL;
settingsScreen->about_refresh_timer = NULL;
settingsScreen->last_selected_item = NULL;
settingsScreen->language_label = NULL;
}
static void _simulate_side_screen_item_click(SettingsScreen_t * const settingsScreen, lv_obj_t *item)
{
if(settingsScreen->last_selected_item == item) return;
if(settingsScreen->last_selected_item == settingsScreen->sensors_item)
if(settingsScreen->last_selected_item == settingsScreen->about_item)
{
lv_timer_del(settingsScreen->sensors_refresh_timer);
settingsScreen->sensors_refresh_timer = NULL;
lv_timer_del(settingsScreen->about_refresh_timer);
settingsScreen->about_refresh_timer = NULL;
}
// Updating the background of the selected category
@ -1111,10 +1017,6 @@ static void _simulate_side_screen_item_click(SettingsScreen_t * const settingsSc
{
load_connectivity_side_screen(settingsScreen);
}
else if(item == settingsScreen->sensors_item)
{
load_sensors_side_screen(settingsScreen);
}
else if(item == settingsScreen->language_item)
{
load_language_side_screen(settingsScreen);
@ -1127,130 +1029,56 @@ static void _simulate_side_screen_item_click(SettingsScreen_t * const settingsSc
static void _set_rtc_time_to_label(SettingsScreen_t * const settingsScreen)
{
uint8_t hour = 0U, minute = 0U, second = 0U, day = 0U, month = 0U, year = 0U;
uint8_t hour = 0, minute = 0, second = 0, day = 0, month = 0, year = 0;
if(settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb)
settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(&hour, &minute, &second, &day, &month, &year, SETTING_MODE_GET);
snprintf(settingsScreen->sensors_labels.clock.text,
sizeof(settingsScreen->sensors_labels.clock.text)-1, "%s%u:%s%u:%s%u %s%u/%s%u/%u",
sprintf(settingsScreen->currentTime.current_time_text, "%s%u:%s%u:%s%u %s%u/%s%u/%u",
hour < 10 ? "0":"", hour,
minute < 10 ? "0":"", minute,
second < 10 ? "0":"", second,
day < 10 ? "0":"", day,
month + 1 < 10 ? "0":"", month + 1,
year+1900);
lv_label_set_text_static(settingsScreen->sensors_labels.clock.label, settingsScreen->sensors_labels.clock.text);
lv_label_set_text_static(settingsScreen->currentTime.current_time_label, settingsScreen->currentTime.current_time_text);
}
static void _set_battery_voltage_to_label(SettingsScreen_t * const settingsScreen)
{
uint16_t voltage = 0U;
uint16_t voltage = 0;
if(settingsScreen->settingsScreenAPIInterface.getBatteryVoltageCb) settingsScreen->settingsScreenAPIInterface.getBatteryVoltageCb(&voltage);
snprintf(settingsScreen->sensors_labels.battery_voltage.text,
sizeof(settingsScreen->sensors_labels.battery_voltage.text)-1, "%u mV", voltage);
lv_label_set_text_static(settingsScreen->sensors_labels.battery_voltage.label, settingsScreen->sensors_labels.battery_voltage.text);
sprintf(settingsScreen->batteryVoltage.batteryVoltageText, "%u mV", voltage);
lv_label_set_text_static(settingsScreen->batteryVoltage.batteryVoltageLabel, settingsScreen->batteryVoltage.batteryVoltageText);
}
static void _set_magnetometer_axes_to_label(SettingsScreen_t * const settingsScreen)
static void _set_magnetometer_data_to_label(SettingsScreen_t * const settingsScreen)
{
int16_t field_x = 0, field_y = 0, field_z = 0;
float temperature = 0.0;
if(settingsScreen->settingsScreenAPIInterface.getMagnetometerRawDataCb) settingsScreen->settingsScreenAPIInterface.getMagnetometerRawDataCb(&field_x, &field_y, &field_z, &temperature);
if(settingsScreen->settingsScreenAPIInterface.getMagnetometerRawDataCb)
settingsScreen->settingsScreenAPIInterface.getMagnetometerRawDataCb(&field_x,
&field_y,
&field_z,
NULL);
snprintf(settingsScreen->sensors_labels.magnetometer.x.text,
sizeof(settingsScreen->sensors_labels.magnetometer.x.text)-1,
"x: %d", field_x);
snprintf(settingsScreen->sensors_labels.magnetometer.y.text,
sizeof(settingsScreen->sensors_labels.magnetometer.y.text)-1,
"y: %d", field_y);
snprintf(settingsScreen->sensors_labels.magnetometer.z.text,
sizeof(settingsScreen->sensors_labels.magnetometer.z.text)-1,
"z: %d", field_z);
sprintf(settingsScreen->magnetometer_x.text, "x: %d", field_x);
lv_label_set_text_static(settingsScreen->magnetometer_x.label, settingsScreen->magnetometer_x.text);
lv_label_set_text_static(settingsScreen->sensors_labels.magnetometer.x.label, settingsScreen->sensors_labels.magnetometer.x.text);
lv_label_set_text_static(settingsScreen->sensors_labels.magnetometer.y.label, settingsScreen->sensors_labels.magnetometer.y.text);
lv_label_set_text_static(settingsScreen->sensors_labels.magnetometer.z.label, settingsScreen->sensors_labels.magnetometer.z.text);
sprintf(settingsScreen->magnetometer_y.text, "y: %d", field_y);
lv_label_set_text_static(settingsScreen->magnetometer_y.label, settingsScreen->magnetometer_y.text);
sprintf(settingsScreen->magnetometer_z.text, "z: %d", field_z);
lv_label_set_text_static(settingsScreen->magnetometer_z.label, settingsScreen->magnetometer_z.text);
sprintf(settingsScreen->magnetometer_temperature.text, "%.2f °C", temperature);
lv_label_set_text_static(settingsScreen->magnetometer_temperature.label, settingsScreen->magnetometer_temperature.text);
}
static void _set_magnetometer_temperature_to_label(SettingsScreen_t * const settingsScreen)
static void _set_bmp280_data_to_label(SettingsScreen_t * const settingsScreen)
{
float temperature = 0.0f;
if(settingsScreen->settingsScreenAPIInterface.getMagnetometerRawDataCb)
settingsScreen->settingsScreenAPIInterface.getMagnetometerRawDataCb(NULL,
NULL,
NULL,
&temperature);
snprintf(settingsScreen->sensors_labels.magnetometer.temperature.text,
sizeof(settingsScreen->sensors_labels.magnetometer.temperature.text)-1,
"%.2f °C", temperature);
lv_label_set_text_static(settingsScreen->sensors_labels.magnetometer.temperature.label, settingsScreen->sensors_labels.magnetometer.temperature.text);
}
static void _set_accelerometer_axes_to_label(SettingsScreen_t * const settingsScreen)
{
int16_t accel_x = 0, accel_y = 0, accel_z = 0;
if(settingsScreen->settingsScreenAPIInterface.getAccelerometerRawDataCb)
settingsScreen->settingsScreenAPIInterface.getAccelerometerRawDataCb(&accel_x,
&accel_y,
&accel_z,
NULL,
NULL);
snprintf(settingsScreen->sensors_labels.accelerometer.x.text,
sizeof(settingsScreen->sensors_labels.accelerometer.x.text)-1,
"x: %d", accel_x);
snprintf(settingsScreen->sensors_labels.accelerometer.y.text,
sizeof(settingsScreen->sensors_labels.accelerometer.y.text)-1,
"y: %d", accel_y);
snprintf(settingsScreen->sensors_labels.accelerometer.z.text,
sizeof(settingsScreen->sensors_labels.accelerometer.z.text)-1,
"z: %d", accel_z);
lv_label_set_text_static(settingsScreen->sensors_labels.accelerometer.x.label, settingsScreen->sensors_labels.accelerometer.x.text);
lv_label_set_text_static(settingsScreen->sensors_labels.accelerometer.y.label, settingsScreen->sensors_labels.accelerometer.y.text);
lv_label_set_text_static(settingsScreen->sensors_labels.accelerometer.z.label, settingsScreen->sensors_labels.accelerometer.z.text);
}
static void _set_accelerometer_steps_and_temperature_to_label(SettingsScreen_t * const settingsScreen)
{
float temperature = 0.0F;
uint32_t steps = 0U;
if(settingsScreen->settingsScreenAPIInterface.getAccelerometerRawDataCb)
settingsScreen->settingsScreenAPIInterface.getAccelerometerRawDataCb(NULL,
NULL,
NULL,
&temperature,
&steps);
snprintf(settingsScreen->sensors_labels.accelerometer.temperature.text,
sizeof(settingsScreen->sensors_labels.accelerometer.temperature.text)-1,
"%.2f °C", temperature);
snprintf(settingsScreen->sensors_labels.accelerometer.steps.text,
sizeof(settingsScreen->sensors_labels.accelerometer.steps.text)-1,
"%s: %u", "steps", steps);
lv_label_set_text_static(settingsScreen->sensors_labels.accelerometer.temperature.label, settingsScreen->sensors_labels.accelerometer.temperature.text);
lv_label_set_text_static(settingsScreen->sensors_labels.accelerometer.steps.label, settingsScreen->sensors_labels.accelerometer.steps.text);
}
static void _set_pressure_sensor_to_label(SettingsScreen_t * const settingsScreen)
{
float pressure = 0.0F, temperature = 0.0F;
float pressure = 0.0, temperature = 0.0;
if(settingsScreen->settingsScreenAPIInterface.getBMP280DataCb) settingsScreen->settingsScreenAPIInterface.getBMP280DataCb(&temperature, &pressure);
snprintf(settingsScreen->sensors_labels.pressure.pressure.text, sizeof(settingsScreen->sensors_labels.pressure.pressure.text)-1, "%.2f hPa", pressure);
snprintf(settingsScreen->sensors_labels.pressure.temperature.text, sizeof(settingsScreen->sensors_labels.pressure.temperature.text)-1, "%.2f °C", temperature);
sprintf(settingsScreen->bmp280_pressure.text, "%.2f hPa", pressure);
lv_label_set_text_static(settingsScreen->bmp280_pressure.label, settingsScreen->bmp280_pressure.text);
lv_label_set_text_static(settingsScreen->sensors_labels.pressure.pressure.label, settingsScreen->sensors_labels.pressure.pressure.text);
lv_label_set_text_static(settingsScreen->sensors_labels.pressure.temperature.label, settingsScreen->sensors_labels.pressure.temperature.text);
sprintf(settingsScreen->bmp280_temperature.text, "%.2f °C", temperature);
lv_label_set_text_static(settingsScreen->bmp280_temperature.label, settingsScreen->bmp280_temperature.text);
}
static void _enable_time_and_date_rollers(bool enabled, SettingsScreen_t * const settingsScreen)
@ -1316,7 +1144,7 @@ static void update_menu_list_item_text(lv_obj_t *menu_list_item, const char *tex
static void _show_ble_pairing_key(SettingsScreen_t * const settingsScreen, bool show)
{
lv_obj_align_to(settingsScreen->ble_pairing_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(settingsScreen->ble_pairing_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
if(show)
{
uint32_t pairing_key = 0;
@ -1324,7 +1152,7 @@ static void _show_ble_pairing_key(SettingsScreen_t * const settingsScreen, bool
sprintf(settingsScreen->ble_pairing_key.text, "%u", pairing_key);
lv_label_set_text_static(settingsScreen->ble_pairing_key.label, settingsScreen->ble_pairing_key.text);
lv_obj_align_to(settingsScreen->ble_dev_name_label, settingsScreen->ble_pairing_key.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(settingsScreen->ble_dev_name_label, settingsScreen->ble_pairing_key.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_clear_flag(settingsScreen->ble_pairing_label, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(settingsScreen->ble_pairing_key.label, LV_OBJ_FLAG_HIDDEN);
}
@ -1332,12 +1160,12 @@ static void _show_ble_pairing_key(SettingsScreen_t * const settingsScreen, bool
{
lv_obj_add_flag(settingsScreen->ble_pairing_key.label, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(settingsScreen->ble_pairing_label, LV_OBJ_FLAG_HIDDEN);
lv_obj_align_to(settingsScreen->ble_dev_name_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(settingsScreen->ble_dev_name_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
}
lv_obj_align_to(settingsScreen->ble_dev_name_value, settingsScreen->ble_dev_name_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
lv_obj_align_to(settingsScreen->ble_dev_mac_label, settingsScreen->ble_dev_name_value, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(settingsScreen->ble_mac_addr.label, settingsScreen->ble_dev_mac_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER);
lv_obj_align_to(settingsScreen->wifi_switch, settingsScreen->ble_mac_addr.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER);
lv_obj_align_to(settingsScreen->ble_dev_name_value, settingsScreen->ble_dev_name_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_align_to(settingsScreen->ble_dev_mac_label, settingsScreen->ble_dev_name_value, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_align_to(settingsScreen->ble_mac_addr.label, settingsScreen->ble_dev_mac_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5);
lv_obj_align_to(settingsScreen->wifi_switch, settingsScreen->ble_mac_addr.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
lv_obj_align_to(settingsScreen->wifi_label, settingsScreen->wifi_switch, LV_ALIGN_OUT_RIGHT_MID, 10, 0);
}

View File

@ -9,12 +9,6 @@ typedef enum SettingMode
SETTING_MODE_SET
} SettingMode_e;
typedef enum ComponentVersion
{
COMPONENT_FREERTOS = 0,
COMPONENT_LVGL
} ComponentVersion_e;
typedef struct SettingsScreenAPIInterface
{
void (*setAutomaticTimeSettingsCb)(bool *enabled, SettingMode_e mode);
@ -40,9 +34,7 @@ typedef struct SettingsScreenAPIInterface
void (*getBLEDevicePairingKeyCb)(uint32_t *pairing_key);
void (*getBatteryVoltageCb)(uint16_t *battery_voltage);
void (*getMagnetometerRawDataCb)(int16_t *field_x, int16_t *field_y, int16_t *field_z, float *temperature);
void (*getAccelerometerRawDataCb)(int16_t *accel_x, int16_t *accel_y, int16_t *accel_z, float *temperature, uint32_t *step_count);
void (*getBMP280DataCb)(float *temperature, float *pressure);
void (*getComponentVersionCb)(const char **version, ComponentVersion_e component);
void (*saveSettingsCb)(void);
void (*factoryResetCb)(void);
} SettingsScreenAPIInterface_t;
@ -59,7 +51,6 @@ typedef enum SettingsScreenCategory
SETTINGS_SCREEN_CATEGORY_DISPLAY,
SETTINGS_SCREEN_CATEGORY_NOTIFICATION,
SETTINGS_SCREEN_CATEGORY_CONNECTIVITY,
SETTINGS_SCREEN_CATEGORY_SENSORS,
SETTINGS_SCREEN_CATEGORY_LANGUAGE,
SETTINGS_SCREEN_CATEGORY_ABOUT,
} SettingsScreenCategory_e;
@ -75,7 +66,6 @@ typedef struct SettingsScreen
lv_obj_t *display_item;
lv_obj_t *notifications_item;
lv_obj_t *connectivity_item;
lv_obj_t *sensors_item;
lv_obj_t *language_item;
lv_obj_t *about_item;
/* Remember the last clicked item needed for the background color logic */
@ -101,66 +91,30 @@ typedef struct SettingsScreen
lv_obj_t *ble_dev_mac_label;
lv_obj_t *language_label;
struct
{
struct
{
lv_obj_t *label;
char text[20];
} clock;
struct
{
struct
{
lv_obj_t *label;
char text[11];
} x, y, z, temperature;
} magnetometer;
struct
{
struct
{
lv_obj_t *label;
char text[11];
} x, y, z, temperature;
struct
{
lv_obj_t *label;
char text[18];
} steps;
} accelerometer;
struct
{
struct
{
lv_obj_t *label;
char text[13];
} pressure;
struct
{
lv_obj_t *label;
char text[11];
} temperature;
} pressure;
struct
{
lv_obj_t *label;
char text[8];
} battery_voltage;
} sensors_labels;
struct
{
lv_obj_t *current_time_label;
char current_time_text[20];
} currentTime;
struct
{
lv_obj_t *batteryVoltageLabel;
char batteryVoltageText[8];
} batteryVoltage;
struct
{
lv_obj_t *label;
char text[11];
} magnetometer_x, magnetometer_y, magnetometer_z, magnetometer_temperature, bmp280_temperature;
struct
{
lv_obj_t *label;
char text[13];
} bmp280_pressure;
struct
{
lv_obj_t *label;
@ -177,7 +131,7 @@ typedef struct SettingsScreen
lv_obj_t *display;
/* Other */
lv_timer_t *sensors_refresh_timer;
lv_timer_t *about_refresh_timer;
SettingsScreenOnStateChangeCb_t settingsScreenOnStateChangeCb;
SettingsScreenUserFeedbackCb_t settingsScreenUserFeedbackCb;
} SettingsScreen_t;

View File

@ -1,13 +1,3 @@
/**
* @file watch_face.c
* @author Anatole SCHRAMM-HENRY
* @brief Watch face source file implementing API functions.
* @version 0.1
* @date 2025-04-29
*
* @copyright MIT
*/
#include "lvgl.h"
#include "watch_face.h"
#include "menu_screen.h"
@ -109,8 +99,6 @@ static void gesture_event_cb(lv_event_t *e)
// We delete the timer
lv_timer_del(watchFace->batteryIndicator.lowBatteryAnimationTimer);
lv_timer_del(watchFace->handAnimationTimer);
// Checking if timer is not NULL here because it could have been deleted already
if(watchFace->handHideTimer)lv_timer_del(watchFace->handHideTimer);
lv_timer_del(watchFace->stepCounterRefreshTimer);
// We create the menu screen and switch to it
extern MenuScreen_t menuScreen;
@ -239,13 +227,6 @@ static void set_battery_state_icon(WatchFace_t * const watchFace)
break;
}
}
static void hide_hour_and_minutes_hand_timer_cb(lv_timer_t *timer)
{
WatchFace_t *watchFace = timer->user_data;
watchFace->handHideTimer = NULL;
watch_face_show_hour_and_minute_hands(watchFace, true);
}
static void hide_hour_and_minutes_hand_cb(lv_event_t *e)
{
@ -253,28 +234,13 @@ static void hide_hour_and_minutes_hand_cb(lv_event_t *e)
if(lv_obj_has_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN))
{
if(watchFace->handHideTimer)
{
/* Make the timer execute now to re-display hands
and cleanly free the timer */
lv_timer_ready(watchFace->handHideTimer);
}
lv_obj_clear_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(watchFace->minuteHand.handImg, LV_OBJ_FLAG_HIDDEN);
}
else
{
// Let's hide the hands
watch_face_show_hour_and_minute_hands(watchFace, false);
// Let's start the hand hide timer
if(watchFace->handHideTimer)
{
LV_LOG_ERROR("handHideTimer should be NULL here !");
lv_timer_del(watchFace->handHideTimer);
watchFace->handHideTimer = NULL;
}
watchFace->handHideTimer = lv_timer_create(&(hide_hour_and_minutes_hand_timer_cb), 3000, watchFace);
// After the timer expires once, delete it by setting the repeat count to 1
lv_timer_set_repeat_count(watchFace->handHideTimer, 1);
lv_obj_add_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(watchFace->minuteHand.handImg, LV_OBJ_FLAG_HIDDEN);
}
}
@ -618,7 +584,6 @@ void watch_face_destroy(WatchFace_t * const watchFace)
watchFace->display = NULL;
watchFace->handAnimationTimer = NULL;
watchFace->handHideTimer = NULL;
watchFace->stepCounterRefreshTimer = NULL;
watchFace->dateWindow.dateWindowWidget = NULL;
watchFace->hourHand.handImg = NULL;
@ -646,29 +611,6 @@ void watch_face_force_sync(WatchFace_t *const watchFace)
update_watch_hands_angles(watchFace, 0);
}
void watch_face_show_hour_and_minute_hands(WatchFace_t * const watchFace, bool show)
{
if(!watchFace)
{
LV_LOG_ERROR("NULL pointer given !");
return;
}
if(watch_face_is_in_use(watchFace))
{
if(show && lv_obj_has_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN))
{
lv_obj_clear_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(watchFace->minuteHand.handImg, LV_OBJ_FLAG_HIDDEN);
}
else if(!show && !lv_obj_has_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN))
{
lv_obj_add_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(watchFace->minuteHand.handImg, LV_OBJ_FLAG_HIDDEN);
}
}
}
bool watch_face_is_in_use(WatchFace_t * const watchFace)
{
if(!watchFace)

View File

@ -1,13 +1,3 @@
/**
* @file watch_face.h
* @author Anatole SCHRAMM-HENRY
* @brief Watch face header file exposing related APIs.
* @version 0.1
* @date 2025-04-29
*
* @copyright MIT
*/
#ifndef WATCH_FACE_H
#define WATCH_FACE_H
@ -79,9 +69,7 @@ typedef struct WatchFace
WatchHand_t minuteHand;
WatchHand_t secondHand;
WatchHand_t mediumHand24h;
lv_timer_t *handAnimationTimer;
lv_timer_t *stepCounterRefreshTimer;
lv_timer_t *handHideTimer;
lv_timer_t *handAnimationTimer, *stepCounterRefreshTimer;
lv_obj_t *display;
DateWindow_t dateWindow;
BatteryIndicator_t batteryIndicator;
@ -131,6 +119,13 @@ void watch_face_register_step_counter_indicator_cb(WatchFace_t * const watchFace
*/
void watch_face_create(WatchFace_t * const watchFace);
/**
* @brief Sets the battery indicator to the given value in percent.
*
* @param watchFace a pointer to the watch face context structure.
* @param percentage the value to set the indicator to in percent.
*/
/**
* @brief Sets the battery level in percent as well as it's current state to draw on the watch face.
*
@ -157,26 +152,18 @@ void watch_face_set_bluetooth_indicator(WatchFace_t * const watchFace, Bluetooth
void watch_face_set_step_count_indicator(WatchFace_t * const watchFace, uint32_t stepCount);
/**
* @brief Forces the watch face to sync up with the RTC by calling the provided date_time_cb.
* @brief Forces the watch face to sync up with the RTC by calling the provided date_time_cb
*
* @param watchFace a pointer to the watch face context structure.
*/
void watch_face_force_sync(WatchFace_t * const watchFace);
/**
* @brief Show or hide the hour and minute hand on the watch face.
*
* @param watchFace a pointer to the watch face context structure.
* @param show a boolean value indicating if hands should be shown or not.
*/
void watch_face_show_hour_and_minute_hands(WatchFace_t * const watchFace, bool show);
/**
* @brief Returns true if the watch face screen is currently being used and displayed.
*
* @param watchFace a pointer to the watch face context structure.
* @return true if the watch face screen is being used.
* @return false if the watch face screen is not being used/currently displayed.
* @return true if the watch face screen is being used
* @return false if the watch face screen is not being used/currently displayed
*/
bool watch_face_is_in_use(WatchFace_t * const watchFace);

View File

@ -1,13 +1,3 @@
/**
* @file translation.c
* @author Anatole SCHRAMM-HENRY
* @brief Translation source file storing strings as const for each language.
* @version 0.1
* @date 2025-04-29
*
* @copyright MIT
*/
#include "wm_type_def.h"
#include "translation.h"
#include "watch_settings.h"
@ -74,11 +64,6 @@ static const char * const translation_dictionary[][TRANSLATED_LANGUAGES_COUNT] =
[TRANSLATION_GERMAN] = "Konnektivität",
[TRANSLATION_ENGLISH]= "Connectivity"
},
[TRANSLATION_SENSORS] = {
[TRANSLATION_FRENCH] = "Capteurs",
[TRANSLATION_GERMAN] = "Sensoren",
[TRANSLATION_ENGLISH]= "Sensors"
},
[TRANSLATION_LANGUAGE] = {
[TRANSLATION_FRENCH] = "Langue",
[TRANSLATION_GERMAN] = "Sprache",

View File

@ -1,13 +1,3 @@
/**
* @file translation.h
* @author Anatole SCHRAMM-HENRY
* @brief Translation header file listing supported languages, translated words and translation API functions.
* @version 0.1
* @date 2025-04-29
*
* @copyright MIT
*/
#ifndef TRANSLATION_H
#define TRANSLATION_H
@ -36,7 +26,6 @@ typedef enum TranslationWord
TRANSLATION_DISPLAY,
TRANSLATION_NOTIFICATIONS,
TRANSLATION_CONNECTIVITY,
TRANSLATION_SENSORS,
TRANSLATION_LANGUAGE,
TRANSLATION_LANGUAGE_2,
TRANSLATION_ABOUT,

View File

@ -3,7 +3,7 @@ sinclude $(TOP_DIR)/tools/w800/conf.mk
ifndef PDIR
GEN_LIBS = liblvgl$(LIB_EXT)
COMPONENTS_liblvgl = lvgl_v8.4/liblvglv8_4$(LIB_EXT) \
COMPONENTS_liblvgl = lvgl_v8.3/liblvglv8_3$(LIB_EXT) \
lvgl_port/liblvgl_port$(LIB_EXT)
endif

View File

@ -1,6 +1,6 @@
/**
* @file lv_conf.h
* Configuration file for v8.4.0
* Configuration file for v8.3.3
*/
/*
@ -49,7 +49,7 @@
#define LV_MEM_CUSTOM 0
#if LV_MEM_CUSTOM == 0
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
#define LV_MEM_SIZE (35U * 1024U) /*[bytes]*/
#define LV_MEM_SIZE (35 * 1024U) /*[bytes]*/
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
#define LV_MEM_ADR 0 /*0: unused*/
@ -89,9 +89,6 @@
#if LV_TICK_CUSTOM
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
/*If using lvgl as ESP32 component*/
// #define LV_TICK_CUSTOM_INCLUDE "esp_timer.h"
// #define LV_TICK_CUSTOM_SYS_TIME_EXPR ((esp_timer_get_time() / 1000LL))
#endif /*LV_TICK_CUSTOM*/
/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
@ -176,9 +173,6 @@
* GPU
*-----------*/
/*Use TSi's (aka Think Silicon) acceleration library NemaGFX */
#define LV_USE_NEMA_GFX 0
/*Use Arm's 2D acceleration library Arm-2D */
#define LV_USE_GPU_ARM2D 0
@ -186,18 +180,10 @@
#define LV_USE_GPU_STM32_DMA2D 0
#if LV_USE_GPU_STM32_DMA2D
/*Must be defined to include path of CMSIS header of target processor
e.g. "stm32f7xx.h" or "stm32f4xx.h"*/
e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#define LV_GPU_DMA2D_CMSIS_INCLUDE
#endif
/*Enable RA6M3 G2D GPU*/
#define LV_USE_GPU_RA6M3_G2D 0
#if LV_USE_GPU_RA6M3_G2D
/*include path of target processor
e.g. "hal_data.h"*/
#define LV_GPU_RA6M3_G2D_INCLUDE "hal_data.h"
#endif
/*Use SWM341's DMA2D GPU*/
#define LV_USE_GPU_SWM341_DMA2D 0
#if LV_USE_GPU_SWM341_DMA2D
@ -642,13 +628,6 @@
#define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
/*API for LittleFS (library needs to be added separately). Uses lfs_file_open, lfs_file_read, etc*/
#define LV_USE_FS_LITTLEFS 0
#if LV_USE_FS_LITTLEFS
#define LV_FS_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_LITTLEFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
/*PNG decoder library*/
#define LV_USE_PNG 0
@ -682,13 +661,6 @@
#endif
#endif
/*Tiny TTF library*/
#define LV_USE_TINY_TTF 0
#if LV_USE_TINY_TTF
/*Load TTF data from files*/
#define LV_TINY_TTF_FILE_SUPPORT 0
#endif
/*Rlottie library*/
#define LV_USE_RLOTTIE 0

View File

@ -1,4 +1,4 @@
# Kconfig file for LVGL v8.4
# Kconfig file for LVGL v8.0
menu "LVGL configuration"
@ -228,16 +228,6 @@ menu "LVGL configuration"
Must be defined to include path of CMSIS header of target processor
e.g. "stm32f769xx.h" or "stm32f429xx.h"
config LV_USE_GPU_RA6M3_G2D
bool "Enable RA6M3 G2D GPU."
config LV_GPU_RA6M3_G2D_INCLUDE
string "include path of target processor"
depends on LV_USE_GPU_RA6M3_G2D
default "hal_data.h"
help
Must be defined to include path of target processor
e.g. "hal_data.h"
config LV_USE_GPU_SWM341_DMA2D
bool "Enable SWM341 DMA2D GPU."
config LV_GPU_SWM341_DMA2D_INCLUDE
@ -921,8 +911,7 @@ menu "LVGL configuration"
string "Set the working directory"
depends on LV_USE_FS_STDIO
config LV_FS_STDIO_CACHE_SIZE
int ">0 to cache this number of bytes in lv_fs_read()"
default 0
string ">0 to cache this number of bytes in lv_fs_read()"
depends on LV_USE_FS_STDIO
config LV_USE_FS_POSIX
@ -964,17 +953,6 @@ menu "LVGL configuration"
default 0
depends on LV_USE_FS_FATFS
config LV_USE_FS_LITTLEFS
bool "File system on top of LittleFS"
config LV_FS_LITTLEFS_LETTER
int "Set an upper cased letter on which the drive will accessible (e.g. 'A' i.e. 65)"
default 0
depends on LV_USE_FS_LITTLEFS
config LV_FS_LITTLEFS_CACHE_SIZE
int ">0 to cache this number of bytes in lv_fs_read()"
default 0
depends on LV_USE_FS_LITTLEFS
config LV_USE_PNG
bool "PNG decoder library"
@ -1011,13 +989,6 @@ menu "LVGL configuration"
endmenu
endif
config LV_USE_TINY_TTF
bool "Tiny TTF library"
config LV_TINY_TTF_FILE_SUPPORT
bool "Load TTF data from files"
depends on LV_USE_TINY_TTF
default n
config LV_USE_RLOTTIE
bool "Lottie library"

View File

@ -2,8 +2,8 @@ TOP_DIR = ../..
sinclude $(TOP_DIR)/tools/w800/conf.mk
ifndef PDIR
GEN_LIBS = liblvglv8_4$(LIB_EXT)
COMPONENTS_liblvglv8_4 = src/liblvglsrc$(LIB_EXT) \
GEN_LIBS = liblvglv8_3$(LIB_EXT)
COMPONENTS_liblvglv8_3 = src/liblvglsrc$(LIB_EXT) \
demos/liblvgldemos$(LIB_EXT)
endif

View File

@ -16,8 +16,10 @@ LVGL provides everything you need to create an embedded GUI with easy-to-use gra
<a href="https://docs.lvgl.io/master/examples.html">Interactive examples</a>
</h4>
**English** | [中文](./README_zh.md) | [Português do Brasil](./README_pt_BR.md)
---
#### Table of content

View File

@ -89,7 +89,7 @@ LV_FONT_DECLARE(lv_font_benchmark_montserrat_16_compr_az);
LV_FONT_DECLARE(lv_font_benchmark_montserrat_28_compr_az);
static void monitor_cb(lv_disp_drv_t * drv, uint32_t time, uint32_t px);
static void next_scene_timer_cb(lv_timer_t * timer);
static void scene_next_task_cb(lv_timer_t * timer);
static void rect_create(lv_style_t * style);
static void img_create(lv_style_t * style, const void * src, bool rotate, bool zoom, bool aa);
static void txt_create(lv_style_t * style);
@ -226,6 +226,7 @@ static void shadow_small_ofs_cb(void)
rect_create(&style_common);
}
static void shadow_large_cb(void)
{
lv_style_reset(&style_common);
@ -249,6 +250,7 @@ static void shadow_large_ofs_cb(void)
rect_create(&style_common);
}
static void img_rgb_cb(void)
{
lv_style_reset(&style_common);
@ -291,6 +293,7 @@ static void img_alpha_cb(void)
img_create(&style_common, &img_benchmark_cogwheel_alpha16, false, false, false);
}
static void img_rgb_recolor_cb(void)
{
lv_style_reset(&style_common);
@ -379,6 +382,7 @@ static void img_rgb_zoom_aa_cb(void)
lv_style_set_img_opa(&style_common, opa_mode ? LV_OPA_50 : LV_OPA_COVER);
img_create(&style_common, &img_benchmark_cogwheel_rgb, false, true, true);
}
static void img_argb_zoom_cb(void)
@ -392,6 +396,7 @@ static void img_argb_zoom_cb(void)
#endif
}
static void img_argb_zoom_aa_cb(void)
{
lv_style_reset(&style_common);
@ -457,6 +462,7 @@ static void txt_large_compr_cb(void)
}
static void line_cb(void)
{
lv_style_reset(&style_common);
@ -484,6 +490,7 @@ static void arc_thick_cb(void)
}
static void sub_rectangle_cb(void)
{
lv_style_reset(&style_common);
@ -556,6 +563,8 @@ static void sub_text_cb(void)
txt_create(&style_common);
}
/**********************
* STATIC VARIABLES
**********************/
@ -627,7 +636,7 @@ static lv_obj_t * scene_bg;
static lv_obj_t * title;
static lv_obj_t * subtitle;
static uint32_t rnd_act;
static lv_timer_t * next_scene_timer;
static const uint32_t rnd_map[] = {
0xbd13204f, 0x67d8167f, 0x20211c99, 0xb0a7cc05,
@ -693,26 +702,15 @@ static void benchmark_init(void)
lv_obj_update_layout(scr);
}
void lv_demo_benchmark(void)
{
benchmark_init();
/*Manually start scenes*/
next_scene_timer_cb(NULL);
scene_next_task_cb(NULL);
}
void lv_demo_benchmark_close(void)
{
if(next_scene_timer) lv_timer_del(next_scene_timer);
next_scene_timer = NULL;
lv_anim_del(NULL, NULL);
lv_style_reset(&style_common);
lv_obj_clean(lv_scr_act());
}
void lv_demo_benchmark_run_scene(int_fast16_t scene_no)
{
@ -727,8 +725,8 @@ void lv_demo_benchmark_run_scene(int_fast16_t scene_no)
scene_act = scene_no >> 1;
if(scenes[scene_act].create_cb) {
lv_label_set_text_fmt(title, "%"LV_PRId32"/%"LV_PRId32": %s%s", scene_act * 2 + (opa_mode ? 1 : 0),
(int32_t)(dimof(scenes) * 2) - 2,
lv_label_set_text_fmt(title, "%"LV_PRId32"/"LV_PRId32": %s%s", scene_act * 2 + (opa_mode ? 1 : 0),
(int)(dimof(scenes) * 2) - 2,
scenes[scene_act].name, opa_mode ? " + opa" : "");
lv_label_set_text(subtitle, "");
@ -740,6 +738,7 @@ void lv_demo_benchmark_run_scene(int_fast16_t scene_no)
}
}
void lv_demo_benchmark_set_finished_cb(finished_cb_t * finished_cb)
{
benchmark_finished_cb = finished_cb;
@ -788,6 +787,7 @@ static void generate_report(void)
weight_opa_sum += w;
}
fps_sum = fps_normal_sum + fps_opa_sum;
weight_sum = weight_normal_sum + weight_opa_sum;
@ -804,6 +804,7 @@ static void generate_report(void)
lv_obj_clean(lv_scr_act());
scene_bg = NULL;
lv_obj_set_flex_flow(lv_scr_act(), LV_FLEX_FLOW_COLUMN);
title = lv_label_create(lv_scr_act());
@ -839,6 +840,7 @@ static void generate_report(void)
// lv_obj_add_style(table, LV_TABLE_PART_CELL3, &style_cell_very_slow);
// lv_obj_add_style(table, LV_TABLE_PART_CELL4, &style_cell_title);
uint16_t row = 0;
lv_table_add_cell_ctrl(table, row, 0, LV_TABLE_CELL_CTRL_MERGE_RIGHT);
lv_table_set_cell_value(table, row, 0, "Slow but common cases");
@ -925,6 +927,7 @@ static void generate_report(void)
lv_snprintf(buf, sizeof(buf), "%"LV_PRIu32, scenes[i].fps_opa);
lv_table_set_cell_value(table, row, 1, buf);
if(scenes[i].fps_opa < 10) {
// lv_table_set_cell_type(table, row, 0, 3);
// lv_table_set_cell_type(table, row, 1, 3);
@ -970,13 +973,11 @@ static void report_cb(lv_timer_t * timer)
}
}
static void next_scene_timer_cb(lv_timer_t * timer)
static void scene_next_task_cb(lv_timer_t * timer)
{
LV_UNUSED(timer);
lv_obj_clean(scene_bg);
next_scene_timer = NULL;
if(opa_mode) {
if(scene_act >= 0) {
if(scenes[scene_act].time_sum_opa == 0) scenes[scene_act].time_sum_opa = 1;
@ -995,8 +996,8 @@ static void next_scene_timer_cb(lv_timer_t * timer)
}
if(scenes[scene_act].create_cb) {
lv_label_set_text_fmt(title, "%"LV_PRId32"/%"LV_PRId32": %s%s", scene_act * 2 + (opa_mode ? 1 : 0),
(int32_t)(dimof(scenes) * 2) - 2, scenes[scene_act].name, opa_mode ? " + opa" : "");
lv_label_set_text_fmt(title, "%"LV_PRId32"/"LV_PRId32": %s%s", scene_act * 2 + (opa_mode ? 1 : 0),
(int)(dimof(scenes) * 2) - 2, scenes[scene_act].name, opa_mode ? " + opa" : "");
if(opa_mode) {
lv_label_set_text_fmt(subtitle, "Result of \"%s\": %"LV_PRId32" FPS", scenes[scene_act].name,
scenes[scene_act].fps_normal);
@ -1013,8 +1014,8 @@ static void next_scene_timer_cb(lv_timer_t * timer)
rnd_reset();
scenes[scene_act].create_cb();
next_scene_timer = lv_timer_create(next_scene_timer_cb, SCENE_TIME, NULL);
lv_timer_set_repeat_count(next_scene_timer, 1);
lv_timer_t * t = lv_timer_create(scene_next_task_cb, SCENE_TIME, NULL);
lv_timer_set_repeat_count(t, 1);
}
/*Ready*/
@ -1036,6 +1037,7 @@ static void next_scene_timer_cb(lv_timer_t * timer)
}
}
static void rect_create(lv_style_t * style)
{
uint32_t i;
@ -1053,6 +1055,7 @@ static void rect_create(lv_style_t * style)
}
}
static void img_create(lv_style_t * style, const void * src, bool rotate, bool zoom, bool aa)
{
uint32_t i;
@ -1071,6 +1074,7 @@ static void img_create(lv_style_t * style, const void * src, bool rotate, bool z
}
}
static void txt_create(lv_style_t * style)
{
uint32_t i;
@ -1086,6 +1090,7 @@ static void txt_create(lv_style_t * style)
}
}
static void line_create(lv_style_t * style)
{
static lv_point_t points[OBJ_NUM][LINE_POINT_NUM];
@ -1100,6 +1105,7 @@ static void line_create(lv_style_t * style)
points[i][j].y = rnd_next(LINE_POINT_DIFF_MIN, LINE_POINT_DIFF_MAX);
}
lv_obj_t * obj = lv_line_create(scene_bg);
lv_obj_remove_style_all(obj);
lv_obj_add_style(obj, style, 0);
@ -1112,6 +1118,7 @@ static void line_create(lv_style_t * style)
}
}
static void arc_anim_end_angle_cb(void * var, int32_t v)
{
lv_arc_set_end_angle(var, v);
@ -1145,6 +1152,7 @@ static void arc_create(lv_style_t * style)
}
}
static void fall_anim_y_cb(void * var, int32_t v)
{
lv_obj_set_y(var, v);

View File

@ -24,13 +24,12 @@ extern "C" {
**********************/
typedef void finished_cb_t(void);
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_demo_benchmark(void);
void lv_demo_benchmark_close(void);
void lv_demo_benchmark_run_scene(int_fast16_t scene_no);
void lv_demo_benchmark_set_finished_cb(finished_cb_t * finished_cb);

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -46,11 +46,8 @@ static lv_obj_t * t2;
void lv_demo_keypad_encoder(void)
{
g = lv_group_get_default();
if(g == NULL) {
g = lv_group_create();
lv_group_set_default(g);
}
g = lv_group_create();
lv_group_set_default(g);
lv_indev_t * cur_drv = NULL;
for(;;) {
@ -79,12 +76,6 @@ void lv_demo_keypad_encoder(void)
msgbox_create();
}
void lv_demo_keypad_encoder_close(void)
{
lv_obj_clean(lv_scr_act());
lv_obj_clean(lv_layer_top());
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -27,7 +27,6 @@ extern "C" {
* GLOBAL PROTOTYPES
**********************/
void lv_demo_keypad_encoder(void);
void lv_demo_keypad_encoder_close(void);
/**********************
* MACROS

View File

@ -47,6 +47,7 @@ extern "C" {
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/

Some files were not shown because too many files have changed in this diff Show More