Compare commits
No commits in common. "a19c3a68bf77d7e8505ece39131b6d9e52e460f5" and "ba885b52b9ea9378cabd284359130e093d4083ec" have entirely different histories.
a19c3a68bf
...
ba885b52b9
@ -1,145 +0,0 @@
|
||||
#include <math.h>
|
||||
#include "i2c.h"
|
||||
#include "BMP280.h"
|
||||
#include "wm_osal.h"
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t dig_T1;
|
||||
int16_t dig_T2;
|
||||
int16_t dig_T3;
|
||||
uint16_t dig_P1;
|
||||
int16_t dig_P2;
|
||||
int16_t dig_P3;
|
||||
int16_t dig_P4;
|
||||
int16_t dig_P5;
|
||||
int16_t dig_P6;
|
||||
int16_t dig_P7;
|
||||
int16_t dig_P8;
|
||||
int16_t dig_P9;
|
||||
|
||||
} BMP280_calibration_data;
|
||||
|
||||
static BMP280_calibration_data _calibration_data = {0};
|
||||
static BMP280_Mode_e _mode;
|
||||
static int32_t t_fine = 0;
|
||||
|
||||
static bool _BMP280_read_calibration_data(void)
|
||||
{
|
||||
uint8_t data[2];
|
||||
|
||||
if(i2c_read(BMP280_I2C_ADDR, BMP280_DIG_T1, data, sizeof data))
|
||||
_calibration_data.dig_T1 = data[1] << 8 | data[0];
|
||||
else return false;
|
||||
|
||||
if(i2c_read(BMP280_I2C_ADDR, BMP280_DIG_T2, data, sizeof data))
|
||||
_calibration_data.dig_T2 = data[1] << 8 | data[0];
|
||||
else return false;
|
||||
|
||||
if(i2c_read(BMP280_I2C_ADDR, BMP280_DIG_T3, data, sizeof data))
|
||||
_calibration_data.dig_T3 = data[1] << 8 | data[0];
|
||||
else return false;
|
||||
|
||||
if(i2c_read(BMP280_I2C_ADDR, BMP280_DIG_P1, data, sizeof data))
|
||||
_calibration_data.dig_P1 = data[1] << 8 | data[0];
|
||||
else return false;
|
||||
|
||||
if(i2c_read(BMP280_I2C_ADDR, BMP280_DIG_P2, data, sizeof data))
|
||||
_calibration_data.dig_P2 = data[1] << 8 | data[0];
|
||||
else return false;
|
||||
|
||||
if(i2c_read(BMP280_I2C_ADDR, BMP280_DIG_P3, data, sizeof data))
|
||||
_calibration_data.dig_P3 = data[1] << 8 | data[0];
|
||||
else return false;
|
||||
|
||||
if(i2c_read(BMP280_I2C_ADDR, BMP280_DIG_P4, data, sizeof data))
|
||||
_calibration_data.dig_P4 = data[1] << 8 | data[0];
|
||||
else return false;
|
||||
|
||||
if(i2c_read(BMP280_I2C_ADDR, BMP280_DIG_P5, data, sizeof data))
|
||||
_calibration_data.dig_P5 = data[1] << 8 | data[0];
|
||||
else return false;
|
||||
|
||||
if(i2c_read(BMP280_I2C_ADDR, BMP280_DIG_P6, data, sizeof data))
|
||||
_calibration_data.dig_P6 = data[1] << 8 | data[0];
|
||||
else return false;
|
||||
|
||||
if(i2c_read(BMP280_I2C_ADDR, BMP280_DIG_P7, data, sizeof data))
|
||||
_calibration_data.dig_P7 = data[1] << 8 | data[0];
|
||||
else return false;
|
||||
|
||||
if(i2c_read(BMP280_I2C_ADDR, BMP280_DIG_P8, data, sizeof data))
|
||||
_calibration_data.dig_P8 = data[1] << 8 | data[0];
|
||||
else return false;
|
||||
|
||||
if(i2c_read(BMP280_I2C_ADDR, BMP280_DIG_P9, data, sizeof data))
|
||||
_calibration_data.dig_P9 = data[1] << 8 | data[0];
|
||||
else return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BMP280_init(void)
|
||||
{
|
||||
uint8_t data;
|
||||
|
||||
if(!i2c_read_reg(BMP280_I2C_ADDR, BMP280_ID_REG, &data)) return false;
|
||||
|
||||
if(data != BMP280_ID) return false;
|
||||
|
||||
if(!_BMP280_read_calibration_data())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BMP280_configure(BMP280_Mode_e mode, BMP280_Oversampling_e temperature_oversampling, BMP280_Oversampling_e pressure_oversampling, BMP280_Filter_e filter, BMP280_Standby_Duration_e standby_duration)
|
||||
{
|
||||
_mode = mode;
|
||||
|
||||
if(!i2c_write_reg(BMP280_I2C_ADDR, BMP280_CONFIG, standby_duration << 5 | filter << 2)) return false;
|
||||
tls_os_time_delay(pdMS_TO_TICKS(4)); //Ugly but needed :(
|
||||
return i2c_write_reg(BMP280_I2C_ADDR, BMP280_CTRL_MEAS, temperature_oversampling << 5 | pressure_oversampling << 2 | mode);
|
||||
}
|
||||
|
||||
bool BMP280_trigger_measurement(void)
|
||||
{
|
||||
uint8_t data;
|
||||
|
||||
if(!i2c_read_reg(BMP280_I2C_ADDR, BMP280_CTRL_MEAS, &data)) return false;
|
||||
data &= 0xFC;
|
||||
data |= _mode;
|
||||
return i2c_write_reg(BMP280_I2C_ADDR, BMP280_CTRL_MEAS, data);
|
||||
}
|
||||
|
||||
float BMP280_get_temperature(void)
|
||||
{
|
||||
int32_t var1, var2;
|
||||
uint8_t data[3];
|
||||
|
||||
if(!i2c_read(BMP280_I2C_ADDR, BMP280_TEMP_MSB, data, sizeof data)) return 0.0f;
|
||||
|
||||
int32_t adc_T = data[0] << 16 | data[1] << 8 | data[2];
|
||||
adc_T >>= 4;
|
||||
|
||||
var1 = ((((adc_T >> 3) - ((int32_t)_calibration_data.dig_T1 << 1))) *
|
||||
((int32_t)_calibration_data.dig_T2)) >>
|
||||
11;
|
||||
|
||||
var2 = (((((adc_T >> 4) - ((int32_t)_calibration_data.dig_T1)) *
|
||||
((adc_T >> 4) - ((int32_t)_calibration_data.dig_T1))) >>
|
||||
12) *
|
||||
((int32_t)_calibration_data.dig_T3)) >>
|
||||
14;
|
||||
|
||||
t_fine = var1 + var2;
|
||||
|
||||
float T = (t_fine * 5 + 128) >> 8;
|
||||
return T / 100;
|
||||
}
|
||||
|
||||
bool BMP280_software_reset(void)
|
||||
{
|
||||
return false;
|
||||
}
|
@ -1,90 +1,6 @@
|
||||
#ifndef BMP280_H
|
||||
#define BMP280_H
|
||||
|
||||
/* Device i2c address */
|
||||
#define BMP280_I2C_ADDR 0x76
|
||||
|
||||
/* Device ID */
|
||||
#define BMP280_ID 0x58
|
||||
|
||||
/* Device registers list */
|
||||
#define BMP280_TEMP_XLSB 0xFC
|
||||
#define BMP280_TEMP_LSB 0xFB
|
||||
#define BMP280_TEMP_MSB 0xFA
|
||||
#define BMP280_PRESS_XLSB 0xF9
|
||||
#define BMP280_PRESS_LSB 0xF8
|
||||
#define BMP280_PRESS_MSB 0xF7
|
||||
#define BMP280_CONFIG 0xF5
|
||||
#define BMP280_CTRL_MEAS 0xF4
|
||||
#define BMP280_STATUS 0xF3
|
||||
#define BMP280_RESET 0xE0
|
||||
#define BMP280_ID_REG 0xD0
|
||||
|
||||
/* Device calibration registers list */
|
||||
#define BMP280_DIG_T1 0x88
|
||||
#define BMP280_DIG_T2 0x8A
|
||||
#define BMP280_DIG_T3 0x8C
|
||||
#define BMP280_DIG_P1 0x8E
|
||||
#define BMP280_DIG_P2 0x90
|
||||
#define BMP280_DIG_P3 0x92
|
||||
#define BMP280_DIG_P4 0x94
|
||||
#define BMP280_DIG_P5 0x96
|
||||
#define BMP280_DIG_P6 0x98
|
||||
#define BMP280_DIG_P7 0x9A
|
||||
#define BMP280_DIG_P8 0x9C
|
||||
#define BMP280_DIG_P9 0x9E
|
||||
|
||||
/* Field masks */
|
||||
|
||||
/* Configuration enumerations */
|
||||
typedef enum
|
||||
{
|
||||
BMP280_Sleep = 0,
|
||||
BMP280_Forced = 1,
|
||||
BMP280_Normal = 3,
|
||||
} BMP280_Mode_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BMP280_Oversampling_Skipped = 0,
|
||||
BMP280_Oversampling_x1 = 1,
|
||||
BMP280_Oversampling_x2 = 2,
|
||||
BMP280_Oversampling_x4 = 3,
|
||||
BMP280_Oversampling_x8 = 4,
|
||||
BMP280_Oversampling_x16 = 5,
|
||||
} BMP280_Oversampling_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BMP280_Filter_OFF = 0,
|
||||
BMP280_Filter_x2 = 1,
|
||||
BMP280_Filter_x4 = 2,
|
||||
BMP280_Filter_x8 = 3,
|
||||
BMP280_Filter_x16 = 4,
|
||||
} BMP280_Filter_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BMP280_Standby_0_5MS = 0,
|
||||
BMP280_Standby_62_5MS = 1,
|
||||
BMP280_Standby_125MS = 2,
|
||||
BMP280_Standby_250MS = 3,
|
||||
BMP280_Standby_500MS = 4,
|
||||
BMP280_Standby_1000MS = 5,
|
||||
BMP280_Standby_2000MS = 6,
|
||||
BMP280_Standby_4000MS = 7,
|
||||
} BMP280_Standby_Duration_e;
|
||||
|
||||
|
||||
|
||||
bool BMP280_init(void);
|
||||
|
||||
bool BMP280_configure(BMP280_Mode_e mode, BMP280_Oversampling_e temperature_oversampling, BMP280_Oversampling_e pressure_oversampling, BMP280_Filter_e filter, BMP280_Standby_Duration_e standby_duration);
|
||||
|
||||
bool BMP280_trigger_measurement(void);
|
||||
|
||||
float BMP280_get_temperature(void);
|
||||
|
||||
bool BMP280_software_reset(void);
|
||||
|
||||
#endif //BMP280_H
|
@ -11,9 +11,9 @@ typedef struct
|
||||
int16_t z_min;
|
||||
int16_t z_max;
|
||||
float temperature_offset;
|
||||
} QMC5883L_calibration_data;
|
||||
} _QMC5883L_calibration_data;
|
||||
|
||||
static QMC5883L_calibration_data _calibration_data = {0};
|
||||
static _QMC5883L_calibration_data calibration_data = {0};
|
||||
|
||||
|
||||
bool QMC5883L_init(void)
|
||||
@ -39,7 +39,7 @@ float QMC5883L_get_temperature(void)
|
||||
|
||||
raw_temp |= data;
|
||||
|
||||
return (float) raw_temp / 100.0 + _calibration_data.temperature_offset;
|
||||
return (float) raw_temp / 100.0 + calibration_data.temperature_offset;
|
||||
}
|
||||
|
||||
bool QMC5883L_is_data_available(void)
|
||||
@ -53,13 +53,13 @@ bool QMC5883L_is_data_available(void)
|
||||
|
||||
void QMC5883L_set_calibration_data(int16_t x_min, int16_t x_max, int16_t y_min, int16_t y_max, int16_t z_min, int16_t z_max, float temperature_offset)
|
||||
{
|
||||
_calibration_data.x_min = x_min;
|
||||
_calibration_data.x_max = x_max;
|
||||
_calibration_data.y_min = y_min;
|
||||
_calibration_data.y_max = y_max;
|
||||
_calibration_data.z_min = z_min;
|
||||
_calibration_data.z_max = z_max;
|
||||
_calibration_data.temperature_offset = temperature_offset;
|
||||
calibration_data.x_min = x_min;
|
||||
calibration_data.x_max = x_max;
|
||||
calibration_data.y_min = y_min;
|
||||
calibration_data.y_max = y_max;
|
||||
calibration_data.z_min = z_min;
|
||||
calibration_data.z_max = z_max;
|
||||
calibration_data.temperature_offset = temperature_offset;
|
||||
}
|
||||
|
||||
QMC5883L_MData_t QMC5883L_get_MFields_raw(void)
|
||||
@ -89,12 +89,12 @@ QMC5883L_MData_calibrated_t QMC5883L_get_MFields_calibrated(void)
|
||||
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;
|
||||
int z_offset = (_calibration_data.z_min + _calibration_data.z_max) / 2;
|
||||
int x_avg_delta = (_calibration_data.x_max - _calibration_data.x_min) / 2;
|
||||
int y_avg_delta = (_calibration_data.y_max - _calibration_data.y_min) / 2;
|
||||
int z_avg_delta = (_calibration_data.z_max - _calibration_data.z_min) / 2;
|
||||
int x_offset = (calibration_data.x_min + calibration_data.x_max) / 2;
|
||||
int y_offset = (calibration_data.y_min + calibration_data.y_max) / 2;
|
||||
int z_offset = (calibration_data.z_min + calibration_data.z_max) / 2;
|
||||
int x_avg_delta = (calibration_data.x_max - calibration_data.x_min) / 2;
|
||||
int y_avg_delta = (calibration_data.y_max - calibration_data.y_min) / 2;
|
||||
int z_avg_delta = (calibration_data.z_max - calibration_data.z_min) / 2;
|
||||
|
||||
int avg_delta = (x_avg_delta + y_avg_delta + z_avg_delta) / 3;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,6 @@
|
||||
#include "wm_io.h"
|
||||
#include "wm_gpio_afsel.h"
|
||||
#include "wm_i2c.h"
|
||||
#include "i2c.h"
|
||||
|
||||
void i2c_init(enum tls_io_name SDAPin, enum tls_io_name SCLPin, uint32_t frequency)
|
||||
{
|
||||
@ -11,31 +10,6 @@ void i2c_init(enum tls_io_name SDAPin, enum tls_io_name SCLPin, uint32_t frequen
|
||||
tls_i2c_init(frequency);
|
||||
}
|
||||
|
||||
bool i2c_write(uint8_t address, uint8_t reg, const uint8_t *const data, size_t length)
|
||||
{
|
||||
if(!data) return false;
|
||||
|
||||
//First we send the address followed by the register from where we want to start writing:
|
||||
tls_i2c_write_byte(address << 1, true);
|
||||
if(tls_i2c_wait_ack() != WM_SUCCESS) return false;
|
||||
tls_i2c_write_byte(reg, false);
|
||||
if(tls_i2c_wait_ack() != WM_SUCCESS) return false;
|
||||
|
||||
for(size_t i = 0; i < length; i++)
|
||||
{
|
||||
tls_i2c_write_byte(data[i], false);
|
||||
if(tls_i2c_wait_ack() != WM_SUCCESS)
|
||||
{
|
||||
tls_i2c_stop();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
tls_i2c_stop();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool i2c_write_reg(uint8_t address, uint8_t reg, uint8_t data)
|
||||
{
|
||||
//First we send the address followed by the register we want to write to:
|
||||
|
@ -15,18 +15,6 @@
|
||||
*/
|
||||
void i2c_init(enum tls_io_name SDAPin, enum tls_io_name SCLPin, uint32_t frequency);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param address the 7 bit address of the slave device
|
||||
* @param reg the address of the register from where the write will start (the device should have write with autoincrement register functionality)
|
||||
* @param data a pointer to an array of uint8_t where the data to write is stored
|
||||
* @param length the size in bytes of the data array
|
||||
* @return true on success
|
||||
* @return false on failure
|
||||
*/
|
||||
bool i2c_write(uint8_t address, uint8_t reg, const uint8_t * const data, size_t length);
|
||||
|
||||
/**
|
||||
* @brief Writes the given data to the provided register of the slave device.
|
||||
*
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "mmc_sdio.h"
|
||||
#include "lcd.h"
|
||||
#include "app_log.h"
|
||||
#include "wm_gpio_afsel.h"
|
||||
|
||||
/**
|
||||
* @brief Prototype of functions only used internally :
|
||||
@ -258,9 +257,7 @@ void lcd_init(LCDConfig_t * const LCDConfig)
|
||||
if(!LCDConfig) return;
|
||||
|
||||
// Backlight is controlled using PWM
|
||||
wm_pwm4_config(LCDConfig->LCDPWMBacklightPin);
|
||||
tls_pwm_init(4, 10000, 0, 0);
|
||||
//tls_gpio_cfg(LCDConfig->LCDPWMBacklightPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||
tls_gpio_cfg(LCDConfig->LCDPWMBacklightPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||
|
||||
tls_gpio_cfg(LCDConfig->LCDChipSelectPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||
tls_gpio_cfg(LCDConfig->LCDDataCommandPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||
@ -356,7 +353,7 @@ spi_write_9_bit(LCDConfig, false, 0x29);
|
||||
|
||||
#endif
|
||||
|
||||
lcd_set_backlight(LCDConfig, 255);
|
||||
lcd_set_backlight(LCDConfig, 1);
|
||||
}
|
||||
|
||||
void lcd_draw_rect_frame(LCDConfig_t * const LCDConfig, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t *data)
|
||||
@ -377,7 +374,10 @@ void lcd_set_backlight(LCDConfig_t * const LCDConfig, uint8_t brightness)
|
||||
{
|
||||
if(!LCDConfig) return;
|
||||
|
||||
tls_pwm_duty_set(4, brightness);
|
||||
if(brightness)
|
||||
tls_gpio_write(LCDConfig->LCDPWMBacklightPin, 1);
|
||||
else
|
||||
tls_gpio_write(LCDConfig->LCDPWMBacklightPin, 0);
|
||||
}
|
||||
|
||||
void lcd_hardware_reset(LCDConfig_t * const LCDConfig)
|
||||
|
@ -137,17 +137,6 @@ void compass_screen_set_azimuth(CompassScreen_t * const compassScreen, uint16_t
|
||||
rotate_cardinal(&compassScreen->westCardinal, azimuth);
|
||||
}
|
||||
|
||||
bool compass_screen_is_in_use(CompassScreen_t *const compassScreen)
|
||||
{
|
||||
if(!compassScreen)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
return compassScreen->display != NULL;
|
||||
}
|
||||
|
||||
void compass_screen_create(CompassScreen_t * const compassScreen)
|
||||
{
|
||||
if(!compassScreen)
|
||||
|
@ -44,8 +44,6 @@ void compass_screen_init(CompassScreen_t * const compassScreen);
|
||||
/* Set the compassAzimuth in degrees to show */
|
||||
void compass_screen_set_azimuth(CompassScreen_t * const compassScreen, uint16_t azimuth);
|
||||
|
||||
bool compass_screen_is_in_use(CompassScreen_t * const compassScreen);
|
||||
|
||||
/* Builds the compass screen graphically */
|
||||
void compass_screen_create(CompassScreen_t * const compassScreen);
|
||||
|
||||
|
@ -9,8 +9,6 @@
|
||||
#include "settings_screen.h"
|
||||
#include "i2c.h"
|
||||
#include "QMC5883L.h"
|
||||
#include "BMP280.h"
|
||||
#include "bma456w.h"
|
||||
|
||||
#include "lv_port_indev.h"
|
||||
|
||||
@ -33,10 +31,31 @@ static void lcd_draw_finished_cb(void *arg)
|
||||
lv_disp_flush_ready((lv_disp_drv_t *)arg);
|
||||
}
|
||||
|
||||
struct tm temptm = {0};
|
||||
|
||||
static void date_time_cb(struct tm * const dateTime)
|
||||
{
|
||||
if(!dateTime)return;
|
||||
tls_get_rtc(dateTime);
|
||||
|
||||
/*time_t time_type = time(NULL);
|
||||
struct tm *tm = localtime(&time_type);*/
|
||||
|
||||
temptm.tm_min++;
|
||||
temptm.tm_sec = 1;
|
||||
|
||||
if(temptm.tm_min == 60)
|
||||
{
|
||||
temptm.tm_min = 0;
|
||||
temptm.tm_hour++;
|
||||
}
|
||||
|
||||
if(temptm.tm_hour == 24)
|
||||
temptm.tm_hour = 0;
|
||||
|
||||
*dateTime = temptm;
|
||||
|
||||
//LV_LOG_USER("Time is : %llu, Time : %d:%d:%d", time_type, tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
LV_LOG_USER("Time : %d:%d:%d", dateTime->tm_hour, dateTime->tm_min, dateTime->tm_sec);
|
||||
}
|
||||
|
||||
WatchFace_t watchFace;
|
||||
@ -44,79 +63,11 @@ MenuScreen_t menuScreen;
|
||||
CompassScreen_t compassScreen;
|
||||
SettingsScreen_t settingsScreen;
|
||||
|
||||
struct bma4_dev bma;
|
||||
struct bma4_accel_config accel_conf;
|
||||
struct bma456w_wrist_wear_wakeup_params setting;
|
||||
uint16_t int_status;
|
||||
|
||||
static void setBrightnessCb(uint8_t brightness)
|
||||
{
|
||||
lcd_set_backlight(&LCDConfig, brightness);
|
||||
}
|
||||
|
||||
static void setTimeCb(uint8_t hour, uint8_t minute, uint8_t second, uint8_t day, uint8_t month, uint8_t year)
|
||||
{
|
||||
struct tm timeToSet;
|
||||
|
||||
//First we get the current time from the RTC
|
||||
tls_get_rtc(&timeToSet);
|
||||
|
||||
if(hour != 0xFF)
|
||||
timeToSet.tm_hour = hour;
|
||||
|
||||
if(minute != 0xFF)
|
||||
timeToSet.tm_min = minute;
|
||||
|
||||
if(second != 0xFF)
|
||||
timeToSet.tm_sec = second;
|
||||
|
||||
if(day != 0xFF)
|
||||
timeToSet.tm_mday = day;
|
||||
|
||||
if(month != 0xFF)
|
||||
timeToSet.tm_mon = month;
|
||||
|
||||
if(year != 0xFF)
|
||||
timeToSet.tm_year = year + 100;
|
||||
|
||||
tls_set_rtc(&timeToSet);
|
||||
}
|
||||
|
||||
SettingsScreenAPIInterface_t settingsScreenAPIInterface =
|
||||
{
|
||||
.setBrightnessSettingsCb = setBrightnessCb,
|
||||
.setTimeSettingsCb = setTimeCb
|
||||
};
|
||||
|
||||
static uint16_t angle_with_offset(uint16_t angle, uint16_t offset)
|
||||
{
|
||||
return (angle + offset) >= 360 ? angle + offset - 360 : angle + offset;
|
||||
}
|
||||
|
||||
static BMA4_INTF_RET_TYPE bma4_i2c_read(uint8_t reg_addr, uint8_t *read_data, uint32_t len, void *intf_ptr)
|
||||
{
|
||||
uint8_t dev_address = *(uint8_t*)intf_ptr;
|
||||
|
||||
return !i2c_read(dev_address, reg_addr, read_data, len);
|
||||
}
|
||||
|
||||
static BMA4_INTF_RET_TYPE bma4_i2c_write(uint8_t reg_addr, const uint8_t *read_data, uint32_t len, void *intf_ptr)
|
||||
{
|
||||
uint8_t dev_address = *(uint8_t*)intf_ptr;
|
||||
|
||||
return !i2c_write(dev_address, reg_addr, read_data, len);
|
||||
}
|
||||
|
||||
static void delay_us(uint32_t period, void *intf_ptr)
|
||||
{
|
||||
(void) intf_ptr;
|
||||
|
||||
if(period < 1000)
|
||||
tls_os_time_delay(1);
|
||||
else
|
||||
tls_os_time_delay(pdMS_TO_TICKS(period / 1000));
|
||||
}
|
||||
|
||||
|
||||
void gfx_task(void *param)
|
||||
{
|
||||
@ -170,7 +121,6 @@ void gfx_task(void *param)
|
||||
menu_screen_init(&menuScreen);
|
||||
compass_screen_init(&compassScreen);
|
||||
settings_screen_init(&settingsScreen);
|
||||
settings_screen_register_API_interface(&settingsScreen, &settingsScreenAPIInterface);
|
||||
|
||||
watch_face_register_cb(&watchFace, &(date_time_cb));
|
||||
watch_face_create(&watchFace);
|
||||
@ -182,18 +132,19 @@ void gfx_task(void *param)
|
||||
|
||||
uint8_t aliveCounter = 0;
|
||||
|
||||
/* Init the magnetometer */
|
||||
//QMC5883L_MData_calibrated_t temp;
|
||||
//uint8_t average = 0;
|
||||
//uint16_t angle;
|
||||
|
||||
if(!QMC5883L_init())
|
||||
APP_LOG_INFO("Failed to init QMC5883L");
|
||||
else
|
||||
APP_LOG_INFO("Inited QMC5883L");
|
||||
tls_os_time_delay(2);
|
||||
|
||||
if(!QMC5883L_set_power_mode(Continuous))
|
||||
APP_LOG_INFO("Failed to set QMC5883L mode");
|
||||
else
|
||||
APP_LOG_INFO("QMC5883L Mode set");
|
||||
tls_os_time_delay(2);
|
||||
|
||||
if(!QMC5883L_configure_1(ODR_10HZ, FS_2G, OSR_512))
|
||||
APP_LOG_INFO("Failed to configure 1 QMC5883L");
|
||||
@ -202,81 +153,12 @@ void gfx_task(void *param)
|
||||
|
||||
QMC5883L_set_calibration_data(-900, 2500, -1400, 1400, 2300, 7500, 0.0);
|
||||
|
||||
/* Init the BMP280 */
|
||||
if(!BMP280_init())
|
||||
APP_LOG_INFO("Failed to init BMP280");
|
||||
else
|
||||
APP_LOG_INFO("Inited BMP280");
|
||||
|
||||
if(!BMP280_configure(BMP280_Forced, BMP280_Oversampling_x16, BMP280_Oversampling_x16, BMP280_Filter_x16, BMP280_Standby_4000MS))
|
||||
APP_LOG_INFO("Failed to configure BMP280");
|
||||
else
|
||||
APP_LOG_INFO("BMP280 configured");
|
||||
|
||||
/* Init the BMA456 */
|
||||
bma.intf = BMA4_I2C_INTF;
|
||||
uint8_t dev_addr = BMA4_I2C_ADDR_SECONDARY;
|
||||
bma.intf_ptr = &dev_addr;
|
||||
bma.bus_read = &(bma4_i2c_read);
|
||||
bma.bus_write = &(bma4_i2c_write);
|
||||
bma.variant = BMA45X_VARIANT;
|
||||
bma.delay_us = &(delay_us);
|
||||
bma.read_write_len = 46;
|
||||
bma.perf_mode_status = BMA4_DISABLE;
|
||||
|
||||
if(bma456w_init(&bma) == BMA4_OK)
|
||||
APP_LOG_INFO("BMA456 init");
|
||||
else
|
||||
APP_LOG_INFO("Failed to init BMA456");
|
||||
|
||||
bma4_soft_reset(&bma);
|
||||
tls_os_time_delay(2);
|
||||
|
||||
if(bma456w_write_config_file(&bma) == BMA4_OK)
|
||||
APP_LOG_INFO("BMA456 config ok");
|
||||
else
|
||||
APP_LOG_INFO("BMA456 config failed");
|
||||
|
||||
accel_conf.odr = BMA4_OUTPUT_DATA_RATE_100HZ;
|
||||
accel_conf.range = BMA4_ACCEL_RANGE_2G;
|
||||
accel_conf.bandwidth = BMA4_ACCEL_NORMAL_AVG4;
|
||||
accel_conf.perf_mode = BMA4_CIC_AVG_MODE;
|
||||
|
||||
if(bma4_set_accel_config(&accel_conf, &bma) == BMA4_OK)
|
||||
APP_LOG_INFO("BMA456 accel conf ok");
|
||||
else
|
||||
APP_LOG_INFO("BMA456 accel conf failed");
|
||||
|
||||
if(bma4_set_accel_enable(1, &bma) == BMA4_OK)
|
||||
APP_LOG_INFO("BMA456 accel en ok");
|
||||
else
|
||||
APP_LOG_INFO("BMA456 accel en failed");
|
||||
|
||||
bma456w_feature_enable(BMA456W_WRIST_WEAR_WAKEUP, 1, &bma);
|
||||
|
||||
bma456w_get_wrist_wear_wakeup_param_config(&setting, &bma);
|
||||
|
||||
APP_LOG_DEBUG("%d %d %d %d %d %d %d %d", setting.min_angle_focus, setting.min_angle_non_focus, setting.angle_landscape_right, setting.angle_landscape_left, setting.angle_portrait_up, setting.angle_portrait_down, setting.min_dur_moved, setting.min_dur_quite);
|
||||
|
||||
bma456w_map_interrupt(BMA4_INTR1_MAP, BMA456W_WRIST_WEAR_WAKEUP_INT, BMA4_ENABLE, &bma);
|
||||
|
||||
//bma456w_map_interrupt(BMA4_INTR1_MAP, (BMA456W_ANY_MOT_INT | BMA456W_NO_MOT_INT), BMA4_ENABLE, &bma);
|
||||
|
||||
/*struct bma456w_any_no_mot_config any_no_mot = {.threshold = 10, .duration = 4, .axes_en = BMA456W_EN_ALL_AXIS};
|
||||
bma456w_set_any_mot_config(&any_no_mot, &bma);
|
||||
|
||||
bma456w_set_no_mot_config(&any_no_mot, &bma);*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for(;;)
|
||||
{
|
||||
lv_timer_handler();
|
||||
tls_os_time_delay(5);
|
||||
|
||||
if(compass_screen_is_in_use(&compassScreen) && QMC5883L_is_data_available())
|
||||
if(QMC5883L_is_data_available())
|
||||
{
|
||||
//QMC5883L_MData_t MDataRaw = QMC5883L_get_MFields_raw();
|
||||
//APP_LOG_TRACE("X %d Y %d Z %d", MDataRaw.MFieldX, MDataRaw.MFieldY, MDataRaw.MFieldZ);
|
||||
@ -285,27 +167,9 @@ void gfx_task(void *param)
|
||||
compass_screen_set_azimuth(&compassScreen, angle_with_offset(QMC5883L_get_azimuth(MData), 180));
|
||||
}
|
||||
|
||||
uint8_t rslt = bma456w_read_int_status(&int_status, &bma);
|
||||
if(rslt != BMA4_OK)
|
||||
APP_LOG_DEBUG("Failed to read int status");
|
||||
|
||||
/* Check if step counter interrupt is triggered */
|
||||
if((BMA4_OK == rslt) && (int_status & BMA456W_ANY_MOT_INT))
|
||||
{
|
||||
APP_LOG_DEBUG("Motion detected");
|
||||
}
|
||||
|
||||
if((BMA4_OK == rslt) && (int_status & BMA456W_WRIST_WEAR_WAKEUP_INT))
|
||||
{
|
||||
APP_LOG_DEBUG("Wrist tilt");
|
||||
}
|
||||
|
||||
if(++aliveCounter % 200 == 0)
|
||||
{
|
||||
float temp = BMP280_get_temperature();
|
||||
BMP280_trigger_measurement();
|
||||
APP_LOG_DEBUG("GFX thread, temp : %0.2f", temp);
|
||||
|
||||
APP_LOG_DEBUG("GFX thread");
|
||||
aliveCounter = 0;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "wm_include.h"
|
||||
|
||||
|
||||
#define GFX_STACK_SIZE_IN_BYTES (1100 * sizeof(StackType_t))
|
||||
#define GFX_STACK_SIZE_IN_BYTES (1024 * sizeof(StackType_t))
|
||||
#define GFX_STACK_PRIORITY (5)
|
||||
|
||||
static u8 gfx_task_stack[GFX_STACK_SIZE_IN_BYTES];
|
||||
|
@ -3,15 +3,12 @@
|
||||
#include "settings_screen.h"
|
||||
#include "menu_screen.h"
|
||||
|
||||
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";
|
||||
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";
|
||||
const char *month_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12";
|
||||
const char *year_options = "22\n23\n24\n25\n26\n27\n28\n29\n30";
|
||||
|
||||
static const char *hour_options = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23";
|
||||
static const char *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 *second_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";
|
||||
|
||||
const char *date_format = "dd/mm/yyyy\ndd/mm/yy\nyyyy/mm/dd\nyy/mm/dd";
|
||||
const char *hour_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23";
|
||||
const char *sec_min_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\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 void gesture_event_cb(lv_event_t * e)
|
||||
{
|
||||
@ -48,52 +45,6 @@ static void cleanup_event_cb(lv_event_t * e)
|
||||
LV_LOG_USER("cleanup");
|
||||
}
|
||||
|
||||
static void time_roller_cb(lv_event_t * e)
|
||||
{
|
||||
SettingsScreen_t *settingsScreen = e->user_data;
|
||||
if(!settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb) return;
|
||||
|
||||
lv_obj_t *roller = lv_event_get_target(e);
|
||||
uint8_t index = lv_roller_get_selected(roller);
|
||||
|
||||
if(roller == settingsScreen->hour_roller)
|
||||
{
|
||||
settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(index, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
else if(roller == settingsScreen->minute_roller)
|
||||
{
|
||||
settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(0xFF, index, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
else if(roller == settingsScreen->second_roller)
|
||||
{
|
||||
settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(0xFF, 0xFF, index, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
else if(roller == settingsScreen->day_roller)
|
||||
{
|
||||
settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(0xFF, 0xFF, 0xFF, index + 1, 0xFF, 0xFF);
|
||||
}
|
||||
else if(roller == settingsScreen->month_roller)
|
||||
{
|
||||
settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(0xFF, 0xFF, 0xFF, 0xFF, index + 1, 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, index + 22);
|
||||
}
|
||||
}
|
||||
|
||||
static void brightness_slider_cb(lv_event_t * e)
|
||||
{
|
||||
SettingsScreen_t *settingsScreen = e->user_data;
|
||||
if(!settingsScreen->settingsScreenAPIInterface.setBrightnessSettingsCb) return;
|
||||
|
||||
lv_obj_t * slider = lv_event_get_target(e);
|
||||
uint8_t brightness = (float)lv_slider_get_value(slider) * 2.55;
|
||||
|
||||
if(brightness > 5)
|
||||
settingsScreen->settingsScreenAPIInterface.setBrightnessSettingsCb(brightness);
|
||||
}
|
||||
|
||||
static lv_obj_t* add_sidebar_entry_to_menu(lv_obj_t *parent, const char *title, lv_obj_t *menu, lv_obj_t *pageToShow)
|
||||
{
|
||||
lv_obj_t *container = lv_menu_cont_create(parent);
|
||||
@ -185,8 +136,8 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen)
|
||||
|
||||
lv_obj_t *section = create_menu_page_section(menu_page_1);
|
||||
|
||||
lv_obj_t *menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Set Time & Date :");
|
||||
lv_obj_t *menu_page_1_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_1_label, "Set Time & Date :");
|
||||
|
||||
lv_obj_t *container = create_section_container(section);
|
||||
lv_obj_t *toggle = lv_switch_create(container);
|
||||
@ -194,10 +145,22 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen)
|
||||
lv_label_set_text_static(toggle_label, "Automatic");
|
||||
lv_obj_set_style_pad_top(toggle_label, 5, LV_PART_MAIN);
|
||||
|
||||
menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Time :");
|
||||
menu_page_1_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_1_label, "Time :");
|
||||
container = create_section_container(section);
|
||||
|
||||
lv_obj_t *hour_drop = lv_dropdown_create(container);
|
||||
lv_dropdown_set_options_static(hour_drop, hour_options);
|
||||
lv_obj_set_width(hour_drop, lv_pct(30));
|
||||
|
||||
hour_drop = lv_dropdown_create(container);
|
||||
lv_dropdown_set_options_static(hour_drop, sec_min_options);
|
||||
lv_obj_set_width(hour_drop, lv_pct(30));
|
||||
|
||||
hour_drop = lv_dropdown_create(container);
|
||||
lv_dropdown_set_options_static(hour_drop, sec_min_options);
|
||||
lv_obj_set_width(hour_drop, lv_pct(30));
|
||||
|
||||
/*container = lv_obj_create(section);
|
||||
lv_obj_set_style_pad_right(container,0, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_left(container,0, LV_PART_MAIN);
|
||||
@ -222,86 +185,36 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen)
|
||||
lv_obj_set_style_arc_width(arc, 1, LV_PART_INDICATOR);
|
||||
lv_obj_set_style_arc_width(arc, 1, LV_PART_MAIN);*/
|
||||
|
||||
settingsScreen->hour_roller = lv_roller_create(container);
|
||||
settingsScreen->minute_roller = lv_roller_create(container);
|
||||
settingsScreen->second_roller = lv_roller_create(container);
|
||||
|
||||
lv_roller_set_options(settingsScreen->hour_roller, hour_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(settingsScreen->hour_roller, 2);
|
||||
lv_obj_add_event_cb(settingsScreen->hour_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen);
|
||||
|
||||
lv_roller_set_options(settingsScreen->minute_roller, minute_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(settingsScreen->minute_roller, 2);
|
||||
lv_obj_add_event_cb(settingsScreen->minute_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen);
|
||||
|
||||
lv_roller_set_options(settingsScreen->second_roller, second_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(settingsScreen->second_roller, 2);
|
||||
lv_obj_add_event_cb(settingsScreen->second_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen);
|
||||
|
||||
menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Time Format :");
|
||||
container = create_section_container(section);
|
||||
|
||||
lv_obj_t *checkbox_12 = lv_checkbox_create(container), *checkbox_24 = lv_checkbox_create(container);
|
||||
lv_checkbox_set_text(checkbox_12, "12H");
|
||||
lv_obj_set_style_radius(checkbox_12, LV_RADIUS_CIRCLE, LV_PART_INDICATOR);
|
||||
lv_checkbox_set_text(checkbox_24, "24H");
|
||||
lv_obj_add_state(checkbox_24, LV_STATE_CHECKED);
|
||||
lv_obj_set_style_radius(checkbox_24, LV_RADIUS_CIRCLE, LV_PART_INDICATOR);
|
||||
|
||||
menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Date :");
|
||||
container = create_section_container(section);
|
||||
|
||||
settingsScreen->day_roller = lv_roller_create(container);
|
||||
settingsScreen->month_roller = lv_roller_create(container);
|
||||
settingsScreen->year_roller = lv_roller_create(container);
|
||||
|
||||
lv_roller_set_options(settingsScreen->day_roller, day_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(settingsScreen->day_roller, 2);
|
||||
lv_obj_add_event_cb(settingsScreen->day_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen);
|
||||
|
||||
lv_roller_set_options(settingsScreen->month_roller, month_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(settingsScreen->month_roller, 2);
|
||||
lv_obj_add_event_cb(settingsScreen->month_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen);
|
||||
|
||||
lv_roller_set_options(settingsScreen->year_roller, year_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(settingsScreen->year_roller, 2);
|
||||
lv_obj_add_event_cb(settingsScreen->year_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen);
|
||||
|
||||
menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Date Format :");
|
||||
container = create_section_container(section);
|
||||
|
||||
lv_obj_t *date_dropdown = lv_dropdown_create(container);
|
||||
lv_dropdown_set_options_static(date_dropdown, date_format);
|
||||
/*lv_obj_t *hour_roller = lv_roller_create(container);, *minute_roller = lv_roller_create(container), *second_roller = lv_roller_create(container);
|
||||
lv_roller_set_options(hour_roller, hour_options, LV_ROLLER_MODE_INFINITE);
|
||||
lv_roller_set_visible_row_count(hour_roller, 1);
|
||||
lv_obj_set_style_anim_time(hour_roller, 0, LV_PART_MAIN);*/
|
||||
|
||||
|
||||
//We create the menu page for the display settings
|
||||
lv_obj_t *menu_page_2 = lv_menu_page_create(menu, NULL);
|
||||
/*lv_roller_set_options(minute_roller, sec_min_options, LV_ROLLER_MODE_INFINITE);
|
||||
lv_roller_set_visible_row_count(minute_roller, 2);
|
||||
|
||||
section = create_menu_page_section(menu_page_2);
|
||||
lv_roller_set_options(second_roller, sec_min_options, LV_ROLLER_MODE_INFINITE);
|
||||
lv_roller_set_visible_row_count(second_roller, 2);*/
|
||||
|
||||
|
||||
menu_page_1_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_1_label, "Date :");
|
||||
/*container = create_section_container(section);
|
||||
|
||||
lv_obj_t *day_roller = lv_roller_create(container), *month_roller = lv_roller_create(container), *year_roller = lv_roller_create(container);
|
||||
lv_roller_set_options(day_roller, day_options, LV_ROLLER_MODE_INFINITE);
|
||||
lv_roller_set_visible_row_count(day_roller, 2);
|
||||
|
||||
lv_roller_set_options(month_roller, month_options, LV_ROLLER_MODE_INFINITE);
|
||||
lv_roller_set_visible_row_count(month_roller, 2);
|
||||
|
||||
lv_roller_set_options(year_roller, year_options, LV_ROLLER_MODE_INFINITE);
|
||||
lv_roller_set_visible_row_count(year_roller, 2);*/
|
||||
|
||||
menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Brightness :");
|
||||
container = create_section_container(section);
|
||||
|
||||
lv_obj_t *slider = lv_slider_create(container);
|
||||
lv_obj_clear_flag(slider, LV_OBJ_FLAG_GESTURE_BUBBLE);
|
||||
lv_obj_set_width(slider, lv_pct(90));
|
||||
lv_obj_set_align(slider, LV_ALIGN_CENTER);
|
||||
lv_obj_add_event_cb(slider, &(brightness_slider_cb), LV_EVENT_VALUE_CHANGED, settingsScreen);
|
||||
|
||||
menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Sleep Timeout :");
|
||||
container = create_section_container(section);
|
||||
|
||||
lv_obj_t *timeout = lv_roller_create(container);
|
||||
lv_roller_set_options(timeout, second_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(timeout, 2);
|
||||
lv_obj_t *timeout_label = lv_label_create(container);
|
||||
lv_label_set_text_static(timeout_label, "Second(s)");
|
||||
lv_obj_set_style_pad_top(timeout_label, 25, LV_PART_MAIN);
|
||||
|
||||
//We create the side bar page
|
||||
lv_obj_t *sidebar_page = lv_menu_page_create(menu, NULL);
|
||||
@ -312,7 +225,7 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen)
|
||||
|
||||
lv_obj_t *selected = add_sidebar_entry_to_menu(settings_section_1, "Time & Date", menu, menu_page_1);
|
||||
|
||||
add_sidebar_entry_to_menu(settings_section_1, "Display", menu, menu_page_2);
|
||||
add_sidebar_entry_to_menu(settings_section_1, "Display", menu, NULL);
|
||||
|
||||
add_sidebar_entry_to_menu(settings_section_1, "Notifications", menu, NULL);
|
||||
|
||||
@ -339,16 +252,10 @@ void settings_screen_destroy(SettingsScreen_t * const settingsScreen)
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
/*const char *date_format = "dd/mm/yyyy\ndd/mm/yy\nyyyy/mm/dd\nyy/mm/dd";
|
||||
|
||||
const char *lang_options = "English\nFrench\nGerman\nItalian";
|
||||
|
||||
|
@ -5,19 +5,12 @@
|
||||
|
||||
typedef struct SettingsScreenAPIInterface
|
||||
{
|
||||
void (*setBrightnessSettingsCb)(uint8_t brightness);
|
||||
void (*setTimeSettingsCb)(uint8_t hour, uint8_t minute, uint8_t second, uint8_t day, uint8_t month, uint8_t year);
|
||||
|
||||
} SettingsScreenAPIInterface_t;
|
||||
|
||||
typedef struct SettingsScreen
|
||||
{
|
||||
SettingsScreenAPIInterface_t settingsScreenAPIInterface;
|
||||
lv_obj_t *hour_roller;
|
||||
lv_obj_t *minute_roller;
|
||||
lv_obj_t *second_roller;
|
||||
lv_obj_t *day_roller;
|
||||
lv_obj_t *month_roller;
|
||||
lv_obj_t *year_roller;
|
||||
lv_obj_t *display;
|
||||
} SettingsScreen_t;
|
||||
|
||||
|
@ -268,14 +268,14 @@
|
||||
*-----------*/
|
||||
|
||||
/*1: Show CPU usage and FPS count*/
|
||||
#define LV_USE_PERF_MONITOR 0
|
||||
#define LV_USE_PERF_MONITOR 1
|
||||
#if LV_USE_PERF_MONITOR
|
||||
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
|
||||
#endif
|
||||
|
||||
/*1: Show the used memory and the memory fragmentation
|
||||
* Requires LV_MEM_CUSTOM = 0*/
|
||||
#define LV_USE_MEM_MONITOR 0
|
||||
#define LV_USE_MEM_MONITOR 1
|
||||
#if LV_USE_MEM_MONITOR
|
||||
#define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
|
||||
#endif
|
||||
@ -466,9 +466,9 @@
|
||||
|
||||
#define LV_USE_BTN 1
|
||||
|
||||
#define LV_USE_BTNMATRIX 0
|
||||
#define LV_USE_BTNMATRIX 1
|
||||
|
||||
#define LV_USE_CANVAS 0
|
||||
#define LV_USE_CANVAS 1
|
||||
|
||||
#define LV_USE_CHECKBOX 1
|
||||
|
||||
@ -509,7 +509,7 @@
|
||||
*----------*/
|
||||
#define LV_USE_ANIMIMG 1
|
||||
|
||||
#define LV_USE_CALENDAR 0
|
||||
#define LV_USE_CALENDAR 1
|
||||
#if LV_USE_CALENDAR
|
||||
#define LV_CALENDAR_WEEK_STARTS_MONDAY 0
|
||||
#if LV_CALENDAR_WEEK_STARTS_MONDAY
|
||||
|
@ -3,15 +3,12 @@
|
||||
#include "settings_screen.h"
|
||||
#include "menu_screen.h"
|
||||
|
||||
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";
|
||||
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";
|
||||
const char *month_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12";
|
||||
const char *year_options = "22\n23\n24\n25\n26\n27\n28\n29\n30";
|
||||
|
||||
static const char *hour_options = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23";
|
||||
static const char *minute_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\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 *second_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\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";
|
||||
|
||||
const char *date_format = "dd/mm/yyyy\ndd/mm/yy\nyyyy/mm/dd\nyy/mm/dd";
|
||||
const char *hour_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23";
|
||||
const char *sec_min_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\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 void gesture_event_cb(lv_event_t * e)
|
||||
{
|
||||
@ -48,25 +45,6 @@ static void cleanup_event_cb(lv_event_t * e)
|
||||
LV_LOG_USER("cleanup");
|
||||
}
|
||||
|
||||
static void time_roller_cb(lv_event_t * e)
|
||||
{
|
||||
SettingsScreen_t *settingsScreen = e->user_data;
|
||||
lv_obj_t *roller = lv_event_get_target(e);
|
||||
|
||||
if(roller == settingsScreen->hour_roller)
|
||||
{
|
||||
LV_LOG_USER("hour : %u", lv_roller_get_selected(roller));
|
||||
}
|
||||
else if(roller == settingsScreen->minute_roller)
|
||||
{
|
||||
LV_LOG_USER("minute : %u", lv_roller_get_selected(roller));
|
||||
}
|
||||
else
|
||||
{
|
||||
LV_LOG_USER("second : %u", lv_roller_get_selected(roller));
|
||||
}
|
||||
}
|
||||
|
||||
static lv_obj_t* add_sidebar_entry_to_menu(lv_obj_t *parent, const char *title, lv_obj_t *menu, lv_obj_t *pageToShow)
|
||||
{
|
||||
lv_obj_t *container = lv_menu_cont_create(parent);
|
||||
@ -158,8 +136,8 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen)
|
||||
|
||||
lv_obj_t *section = create_menu_page_section(menu_page_1);
|
||||
|
||||
lv_obj_t *menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Set Time & Date :");
|
||||
lv_obj_t *menu_page_1_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_1_label, "Set Time & Date :");
|
||||
|
||||
lv_obj_t *container = create_section_container(section);
|
||||
lv_obj_t *toggle = lv_switch_create(container);
|
||||
@ -167,10 +145,23 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen)
|
||||
lv_label_set_text_static(toggle_label, "Automatic");
|
||||
lv_obj_set_style_pad_top(toggle_label, 5, LV_PART_MAIN);
|
||||
|
||||
menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Time :");
|
||||
menu_page_1_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_1_label, "Time :");
|
||||
|
||||
container = create_section_container(section);
|
||||
|
||||
lv_obj_t *hour_drop = lv_dropdown_create(container);
|
||||
lv_dropdown_set_options_static(hour_drop, hour_options);
|
||||
lv_obj_set_width(hour_drop, lv_pct(30));
|
||||
|
||||
hour_drop = lv_dropdown_create(container);
|
||||
lv_dropdown_set_options_static(hour_drop, sec_min_options);
|
||||
lv_obj_set_width(hour_drop, lv_pct(30));
|
||||
|
||||
hour_drop = lv_dropdown_create(container);
|
||||
lv_dropdown_set_options_static(hour_drop, sec_min_options);
|
||||
lv_obj_set_width(hour_drop, lv_pct(30));
|
||||
|
||||
/*container = lv_obj_create(section);
|
||||
lv_obj_set_style_pad_right(container,0, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_left(container,0, LV_PART_MAIN);
|
||||
@ -190,87 +181,42 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen)
|
||||
lv_obj_set_style_arc_width(arc, 1, LV_PART_MAIN);
|
||||
|
||||
arc = lv_arc_create(container);
|
||||
lv_obj_set_size(arc, 70, 70);
|
||||
lv_obj_set_size(arc, 75, 75);
|
||||
lv_obj_center(arc);
|
||||
lv_obj_set_style_arc_width(arc, 1, LV_PART_INDICATOR);
|
||||
lv_obj_set_style_arc_width(arc, 1, LV_PART_MAIN);*/
|
||||
|
||||
settingsScreen->hour_roller = lv_roller_create(container);
|
||||
settingsScreen->minute_roller = lv_roller_create(container);
|
||||
settingsScreen->second_roller = lv_roller_create(container);
|
||||
/*container = create_section_container(section);
|
||||
|
||||
lv_roller_set_options(settingsScreen->hour_roller, hour_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(settingsScreen->hour_roller, 2);
|
||||
lv_obj_add_event_cb(settingsScreen->hour_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen);
|
||||
lv_obj_t *hour_roller = lv_roller_create(container), *minute_roller = lv_roller_create(container), *second_roller = lv_roller_create(container);
|
||||
lv_roller_set_options(hour_roller, hour_options, LV_ROLLER_MODE_INFINITE);
|
||||
lv_roller_set_visible_row_count(hour_roller, 2);
|
||||
|
||||
lv_roller_set_options(settingsScreen->minute_roller, minute_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(settingsScreen->minute_roller, 2);
|
||||
lv_obj_add_event_cb(settingsScreen->minute_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen);
|
||||
|
||||
lv_roller_set_options(settingsScreen->second_roller, second_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(settingsScreen->second_roller, 2);
|
||||
lv_obj_add_event_cb(settingsScreen->second_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen);
|
||||
lv_roller_set_options(minute_roller, sec_min_options, LV_ROLLER_MODE_INFINITE);
|
||||
lv_roller_set_visible_row_count(minute_roller, 2);
|
||||
|
||||
menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Time Format :");
|
||||
lv_roller_set_options(second_roller, sec_min_options, LV_ROLLER_MODE_INFINITE);
|
||||
lv_roller_set_visible_row_count(second_roller, 2);
|
||||
|
||||
|
||||
menu_page_1_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_1_label, "Date :");
|
||||
container = create_section_container(section);
|
||||
|
||||
lv_obj_t *checkbox_12 = lv_checkbox_create(container), *checkbox_24 = lv_checkbox_create(container);
|
||||
lv_checkbox_set_text(checkbox_12, "12H");
|
||||
lv_obj_set_style_radius(checkbox_12, LV_RADIUS_CIRCLE, LV_PART_INDICATOR);
|
||||
lv_checkbox_set_text(checkbox_24, "24H");
|
||||
lv_obj_add_state(checkbox_24, LV_STATE_CHECKED);
|
||||
lv_obj_set_style_radius(checkbox_24, LV_RADIUS_CIRCLE, LV_PART_INDICATOR);
|
||||
lv_obj_t *day_roller = lv_roller_create(container), *month_roller = lv_roller_create(container), *year_roller = lv_roller_create(container);
|
||||
lv_roller_set_options(day_roller, day_options, LV_ROLLER_MODE_INFINITE);
|
||||
lv_roller_set_visible_row_count(day_roller, 2);
|
||||
|
||||
menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Date :");
|
||||
container = create_section_container(section);
|
||||
lv_roller_set_options(month_roller, month_options, LV_ROLLER_MODE_INFINITE);
|
||||
lv_roller_set_visible_row_count(month_roller, 2);
|
||||
|
||||
settingsScreen->day_roller = lv_roller_create(container);
|
||||
settingsScreen->month_roller = lv_roller_create(container);
|
||||
settingsScreen->year_roller = lv_roller_create(container);
|
||||
|
||||
lv_roller_set_options(settingsScreen->day_roller, day_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(settingsScreen->day_roller, 2);
|
||||
|
||||
lv_roller_set_options(settingsScreen->month_roller, month_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(settingsScreen->month_roller, 2);
|
||||
|
||||
lv_roller_set_options(settingsScreen->year_roller, year_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(settingsScreen->year_roller, 2);
|
||||
|
||||
menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Date Format :");
|
||||
container = create_section_container(section);
|
||||
|
||||
lv_obj_t *date_dropdown = lv_dropdown_create(container);
|
||||
lv_dropdown_set_options_static(date_dropdown, date_format);
|
||||
lv_roller_set_options(year_roller, year_options, LV_ROLLER_MODE_INFINITE);
|
||||
lv_roller_set_visible_row_count(year_roller, 2);*/
|
||||
|
||||
|
||||
//We create the menu page for the display settings
|
||||
lv_obj_t *menu_page_2 = lv_menu_page_create(menu, NULL);
|
||||
|
||||
section = create_menu_page_section(menu_page_2);
|
||||
|
||||
menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Brightness :");
|
||||
container = create_section_container(section);
|
||||
|
||||
lv_obj_t *slider = lv_slider_create(container);
|
||||
lv_obj_clear_flag(slider, LV_OBJ_FLAG_GESTURE_BUBBLE);
|
||||
lv_obj_set_width(slider, lv_pct(90));
|
||||
lv_obj_set_align(slider, LV_ALIGN_CENTER);
|
||||
|
||||
menu_page_label = lv_label_create(section);
|
||||
lv_label_set_text_static(menu_page_label, "Sleep Timeout :");
|
||||
container = create_section_container(section);
|
||||
|
||||
lv_obj_t *timeout = lv_roller_create(container);
|
||||
lv_roller_set_options(timeout, second_options, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(timeout, 2);
|
||||
lv_obj_t *timeout_label = lv_label_create(container);
|
||||
lv_label_set_text_static(timeout_label, "Second(s)");
|
||||
lv_obj_set_style_pad_top(timeout_label, 25, LV_PART_MAIN);
|
||||
|
||||
//We create the side bar page
|
||||
lv_obj_t *sidebar_page = lv_menu_page_create(menu, NULL);
|
||||
@ -310,12 +256,6 @@ void settings_screen_destroy(SettingsScreen_t * const settingsScreen)
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,6 @@ typedef struct SettingsScreenAPIInterface
|
||||
typedef struct SettingsScreen
|
||||
{
|
||||
SettingsScreenAPIInterface_t settingsScreenAPIInterface;
|
||||
lv_obj_t *hour_roller;
|
||||
lv_obj_t *minute_roller;
|
||||
lv_obj_t *second_roller;
|
||||
lv_obj_t *day_roller;
|
||||
lv_obj_t *month_roller;
|
||||
lv_obj_t *year_roller;
|
||||
lv_obj_t *display;
|
||||
} SettingsScreen_t;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user