/* * MIT License * * Copyright (c) 2023 Wesley Aptekar-Cassels * Copyright (c) 2025 Vaipex * * 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. */ #include #include #include "simple_coin_flip_face.h" #include "delay.h" void simple_coin_flip_face_setup(uint8_t watch_face_index, void ** context_ptr) { (void) watch_face_index; if (*context_ptr == NULL) { *context_ptr = malloc(sizeof(simple_coin_flip_face_state_t)); memset(*context_ptr, 0, sizeof(simple_coin_flip_face_state_t)); } } void simple_coin_flip_face_activate(void *context) { (void) context; } static uint32_t get_random(uint32_t max) { #if __EMSCRIPTEN__ return rand() % max; #else return arc4random_uniform(max); #endif } static void draw_start_face(void) { watch_clear_display(); if (watch_get_lcd_type() == WATCH_LCD_TYPE_CLASSIC) { watch_display_text(WATCH_POSITION_BOTTOM, " Flip"); } else { watch_display_text(WATCH_POSITION_BOTTOM, "Flip"); } } static void set_pixels(int pixels[3][4][2], int j_len) { for(int loopruns = 0; loopruns<2; loopruns++) { for(int i = 0; i<3; i++) { watch_clear_display(); for(int j = 0; jis_start_face && !state->active){ if(state->inactivity_ticks >= 15){ state->is_start_face = false; state->inactivity_ticks = 0; draw_start_face(); }else{ state->inactivity_ticks++; } } else { state->inactivity_ticks = 0; } break; //execute same action for light and alarm button case EVENT_LIGHT_BUTTON_UP: case EVENT_ALARM_BUTTON_UP: if (!state->active) { state->active = true; _blink_face_update_lcd(state); state->active = false; state->is_start_face = false; state->inactivity_ticks = 0; } break; case EVENT_TIMEOUT: movement_move_to_face(0); break; case EVENT_LOW_ENERGY_UPDATE: break; default: return movement_default_loop_handler(event); } return true; } void simple_coin_flip_face_resign(void *context) { (void) context; }