diff --git a/ui/Lcd.cpp b/ui/Lcd.cpp index c3702d7..813531f 100644 --- a/ui/Lcd.cpp +++ b/ui/Lcd.cpp @@ -506,6 +506,12 @@ static unsigned char ascii_table_5x8[95][5] = { Lcd::Lcd() : spi_sck(51), spi_sda(72), spi_cs(154), spi_reset(150), spi_rs(156),COM_BOOT0(153) { + for(auto& v: line_field_) + { + v.x = 0; + v.w = LCD_WIDTH; + } + printf("Lcd()\n"); write_dev(IOEXPORTPATH,51); write_dev(IOEXPORTPATH,72); @@ -837,6 +843,31 @@ void Lcd::clear(int x, int y, int w, int h) write_end(); } } +void Lcd::clear_pages(int* page_inds, int count) +{ + static int ind[LCD_HEIGHT / LCD_LINE_PER_PAGE] = {0}; + if(ind[1] == 0) + { + for(int i = 0; i < _countof(ind); ++i) + ind[i] = i; + } + + if(page_inds == nullptr || count == 0) + { + page_inds = ind; + count = _countof(ind); + } + + for(int i = 0; i < count; ++i) + { + go_to(page_inds[i], line_field_[page_inds[i]].x); + write_before(); + set_data_type(true); + for(int c = 0; c < line_field_[page_inds[i]].w; ++c) + write_char(0); + write_end(); + } +} void Lcd::write_line(uint8_t** data, uint8_t cnt, int x, int y, uint8_t mask) { uint8_t *ptr[16] = {0}, @@ -848,7 +879,12 @@ void Lcd::write_line(uint8_t** data, uint8_t cnt, int x, int y, uint8_t mask) for(int r = 0; r < data[0][1] / LCD_LINE_PER_PAGE; ++r) { - go_to(y / LCD_LINE_PER_PAGE + r, x); + int page = y / LCD_LINE_PER_PAGE + r, w = 0; + + if(line_field_[page].x > x) + line_field_[page].x = x; + + go_to(page, x); write_before(); set_data_type(true); @@ -856,11 +892,61 @@ void Lcd::write_line(uint8_t** data, uint8_t cnt, int x, int y, uint8_t mask) { for(int c = 0; c < data[ind][0]; ++c) { + w++; write_char(*ptr[ind]++, mask); } write_char(0, mask); + w++; } write_end(); + if(line_field_[page].x + line_field_[page].w < x + w) + line_field_[page].w = x + w - line_field_[page].x; + } +} +void Lcd::write_whole_line(uint8_t** data, uint8_t cnt, int x, int y, uint8_t mask) +{ + 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] + 2; + + for(int r = 0; r < data[0][1] / LCD_LINE_PER_PAGE; ++r) + { + int page = y / LCD_LINE_PER_PAGE + r, w = 0, + start = x <= line_field_[page].x ? x : line_field_[page].x, + end = line_field_[page].x + line_field_[page].w, + blank = x - start; + + line_field_[page].x = x; + + go_to(page, start); + write_before(); + set_data_type(true); + + // clear previous bits ... + for(int space = 0; space < blank; ++space) + write_char(0); + + for(int ind = 0; ind < cnt; ++ind) + { + for(int c = 0; c < data[ind][0]; ++c) + { + w++; + write_char(*ptr[ind]++, mask); + } + write_char(0, mask); + w++; + } + + // clear rear bits ... + end -= x + w; + for(int space = 0; space < end; ++space) + write_char(0); + line_field_[page].w = x + w - line_field_[page].x; + + write_end(); } } diff --git a/ui/Lcd.h b/ui/Lcd.h index 2cbad18..5f0b1f6 100644 --- a/ui/Lcd.h +++ b/ui/Lcd.h @@ -69,7 +69,9 @@ public: 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** data, uint8_t cnt, int x = 0, int y = 0, uint8_t mask = 0); + void write_whole_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); + void clear_pages(int* page_inds = nullptr, int count = 0); private: void set_data_type(bool data); @@ -77,6 +79,13 @@ private: void write_char(uint8_t val, uint8_t mask = 0); void write_end(void); +private: + typedef struct _page_range + { + int x; + int w; + }PAGERANGE; + PAGERANGE line_field_[LCD_HEIGHT / LCD_LINE_PER_PAGE]; }; diff --git a/ui/dev_menu.cpp b/ui/dev_menu.cpp index 26e6afa..6e7b1fb 100644 --- a/ui/dev_menu.cpp +++ b/ui/dev_menu.cpp @@ -403,7 +403,7 @@ static uint8_t qiaoting[] = {128, 32 } }; -#define TEST_PLATFORM_EVENT +// #define TEST_PLATFORM_EVENT #ifdef TEST_PLATFORM_EVENT platform_event to__("to"); #endif @@ -488,11 +488,13 @@ ui_mgr::ui_mgr() : disp_data_("lcd-msg") paper_total_ = 0; memset(&dd, 0, sizeof(dd)); dd.cnt = dd.mask = -1; + dd.method = DISP_METHOD_CLEAR; disp_data_.save(dd, true); dd.mask = 0; dd.cnt = custom_font::get_string_font(pack->data[0] == devui::SCAN_NORMAL ? WORDS_STATUS_SCANNING_NORMAL : WORDS_STATUS_SCANNING_COUNT, dd.ptr); hold_pos_.x = dd.ptr[0][0] * 1; hold_pos_.y = dd.ptr[0][1]; + dd.method = DISP_METHOD_WHOLE_LINE; disp_data_.save(dd, true); } } @@ -513,6 +515,7 @@ ui_mgr::ui_mgr() : disp_data_("lcd-msg") sprintf(num, "%03d", paper_cnt_); dd.x = hold_pos_.x; dd.y = hold_pos_.y; + dd.method = DISP_METHOD_PART_LINE; dd.cnt = custom_font::get_string_font(num, dd.ptr); cnt = disp_data_.save(dd, true); @@ -692,10 +695,12 @@ void ui_mgr::init(void) memset(&dd, 0, sizeof(dd)); dd.cnt = dd.mask = -1; + dd.method = DISP_METHOD_CLEAR; disp_data_.save(dd, true); dd.mask = 0; dd.cnt = custom_font::get_string_font(WORDS_MENU_COUNT_MODE, dd.ptr); + dd.method = DISP_METHOD_WHOLE_LINE; disp_data_.save(dd, true); dd.y = dd.ptr[0][1]; @@ -705,6 +710,7 @@ void ui_mgr::init(void) hold_pos_.x += dd.ptr[i][0] + 1; hold_pos_.y = dd.y; hold_pos_.x += 2; + dd.method = DISP_METHOD_PART_LINE; disp_data_.save(dd, true); devui::send_message(devui::UI_CMD_COUNT_PAPER); @@ -736,11 +742,12 @@ void ui_mgr::init(void) DISPDATA dd; memset(&dd, 0, sizeof(dd)); - dd.cnt = dd.mask = -1; - disp_data_.save(dd, true); + // 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); + dd.method = DISP_METHOD_WHOLE_LINE; disp_data_.save(dd, true); dd.y = dd.ptr[0][1]; @@ -760,11 +767,12 @@ void ui_mgr::init(void) char cnt[40] = {0}; memset(&dd, 0, sizeof(dd)); - dd.cnt = dd.mask = -1; - disp_data_.save(dd, true); + // 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); + dd.method = DISP_METHOD_WHOLE_LINE; disp_data_.save(dd, true); dd.y = dd.ptr[0][1]; @@ -851,6 +859,7 @@ void ui_mgr::init(void) dd.y = 0; dd.cnt = 1; dd.ptr[0] = welcome::get_current_pic(); + dd.method = DISP_METHOD_WHOLE_LINE; disp_data_.save(dd, true); return false; @@ -902,15 +911,11 @@ void ui_mgr::refresh_lcd(bool cur_at_top) DISPDATA dd; 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.cnt = custom_font::get_string_font(disp[i].c_str(), dd.ptr); + dd.method = DISP_METHOD_WHOLE_LINE; cur = disp_data_.save(dd, true); rows += font_size_.cy; } @@ -963,10 +968,12 @@ void ui_mgr::thread_display(void) { if(disp_data_.take(dd, true, SEC_2_MS(wait))) { - if(dd.ptr[0]) + if(dd.method == DISP_METHOD_PART_LINE) lcd_->write_line(dd.ptr, dd.cnt, dd.x, dd.y, dd.mask); - else + else if(dd.method == DISP_METHOD_CLEAR) lcd_->clear(dd.x, dd.y, dd.cnt, dd.mask); + else if(dd.method == DISP_METHOD_WHOLE_LINE) + lcd_->write_whole_line(dd.ptr, dd.cnt, dd.x, dd.y, dd.mask); wait = 6; } else if(ready_enable_) @@ -981,9 +988,9 @@ void ui_mgr::display_ready(void) set_ready_status_enabled(false); menu_mode_ = false; - lcd_->clear(); + // lcd_->clear(); - lcd_->write_line(ready_.ptr, ready_.cnt, ready_.x, ready_.y, ready_.mask); + lcd_->write_whole_line(ready_.ptr, ready_.cnt, ready_.x, ready_.y, ready_.mask); } void ui_mgr::set_ready_status_enabled(bool enable) { diff --git a/ui/dev_menu.h b/ui/dev_menu.h index 2b05e67..56eb4b7 100644 --- a/ui/dev_menu.h +++ b/ui/dev_menu.h @@ -282,10 +282,17 @@ class ui_mgr : public refer void move_to(bool next); void enter(void); + enum dispaly_method + { + DISP_METHOD_CLEAR = 0, + DISP_METHOD_PART_LINE, + DISP_METHOD_WHOLE_LINE, + }; typedef struct _disp_data { uint8_t x; - uint8_t y; + uint8_t y : 6; + uint8_t method : 2; uint8_t cnt; // clear width when ptr[0] == nullptr uint8_t mask; // clear height when ptr[0] == nullptr uint8_t *ptr[16]; diff --git a/xmake.lua b/xmake.lua index 4f3d051..180f002 100644 --- a/xmake.lua +++ b/xmake.lua @@ -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=20240218") -add_defines("VER_BUILD=20") +add_defines("VER_DATE=20240219") +add_defines("VER_BUILD=2") target("conf") set_kind("phony")