Kleidos API Search

In development. It changes without notice.

Topic

Shared Screen Parts

The pieces several screens draw or steer by: the header, the lock screen's clock, the Bluetooth chip, the list's motion, and the navigation with two buttons or a dial.

They take what they draw as arguments and never the context.

See also
Application States, State Context & Shared Flows, State Rules

Files

file src/states/chrome/dial_nav.h
The CoreInk dial grammar: one key reader and one repaint rule for every screen the ▲●▼ dial drives.
file src/states/chrome/glass_header.h
The main loop's watch on the battery gauge of the header on the glass.
file src/states/chrome/header_watch.h
The watch every screen keeps on its header band, tick by tick.
file src/states/chrome/list_slide_motion.h
Where a sliding list's step starts, and the two tweens that carry it.
file src/states/chrome/list_slide_regions.h
The rows one frame of a sliding list repaints, and the band a paint leaves for the next frame to narrow against.
file src/states/chrome/lock_face_clock.h
The clock on the CoreInk's retained lock face, kept current while the board is off.
file src/states/chrome/two_button_nav.h
Single source of truth for the two-button (Stick) gesture convention.
file src/states/chrome/vault_tabs.h
The vault's tab strip, named once for every screen that draws it.

Classes

struct kleidos::states::HeaderShown
What a header band shows that moves on its own. More about kleidos::states::HeaderShown
class kleidos::states::HeaderWatch
One screen's record of what its header band shows. More about kleidos::states::HeaderWatch
struct kleidos::states::listslide::Place
Where a list rests: its window and its selection, as a paint draws them. More about kleidos::states::listslide::Place
struct kleidos::states::listslide::Sample
A list at one instant of its slide, in fractional rows. More about kleidos::states::listslide::Sample
class kleidos::states::listslide::Motion
The slide of one list: its two tweens and the place they lead to. More about kleidos::states::listslide::Motion
struct kleidos::states::listslide::DrawnBand
Where the selection band was last painted, as the next frame needs it. More about kleidos::states::listslide::DrawnBand
struct kleidos::states::listslide::Frame
What one frame of the slide draws. More about kleidos::states::listslide::Frame
struct kleidos::states::listslide::Regions
The rectangles one frame repaints (one or two, inside the body). More about kleidos::states::listslide::Regions
class kleidos::states::twobtn::HoldGauge
Tracks one button's hold and reports the gauge fill, with change detection so a screen repaints only when the fill actually moves. More about kleidos::states::twobtn::HoldGauge
struct kleidos::states::VaultTabStrip
The tabs one strip draws, in slot order, with what each slot shows. More about kleidos::states::VaultTabStrip

Enumerations

enum class kleidos::states::BleLink : uint8_t { kleidos::states::BleLink::Visible , kleidos::states::BleLink::Pairing , kleidos::states::BleLink::Connected }
What the Bluetooth link is doing, as every pairing surface names it. More about kleidos::states::BleLink
enum class kleidos::states::dial::DialKeys : uint8_t { DialKeys::None, DialKeys::Up, DialKeys::Down, DialKeys::Ok, DialKeys::OkHold }
What the dial asked for this frame. More about kleidos::states::dial::DialKeys
enum class kleidos::states::HeaderRepaint : uint8_t { kleidos::states::HeaderRepaint::None , kleidos::states::HeaderRepaint::Band , kleidos::states::HeaderRepaint::Screen }
What a screen's header needs on a tick at rest. More about kleidos::states::HeaderRepaint
enum class kleidos::states::lock_clock::BootSource : uint8_t { BootSource::PowerOn , BootSource::TimerWake , BootSource::KeyWake , BootSource::Other }
What brought the board up, as far as the tick is concerned. More about kleidos::states::lock_clock::BootSource
enum class kleidos::states::lock_clock::TickVerdict : uint8_t { TickVerdict::Boot , TickVerdict::Tick , TickVerdict::SleepAgain }
What a boot does with the tick. More about kleidos::states::lock_clock::TickVerdict
enum class kleidos::states::twobtn::ListKeys : uint8_t { kleidos::states::twobtn::ListKeys::None, kleidos::states::twobtn::ListKeys::Down, kleidos::states::twobtn::ListKeys::Up, kleidos::states::twobtn::ListKeys::Activate, kleidos::states::twobtn::ListKeys::Back }
What a two-button list's keys asked for this frame. More about kleidos::states::twobtn::ListKeys
enum class kleidos::states::twobtn::Page : uint8_t { kleidos::states::twobtn::Page::Credentials , kleidos::states::twobtn::Page::Totp , kleidos::states::twobtn::Page::Settings }
The three top-level Stick pages, cycled by a B hold. More about kleidos::states::twobtn::Page
enum class kleidos::states::VaultTab : uint8_t { kleidos::states::VaultTab::Pass , kleidos::states::VaultTab::Totp , kleidos::states::VaultTab::Actions }
The vault's tabs, in strip order; the value indexes the per-tab arrays. More about kleidos::states::VaultTab

