|
|
@ -49,7 +49,7 @@ static int32_t m_last_usr_operation_time = 0; |
|
|
|
void on_zapp_ebus_event(void* p_event_data, uint16_t event_size); |
|
|
|
|
|
|
|
/*********************************************************************************************************************** |
|
|
|
* 钃濈墮杩炴帴浜嬩欢鏋勯€� * |
|
|
|
* 蓝牙连接事件构造 * |
|
|
|
***********************************************************************************************************************/ |
|
|
|
void on_zble_event(zble_event_t* event) { |
|
|
|
static app_event_t appevent; |
|
|
@ -63,7 +63,7 @@ void on_zble_event(zble_event_t* event) { |
|
|
|
} |
|
|
|
} |
|
|
|
/*********************************************************************************************************************** |
|
|
|
* 钃濈墮娑堟伅澶勭悊 * |
|
|
|
* 蓝牙消息处理 * |
|
|
|
***********************************************************************************************************************/ |
|
|
|
void one_conduction_process_rx_packet(uint8_t* rx, int len) { |
|
|
|
hand_acid_ble_proto_t* rxheader = (hand_acid_ble_proto_t*)rx; |
|
|
@ -132,7 +132,7 @@ void one_conduction_process_rx_packet(uint8_t* rx, int len) { |
|
|
|
} |
|
|
|
|
|
|
|
/*********************************************************************************************************************** |
|
|
|
* 浜嬩欢澶勭悊 * |
|
|
|
* 事件处理 * |
|
|
|
***********************************************************************************************************************/ |
|
|
|
|
|
|
|
static void nrf_gpio_set_rgb(uint8_t r, uint8_t g, uint8_t b) { |
|
|
@ -144,25 +144,25 @@ static void nrf_gpio_set_rgb(uint8_t r, uint8_t g, uint8_t b) { |
|
|
|
static void update_light_state() { |
|
|
|
/** |
|
|
|
* @brief |
|
|
|
* 鍏虫満:鐏�唲鐏� |
|
|
|
* 寮€鏈�: |
|
|
|
* 鐐瑰姩妯″紡:钃濈伅 |
|
|
|
* 鎵嬪姩妯″紡:缁跨伅 |
|
|
|
* 绂荤嚎 :绾㈢伅 |
|
|
|
* 关机:灯熄灭 |
|
|
|
* 开机: |
|
|
|
* 点动模式:蓝灯 |
|
|
|
* 手动模式:绿灯 |
|
|
|
* 离线 :红灯 |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
if (zapp_state_machine_now_state() == kstate_standby) { |
|
|
|
// 寰呮満妯″紡 |
|
|
|
// 待机模式 |
|
|
|
nrf_gpio_set_rgb(0, 0, 0); |
|
|
|
} else { |
|
|
|
if (g_connected) { // 杩炴帴鐘舵€� |
|
|
|
if (g_connected) { // 连接状态 |
|
|
|
if (g_hand_acid_mode == khand_acid_m_jog_mode) { |
|
|
|
nrf_gpio_set_rgb(0, 0, 1); // 鐐瑰姩妯″紡 |
|
|
|
nrf_gpio_set_rgb(0, 0, 1); // 点动模式 |
|
|
|
} else if (g_hand_acid_mode == khand_acid_m_continuous_mode) { |
|
|
|
nrf_gpio_set_rgb(0, 1, 0); // 鎵嬪姩妯″紡 |
|
|
|
nrf_gpio_set_rgb(0, 1, 0); // 手动模式 |
|
|
|
} else if (g_hand_acid_mode == khand_acid_m_unset_mode) { |
|
|
|
nrf_gpio_set_rgb(1, 1, 1); // 鐘舵€佹湭鍚屾� |
|
|
|
nrf_gpio_set_rgb(1, 1, 1); // 状态未同步 |
|
|
|
} |
|
|
|
} else { |
|
|
|
nrf_gpio_set_rgb(1, 0, 0); |
|
|
@ -266,9 +266,9 @@ void on_zapp_ebus_event(void* p_event_data, uint16_t event_size) { |
|
|
|
} |
|
|
|
|
|
|
|
/*********************************************************************************************************************** |
|
|
|
* 鎸夐敭鐩戝惉 * |
|
|
|
* 按键监听 * |
|
|
|
***********************************************************************************************************************/ |
|
|
|
APP_TIMER_DEF(m_key_monitor_tmr); // 鐘舵€佹満椹卞姩瀹氭椂鍣� |
|
|
|
APP_TIMER_DEF(m_key_monitor_tmr); // 状态机驱动定时器 |
|
|
|
bool key_read_acid_state() { |
|
|
|
uint32_t val = nrf_gpio_pin_read(ADD_ACID_KEY); |
|
|
|
if (val == 0) { |
|
|
@ -298,21 +298,21 @@ typedef struct { |
|
|
|
|
|
|
|
static void process_key(key_t* key) { |
|
|
|
static app_event_t event; |
|
|
|
bool nowState = key->read_key_state(); // 瑙﹀彂鎸夐敭 |
|
|
|
bool nowState = key->read_key_state(); // 触发按键 |
|
|
|
|
|
|
|
if (nowState != key->keystate) { |
|
|
|
// 鎸変笅浜嬩欢 |
|
|
|
// 按下事件 |
|
|
|
m_last_usr_operation_time = znordic_getpower_on_ms(); |
|
|
|
if (nowState) { |
|
|
|
key->longPress = false; |
|
|
|
key->pressing = true; |
|
|
|
key->pressTicket = znordic_getpower_on_ms(); |
|
|
|
} |
|
|
|
// 鎸夐敭鏉惧紑浜嬩欢 |
|
|
|
// 按键松开事件 |
|
|
|
if (!nowState) { |
|
|
|
if (!key->longPress) { |
|
|
|
event.eventType = kappevent_key_pressed; |
|
|
|
event.val.keyid = key->keid; // 瑙﹀彂鎸夐敭 |
|
|
|
event.val.keyid = key->keid; // 触发按键 |
|
|
|
zapp_ebus_push_event(&event); |
|
|
|
} |
|
|
|
key->pressing = false; |
|
|
@ -323,7 +323,7 @@ static void process_key(key_t* key) { |
|
|
|
if (znordic_haspassed_ms(key->pressTicket) > m_longpress_trigger_time) { |
|
|
|
key->longPress = true; |
|
|
|
event.eventType = kappevent_key_long_pressed; |
|
|
|
event.val.keyid = key->keid; // 瑙﹀彂鎸夐敭 |
|
|
|
event.val.keyid = key->keid; // 触发按键 |
|
|
|
zapp_ebus_push_event(&event); |
|
|
|
} |
|
|
|
} |
|
|
@ -346,7 +346,7 @@ static void state_machine_driver_tmr_cb(void* p_context) { // |
|
|
|
} |
|
|
|
|
|
|
|
/*********************************************************************************************************************** |
|
|
|
* 鎸夐敭鐩戝惉缁撴潫 * |
|
|
|
* 按键监听结束 * |
|
|
|
***********************************************************************************************************************/ |
|
|
|
|
|
|
|
static void board_init() { |
|
|
|