14#include <goodisplay/gdey029T94.h>
17static const char*
TAG =
"TimeInputView";
38 hour_ = (hour <= 23) ? hour : 0;
39 minute_ = (minute <= 59) ? minute : 0;
40 currentField_ = Field::HOUR;
50void TimeInputView::nextField() {
51 if (currentField_ == Field::HOUR) {
52 currentField_ = Field::MINUTE;
62void TimeInputView::prevField() {
63 if (currentField_ == Field::MINUTE) {
64 currentField_ = Field::HOUR;
74void TimeInputView::clearField() {
75 switch (currentField_) {
92void TimeInputView::enterDigit(
char digit) {
93 uint8_t d = digit -
'0';
95 switch (currentField_) {
101 hour_ = (hour_ / 10) * 10 + d;
102 if (hour_ > 23) hour_ = 23;
107 case Field::MINUTE: {
108 if (digitPos_ == 0) {
112 minute_ = (minute_ / 10) * 10 + d;
113 if (minute_ > 59) minute_ = 59;
130 if (key >=
'0' && key <=
'9') {
138 (currentField_ == Field::HOUR && hour_ > 0) ||
139 (currentField_ == Field::MINUTE && minute_ > 0)) {
150 if (hour_ > 23) hour_ = 23;
151 if (minute_ > 59) minute_ = 59;
152 LOG_I(
TAG,
"Time confirmed: %02d:%02d", hour_, minute_);
155 onConfirm_(hour_, minute_);
169 return ui::tr(
"core.hint_time_input");
181 auto* gfx =
static_cast<Gdey029T94*
>(
display->getNativeHandle());
184 const uint16_t width =
display->getWidth();
185 const uint16_t height =
display->getHeight();
188 gfx->fillScreen(EPD_WHITE);
191 gfx->setTextColor(EPD_BLACK);
199 snprintf(timeStr,
sizeof(timeStr),
"%02d : %02d", hour_, minute_);
204 gfx->getTextBounds(timeStr, 0, 0, &x1, &y1, &w, &h);
205 int startX = (width - w) / 2;
206 gfx->setCursor(startX,
TIME_Y);
209 gfx->fillRect(0,
UNDERLINE_Y, width, 4, EPD_WHITE);
212 int underlineX = startX;
213 int underlineW = 2 * charWidth;
215 switch (currentField_) {
220 underlineX = startX + 5 * charWidth;
224 gfx->fillRect(underlineX,
UNDERLINE_Y, underlineW, 3, EPD_BLACK);
Internationalization with English fallbacks in code and overlay translations loaded at runtime from a...
static constexpr int TITLE_Y
Display layout constants.
CDC Log: logging over TinyUSB CDC and UART.
#define LOG_I(tag, fmt,...)
static ViewStack & instance()
Returns singleton view-stack instance.
IDisplay * getDisplayInstance()
Returns lazily created singleton display instance.
void drawFooterBar(Gdey029T94 *gfx, uint16_t width, uint16_t height, const char *prefix, const char *hint, bool force=false)
Draws footer bar with optional prefix and hint text.
void drawHeaderCentered(Gdey029T94 *gfx, const char *title, int y, uint16_t width)
Draws a centered header title.
Centralized key-code constants for cdc_views.
const char * tr(const char *key)
Look up a translation by string key.
static constexpr char KEY_NO
Cancel / Back / Backspace.
static constexpr int TITLE_Y
Layout constants mirror the ones used by T9InputView.
static constexpr char KEY_YES
Confirm / OK / Save.