就绪界面显示当前时间;调整8号字体数字点阵
This commit is contained in:
parent
e7c79e24fc
commit
4a86d070ab
|
@ -4,7 +4,9 @@
|
|||
//
|
||||
// created on 2022-12-06
|
||||
//
|
||||
#if !defined(WIN32)
|
||||
#if defined(WIN32)
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#include <bits/stdint-uintn.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
#include "ini_file.h"
|
||||
|
||||
|
||||
#include <mutex>
|
||||
#include <algorithm>
|
||||
|
||||
#if OS_WIN
|
||||
#include <huagao/brand.h>
|
||||
#include <direct.h>
|
||||
#include <Windows.h>
|
||||
#include <time.h>
|
||||
|
@ -493,6 +493,24 @@ namespace utils
|
|||
{
|
||||
return u2m(m2u(ansi, CP_ACP).c_str(), CP_UTF8);
|
||||
}
|
||||
|
||||
static time_t file_time_2_utc(FILETIME ft)
|
||||
{
|
||||
SYSTEMTIME sys = { 0 };
|
||||
struct tm t = { 0 };
|
||||
|
||||
if (FileTimeToSystemTime(&ft, &sys))
|
||||
{
|
||||
t.tm_year = sys.wYear - 1900;
|
||||
t.tm_mon = sys.wMonth - 1;
|
||||
t.tm_mday = sys.wDay;
|
||||
t.tm_hour = sys.wHour;
|
||||
t.tm_min = sys.wMinute;
|
||||
t.tm_sec = sys.wSecond;
|
||||
}
|
||||
|
||||
return mktime(&t);
|
||||
}
|
||||
#else
|
||||
// This function will return 'in' string if failed !
|
||||
static std::string transform_between_gbk_and_utf8(const char* in, bool to_utf8, int *err, const char* ansi = "GBK")
|
||||
|
@ -1261,6 +1279,24 @@ namespace utils
|
|||
int err = 0;
|
||||
|
||||
#if OS_WIN
|
||||
if (born)
|
||||
{
|
||||
WIN32_FILE_ATTRIBUTE_DATA wfd = { 0 };
|
||||
|
||||
if (GetFileAttributesExA(file, GetFileExInfoStandard, &wfd))
|
||||
{
|
||||
if (born)
|
||||
*born = file_time_2_utc(wfd.ftCreationTime);
|
||||
if (modify)
|
||||
*modify = file_time_2_utc(wfd.ftLastWriteTime);
|
||||
if (last_access)
|
||||
*last_access = file_time_2_utc(wfd.ftLastAccessTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = GetLastError();
|
||||
}
|
||||
}
|
||||
#else
|
||||
if(born)
|
||||
{
|
||||
|
@ -2393,7 +2429,12 @@ void safe_thread::thread_notify_exception(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
void* safe_thread::raw_thread(void* lp)
|
||||
#if OS_WIN
|
||||
DWORD WINAPI
|
||||
#else
|
||||
void*
|
||||
#endif
|
||||
safe_thread::raw_thread(void* lp)
|
||||
{
|
||||
safe_thread *obj = ((LPCRAWTHRD)lp)->obj;
|
||||
std::function<void(void)> func = ((LPCRAWTHRD)lp)->func;
|
||||
|
@ -2433,7 +2474,7 @@ int safe_thread::start(std::function<void(void)> f, std::size_t stack, const cha
|
|||
param->addr = addr;
|
||||
|
||||
#if OS_WIN
|
||||
st.thread_raw = CreateThread(NULL, stack, &safe_thread::thread_worker, param, 0, nullptr);
|
||||
st.thread_raw = CreateThread(NULL, stack, &safe_thread::raw_thread, param, 0, nullptr);
|
||||
if(!st.thread_raw)
|
||||
err = GetLastError();
|
||||
#else
|
||||
|
|
|
@ -486,7 +486,13 @@ class safe_thread
|
|||
std::string name;
|
||||
void* addr;
|
||||
}CRAWTHRD, *LPCRAWTHRD;
|
||||
static void* raw_thread(void* lp);
|
||||
static
|
||||
#if OS_WIN
|
||||
DWORD WINAPI
|
||||
#else
|
||||
void*
|
||||
#endif
|
||||
raw_thread(void* lp);
|
||||
|
||||
public:
|
||||
safe_thread(void);
|
||||
|
|
|
@ -428,7 +428,7 @@ ui_mgr::ui_mgr() : disp_data_("lcd-msg")
|
|||
lcd_->clear();
|
||||
|
||||
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_.x = (Lcd::LCD_WIDTH - ready_.ptr[0][0] * ready_.cnt - 8) / 2;
|
||||
ready_.y = (Lcd::LCD_HEIGHT - ready_.ptr[0][1]) / 2;
|
||||
ready_.mask = 0;
|
||||
|
||||
|
@ -964,6 +964,7 @@ void ui_mgr::thread_display(void)
|
|||
{
|
||||
DISPDATA dd;
|
||||
int wait = 10;
|
||||
bool ready_msg = false;
|
||||
|
||||
// welcome
|
||||
{
|
||||
|
@ -975,6 +976,7 @@ void ui_mgr::thread_display(void)
|
|||
{
|
||||
if(disp_data_.take(dd, true, SEC_2_MS(wait)))
|
||||
{
|
||||
ready_msg = false;
|
||||
if(dd.method == DISP_METHOD_PART_LINE)
|
||||
lcd_->write_line(dd.ptr, dd.cnt, dd.x, dd.y, dd.mask);
|
||||
else if(dd.method == DISP_METHOD_CLEAR)
|
||||
|
@ -986,7 +988,14 @@ void ui_mgr::thread_display(void)
|
|||
else if(ready_enable_)
|
||||
{
|
||||
if(get_ready_watch_ms() / SEC_2_MS(1) >= wait)
|
||||
display_ready();
|
||||
{
|
||||
display_ready(ready_msg);
|
||||
if(ready_msg)
|
||||
wait = 60;
|
||||
else
|
||||
wait = 60 - (time(nullptr) % 60);
|
||||
ready_msg = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1005,14 +1014,40 @@ void ui_mgr::display_scan_title(void)
|
|||
dd.method = DISP_METHOD_PART_LINE;
|
||||
disp_data_.save(dd, true);
|
||||
}
|
||||
void ui_mgr::display_ready(void)
|
||||
void ui_mgr::display_ready(bool time_only)
|
||||
{
|
||||
set_ready_status_enabled(false);
|
||||
// set_ready_status_enabled(false);
|
||||
|
||||
menu_mode_ = false;
|
||||
// lcd_->clear();
|
||||
|
||||
lcd_->write_whole_line(ready_.ptr, ready_.cnt, ready_.x, ready_.y, ready_.mask);
|
||||
if(!time_only)
|
||||
{
|
||||
lcd_->write_whole_line(ready_.ptr, ready_.cnt, ready_.x, ready_.y, ready_.mask);
|
||||
// {
|
||||
// DISPDATA dd;
|
||||
// memset(&dd, 0, sizeof(dd));
|
||||
// dd.cnt = custom_font::get_string_font("0123456789", dd.ptr, custom_font::FONT_SIZE_8);
|
||||
// lcd_->write_line(dd.ptr, dd.cnt, dd.x, dd.y, dd.mask);
|
||||
// }
|
||||
}
|
||||
|
||||
{
|
||||
std::string now(utils::format_current_time());
|
||||
size_t pos = now.find(" ");
|
||||
DISPDATA dd;
|
||||
|
||||
if(pos++ != std::string::npos)
|
||||
now.erase(0, pos);
|
||||
pos = now.rfind(':');
|
||||
if(pos != std::string::npos)
|
||||
now.erase(pos);
|
||||
|
||||
memset(&dd, 0, sizeof(dd));
|
||||
dd.cnt = custom_font::get_string_font(now.c_str(), dd.ptr, custom_font::FONT_SIZE_8);
|
||||
dd.x = Lcd::LCD_WIDTH - 30;
|
||||
dd.y = 8;
|
||||
lcd_->write_line(dd.ptr, dd.cnt, dd.x, dd.y, dd.mask);
|
||||
}
|
||||
}
|
||||
void ui_mgr::display_status(void* data)
|
||||
{
|
||||
|
|
|
@ -311,7 +311,7 @@ class ui_mgr : public refer
|
|||
|
||||
void thread_display(void);
|
||||
void display_scan_title(void);
|
||||
void display_ready(void);
|
||||
void display_ready(bool time_only);
|
||||
void display_status(void* data);
|
||||
void set_ready_status_enabled(bool enable); // disable ready message, the last message will display until keyboard event triggered
|
||||
void reset_ready_watch(void);
|
||||
|
|
93
ui/font.cpp
93
ui/font.cpp
|
@ -24,65 +24,60 @@ namespace custom_font
|
|||
|
||||
void init_8x8(void)
|
||||
{
|
||||
static uint8_t num0[] = {6, 8
|
||||
, 0x00, 0x7C, 0x44, 0x7C, 0x00, 0x00
|
||||
};
|
||||
font_map8x8_["\060\000\000"] = num0;
|
||||
static uint8_t colon[] = {5, 8
|
||||
, 0x00, 0x00, 0x28, 0x00, 0x00
|
||||
};
|
||||
font_map8x8_["\072\000\000"] = colon;
|
||||
|
||||
static uint8_t num1[] = {6, 8
|
||||
, 0x00, 0x08, 0xFC, 0x00, 0x00, 0x00
|
||||
};
|
||||
font_map8x8_["\061\000\000"] = num1;
|
||||
static uint8_t num0[] = {5, 8
|
||||
, 0x00, 0x7C, 0x44, 0x7C, 0x00
|
||||
};
|
||||
font_map8x8_["\060\000\000"] = num0;
|
||||
|
||||
static uint8_t num2[] = {6, 8
|
||||
, 0x00, 0xCC, 0xA4, 0xB4, 0x9C, 0x00
|
||||
};
|
||||
font_map8x8_["\062\000\000"] = num2;
|
||||
static uint8_t num1[] = {5, 8
|
||||
, 0x00, 0x44, 0x7C, 0x40, 0x00
|
||||
};
|
||||
font_map8x8_["\061\000\000"] = num1;
|
||||
|
||||
static uint8_t num3[] = {6, 8
|
||||
, 0x00, 0x44, 0x54, 0x7C, 0x00, 0x00
|
||||
};
|
||||
font_map8x8_["\063\000\000"] = num3;
|
||||
static uint8_t num2[] = {5, 8
|
||||
, 0x00, 0x6C, 0x54, 0x4C, 0x00
|
||||
};
|
||||
font_map8x8_["\062\000\000"] = num2;
|
||||
|
||||
static uint8_t num4[] = {6, 8
|
||||
, 0x20, 0x28, 0xFC, 0xFE, 0x20, 0x00
|
||||
};
|
||||
font_map8x8_["\064\000\000"] = num4;
|
||||
static uint8_t num3[] = {5, 8
|
||||
, 0x00, 0x44, 0x54, 0x7C, 0x00
|
||||
};
|
||||
font_map8x8_["\063\000\000"] = num3;
|
||||
|
||||
static uint8_t num5[] = {6, 8
|
||||
, 0x00, 0x9C, 0x94, 0xB4, 0x60, 0x00
|
||||
};
|
||||
font_map8x8_["\065\000\000"] = num5;
|
||||
static uint8_t num4[] = {5, 8
|
||||
, 0x20, 0x30, 0x7C, 0x20, 0x00
|
||||
};
|
||||
font_map8x8_["\064\000\000"] = num4;
|
||||
|
||||
static uint8_t num6[] = {6, 8
|
||||
, 0x00, 0xF8, 0x94, 0x94, 0x74, 0x00
|
||||
};
|
||||
font_map8x8_["\066\000\000"] = num6;
|
||||
static uint8_t num5[] = {5, 8
|
||||
, 0x00, 0x5C, 0x54, 0x74, 0x00
|
||||
};
|
||||
font_map8x8_["\065\000\000"] = num5;
|
||||
|
||||
static uint8_t num7[] = {6, 8
|
||||
, 0x04, 0x04, 0xE4, 0x1C, 0x00, 0x00
|
||||
};
|
||||
font_map8x8_["\067\000\000"] = num7;
|
||||
static uint8_t num6[] = {5, 8
|
||||
, 0x00, 0x54, 0x54, 0x74, 0x00
|
||||
};
|
||||
font_map8x8_["\066\000\000"] = num6;
|
||||
|
||||
static uint8_t num8[] = {6, 8
|
||||
, 0x00, 0x7C, 0x54, 0x7C, 0x00, 0x00
|
||||
};
|
||||
font_map8x8_["\070\000\000"] = num8;
|
||||
static uint8_t num7[] = {5, 8
|
||||
, 0x00, 0x44, 0x74, 0x0C, 0x00
|
||||
};
|
||||
font_map8x8_["\067\000\000"] = num7;
|
||||
|
||||
static uint8_t num9[] = {6, 8
|
||||
, 0x00, 0x5C, 0x54, 0x3C, 0x00, 0x00
|
||||
};
|
||||
font_map8x8_["\071\000\000"] = num9;
|
||||
static uint8_t num8[] = {5, 8
|
||||
, 0x00, 0x7C, 0x54, 0x7C, 0x00
|
||||
};
|
||||
font_map8x8_["\070\000\000"] = num8;
|
||||
|
||||
static uint8_t zong[] = {8, 8
|
||||
, 0x00, 0x60, 0x6E, 0x4B, 0x7A, 0x4B, 0x6C, 0x60
|
||||
};
|
||||
font_map8x8_["\346\200\273"] = zong;
|
||||
|
||||
static uint8_t maohao[] = {8, 8
|
||||
, 0x00, 0x50, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
font_map8x8_["\357\274\232"] = maohao;
|
||||
static uint8_t num9[] = {5, 8
|
||||
, 0x00, 0x5C, 0x54, 0x3C, 0x00
|
||||
};
|
||||
font_map8x8_["\071\000\000"] = num9;
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue