Refactor presto/records_on_the_day.py into a unified app with a splash screen, search capability, and the existing calendar. All work is in the single MicroPython file.
New states
STATE_HOME (new, default on boot/wake)
STATE_SEARCH_INPUT (new — search box + on-screen keyboard)
STATE_SEARCH_RESULTS (new — results list, reuses day-view rendering)
New globals: search_query, search_results, search_results_error, search_scroll_offset, _search_content_height, keyboard_mode, previous_state.
Splash screen (STATE_HOME)
draw_home_screen() with "Search Collection" and "Today's Records" buttons. Tapping "Today's Records" → month view with today highlighted. Tapping "Search Collection" → search input.
On-screen keyboard (STATE_SEARCH_INPUT)
QWERTY layout (3 rows) + numbers/symbols. Bottom row: [123/ABC] [Space] [Backspace] [OK]. OK dimmed when query empty. _keyboard_hit_test() maps touch to action. handle_search_input_touch() dispatches all actions. Visual feedback via _flash_key().
Search results (STATE_SEARCH_RESULTS)
Reuses _draw_record_row(). Own scroll state (search_scroll_offset, _search_content_height). Header: "Search: " with truncation. Empty: "No records found". Error: "Could not reach server" with retry-on-tap.
API client
fetch_search_results(query) → GET /api/v1/collection?q=<encoded>&limit=20. Returns (records_list, error_flag).
Generic display pipeline
prepare_records_for_display(recs=None) and preload_record_thumbnails(recs=None) accept optional list. Height cache tracked per source.
Navigation tracking
previous_state tracks detail origin (STATE_DAY / STATE_SEARCH_RESULTS). Back → correct origin. draw_record_detail() reads from search_results or records.
Back-to-Home
Month header gains "H" Home button. wake_display() always sets state = STATE_HOME. Search input header Back → Home.
Boot flow
Starts at draw_home_screen(), no auto-fetch. User taps a button.
Main loop
New dispatches for STATE_HOME, STATE_SEARCH_INPUT, STATE_SEARCH_RESULTS (drag scroll mirrors day view).
Touch helpers
touch_to_record_index() accepts optional recs and offset params.
Verification
Syntax check passes (python3 py_compile). No STATE_STARTUP references remain.