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
Go to the documentation of this file.
1/*
2 * display.h
3 *
4 * Created on: Jan 24, 2026
5 * Author: Souham Biswas
6 * GitHub: https://github.com/ironhide23586/icarus-os-core
7 */
8
9#ifndef DISPLAY_H_
10#define DISPLAY_H_
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16/* Includes ------------------------------------------------------------------*/
17#include <stdint.h>
18#include <stdbool.h>
19#include <stdio.h>
20
21/* Exported constants --------------------------------------------------------*/
22// Feature flags
23#define ENABLE_HEARTBEAT_VISUALIZATION 1 // Set to 1 to enable, 0 to disable heartbeat visualization
24
25// Terminal row assignments for fixed-position rendering
26#define ROW_HEADER 1
27#define ROW_SEPARATOR 9
28#if ENABLE_HEARTBEAT_VISUALIZATION
29#define ROW_HEARTBEAT 10
30#define ROW_TASK_A 11
31#define ROW_TASK_B 12
32#define ROW_TASK_C 13
33#else
34#define ROW_TASK_A 11
35#define ROW_TASK_B 12
36#define ROW_TASK_C 13
37#endif
38
39#define BAR_WIDTH 40
40#define BAR_COL_START 6 // Column where bar starts (after "[A] ")
41
42// Vertical bar configuration (for semaphore visualization)
43#define VBAR_HEIGHT 10 // Height of vertical bar in rows
44#define VBAR_COL 70 // Column position for vertical bar
45
46// Task period durations (in ticks) - longer = slower, more visible animation
47#define HEARTBEAT_ON_TICKS 437 // Heartbeat LED on duration (437ms)
48#define HEARTBEAT_OFF_TICKS 479 // Heartbeat LED off duration (479ms)
49#define HEARTBEAT_PERIOD_TICKS (HEARTBEAT_ON_TICKS + HEARTBEAT_OFF_TICKS) // Total period (916ms)
50#define TASK_A_PERIOD_TICKS 2000 // Task A period duration
51#define TASK_B_PERIOD_TICKS 4000 // Task B period duration (2x slower than A)
52#define TASK_C_PERIOD_TICKS 3000 // Task C period duration
53
54// Rendering and timing configuration
55#define RENDER_INTERVAL_TICKS 20 // How often to update the display (in ticks)
56#define CYCLE_PAUSE_TICKS 100 // Pause between cycles (in ticks)
57
58/* Exported functions prototypes ---------------------------------------------*/
62void display_init(void);
63
71void display_render_bar(uint8_t row, const char* task_name, uint32_t elapsed_ticks, uint32_t period_ticks);
72
79void display_render_banner(uint8_t row, const char* task_name, bool is_on);
80
88void display_render_vbar(uint8_t start_row, uint8_t col, uint32_t count, uint32_t max_count);
89
102void display_render_pipe(uint8_t start_row, uint8_t col, const char* label,
103 uint8_t count, uint8_t max_count,
104 uint8_t last_sent, uint8_t last_recv,
105 bool show_sent, bool show_recv);
106
116void display_render_producer(uint8_t row, const char* task_name,
117 uint32_t elapsed_ticks, uint32_t period_ticks,
118 uint8_t msg_value, bool show_msg);
119
129void display_render_consumer(uint8_t row, const char* task_name,
130 uint32_t elapsed_ticks, uint32_t period_ticks,
131 uint8_t msg_value, bool show_msg);
132
133// Message history configuration
134#define MSG_HISTORY_LEN 8 // Number of messages to show in history
135#define MSG_HISTORY_MAX_BYTES 4 // Max bytes per message to display
136
140typedef struct {
141 uint8_t data[MSG_HISTORY_MAX_BYTES]; // Message data
142 uint8_t len; // Actual message length
143 uint8_t source_id; // Producer ID (0, 1, etc.) or 0xFF for unknown
144 bool is_send; // true = sent, false = received
146
150typedef struct {
152 uint8_t head; // Next write position
153 uint8_t count; // Number of valid entries
155
161
170void msg_history_add(msg_history_t* hist, const uint8_t* data, uint8_t len,
171 uint8_t source_id, bool is_send);
172
180void display_render_msg_history(uint8_t row, uint8_t col, msg_history_t* hist, const char* label);
181
182#ifdef __cplusplus
183}
184#endif
185
186#endif /* DISPLAY_H_ */
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.
Definition display.c:431
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.
Definition display.c:174
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.
Definition display.c:127
void display_render_banner(uint8_t row, const char *task_name, bool is_on)
Render a simple flashing banner (on/off indicator)
Definition display.c:306
void display_init(void)
Initialize terminal display - clear screen and print header.
Definition display.c:654
#define MSG_HISTORY_LEN
Definition display.h:134
void msg_history_init(msg_history_t *hist)
Initialize a message history buffer.
Definition display.c:104
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.
Definition display.c:247
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.
Definition display.c:352
#define MSG_HISTORY_MAX_BYTES
Definition display.h:135
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.
Definition display.c:516
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.
Definition display.c:580
Message history entry for rolling window display.
Definition display.h:140
bool is_send
Definition display.h:144
uint8_t len
Definition display.h:142
uint8_t source_id
Definition display.h:143
Message history buffer for a pipe.
Definition display.h:150
uint8_t count
Definition display.h:153
uint8_t head
Definition display.h:152