Functions

constexpr BleLinkkleidos::states::bleLinkOf (ble::StackState state, bool linked)
The link a published stack state and a link reading name.
ui::StatusChipPropskleidos::states::bleLinkChip (BleLink link)
The chip that names the link: "Visible" while the device waits for a host, "Pairing" while one pairs, "Connected" once one holds the link.
voidkleidos::states::drawBleLinkChip (ui::Canvas &canvas, const ui::LayoutContext &layout, int16_t cx, int16_t cy, BleLink link)
Draw kleidos::states::bleLinkChip centered on (cx, cy).
DialKeyskleidos::states::dial::pollDialKeys (ButtonInput &up, ButtonInput &ok, ButtonInput *down)
Read one frame of the dial grammar.
constexpr boolkleidos::states::dial::gaugeRepaintOnMono (uint8_t prevPct, uint8_t pct)
Whether a hold gauge moving from prevPct to pct changes a 1-bit bar.
boolkleidos::states::dial::onDial ()
Whether this board navigates with the ▲●▼ dial.
voidkleidos::states::watchGlassHeader (PowerManager &power)
Keep the battery gauge of the header on the glass live, on a tick at rest.
constexpr ui::Rectkleidos::states::listslide::bandUnion (const ui::Rect &body, int16_t newY, int16_t oldY, int16_t rowH)
The band's old and new rows as one rectangle, clamped to the body.
constexpr boolkleidos::states::listslide::windowStill (const Frame &frame, const DrawnBand &drawn)
Whether a frame's window is where the last paint left it.
constexpr Regionskleidos::states::listslide::slideRegions (const Frame &frame, const DrawnBand &drawn)
The rectangles a frame of the slide repaints.
constexpr DrawnBandkleidos::states::listslide::bandAfter (const Frame &frame, bool covered)
The band a frame of the slide leaves for the next frame.
constexpr DrawnBandkleidos::states::listslide::restingBand (const ui::Rect &body, uint16_t selected, uint16_t topRow, int16_t rowH, uint8_t visible, bool covered)
The band a resting paint of the list leaves for the next frame.
constexpr TickVerdictkleidos::states::lock_clock::classifyBoot (BootSource source, bool alarmFired, bool tickArmed, uint8_t seconds)
Decide what this boot does with the tick.
constexpr RtcAlarmkleidos::states::lock_clock::nextMinuteAlarm (const RtcTime &utc)
The alarm for the minute after utc.
constexpr uint16_tkleidos::states::lock_clock::minutesSinceShown (const RtcAlarm &armed, const RtcTime &utc)
Minutes between the minute the glass shows and utc.
constexpr boolkleidos::states::lock_clock::fullRefreshDue (const RtcTime &local)
Whether the minute local gets a full refresh.
constexpr uint64_tkleidos::states::lock_clock::microsToNextTick (uint8_t seconds)
Microseconds from seconds past the minute to one second into the next.
boolkleidos::states::lock_clock::shown ()
Whether the owner shows the clock on the lock face.
boolkleidos::states::lock_clock::setShown (bool on)
Store whether the lock face shows the clock.
voidkleidos::states::lock_clock::runIfMinuteTick ()
Run the minute tick when the RTC alarm switched the board on.
boolkleidos::states::lock_clock::prepareSleepFace (bool lowBattery)
Draw the face the board sleeps under, and arm what keeps it current.
voidkleidos::states::lock_clock::armStandInTimer ()
Arm the ESP32 timer that stands in for the RTC interrupt on USB power.
voidkleidos::states::lock_clock::drawSleepFace (bool showClock)
Draw a sleep face exactly as the board sleeps under it, arming nothing.
constexpr uint16_tkleidos::states::twobtn::moveDown (uint16_t selected, uint16_t itemCount)
A-short = DOWN: move the selection one item toward the bottom.
constexpr uint16_tkleidos::states::twobtn::moveUp (uint16_t selected, uint16_t itemCount)
B-short = UP: move the selection one item toward the top.
boolkleidos::states::twobtn::downShort (ButtonInput &btnA)
A-short edge: DOWN / NEXT. Consumes the click edge.
boolkleidos::states::twobtn::upShort (ButtonInput &btnB)
B-short edge: UP / PREV. Consumes the click edge.
boolkleidos::states::twobtn::activateLong (ButtonInput &btnA)
A-long edge: ACTIVATE / PRIMARY. Fires on release after kleidos::states::twobtn::kHoldMs.
boolkleidos::states::twobtn::backLong (ButtonInput &btnB)
B-long edge: BACK / SECONDARY. Fires on release after kleidos::states::twobtn::kHoldMs.
ListKeyskleidos::states::twobtn::pollListKeys (ButtonInput &btnA, ButtonInput &btnB)
Read one frame of the list grammar: taps move, holds act.
constexpr uint8_tkleidos::states::twobtn::holdPct (uint32_t heldMs, uint32_t thresholdMs=kHoldMs)
Fill percentage of a hold in progress.
uint8_tkleidos::states::twobtn::pollHoldGauge (HoldGauge &gauge, ButtonInput &btn)
Convenience: advance a kleidos::states::twobtn::HoldGauge from a live button using the platform clock facade.
constexpr uint8_tkleidos::states::twobtn::pageCount (bool totpShown)
Number of pages the pager cycles through and its strip draws.
constexpr uint8_tkleidos::states::twobtn::stripSlot (Page p, bool totpShown)
The strip slot p occupies.
constexpr Pagekleidos::states::twobtn::nextPage (Page p, bool totpShown)
B hold = next page (Credentials -> Totp -> Settings -> Credentials), skipping the 2FA page while it is hidden.
constexpr Pagekleidos::states::twobtn::prevPage (Page p, bool totpShown)
Previous page (Credentials -> Settings -> Totp -> Credentials), skipping the 2FA page while it is hidden.
constexpr VaultTabStripkleidos::states::vaultTabStrip (bool totpShown)
The strip the vault draws.
constexpr uint8_tkleidos::states::tabIndex (VaultTab tab)
The logical index of tab, for the per-tab arrays.

