Skip to content

Mode Stack Manager

Neo Hop edited this page Jun 18, 2024 · 1 revision

Design

  • Run mode with highest priority
  • Add or remove modes from stack
  • Only one instance of a mode can exist on the stack.
  • Modes cannot have same priority
  • There is always and idle state with priority level 0.
  • Store current running state in Marker State Manager

UML

Software component diagram

Mode Stack Manager-2024-06-18-09-56-56

Stack flow diagram

image

Variables

Config

none

State

uint8_t current_mode

Typedefs

typedef struct {
	uint8_t id; // unique
	const char* name;

	uint8_t priority;
	
	mode_function_t mode_enter_func;
	mode_function_t mode_function;
	mode_function_t mode_exit_func;
} stack_manager_mode_t;

typedef void (* mode_function_t)( /* void * */ );

Functions

private

esp_err_t mode_stack_manager_sort();
void mode_stack_manager_print();
void mode_stack_manager_task(void* args);

public

esp_err_t mode_stack_manager_init(stack_manager_mode_t* idle_mode);
esp_err_t mode_stack_manager_add_mode(stack_manager_mode_t* mode);
esp_err_t mode_stack_manager_enter_mode(uint8_t id);
esp_err_t mode_stack_manager_exit_mode(uint8_t id);
esp_err_t mode_stack_manager_get_current_mode(stack_manager_mode_t** mode);
esp_err_t mode_stack_manager_get_mode(uint8_t id, stack_manager_mode_t** mode);