#include "LCDDisplay.h" #include "Lcd.h" #include #include #include #include "stringex.hpp" using namespace std; LCDDisplay::LCDDisplay() { lcd.reset(new Lcd()); lcd->Lcd_Initial_Lcd(false); // lcd->Lcd_Clear_screen(); // lcd->Lcd_Display_Graphic_16x16(map_Display[DisType::Dis_Init].page, map_Display[DisType::Dis_Init].col, map_Display[DisType::Dis_Init].str.data(),map_Display[DisType::Dis_Init].str.size()/32); } LCDDisplay::~LCDDisplay() { lcd->Lcd_Clear_screen(); lcd.reset(); } void LCDDisplay::DisplayState(DisType ds, unsigned int pagenum,ClearScreen clearscree) { if(clearscree == ClearScreen::All) lcd->Lcd_Clear_screen(); if(clearscree == ClearScreen::TOP) lcd->Lcd_Clear_Half_Screen(true); if(clearscree == ClearScreen::BOT) lcd->Lcd_Clear_Half_Screen(false); if (map_Display.count(ds) > 0) { m_status = ds; StopWatch sw; auto dsinfo = map_Display[ds]; if (ds == DisType::Dis_Welcome)//show logo { lcd->Lcd_Display_Graphic_128x64(dsinfo.page, dsinfo.col, dsinfo.str.data()); } else { lcd->Lcd_Display_Graphic_16x16(dsinfo.page, dsinfo.col, dsinfo.str.data(), dsinfo.str.size() / 32); //if (ds == DisType::Dis_Scan || ds == DisType::Dis_Set_Count) //扫描或者计数 更新下半部分内容 //{ //lcd->Lcd_Clear_Half_Screen(false); //lcd->Lcd_Display_String_8x16(3, 96, "0"); //lcd->Lcd_Display_Graphic_16x16(map_Display[DisType::Dis_Scan_Page].page, map_Display[DisType::Dis_Scan_Page].col, map_Display[DisType::Dis_Scan_Page].str.data(), map_Display[DisType::Dis_Scan_Page].str.size() / 32); //} } switch (ds) { case DisType::Dis_Count_Page: case DisType::Dis_Scan_Page: { //std::string val = std::to_string(pagenum); //auto offsetdot = bitnum(pagenum) - 1; std::string val = string_format("%04d",pagenum); int offsetdot = val.length(); //printf("\n val = %s lenght = %d",val.c_str(),val.size()); lcd->Lcd_Display_String_8x16(3, 112 - offsetdot * 8, val.c_str()); //8 -> 一个数字所占点个数宽度 lcd->Lcd_Display_Graphic_16x16(map_Display[DisType::Dis_Scan_Page].page, map_Display[DisType::Dis_Scan_Page].col, map_Display[DisType::Dis_Scan_Page].str.data(), map_Display[DisType::Dis_Scan_Page].str.size() / 32); break; } case DisType::Dis_Err_JamIn: { if(pagenum == 1) lcd->Lcd_Display_String_8x16(3, 56, "P a 1 0 1"); //8 -> 一个数字所占点个数宽度 else if(pagenum == 2) lcd->Lcd_Display_String_8x16(3, 56, "P a 1 0 2"); else if(pagenum == 3) lcd->Lcd_Display_String_8x16(3, 56, "P a 1 0 3"); break; } case DisType::Dis_Err_AqrImgTimeout: lcd->Lcd_Display_String_8x16(3, 56, "G p 0 0 1"); break; case DisType::Dis_Err_CoverOpen: lcd->Lcd_Display_String_8x16(3, 56, "C o 0 0 1"); break; case DisType::Dis_Err_PaperScrew: lcd->Lcd_Display_String_8x16(3, 56, "S K 0 0 1"); break; case DisType::Dis_Err_DoubleFeed: lcd->Lcd_Display_String_8x16(3, 56, "D b 0 0 1"); break; case DisType::Dis_Err_NoPaper: lcd->Lcd_Display_String_8x16(3, 56, "N o 0 0 1"); break; case DisType::Dis_Err_Stable: lcd->Lcd_Display_String_8x16(3, 56, "S T 0 0 1"); break; case DisType::Dis_Err_FeedError: lcd->Lcd_Display_String_8x16(3, 56, "P f 0 0 1"); break; case DisType::Dis_Err_DogEar: lcd->Lcd_Display_String_8x16(3, 56, "Z J 0 0 1"); break; case DisType::Dis_Err_Size: lcd->Lcd_Display_String_8x16(3, 56, "C C 0 0 1"); break; default: break; } } else { switch (ds){ case DisType::Dis_Set_SleepMode_5M: lcd->Lcd_Display_String_8x16(3, 112, "5M"); break; case DisType::Dis_Set_SleepMode_10M: lcd->Lcd_Display_String_8x16(3, 104, "10M"); break; case DisType::Dis_Set_SleepMode_20M: lcd->Lcd_Display_String_8x16(3, 104, "20M"); break; case DisType::Dis_Set_SleepMode_30M: lcd->Lcd_Display_String_8x16(3, 104, "30M"); break; case DisType::Dis_Set_SleepMode_1H: lcd->Lcd_Display_String_8x16(3, 112, "1H"); break; case DisType::Dis_Set_SleepMode_2H: lcd->Lcd_Display_String_8x16(3, 112, "2H"); break; case DisType::Dis_Set_SleepMode_4H: lcd->Lcd_Display_String_8x16(3, 112, "4H"); break; default: m_status= DisType::Dis_Unkown; break; } } } int LCDDisplay::bitnum(unsigned int num) { int count = 0; do { num = num / 10; count++; } while (num > 0); return count; } DisType LCDDisplay::GetCurrentStatus() const { return m_status; }