模拟菜单功能;优化字符显示(支持不同宽度字符)
This commit is contained in:
parent
fcb90d0b7d
commit
aa26512313
|
@ -104,6 +104,11 @@ typedef struct _size
|
|||
u_int32_t cx;
|
||||
u_int32_t cy;
|
||||
}SIZE, *LPSIZE;
|
||||
typedef struct _point
|
||||
{
|
||||
u_int32_t x;
|
||||
u_int32_t y;
|
||||
}POINT, *LPPOINT;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
|
|
|
@ -46,6 +46,6 @@
|
|||
#define WORDS_MENU_YES "\347\241\256\345\256\232"
|
||||
#define WORDS_MENU_NO "\345\217\226\346\266\210"
|
||||
|
||||
#define WORDS_FUNCTION_COUNT "\345\274\240\346\225\260"
|
||||
#define WORDS_FUNCTION_COUNT "\345\274\240\346\225\260\357\274\232"
|
||||
|
||||
#define WORDS_STATUS_READY "\345\260\261\347\273\252"
|
12
ui/Lcd.cpp
12
ui/Lcd.cpp
|
@ -837,14 +837,16 @@ void Lcd::clear(int x, int y, int w, int h)
|
|||
write_end();
|
||||
}
|
||||
}
|
||||
void Lcd::write_line(uint8_t rows, uint8_t cols, uint8_t cnt, uint8_t** data, int x, int y, uint8_t mask)
|
||||
void Lcd::write_line(uint8_t** data, uint8_t cnt, int x, int y, uint8_t mask)
|
||||
{
|
||||
uint8_t *ptr[16] = {0};
|
||||
uint8_t *ptr[16] = {0},
|
||||
blank[Lcd::LCD_WIDTH] = {0},
|
||||
over = 0;
|
||||
|
||||
for(int i = 0; i < cnt && i < _countof(ptr); ++i)
|
||||
ptr[i] = data[i];
|
||||
ptr[i] = data[i] + 2;
|
||||
|
||||
for(int r = 0; r < rows / LCD_LINE_PER_PAGE; ++r)
|
||||
for(int r = 0; r < data[0][1] / LCD_LINE_PER_PAGE; ++r)
|
||||
{
|
||||
go_to(y / LCD_LINE_PER_PAGE + r, x);
|
||||
write_before();
|
||||
|
@ -852,7 +854,7 @@ void Lcd::write_line(uint8_t rows, uint8_t cols, uint8_t cnt, uint8_t** data, in
|
|||
|
||||
for(int ind = 0; ind < cnt; ++ind)
|
||||
{
|
||||
for(int c = 0; c < cols; ++c)
|
||||
for(int c = 0; c < data[ind][0]; ++c)
|
||||
{
|
||||
write_char(*ptr[ind]++, mask);
|
||||
}
|
||||
|
|
2
ui/Lcd.h
2
ui/Lcd.h
|
@ -68,7 +68,7 @@ public:
|
|||
// size: 32lines x 1056px
|
||||
void go_to(uint8_t page, uint8_t col);
|
||||
void write(uint8_t val, bool data, uint8_t mask = 0);
|
||||
void write_line(uint8_t rows, uint8_t cols, uint8_t cnt, uint8_t** data, int x = 0, int y = 0, uint8_t mask = 0);
|
||||
void write_line(uint8_t** data, uint8_t cnt, int x = 0, int y = 0, uint8_t mask = 0);
|
||||
void clear(int x = 0, int y = 0, int w = -1, int h = -1);
|
||||
|
||||
private:
|
||||
|
|
329
ui/dev_menu.cpp
329
ui/dev_menu.cpp
|
@ -291,21 +291,28 @@ ui_mgr::ui_mgr() : disp_data_("lcd-msg")
|
|||
lcd_->Lcd_Initial_Lcd(false);
|
||||
lcd_->clear();
|
||||
|
||||
ready_.cnt = get_string_font(WORDS_STATUS_READY, ready_.ptr, &ready_.rows, &ready_.cols);
|
||||
ready_.x = (Lcd::LCD_WIDTH - ready_.cols * ready_.cnt) / 2;
|
||||
ready_.y = (Lcd::LCD_HEIGHT - ready_.rows) / 2;
|
||||
srand(time(nullptr));
|
||||
his_cnt_ = rand() % 1000000;
|
||||
rol_cnt_ = his_cnt_ / (2 + (rand() % 5));
|
||||
|
||||
ready_.cnt = custom_font::get_string_font(WORDS_STATUS_READY, ready_.ptr);
|
||||
ready_.x = (Lcd::LCD_WIDTH - ready_.ptr[0][0] * ready_.cnt) / 2;
|
||||
ready_.y = (Lcd::LCD_HEIGHT - ready_.ptr[0][1]) / 2;
|
||||
ready_.mask = 0;
|
||||
|
||||
keyboard_.reset(new KeyMonitor(ke));
|
||||
disp_thrd_.reset(new std::thread(&ui_mgr::thread_display, this));
|
||||
// refresh_lcd(true);
|
||||
|
||||
auto display = [this](void) -> void
|
||||
{
|
||||
thread_display();
|
||||
};
|
||||
disp_thrd_.start(display, "thread_display");
|
||||
}
|
||||
ui_mgr::~ui_mgr()
|
||||
{
|
||||
run_ = false;
|
||||
menu_mode_ = false;
|
||||
disp_data_.trigger();
|
||||
if(disp_thrd_.get() && disp_thrd_->joinable())
|
||||
disp_thrd_->join();
|
||||
|
||||
clear();
|
||||
}
|
||||
|
@ -318,7 +325,9 @@ bool ui_mgr::do_menu_command(int cmd)
|
|||
holdui = handler_[cmd](cur_, cmd);
|
||||
|
||||
// at last, we return to main menu OR parent ?
|
||||
if(!holdui)
|
||||
if(holdui)
|
||||
menu_mode_ = false;
|
||||
else
|
||||
{
|
||||
cur_->release();
|
||||
cur_ = root_; // main menu
|
||||
|
@ -333,8 +342,7 @@ void ui_mgr::init(void)
|
|||
|
||||
root_ = new dev_menu();
|
||||
|
||||
// 分纸强度(低中高)
|
||||
{
|
||||
// 分纸强度(低ä¸é«˜ï¼? {
|
||||
child = new dev_menu(true);
|
||||
child->add_menu(WORDS_MENU_LOW, MENU_CMD_ID_SEPARATE_LOW);
|
||||
{
|
||||
|
@ -364,8 +372,7 @@ void ui_mgr::init(void)
|
|||
root_->add_menu(WORDS_MENU_SEPARATE_STRENGTH, child);
|
||||
child->release();
|
||||
}
|
||||
// 休眠时间(不休眠,5min, 10min, 20min, 30min, 1h, 2h, 4h)
|
||||
{
|
||||
// ä¼‘çœ æ—¶é—´ï¼ˆä¸<C3A4>ä¼‘çœ ï¼?min, 10min, 20min, 30min, 1h, 2h, 4hï¼? {
|
||||
child = new dev_menu(true);
|
||||
child->add_menu(WORDS_MENU_SLEEP_NONE, MENU_CMD_ID_SLEEP_NEVER);
|
||||
{
|
||||
|
@ -443,6 +450,126 @@ void ui_mgr::init(void)
|
|||
root_->add_menu(WORDS_MENU_POWER, child);
|
||||
child->release();
|
||||
}
|
||||
|
||||
// 计数模å¼<C3A5>ã€<C3A3>手动模å¼<C3A5>ã€<C3A3>清ç<E280A6>†çº¸é<C2B8>“ã€<C3A3>历å<E280A0>²å¼ æ•°ã€<C3A3>æ»šè½´å¼ æ•°ã€<C3A3>æ¸…é™¤æ»šè½´å¼ æ•?确定,å<C592>–æ¶?ã€<C3A3>è¿›å…¥ä¼‘çœ ã€<C3A3>å…³æœ? root_->add_menu(WORDS_MENU_COUNT_MODE, MENU_CMD_ID_COUNT_MODE);
|
||||
{
|
||||
auto f = [this](dev_menu* m, int id) -> MENU_CMD_HANDLER_RET
|
||||
{
|
||||
// ä¿<C3A4>æŒ<C3A6>ç•Œé<C592>¢ï¼šç¬¬ä¸€è¡Œæ˜¾ç¤ºå½“å‰<C3A5>ä¿<C3A4>æŒ<C3A6>的功能
|
||||
// 第二行显示当å‰<C3A5>功能的信æ<C2A1>¯ï¼Œè¿‡ç¨‹ä¸å<C2AD>ªæ›´æ–°è¯¥è¡? //
|
||||
// ä»»æ„<C3A6>按键的å<E2809E><C3A5>应:第一行显示“退出当å‰<C3A5>功能â€? // 第二行显示“确定â€<C3A2>ã€<C3A3>“å<C593>–消â€<C3A2>,è<C592>œå<C593>•é”®åœ¨æ¤ä¸¤é¡¹ä¸è·³è½¬
|
||||
DISPDATA dd;
|
||||
|
||||
memset(&dd, 0, sizeof(dd));
|
||||
dd.cnt = dd.mask = -1;
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
dd.mask = 0;
|
||||
dd.cnt = custom_font::get_string_font(WORDS_MENU_COUNT_MODE, dd.ptr);
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
dd.y = dd.ptr[0][1];
|
||||
dd.cnt = custom_font::get_string_font(WORDS_FUNCTION_COUNT, dd.ptr);
|
||||
hold_pos_.x = dd.x;
|
||||
for(int i = 0; i < dd.cnt; ++i)
|
||||
hold_pos_.x += dd.ptr[i][0] + 1;
|
||||
hold_pos_.y = dd.y;
|
||||
hold_pos_.x += 2;
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
auto test = [this](void) -> void
|
||||
{
|
||||
thread_test_hold_ui();
|
||||
};
|
||||
disp_thrd_.stop("thread_test_hold_ui");
|
||||
disp_thrd_.start(test, "thread_test_hold_ui");
|
||||
|
||||
return true;
|
||||
};
|
||||
handler_[MENU_CMD_ID_COUNT_MODE] = f;
|
||||
}
|
||||
root_->add_menu(WORDS_MENU_MANUAL_MODE, MENU_CMD_ID_HANDLE_MODE);
|
||||
{
|
||||
auto f = [this](dev_menu* m, int id) -> MENU_CMD_HANDLER_RET
|
||||
{
|
||||
return true;
|
||||
};
|
||||
handler_[MENU_CMD_ID_HANDLE_MODE] = f;
|
||||
}
|
||||
root_->add_menu(WORDS_MENU_CLEAR_PASSWAY, MENU_CMD_ID_CLEAR_PASSWAY);
|
||||
{
|
||||
auto f = [this](dev_menu* m, int id) -> MENU_CMD_HANDLER_RET
|
||||
{
|
||||
return false;
|
||||
};
|
||||
handler_[MENU_CMD_ID_CLEAR_PASSWAY] = f;
|
||||
}
|
||||
root_->add_menu(WORDS_MENU_HISTORY_COUNT, MENU_CMD_ID_GET_HISTORY_COUNT);
|
||||
{
|
||||
auto f = [this](dev_menu* m, int id) -> MENU_CMD_HANDLER_RET
|
||||
{
|
||||
DISPDATA dd;
|
||||
char cnt[40] = {0};
|
||||
|
||||
memset(&dd, 0, sizeof(dd));
|
||||
dd.cnt = dd.mask = -1;
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
dd.mask = 0;
|
||||
dd.cnt = custom_font::get_string_font(WORDS_MENU_HISTORY_COUNT, dd.ptr);
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
dd.y = dd.ptr[0][1];
|
||||
dd.x = dd.ptr[0][0] * 2;
|
||||
sprintf(cnt, "%u", his_cnt_);
|
||||
dd.cnt = custom_font::get_string_font(cnt, dd.ptr);
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
return true;
|
||||
};
|
||||
handler_[MENU_CMD_ID_GET_HISTORY_COUNT] = f;
|
||||
}
|
||||
root_->add_menu(WORDS_MENU_ROLLER_COUNT, MENU_CMD_ID_GET_ROLLER_COUNT);
|
||||
{
|
||||
auto f = [this](dev_menu* m, int id) -> MENU_CMD_HANDLER_RET
|
||||
{
|
||||
DISPDATA dd;
|
||||
char cnt[40] = {0};
|
||||
|
||||
memset(&dd, 0, sizeof(dd));
|
||||
dd.cnt = dd.mask = -1;
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
dd.mask = 0;
|
||||
dd.cnt = custom_font::get_string_font(WORDS_MENU_ROLLER_COUNT, dd.ptr);
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
dd.y = dd.ptr[0][1];
|
||||
dd.x = dd.ptr[0][0] * 2;
|
||||
sprintf(cnt, "%u", rol_cnt_);
|
||||
dd.cnt = custom_font::get_string_font(cnt, dd.ptr);
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
return true;
|
||||
};
|
||||
handler_[MENU_CMD_ID_GET_ROLLER_COUNT] = f;
|
||||
}
|
||||
{
|
||||
child = new dev_menu(false, false);
|
||||
child->add_menu(WORDS_MENU_YES, MENU_CMD_ID_CLEAR_ROLLER_CNT);
|
||||
{
|
||||
auto f = [this](dev_menu* m, int id) -> MENU_CMD_HANDLER_RET
|
||||
{
|
||||
rol_cnt_ = 0;
|
||||
|
||||
return false;
|
||||
};
|
||||
handler_[MENU_CMD_ID_CLEAR_ROLLER_CNT] = f;
|
||||
}
|
||||
child->add_menu(WORDS_MENU_NO, MENU_CMD_ID_CANCEL);
|
||||
root_->add_menu(WORDS_MENU_RESET_ROLLOER_CNT, child);
|
||||
child->release();
|
||||
}
|
||||
// 升降台位置(低中高)
|
||||
{
|
||||
child = new dev_menu(true);
|
||||
|
@ -474,79 +601,6 @@ void ui_mgr::init(void)
|
|||
root_->add_menu(WORDS_MENU_LIFTER_POS, child);
|
||||
child->release();
|
||||
}
|
||||
|
||||
// 计数模式、手动模式、清理纸道、历史张数、滚轴张数、清除滚轴张数(确定,取消)、进入休眠、关机
|
||||
root_->add_menu(WORDS_MENU_COUNT_MODE, MENU_CMD_ID_COUNT_MODE);
|
||||
{
|
||||
auto f = [this](dev_menu* m, int id) -> MENU_CMD_HANDLER_RET
|
||||
{
|
||||
// 保持界面:第一行显示当前保持的功能
|
||||
// 第二行显示当前功能的信息,过程中只更新该行
|
||||
//
|
||||
// 任意按键的反应:第一行显示“退出当前功能”
|
||||
// 第二行显示“确定”、“取消”,菜单键在此两项中跳转
|
||||
DISPDATA dd;
|
||||
|
||||
memset(&dd, 0, sizeof(dd));
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
dd.cnt = get_string_font(WORDS_MENU_COUNT_MODE, dd.ptr, &dd.rows, &dd.cols);
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
dd.y = dd.rows;
|
||||
dd.cnt = get_string_font(WORDS_FUNCTION_COUNT, dd.ptr, &dd.rows, &dd.cols);
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
return true;
|
||||
};
|
||||
handler_[MENU_CMD_ID_COUNT_MODE] = f;
|
||||
}
|
||||
root_->add_menu(WORDS_MENU_MANUAL_MODE, MENU_CMD_ID_HANDLE_MODE);
|
||||
{
|
||||
auto f = [this](dev_menu* m, int id) -> MENU_CMD_HANDLER_RET
|
||||
{
|
||||
return true;
|
||||
};
|
||||
handler_[MENU_CMD_ID_HANDLE_MODE] = f;
|
||||
}
|
||||
root_->add_menu(WORDS_MENU_CLEAR_PASSWAY, MENU_CMD_ID_CLEAR_PASSWAY);
|
||||
{
|
||||
auto f = [this](dev_menu* m, int id) -> MENU_CMD_HANDLER_RET
|
||||
{
|
||||
return false;
|
||||
};
|
||||
handler_[MENU_CMD_ID_CLEAR_PASSWAY] = f;
|
||||
}
|
||||
root_->add_menu(WORDS_MENU_HISTORY_COUNT, MENU_CMD_ID_GET_HISTORY_COUNT);
|
||||
{
|
||||
auto f = [this](dev_menu* m, int id) -> MENU_CMD_HANDLER_RET
|
||||
{
|
||||
return false;
|
||||
};
|
||||
handler_[MENU_CMD_ID_GET_HISTORY_COUNT] = f;
|
||||
}
|
||||
root_->add_menu(WORDS_MENU_ROLLER_COUNT, MENU_CMD_ID_GET_ROLLER_COUNT);
|
||||
{
|
||||
auto f = [this](dev_menu* m, int id) -> MENU_CMD_HANDLER_RET
|
||||
{
|
||||
return false;
|
||||
};
|
||||
handler_[MENU_CMD_ID_GET_ROLLER_COUNT] = f;
|
||||
}
|
||||
{
|
||||
child = new dev_menu(false, false);
|
||||
child->add_menu(WORDS_MENU_YES, MENU_CMD_ID_CLEAR_ROLLER_CNT);
|
||||
{
|
||||
auto f = [this](dev_menu* m, int id) -> MENU_CMD_HANDLER_RET
|
||||
{
|
||||
return false;
|
||||
};
|
||||
handler_[MENU_CMD_ID_CLEAR_ROLLER_CNT] = f;
|
||||
}
|
||||
child->add_menu(WORDS_MENU_NO, MENU_CMD_ID_CANCEL);
|
||||
root_->add_menu(WORDS_MENU_RESET_ROLLOER_CNT, child);
|
||||
child->release();
|
||||
}
|
||||
{
|
||||
child = new dev_menu(false, false);
|
||||
child->add_menu(WORDS_MENU_YES, MENU_CMD_ID_SHUTDOWN);
|
||||
|
@ -572,10 +626,8 @@ void ui_mgr::init(void)
|
|||
dd.mask = 0;
|
||||
dd.x = 0;
|
||||
dd.y = 0;
|
||||
dd.rows = welcome[1];
|
||||
dd.cols = welcome[0];
|
||||
dd.cnt = 1;
|
||||
dd.ptr[0] = welcome + 2;
|
||||
dd.ptr[0] = welcome;
|
||||
disp_data_.save(dd, true);
|
||||
|
||||
return false;
|
||||
|
@ -628,13 +680,14 @@ void ui_mgr::refresh_lcd(bool cur_at_top)
|
|||
|
||||
memset(&dd, 0, sizeof(dd));
|
||||
if(i == 0)
|
||||
{
|
||||
dd.cnt = dd.mask = -1;
|
||||
disp_data_.save(dd, true);
|
||||
}
|
||||
dd.mask = i == sel ? 0x0ff : 0;
|
||||
dd.x = disp[i].find(WORDS_MENU_SELECTED) == 0 ? 0 : font_size_.cx;
|
||||
dd.y = rows;
|
||||
dd.rows = font_size_.cy;
|
||||
dd.cols = font_size_.cx;
|
||||
dd.cnt = get_string_font(disp[i].c_str(), dd.ptr, &dd.rows, &dd.cols);
|
||||
dd.cnt = custom_font::get_string_font(disp[i].c_str(), dd.ptr);
|
||||
cur = disp_data_.save(dd, true);
|
||||
rows += font_size_.cy;
|
||||
}
|
||||
|
@ -652,19 +705,6 @@ void ui_mgr::move_to(bool next)
|
|||
}
|
||||
void ui_mgr::enter(void)
|
||||
{
|
||||
if(!menu_mode_)
|
||||
{
|
||||
menu_mode_ = true;
|
||||
if(cur_)
|
||||
cur_->release();
|
||||
cur_ = root_;
|
||||
if(cur_)
|
||||
cur_->add_ref();
|
||||
refresh_lcd(true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(cur_)
|
||||
{
|
||||
int id = -1;
|
||||
|
@ -684,58 +724,65 @@ void ui_mgr::enter(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
int ui_mgr::get_string_font(const char* text, uint8_t** ptr, uint8_t* rows, uint8_t* cols)
|
||||
|
||||
void ui_mgr::thread_test_hold_ui(void)
|
||||
{
|
||||
uint32_t cnt = 99900 + (rand() % 100);
|
||||
DISPDATA dd;
|
||||
int cnt = 0, ind = 0;
|
||||
char number[40] = {0};
|
||||
custom_font::font_size size = custom_font::FONT_SIZE_16;
|
||||
|
||||
for(; text[ind] && cnt < _countof(dd.ptr); ++cnt)
|
||||
dd.x = hold_pos_.x;
|
||||
dd.y = hold_pos_.y;
|
||||
dd.mask = 0;
|
||||
printf("Start testing count from %d\n", cnt);
|
||||
while(!menu_mode_)
|
||||
{
|
||||
// Fixed ME !!! how to count a character width ? here I assume 3-bytes
|
||||
char utf8[4] = {text[ind], text[ind + 1], text[ind + 2], 0};
|
||||
|
||||
if(text[ind] >= 0 && text[ind] <= 0x7f)
|
||||
rol_cnt_++;
|
||||
sprintf(number, "%d", cnt++);
|
||||
if(size == custom_font::FONT_SIZE_16 && (Lcd::LCD_WIDTH - dd.x) / font_size_.cx < strlen(number))
|
||||
{
|
||||
utf8[1] = utf8[2] = 0;
|
||||
ind++;
|
||||
{
|
||||
// clear
|
||||
dd.cnt = -1;
|
||||
dd.mask = -1;
|
||||
dd.ptr[0] = nullptr; // perform clear
|
||||
disp_data_.save(dd, true);
|
||||
dd.mask = 0;
|
||||
}
|
||||
size = custom_font::FONT_SIZE_8;
|
||||
dd.y += Lcd::LCD_LINE_PER_PAGE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ind += 3;
|
||||
}
|
||||
ptr[cnt] = get_font_data(utf8, rows, cols) + 2; // skip height and widht data
|
||||
dd.cnt = custom_font::get_string_font(number, dd.ptr, size);
|
||||
disp_data_.save(dd, true);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
|
||||
return cnt;
|
||||
printf("Finished testing count from %d\n", cnt);
|
||||
}
|
||||
|
||||
void ui_mgr::thread_display(void)
|
||||
{
|
||||
DISPDATA dd;
|
||||
bool first = true;
|
||||
int wait = 10;
|
||||
|
||||
// welcome
|
||||
{
|
||||
uint8_t *ptr[] = {welcome + 2};
|
||||
lcd_->write_line(welcome[1], welcome[0], 1, ptr);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||
uint8_t *ptr[] = {welcome};
|
||||
lcd_->write_line(ptr, 1);
|
||||
}
|
||||
|
||||
while(run_)
|
||||
{
|
||||
if(disp_data_.take(dd, true, SEC_2_MS(3)))
|
||||
if(disp_data_.take(dd, true, SEC_2_MS(wait)))
|
||||
{
|
||||
if(dd.cnt)
|
||||
lcd_->write_line(dd.rows, dd.cols, dd.cnt, dd.ptr, dd.x, dd.y, dd.mask);
|
||||
if(dd.ptr[0])
|
||||
lcd_->write_line(dd.ptr, dd.cnt, dd.x, dd.y, dd.mask);
|
||||
else
|
||||
lcd_->clear();
|
||||
lcd_->clear(dd.x, dd.y, dd.cnt, dd.mask);
|
||||
wait = 3;
|
||||
}
|
||||
else if(ready_enable_)
|
||||
{
|
||||
int elapse = first ? 10 : get_ready_watch_ms() / SEC_2_MS(1);
|
||||
|
||||
first = false;
|
||||
if(elapse >= 3)
|
||||
if(get_ready_watch_ms() / SEC_2_MS(1) >= wait)
|
||||
display_ready();
|
||||
}
|
||||
}
|
||||
|
@ -747,7 +794,7 @@ void ui_mgr::display_ready(void)
|
|||
menu_mode_ = false;
|
||||
lcd_->clear();
|
||||
|
||||
lcd_->write_line(ready_.rows, ready_.cols, ready_.cnt, ready_.ptr, ready_.x, ready_.y, ready_.mask);
|
||||
lcd_->write_line(ready_.ptr, ready_.cnt, ready_.x, ready_.y, ready_.mask);
|
||||
}
|
||||
void ui_mgr::set_ready_status_enabled(bool enable)
|
||||
{
|
||||
|
@ -770,6 +817,20 @@ int ui_mgr::get_ready_watch_ms(void)
|
|||
void ui_mgr::key_event(int key)
|
||||
{
|
||||
reset_ready_watch();
|
||||
set_ready_status_enabled(true);
|
||||
|
||||
if(!menu_mode_)
|
||||
{
|
||||
menu_mode_ = true;
|
||||
if(cur_)
|
||||
cur_->release();
|
||||
cur_ = root_;
|
||||
if(cur_)
|
||||
cur_->add_ref();
|
||||
refresh_lcd(true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(key == (int)KeyMonitor::HGKey::Key_Menu)
|
||||
enter();
|
||||
|
|
|
@ -94,6 +94,10 @@ class ui_mgr : public refer
|
|||
volatile bool run_ = true;
|
||||
volatile bool ready_enable_ = true;
|
||||
SIZE font_size_ = {16, 16};
|
||||
POINT hold_pos_ = {0, 0};
|
||||
|
||||
uint32_t his_cnt_;
|
||||
uint32_t rol_cnt_;
|
||||
|
||||
std::map<int, MENU_CMD_CALLBACK> handler_;
|
||||
std::unique_ptr<Lcd> lcd_;
|
||||
|
@ -105,24 +109,23 @@ class ui_mgr : public refer
|
|||
void refresh_lcd(bool cur_at_top);
|
||||
void move_to(bool next);
|
||||
void enter(void);
|
||||
int get_string_font(const char* text, uint8_t** ptr, uint8_t* rows, uint8_t* cols);
|
||||
|
||||
typedef struct _disp_data
|
||||
{
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
uint8_t rows;
|
||||
uint8_t cols;
|
||||
uint8_t cnt; // 0 to clear
|
||||
uint8_t mask;
|
||||
uint8_t cnt; // clear width when ptr[0] == nullptr
|
||||
uint8_t mask; // clear height when ptr[0] == nullptr
|
||||
uint8_t *ptr[16];
|
||||
}DISPDATA;
|
||||
|
||||
MUTEX ready_lck_;
|
||||
chronograph ready_watch_;
|
||||
DISPDATA ready_;
|
||||
safe_fifo<DISPDATA> disp_data_;
|
||||
std::unique_ptr<std::thread> disp_thrd_;
|
||||
MUTEX ready_lck_;
|
||||
chronograph ready_watch_;
|
||||
DISPDATA ready_;
|
||||
safe_fifo<DISPDATA> disp_data_;
|
||||
safe_thread disp_thrd_;
|
||||
|
||||
void thread_test_hold_ui(void);
|
||||
void thread_display(void);
|
||||
void display_ready(void);
|
||||
void set_ready_status_enabled(bool enable);
|
||||
|
|
991
ui/font.cpp
991
ui/font.cpp
File diff suppressed because it is too large
Load Diff
36
ui/font.h
36
ui/font.h
|
@ -4,4 +4,38 @@
|
|||
#pragma once
|
||||
#include <base/utils.h>
|
||||
|
||||
uint8_t* get_font_data(const char* str, uint8_t* rows, uint8_t* cols);
|
||||
|
||||
namespace custom_font
|
||||
{
|
||||
enum font_size
|
||||
{
|
||||
FONT_SIZE_8 = 0,
|
||||
FONT_SIZE_16,
|
||||
FONT_SIZE_24,
|
||||
FONT_SIZE_32,
|
||||
};
|
||||
|
||||
// Function: get character font dot-array data
|
||||
//
|
||||
// Parameters: str - character
|
||||
//
|
||||
// fs - font height
|
||||
//
|
||||
// Return: the dot array buffer (do not free the buffer)
|
||||
//
|
||||
// NOTE: the ptr[0] is cols and ptr[1] is rows, real dot-array data started from ptr[2]
|
||||
uint8_t* get_font_data(const char* str, font_size fs = FONT_SIZE_16);
|
||||
|
||||
// Function: get string font dot-array data
|
||||
//
|
||||
// Parameters: text - string
|
||||
//
|
||||
// ptr - to receive the font data (do not free the buffer), user should ensure enough space
|
||||
//
|
||||
// NOTE: the ptr[i][0] is cols and ptr[i][1] is rows, real dot-array data started from ptr[i][2]
|
||||
//
|
||||
// fs - font height
|
||||
//
|
||||
// Return: words of the text or valid data put in ptr
|
||||
int get_string_font(const char* text, uint8_t** ptr, custom_font::font_size fs = FONT_SIZE_16);
|
||||
};
|
||||
|
|
|
@ -60,8 +60,8 @@ add_packagedirs("sdk")
|
|||
add_defines("BUILD_AS_DEVICE")
|
||||
add_defines("VER_MAIN=2")
|
||||
add_defines("VER_FAMILY=200")
|
||||
add_defines("VER_DATE=20240205")
|
||||
add_defines("VER_BUILD=15")
|
||||
add_defines("VER_DATE=20240206")
|
||||
add_defines("VER_BUILD=21")
|
||||
|
||||
target("conf")
|
||||
set_kind("phony")
|
||||
|
|
Loading…
Reference in New Issue