You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
5.8 KiB
134 lines
5.8 KiB
#pragma once
|
|
#include "apphardware/apphardware.hpp"
|
|
#include "config/config.hpp"
|
|
#include "uappbase/base.hpp"
|
|
//
|
|
#include "ui_state_mgr.hpp"
|
|
#include "uicontroler/base/ui_state.hpp"
|
|
|
|
//
|
|
#include "tjc/tjc.hpp"
|
|
|
|
namespace iflytop {
|
|
using namespace std;
|
|
typedef struct {
|
|
uint8_t data[TJC_MAX_PACKET_SIZE];
|
|
uint16_t datalen;
|
|
} tjc_rx_packet_t;
|
|
|
|
#define UIS UIControler::ins()
|
|
class UIControler {
|
|
ZThread m_thread;
|
|
|
|
tjc_rx_packet_t ackcache;
|
|
zmutex m_cmdlock = {"UI_LOCK"};
|
|
|
|
|
|
public:
|
|
UIControler() {};
|
|
~UIControler() {};
|
|
|
|
static UIControler* ins() {
|
|
static UIControler instance;
|
|
return &instance;
|
|
}
|
|
void postInitialize();
|
|
void initialize();
|
|
void pageInitialize();
|
|
int getNowPage() { return UIStateMgr::ins()->nowPage; }
|
|
void chpage(uint8_t page, bool triggerEvent);
|
|
bool echo(uint8_t tx, uint8_t* rx);
|
|
|
|
void startSchedule();
|
|
|
|
/***********************************************************************************************************************
|
|
* WRITE *
|
|
***********************************************************************************************************************/
|
|
|
|
void virtualClick(uint8_t pid, uint8_t bid, uint8_t event);
|
|
bool setTxt(uint8_t pid, uint8_t bid, const char* txt, ...);
|
|
bool setTxt(uint8_t pid, uint8_t bid, const char* txt, va_list args);
|
|
void setPic(uint8_t pid, uint8_t bid, int32_t picNum);
|
|
void setAph(uint8_t pid, uint8_t bid, int32_t state); // 组件透明度,最大127,设置为0则隐藏组件,事件依然会触发,可以由底层过滤
|
|
bool setVal(uint8_t pid, uint8_t bid, int32_t val);
|
|
void setEnumComponentState(uint8_t pid, uint8_t bid, int32_t state);
|
|
void setPicturePicNum(uint8_t pid, uint8_t bid, uint8_t fromBid);
|
|
void setButtonPicNum(uint8_t pid, uint8_t bid, uint8_t fromBid);
|
|
void setPicturePicNumFromGlobal(uint8_t pid, uint8_t bid, uint8_t fromPid, uint8_t fromBid);
|
|
void setButtonPicNumFromGlobal(uint8_t pid, uint8_t bid, uint8_t fromPid, uint8_t fromBid);
|
|
void setrtc(zdate_t* date);
|
|
void setPath(uint8_t pid, uint8_t bid, const char* path) {
|
|
zlock_guard lg(m_cmdlock);
|
|
sendcmd("p[%d].b[%d].path=\"%s\"", pid, bid, path);
|
|
}
|
|
|
|
void sendcmd(const char* format, ...);
|
|
void sendcmd(const char* format, va_list args);
|
|
void setEffect(uint8_t pid, uint8_t bid, tjc_effet_t effect) {
|
|
zlock_guard lg(m_cmdlock);
|
|
sendcmd("p[%d].b[%d].effect=%d", pid, bid, effect);
|
|
}
|
|
|
|
/***********************************************************************************************************************
|
|
* READ *
|
|
***********************************************************************************************************************/
|
|
bool readTxt(uint8_t pid, uint8_t bid, char* txt, int32_t txtbuflen);
|
|
bool readInt(uint8_t pid, uint8_t bid, int32_t* val);
|
|
bool readFiledAsInt(uint8_t pid, uint8_t bid, const char* filedName, int32_t* val);
|
|
|
|
/***********************************************************************************************************************
|
|
* POP_WIN *
|
|
***********************************************************************************************************************/
|
|
void popWin(UIPopWinType_t type, const char* info, function<void(bool)> onConfirm);
|
|
void popWarningWin(const char* info) { popWin(UI_POP_WIN_TYPE_WARNING_INFO, info, nullptr); }
|
|
void popFatalErrorWin(const char* info) { popWin(UI_POP_WIN_TYPE_FATAL_ERROR, info, nullptr); }
|
|
void popConfirmWin(const char* info, function<void(bool)> onConfirm) { popWin(UI_POP_WIN_TYPE_CONFIRM, info, onConfirm); }
|
|
void popInfoWin(const char* info, function<void(bool)> onConfirm = nullptr) { popWin(UI_POP_WIN_TYPE_INFO, info, onConfirm); }
|
|
void popPowerOffWin(const char* info) { popWin(UI_POP_WIN_TYPE_POWER_OFF_INFO, info, nullptr); }
|
|
|
|
|
|
void doInUILockArea(function<void()> fn) {
|
|
zlock_guard lg(m_cmdlock);
|
|
fn();
|
|
}
|
|
/**
|
|
* @brief
|
|
*/
|
|
|
|
void popFullKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitLength, const char* initval);
|
|
void popPasswdKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitLength);
|
|
void popNumKeyBoard(uint8_t fromPid, uint8_t fromBid, int limitLength, const char* initval, ...);
|
|
|
|
void popKeyBMutSel(uint8_t fromPid, uint8_t fromBid, int selectvalindex, const char** selectvals);
|
|
void popKeyBMutSel(uint8_t fromPid, uint8_t fromBid, int selectvalindex, const char* selectvals);
|
|
|
|
void popKeyBMutSelFix(uint8_t fromPid, uint8_t fromBid, int selectvalindex, const char* keyboardName, const char** selectvals);
|
|
|
|
/***********************************************************************************************************************
|
|
* UTILS *
|
|
***********************************************************************************************************************/
|
|
|
|
bool visEx(uint8_t pid, uint8_t bid, bool val); // 通过搬移组件实现跨页面隐藏
|
|
bool movePicToXY(uint8_t pid, uint8_t bid, int32_t x, int32_t y);
|
|
bool movePicTo(uint8_t pid, uint8_t bid, uint8_t toBid);
|
|
bool movePicOutOfScreen(uint8_t pid, uint8_t bid);
|
|
|
|
void doBlockWork(const char* blockmask, function<void()> fn) ;
|
|
|
|
private:
|
|
void processScreenRxPacket(uint8_t* data, size_t len);
|
|
|
|
void startReceiveAck();
|
|
void callUsrEventCb(UIEvent* event);
|
|
|
|
bool _readFiledAsInt(uint8_t pid, uint8_t bid, const char* valName, int32_t* val);
|
|
|
|
private:
|
|
bool vis(uint16_t bid, int32_t val); // 不支持跨页面隐藏
|
|
void setTouchEnableState(uint8_t bid, uint8_t enable); // 不支持跨页面隐藏
|
|
|
|
void placeHolder() {}
|
|
};
|
|
|
|
|
|
} // namespace iflytop
|