Variables

constexpr uint16_tkleidos::states::lock_clock::kMinutesPerDay
Minutes in a day.
constexpr uint16_tkleidos::states::lock_clock::kFullRefreshEveryMin
constexpr uint8_tkleidos::states::lock_clock::kTickWindowSec
constexpr uint32_tkleidos::states::twobtn::kHoldMs
constexpr uint32_tkleidos::states::twobtn::kHoldGraceMs
constexpr uint8_tkleidos::states::twobtn::kHoldPctStep
constexpr uint8_tkleidos::states::twobtn::kPageCount
Number of logical pages (the size of the per-page arrays).
constexpr uint8_tkleidos::states::kVaultTabCount
Number of logical vault tabs (the per-tab arrays' size).
constexpr std::array< i18n::StringId, kVaultTabCount >kleidos::states::kVaultTabLabelIds
The vault's three tabs' names, by VaultTab.
constexpr std::array< ui::IconId, kVaultTabCount >kleidos::states::kVaultTabIcons
The same three tabs as the marks a narrow strip draws: card, clock, menu.

Back to the top

Enumeration Type Documentation

BleLink #

enum class kleidos::states::BleLink : uint8_t

What the Bluetooth link is doing, as every pairing surface names it.

Enumerator
Visible 

The device waits for a host.

Pairing 

A host is pairing: the owner was asked, the host has not finished.

Connected 

A host holds the link.

BootSource #

enum class kleidos::states::lock_clock::BootSource : uint8_t

What brought the board up, as far as the tick is concerned.

Enumerator
PowerOn 

The supply came up: on battery, the RTC interrupt or the side key.

TimerWake 

The ESP32 timer that stands in for the RTC interrupt on USB power.

KeyWake 

The side key woke the board from deep sleep (USB power).

Other 

A reset, a crash or a firmware flash.

DialKeys #

enum class kleidos::states::dial::DialKeys : uint8_t

What the dial asked for this frame.

Enumerator
None 

No key edge this frame.

Up 

▲ pressed: previous row, or raise a value.

Down 

▼ pressed: next row, or lower a value.

Ok 

OK tapped: select, open or advance.

OkHold 

OK held past the hold threshold: the screen's action.

HeaderRepaint #

enum class kleidos::states::HeaderRepaint : uint8_t

What a screen's header needs on a tick at rest.

Enumerator
None 

The glass shows what is live.

Band 

Repaint the header band alone.

Screen 

An overlay reaches into the band: repaint the whole screen.

ListKeys #

enum class kleidos::states::twobtn::ListKeys : uint8_t

What a two-button list's keys asked for this frame.

Enumerator
None 

No key edge this frame.

Down 

A tap: next row.

Up 

B tap: previous row.

Activate 

A hold: open / run the focused row.

Back 

B hold: leave the list.

Page #

enum class kleidos::states::twobtn::Page : uint8_t

The three top-level Stick pages, cycled by a B hold.

Order is the page-switch order: a B hold advances (Credentials -> Totp -> Settings -> Credentials). The 2FA page exists only while the 2FA codes setting is on; with it off the pager is Credentials <-> Settings, and each function below takes that as totpShown.

Enumerator
Credentials 

Credential list. Passwords only — a credential's own TOTP, when it has one, lives inside that credential's detail screen and never as a row here; the two lists are separate pages, never one merged list.

Totp 

Dedicated browsable TOTP list.

Settings 

Settings page (WiFi Admin, Lock, About).

TickVerdict #

enum class kleidos::states::lock_clock::TickVerdict : uint8_t

What a boot does with the tick.

Enumerator
Boot 

A normal boot: disarm the alarm and go on.

Tick 

Redraw the minute and power off again.

SleepAgain 

Woke before the alarm: sleep to the minute without drawing.

VaultTab #

enum class kleidos::states::VaultTab : uint8_t

The vault's tabs, in strip order; the value indexes the per-tab arrays.

Enumerator
Pass 

The credential list.

Totp 

The 2FA codes; drawn only while the setting is on.

Actions 

The device actions (settings, admin portal, lock).

Back to the top

Function Documentation

activateLong() #

bool kleidos::states::twobtn::activateLong(ButtonInput & btnA)
inlinenodiscard

A-long edge: ACTIVATE / PRIMARY. Fires on release after kleidos::states::twobtn::kHoldMs.

Parameters
NameDirectionMeaning
btnAin, outThe A nav button; its release edge is consumed.
Returns
true on the A-long release edge this frame.

armStandInTimer() #

void kleidos::states::lock_clock::armStandInTimer()

Arm the ESP32 timer that stands in for the RTC interrupt on USB power.

Call before deep sleep, after prepareSleepFace armed the minute. The wake is a deadline from the reading this call takes, so it falls one second into the next minute however long the rest of the teardown runs, and wakes the board at once when that moment comes before the sleep starts. Does nothing when no minute is armed.

backLong() #

bool kleidos::states::twobtn::backLong(ButtonInput & btnB)
inlinenodiscard

B-long edge: BACK / SECONDARY. Fires on release after kleidos::states::twobtn::kHoldMs.

Parameters
NameDirectionMeaning
btnBin, outThe B nav button; its release edge is consumed.
Returns
true on the B-long release edge this frame.

bandAfter() #

DrawnBand kleidos::states::listslide::bandAfter(const Frame & frame, bool covered)
constexpr

The band a frame of the slide leaves for the next frame.

Recorded only when the frame drew the rows in their resting places (no sub-row shift): rows drawn shifted mid-scroll are not where a still window puts them, so a frame that narrowed from them would leave them shifted.

Parameters
NameDirectionMeaning
frameinThe frame just drawn.
coveredinSomething was composited over the list (a toast).
Returns
The band.

bandUnion() #

ui::Rect kleidos::states::listslide::bandUnion(const ui::Rect & body, int16_t newY, int16_t oldY, int16_t rowH)
constexpr

The band's old and new rows as one rectangle, clamped to the body.

Parameters
NameDirectionMeaning
bodyinThe list's body.
newYinTop of the band this frame (px).
oldYinTop of the band the last paint drew (px).
rowHinRow height (px).
Returns
The rows between and including both bands; empty when they fall outside the body.

bleLinkChip() #

ui::StatusChipProps kleidos::states::bleLinkChip(BleLink link)
inline

The chip that names the link: "Visible" while the device waits for a host, "Pairing" while one pairs, "Connected" once one holds the link.

Parameters
NameDirectionMeaning
linkinWhat the link is doing.
Returns
The chip's label and style.

bleLinkOf() #

BleLink kleidos::states::bleLinkOf(ble::StackState state, bool linked)
constexpr

The link a published stack state and a link reading name.

Parameters
NameDirectionMeaning
stateinThe stack's published state.
linkedinWhether a host holds an authenticated link.
Returns
Connected for a linked host, Pairing while the stack reads AUTHENTICATING, Visible otherwise.

classifyBoot() #

TickVerdict kleidos::states::lock_clock::classifyBoot(BootSource source, bool alarmFired, bool tickArmed, uint8_t seconds)
constexpr

Decide what this boot does with the tick.

A power-on is a tick only when it finds the alarm flag within the first kTickWindowSec seconds of the minute; a flag found later was left pending by something else (a reset, a flash). The USB stand-in timer is a tick once the alarm has fired, and sleeps again when it woke early while a minute is armed. Any other timer wake (a debug sleep, with no minute armed) is a normal boot.

Parameters
NameDirectionMeaning
sourceinWhat brought the board up.
alarmFiredinWhether the RTC alarm flag is set.
tickArmedinWhether a minute alarm is armed (its matches enabled).
secondsinSeconds past the minute now (RTC).
Returns
The verdict.

downShort() #

bool kleidos::states::twobtn::downShort(ButtonInput & btnA)
inlinenodiscard

A-short edge: DOWN / NEXT. Consumes the click edge.

Parameters
NameDirectionMeaning
btnAin, outThe A nav button; its click edge is consumed.
Returns
true on the A-short click edge this frame.

drawBleLinkChip() #

void kleidos::states::drawBleLinkChip(ui::Canvas & canvas, const ui::LayoutContext & layout, int16_t cx, int16_t cy, BleLink link)
inline

Draw kleidos::states::bleLinkChip centered on (cx, cy).

Parameters
NameDirectionMeaning
canvasin, outDrawing surface.
layoutinResponsive context.
cxinHorizontal center.
cyinVertical center.
linkinWhat the link is doing.

drawSleepFace() #

void kleidos::states::lock_clock::drawSleepFace(bool showClock)

Draw a sleep face exactly as the board sleeps under it, arming nothing.

For a capture: the clock in 1-bit at the current time, or the gray brand mark (and the gray clock when the time is not trusted).

Parameters
NameDirectionMeaning
showClockinTrue for the clock face, false for the brand mark.

fullRefreshDue() #

bool kleidos::states::lock_clock::fullRefreshDue(const RtcTime & local)
constexpr

Whether the minute local gets a full refresh.

Parameters
NameDirectionMeaning
localinThe local wall-clock time about to be shown.
Returns
True every kFullRefreshEveryMin minutes of the day.

gaugeRepaintOnMono() #

bool kleidos::states::dial::gaugeRepaintOnMono(uint8_t prevPct, uint8_t pct)
nodiscardconstexpr

Whether a hold gauge moving from prevPct to pct changes a 1-bit bar.

On a 1-bit panel the gauge draws only its empty rule (at 0) and inverts its cell when full (100 or more); every step between draws the same pixels. Each e-paper repaint is a partial refresh, so a screen repaints the gauge only when this is true.

Parameters
NameDirectionMeaning
prevPctinThe gauge percent last drawn.
pctinThe gauge percent now.
Returns
True when the bar would draw different pixels.

holdPct() #

uint8_t kleidos::states::twobtn::holdPct(uint32_t heldMs, uint32_t thresholdMs = kHoldMs)
nodiscardconstexpr

Fill percentage of a hold in progress.

Parameters
NameDirectionMeaning
heldMsinHow long the button has been down (ms).
thresholdMsinHold threshold; defaults to kleidos::states::twobtn::kHoldMs.
Returns
0..100, saturating at 100 once the threshold is reached.

microsToNextTick() #

uint64_t kleidos::states::lock_clock::microsToNextTick(uint8_t seconds)
constexpr

Microseconds from seconds past the minute to one second into the next.

On USB power the board never loses power, so the ESP32 timer stands in for the RTC interrupt; the extra second lets the alarm fire first.

Parameters
NameDirectionMeaning
secondsinSeconds past the minute now (0..59).
Returns
The timer wake delay in microseconds.

minutesSinceShown() #

uint16_t kleidos::states::lock_clock::minutesSinceShown(const RtcAlarm & armed, const RtcTime & utc)
constexpr

Minutes between the minute the glass shows and utc.

The glass shows the minute before the armed one.

Parameters
NameDirectionMeaning
armedinThe alarm that switched the board on.
utcinThe RTC time (UTC) now.
Returns
1 on time, more after a missed wake, 0 when nothing changed.

moveDown() #

uint16_t kleidos::states::twobtn::moveDown(uint16_t selected, uint16_t itemCount)
nodiscardconstexpr

A-short = DOWN: move the selection one item toward the bottom.

Wraps: stepping past the last item returns to the first. On a two-button device every extra press is a thumb movement, so a list that stops dead at its end forces the user to walk all the way back for the item just above the one they started on. The cycle is also what the settings tree already does, so both tabs of one pager move alike.

Parameters
NameDirectionMeaning
selectedinCurrent selection index.
itemCountinTotal selectable items (0 = nothing to move).
Returns
The next index, wrapping to 0 past the last item.

moveUp() #

uint16_t kleidos::states::twobtn::moveUp(uint16_t selected, uint16_t itemCount)
nodiscardconstexpr

B-short = UP: move the selection one item toward the top.

Wraps: stepping up from the first item lands on the last, which is the cheapest way to reach the end of a long list on two buttons.

Parameters
NameDirectionMeaning
selectedinCurrent selection index.
itemCountinTotal selectable items (0 = nothing to move).
Returns
The previous index, wrapping to the last item from 0.

nextMinuteAlarm() #

RtcAlarm kleidos::states::lock_clock::nextMinuteAlarm(const RtcTime & utc)
constexpr

The alarm for the minute after utc.

Hour and minute are both matched, so a wake that does not happen is retried a day later, not every hour at that minute.

Parameters
NameDirectionMeaning
utcinThe RTC time (UTC) the shown minute was read at.
Returns
The alarm to arm.

nextPage() #

Page kleidos::states::twobtn::nextPage(Page p, bool totpShown)
nodiscardconstexpr

B hold = next page (Credentials -> Totp -> Settings -> Credentials), skipping the 2FA page while it is hidden.

Parameters
NameDirectionMeaning
pinCurrent page.
totpShowninWhether the 2FA page is drawn.
Returns
The next page in the cyclic order.

onDial() #

bool kleidos::states::dial::onDial()
inlinenodiscard

Whether this board navigates with the ▲●▼ dial.

Returns
The profile's dial capability (true on the CoreInk).

pageCount() #

uint8_t kleidos::states::twobtn::pageCount(bool totpShown)
nodiscardconstexpr

Number of pages the pager cycles through and its strip draws.

Parameters
NameDirectionMeaning
totpShowninWhether the 2FA codes setting is on.
Returns
3, or 2 while the 2FA page is hidden.

pollDialKeys() #

DialKeys kleidos::states::dial::pollDialKeys(ButtonInput & up, ButtonInput & ok, ButtonInput * down)
inlinenodiscard

Read one frame of the dial grammar.

The OK hold is read first, then the OK tap, then ▲ and ▼ on their press edge, as every three-button list reads them.

Parameters
NameDirectionMeaning
upin, outThe ▲ input; its press edge is consumed when read.
okin, outThe OK input; its release edge is consumed when read.
downin, outThe ▼ input, or null on a board without one.
Returns
What the dial asked for this frame.

pollHoldGauge() #

uint8_t kleidos::states::twobtn::pollHoldGauge(HoldGauge & gauge, ButtonInput & btn)
inlinenodiscard

Convenience: advance a kleidos::states::twobtn::HoldGauge from a live button using the platform clock facade.

Reads the button level (not an edge), so it composes with the gesture predicates above: the same press that fills the gauge still resolves to a tap or a long-press through downShort / activateLong.

Parameters
NameDirectionMeaning
gaugein, outThe gauge to advance.
btnin, outThe button whose pressed level is sampled.
Returns
The fill to publish this frame (0..100).

pollListKeys() #

ListKeys kleidos::states::twobtn::pollListKeys(ButtonInput & btnA, ButtonInput & btnB)
inlinenodiscard

Read one frame of the list grammar: taps move, holds act.

The holds are read first, so a hold's release is never also a step.

Parameters
NameDirectionMeaning
btnAin, outThe A nav button; its edges are consumed.
btnBin, outThe B nav button; its edges are consumed.
Returns
What the keys asked for this frame.

prepareSleepFace() #

bool kleidos::states::lock_clock::prepareSleepFace(bool lowBattery)

Draw the face the board sleeps under, and arm what keeps it current.

The panel is woken first: an idle screen-off leaves it in deep sleep, where a flush never reaches the glass. With the clock shown and a trusted time: the next minute's alarm, then the clock in 1-bit for the same reading (the USB stand-in timer comes last, from armStandInTimer). Otherwise the face in gray, the brand mark when the owner hid the clock, and no alarm. On a critical battery the glass keeps the low-battery screen and nothing is armed. Call from the sleep path while the RTC bus is still up.

Parameters
NameDirectionMeaning
lowBatteryinTrue when the board sleeps because the battery is critical.
Returns
True when the minute tick was armed.

prevPage() #

Page kleidos::states::twobtn::prevPage(Page p, bool totpShown)
nodiscardconstexpr

Previous page (Credentials -> Settings -> Totp -> Credentials), skipping the 2FA page while it is hidden.

Parameters
NameDirectionMeaning
pinCurrent page.
totpShowninWhether the 2FA page is drawn.
Returns
The previous page in the cyclic order.

restingBand() #

DrawnBand kleidos::states::listslide::restingBand(const ui::Rect & body, uint16_t selected, uint16_t topRow, int16_t rowH, uint8_t visible, bool covered)
constexpr

The band a resting paint of the list leaves for the next frame.

A static paint draws the selection where a settled slide leaves it, so the first frame of the next step can narrow from it instead of repainting the whole body.

Parameters
NameDirectionMeaning
bodyinThe list's body.
selectedinThe selected row.
topRowinThe window's first row.
rowHinRow height (px).
visibleinWhole rows the body shows.
coveredinSomething was composited over the list (a toast).
Returns
The band; not valid when the selection is off the window or the list is covered.

runIfMinuteTick() #

void kleidos::states::lock_clock::runIfMinuteTick()

Run the minute tick when the RTC alarm switched the board on.

Call first thing at boot, before the HAL brings the panel up (its init clears the glass). On a tick it redraws the digits that changed, arms the next minute and cuts the power, and does not return; on a critical battery it stops the ticks instead. It returns on a normal boot, after disarming the alarm, and when the side key is pressed during the tick, so that press goes on to unlock.

setShown() #

bool kleidos::states::lock_clock::setShown(bool on)
nodiscard

Store whether the lock face shows the clock.

Parameters
NameDirectionMeaning
oninTrue to show the clock, false for the brand mark.
Returns
True when the setting was stored.

shown() #

bool kleidos::states::lock_clock::shown()
nodiscard

Whether the owner shows the clock on the lock face.

Returns
The stored setting; on when never set.

slideRegions() #

Regions kleidos::states::listslide::slideRegions(const Frame & frame, const DrawnBand & drawn)
constexpr

The rectangles a frame of the slide repaints.

  • The window still (windowStill): the band's old and new rows.
  • Otherwise (the window scrolls, no band was recorded, an overlay is up): the whole body.
  • The settling frame adds the strip from the bottom of the last whole row to the bottom of the body, where the resting list differs from the slide; merged into the band's rectangle when the two touch.
Parameters
NameDirectionMeaning
frameinThe frame.
drawninThe band the last paint recorded.
Returns
One or two rectangles inside the body.

stripSlot() #

uint8_t kleidos::states::twobtn::stripSlot(Page p, bool totpShown)
nodiscardconstexpr

The strip slot p occupies.

Parameters
NameDirectionMeaning
pinPage.
totpShowninWhether the 2FA page is drawn.
Returns
Its slot, 0-based; the hidden 2FA page answers the Credentials slot, where the pager moves a screen left on it.

tabIndex() #

uint8_t kleidos::states::tabIndex(VaultTab tab)
nodiscardconstexpr

The logical index of tab, for the per-tab arrays.

Parameters
NameDirectionMeaning
tabinLogical tab.
Returns
Its value, 0..2.

upShort() #

bool kleidos::states::twobtn::upShort(ButtonInput & btnB)
inlinenodiscard

B-short edge: UP / PREV. Consumes the click edge.

Parameters
NameDirectionMeaning
btnBin, outThe B nav button; its click edge is consumed.
Returns
true on the B-short click edge this frame.

vaultTabStrip() #

VaultTabStrip kleidos::states::vaultTabStrip(bool totpShown)
nodiscardconstexpr

The strip the vault draws.

Parameters
NameDirectionMeaning
totpShowninWhether the 2FA codes setting is on.
Returns
Credentials, 2FA and Actions; or Credentials and Actions while 2FA codes are off.

watchGlassHeader() #

void kleidos::states::watchGlassHeader(PowerManager & power)

Keep the battery gauge of the header on the glass live, on a tick at rest.

Paints nothing on a sleeping panel (sleeping_panel.h): the wake takes a fresh sample and the first tick after it repaints. Called by the main loop once per tick, after the compositor pass and outside any frame, never on a tick that changed state (the entering screen drew its header live) nor while a modal phase or the critical-battery screen owns the glass.

Parameters
NameDirectionMeaning
powerin, outBoard power manager (the battery sample).

windowStill() #

bool kleidos::states::listslide::windowStill(const Frame & frame, const DrawnBand & drawn)
constexpr

Whether a frame's window is where the last paint left it.

Parameters
NameDirectionMeaning
frameinThe frame.
drawninThe band the last paint recorded.
Return values
ValueMeaning
trueNo sub-row shift, the same first row, a recorded band, and nothing forcing the whole body: only the band moves.

Back to the top

Variable Documentation

kFullRefreshEveryMin #

uint16_t kleidos::states::lock_clock::kFullRefreshEveryMin
inlineconstexpr

Every how many minutes of the day the face gets a full refresh instead of a partial one: at every full hour, clearing what the partial updates leave.

kHoldGraceMs #

uint32_t kleidos::states::twobtn::kHoldGraceMs
inlineconstexpr

Grace period (ms) before the gauge shows any fill. A quick tap is a tap, not an aborted hold, so it must not flash a sliver of progress under the label.

kHoldMs #

uint32_t kleidos::states::twobtn::kHoldMs
inlineconstexpr

Long-press threshold (ms) for A-long / B-long: the motion.longpress design token, the same value the FSM uses for kLongPressMs (asserted below) and the single named source of truth for every Stick hold.

kHoldPctStep #

uint8_t kleidos::states::twobtn::kHoldPctStep
inlineconstexpr

Quantization step (%) of the reported fill. The gauge repaints only when it crosses a step, so a 800 ms hold costs ~20 partial repaints instead of one per frame — enough steps to read as continuous motion, few enough to leave the UI core idle between them.

kTickWindowSec #

uint8_t kleidos::states::lock_clock::kTickWindowSec
inlineconstexpr

Seconds into the minute within which a power-on is a tick: the RTC interrupt switches the board on at the minute.

Back to the top