At least: font code generator, exchange code support for color 128x128

This commit is contained in:
2019-08-04 15:35:44 -07:00
parent e0b49ba109
commit 77f09bca16
47 changed files with 899 additions and 16431 deletions

View File

@@ -23,7 +23,7 @@
#include "RtcDriver.h"
#include "SystemTime.h"
#include "SystemFonts.h"
#include "LowPower.h"
using Common::ReturnCode;
using Common::Time;
@@ -34,9 +34,10 @@ DisplayTimeScreen::DisplayTimeScreen(BSP::DisplayDriver &driver,
Screen &menu_screen)
: m_driver(driver)
, m_last_time()
, m_refresh(true)
, m_manager(manager)
, m_menu_screen(menu_screen)
, m_display_seconds(false)
, m_display_seconds(true)
{}
static char get_char_for_digit(uint8_t bcd_digit)
@@ -49,6 +50,8 @@ static char get_char_for_digit(uint8_t bcd_digit)
ReturnCode DisplayTimeScreen::init()
{
SET(RCC->CFGR, RCC_CFGR_SW_HSI);
return ReturnCode::OK;
}
@@ -67,48 +70,57 @@ void DisplayTimeScreen::display_time()
{
Common::WallClockTime time;
BSP::RtcDriver::get_time(time);
const struct font &font = large_font;
const uint32_t font_width = large_font_width;
const uint32_t y_space = (m_driver.get_height() - (2 * font.size)) / 3;
const uint32_t x_space = (m_driver.get_width() - (2 * font_width)) / 2;
const struct font &font = font_large_digits;
const uint32_t y_space = (m_driver.get_height() - (2 * font.height)) / 3;
const uint32_t x_space = (m_driver.get_width() - (2 * font.width)) / 2;
uint32_t x = 0;
if (m_last_time.get_hours_24() != time.get_hours_24()) {
if (m_refresh || m_last_time.get_hours_24() != time.get_hours_24()) {
x = x_space;
display_number(&x, y_space,
time.get_hours_12_tens(), time.get_hours_12_ones(), font);
}
if (m_last_time.get_minutes() != time.get_minutes()) {
if (m_refresh || m_last_time.get_minutes() != time.get_minutes()) {
x = x_space;
display_number(&x, y_space * 2 + font.size,
display_number(&x, y_space * 2 + font.height,
time.get_minutes_tens(), time.get_minutes_ones(), font);
}
if (m_display_seconds) {
if (m_refresh || m_display_seconds) {
// display_number(&x, y,
// time.get_seconds_tens(), time.get_seconds_ones(), font_default);
}
m_last_time = time;
m_refresh = false;
m_driver.refresh();
}
NextTime DisplayTimeScreen::execute()
{
// m_refresh = true;
display_time();
Common::time_t now;
BSP::SystemTimer::get_time(now);
uint32_t next_secs = Time::to_seconds(now) + (m_display_seconds ? 1 : 60);
return NextTime::at(Time::seconds(next_secs));
if (m_display_seconds) {
return NextTime::in(Time::seconds(1));
} else {
Common::WallClockTime wall_time;
BSP::RtcDriver::get_time(wall_time);
return NextTime::in(Time::seconds(61 - wall_time.get_seconds()));
}
}
void DisplayTimeScreen::enable() {
m_refresh = true;
m_driver.clear();
m_last_time = {};
display_time();
}
void DisplayTimeScreen::disable() {