优化菜单显示
This commit is contained in:
parent
f7a095f7b4
commit
8ea7ea4e82
|
@ -18,13 +18,15 @@
|
|||
|
||||
|
||||
|
||||
#define WORDS_MENU_RETURN "\350\277\224\345\233\236\344\270\212\344\270\200\347\272\247\350\217\234\345\215\225"
|
||||
#define WORDS_MENU_SELECTED "\342\210\232"
|
||||
#define WORDS_MENU_RETURN "\350\277\224\345\233\236\344\270\212\347\272\247\350\217\234\345\215\225"
|
||||
#define WORDS_MENU_SEPARATE_STRENGTH "\345\210\206\347\272\270\345\274\272\345\272\246"
|
||||
#define WORDS_MENU_LOW "\344\275\216"
|
||||
#define WORDS_MENU_MID "\344\270\255"
|
||||
#define WORDS_MENU_HIGH "\351\253\230"
|
||||
#define WORDS_MENU_POWER "\344\274\221\347\234\240\346\227\266\351\227\264"
|
||||
#define WORDS_MENU_SLEEP_NONE "\344\270\215\344\274\221\347\234\240"
|
||||
#define WORDS_MENU_SLEEP_NOW "\347\253\213\345\215\263\344\274\221\347\234\240"
|
||||
#define WORDS_MENU_SLEEP_5_MIN "5min"
|
||||
#define WORDS_MENU_SLEEP_10_MIN "10min"
|
||||
#define WORDS_MENU_SLEEP_20_MIN "20min"
|
||||
|
@ -39,7 +41,6 @@
|
|||
#define WORDS_MENU_HISTORY_COUNT "\345\216\206\345\217\262\345\274\240\346\225\260"
|
||||
#define WORDS_MENU_ROLLER_COUNT "\346\273\232\350\275\264\345\274\240\346\225\260"
|
||||
#define WORDS_MENU_RESET_ROLLOER_CNT "\346\270\205\351\231\244\346\273\232\350\275\264\345\274\240\346\225\260"
|
||||
#define WORDS_MENU_SLEEP_NOW "\350\277\233\345\205\245\344\274\221\347\234\240"
|
||||
#define WORDS_MENU_SHUTDOWN "\345\205\263\346\234\272"
|
||||
#define WORDS_MENU_YES "\347\241\256\345\256\232"
|
||||
#define WORDS_MENU_NO "\345\217\226\346\266\210"
|
133
ui/dev_menu.cpp
133
ui/dev_menu.cpp
|
@ -9,7 +9,10 @@
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// dev_menu
|
||||
dev_menu::dev_menu()
|
||||
dev_menu::dev_menu(bool check_item
|
||||
, bool need_ret_parent)
|
||||
: check_item_(check_item)
|
||||
, need_ret_parent_(need_ret_parent)
|
||||
{}
|
||||
dev_menu::~dev_menu()
|
||||
{
|
||||
|
@ -53,6 +56,8 @@ void dev_menu::set_parent(dev_menu* parent)
|
|||
if(parent_)
|
||||
{
|
||||
parent_->add_ref();
|
||||
if(need_ret_parent_)
|
||||
{
|
||||
if(!items_.size() || items_[0].id != MENU_ID_RETURN)
|
||||
{
|
||||
MITEM mi;
|
||||
|
@ -60,6 +65,9 @@ void dev_menu::set_parent(dev_menu* parent)
|
|||
mi.leaf = true;
|
||||
mi.id = MENU_ID_RETURN;
|
||||
items_.insert(items_.begin(), mi);
|
||||
if(sel_ != -1)
|
||||
sel_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,13 +151,13 @@ bool dev_menu::select(const char* txt)
|
|||
if(ind == -1)
|
||||
return false;
|
||||
|
||||
cur_ = ind;
|
||||
sel_ = ind;
|
||||
|
||||
return true;
|
||||
}
|
||||
void dev_menu::reset_pos(void)
|
||||
{
|
||||
cur_ = 0;
|
||||
cur_ = sel_ == -1 ? 0 : sel_;
|
||||
}
|
||||
|
||||
dev_menu* dev_menu::enter(int* id)
|
||||
|
@ -168,7 +176,11 @@ dev_menu* dev_menu::enter(int* id)
|
|||
menu = parent_;
|
||||
}
|
||||
else if(id)
|
||||
{
|
||||
*id = items_[cur_].id;
|
||||
if(check_item_)
|
||||
sel_ = cur_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -181,11 +193,13 @@ dev_menu* dev_menu::enter(int* id)
|
|||
|
||||
return menu;
|
||||
}
|
||||
int dev_menu::get_menu_text(std::vector<std::string>& text)
|
||||
int dev_menu::get_menu_text(std::vector<std::string>& text, int& sel)
|
||||
{
|
||||
for(auto& v: items_)
|
||||
text.push_back(v.text);
|
||||
|
||||
sel = sel_;
|
||||
|
||||
return cur_;
|
||||
}
|
||||
|
||||
|
@ -196,10 +210,35 @@ int dev_menu::get_menu_text(std::vector<std::string>& text)
|
|||
// ui_mgr
|
||||
enum
|
||||
{
|
||||
MENU_CMD_ID_GET_ROLLER_COUNT = 0x100,
|
||||
MENU_CMD_ID_CLEAR_ROLLER_COUNT,
|
||||
MENU_CMD_ID_SLEEP_NOW,
|
||||
MENU_CMD_ID_SHUTDOWN,
|
||||
MENU_CMD_ID_CANCEL = 0,
|
||||
|
||||
MENU_CMD_ID_SEPARATE_LOW = 0x10,
|
||||
MENU_CMD_ID_SEPARATE_MID,
|
||||
MENU_CMD_ID_SEPARATE_HIGH,
|
||||
|
||||
MENU_CMD_ID_SLEEP_NEVER = 0x20,
|
||||
MENU_CMD_ID_SLEEP_IMMEDIATELY,
|
||||
MENU_CMD_ID_SLEEP_5MIN,
|
||||
MENU_CMD_ID_SLEEP_10MIN,
|
||||
MENU_CMD_ID_SLEEP_20MIN,
|
||||
MENU_CMD_ID_SLEEP_30MIN,
|
||||
MENU_CMD_ID_SLEEP_1H,
|
||||
MENU_CMD_ID_SLEEP_2H,
|
||||
MENU_CMD_ID_SLEEP_4H,
|
||||
|
||||
MENU_CMD_ID_LIFTER_LOW = 0x30,
|
||||
MENU_CMD_ID_LIFTER_MID,
|
||||
MENU_CMD_ID_LIFTER_HIGH,
|
||||
|
||||
MENU_CMD_ID_COUNT_MODE = 0x40,
|
||||
MENU_CMD_ID_HANDLE_MODE = 0x50,
|
||||
MENU_CMD_ID_CLEAR_PASSWAY = 0x60,
|
||||
MENU_CMD_ID_GET_HISTORY_COUNT = 0x70,
|
||||
|
||||
MENU_CMD_ID_CLEAR_ROLLER_CNT = 0x80,
|
||||
MENU_CMD_ID_GET_ROLLER_COUNT,
|
||||
|
||||
MENU_CMD_ID_SHUTDOWN = 0x90,
|
||||
};
|
||||
|
||||
ui_mgr::ui_mgr() : disp_data_("lcd-msg")
|
||||
|
@ -246,52 +285,61 @@ void ui_mgr::init(void)
|
|||
|
||||
// 分纸强度(低中高)
|
||||
{
|
||||
child = new dev_menu();
|
||||
child->add_menu(WORDS_MENU_LOW, (int)DisType::Dis_Set_PollPI_Low);
|
||||
child->add_menu(WORDS_MENU_MID, (int)DisType::Dis_Set_PollPI_Mid);
|
||||
child->add_menu(WORDS_MENU_HIGH, (int)DisType::Dis_Set_PollPI_High);
|
||||
child = new dev_menu(true);
|
||||
child->add_menu(WORDS_MENU_LOW, MENU_CMD_ID_SEPARATE_LOW);
|
||||
child->add_menu(WORDS_MENU_MID, MENU_CMD_ID_SEPARATE_MID);
|
||||
child->add_menu(WORDS_MENU_HIGH, MENU_CMD_ID_SEPARATE_HIGH);
|
||||
child->select(WORDS_MENU_MID);
|
||||
root_->add_menu(WORDS_MENU_SEPARATE_STRENGTH, child);
|
||||
child->release();
|
||||
}
|
||||
// 休眠时间(不休眠,5min, 10min, 20min, 30min, 1h, 2h, 4h)
|
||||
{
|
||||
child = new dev_menu();
|
||||
child->add_menu(WORDS_MENU_SLEEP_NONE, (int)DisType::Dis_Set_SleepMode_NEVER);
|
||||
child->add_menu(WORDS_MENU_SLEEP_5_MIN, (int)DisType::Dis_Set_SleepMode_5M);
|
||||
child->add_menu(WORDS_MENU_SLEEP_10_MIN, (int)DisType::Dis_Set_SleepMode_10M);
|
||||
child->add_menu(WORDS_MENU_SLEEP_20_MIN, (int)DisType::Dis_Set_SleepMode_20M);
|
||||
child->add_menu(WORDS_MENU_SLEEP_30_MIN, (int)DisType::Dis_Set_SleepMode_30M);
|
||||
child->add_menu(WORDS_MENU_SLEEP_1_HOUR, (int)DisType::Dis_Set_SleepMode_1H);
|
||||
child->add_menu(WORDS_MENU_SLEEP_2_HOUR, (int)DisType::Dis_Set_SleepMode_2H);
|
||||
child->add_menu(WORDS_MENU_SLEEP_4_HOUR, (int)DisType::Dis_Set_SleepMode_4H);
|
||||
child = new dev_menu(true);
|
||||
child->add_menu(WORDS_MENU_SLEEP_NONE, MENU_CMD_ID_SLEEP_NEVER);
|
||||
child->add_menu(WORDS_MENU_SLEEP_NOW, MENU_CMD_ID_SLEEP_IMMEDIATELY);
|
||||
child->add_menu(WORDS_MENU_SLEEP_5_MIN, MENU_CMD_ID_SLEEP_5MIN);
|
||||
child->add_menu(WORDS_MENU_SLEEP_10_MIN, MENU_CMD_ID_SLEEP_10MIN);
|
||||
child->add_menu(WORDS_MENU_SLEEP_20_MIN, MENU_CMD_ID_SLEEP_20MIN);
|
||||
child->add_menu(WORDS_MENU_SLEEP_30_MIN, MENU_CMD_ID_SLEEP_30MIN);
|
||||
child->add_menu(WORDS_MENU_SLEEP_1_HOUR, MENU_CMD_ID_SLEEP_1H);
|
||||
child->add_menu(WORDS_MENU_SLEEP_2_HOUR, MENU_CMD_ID_SLEEP_2H);
|
||||
child->add_menu(WORDS_MENU_SLEEP_4_HOUR, MENU_CMD_ID_SLEEP_4H);
|
||||
child->select(WORDS_MENU_SLEEP_NONE);
|
||||
root_->add_menu(WORDS_MENU_POWER, child);
|
||||
child->release();
|
||||
}
|
||||
// 升降台位置(低中高)
|
||||
{
|
||||
child = new dev_menu();
|
||||
child->add_menu(WORDS_MENU_LOW, (int)DisType::Dis_Set_TrayPosition_Low);
|
||||
child->add_menu(WORDS_MENU_MID, (int)DisType::Dis_Set_TrayPosition_Mid);
|
||||
child->add_menu(WORDS_MENU_HIGH, (int)DisType::Dis_Set_TrayPosition_High);
|
||||
child = new dev_menu(true);
|
||||
child->add_menu(WORDS_MENU_LOW, MENU_CMD_ID_LIFTER_LOW);
|
||||
child->add_menu(WORDS_MENU_MID, MENU_CMD_ID_LIFTER_MID);
|
||||
child->add_menu(WORDS_MENU_HIGH, MENU_CMD_ID_LIFTER_HIGH);
|
||||
child->select(WORDS_MENU_LOW);
|
||||
root_->add_menu(WORDS_MENU_LIFTER_POS, child);
|
||||
child->release();
|
||||
}
|
||||
|
||||
// 计数模式、手动模式、清理纸道、历史张数、滚轴张数、清除滚轴张数(确定,取消)、进入休眠、关机
|
||||
root_->add_menu(WORDS_MENU_COUNT_MODE, (int)DisType::Dis_Count_Page);
|
||||
root_->add_menu(WORDS_MENU_MANUAL_MODE, (int)DisType::Dis_HandMode);
|
||||
root_->add_menu(WORDS_MENU_CLEAR_PASSWAY, (int)DisType::Dis_Set_ClearPaperPass);
|
||||
root_->add_menu(WORDS_MENU_HISTORY_COUNT, (int)DisType::Dis_Set_Get_History_ScanNum);
|
||||
root_->add_menu(WORDS_MENU_COUNT_MODE, MENU_CMD_ID_COUNT_MODE);
|
||||
root_->add_menu(WORDS_MENU_MANUAL_MODE, MENU_CMD_ID_HANDLE_MODE);
|
||||
root_->add_menu(WORDS_MENU_CLEAR_PASSWAY, MENU_CMD_ID_CLEAR_PASSWAY);
|
||||
root_->add_menu(WORDS_MENU_HISTORY_COUNT, MENU_CMD_ID_GET_HISTORY_COUNT);
|
||||
root_->add_menu(WORDS_MENU_ROLLER_COUNT, MENU_CMD_ID_GET_ROLLER_COUNT);
|
||||
{
|
||||
child = new dev_menu();
|
||||
child->add_menu(WORDS_MENU_YES, (int)DisType::Dis_Set_YES);
|
||||
child->add_menu(WORDS_MENU_NO, (int)DisType::Dis_Set_No);
|
||||
child = new dev_menu(false, false);
|
||||
child->add_menu(WORDS_MENU_YES, MENU_CMD_ID_CLEAR_ROLLER_CNT);
|
||||
child->add_menu(WORDS_MENU_NO, MENU_CMD_ID_CANCEL);
|
||||
root_->add_menu(WORDS_MENU_RESET_ROLLOER_CNT, child);
|
||||
child->release();
|
||||
}
|
||||
root_->add_menu(WORDS_MENU_SLEEP_NOW, MENU_CMD_ID_SLEEP_NOW);
|
||||
root_->add_menu(WORDS_MENU_SHUTDOWN, MENU_CMD_ID_SHUTDOWN);
|
||||
{
|
||||
child = new dev_menu(false, false);
|
||||
child->add_menu(WORDS_MENU_YES, MENU_CMD_ID_SHUTDOWN);
|
||||
child->add_menu(WORDS_MENU_NO, MENU_CMD_ID_CANCEL);
|
||||
root_->add_menu(WORDS_MENU_SHUTDOWN, child);
|
||||
child->release();
|
||||
}
|
||||
|
||||
cur_ = root_;
|
||||
cur_->add_ref();
|
||||
|
@ -309,25 +357,25 @@ void ui_mgr::clear(void)
|
|||
void ui_mgr::refresh_lcd(bool cur_at_top)
|
||||
{
|
||||
std::vector<std::string> text, disp;
|
||||
int cur = cur_->get_menu_text(text), sel = 0,
|
||||
int val = -1, cur = cur_->get_menu_text(text, val), sel = 0,
|
||||
rows = Lcd::LCD_HEIGHT / font_size_.cy;
|
||||
|
||||
if(cur >= 0 && cur < text.size())
|
||||
{
|
||||
disp.push_back(text[cur]);
|
||||
disp.push_back(cur == val ? WORDS_MENU_SELECTED + text[cur] : text[cur]);
|
||||
if(cur_at_top)
|
||||
{
|
||||
for(int i = cur + 1; i < text.size() && disp.size() < rows; ++i)
|
||||
disp.push_back(text[i]);
|
||||
disp.push_back(i == val ? WORDS_MENU_SELECTED + text[i] : text[i]);
|
||||
for(int i = cur - 1; i >= 0 && disp.size() < rows; --i, sel++)
|
||||
disp.insert(disp.begin(), text[i]);
|
||||
disp.insert(disp.begin(), i == val ? WORDS_MENU_SELECTED + text[i] : text[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = cur - 1; i >= 0 && disp.size() < rows; --i, sel++)
|
||||
disp.insert(disp.begin(), text[i]);
|
||||
disp.insert(disp.begin(), i == val ? WORDS_MENU_SELECTED + text[i] : text[i]);
|
||||
for(int i = cur + 1; i < text.size() && disp.size() < rows; ++i)
|
||||
disp.push_back(text[i]);
|
||||
disp.push_back(i == val ? WORDS_MENU_SELECTED + text[i] : text[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,14 +388,13 @@ void ui_mgr::refresh_lcd(bool cur_at_top)
|
|||
if(i == 0)
|
||||
disp_data_.save(dd, true);
|
||||
dd.mask = i == sel ? 0x0ff : 0;
|
||||
dd.x = font_size_.cx;
|
||||
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);
|
||||
cur = disp_data_.save(dd, true);
|
||||
rows += font_size_.cy;
|
||||
printf("display '%s', queue = %d, mask = %02x\n", disp[i].c_str(), cur, dd.mask);
|
||||
}
|
||||
}
|
||||
void ui_mgr::move_to(bool next)
|
||||
|
@ -433,7 +480,7 @@ void ui_mgr::thread_display(void)
|
|||
|
||||
void ui_mgr::key_event(int key)
|
||||
{
|
||||
if(key == (int)KeyMonitor::HGKey::Key_Enter)
|
||||
if(key == (int)KeyMonitor::HGKey::Key_Menu)
|
||||
enter();
|
||||
else if(key == (int)KeyMonitor::HGKey::Key_Left)
|
||||
move_to(false);
|
||||
|
|
|
@ -43,11 +43,14 @@ class dev_menu : public refer
|
|||
}MITEM;
|
||||
std::vector<MITEM> items_;
|
||||
int cur_ = 0;
|
||||
int sel_ = -1;
|
||||
bool check_item_ = false;
|
||||
bool need_ret_parent_ = true;
|
||||
|
||||
int find_item(const char* text);
|
||||
|
||||
public:
|
||||
dev_menu();
|
||||
dev_menu(bool check_item = false, bool need_ret_parent = true);
|
||||
|
||||
protected:
|
||||
virtual ~dev_menu();
|
||||
|
@ -58,6 +61,7 @@ public:
|
|||
bool add_menu(const char* text, int id);
|
||||
bool add_menu(const char* text, dev_menu* submenu);
|
||||
bool remove_menu(const char* text);
|
||||
void set_need_return_parent(bool need);
|
||||
bool move_to(bool next); // true - move to next, false - move to previous. if at end position of move direction, return false
|
||||
bool select(const char* txt);
|
||||
void reset_pos(void);
|
||||
|
@ -73,8 +77,10 @@ public:
|
|||
//
|
||||
// Parameter: text - to receive the menu text
|
||||
//
|
||||
// sel - to receive current setting index
|
||||
//
|
||||
// Return: current menu index
|
||||
int get_menu_text(std::vector<std::string>& text);
|
||||
int get_menu_text(std::vector<std::string>& text, int& sel);
|
||||
};
|
||||
|
||||
|
||||
|
|
24
ui/font.cpp
24
ui/font.cpp
|
@ -22,6 +22,12 @@ class font_init
|
|||
public:
|
||||
font_init()
|
||||
{
|
||||
static uint8_t right[] = {16, 16
|
||||
, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x3C, 0x04, 0x00
|
||||
, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x06, 0x1C, 0x30, 0x78, 0x0F, 0x01, 0x00, 0x00, 0x00
|
||||
};
|
||||
font_map_["\342\210\232"] = right;
|
||||
|
||||
static uint8_t fan[] = {16, 16
|
||||
, 0x00, 0x40, 0x40, 0x42, 0xCC, 0x48, 0x00, 0xFC, 0xFC, 0x24, 0x24, 0x24, 0x24, 0xA6, 0xE2, 0x00
|
||||
, 0x00, 0x00, 0xC0, 0x20, 0x3F, 0x20, 0x58, 0x4F, 0xA1, 0x90, 0x91, 0x8E, 0x86, 0x87, 0x98, 0xB8
|
||||
|
@ -358,6 +364,24 @@ static uint8_t xiao[] = {16, 16
|
|||
};
|
||||
font_map_["\346\266\210"] = xiao;
|
||||
|
||||
static uint8_t chu[] = {16, 16
|
||||
, 0x00, 0x00, 0xFE, 0x02, 0x62, 0x9E, 0x06, 0x40, 0x30, 0x58, 0x4E, 0xC3, 0x44, 0x58, 0x70, 0x60
|
||||
, 0x00, 0x00, 0xFF, 0x00, 0x08, 0x19, 0x4F, 0x60, 0xBA, 0x9A, 0x82, 0xFF, 0x02, 0x0A, 0x12, 0x62
|
||||
};
|
||||
font_map_["\351\231\244"] = chu;
|
||||
|
||||
static uint8_t li[] = {16, 16
|
||||
, 0x00, 0x00, 0x00, 0x08, 0x08, 0x48, 0x88, 0x09, 0x0B, 0x0E, 0x08, 0x08, 0xE8, 0x48, 0x08, 0x08
|
||||
, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x4F, 0x5E, 0x40, 0x40, 0x70, 0x5F, 0x43, 0x40, 0x40, 0x40
|
||||
};
|
||||
font_map_["\347\253\213"] = li;
|
||||
|
||||
static uint8_t ji4s[] = {16, 16
|
||||
, 0x00, 0x00, 0xFE, 0xFE, 0x92, 0x92, 0x92, 0xFE, 0x02, 0x00, 0xFE, 0xFE, 0x02, 0x02, 0x02, 0xFE
|
||||
, 0x00, 0x00, 0x3F, 0x3F, 0x20, 0x12, 0x14, 0x1D, 0x38, 0x00, 0xFF, 0xFF, 0x08, 0x08, 0x18, 0x1F
|
||||
};
|
||||
font_map_["\345\215\263"] = ji4s;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ KeyMonitor::KeyMonitor(std::function<void(int)> keycall) : m_keycall(keycall)
|
|||
auto pincall=[&](int pin)
|
||||
{
|
||||
auto value= read_key();
|
||||
printf("Key = %02x pin value = %d \n",value,pin);
|
||||
// printf("Key = %02x pin value = %d \n",value,pin);
|
||||
if(m_keycall)
|
||||
m_keycall(value);
|
||||
};
|
||||
|
|
|
@ -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=20240202")
|
||||
add_defines("VER_BUILD=58")
|
||||
add_defines("VER_DATE=20240204")
|
||||
add_defines("VER_BUILD=8")
|
||||
|
||||
target("conf")
|
||||
set_kind("phony")
|
||||
|
|
Loading…
Reference in New Issue