Compare commits
No commits in common. "10cb049ab16f7d22341cdc7fb5715d6b2d425208" and "5276ce16648fcf38c8717372a991139719c274a0" have entirely different histories.
10cb049ab1
...
5276ce1664
@ -21,19 +21,6 @@ static int8_t _adc_offset = 0;
|
|||||||
|
|
||||||
/* Vibration motor timer */
|
/* Vibration motor timer */
|
||||||
static uint8_t _vibration_motor_timer_id = WM_TIMER_ID_INVALID;
|
static uint8_t _vibration_motor_timer_id = WM_TIMER_ID_INVALID;
|
||||||
static uint8_t _vibration_strength = 0;
|
|
||||||
|
|
||||||
static struct vibration_pattern_conf
|
|
||||||
{
|
|
||||||
uint16_t vibration_pattern[VIBRATION_PATTERN_SLOTS];
|
|
||||||
uint8_t vibration_pattern_index;
|
|
||||||
bool vibration_pattern_mode;
|
|
||||||
} _vibration_pattern_conf =
|
|
||||||
{
|
|
||||||
.vibration_pattern = {0}, /* Used to store the pattern itself */
|
|
||||||
.vibration_pattern_index = 0, /* Used to iterate over the array */
|
|
||||||
.vibration_pattern_mode = false, /* Value used by the timer callback to know if we are in pattern mode */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Battery charge controller status */
|
/* Battery charge controller status */
|
||||||
static battery_controller_status_e _battery_fsm = BATTERY_CONTROLLER_STATUS_DISCHARGING;
|
static battery_controller_status_e _battery_fsm = BATTERY_CONTROLLER_STATUS_DISCHARGING;
|
||||||
@ -63,40 +50,9 @@ struct
|
|||||||
static void vibration_motor_timer_irq_cb(void *p)
|
static void vibration_motor_timer_irq_cb(void *p)
|
||||||
{
|
{
|
||||||
(void)p;
|
(void)p;
|
||||||
|
|
||||||
if(!_vibration_pattern_conf.vibration_pattern_mode)
|
|
||||||
{
|
|
||||||
tls_pwm_stop(VIBRATION_MOTOR_PWM_CHANNEL);
|
tls_pwm_stop(VIBRATION_MOTOR_PWM_CHANNEL);
|
||||||
tls_gpio_cfg(VIBRATION_MOTOR_ENABLE, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
tls_gpio_cfg(VIBRATION_MOTOR_ENABLE, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||||
tls_gpio_write(VIBRATION_MOTOR_ENABLE, 0);
|
tls_gpio_write(VIBRATION_MOTOR_ENABLE, 0);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Depending on the index, we may turn the vibration on or off */
|
|
||||||
if(++_vibration_pattern_conf.vibration_pattern_index % 2 != 0) /* Odd indexes */
|
|
||||||
{
|
|
||||||
tls_pwm_stop(VIBRATION_MOTOR_PWM_CHANNEL);
|
|
||||||
tls_gpio_cfg(VIBRATION_MOTOR_ENABLE, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
|
||||||
tls_gpio_write(VIBRATION_MOTOR_ENABLE, 0);
|
|
||||||
}
|
|
||||||
else if(_vibration_pattern_conf.vibration_pattern[_vibration_pattern_conf.vibration_pattern_index]) /* We turn the vibration back on */
|
|
||||||
{
|
|
||||||
wm_pwm0_config(VIBRATION_MOTOR_ENABLE);
|
|
||||||
tls_pwm_init(VIBRATION_MOTOR_PWM_CHANNEL, 10000, 0, 0);
|
|
||||||
tls_pwm_duty_set(VIBRATION_MOTOR_PWM_CHANNEL, _vibration_strength);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we are reaching the end of the pattern array, or the current pattern has a length of 0 (meaning the end), exit the function */
|
|
||||||
if(_vibration_pattern_conf.vibration_pattern_index >= VIBRATION_PATTERN_SLOTS - 1 || !_vibration_pattern_conf.vibration_pattern[_vibration_pattern_conf.vibration_pattern_index])
|
|
||||||
{
|
|
||||||
_vibration_pattern_conf.vibration_pattern_index = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We rearm the timer for the next call */
|
|
||||||
tls_timer_change(_vibration_motor_timer_id, _vibration_pattern_conf.vibration_pattern[_vibration_pattern_conf.vibration_pattern_index]);
|
|
||||||
tls_timer_start(_vibration_motor_timer_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BATTERY_CONTROLLER_STATUS_DETECTION_POLICY == POLL_POLICY && HARDWARE_PLATFORM == SMART_WATCH_PCB
|
#if BATTERY_CONTROLLER_STATUS_DETECTION_POLICY == POLL_POLICY && HARDWARE_PLATFORM == SMART_WATCH_PCB
|
||||||
@ -339,10 +295,6 @@ void watch_peripherals_vibrate(uint8_t strength, uint32_t durationMs)
|
|||||||
{
|
{
|
||||||
/* No need to do anything if the duration is 0 or if the strength is 0 */
|
/* No need to do anything if the duration is 0 or if the strength is 0 */
|
||||||
if(!strength || !durationMs) return;
|
if(!strength || !durationMs) return;
|
||||||
|
|
||||||
/* We indicate that we are not working in vibration pattern mode */
|
|
||||||
_vibration_pattern_conf.vibration_pattern_mode = false;
|
|
||||||
|
|
||||||
/* We start the timer which will stop the vibration after durationMs time */
|
/* We start the timer which will stop the vibration after durationMs time */
|
||||||
tls_timer_change(_vibration_motor_timer_id, durationMs);
|
tls_timer_change(_vibration_motor_timer_id, durationMs);
|
||||||
wm_pwm0_config(VIBRATION_MOTOR_ENABLE);
|
wm_pwm0_config(VIBRATION_MOTOR_ENABLE);
|
||||||
@ -351,29 +303,6 @@ void watch_peripherals_vibrate(uint8_t strength, uint32_t durationMs)
|
|||||||
tls_timer_start(_vibration_motor_timer_id);
|
tls_timer_start(_vibration_motor_timer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void watch_peripherals_vibrate_with_pattern(uint8_t strength, uint16_t pattern[VIBRATION_PATTERN_SLOTS])
|
|
||||||
{
|
|
||||||
if(!pattern || !strength) return;
|
|
||||||
if(!pattern[0]) return;
|
|
||||||
|
|
||||||
/* We indicate that we are working in vibration pattern mode */
|
|
||||||
_vibration_pattern_conf.vibration_pattern_mode = true;
|
|
||||||
|
|
||||||
/* First we copy the provided pattern in our local array */
|
|
||||||
memcpy(_vibration_pattern_conf.vibration_pattern, pattern, sizeof _vibration_pattern_conf.vibration_pattern);
|
|
||||||
/* We reset the iterator index */
|
|
||||||
_vibration_pattern_conf.vibration_pattern_index = 0;
|
|
||||||
_vibration_strength = strength;
|
|
||||||
/* We start the timer and the vibration */
|
|
||||||
tls_timer_change(_vibration_motor_timer_id, _vibration_pattern_conf.vibration_pattern[_vibration_pattern_conf.vibration_pattern_index]);
|
|
||||||
|
|
||||||
wm_pwm0_config(VIBRATION_MOTOR_ENABLE);
|
|
||||||
tls_pwm_init(VIBRATION_MOTOR_PWM_CHANNEL, 10000, 0, 0);
|
|
||||||
tls_pwm_duty_set(VIBRATION_MOTOR_PWM_CHANNEL, strength);
|
|
||||||
|
|
||||||
tls_timer_start(_vibration_motor_timer_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void watch_peripherals_set_brightness(uint8_t brightness)
|
void watch_peripherals_set_brightness(uint8_t brightness)
|
||||||
{
|
{
|
||||||
extern LCDConfig_t LCDConfig;
|
extern LCDConfig_t LCDConfig;
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
#include "wm_type_def.h"
|
#include "wm_type_def.h"
|
||||||
#include "QMC5883L.h"
|
#include "QMC5883L.h"
|
||||||
|
|
||||||
#define VIBRATION_PATTERN_SLOTS (8)
|
|
||||||
|
|
||||||
typedef enum battery_unit
|
typedef enum battery_unit
|
||||||
{
|
{
|
||||||
battery_unit_mv = 0,
|
battery_unit_mv = 0,
|
||||||
@ -85,15 +83,6 @@ battery_controller_status_e watch_peripherals_get_battery_controller_status(void
|
|||||||
*/
|
*/
|
||||||
void watch_peripherals_vibrate(uint8_t strength, uint32_t durationMs);
|
void watch_peripherals_vibrate(uint8_t strength, uint32_t durationMs);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Triggers the vibration motor to vibrate with the specified pattern.
|
|
||||||
*
|
|
||||||
* @param strength the vibration strength from 0 to 255 (the same is used for every vibrations)
|
|
||||||
* @param pattern the vibration pattern : a pointer to an array of size @ref VIBRATION_PATTERN_SLOTS.
|
|
||||||
* The first duration is the on duration, the second is the off duration and so on.
|
|
||||||
*/
|
|
||||||
void watch_peripherals_vibrate_with_pattern(uint8_t strength, uint16_t pattern[VIBRATION_PATTERN_SLOTS]);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the brightness of the LCD display
|
* @brief Sets the brightness of the LCD display
|
||||||
*
|
*
|
||||||
|
@ -57,11 +57,11 @@ static void music_player_button_click_event_cb(lv_event_t *e)
|
|||||||
}
|
}
|
||||||
else if(action == MUSIC_CONTROL_NEXT)
|
else if(action == MUSIC_CONTROL_NEXT)
|
||||||
{
|
{
|
||||||
musicPlayerScreen->musicPlaybackCtrlCb(e->code == LV_EVENT_SHORT_CLICKED ? MUSIC_CONTROL_NEXT : MUSIC_CONTROL_FORWARD);
|
musicPlayerScreen->musicPlaybackCtrlCb(e->code == LV_EVENT_SHORT_CLICKED ? MUSIC_CONTROL_FORWARD : MUSIC_CONTROL_NEXT);
|
||||||
}
|
}
|
||||||
else if(action == MUSIC_CONTROL_PREVIOUS)
|
else if(action == MUSIC_CONTROL_PREVIOUS)
|
||||||
{
|
{
|
||||||
musicPlayerScreen->musicPlaybackCtrlCb(e->code == LV_EVENT_SHORT_CLICKED ? MUSIC_CONTROL_PREVIOUS : MUSIC_CONTROL_REWIND);
|
musicPlayerScreen->musicPlaybackCtrlCb(e->code == LV_EVENT_SHORT_CLICKED ? MUSIC_CONTROL_REWIND : MUSIC_CONTROL_PREVIOUS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ static void update_watch_hands_angles(WatchFace_t * const watchFace, uint8_t inc
|
|||||||
watchFace->secondHand.handAngle = 60 * watchFace->dateTime.tm_sec;
|
watchFace->secondHand.handAngle = 60 * watchFace->dateTime.tm_sec;
|
||||||
|
|
||||||
//Don't forget to update the day date window
|
//Don't forget to update the day date window
|
||||||
sprintf(watchFace->dateWindow.dateWindowText, "%d", watchFace->dateTime.tm_mday);
|
sprintf(watchFace->dateWindow.dateWindowText, "%s%d", watchFace->dateTime.tm_mday < 10 ? " " : "", watchFace->dateTime.tm_mday);
|
||||||
lv_label_set_text_static(watchFace->dateWindow.dateWindowWidget, watchFace->dateWindow.dateWindowText);
|
lv_label_set_text_static(watchFace->dateWindow.dateWindowWidget, watchFace->dateWindow.dateWindowText);
|
||||||
|
|
||||||
APP_LOG_DEBUG("Syncing time");
|
APP_LOG_DEBUG("Syncing time");
|
||||||
@ -372,9 +372,7 @@ void watch_face_create(WatchFace_t * const watchFace)
|
|||||||
}
|
}
|
||||||
watchFace->dateWindow.dateWindowWidget = lv_label_create(watchFace->display);
|
watchFace->dateWindow.dateWindowWidget = lv_label_create(watchFace->display);
|
||||||
lv_label_set_text_static(watchFace->dateWindow.dateWindowWidget, watchFace->dateWindow.dateWindowText);
|
lv_label_set_text_static(watchFace->dateWindow.dateWindowWidget, watchFace->dateWindow.dateWindowText);
|
||||||
lv_obj_set_pos(watchFace->dateWindow.dateWindowWidget, 180,112);
|
lv_obj_set_pos(watchFace->dateWindow.dateWindowWidget, 182,111);
|
||||||
lv_obj_set_width(watchFace->dateWindow.dateWindowWidget, 20);
|
|
||||||
lv_obj_set_style_text_align(watchFace->dateWindow.dateWindowWidget, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN);
|
|
||||||
|
|
||||||
if(watchFace->hourHand.handImg)
|
if(watchFace->hourHand.handImg)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user