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.c File Reference

ICARUS OS Terminal Display Implementation. More...

#include "bsp/display.h"
#include "icarus/kernel.h"
#include "icarus/scheduler.h"
#include <string.h>
#include <inttypes.h>

Go to the source code of this file.

Macros

#define ANSI_GOTO(row, col)   (void)printf("\033[%d;%dH", (row), (col))
 Move cursor to specified row and column (1-indexed)
 
#define ANSI_SHOW_CURSOR()   (void)printf("\033[?25h")
 Show terminal cursor.
 
#define ANSI_HIDE_CURSOR()   (void)printf("\033[?25l")
 Hide terminal cursor.
 
#define ANSI_RESET   "\033[0m"
 Reset all text attributes.
 
#define ANSI_BOLD   "\033[1m"
 Bold text attribute.
 
#define ANSI_DIM   "\033[2m"
 Dim text attribute.
 
#define ANSI_GREEN   "\033[32m"
 Green foreground color.
 
#define ANSI_YELLOW   "\033[33m"
 Yellow foreground color.
 
#define ANSI_MAGENTA   "\033[35m"
 Magenta foreground color.
 
#define ANSI_CYAN   "\033[36m"
 Cyan foreground color.
 
#define ANSI_WHITE   "\033[37m"
 White foreground color.
 
#define ANSI_BG_GREEN   "\033[42m"
 Green background color.
 
#define ANSI_BG_MAGENTA   "\033[45m"
 Magenta background color.
 

Functions

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 the history buffer.
 
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 display.
 
void display_render_bar (uint8_t row, const char *task_name, uint32_t elapsed_ticks, uint32_t period_ticks)
 Render a horizontal progress bar for task visualization.
 
void display_render_banner (uint8_t row, const char *task_name, bool is_on)
 Render a flashing banner indicator (heartbeat display)
 
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 (pipe) 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 progress bar with 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 progress bar with message indicator.
 
void display_init (void)
 Initialize terminal display subsystem.
 

Detailed Description

ICARUS OS Terminal Display Implementation.

Version
0.1.0

Implements ANSI terminal-based visualization for real-time kernel monitoring. Provides progress bars, semaphore indicators, message queue visualizations, and rolling message history displays.

Terminal Requirements:
  • ANSI escape code support (VT100 compatible)
  • UTF-8 encoding for box drawing characters
  • Minimum 80x24 terminal size (100x40 recommended)
  • 115200 baud USB CDC connection
Color Coding:
  • Green: Producers, successful operations
  • Magenta: Consumers, receive operations
  • Cyan: Headers, labels, informational
  • Yellow: Warnings, queue fill indicators
See also
docs/do178c/design/SDD.md Section 6 - Display Subsystem
Author
Souham Biswas
Date
2025

Definition in file display.c.

Function Documentation

◆ display_init()

void display_init ( void  )

Initialize terminal display subsystem.

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 flashing banner indicator (heartbeat display)

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 horizontal progress bar for task visualization.

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 progress bar with message indicator.

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 display.

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 (pipe) visualization panel.

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 progress bar with message indicator.

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.

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 the history buffer.

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.

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.