You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.3 KiB
95 lines
2.3 KiB
2 years ago
|
/**
|
||
|
* TODO file description
|
||
|
*/
|
||
|
|
||
|
#ifndef BLUEPILLTROUBA_APP_GUI_H
|
||
|
#define BLUEPILLTROUBA_APP_GUI_H
|
||
|
|
||
|
#include "cmsis_os2.h"
|
||
|
#include <stdbool.h>
|
||
|
#include "gui_event.h"
|
||
|
|
||
|
void app_task_gui(void *argument);
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Screen callback type. The event is either INIT, PAINT, or one of the input events.
|
||
|
*/
|
||
|
typedef void (*screen_t)(GuiEvent event);
|
||
|
|
||
|
|
||
|
|
||
|
/** Input beep (push or knob turn) */
|
||
|
void input_sound_effect();
|
||
|
|
||
|
/** Switch to a different screen. Handles initial push state handling (so release
|
||
|
* does not cause a "click" event).
|
||
|
*
|
||
|
* @param pScreen - screen to switch to
|
||
|
* @param init - call the INIT event immediately after
|
||
|
*/
|
||
|
void switch_screen(screen_t pScreen, bool init);
|
||
|
|
||
|
void request_paint();
|
||
|
|
||
|
uint32_t push_time();
|
||
|
|
||
|
// prototypes for screen handlers
|
||
|
|
||
|
void screen_home(GuiEvent event);
|
||
|
void screen_manual(GuiEvent event);
|
||
|
void screen_manual_menu(GuiEvent event);
|
||
|
|
||
|
static struct State {
|
||
|
/// Latest oven temp readout
|
||
|
float oven_temp;
|
||
|
//float soc_temp;
|
||
|
|
||
|
// manual mode controls
|
||
|
|
||
|
/// Currently set target temp
|
||
|
int set_temp;
|
||
|
/// Heater enabled status (only visual)
|
||
|
bool heater_enabled;
|
||
|
|
||
|
/// Prescaller for the knob, CCW direction.
|
||
|
/// Event increments this counter and resets the other. Knob turn event is generated on overflow.
|
||
|
bool down_prescaller;
|
||
|
/// Prescaller for the knob, CW direction
|
||
|
/// See `down_prescaller`
|
||
|
bool up_prescaller;
|
||
|
|
||
|
/// Curent status of the push button
|
||
|
bool pushed;
|
||
|
/// Repaint was requested from the screen code
|
||
|
bool paint_needed;
|
||
|
|
||
|
/// Timestamp of the last GUI tick
|
||
|
uint32_t last_tick_time;
|
||
|
/// Timestamp when the button was pushed
|
||
|
uint32_t push_time;
|
||
|
/// Timestamp when we last read oven temperature for display
|
||
|
uint32_t last_read_temp_time;
|
||
|
|
||
|
/// true if the button is still held since init (i.e. the push action should not work as "enter")
|
||
|
bool initial_pushed;
|
||
|
|
||
|
/// Pointer to the currently active screen func
|
||
|
screen_t screen;
|
||
|
|
||
|
/// data specific for each of the screens (not persistent across screen switching)
|
||
|
union {
|
||
|
/// Generic menu
|
||
|
struct menu_state {
|
||
|
int pos;
|
||
|
int len;
|
||
|
uint32_t change_time;
|
||
|
uint32_t slide_end_time;
|
||
|
uint16_t text_slide;
|
||
|
uint8_t tick_counter;
|
||
|
} menu;
|
||
|
} page;
|
||
|
} s_app = {};
|
||
|
|
||
|
#endif //BLUEPILLTROUBA_APP_GUI_H
|