/* * MIT License * * Copyright (c) 2025 OpenCode * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef BILLING_FACE_H_ #define BILLING_FACE_H_ /* * BILLING FACE * * A stopwatch-style face that accrues money instead of elapsed time. You set an * hourly rate (in generic monetary units) using an on-face editor, and the face * displays the current amount billed for the time elapsed since you started it. * * Controls: * - Alarm button: start / stop the billing timer. * - Light button (when stopped): reset the timer. * - Light button long press: enter the rate editor (or, inside the editor, * save the rate and exit). * - Inside the editor: * - Light button: move to the next digit. * - Alarm button: increment the current digit. * - Alarm button long press: rapidly increment the current digit. * - Mode button or Light long press: save and exit. * * Display (money only): * - Bottom 6 digits: the amount billed, space-padded (no leading zeros), * saturating at 999999 when it no longer fits in 6 digits. * - Top-right 2 digits: the two most-significant digits of the hourly rate, * as a reminder of what you're billing at. */ #include "movement.h" typedef struct { bool running; rtc_counter_t start_counter; // virtual 128 Hz start time (so resume is accurate) rtc_counter_t paused_counter; // accumulated ticks while stopped uint32_t rate_money_per_hour; // hourly rate uint32_t saved_rate; // rate at editor entry, restored if the edit times out uint8_t mode; // 0 = normal, 1 = editing rate uint8_t cursor; // active digit (0..5) while editing bool editor_quick; // auto-increment while Alarm is held } billing_state_t; void billing_face_setup(uint8_t watch_face_index, void ** context_ptr); void billing_face_activate(void *context); bool billing_face_loop(movement_event_t event, void *context); void billing_face_resign(void *context); #define billing_face ((const watch_face_t){ \ billing_face_setup, \ billing_face_activate, \ billing_face_loop, \ billing_face_resign, \ NULL, \ }) #endif // BILLING_FACE_H_