60 lines
1.7 KiB
C
60 lines
1.7 KiB
C
/* File: state_machine.h */
|
||
/**
|
||
* @file state_machine.h
|
||
* @brief State machine interface for the beverage dispenser core program.
|
||
*
|
||
* This module drives a keypad‐and‐LCD UI to select beverage types (A–D),
|
||
* 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 beverage’s 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 state‐machine’s main loop (low‐power + interrupts).
|
||
*/
|
||
void sm_loop(void);
|
||
|
||
#endif // STATE_MACHINE_H
|