summaryrefslogtreecommitdiff
path: root/firmware/s1224/src/common/banner.c
diff options
context:
space:
mode:
authorinfo@mode42.com <info@mode42.com>2026-08-07 18:09:58 +0000
committerinfo@mode42.com <info@mode42.com>2026-08-07 18:09:58 +0000
commita7362dc14bca1233eb34b41aefebe9cfb22684ac (patch)
treef727c87f92aeb503038deeecc24d3e074dc0197c /firmware/s1224/src/common/banner.c
Initial pushmain
Diffstat (limited to 'firmware/s1224/src/common/banner.c')
-rw-r--r--firmware/s1224/src/common/banner.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/firmware/s1224/src/common/banner.c b/firmware/s1224/src/common/banner.c
new file mode 100644
index 0000000..21d1f3c
--- /dev/null
+++ b/firmware/s1224/src/common/banner.c
@@ -0,0 +1,82 @@
+/*
+ * Fixed boot banner — edit source only; not INI / CDC.
+ * Always printed once after USB CDC ready (main); quiet never suppresses it.
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+#include "banner.h"
+#include "version.h"
+#include "afsk_soft.h"
+#include <stdio.h>
+#include <string.h>
+
+/* Fixed CDC column width for centered serial look (40–48). */
+#define BANNER_WIDTH 44
+
+/** Display columns (UTF-8 code points ≈ 1 col; ASCII-safe). */
+static size_t banner_cols(const char *s)
+{
+ size_t cols = 0;
+ while (*s) {
+ unsigned char c = (unsigned char)*s++;
+ if ((c & 0x80u) == 0u) {
+ cols++;
+ } else if ((c & 0xE0u) == 0xC0u) {
+ if (*s) {
+ s++;
+ }
+ cols++;
+ } else if ((c & 0xF0u) == 0xE0u) {
+ if (*s) {
+ s++;
+ }
+ if (*s) {
+ s++;
+ }
+ cols++;
+ } else if ((c & 0xF8u) == 0xF0u) {
+ if (*s) {
+ s++;
+ }
+ if (*s) {
+ s++;
+ }
+ if (*s) {
+ s++;
+ }
+ cols++;
+ } else {
+ cols++;
+ }
+ }
+ return cols;
+}
+
+static void banner_line(const char *text)
+{
+ size_t cols = banner_cols(text);
+ size_t pad = 0;
+ if (cols < BANNER_WIDTH) {
+ pad = (BANNER_WIDTH - cols) / 2u;
+ }
+ for (size_t i = 0; i < pad; i++) {
+ putchar(' ');
+ }
+ fputs(text, stdout);
+ fputs("\r\n", stdout);
+}
+
+void banner_print(void)
+{
+ /* Fixed boot banner — edit source only */
+ char line[BANNER_WIDTH + 8];
+
+ snprintf(line, sizeof(line), "T-Modem-s1224 %s", S1224_FW_VERSION);
+ banner_line(line);
+
+ snprintf(line, sizeof(line), "USB KISS Half-TNC · AFSK %u",
+ (unsigned)afsk_bitrate());
+ banner_line(line);
+
+ banner_line("Non-Profit · GNU GPLv3 · AS-IS");
+ banner_line("https://github.com/ngteq");
+}
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com