Compare commits
No commits in common. "a165e8a2431ddb77c86b4cb4347d5b07d47a241a" and "0138b7d152da90e57b5fd7b429eccddf49d04b09" have entirely different histories.
a165e8a243
...
0138b7d152
@ -1 +0,0 @@
|
||||
|
@ -1,6 +0,0 @@
|
||||
#ifndef CST816D_H
|
||||
#define CST816D_H
|
||||
|
||||
|
||||
|
||||
#endif //CST816D_H
|
@ -78,7 +78,7 @@ const uint8_t gc9a01_init_seq[] = {
|
||||
0x02, 0, 0x8E, 0xFF,
|
||||
0x02, 0, 0x8F, 0xFF,
|
||||
0x03, 0, 0xB6, 0x00, 0x00,
|
||||
0x02, 0, 0x36, 0x88,
|
||||
0x02, 0, 0x36, 0x48,
|
||||
0x02, 0, 0x3A, 0x55,
|
||||
0x05, 0, 0x90, 0x08, 0x08, 0x08, 0x08,
|
||||
0x02, 0, 0xBD, 0x06,
|
||||
@ -298,6 +298,10 @@ void lcd_register_draw_finished_cb(LCDConfig_t * const LCDConfig, DrawFinishedCb
|
||||
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->LCDChipSelectPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||
@ -417,24 +421,8 @@ void lcd_set_backlight(LCDConfig_t * const LCDConfig, uint8_t brightness)
|
||||
{
|
||||
if(!LCDConfig) return;
|
||||
|
||||
if(brightness)
|
||||
{
|
||||
// Backlight is controlled using PWM
|
||||
wm_pwm4_config(LCDConfig->LCDPWMBacklightPin);
|
||||
// Set pwm to 10kHz
|
||||
tls_pwm_init(4, 10000, 0, 0);
|
||||
// Set brightness
|
||||
tls_pwm_duty_set(4, brightness);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We stop the pwm
|
||||
tls_pwm_stop(4);
|
||||
tls_gpio_cfg(LCDConfig->LCDPWMBacklightPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||
tls_gpio_write(LCDConfig->LCDPWMBacklightPin, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void lcd_hardware_reset(LCDConfig_t * const LCDConfig)
|
||||
{
|
||||
|
@ -37,7 +37,6 @@ static void date_time_cb(struct tm * const dateTime)
|
||||
{
|
||||
if(!dateTime)return;
|
||||
tls_get_rtc(dateTime);
|
||||
//APP_LOG_DEBUG("RTC time : %d:%d:%d", dateTime->tm_hour, dateTime->tm_min, dateTime->tm_sec);
|
||||
}
|
||||
|
||||
WatchFace_t watchFace;
|
||||
@ -48,7 +47,6 @@ SettingsScreen_t settingsScreen;
|
||||
struct bma4_dev bma;
|
||||
struct bma4_accel_config accel_conf;
|
||||
struct bma456w_wrist_wear_wakeup_params setting;
|
||||
struct bma4_int_pin_config pin_config;
|
||||
uint16_t int_status;
|
||||
|
||||
static void setBrightnessCb(uint8_t brightness)
|
||||
@ -120,18 +118,6 @@ static void delay_us(uint32_t period, void *intf_ptr)
|
||||
}
|
||||
|
||||
|
||||
/*uint16_t x = 0, y = 0, action = 0;
|
||||
|
||||
static void touch_screen_isr(void *arg)
|
||||
{
|
||||
tls_clr_gpio_irq_status(WM_IO_PB_00);
|
||||
uint8_t tc_data[9];
|
||||
i2c_read(0x15, 0x00, tc_data, sizeof tc_data);
|
||||
x = ((tc_data[3] & 0x0f) << 8) | tc_data[4];
|
||||
y = ((tc_data[5] & 0x0f) << 8) | tc_data[6];
|
||||
action = tc_data[3] >> 6;
|
||||
}*/
|
||||
|
||||
void gfx_task(void *param)
|
||||
{
|
||||
APP_LOG_TRACE("starting");
|
||||
@ -145,7 +131,7 @@ void gfx_task(void *param)
|
||||
display_driver.hor_res = LCD_PIXEL_WIDTH;
|
||||
display_driver.ver_res = LCD_PIXEL_HEIGHT;
|
||||
|
||||
display_driver.rotated = LV_DISP_ROT_NONE;
|
||||
display_driver.rotated = LV_DISP_ROT_180;
|
||||
|
||||
lv_disp_draw_buf_init(&lvgl_draw_buffer_dsc, lvgl_draw_buffer, NULL, LVGL_GFX_BUFFER_SIZE);
|
||||
|
||||
@ -192,7 +178,7 @@ void gfx_task(void *param)
|
||||
lv_scr_load(watchFace.display);
|
||||
|
||||
/* Let's init the I2C interface */
|
||||
i2c_init(WM_IO_PA_04, WM_IO_PA_01, 100000);
|
||||
i2c_init(WM_IO_PA_04, WM_IO_PA_01, 400000);
|
||||
|
||||
uint8_t aliveCounter = 0;
|
||||
|
||||
@ -214,8 +200,7 @@ void gfx_task(void *param)
|
||||
else
|
||||
APP_LOG_INFO("QMC5883L configured");
|
||||
|
||||
//QMC5883L_set_calibration_data(-900, 2500, -1400, 1400, 2300, 7500, 0.0);
|
||||
QMC5883L_set_calibration_data(4812, 8550, -3200, 20, -2200, 3500, 0.0);
|
||||
QMC5883L_set_calibration_data(-900, 2500, -1400, 1400, 2300, 7500, 0.0);
|
||||
|
||||
/* Init the BMP280 */
|
||||
if(!BMP280_init())
|
||||
@ -273,30 +258,18 @@ void gfx_task(void *param)
|
||||
|
||||
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);
|
||||
|
||||
if(bma4_get_int_pin_config(&pin_config, BMA4_INTR1_MAP, &bma) == BMA4_OK)
|
||||
APP_LOG_INFO("BMA456 get pin conf ok");
|
||||
else
|
||||
APP_LOG_INFO("BMA456 get pin conf failed");
|
||||
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);*/
|
||||
|
||||
if(bma456w_map_interrupt(BMA4_INTR1_MAP, BMA456W_WRIST_WEAR_WAKEUP_INT, BMA4_ENABLE, &bma) == BMA4_OK)
|
||||
APP_LOG_INFO("BMA456 map int ok");
|
||||
else
|
||||
APP_LOG_INFO("BMA456 map int failed");
|
||||
|
||||
pin_config.edge_ctrl = BMA4_EDGE_TRIGGER;
|
||||
pin_config.output_en = BMA4_OUTPUT_ENABLE;
|
||||
pin_config.lvl = BMA4_ACTIVE_LOW;
|
||||
pin_config.od = BMA4_PUSH_PULL;
|
||||
pin_config.input_en = BMA4_INPUT_DISABLE;
|
||||
|
||||
if(bma4_set_int_pin_config(&pin_config, BMA4_INTR1_MAP, &bma) == BMA4_OK)
|
||||
APP_LOG_INFO("BMA456 set pin conf ok");
|
||||
else
|
||||
APP_LOG_INFO("BMA456 set pin conf failed");
|
||||
|
||||
/*tls_gpio_cfg(WM_IO_PB_00, WM_GPIO_DIR_INPUT, WM_GPIO_ATTR_PULLHIGH);
|
||||
tls_gpio_isr_register(WM_IO_PB_00, &(touch_screen_isr), NULL);
|
||||
tls_gpio_irq_enable(WM_IO_PB_00, WM_GPIO_IRQ_TRIG_FALLING_EDGE);*/
|
||||
|
||||
for(;;)
|
||||
{
|
||||
@ -305,46 +278,35 @@ void gfx_task(void *param)
|
||||
|
||||
if(compass_screen_is_in_use(&compassScreen) && QMC5883L_is_data_available())
|
||||
{
|
||||
/*__disable_irq();
|
||||
QMC5883L_MData_t MDataRaw = QMC5883L_get_MFields_raw();
|
||||
APP_LOG_TRACE("X %d Y %d Z %d", MDataRaw.MFieldX, MDataRaw.MFieldY, MDataRaw.MFieldZ);
|
||||
__enable_irq();*/
|
||||
//QMC5883L_MData_t MDataRaw = QMC5883L_get_MFields_raw();
|
||||
//APP_LOG_TRACE("X %d Y %d Z %d", MDataRaw.MFieldX, MDataRaw.MFieldY, MDataRaw.MFieldZ);
|
||||
|
||||
QMC5883L_MData_calibrated_t MData = QMC5883L_get_MFields_calibrated();
|
||||
compass_screen_set_azimuth(&compassScreen, angle_with_offset(QMC5883L_get_azimuth(MData), 180));
|
||||
}
|
||||
|
||||
/*uint8_t rslt = bma456w_read_int_status(&int_status, &bma);
|
||||
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("------------ x %d y %d, action : %d", x, y, action);
|
||||
|
||||
aliveCounter = 0;
|
||||
}
|
||||
|
||||
/* Handle inactivity periods : */
|
||||
/*if(lv_disp_get_inactive_time(NULL) > 10000)
|
||||
{
|
||||
// First, we disable the display backlight and we set all the peripherals in their low power mode
|
||||
lcd_set_backlight(&LCDConfig, 0);
|
||||
// Let's sleep
|
||||
tls_pmu_sleep_start();
|
||||
// On wake up, we force the watch face to sync up with the rtc /!\ RTC update delay WTF ?
|
||||
tls_os_time_delay(1);
|
||||
watch_face_force_sync(&watchFace);
|
||||
lv_disp_trig_activity(NULL);
|
||||
lcd_set_backlight(&LCDConfig, 255);
|
||||
}*/
|
||||
}
|
||||
}
|
@ -11,7 +11,6 @@
|
||||
*********************/
|
||||
#include "lv_port_indev.h"
|
||||
#include "touchpad.h"
|
||||
#include "i2c.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -68,18 +67,6 @@ lv_indev_t * indev_touchpad;
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
uint16_t x = 0, y = 0, action = 0;
|
||||
|
||||
static void touch_screen_isr(void *arg)
|
||||
{
|
||||
tls_clr_gpio_irq_status(WM_IO_PB_00);
|
||||
uint8_t tc_data[9];
|
||||
i2c_read(0x15, 0x00, tc_data, sizeof tc_data);
|
||||
x = ((tc_data[3] & 0x0f) << 8) | tc_data[4];
|
||||
y = ((tc_data[5] & 0x0f) << 8) | tc_data[6];
|
||||
action = tc_data[3] >> 6;
|
||||
}
|
||||
|
||||
void lv_port_indev_init(void)
|
||||
{
|
||||
/**
|
||||
@ -101,10 +88,7 @@ void lv_port_indev_init(void)
|
||||
* -----------------*/
|
||||
|
||||
/*Initialize your touchpad if you have*/
|
||||
//touchpad_init();
|
||||
tls_gpio_cfg(WM_IO_PB_00, WM_GPIO_DIR_INPUT, WM_GPIO_ATTR_PULLHIGH);
|
||||
tls_gpio_isr_register(WM_IO_PB_00, &(touch_screen_isr), NULL);
|
||||
tls_gpio_irq_enable(WM_IO_PB_00, WM_GPIO_IRQ_TRIG_FALLING_EDGE);
|
||||
touchpad_init();
|
||||
|
||||
/*Register a touchpad input device*/
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
@ -203,12 +187,12 @@ static void touchpad_init(void)
|
||||
}
|
||||
|
||||
/*Will be called by the library to read the touchpad*/
|
||||
/*static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
static lv_coord_t last_x = 0;
|
||||
static lv_coord_t last_y = 0;
|
||||
|
||||
// Save the pressed coordinates and the state
|
||||
/*Save the pressed coordinates and the state*/
|
||||
if(touchpad_is_pressed()) {
|
||||
touchpad_get_xy(&last_x, &last_y);
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
@ -217,60 +201,30 @@ static void touchpad_init(void)
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
// Set the last pressed coordinates
|
||||
data->point.x = 240-last_y;
|
||||
data->point.y = last_x;
|
||||
}*/
|
||||
|
||||
static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
static lv_coord_t last_x = 0;
|
||||
static lv_coord_t last_y = 0;
|
||||
|
||||
// Save the pressed coordinates and the state
|
||||
if(touchpad_is_pressed()) {
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
}
|
||||
else {
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
// Set the last pressed coordinates
|
||||
data->point.x = 239-last_x;
|
||||
data->point.y = 239-last_y;
|
||||
/*Set the last pressed coordinates*/
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
}
|
||||
|
||||
/*Return true is the touchpad is pressed*/
|
||||
/*static bool touchpad_is_pressed(void)
|
||||
static bool touchpad_is_pressed(void)
|
||||
{
|
||||
// Your code comes here
|
||||
/*Your code comes here*/
|
||||
bool val = bsp_touchpad_is_pressed();
|
||||
// printf("---> %d\n",val);
|
||||
return val;
|
||||
}*/
|
||||
|
||||
static bool touchpad_is_pressed(void)
|
||||
{
|
||||
return action == 2;
|
||||
}
|
||||
|
||||
/*Get the x and y coordinates if the touchpad is pressed*/
|
||||
static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y)
|
||||
{
|
||||
//Your code comes here
|
||||
/*Your code comes here*/
|
||||
// (*x) = ;
|
||||
// (*y) = ;
|
||||
bsp_touchpad_get_xy(x, y);
|
||||
// printf("---> x:%d y:%d\n", (*x), (*y));
|
||||
}
|
||||
|
||||
/*static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y)
|
||||
{
|
||||
|
||||
}*/
|
||||
|
||||
// /*------------------
|
||||
// * Mouse
|
||||
// * -----------------*/
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include "watch_face.h"
|
||||
#include "menu_screen.h"
|
||||
#include <stdio.h>
|
||||
#include "app_log.h"
|
||||
|
||||
static void gesture_event_cb(lv_event_t * e)
|
||||
{
|
||||
@ -61,7 +60,6 @@ static void update_watch_hands_angles(WatchFace_t * const watchFace, uint8_t inc
|
||||
//Don't forget to update the day date window
|
||||
sprintf(watchFace->dateWindow.dateWindowText, "%s%d", watchFace->dateTime.tm_mday < 10 ? " " : "", watchFace->dateTime.tm_mday);
|
||||
lv_obj_invalidate(watchFace->dateWindow.dateWindowWidget);
|
||||
APP_LOG_DEBUG("Syncing time");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -135,7 +133,6 @@ void watch_face_create(WatchFace_t * const watchFace)
|
||||
watchFace->display = NULL;
|
||||
}
|
||||
watchFace->display = lv_obj_create(NULL);
|
||||
lv_obj_set_style_bg_color(watchFace->display, lv_color_black(), LV_PART_MAIN);
|
||||
//We load our assets :
|
||||
lv_obj_t *watchFaceImg = lv_img_create(watchFace->display);
|
||||
lv_img_set_src(watchFaceImg, &watch_casio_face_asset);
|
||||
@ -228,19 +225,6 @@ void watch_face_create(WatchFace_t * const watchFace)
|
||||
watchFace->handAnimationTimer = lv_timer_create(&(hand_timer_anim_cb), 199, watchFace);
|
||||
}
|
||||
|
||||
void watch_face_force_sync(WatchFace_t *const watchFace)
|
||||
{
|
||||
if(!watchFace)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!watchFace->display) return;
|
||||
|
||||
update_watch_hands_angles(watchFace, 0);
|
||||
}
|
||||
|
||||
void watch_face_destroy(WatchFace_t * const watchFace)
|
||||
{
|
||||
if(!watchFace)
|
||||
|
@ -42,13 +42,6 @@ void watch_face_register_cb(WatchFace_t * const watchFace, DateTimeCb_t DateTime
|
||||
/* Builds the watch face graphically */
|
||||
void watch_face_create(WatchFace_t * const watchFace);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/* Frees all resources used by the WatchFace object */
|
||||
void watch_face_destroy(WatchFace_t * const watchFace);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user