ICARUS OS (Intelligent Cooperative Architecture for Real-time Unified Systems) 0.1.0
Preemptive Real-Time Operating System for ARM Cortex-M7
Loading...
Searching...
No Matches
display.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  msg_history_entry_t
 Message history entry for rolling window display. More...
 
struct  msg_history_t
 Message history buffer for a pipe. More...
 

Macros

#define ENABLE_HEARTBEAT_VISUALIZATION   1
 
#define ROW_HEADER   1
 
#define ROW_SEPARATOR   9
 
#define ROW_HEARTBEAT   10
 
#define ROW_TASK_A   11
 
#define ROW_TASK_B   12
 
#define ROW_TASK_C   13
 
#define BAR_WIDTH   40
 
#define BAR_COL_START   6
 
#define VBAR_HEIGHT   10
 
#define VBAR_COL   70
 
#define HEARTBEAT_ON_TICKS   437
 
#define HEARTBEAT_OFF_TICKS   479
 
#define HEARTBEAT_PERIOD_TICKS   (HEARTBEAT_ON_TICKS + HEARTBEAT_OFF_TICKS)
 
#define TASK_A_PERIOD_TICKS   2000
 
#define TASK_B_PERIOD_TICKS   4000
 
#define TASK_C_PERIOD_TICKS   3000
 
#define RENDER_INTERVAL_TICKS   20
 
#define CYCLE_PAUSE_TICKS   100
 
#define MSG_HISTORY_LEN   8
 
#define MSG_HISTORY_MAX_BYTES   4
 

Functions

void display_init (void)
 Initialize terminal display - clear screen and print header.
 
void display_render_bar (uint8_t row, const char *task_name, uint32_t elapsed_ticks, uint32_t period_ticks)
 Render a progress bar on a fixed row.
 
void display_render_banner (uint8_t row, const char *task_name, bool is_on)
 Render a simple flashing banner (on/off indicator)
 
void display_render_vbar (uint8_t start_row, uint8_t col, uint32_t count, uint32_t max_count)
 Render a vertical bar showing semaphore fill level.
 
void display_render_pipe (uint8_t start_row, uint8_t col, const char *label, uint8_t count, uint8_t max_count, uint8_t last_sent, uint8_t last_recv, bool show_sent, bool show_recv)
 Render a message queue visualization panel.
 
void display_render_producer (uint8_t row, const char *task_name, uint32_t elapsed_ticks, uint32_t period_ticks, uint8_t msg_value, bool show_msg)
 Render a producer task bar with sent message indicator.
 
void display_render_consumer (uint8_t row, const char *task_name, uint32_t elapsed_ticks, uint32_t period_ticks, uint8_t msg_value, bool show_msg)
 Render a consumer task bar with received message indicator.
 
void msg_history_init (msg_history_t *hist)
 Initialize a message history buffer.
 
void msg_history_add (msg_history_t *hist, const uint8_t *data, uint8_t len, uint8_t source_id, bool is_send)
 Add a message to history.
 
void display_render_msg_history (uint8_t row, uint8_t col, msg_history_t *hist, const char *label)
 Render message history as a rolling window.
 

Macro Definition Documentation

◆ BAR_COL_START

#define BAR_COL_START   6

Definition at line 40 of file display.h.

◆ BAR_WIDTH

#define BAR_WIDTH   40

Definition at line 39 of file display.h.

◆ CYCLE_PAUSE_TICKS

#define CYCLE_PAUSE_TICKS   100

Definition at line 56 of file display.h.

◆ ENABLE_HEARTBEAT_VISUALIZATION

#define ENABLE_HEARTBEAT_VISUALIZATION   1

Definition at line 23 of file display.h.

◆ HEARTBEAT_OFF_TICKS

#define HEARTBEAT_OFF_TICKS   479

Definition at line 48 of file display.h.

◆ HEARTBEAT_ON_TICKS

#define HEARTBEAT_ON_TICKS   437

Definition at line 47 of file display.h.

◆ HEARTBEAT_PERIOD_TICKS

#define HEARTBEAT_PERIOD_TICKS   (HEARTBEAT_ON_TICKS + HEARTBEAT_OFF_TICKS)

Definition at line 49 of file display.h.

◆ MSG_HISTORY_LEN

#define MSG_HISTORY_LEN   8

Definition at line 134 of file display.h.

◆ MSG_HISTORY_MAX_BYTES

#define MSG_HISTORY_MAX_BYTES   4

Definition at line 135 of file display.h.

◆ RENDER_INTERVAL_TICKS

#define RENDER_INTERVAL_TICKS   20

Definition at line 55 of file display.h.

◆ ROW_HEADER

#define ROW_HEADER   1

Definition at line 26 of file display.h.

◆ ROW_HEARTBEAT

#define ROW_HEARTBEAT   10

Definition at line 29 of file display.h.

◆ ROW_SEPARATOR

#define ROW_SEPARATOR   9

Definition at line 27 of file display.h.

◆ ROW_TASK_A

#define ROW_TASK_A   11

Definition at line 30 of file display.h.

◆ ROW_TASK_B

#define ROW_TASK_B   12

Definition at line 31 of file display.h.

◆ ROW_TASK_C

#define ROW_TASK_C   13

Definition at line 32 of file display.h.

◆ TASK_A_PERIOD_TICKS

#define TASK_A_PERIOD_TICKS   2000

Definition at line 50 of file display.h.

◆ TASK_B_PERIOD_TICKS

#define TASK_B_PERIOD_TICKS   4000

Definition at line 51 of file display.h.

◆ TASK_C_PERIOD_TICKS

#define TASK_C_PERIOD_TICKS   3000

Definition at line 52 of file display.h.

◆ VBAR_COL

#define VBAR_COL   70

Definition at line 44 of file display.h.

◆ VBAR_HEIGHT

#define VBAR_HEIGHT   10

Definition at line 43 of file display.h.

Function Documentation

◆ display_init()

void display_init ( void  )

Initialize terminal display - clear screen and print header.

Initialize terminal display - clear screen and print header.

Performs one-time initialization of the terminal display:

  • Clears screen and hides cursor
  • Renders ICARUS ASCII art logo header
  • Initializes task progress bar rows
  • Sets up heartbeat visualization (if enabled)
Precondition
USB CDC must be initialized and connected
Postcondition
Terminal ready for real-time updates
Note
This function is idempotent - subsequent calls are no-ops
Called automatically by os_idle_task on first run
Logo Display:
*     ┌──────────────────────────────────────────────────────────────┐
*     │   ██╗ ██████╗  █████╗ ██████╗ ██╗   ██╗ ██████╗              │
*     │   ██║██╔════╝ ██╔══██╗██╔══██╗██║   ██║██╔════╝              │
*     │   ██║██║      ███████║██████╔╝██║   ██║╚█████╗               │
*     │   ██║██║      ██╔══██║██╔══██╗██║   ██║ ╚═══██╗              │
*     │   ██║╚██████╗ ██║  ██║██║  ██║╚██████╔╝██████╔╝              │
*     │   ╚═╝ ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚═════╝               │
*     │   Preemptive Kernel • ARMv7E-M • STM32H750                   │
*     └──────────────────────────────────────────────────────────────┘
* 

Definition at line 654 of file display.c.

References ANSI_GOTO, ANSI_HIDE_CURSOR, display_render_banner(), display_render_bar(), os_get_num_created_tasks(), os_get_task_name(), ROW_HEADER, ROW_HEARTBEAT, ROW_SEPARATOR, ROW_TASK_A, ROW_TASK_C, TASK_A_PERIOD_TICKS, TASK_B_PERIOD_TICKS, and TASK_C_PERIOD_TICKS.

Referenced by os_idle_task().

◆ display_render_banner()

void display_render_banner ( uint8_t  row,
const char *  task_name,
bool  is_on 
)

Render a simple flashing banner (on/off indicator)

Parameters
rowterminal row (1-indexed)
task_nametask name string
is_ontrue to show banner (LED on), false to clear (LED off)

Render a simple flashing banner (on/off indicator)

Displays or clears a star-filled banner synchronized with the heartbeat LED. Used to provide visual confirmation that the kernel scheduler is running.

Parameters
[in]rowTerminal row (1-indexed)
[in]task_nameTask name to display at banner edges
[in]is_ontrue = show banner (LED on), false = clear line (LED off)
Display Format (when on):
*     [>ICARUS_HEARTBEAT<] ★★★★★★★★★★★★★★★★★★★★ [>ICARUS_HEARTBEAT<]
* 

Definition at line 306 of file display.c.

References ANSI_GOTO, and BAR_WIDTH.

Referenced by display_init(), and os_heartbeat_task().

◆ display_render_bar()

void display_render_bar ( uint8_t  row,
const char *  task_name,
uint32_t  elapsed_ticks,
uint32_t  period_ticks 
)

Render a progress bar on a fixed row.

Parameters
rowterminal row (1-indexed)
task_nametask name string (from TCB)
elapsed_ticksticks elapsed in current period
period_tickstotal ticks for this period

Render a progress bar on a fixed row.

Displays a fixed-width progress bar showing task execution progress within its current period. Uses Unicode block characters for smooth fill animation.

Parameters
[in]rowTerminal row (1-indexed)
[in]task_nameTask name string (from TCB, max 16 chars displayed)
[in]elapsed_ticksTicks elapsed in current period
[in]period_ticksTotal ticks for this period (must be > 0)
Display Format:
*     [task_name] ████████████────────────────  160 / 2000 ticks
* 
Note
Clears to end of line to prevent display artifacts
Division by zero is guarded (period_ticks forced to 1 if 0)

Definition at line 247 of file display.c.

References ANSI_GOTO, and BAR_WIDTH.

Referenced by display_init().

◆ display_render_consumer()

void display_render_consumer ( uint8_t  row,
const char *  task_name,
uint32_t  elapsed_ticks,
uint32_t  period_ticks,
uint8_t  msg_value,
bool  show_msg 
)

Render a consumer task bar with received message indicator.

Parameters
rowterminal row (1-indexed)
task_nametask name string
elapsed_ticksticks elapsed in current period
period_tickstotal ticks for this period
msg_valuelast message value received
show_msgtrue to show message value with animation

Render a consumer task bar with received message indicator.

Displays a magenta-colored progress bar for consumer tasks with an animated arrow indicator showing the last received message value.

Parameters
[in]rowTerminal row (1-indexed)
[in]task_nameTask name string
[in]elapsed_ticksTicks elapsed in current period
[in]period_ticksTotal ticks for this period
[in]msg_valueLast message value received (0-255)
[in]show_msgtrue to show message indicator with flash effect
Display Format:
*     [consumer] ████████████────────  160/2000 ←[42]
* 

Definition at line 580 of file display.c.

References ANSI_GOTO, and BAR_WIDTH.

◆ display_render_msg_history()

void display_render_msg_history ( uint8_t  row,
uint8_t  col,
msg_history_t hist,
const char *  label 
)

Render message history as a rolling window.

Parameters
rowstarting row for display
colcolumn position
histpointer to history buffer
labellabel for the history (e.g., "SS", "SM")

Render message history as a rolling window.

Displays the last MSG_HISTORY_LEN messages in a bordered panel. Uses ASCII box drawing characters for terminal compatibility. Color-codes entries: green for sends, magenta for receives.

Parameters
[in]rowStarting terminal row (1-indexed)
[in]colColumn position for left edge of panel
[in]histPointer to history buffer to render
[in]labelShort label for panel header (e.g., "SS", "SM")
Display Format:
*     +---SS---+
*     |>P0: 42|   <- Producer 0 sent 42
*     |<C0: 42|   <- Consumer 0 received 42
*     |>P0: 43|
*     +---------+
* 

Definition at line 174 of file display.c.

References ANSI_BOLD, ANSI_CYAN, ANSI_GOTO, ANSI_GREEN, ANSI_MAGENTA, ANSI_RESET, msg_history_t::count, msg_history_entry_t::data, msg_history_t::entries, msg_history_t::head, msg_history_entry_t::is_send, msg_history_entry_t::len, MSG_HISTORY_LEN, and msg_history_entry_t::source_id.

◆ display_render_pipe()

void display_render_pipe ( uint8_t  start_row,
uint8_t  col,
const char *  label,
uint8_t  count,
uint8_t  max_count,
uint8_t  last_sent,
uint8_t  last_recv,
bool  show_sent,
bool  show_recv 
)

Render a message queue visualization panel.

Parameters
start_rowtop row of the panel (1-indexed)
colcolumn position for the panel
labelshort label for the queue (e.g., "SS", "SM")
countcurrent message count in queue
max_countmaximum queue capacity
last_sentlast message value sent (0-255)
last_recvlast message value received (0-255)
show_senttrue if last_sent is valid
show_recvtrue if last_recv is valid

Render a message queue visualization panel.

Displays a compact panel showing pipe fill level and recent send/receive activity. Includes horizontal fill bar and directional arrows for message flow indication.

