Added a simple implementation of adaptive MCU core clock to save power, displayed the current core clock in the main task, minor changes to the app_config file
This commit is contained in:
parent
c9d01ef022
commit
0a1737591d
@ -45,7 +45,7 @@
|
||||
#define LCD_DATA_COMMAND WM_IO_PB_08
|
||||
#define LCD_RESET WM_IO_PB_09
|
||||
#define LCD_PWM_BACKLIGHT WM_IO_PA_07
|
||||
#define LCD_PWM_CHANNEL 4
|
||||
#define LCD_PWM_CHANNEL (4)
|
||||
|
||||
/**
|
||||
* @brief lcd touch panel
|
||||
@ -75,6 +75,7 @@
|
||||
* @brief vibration motor control pin
|
||||
*
|
||||
*/
|
||||
#define VIBRATION_MOTOR_ENABLE WM_IO_PB_03
|
||||
#define VIBRATION_MOTOR_ENABLE WM_IO_PB_00
|
||||
#define VIBRATION_MOTOR_PWM_CHANNEL (0)
|
||||
|
||||
#endif //APPCONFIG_H
|
@ -14,7 +14,7 @@ static void vibration_motor_timer_irq_cb(void *p)
|
||||
{
|
||||
(void)p;
|
||||
//tls_gpio_write(VIBRATION_MOTOR_ENABLE, 0);
|
||||
tls_pwm_stop(3);
|
||||
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);
|
||||
APP_LOG_DEBUG("Vibration stopped");
|
||||
@ -69,9 +69,8 @@ void watch_peripherals_vibrate(uint8_t strength, uint32_t durationMs)
|
||||
APP_LOG_DEBUG("Vibration started");
|
||||
/* We start the timer which will stop the vibration after durationMs time */
|
||||
tls_timer_change(_vibration_motor_timer_id, durationMs);
|
||||
//tls_gpio_write(VIBRATION_MOTOR_ENABLE, 1);
|
||||
wm_pwm3_config(VIBRATION_MOTOR_ENABLE);
|
||||
tls_pwm_init(3, 10000, 0, 0);
|
||||
tls_pwm_duty_set(3, strength);
|
||||
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);
|
||||
}
|
||||
|
@ -80,11 +80,21 @@ static void setTimeoutCb(uint8_t timeout)
|
||||
persistency_get_settings()->display.sleep_timeout = timeout;
|
||||
}
|
||||
|
||||
static void setOrientationCb(uint8_t orientation)
|
||||
{
|
||||
extern LCDConfig_t LCDConfig;
|
||||
lcd_orientation(&LCDConfig, orientation);
|
||||
persistency_get_settings()->display.orientation = orientation;
|
||||
// Forces to redraw the full screen to avoid strange artifact
|
||||
lv_obj_invalidate(lv_scr_act());
|
||||
}
|
||||
|
||||
SettingsScreenAPIInterface_t settingsScreenAPIInterface =
|
||||
{
|
||||
.setBrightnessSettingsCb = setBrightnessCb,
|
||||
.setTimeSettingsCb = setTimeCb,
|
||||
.setTimeoutSettingsCb = setTimeoutCb,
|
||||
.setOrientationSettingsCb = setOrientationCb,
|
||||
};
|
||||
|
||||
static uint16_t angle_with_offset(uint16_t angle, uint16_t offset)
|
||||
@ -302,6 +312,7 @@ void gfx_task(void *param)
|
||||
//lcd_on(&LCDConfig, false);
|
||||
lcd_sleep(&LCDConfig, true);
|
||||
QMC5883L_set_power_mode(Standby);
|
||||
CST816D_set_power_mode();
|
||||
// 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 ?
|
||||
@ -313,5 +324,27 @@ void gfx_task(void *param)
|
||||
lcd_sleep(&LCDConfig, false);
|
||||
setBrightness(persistency_get_settings()->display.brightness);
|
||||
}
|
||||
|
||||
/* Throttle CPU freq down when inactive to save power or to increase responsiveness */
|
||||
tls_sys_clk clk;
|
||||
tls_sys_clk_get(&clk);
|
||||
if(lv_disp_get_inactive_time(NULL) > 5000)
|
||||
{
|
||||
if(clk.cpuclk != 40)
|
||||
{
|
||||
tls_sys_clk_set(CPU_CLK_40M);
|
||||
APP_LOG_DEBUG("CPU 40Mhz");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(clk.cpuclk != 160)
|
||||
{
|
||||
tls_sys_clk_set(CPU_CLK_160M);
|
||||
APP_LOG_DEBUG("CPU 160Mhz");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -32,14 +32,17 @@ void user_task_main(void *param)
|
||||
TickType_t time_ref = tls_os_get_time();
|
||||
for(;;)
|
||||
{
|
||||
tls_sys_clk clk;
|
||||
tls_sys_clk_get(&clk);
|
||||
char *buf = tls_mem_alloc(800);
|
||||
if(buf)
|
||||
{
|
||||
UBaseType_t writtenSize = vTaskList((char *)buf, 800);
|
||||
APP_LOG_INFO("Available RAM (bytes)/Total RAM (bytes) : %u/%u"NEW_LINE"Reset reason : %d"NEW_LINE"Tasks (%lu) :"NEW_LINE,
|
||||
APP_LOG_INFO("Available RAM (bytes)/Total RAM (bytes) : %u/%u"NEW_LINE"Reset reason : %d"NEW_LINE"Clk : apb(%u), cpu(%u), wlan(%u)"NEW_LINE"Tasks (%lu) :"NEW_LINE,
|
||||
tls_mem_get_avail_heapsize(),
|
||||
total_mem_size,
|
||||
tls_sys_get_reboot_reason(),
|
||||
clk.apbclk, clk.cpuclk, clk.wlanclk,
|
||||
writtenSize);
|
||||
printf("\n%s", buf);
|
||||
tls_mem_free(buf);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "lv_port_indev.h"
|
||||
#include "wm_gpio.h"
|
||||
#include "app_config.h"
|
||||
#include "lcd.h"
|
||||
#include "CST816D.h"
|
||||
#include "watch_peripherals.h"
|
||||
|
||||
@ -115,6 +116,7 @@ void lv_port_indev_init(void)
|
||||
|
||||
static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
extern LCDConfig_t LCDConfig;
|
||||
static lv_coord_t last_x = 0;
|
||||
static lv_coord_t last_y = 0;
|
||||
|
||||
@ -130,9 +132,26 @@ static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
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 taking into account the current display orientation
|
||||
switch(LCDConfig.LCDOrientation)
|
||||
{
|
||||
case LCD_ORIENTATION_90:
|
||||
data->point.x = 239-last_y;
|
||||
data->point.y = last_x;
|
||||
break;
|
||||
case LCD_ORIENTATION_180:
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
break;
|
||||
case LCD_ORIENTATION_270:
|
||||
data->point.x = last_y;
|
||||
data->point.y = 239-last_x;
|
||||
break;
|
||||
default:
|
||||
data->point.x = 239-last_x;
|
||||
data->point.y = 239-last_y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#else /*Enable this file at the top*/
|
||||
|
Loading…
Reference in New Issue
Block a user