up
修复 显示问题
This commit is contained in:
Binary file not shown.
@@ -4,10 +4,11 @@ file(GLOB_RECURSE SRC_LIST "*.c")
|
||||
|
||||
idf_component_register(
|
||||
SRCS ${SRC_LIST}
|
||||
PRIV_REQUIRES spi_flash esp_driver_spi esp_driver_gpio esp_timer
|
||||
PRIV_REQUIRES spi_flash esp_timer
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES
|
||||
spiffs
|
||||
driver
|
||||
PRIV_REQUIRES
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "e11.h"
|
||||
|
||||
static const char *TAG = "E11";
|
||||
|
||||
// ==================== 全局变量 ====================
|
||||
// static QueueHandle_t pcnt_evt_queue = NULL; // PCNT事件队列
|
||||
// static QueueHandle_t gpio_evt_queue = NULL; // GPIO事件队列
|
||||
|
||||
static encoder_state_t encoder = {0};
|
||||
|
||||
void e11_loop(){
|
||||
|
||||
}
|
||||
|
||||
void e11_init()
|
||||
{
|
||||
// 配置GPIO
|
||||
gpio_config_t io_conf = {
|
||||
.pin_bit_mask = (1ULL << EC11_A_PIN) | (1ULL << EC11_B_PIN) | (1ULL << EC11_SW_PIN), // LCD_DS LCD_CS
|
||||
.mode = GPIO_MODE_INPUT, // 输出模式
|
||||
.pull_up_en = GPIO_PULLUP_ENABLE, //
|
||||
.pull_down_en = GPIO_PULLDOWN_DISABLE, //
|
||||
.intr_type = GPIO_INTR_DISABLE // 禁用中断
|
||||
};
|
||||
|
||||
// 应用配置
|
||||
gpio_config(&io_conf);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef E11_H
|
||||
#define E11_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "driver/pcnt.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
|
||||
#define EC11_A_PIN GPIO_NUM_18 // 相位A (CLK)
|
||||
#define EC11_B_PIN GPIO_NUM_19 // 相位B (DT)
|
||||
#define EC11_SW_PIN GPIO_NUM_9 // 按键引脚
|
||||
|
||||
|
||||
#define PCNT_UNIT PCNT_UNIT_0 // 使用PCNT单元0
|
||||
#define PCNT_CHANNEL PCNT_CHANNEL_0 // 使用通道0
|
||||
#define PCNT_H_LIMIT 10000 // 计数上限
|
||||
#define PCNT_L_LIMIT -10000 // 计数下限
|
||||
|
||||
// 滤波参数(消除抖动)
|
||||
#define PCNT_FILTER_VAL 1023 // 最大滤波值(约102us)
|
||||
|
||||
|
||||
|
||||
// PCNT事件结构体
|
||||
typedef struct {
|
||||
int unit; // PCNT单元号
|
||||
uint32_t status; // 状态寄存器值
|
||||
int64_t timestamp; // 时间戳
|
||||
} pcnt_evt_t;
|
||||
|
||||
// GPIO事件结构体
|
||||
typedef struct {
|
||||
uint32_t gpio_num; // GPIO引脚号
|
||||
uint32_t level; // 电平状态
|
||||
int64_t timestamp; // 时间戳
|
||||
} gpio_evt_t;
|
||||
|
||||
// 编码器状态结构体
|
||||
typedef struct {
|
||||
int32_t count; // 当前计数值
|
||||
int32_t delta; // 上次变化量
|
||||
bool direction; // 旋转方向: true=CW, false=CCW
|
||||
bool button_state; // 按键状态: true=按下, false=释放
|
||||
} encoder_state_t;
|
||||
|
||||
|
||||
|
||||
void e11_init();
|
||||
void e11_loop();
|
||||
|
||||
#endif
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "esp_system.h"
|
||||
#include "esp_spiffs.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_timer.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/unistd.h>
|
||||
@@ -25,24 +26,15 @@
|
||||
#include <time.h> // 时间相关函数
|
||||
|
||||
#include "spiffs.h"
|
||||
|
||||
#include "spi.h"
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
#include "esp_timer.h"
|
||||
|
||||
#include "e11.h"
|
||||
|
||||
#include "lv_conf.h"
|
||||
|
||||
/* 然后包含 lvgl.h */
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
#include "lv_port_disp.h"
|
||||
#include "lv_port_fs.h"
|
||||
|
||||
#include "lv_log_to_esp.h"
|
||||
|
||||
#include "lv_apps/helloworld/lv_helloworld.h"
|
||||
|
||||
static const char *TAG = "SYS";
|
||||
@@ -133,6 +125,8 @@ void app_main(void)
|
||||
list_spiffs_files_safe(spiffs_base_path);
|
||||
}
|
||||
|
||||
e11_init();
|
||||
|
||||
spi_init();
|
||||
lcd_init();
|
||||
|
||||
@@ -145,6 +139,8 @@ void app_main(void)
|
||||
|
||||
lv_example_get_started_1();
|
||||
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user