Parameters
[in]start_rowTop row of the panel (1-indexed)
[in]colColumn position for left edge
[in]labelShort label for the queue (e.g., "Q1", "PIPE0")
[in]countCurrent byte count in pipe
[in]max_countMaximum pipe capacity in bytes
[in]last_sentLast message value sent (0-255)
[in]last_recvLast message value received (0-255)
[in]show_senttrue to display sent indicator with animation
[in]show_recvtrue to display received indicator with animation
Display Format:
*     PIPE0
*     [████────]
*      12/32
*     →123      <- Green arrow + sent value
*     ← 45      <- Magenta arrow + received value
* 

Definition at line 431 of file display.c.

References ANSI_GOTO.

◆ display_render_producer()

void display_render_producer ( uint8_t  row,
const char *  task_name,
uint32_t  elapsed_ticks,
uint32_t  period_ticks,
uint8_t  msg_value,
bool  show_msg 
)

Render a producer task bar with sent message indicator.

Parameters
rowterminal row (1-indexed)
task_nametask name string
elapsed_ticksticks elapsed in current period
period_tickstotal ticks for this period
msg_valuelast message value sent
show_msgtrue to show message value with animation

Render a producer task bar with sent message indicator.

Displays a green-colored progress bar for producer tasks with an animated arrow indicator showing the last sent message value.

Parameters
[in]rowTerminal row (1-indexed)
[in]task_nameTask name string
[in]elapsed_ticksTicks elapsed in current period
[in]period_ticksTotal ticks for this period
[in]msg_valueLast message value sent (0-255)
[in]show_msgtrue to show message indicator with flash effect
Display Format:
*     [producer] ████████████────────  160/2000 →[42]
* 

Definition at line 516 of file display.c.

References ANSI_GOTO, and BAR_WIDTH.

◆ display_render_vbar()

void display_render_vbar ( uint8_t  start_row,
uint8_t  col,
uint32_t  count,
uint32_t  max_count 
)

Render a vertical bar showing semaphore fill level.

Parameters
start_rowtop row of the vertical bar (1-indexed)
colcolumn position for the bar
countcurrent semaphore count
max_countmaximum semaphore capacity (init_count)

Displays a vertical bar chart representing semaphore count as a percentage of maximum capacity. Bar fills from bottom to top. Uses ASCII box drawing for terminal compatibility.

Parameters
[in]start_rowTop row of the vertical bar (1-indexed)
[in]colColumn position for left edge
[in]countCurrent semaphore count
[in]max_countMaximum semaphore capacity
Display Format:
*       SEM
*     +---+
*     |###|  <- Filled portion (green)
*     |###|
*     |   |  <- Empty portion
*     |   |
*     +---+
*      3/10  <- Current/max count
* 
Note
Division by zero is guarded (max_count forced to 1 if 0)

Definition at line 352 of file display.c.

References ANSI_CYAN, ANSI_GOTO, ANSI_GREEN, ANSI_RESET, and VBAR_HEIGHT.

◆ msg_history_add()

void msg_history_add ( msg_history_t hist,
const uint8_t *  data,
uint8_t  len,
uint8_t  source_id,
bool  is_send 
)

Add a message to history.

Parameters
histpointer to history buffer
datamessage data
lenmessage length in bytes
source_idproducer ID (use 0xFF if unknown)
is_sendtrue if this is a send event, false for receive

Add a message to history.

Adds a new entry at the head position using circular buffer semantics. Oldest entries are overwritten when buffer is full.

Parameters
[in,out]histPointer to history buffer
[in]dataMessage data bytes
[in]lenNumber of bytes in message (clamped to MSG_HISTORY_MAX_BYTES)
[in]source_idProducer/consumer ID (0-254, 0xFF = unknown)
[in]is_sendtrue = send event, false = receive event
Precondition
hist != NULL
data != NULL
len > 0

Definition at line 127 of file display.c.

References msg_history_t::count, msg_history_entry_t::data, msg_history_t::entries, msg_history_t::head, msg_history_entry_t::is_send, msg_history_entry_t::len, MSG_HISTORY_LEN, MSG_HISTORY_MAX_BYTES, and msg_history_entry_t::source_id.

◆ msg_history_init()

void msg_history_init ( msg_history_t hist)

Initialize a message history buffer.

Parameters
histpointer to history buffer

Clears all entries and resets head/count to zero. Must be called before using the history buffer.

Parameters
[out]histPointer to history buffer to initialize
Precondition
hist != NULL
Postcondition
hist->count == 0, hist->head == 0

Definition at line 104 of file display.c.