Skip to content

mastedore/TitaniumFSM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TitaniumFSM logo

TitaniumFSM

For examples, see /examples Owake uses TiFSM as its backend

Note

This is the Community Edition of TitaniumFSM, licensed under GPLv3.0. For a commercial/private license, contact markusianito@proton.me

TitaniumFSM is a lightweight, dependency-free Finite State Machine engine written in pure C89, designed for portability, scalability, and architectural clarity.

-> It runs anywhere C runs.

From 8-bit microcontrollers to large-scale applications, TitaniumFSM provides a structured and maintainable way to organize behavior using hierarchical state management.

Features

  • Written in C89

  • No dependencies

  • Portable across any architecture supporting C

  • Suitable for embedded systems and high-level applications

  • Scalable design

  • Optional C++ wrapper

  • No STL

  • No RTTI

  • No mandatory RAII

  • Clear hierarchical state organization

  • Safe state and subsystem transitions

  • Minimal runtime overhead

Conceptual Model

TitaniumFSM is built around four core components:

Program -> State -> Subsystem -> FSM

Program

A Program is the atomic behavioral unit. It is a struct containing three function pointers: setup, loop, exit

Each state executes its assigned Program through these lifecycle callbacks.

State

A State contains: A Program A pointer to its owning Subsystem States can request transitions by referencing IDs.

Subsystem

A Subsystem groups multiple states. It acts as a self-contained module and has its own dispatcher that: Calls setup, loop, and exit appropriately Handles transitions between its internal states

Example use cases:

  • Clock / Timer / Alarm module

  • Game menu system

  • Communication protocols

  • Device operating modes

FSM

The FSM is the top-level container. It holds multiple Subsystems and:

  • Executes the current active Subsystem

  • Safely manages transitions between Subsystems

  • Delegates execution through internal dispatchers

Call fsm.execute() inside your main loop and the engine handles the rest.

Transition System

Transitions are performed using 16-bit IDs. This allows up to:

65,535 States, 65,535 Subsystems

States can request state changes within their Subsystem. Subsystems can request transitions to other Subsystems via the FSM. All transitions are handled safely by the dispatching system.

Usage

In C

TitaniumFSM provides helper functions to create and configure Programs, States, Subsystems and FSM instances.

The dispatcher handles lifecycle management automatically.

In C++

The optional wrapper allows you to:

FSM fsm;

// in loop
fsm.execute();

No STL :o No RTTI :O No forced RAII.

Pure control, minimal abstraction, maximum predictability.

Use Cases

AVR projects (clocks, menus, control systems)

Embedded firmware

Communication protocols

UI navigation systems

Game state management

Industrial control logic

Any application that benefits from deterministic behavior control

Design Philosophy

TitaniumFSM is built on three principles:

  • Explicit structure
  • Deterministic execution
  • Architectural clarity

It encourages modular thinking and clean separation of responsibilities.

No magic. No hidden allocations. No runtime surprises.

Just controlled state flow.

License

GPL v3.0

  • Marcos.

About

TitaniumFSM hierarchical finite state machine enigne

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors