Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 92bead72b9 | |||
| 5ef6c20862 | |||
| b154c3fa20 |
+147
-43
@@ -7,20 +7,38 @@
|
|||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/queue.h"
|
#include "freertos/queue.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "lvgl.h"
|
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
static const char *TAG = "motion";
|
static const char *TAG = "motion";
|
||||||
|
|
||||||
|
#define SAMPLE_PERIOD_MS 10
|
||||||
#define SAMPLE_RATE_HZ 100
|
#define SAMPLE_RATE_HZ 100
|
||||||
|
|
||||||
|
/* Calibration: keep a sliding window of the last 500 ms and finish only when
|
||||||
|
* the window is stable (low variance). This avoids calibrating while the user
|
||||||
|
* is picking up or moving the device. */
|
||||||
|
#define CALIBRATION_MS 500
|
||||||
|
#define CALIBRATION_WINDOW_SAMPLES (CALIBRATION_MS / SAMPLE_PERIOD_MS)
|
||||||
|
#define CALIBRATION_MAX_VAR_G2 0.010f
|
||||||
|
|
||||||
|
/* Shake is detected on the horizontal plane (X/Y) so that picking the device
|
||||||
|
* up or putting it down (Z-axis jolt) does not trigger navigation. */
|
||||||
#define THRESHOLD_LOW_G 0.6f
|
#define THRESHOLD_LOW_G 0.6f
|
||||||
#define THRESHOLD_MED_G 0.8f
|
#define THRESHOLD_MED_G 0.8f
|
||||||
#define THRESHOLD_HIGH_G 1.0f
|
#define THRESHOLD_HIGH_G 1.0f
|
||||||
|
|
||||||
|
/* A valid shake must produce enough strong samples within a short window. */
|
||||||
#define WINDOW_MS 300
|
#define WINDOW_MS 300
|
||||||
#define MIN_SAMPLES 5
|
#define MIN_SAMPLES 5
|
||||||
#define COOLDOWN_MS 800
|
|
||||||
#define CALIBRATION_MS 500
|
/* A real shake oscillates; require at least two zero-crossings on the
|
||||||
|
* dominant horizontal axis to distinguish it from a single jolt. */
|
||||||
|
#define MIN_ZERO_CROSSINGS 2
|
||||||
|
|
||||||
|
/* Cooldown prevents one physical shake from generating multiple events. */
|
||||||
|
#define COOLDOWN_MS 350
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GESTURE_IDLE = 0,
|
GESTURE_IDLE = 0,
|
||||||
@@ -32,20 +50,29 @@ static bool s_enabled = true;
|
|||||||
static float s_threshold = THRESHOLD_MED_G;
|
static float s_threshold = THRESHOLD_MED_G;
|
||||||
static gesture_state_t s_state = GESTURE_IDLE;
|
static gesture_state_t s_state = GESTURE_IDLE;
|
||||||
|
|
||||||
|
/* Baseline calibration */
|
||||||
static float s_ref_x;
|
static float s_ref_x;
|
||||||
static float s_ref_y;
|
static float s_ref_y;
|
||||||
static float s_ref_z;
|
static float s_ref_z;
|
||||||
static bool s_calibrated;
|
static bool s_calibrated;
|
||||||
static int64_t s_cal_start_us;
|
|
||||||
static int s_cal_count;
|
|
||||||
static float s_cal_sum_x;
|
|
||||||
static float s_cal_sum_y;
|
|
||||||
static float s_cal_sum_z;
|
|
||||||
|
|
||||||
|
static float s_cal_buf_x[CALIBRATION_WINDOW_SAMPLES];
|
||||||
|
static float s_cal_buf_y[CALIBRATION_WINDOW_SAMPLES];
|
||||||
|
static float s_cal_buf_z[CALIBRATION_WINDOW_SAMPLES];
|
||||||
|
static int s_cal_head;
|
||||||
|
static int s_cal_count;
|
||||||
|
|
||||||
|
/* Detection window state */
|
||||||
static int s_over_count;
|
static int s_over_count;
|
||||||
static int64_t s_window_start_us;
|
static int64_t s_window_start_us;
|
||||||
|
static int s_zero_crossings;
|
||||||
|
static int s_last_x_sign;
|
||||||
|
static int s_last_y_sign;
|
||||||
static int64_t s_cooldown_until_us;
|
static int64_t s_cooldown_until_us;
|
||||||
|
|
||||||
|
/* Last horizontal magnitude, exposed for UI/debug. */
|
||||||
|
static float s_last_horizontal_mag;
|
||||||
|
|
||||||
static void nav_handler_task(void *arg)
|
static void nav_handler_task(void *arg)
|
||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
@@ -58,11 +85,6 @@ static void nav_handler_task(void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static float magnitude(float ax, float ay, float az)
|
|
||||||
{
|
|
||||||
return sqrtf(ax * ax + ay * ay + az * az);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void post_nav_next(void)
|
static void post_nav_next(void)
|
||||||
{
|
{
|
||||||
motion_nav_event_t ev = MOTION_NAV_NEXT;
|
motion_nav_event_t ev = MOTION_NAV_NEXT;
|
||||||
@@ -73,30 +95,78 @@ static void post_nav_next(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_calibration(float ax, float ay, float az)
|
|
||||||
{
|
|
||||||
s_cal_sum_x += ax;
|
|
||||||
s_cal_sum_y += ay;
|
|
||||||
s_cal_sum_z += az;
|
|
||||||
s_cal_count++;
|
|
||||||
|
|
||||||
int64_t elapsed_us = esp_timer_get_time() - s_cal_start_us;
|
|
||||||
if (elapsed_us >= (int64_t)CALIBRATION_MS * 1000) {
|
|
||||||
if (s_cal_count > 0) {
|
|
||||||
s_ref_x = s_cal_sum_x / (float)s_cal_count;
|
|
||||||
s_ref_y = s_cal_sum_y / (float)s_cal_count;
|
|
||||||
s_ref_z = s_cal_sum_z / (float)s_cal_count;
|
|
||||||
}
|
|
||||||
s_calibrated = true;
|
|
||||||
ESP_LOGI(TAG, "Baseline calibrated (ref=%.3f,%.3f,%.3f g)", s_ref_x, s_ref_y,
|
|
||||||
s_ref_z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void reset_window(void)
|
static void reset_window(void)
|
||||||
{
|
{
|
||||||
s_over_count = 0;
|
s_over_count = 0;
|
||||||
s_window_start_us = 0;
|
s_window_start_us = 0;
|
||||||
|
s_zero_crossings = 0;
|
||||||
|
s_last_x_sign = 0;
|
||||||
|
s_last_y_sign = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void run_calibration(float ax, float ay, float az)
|
||||||
|
{
|
||||||
|
s_cal_buf_x[s_cal_head] = ax;
|
||||||
|
s_cal_buf_y[s_cal_head] = ay;
|
||||||
|
s_cal_buf_z[s_cal_head] = az;
|
||||||
|
s_cal_head = (s_cal_head + 1) % CALIBRATION_WINDOW_SAMPLES;
|
||||||
|
if (s_cal_count < CALIBRATION_WINDOW_SAMPLES) {
|
||||||
|
s_cal_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_cal_count < CALIBRATION_WINDOW_SAMPLES) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float sum_x = 0.0f;
|
||||||
|
float sum_y = 0.0f;
|
||||||
|
float sum_z = 0.0f;
|
||||||
|
float sum_sq_x = 0.0f;
|
||||||
|
float sum_sq_y = 0.0f;
|
||||||
|
float sum_sq_z = 0.0f;
|
||||||
|
|
||||||
|
for (int i = 0; i < CALIBRATION_WINDOW_SAMPLES; i++) {
|
||||||
|
sum_x += s_cal_buf_x[i];
|
||||||
|
sum_y += s_cal_buf_y[i];
|
||||||
|
sum_z += s_cal_buf_z[i];
|
||||||
|
sum_sq_x += s_cal_buf_x[i] * s_cal_buf_x[i];
|
||||||
|
sum_sq_y += s_cal_buf_y[i] * s_cal_buf_y[i];
|
||||||
|
sum_sq_z += s_cal_buf_z[i] * s_cal_buf_z[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
const int n = CALIBRATION_WINDOW_SAMPLES;
|
||||||
|
float var_x = (sum_sq_x / n) - (sum_x / n) * (sum_x / n);
|
||||||
|
float var_y = (sum_sq_y / n) - (sum_y / n) * (sum_y / n);
|
||||||
|
float var_z = (sum_sq_z / n) - (sum_z / n) * (sum_z / n);
|
||||||
|
float max_var = fmaxf(var_x, fmaxf(var_y, var_z));
|
||||||
|
|
||||||
|
if (max_var > CALIBRATION_MAX_VAR_G2) {
|
||||||
|
static int64_t s_last_cal_warn_us;
|
||||||
|
int64_t now_us = esp_timer_get_time();
|
||||||
|
if ((now_us - s_last_cal_warn_us) >= 1000 * 1000) {
|
||||||
|
s_last_cal_warn_us = now_us;
|
||||||
|
ESP_LOGW(TAG, "Calibration: motion detected (var=%.3f), waiting", max_var);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_ref_x = sum_x / n;
|
||||||
|
s_ref_y = sum_y / n;
|
||||||
|
s_ref_z = sum_z / n;
|
||||||
|
s_calibrated = true;
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Baseline calibrated (ref=%.3f,%.3f,%.3f g)", s_ref_x, s_ref_y, s_ref_z);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int axis_sign(float value)
|
||||||
|
{
|
||||||
|
if (value > 0.0f) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (value < 0.0f) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_sample(float ax, float ay, float az)
|
static void process_sample(float ax, float ay, float az)
|
||||||
@@ -108,6 +178,15 @@ static void process_sample(float ax, float ay, float az)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float dx = ax - s_ref_x;
|
||||||
|
float dy = ay - s_ref_y;
|
||||||
|
float dz = az - s_ref_z;
|
||||||
|
|
||||||
|
/* Use only horizontal magnitude for shake detection. Z-axis is dominated by
|
||||||
|
* gravity and is the main axis for pick-up/put-down false triggers. */
|
||||||
|
float horizontal_mag = sqrtf(dx * dx + dy * dy);
|
||||||
|
s_last_horizontal_mag = horizontal_mag;
|
||||||
|
|
||||||
if (s_state == GESTURE_COOLDOWN) {
|
if (s_state == GESTURE_COOLDOWN) {
|
||||||
if (now_us >= s_cooldown_until_us) {
|
if (now_us >= s_cooldown_until_us) {
|
||||||
s_state = GESTURE_IDLE;
|
s_state = GESTURE_IDLE;
|
||||||
@@ -116,24 +195,34 @@ static void process_sample(float ax, float ay, float az)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float dx = ax - s_ref_x;
|
if (horizontal_mag > s_threshold) {
|
||||||
float dy = ay - s_ref_y;
|
|
||||||
float dz = az - s_ref_z;
|
|
||||||
float mag = magnitude(dx, dy, dz);
|
|
||||||
|
|
||||||
if (mag > s_threshold) {
|
|
||||||
if (s_over_count == 0) {
|
if (s_over_count == 0) {
|
||||||
s_window_start_us = now_us;
|
s_window_start_us = now_us;
|
||||||
}
|
}
|
||||||
s_over_count++;
|
s_over_count++;
|
||||||
|
|
||||||
|
int x_sign = axis_sign(dx);
|
||||||
|
int y_sign = axis_sign(dy);
|
||||||
|
if (s_last_x_sign != 0 && x_sign != s_last_x_sign) {
|
||||||
|
s_zero_crossings++;
|
||||||
|
}
|
||||||
|
if (s_last_y_sign != 0 && y_sign != s_last_y_sign) {
|
||||||
|
s_zero_crossings++;
|
||||||
|
}
|
||||||
|
s_last_x_sign = x_sign;
|
||||||
|
s_last_y_sign = y_sign;
|
||||||
|
|
||||||
int64_t window_us = (int64_t)WINDOW_MS * 1000;
|
int64_t window_us = (int64_t)WINDOW_MS * 1000;
|
||||||
if ((now_us - s_window_start_us) > window_us) {
|
if ((now_us - s_window_start_us) > window_us) {
|
||||||
s_over_count = 1;
|
/* Window expired: start fresh with the current sample. */
|
||||||
|
reset_window();
|
||||||
s_window_start_us = now_us;
|
s_window_start_us = now_us;
|
||||||
|
s_over_count = 1;
|
||||||
|
s_last_x_sign = axis_sign(dx);
|
||||||
|
s_last_y_sign = axis_sign(dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_over_count >= MIN_SAMPLES) {
|
if (s_over_count >= MIN_SAMPLES && s_zero_crossings >= MIN_ZERO_CROSSINGS) {
|
||||||
if (s_enabled) {
|
if (s_enabled) {
|
||||||
post_nav_next();
|
post_nav_next();
|
||||||
}
|
}
|
||||||
@@ -147,6 +236,8 @@ static void process_sample(float ax, float ay, float az)
|
|||||||
reset_window();
|
reset_window();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void)dz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void motion_gesture_init(motion_nav_cb_t cb)
|
void motion_gesture_init(motion_nav_cb_t cb)
|
||||||
@@ -156,7 +247,10 @@ void motion_gesture_init(motion_nav_cb_t cb)
|
|||||||
s_nav_queue = xQueueCreate(4, sizeof(motion_nav_event_t));
|
s_nav_queue = xQueueCreate(4, sizeof(motion_nav_event_t));
|
||||||
xTaskCreate(nav_handler_task, "nav_handler", 2048, NULL, 5, NULL);
|
xTaskCreate(nav_handler_task, "nav_handler", 2048, NULL, 5, NULL);
|
||||||
|
|
||||||
s_cal_start_us = esp_timer_get_time();
|
s_calibrated = false;
|
||||||
|
s_cal_head = 0;
|
||||||
|
s_cal_count = 0;
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Motion gesture ready (calibrating %d ms)", CALIBRATION_MS);
|
ESP_LOGI(TAG, "Motion gesture ready (calibrating %d ms)", CALIBRATION_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +273,7 @@ void motion_gesture_set_sensitivity(shake_sensitivity_t sens)
|
|||||||
s_threshold = THRESHOLD_HIGH_G;
|
s_threshold = THRESHOLD_HIGH_G;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LV_ASSERT_MSG(false, "unexpected shake_sensitivity_t");
|
assert(false && "unexpected shake_sensitivity_t");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "Sensitivity set (threshold=%.2f g)", s_threshold);
|
ESP_LOGI(TAG, "Sensitivity set (threshold=%.2f g)", s_threshold);
|
||||||
@@ -189,3 +283,13 @@ void motion_gesture_on_sample(float ax_g, float ay_g, float az_g)
|
|||||||
{
|
{
|
||||||
process_sample(ax_g, ay_g, az_g);
|
process_sample(ax_g, ay_g, az_g);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float motion_gesture_get_last_magnitude(void)
|
||||||
|
{
|
||||||
|
return s_last_horizontal_mag;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool motion_gesture_is_calibrated(void)
|
||||||
|
{
|
||||||
|
return s_calibrated;
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,3 +14,6 @@ void motion_gesture_init(motion_nav_cb_t cb);
|
|||||||
void motion_gesture_set_enabled(bool enabled);
|
void motion_gesture_set_enabled(bool enabled);
|
||||||
void motion_gesture_set_sensitivity(shake_sensitivity_t sens);
|
void motion_gesture_set_sensitivity(shake_sensitivity_t sens);
|
||||||
void motion_gesture_on_sample(float ax_g, float ay_g, float az_g);
|
void motion_gesture_on_sample(float ax_g, float ay_g, float az_g);
|
||||||
|
|
||||||
|
float motion_gesture_get_last_magnitude(void);
|
||||||
|
bool motion_gesture_is_calibrated(void);
|
||||||
|
|||||||
+1
-4
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "board_config.h"
|
#include "board_config.h"
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
|
||||||
#include "driver/ledc.h"
|
#include "driver/ledc.h"
|
||||||
#include "driver/spi_master.h"
|
#include "driver/spi_master.h"
|
||||||
#include "esp_lcd_panel_ops.h"
|
#include "esp_lcd_panel_ops.h"
|
||||||
@@ -49,6 +48,7 @@ esp_err_t display_init(esp_lcd_panel_io_handle_t *io_handle_out,
|
|||||||
.gpio_num = BOARD_PIN_BK_LIGHT,
|
.gpio_num = BOARD_PIN_BK_LIGHT,
|
||||||
.duty = 0,
|
.duty = 0,
|
||||||
.hpoint = 0,
|
.hpoint = 0,
|
||||||
|
.flags.output_invert = 1,
|
||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel));
|
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel));
|
||||||
|
|
||||||
@@ -90,9 +90,6 @@ esp_err_t display_init(esp_lcd_panel_io_handle_t *io_handle_out,
|
|||||||
ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, BOARD_LCD_GAP_X, BOARD_LCD_GAP_Y));
|
ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, BOARD_LCD_GAP_X, BOARD_LCD_GAP_Y));
|
||||||
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
|
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Turn on LCD backlight");
|
|
||||||
gpio_set_level(BOARD_PIN_BK_LIGHT, BOARD_LCD_BK_LIGHT_ON_LEVEL);
|
|
||||||
|
|
||||||
*io_handle_out = io_handle;
|
*io_handle_out = io_handle;
|
||||||
*panel_handle_out = panel_handle;
|
*panel_handle_out = panel_handle;
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// Project name: HeavenlyHeroStar
|
// Project name: HeavenlyHeroStar
|
||||||
|
|
||||||
#include "../ui.h"
|
#include "../ui.h"
|
||||||
|
#include "board_config.h"
|
||||||
|
|
||||||
lv_obj_t * uic_Calendar1;
|
lv_obj_t * uic_Calendar1;
|
||||||
lv_obj_t * ui_Screen1 = NULL;
|
lv_obj_t * ui_Screen1 = NULL;
|
||||||
@@ -15,12 +16,13 @@ lv_obj_t * ui_Calendar1 = NULL;
|
|||||||
void ui_Screen1_screen_init(void)
|
void ui_Screen1_screen_init(void)
|
||||||
{
|
{
|
||||||
ui_Screen1 = lv_obj_create(NULL);
|
ui_Screen1 = lv_obj_create(NULL);
|
||||||
|
lv_obj_set_size(ui_Screen1, BOARD_LCD_LOGIC_H_RES, BOARD_LCD_LOGIC_V_RES);
|
||||||
lv_obj_remove_flag(ui_Screen1, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
lv_obj_remove_flag(ui_Screen1, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
||||||
|
|
||||||
ui_Calendar1 = lv_calendar_create(ui_Screen1);
|
ui_Calendar1 = lv_calendar_create(ui_Screen1);
|
||||||
lv_obj_t * ui_Calendar1_header = lv_calendar_header_arrow_create(ui_Calendar1);
|
lv_obj_t * ui_Calendar1_header = lv_calendar_header_arrow_create(ui_Calendar1);
|
||||||
lv_obj_set_width(ui_Calendar1, 170);
|
lv_obj_set_width(ui_Calendar1, BOARD_LCD_LOGIC_H_RES);
|
||||||
lv_obj_set_height(ui_Calendar1, 320);
|
lv_obj_set_height(ui_Calendar1, BOARD_LCD_LOGIC_V_RES);
|
||||||
lv_obj_set_align(ui_Calendar1, LV_ALIGN_CENTER);
|
lv_obj_set_align(ui_Calendar1, LV_ALIGN_CENTER);
|
||||||
|
|
||||||
uic_Calendar1 = ui_Calendar1;
|
uic_Calendar1 = ui_Calendar1;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// Project name: HeavenlyHeroStar
|
// Project name: HeavenlyHeroStar
|
||||||
|
|
||||||
#include "../ui.h"
|
#include "../ui.h"
|
||||||
|
#include "board_config.h"
|
||||||
|
|
||||||
lv_obj_t * ui_Screen2 = NULL;
|
lv_obj_t * ui_Screen2 = NULL;
|
||||||
lv_obj_t * ui_Button1 = NULL;
|
lv_obj_t * ui_Button1 = NULL;
|
||||||
@@ -45,11 +46,14 @@ void ui_event_Button3(lv_event_t * e)
|
|||||||
void ui_Screen2_screen_init(void)
|
void ui_Screen2_screen_init(void)
|
||||||
{
|
{
|
||||||
ui_Screen2 = lv_obj_create(NULL);
|
ui_Screen2 = lv_obj_create(NULL);
|
||||||
|
lv_obj_set_size(ui_Screen2, BOARD_LCD_LOGIC_H_RES, BOARD_LCD_LOGIC_V_RES);
|
||||||
lv_obj_remove_flag(ui_Screen2, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
lv_obj_remove_flag(ui_Screen2, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
||||||
|
|
||||||
ui_Button1 = lv_button_create(ui_Screen2);
|
ui_Button1 = lv_button_create(ui_Screen2);
|
||||||
lv_obj_set_width(ui_Button1, 100);
|
lv_obj_set_width(ui_Button1, 100);
|
||||||
lv_obj_set_height(ui_Button1, 80);
|
lv_obj_set_height(ui_Button1, 80);
|
||||||
|
lv_obj_set_x(ui_Button1, -100);
|
||||||
|
lv_obj_set_y(ui_Button1, 0);
|
||||||
lv_obj_set_align(ui_Button1, LV_ALIGN_CENTER);
|
lv_obj_set_align(ui_Button1, LV_ALIGN_CENTER);
|
||||||
lv_obj_add_flag(ui_Button1, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags
|
lv_obj_add_flag(ui_Button1, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags
|
||||||
lv_obj_remove_flag(ui_Button1, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
lv_obj_remove_flag(ui_Button1, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
||||||
@@ -58,7 +62,7 @@ void ui_Screen2_screen_init(void)
|
|||||||
lv_obj_set_width(ui_Button2, 100);
|
lv_obj_set_width(ui_Button2, 100);
|
||||||
lv_obj_set_height(ui_Button2, 80);
|
lv_obj_set_height(ui_Button2, 80);
|
||||||
lv_obj_set_x(ui_Button2, 0);
|
lv_obj_set_x(ui_Button2, 0);
|
||||||
lv_obj_set_y(ui_Button2, 100);
|
lv_obj_set_y(ui_Button2, 0);
|
||||||
lv_obj_set_align(ui_Button2, LV_ALIGN_CENTER);
|
lv_obj_set_align(ui_Button2, LV_ALIGN_CENTER);
|
||||||
lv_obj_add_flag(ui_Button2, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags
|
lv_obj_add_flag(ui_Button2, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags
|
||||||
lv_obj_remove_flag(ui_Button2, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
lv_obj_remove_flag(ui_Button2, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
||||||
@@ -66,8 +70,8 @@ void ui_Screen2_screen_init(void)
|
|||||||
ui_Button3 = lv_button_create(ui_Screen2);
|
ui_Button3 = lv_button_create(ui_Screen2);
|
||||||
lv_obj_set_width(ui_Button3, 100);
|
lv_obj_set_width(ui_Button3, 100);
|
||||||
lv_obj_set_height(ui_Button3, 80);
|
lv_obj_set_height(ui_Button3, 80);
|
||||||
lv_obj_set_x(ui_Button3, 0);
|
lv_obj_set_x(ui_Button3, 100);
|
||||||
lv_obj_set_y(ui_Button3, -100);
|
lv_obj_set_y(ui_Button3, 0);
|
||||||
lv_obj_set_align(ui_Button3, LV_ALIGN_CENTER);
|
lv_obj_set_align(ui_Button3, LV_ALIGN_CENTER);
|
||||||
lv_obj_add_flag(ui_Button3, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags
|
lv_obj_add_flag(ui_Button3, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /// Flags
|
||||||
lv_obj_remove_flag(ui_Button3, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
lv_obj_remove_flag(ui_Button3, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
||||||
@@ -75,6 +79,8 @@ void ui_Screen2_screen_init(void)
|
|||||||
ui_Label2 = lv_label_create(ui_Screen2);
|
ui_Label2 = lv_label_create(ui_Screen2);
|
||||||
lv_obj_set_width(ui_Label2, LV_SIZE_CONTENT); /// 1
|
lv_obj_set_width(ui_Label2, LV_SIZE_CONTENT); /// 1
|
||||||
lv_obj_set_height(ui_Label2, LV_SIZE_CONTENT); /// 1
|
lv_obj_set_height(ui_Label2, LV_SIZE_CONTENT); /// 1
|
||||||
|
lv_obj_set_x(ui_Label2, -100);
|
||||||
|
lv_obj_set_y(ui_Label2, 0);
|
||||||
lv_obj_set_align(ui_Label2, LV_ALIGN_CENTER);
|
lv_obj_set_align(ui_Label2, LV_ALIGN_CENTER);
|
||||||
lv_label_set_text(ui_Label2, "Ctrl+C");
|
lv_label_set_text(ui_Label2, "Ctrl+C");
|
||||||
|
|
||||||
@@ -82,15 +88,15 @@ void ui_Screen2_screen_init(void)
|
|||||||
lv_obj_set_width(ui_Label4, LV_SIZE_CONTENT); /// 1
|
lv_obj_set_width(ui_Label4, LV_SIZE_CONTENT); /// 1
|
||||||
lv_obj_set_height(ui_Label4, LV_SIZE_CONTENT); /// 1
|
lv_obj_set_height(ui_Label4, LV_SIZE_CONTENT); /// 1
|
||||||
lv_obj_set_x(ui_Label4, 0);
|
lv_obj_set_x(ui_Label4, 0);
|
||||||
lv_obj_set_y(ui_Label4, 100);
|
lv_obj_set_y(ui_Label4, 0);
|
||||||
lv_obj_set_align(ui_Label4, LV_ALIGN_CENTER);
|
lv_obj_set_align(ui_Label4, LV_ALIGN_CENTER);
|
||||||
lv_label_set_text(ui_Label4, "Ctrl+V");
|
lv_label_set_text(ui_Label4, "Ctrl+V");
|
||||||
|
|
||||||
ui_Label5 = lv_label_create(ui_Screen2);
|
ui_Label5 = lv_label_create(ui_Screen2);
|
||||||
lv_obj_set_width(ui_Label5, LV_SIZE_CONTENT); /// 1
|
lv_obj_set_width(ui_Label5, LV_SIZE_CONTENT); /// 1
|
||||||
lv_obj_set_height(ui_Label5, LV_SIZE_CONTENT); /// 1
|
lv_obj_set_height(ui_Label5, LV_SIZE_CONTENT); /// 1
|
||||||
lv_obj_set_x(ui_Label5, 0);
|
lv_obj_set_x(ui_Label5, 100);
|
||||||
lv_obj_set_y(ui_Label5, -100);
|
lv_obj_set_y(ui_Label5, 0);
|
||||||
lv_obj_set_align(ui_Label5, LV_ALIGN_CENTER);
|
lv_obj_set_align(ui_Label5, LV_ALIGN_CENTER);
|
||||||
lv_label_set_text(ui_Label5, "Ctrl+X");
|
lv_label_set_text(ui_Label5, "Ctrl+X");
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// Project name: HeavenlyHeroStar
|
// Project name: HeavenlyHeroStar
|
||||||
|
|
||||||
#include "../ui.h"
|
#include "../ui.h"
|
||||||
|
#include "board_config.h"
|
||||||
|
|
||||||
lv_obj_t * ui_Screen3 = NULL;
|
lv_obj_t * ui_Screen3 = NULL;
|
||||||
lv_obj_t * ui_BtnVolDown = NULL;
|
lv_obj_t * ui_BtnVolDown = NULL;
|
||||||
@@ -23,8 +24,8 @@ static void ui_screen3_create_button(lv_obj_t **btn, lv_obj_t **label, int32_t x
|
|||||||
const char *text)
|
const char *text)
|
||||||
{
|
{
|
||||||
*btn = lv_button_create(ui_Screen3);
|
*btn = lv_button_create(ui_Screen3);
|
||||||
lv_obj_set_width(*btn, 75);
|
lv_obj_set_width(*btn, 90);
|
||||||
lv_obj_set_height(*btn, 90);
|
lv_obj_set_height(*btn, 45);
|
||||||
lv_obj_set_x(*btn, x);
|
lv_obj_set_x(*btn, x);
|
||||||
lv_obj_set_y(*btn, y);
|
lv_obj_set_y(*btn, y);
|
||||||
lv_obj_set_align(*btn, LV_ALIGN_CENTER);
|
lv_obj_set_align(*btn, LV_ALIGN_CENTER);
|
||||||
@@ -100,14 +101,15 @@ void ui_event_BtnNext(lv_event_t * e)
|
|||||||
void ui_Screen3_screen_init(void)
|
void ui_Screen3_screen_init(void)
|
||||||
{
|
{
|
||||||
ui_Screen3 = lv_obj_create(NULL);
|
ui_Screen3 = lv_obj_create(NULL);
|
||||||
|
lv_obj_set_size(ui_Screen3, BOARD_LCD_LOGIC_H_RES, BOARD_LCD_LOGIC_V_RES);
|
||||||
lv_obj_remove_flag(ui_Screen3, LV_OBJ_FLAG_SCROLLABLE);
|
lv_obj_remove_flag(ui_Screen3, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
|
|
||||||
ui_screen3_create_button(&ui_BtnVolDown, &ui_LabelVolDown, -42, -107, "Vol-");
|
ui_screen3_create_button(&ui_BtnVolDown, &ui_LabelVolDown, -50, -55, "Vol-");
|
||||||
ui_screen3_create_button(&ui_BtnVolUp, &ui_LabelVolUp, 42, -107, "Vol+");
|
ui_screen3_create_button(&ui_BtnVolUp, &ui_LabelVolUp, 50, -55, "Vol+");
|
||||||
ui_screen3_create_button(&ui_BtnMute, &ui_LabelMute, -42, 0, "Mute");
|
ui_screen3_create_button(&ui_BtnMute, &ui_LabelMute, -50, 0, "Mute");
|
||||||
ui_screen3_create_button(&ui_BtnPlayPause, &ui_LabelPlayPause, 42, 0, "Play");
|
ui_screen3_create_button(&ui_BtnPlayPause, &ui_LabelPlayPause, 50, 0, "Play");
|
||||||
ui_screen3_create_button(&ui_BtnPrev, &ui_LabelPrev, -42, 107, "Prev");
|
ui_screen3_create_button(&ui_BtnPrev, &ui_LabelPrev, -50, 55, "Prev");
|
||||||
ui_screen3_create_button(&ui_BtnNext, &ui_LabelNext, 42, 107, "Next");
|
ui_screen3_create_button(&ui_BtnNext, &ui_LabelNext, 50, 55, "Next");
|
||||||
|
|
||||||
lv_obj_add_event_cb(ui_BtnVolDown, ui_event_BtnVolDown, LV_EVENT_ALL, NULL);
|
lv_obj_add_event_cb(ui_BtnVolDown, ui_event_BtnVolDown, LV_EVENT_ALL, NULL);
|
||||||
lv_obj_add_event_cb(ui_BtnVolUp, ui_event_BtnVolUp, LV_EVENT_ALL, NULL);
|
lv_obj_add_event_cb(ui_BtnVolUp, ui_event_BtnVolUp, LV_EVENT_ALL, NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user