ESR-2025/src/state_machine.h

60 lines
1.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* File: state_machine.h */
/**
* @file state_machine.h
* @brief State machine interface for the beverage dispenser core program.
*
* This module drives a keypadandLCD UI to select beverage types (AD),
* choose quantities, confirm orders, detect door events, and edit stock levels.
*
* @author Frederik Beimgraben
* @author Minh Dan Cam
* @author Luis Meyer
* @date 2025-07-03
*/
#ifndef STATE_MACHINE_H
#define STATE_MACHINE_H
#include <stdint.h>
#include <stdbool.h>
/**
* @enum State_t
* @brief All possible states of the UI state machine.
*/
typedef enum {
STATE_IDLE, /**< Waiting for user input */
STATE_SEL_COUNT, /**< Selecting order quantity */
STATE_CONFIRMED, /**< Order confirmed */
STATE_OPEN, /**< Door is open */
STATE_UNAUTHORIZED, /**< Unauthorized door opening */
STATE_NONE_SELECTED, /**< No beverage selected at confirm */
STATE_RESET, /**< Transient “reset” display */
STATE_EDIT_STOCK_SELECT, /**< Select which beverages stock to edit */
STATE_EDIT_STOCK_SET, /**< Enter new stock value */
STATE_EDIT_STOCK_CONFIRMED /**< Stock update confirmed */
} State_t;
/**
* @enum SelectedBev_t
* @brief Identifiers for the four beverage types.
*/
typedef enum {
BEV_A, /**< Beverage A */
BEV_B, /**< Beverage B */
BEV_C, /**< Beverage C */
BEV_D /**< Beverage D */
} SelectedBev_t;
/**
* @brief Initialize the state machine, keypad, door sensor, and LCD.
*/
void sm_init(void);
/**
* @brief Enter the statemachines main loop (lowpower + interrupts).
*/
void sm_loop(void);
#endif // STATE_MACHINE_H