/** * Dispay */ #include "user_interface.h" #include "twi.h" #include "ssd1306.h" #include "sevenseg.h" #include "global_state.h" #include "radiation.h" static bool ended_loading = false; static struct SevenSeg sseg = { .x0 = 0, .y0 = 0, .charwidth = 17, .thick = 3, //.charwidth = 16, //.thick = 1, .spacing = 4, }; void clear_screen() { ssd1306_clearScreen(); } void init_user_interface() { TWI_Init(); ssd1306_128x32_i2c_init(); ssd1306_clearScreen(); } void turn_off_display() { ssd1306_displayOff(); } static volatile uint16_t last_value = 0; static volatile uint16_t last_value_d = 0; void show_current_radiation() { // this is called from main, so we can sleep if (!ended_loading) { int progress = rad_get_progress(); if (progress == 100) { show_loading_screen(100, false); ended_loading = true; // so user sees it _delay_ms(250); clear_screen(); // start showing values } else { if (progress < 10) progress = 10; show_loading_screen(progress, false); return; } } // uint16_t cpm = rad_get_cpm(); // if (cpm != last_value) { // last_value = cpm; // sseg_number(&sseg, cpm, 5, 1); // } uint8_t decimals = 0; uint16_t usvh = rad_get_usvh(&decimals); if (usvh != last_value || decimals != last_value_d) { last_value = usvh; last_value_d = decimals; sseg_number(&sseg, usvh, 5, decimals); } }