WT_0_S2_240MW1
加载对应开发板型号
Linux环境下
bash load.sh
1): WT32_SC01
2): WT154_C3SI1
3): WT154_S2MI1
4): WT_86_32_3ZW1
5): WT280_S2MX1
6): WT240_C3SI1
7): WT_0_S2_240MW1
8): ZX3D50CE02S_USRC_4832
9): ZX3D95CE01S_AR_4848
10): ZX3D95CE01S_UR_4848
11): ZX4D30NE01S_UR_4827
12): ZX4D60_AR_4896
13): ZX2D10GE01R_V_4848
14): ZX7D00CE01S_UR_8048
7
Set to 7-WT_0_S2_240MW1
--- sdkconfig done
Done
Windows环境下
直接双击load_windowns.bat,选择对应的开发板机型
编译测试DEMO
cd examples/demo_knob_240
idf.py build
idf.py flash
说明
如下代码实现了按钮和旋钮的事件检测,并通过qmsd_notifier_call发送相关事件,最终会调用到__qmsd_got_encoder_func函数用于处理这些事件。
mt8901_init(16, 17);
qmsd_button_config_t config = {
.ticks_interval_ms = 10,
.debounce_ticks = 2,
.short_ticks = 200 / 10,
.long_ticks = 1000 / 10,
.update_task = {
.en = 1,
.core = 1,
.priority = 1,
}};
qmsd_button_init(&config);
btn_handle_t *btn0 = qmsd_button_create_gpio(7, 1, NULL);
qmsd_button_start(btn0);
for (;;)
{
static int16_t cont_last = 0;
int16_t cont_now = mt8901_get_count();
int16_t enc_diff = ECO_STEP(cont_now - cont_last);
cont_last = cont_now;
if (enc_diff == 1)
{
// 右转
qmsd_notifier_call(ENCODER_RIGHT,NULL);
}
else if(enc_diff == -1)
{
// 左转
qmsd_notifier_call(ENCODER_LEFT,NULL);
}
else
{
qmsd_notifier_call(ENCODER_NONE,NULL);
}
if (qmsd_button_wait_event(btn0, BUTTON_SINGLE_CLICK, pdMS_TO_TICKS(0)))
{
// 短按
qmsd_notifier_call(ENCODER_SHORT_CLICK,NULL);
}
if (qmsd_button_wait_event(btn0, BUTTON_LONG_PRESS_START, pdMS_TO_TICKS(0)))
{
// 长按
qmsd_notifier_call(ENCODER_LONG_CLICK,NULL);
}
vTaskDelay(pdMS_TO_TICKS(20));
}