|
|
@ -1,4 +1,4 @@ |
|
|
|
#include "front_end_controler.hpp"
|
|
|
|
#include "ui_controler.hpp"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
@ -31,7 +31,7 @@ static const char* zhex2str(uint8_t* data, size_t len) { |
|
|
|
return buf; |
|
|
|
} |
|
|
|
|
|
|
|
void UI::initialize() { //
|
|
|
|
void UIControler::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 UI::initialize() { // |
|
|
|
m_cmdlock.init(); |
|
|
|
} |
|
|
|
#define UART_RX_OVERTIME 5
|
|
|
|
void UI::startSchedule() { |
|
|
|
void UIControler::startSchedule() { |
|
|
|
usartRxThread.start([this]() { |
|
|
|
static uint8_t rxbuf[128]; |
|
|
|
tjcUart->USR_UartITRxing = 1; |
|
|
@ -116,7 +116,7 @@ void UI::startSchedule() { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
void UI::processScreenRxPacket(uint8_t* data, size_t len) { |
|
|
|
void UIControler::processScreenRxPacket(uint8_t* data, size_t len) { |
|
|
|
// 判断包是否合法
|
|
|
|
#if MODULE_DEBUG
|
|
|
|
ZLOGI(TAG, "[rx-thread] : rx :%s(%d)", zhex2str(data, len), len); |
|
|
@ -164,7 +164,7 @@ static const char* zcpystr(char* cpyto, const char* strbegin, int32_t maxlen) { |
|
|
|
} |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
void UI::processUsrButtonEvent(uint8_t* data, size_t len) { |
|
|
|
void UIControler::processUsrButtonEvent(uint8_t* data, size_t len) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* 指令格式: |
|
|
@ -186,7 +186,7 @@ void UI::processUsrButtonEvent(uint8_t* data, size_t len) { |
|
|
|
|
|
|
|
callUsrEventCb(&event_cache); |
|
|
|
} |
|
|
|
void UI::processUsrDoubleStateButtonEvent(uint8_t* data, size_t len) { |
|
|
|
void UIControler::processUsrDoubleStateButtonEvent(uint8_t* data, size_t len) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* 指令格式: |
|
|
@ -210,14 +210,14 @@ void UI::processUsrDoubleStateButtonEvent(uint8_t* data, size_t len) { |
|
|
|
|
|
|
|
callUsrEventCb(&event_cache); |
|
|
|
} |
|
|
|
void UI::callUsrEventCb(tjc::UIEvent* event) { |
|
|
|
void UIControler::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 UI::processInputfieldContentChangeEvent0(uint8_t* data, size_t len) { |
|
|
|
void UIControler::processInputfieldContentChangeEvent0(uint8_t* data, size_t len) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* |
|
|
@ -240,7 +240,7 @@ void UI::processInputfieldContentChangeEvent0(uint8_t* data, size_t len) { |
|
|
|
callUsrEventCb(&event_cache); |
|
|
|
} |
|
|
|
|
|
|
|
void UI::processInputfieldContentChangeEvent1(uint8_t* data, size_t len) { |
|
|
|
void UIControler::processInputfieldContentChangeEvent1(uint8_t* data, size_t len) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* |
|
|
@ -266,7 +266,7 @@ void UI::processInputfieldContentChangeEvent1(uint8_t* data, size_t len) { |
|
|
|
callUsrEventCb(&event_cache); |
|
|
|
} |
|
|
|
|
|
|
|
bool UI::readTxt(uint8_t pid, uint8_t cId, char* txt, int32_t txtbuflen) { |
|
|
|
bool UIControler::readTxt(uint8_t pid, uint8_t cId, char* txt, int32_t txtbuflen) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
|
|
|
|
startReceiveAck(); |
|
|
@ -290,7 +290,7 @@ bool UI::readTxt(uint8_t pid, uint8_t cId, char* txt, int32_t txtbuflen) { |
|
|
|
memcpy(txt, &ackcache.data[1], cpysize); |
|
|
|
return true; |
|
|
|
} |
|
|
|
bool UI::readInt(uint8_t pid, uint8_t cId, int32_t* val) { |
|
|
|
bool UIControler::readInt(uint8_t pid, uint8_t cId, int32_t* val) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
|
|
|
|
startReceiveAck(); |
|
|
@ -312,7 +312,7 @@ bool UI::readInt(uint8_t pid, uint8_t cId, int32_t* val) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
bool UI::echo(uint8_t tx, uint8_t* rx) { |
|
|
|
bool UIControler::echo(uint8_t tx, uint8_t* rx) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
|
|
|
|
startReceiveAck(); |
|
|
@ -339,7 +339,7 @@ bool UI::echo(uint8_t tx, uint8_t* rx) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
bool UI::setTxt(uint8_t pid, uint8_t bid, const char* txt, ...) { |
|
|
|
bool UIControler::setTxt(uint8_t pid, uint8_t bid, const char* txt, ...) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
|
|
|
|
va_list args; |
|
|
@ -352,28 +352,28 @@ bool UI::setTxt(uint8_t pid, uint8_t bid, const char* txt, ...) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
void UI::setPicturePicNum(uint8_t pid, uint8_t bid, uint8_t fromBid) { |
|
|
|
void UIControler::setPicturePicNum(uint8_t pid, uint8_t bid, uint8_t fromBid) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
sendcmd("p[%d].b[%d].pic=p[%d].b[%d].pic", pid, bid, pid, fromBid); |
|
|
|
} |
|
|
|
void UI::setButtonPicNum(uint8_t pid, uint8_t bid, uint8_t fromBid) { |
|
|
|
void UIControler::setButtonPicNum(uint8_t pid, uint8_t bid, uint8_t fromBid) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
sendcmd("p[%d].b[%d].pic=p[%d].b[%d].pic", pid, bid, pid, fromBid); |
|
|
|
sendcmd("p[%d].b[%d].pic2=p[%d].b[%d].pic2", pid, bid, pid, fromBid); |
|
|
|
} |
|
|
|
|
|
|
|
bool UI::setVal(uint8_t pid, uint8_t cid, int32_t val) { |
|
|
|
bool UIControler::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 UI::vis(uint16_t buuid, int32_t val) { |
|
|
|
bool UIControler::vis(uint16_t buuid, int32_t val) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
sendcmd("vis %d,%d", buuid & 0xff, val); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
void UI::setrtc(zdate_t* date) { |
|
|
|
void UIControler::setrtc(zdate_t* date) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
sendcmd("rtc0=%d", date->year); |
|
|
|
sendcmd("rtc1=%d", date->month); |
|
|
@ -383,7 +383,7 @@ void UI::setrtc(zdate_t* date) { |
|
|
|
sendcmd("rtc5=%d", date->seconds); |
|
|
|
} |
|
|
|
|
|
|
|
void UI::alert(const char* info, function<void(bool)> onConfirm) { |
|
|
|
void UIControler::alert(const char* info, function<void(bool)> onConfirm) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
// if (m_isInPopWin) {
|
|
|
|
// ZLOGE(TAG, "isInPopWin,alert failed");
|
|
|
@ -398,7 +398,7 @@ void UI::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 UI::alertNoConfirm(const char* info) { |
|
|
|
void UIControler::alertNoConfirm(const char* info) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
// if (m_isInPopWin) {
|
|
|
|
// ZLOGE(TAG, "isInPopWin,alertNoConfirm failed");
|
|
|
@ -414,7 +414,7 @@ void UI::alertNoConfirm(const char* info) { |
|
|
|
// vis(ob_alert_confirmkey, 0);
|
|
|
|
} |
|
|
|
|
|
|
|
void UI::confirmNoCancle(const char* info, function<void(bool)> onConfirm) { |
|
|
|
void UIControler::confirmNoCancle(const char* info, function<void(bool)> onConfirm) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
// if (m_isInPopWin) {
|
|
|
|
// ZLOGE(TAG, "isInPopWin,confirmNoCancle failed");
|
|
|
@ -432,7 +432,7 @@ void UI::confirmNoCancle(const char* info, function<void(bool)> onConfirm) { |
|
|
|
// vis(ob_confirm_canclekey, 0);
|
|
|
|
} |
|
|
|
|
|
|
|
void UI::confirm(const char* info, function<void(bool)> onConfirm) { |
|
|
|
void UIControler::confirm(const char* info, function<void(bool)> onConfirm) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
// if (m_isInPopWin) {
|
|
|
|
// ZLOGE(TAG, "isInPopWin,confirm failed");
|
|
|
@ -449,9 +449,9 @@ void UI::confirm(const char* info, function<void(bool)> onConfirm) { |
|
|
|
// vis(ob_confirm_canclekey, 1);
|
|
|
|
} |
|
|
|
|
|
|
|
void UI::chpage(uint8_t page) { sendcmd("page %d", page); } |
|
|
|
// void UI::bakpage() { sendcmd("page %d", m_lastPage); }
|
|
|
|
void UI::sendcmd(const char* format, ...) { |
|
|
|
void UIControler::chpage(uint8_t page) { sendcmd("page %d", page); } |
|
|
|
// void UIControler::bakpage() { sendcmd("page %d", m_lastPage); }
|
|
|
|
void UIControler::sendcmd(const char* format, ...) { |
|
|
|
static char buf[128]; |
|
|
|
va_list args; |
|
|
|
va_start(args, format); |
|
|
@ -477,31 +477,31 @@ void UI::sendcmd(const char* format, ...) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void UI::startReceiveAck() { |
|
|
|
void UIControler::startReceiveAck() { |
|
|
|
ackQueue.clear(); |
|
|
|
m_isWaitingForAck = true; |
|
|
|
} |
|
|
|
|
|
|
|
void UI::virtualClick(uint8_t pid, uint8_t bid, uint8_t event) { |
|
|
|
void UIControler::virtualClick(uint8_t pid, uint8_t bid, uint8_t event) { |
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
sendcmd("click b[%d],%d", bid, event); |
|
|
|
} |
|
|
|
|
|
|
|
void UI::setTouchEnableState(uint8_t bid, uint8_t enable) { |
|
|
|
void UIControler::setTouchEnableState(uint8_t bid, uint8_t enable) { |
|
|
|
// tsw obj,state
|
|
|
|
zlock_guard lg(m_cmdlock); |
|
|
|
sendcmd("tsw b[%d],%d", bid, enable); |
|
|
|
} |
|
|
|
|
|
|
|
void UI::setEnumComponentState(uint8_t pid, uint8_t bid, int32_t state) { |
|
|
|
void UIControler::setEnumComponentState(uint8_t pid, uint8_t bid, int32_t state) { |
|
|
|
// 枚举类型使用动画组件
|
|
|
|
sendcmd("p[%d].b[%d].tim=%d", pid, bid, state * 50); |
|
|
|
} |
|
|
|
void UI::setPic(uint8_t pid, uint8_t bid, int32_t picNum) { sendcmd("p[%d].b[%d].pic=%d", pid, bid, picNum); } |
|
|
|
void UIControler::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 UIControler::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 UIControler::pageInit() { UIPageInit(); } |
|
|
|
|
|
|
|
namespace iflytop { |
|
|
|
__weak void UIPageInit() {} |