VT100 Terminal App
Circle VT100 module documentation
Loading...
Searching...
No Matches
TConfig.h
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Module: CTConfig
3// Description: Loads VT100 configuration from storage and exposes runtime settings.
4// Author: R. Zuehlsdorff, ralf.zuehlsdorff@t-online.de
5// Created: 2026-01-18
6// License: MIT License (https://opensource.org/license/mit/)
7//------------------------------------------------------------------------------
8// Change Log:
9// 2026-01-18 R. Zuehlsdorff Initial creation
10//------------------------------------------------------------------------------
11
12#pragma once
13
14// Include Circle core components
15#include <circle/sched/task.h>
16#include <circle/string.h>
17#include <fatfs/ff.h>
18
19#include "TColorPalette.h"
20#include "TFontConverter.h"
21
32// Forward declarations and includes for classes used in this module
33class CKernel;
34
35// Simple config parameter structure
37{
38 const char *keyword;
39 unsigned int *variable; // Pointer to integer variable
40 unsigned int defaultValue; // Default value
41 const char *description; // Description with value meanings
42};
43
53class CTConfig : public CTask
54{
55public:
56 static constexpr unsigned int TabStopsMax = 160U;
59 static CTConfig *Get(void);
60
62 CTConfig(void);
64 ~CTConfig(void);
65
68 boolean Initialize(void);
69
71 void Run() override;
72
75 boolean LoadFromFile(void);
78 boolean SaveToFile(void);
79
80 // --- Configuration Parameters: Getters and Setters ---
81
84 unsigned int GetLineEndingMode(void) const { return m_LineEnding; }
87 void SetLineEndingMode(unsigned int mode);
88
91 unsigned int GetBaudRate(void) const { return m_BaudRate; }
94 void SetBaudRate(unsigned int baudRate);
95
98 boolean GetCursorBlock(void) const { return m_CursorType != 0; }
101 void SetCursorBlock(boolean block);
102
105 boolean GetCursorBlinking(void) const { return m_CursorBlinking != 0; }
108 void SetCursorBlinking(boolean blinking);
109
112 boolean GetVTTestEnabled(void) const { return m_VTTestEnabled != 0; }
115 void SetVTTestEnabled(boolean enabled);
116
119 boolean GetVT52ModeEnabled(void) const { return m_VT52Mode != 0; }
122 void SetVT52ModeEnabled(boolean enabled);
123
126 unsigned int GetLogOutput(void) const { return m_LogOutput; }
129 void SetLogOutput(unsigned int logOutput);
130
133 const char *GetLogFileName(void) const { return m_LogFileName; }
136 void SetLogFileName(const char *pFileName);
137
140 EColorSelection GetTextColor(void) const { return m_TextColorIndex; }
143 void SetTextColor(EColorSelection color);
144
147 EColorSelection GetBackgroundColor(void) const { return m_BackgroundColorIndex; }
150 void SetBackgroundColor(EColorSelection color);
151
154 EFontSelection GetFontSelection(void) const { return static_cast<EFontSelection>(m_FontSelection); }
157 void SetFontSelection(EFontSelection selection);
158
161 unsigned int GetBuzzerVolume(void) const { return m_BuzzerVolume; }
164 void SetBuzzerVolume(unsigned int volume);
165
168 unsigned int GetKeyClick(void) const { return m_KeyClick; }
171 void SetKeyClick(boolean enabled);
172
175 unsigned int GetSwitchTxRx(void) const { return m_SwitchTxRx; }
178 void SetSwitchTxRx(boolean enabled);
179
182 unsigned int GetWlanHostAutoStart(void) const { return m_WlanHostAutoStart; }
185 void SetWlanHostAutoStart(boolean enabled);
186
189 unsigned int GetKeyRepeatDelayMs(void) const { return m_KeyRepeatDelayMs; }
192 boolean GetKeyAutoRepeatEnabled(void) const { return m_KeyAutoRepeat != 0; }
195 void SetKeyAutoRepeatEnabled(boolean enabled);
198 void SetKeyRepeatDelayMs(unsigned int delayMs);
199
202 unsigned int GetKeyRepeatRateCps(void) const { return m_KeyRepeatRateCps; }
205 void SetKeyRepeatRateCps(unsigned int rateCps);
206
209 boolean GetScreenInverted(void) const { return m_ScreenInverted != 0; }
212 void SetScreenInverted(boolean inverted);
213
216 boolean GetSmoothScrollEnabled(void) const { return m_SmoothScrollEnabled != 0; }
219 void SetSmoothScrollEnabled(boolean enabled);
220
223 boolean GetWrapAroundEnabled(void) const { return m_WrapAroundEnabled != 0; }
226 void SetWrapAroundEnabled(boolean enabled);
227
230 unsigned int GetSerialDataBits(void) const { return m_SerialDataBits; }
233 void SetSerialDataBits(unsigned int dataBits);
234
237 unsigned int GetSerialParityMode(void) const { return m_SerialParityMode; }
240 void SetSerialParityMode(unsigned int parityMode);
241
244 boolean GetSoftwareFlowControl(void) const { return m_SoftwareFlowControl != 0; }
247 void SetSoftwareFlowControl(boolean enabled);
248
251 boolean GetMarginBellEnabled(void) const { return m_MarginBellEnabled != 0; }
254 void SetMarginBellEnabled(boolean enabled);
255
256 // --- End Configuration Parameters ---
257
262 void ResolveLogOutputs(bool &screen, bool &file, bool &wlan) const;
265 const char *GetLineEndingModeString(void) const;
267 void logConfig(void) const;
268
271 bool IsTabStop(unsigned int column) const;
274 void SetTabStop(unsigned int column, bool enabled);
277 void InitDefaultTabStops(unsigned int columns = TabStopsMax);
278
279private:
282 boolean LoadConfigFromFile(void);
284 void LoadDefaults(void);
288 boolean ParseConfigLine(const char *pLine);
291 void TrimWhitespace(char *pString);
292
293 // Configuration variables (all integers for simplicity)
294 unsigned int m_LineEnding; // 0=LF, 1=CRLF
295 unsigned int m_BaudRate; // Baud rate
296 unsigned int m_CursorType; // 0=underline, 1=block
297 unsigned int m_CursorBlinking; // 0=steady, 1=blinking
298 unsigned int m_VTTestEnabled; // 0=off, 1=on
299 unsigned int m_VT52Mode; // 0=ANSI, 1=VT52
300 unsigned int m_LogOutput; // bitmask: 1=screen, 2=file, 4=wlan
301 EColorSelection m_TextColorIndex; // Color index for text (EColorSelection)
302 EColorSelection m_BackgroundColorIndex; // Color index for background (EColorSelection)
303 unsigned int m_FontSelection; // Encoded font selection identifier
304 unsigned int m_BuzzerVolume; // 0-100% duty cycle for buzzer
305 unsigned int m_KeyClick; // 0=disabled, 1=enabled key click feedback
306 unsigned int m_SwitchTxRx; // 0=normal wiring, 1=swap TX/RX via GPIO16
307 unsigned int m_WlanHostAutoStart; // 0=command/log mode on connect, 1=host mode auto-start
308 unsigned int m_KeyAutoRepeat; // 0=disabled, 1=enabled keyboard auto-repeat
309 unsigned int m_KeyRepeatDelayMs; // Key repeat delay in milliseconds
310 unsigned int m_KeyRepeatRateCps; // Repeat frequency in characters per second
311 unsigned int m_ScreenInverted; // 0=normal, 1=swap fg/bg screen colors
312 unsigned int m_SmoothScrollEnabled; // 0=off, 1=on smooth scrolling animation
313 unsigned int m_WrapAroundEnabled; // 0=off hold at right margin, 1=on wrap to next line
314 unsigned int m_SerialDataBits; // UART data bits (7 or 8)
315 unsigned int m_SerialParityMode; // UART parity (0=none, 1=even, 2=odd)
316 unsigned int m_SoftwareFlowControl; // 0=off, 1=on software flow control (XON/XOFF)
317 unsigned int m_MarginBellEnabled; // 0=off, 1=on margin bell (8 columns before right margin)
318 char m_LogFileName[64]; // Log filename (string, special handling)
319 bool m_TabStops[TabStopsMax]; // Tab stop positions (0-based columns)
320
321 static const char ConfigFileName[];
322 TConfigParam s_ConfigParams[24]; // Instance array for config params
323};
Declares shared color selection enums for the VT100 renderer stack.
Declares the task that prepares VT100 font assets for rendering.
Central coordinator for hardware bring-up and runtime control.
Definition kernel.h:73
Cooperative task responsible for configuration persistence and lookup.
Definition TConfig.h:54
unsigned int GetKeyClick(void) const
Check whether key click feedback is enabled.
Definition TConfig.h:168
EColorSelection GetBackgroundColor(void) const
Retrieve the configured background color index.
Definition TConfig.h:147
void SetVTTestEnabled(boolean enabled)
Enable or disable the VT test runner.
Definition TConfig.cpp:1077
void SetSwitchTxRx(boolean enabled)
Enable or disable TX/RX swap mode.
Definition TConfig.cpp:1208
boolean GetMarginBellEnabled(void) const
Query whether margin bell is enabled.
Definition TConfig.h:251
void SetBuzzerVolume(unsigned int volume)
Adjust the buzzer volume setting.
Definition TConfig.cpp:1191
void SetTextColor(EColorSelection color)
Set the configured text color index.
Definition TConfig.cpp:1144
static CTConfig * Get(void)
Access the singleton configuration task.
Definition TConfig.cpp:41
void SetBaudRate(unsigned int baudRate)
Set the serial baud rate.
Definition TConfig.cpp:1048
unsigned int GetSerialDataBits(void) const
Retrieve configured UART data bits.
Definition TConfig.h:230
void SetSoftwareFlowControl(boolean enabled)
Enable or disable software flow control.
Definition TConfig.cpp:1296
unsigned int GetKeyRepeatRateCps(void) const
Retrieve key repeat rate in characters per second.
Definition TConfig.h:202
unsigned int GetBuzzerVolume(void) const
Retrieve the buzzer volume setting in percent.
Definition TConfig.h:161
void SetBackgroundColor(EColorSelection color)
Set the configured background color index.
Definition TConfig.cpp:1155
EColorSelection GetTextColor(void) const
Retrieve the configured text color index.
Definition TConfig.h:140
EFontSelection GetFontSelection(void) const
Retrieve the configured font selection.
Definition TConfig.h:154
boolean GetKeyAutoRepeatEnabled(void) const
Check whether keyboard auto-repeat is enabled.
Definition TConfig.h:192
void SetTabStop(unsigned int column, bool enabled)
Set or clear a tab stop at the specified column.
Definition TConfig.cpp:417
boolean GetSoftwareFlowControl(void) const
Query whether software flow control (XON/XOFF) is enabled.
Definition TConfig.h:244
void SetKeyRepeatRateCps(unsigned int rateCps)
Set key repeat rate.
Definition TConfig.cpp:1241
void InitDefaultTabStops(unsigned int columns=TabStopsMax)
Reset tab stops to default 8-column positions.
Definition TConfig.cpp:426
void SetKeyRepeatDelayMs(unsigned int delayMs)
Set key repeat delay.
Definition TConfig.cpp:1226
unsigned int GetSwitchTxRx(void) const
Check whether TX/RX wiring is swapped.
Definition TConfig.h:175
bool IsTabStop(unsigned int column) const
Query whether a tab stop is set at the specified column.
Definition TConfig.cpp:408
boolean GetSmoothScrollEnabled(void) const
Check whether smooth scrolling animation is enabled.
Definition TConfig.h:216
void logConfig(void) const
Emit the active configuration to the logger.
Definition TConfig.cpp:284
boolean LoadFromFile(void)
Load configuration from persistent storage if present.
Definition TConfig.cpp:443
void SetLogOutput(unsigned int logOutput)
Update the log output bitmask.
Definition TConfig.cpp:1089
const char * GetLogFileName(void) const
Retrieve the configured log file name.
Definition TConfig.h:133
boolean GetScreenInverted(void) const
Check whether screen colors are inverted (screen mode).
Definition TConfig.h:209
unsigned int GetWlanHostAutoStart(void) const
Check whether WLAN host mode auto-start is enabled.
Definition TConfig.h:182
void SetScreenInverted(boolean inverted)
Enable or disable screen color inversion.
Definition TConfig.cpp:1256
void SetCursorBlock(boolean block)
Change cursor style.
Definition TConfig.cpp:1065
~CTConfig(void)
Release configuration resources.
Definition TConfig.cpp:362
void SetLineEndingMode(unsigned int mode)
Update the configured line ending mode.
Definition TConfig.cpp:1054
unsigned int GetSerialParityMode(void) const
Retrieve configured UART parity mode.
Definition TConfig.h:237
void SetVT52ModeEnabled(boolean enabled)
Enable or disable VT52 emulation mode.
Definition TConfig.cpp:1083
boolean GetCursorBlock(void) const
Check whether the cursor is configured as block style.
Definition TConfig.h:98
void SetSerialParityMode(unsigned int parityMode)
Set UART parity mode.
Definition TConfig.cpp:1285
const char * GetLineEndingModeString(void) const
Obtain a textual description of the current line ending mode.
Definition TConfig.cpp:1313
boolean SaveToFile(void)
Save current configuration values to persistent storage.
Definition TConfig.cpp:461
void SetWrapAroundEnabled(boolean enabled)
Enable or disable automatic line wrap-around.
Definition TConfig.cpp:1268
unsigned int GetLineEndingMode(void) const
Retrieve the line ending mode (0=LF, 1=CRLF, 2=CR).
Definition TConfig.h:84
boolean GetWrapAroundEnabled(void) const
Check whether automatic line wrap-around is enabled.
Definition TConfig.h:223
void SetSerialDataBits(unsigned int dataBits)
Set UART data bits.
Definition TConfig.cpp:1274
boolean Initialize(void)
Initialize the configuration task and load defaults.
Definition TConfig.cpp:367
void ResolveLogOutputs(bool &screen, bool &file, bool &wlan) const
Decode the log output bitmask into individual booleans.
Definition TConfig.cpp:1100
unsigned int GetBaudRate(void) const
Retrieve the configured serial baud rate.
Definition TConfig.h:91
boolean GetVTTestEnabled(void) const
Check whether the VT test runner is enabled.
Definition TConfig.h:112
void SetLogFileName(const char *pFileName)
Set the configured log file name.
Definition TConfig.cpp:1166
void SetKeyClick(boolean enabled)
Enable or disable key click feedback.
Definition TConfig.cpp:1202
CTConfig(void)
Construct the configuration task with default values.
Definition TConfig.cpp:322
void Run() override
Scheduler entry point to service configuration events.
Definition TConfig.cpp:376
void SetKeyAutoRepeatEnabled(boolean enabled)
Enable or disable keyboard auto-repeat.
Definition TConfig.cpp:1220
void SetWlanHostAutoStart(boolean enabled)
Enable or disable WLAN host mode auto-start on telnet connect.
Definition TConfig.cpp:1214
unsigned int GetKeyRepeatDelayMs(void) const
Retrieve key repeat delay in milliseconds.
Definition TConfig.h:189
boolean GetCursorBlinking(void) const
Check whether the cursor is configured to blink.
Definition TConfig.h:105
void SetFontSelection(EFontSelection selection)
Set the active font selection.
Definition TConfig.cpp:1180
boolean GetVT52ModeEnabled(void) const
Check whether VT52 emulation mode is enabled.
Definition TConfig.h:119
void SetCursorBlinking(boolean blinking)
Toggle cursor blinking behavior.
Definition TConfig.cpp:1071
void SetSmoothScrollEnabled(boolean enabled)
Enable or disable smooth scrolling animation.
Definition TConfig.cpp:1262
void SetMarginBellEnabled(boolean enabled)
Enable or disable margin bell.
Definition TConfig.cpp:1302
unsigned int GetLogOutput(void) const
Retrieve the configured log output bitmask.
Definition TConfig.h:126
Definition TConfig.h:37