|
|
@ -31,7 +31,7 @@ static const char* zhex2str(uint8_t* data, size_t len) { |
|
|
|
return buf; |
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::initialize() { //
|
|
|
|
void UI::initialize() { //
|
|
|
|
ackQueue.initialize(5, sizeof(tjc_rx_packet_t)); |
|
|
|
eventQueue.initialize(5, sizeof(tjc_rx_packet_t)); |
|
|
|
usartRxThread.init("usartRxThread", 1024); |
|
|
@ -41,7 +41,7 @@ void FrontEndControler::initialize() { // |
|
|
|
m_cmdlock.init(); |
|
|
|
} |
|
|
|
#define UART_RX_OVERTIME 5
|
|
|
|
void FrontEndControler::startSchedule() { |
|
|
|
void UI::startSchedule() { |
|
|
|
usartRxThread.start([this]() { |
|
|
|
static uint8_t rxbuf[128]; |
|
|
|
tjcUart->USR_UartITRxing = 1; |
|
|
@ -116,7 +116,7 @@ void FrontEndControler::startSchedule() { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::processScreenRxPacket(uint8_t* data, size_t len) { |
|
|
|
void UI::processScreenRxPacket(uint8_t* data, size_t len) { |
|
|
|
// 判断包是否合法
|
|
|
|
#if MODULE_DEBUG
|
|
|
|
ZLOGI(TAG, "[rx-thread] : rx :%s(%d)", zhex2str(data, len), len); |
|
|
@ -153,11 +153,6 @@ void FrontEndControler::processScreenRxPacket(uint8_t* data, size_t len) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::regOnUsrEventCb(on_usr_event_cb_t cb) { |
|
|
|
m_cb[m_ncb] = cb; |
|
|
|
m_ncb++; |
|
|
|
} |
|
|
|
|
|
|
|
static const char* zcpystr(char* cpyto, const char* strbegin, int32_t maxlen) { |
|
|
|
if (strbegin == NULL) return NULL; |
|
|
|
int32_t i = 0; |
|
|
@ -169,7 +164,7 @@ static const char* zcpystr(char* cpyto, const char* strbegin, int32_t maxlen) { |
|
|
|
} |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
void FrontEndControler::processUsrButtonEvent(uint8_t* data, size_t len) { |
|
|
|
void UI::processUsrButtonEvent(uint8_t* data, size_t len) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* 指令格式: |
|
|
@ -189,18 +184,9 @@ void FrontEndControler::processUsrButtonEvent(uint8_t* data, size_t len) { |
|
|
|
event_cache.pid = data[1]; |
|
|
|
event_cache.bid = data[2]; |
|
|
|
|
|
|
|
if (event_cache.pid == pg_confirm && event_cache.bid == ob_confirm_confirm) { |
|
|
|
if (m_onConfirmPageConfirmKey) m_onConfirmPageConfirmKey(true); |
|
|
|
m_onConfirmPageConfirmKey = nullptr; |
|
|
|
} else if (event_cache.pid == pg_confirm && event_cache.bid == ob_confirm_canclekey) { |
|
|
|
if (m_onAlertPageConfirmKey) m_onAlertPageConfirmKey(false); |
|
|
|
m_onAlertPageConfirmKey = nullptr; |
|
|
|
} else if (event_cache.pid == pg_alert && event_cache.bid == ob_alert_confirmkey) { |
|
|
|
} |
|
|
|
|
|
|
|
callUsrEventCb(&event_cache); |
|
|
|
} |
|
|
|
void FrontEndControler::processUsrDoubleStateButtonEvent(uint8_t* data, size_t len) { |
|
|
|
void UI::processUsrDoubleStateButtonEvent(uint8_t* data, size_t len) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* 指令格式: |
|
|
@ -224,13 +210,14 @@ void FrontEndControler::processUsrDoubleStateButtonEvent(uint8_t* data, size_t l |
|
|
|
|
|
|
|
callUsrEventCb(&event_cache); |
|
|
|
} |
|
|
|
void FrontEndControler::callUsrEventCb(tjc::tjc_usr_event_t* event) { |
|
|
|
for (int32_t i = 0; i < m_ncb; i++) { |
|
|
|
m_cb[i](event); |
|
|
|
} |
|
|
|
void UI::callUsrEventCb(tjc::UIEvent* event) { |
|
|
|
static AppEvent_t appEvent; |
|
|
|
appEvent.type = KAE_UIEvent; |
|
|
|
memcpy(&appEvent.d.uiEvent, event, sizeof(tjc::UIEvent)); |
|
|
|
AppEventBus::ins()->pushEvent(appEvent); |
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::processInputfieldContentChangeEvent0(uint8_t* data, size_t len) { |
|
|
|
void UI::processInputfieldContentChangeEvent0(uint8_t* data, size_t len) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* |
|
|
@ -253,7 +240,7 @@ void FrontEndControler::processInputfieldContentChangeEvent0(uint8_t* data, size |
|
|
|
callUsrEventCb(&event_cache); |
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::processInputfieldContentChangeEvent1(uint8_t* data, size_t len) { |
|
|
|
void UI::processInputfieldContentChangeEvent1(uint8_t* data, size_t len) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* |
|
|
@ -279,7 +266,7 @@ void FrontEndControler::processInputfieldContentChangeEvent1(uint8_t* data, size |
|
|
|
callUsrEventCb(&event_cache); |
|
|
|
} |
|
|
|
|
|
|
|
bool FrontEndControler::readTxt(uint8_t pid, uint8_t cId, char* txt, int32_t txtbuflen) { |
|
|
|
bool UI::readTxt(uint8_t pid, uint8_t cId, char* txt, int32_t txtbuflen) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
|
|
|
|
startReceiveAck(); |
|
|
@ -303,7 +290,7 @@ bool FrontEndControler::readTxt(uint8_t pid, uint8_t cId, char* txt, int32_t txt |
|
|
|
memcpy(txt, &ackcache.data[1], cpysize); |
|
|
|
return true; |
|
|
|
} |
|
|
|
bool FrontEndControler::readInt(uint8_t pid, uint8_t cId, int32_t* val) { |
|
|
|
bool UI::readInt(uint8_t pid, uint8_t cId, int32_t* val) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
|
|
|
|
startReceiveAck(); |
|
|
@ -325,7 +312,7 @@ bool FrontEndControler::readInt(uint8_t pid, uint8_t cId, int32_t* val) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
bool FrontEndControler::echo(uint8_t tx, uint8_t* rx) { |
|
|
|
bool UI::echo(uint8_t tx, uint8_t* rx) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
|
|
|
|
startReceiveAck(); |
|
|
@ -352,7 +339,7 @@ bool FrontEndControler::echo(uint8_t tx, uint8_t* rx) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
bool FrontEndControler::setTxt(uint8_t pid, uint8_t bid, const char* txt, ...) { |
|
|
|
bool UI::setTxt(uint8_t pid, uint8_t bid, const char* txt, ...) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
|
|
|
|
va_list args; |
|
|
@ -364,18 +351,18 @@ bool FrontEndControler::setTxt(uint8_t pid, uint8_t bid, const char* txt, ...) { |
|
|
|
sendcmd("p[%d].b[%d].txt=\"%s\"", pid, bid, buf); |
|
|
|
return true; |
|
|
|
} |
|
|
|
bool FrontEndControler::setVal(uint8_t pid, uint8_t cid, int32_t val) { |
|
|
|
bool UI::setVal(uint8_t pid, uint8_t cid, int32_t val) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
sendcmd("p[%d].b[%d].val=%d", pid, cid, val); |
|
|
|
return true; |
|
|
|
} |
|
|
|
bool FrontEndControler::vis(uint16_t buuid, int32_t val) { |
|
|
|
bool UI::vis(uint16_t buuid, int32_t val) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
sendcmd("vis %d,%d", buuid & 0xff, val); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::alert(const char* info, function<void(bool)> onConfirm) { |
|
|
|
void UI::alert(const char* info, function<void(bool)> onConfirm) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
// if (m_isInPopWin) {
|
|
|
|
// ZLOGE(TAG, "isInPopWin,alert failed");
|
|
|
@ -390,7 +377,7 @@ void FrontEndControler::alert(const char* info, function<void(bool)> onConfirm) |
|
|
|
// sendcmd("p[%d].b[%d].txt=\"%s\"", pg_alert, ob_alert_info, buf);
|
|
|
|
// sendcmd("page alert");
|
|
|
|
} |
|
|
|
void FrontEndControler::alertNoConfirm(const char* info) { |
|
|
|
void UI::alertNoConfirm(const char* info) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
// if (m_isInPopWin) {
|
|
|
|
// ZLOGE(TAG, "isInPopWin,alertNoConfirm failed");
|
|
|
@ -406,7 +393,7 @@ void FrontEndControler::alertNoConfirm(const char* info) { |
|
|
|
// vis(ob_alert_confirmkey, 0);
|
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::confirmNoCancle(const char* info, function<void(bool)> onConfirm) { |
|
|
|
void UI::confirmNoCancle(const char* info, function<void(bool)> onConfirm) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
// if (m_isInPopWin) {
|
|
|
|
// ZLOGE(TAG, "isInPopWin,confirmNoCancle failed");
|
|
|
@ -424,7 +411,7 @@ void FrontEndControler::confirmNoCancle(const char* info, function<void(bool)> o |
|
|
|
// vis(ob_confirm_canclekey, 0);
|
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::confirm(const char* info, function<void(bool)> onConfirm) { |
|
|
|
void UI::confirm(const char* info, function<void(bool)> onConfirm) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
// if (m_isInPopWin) {
|
|
|
|
// ZLOGE(TAG, "isInPopWin,confirm failed");
|
|
|
@ -441,9 +428,9 @@ void FrontEndControler::confirm(const char* info, function<void(bool)> onConfirm |
|
|
|
// vis(ob_confirm_canclekey, 1);
|
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::chpage(uint8_t page) { sendcmd("page %d", page); } |
|
|
|
// void FrontEndControler::bakpage() { sendcmd("page %d", m_lastPage); }
|
|
|
|
void FrontEndControler::sendcmd(const char* format, ...) { |
|
|
|
void UI::chpage(uint8_t page) { sendcmd("page %d", page); } |
|
|
|
// void UI::bakpage() { sendcmd("page %d", m_lastPage); }
|
|
|
|
void UI::sendcmd(const char* format, ...) { |
|
|
|
static char buf[128]; |
|
|
|
va_list args; |
|
|
|
va_start(args, format); |
|
|
@ -469,26 +456,32 @@ void FrontEndControler::sendcmd(const char* format, ...) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::startReceiveAck() { |
|
|
|
void UI::startReceiveAck() { |
|
|
|
ackQueue.clear(); |
|
|
|
m_isWaitingForAck = true; |
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::virtualClick(uint8_t pid, uint8_t bid, uint8_t event) { |
|
|
|
void UI::virtualClick(uint8_t pid, uint8_t bid, uint8_t event) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
sendcmd("click b[%d],%d", bid, event); |
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::setTouchEnableState(uint8_t bid, uint8_t enable) { |
|
|
|
void UI::setTouchEnableState(uint8_t bid, uint8_t enable) { |
|
|
|
// tsw obj,state
|
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
sendcmd("tsw b[%d],%d", bid, enable); |
|
|
|
} |
|
|
|
|
|
|
|
void FrontEndControler::setEnumComponentState(uint8_t pid, uint8_t bid, int32_t state) { |
|
|
|
void UI::setEnumComponentState(uint8_t pid, uint8_t bid, int32_t state) { |
|
|
|
// 枚举类型使用动画组件
|
|
|
|
sendcmd("p[%d].b[%d].tim=%d", pid, bid, state * 50); |
|
|
|
} |
|
|
|
void FrontEndControler::setPic(uint8_t pid, uint8_t bid, int32_t picNum) { sendcmd("p[%d].b[%d].pic=%d", pid, bid, picNum); } |
|
|
|
void UI::setPic(uint8_t pid, uint8_t bid, int32_t picNum) { sendcmd("p[%d].b[%d].pic=%d", pid, bid, picNum); } |
|
|
|
|
|
|
|
void UI::setAph(uint8_t pid, uint8_t bid, int32_t state) { sendcmd("p[%d].b[%d].aph=%d", pid, bid, state); } |
|
|
|
|
|
|
|
void UI::pageInit() { UIPageInit(); } |
|
|
|
|
|
|
|
void FrontEndControler::setAph(uint8_t pid, uint8_t bid, int32_t state) { sendcmd("p[%d].b[%d].aph=%d", pid, bid, state); } |
|
|
|
namespace iflytop { |
|
|
|
__weak void UIPageInit() {} |
|
|
|
} // namespace iflytop
|