Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Aligned columns on the serial monitor while keeping CSV on the SD card

Aperta Adatta ai principianti
#8 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
arduino, cpp
Ambito
embedded-iot

Direzione di ricerca

Inizia dal codice del logger, dove attualmente lo stesso String viene inviato al file SD e a Serial; poi esamina l’interfaccia Arduino Print e la condizione esistente per l’eco seriale. Aggiungi l’adattatore in quel punto dell’eco lasciando invariata la scrittura nel file e verifica che intestazioni e dati siano allineati su Serial, mentre la scheda continua a ricevere il CSV originale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Summary

Keep the SD card log as plain comma-separated values, but show the same lines on the serial monitor as aligned columns, so a person watching the logger can read them. Today the logger writes one String to both the file and Serial, which made alignment look hard. It is not: the alignment can be done on the byte stream on its way to Serial, with no change to the sensors, to getString(), or to what reaches the card.

Design

A small Print adapter sits in front of Serial. It passes bytes through, and at each comma pads the current field to a fixed column width. The file still receives the unmodified CSV.

class AlignedPrint : public Print {           // pads each comma-separated field to a column
    Print& _out; uint8_t _width, _col = 0;
  public:
    AlignedPrint(Print& out, uint8_t width = 24) : _out(out), _width(width) {}
    size_t write(uint8_t c) override {
        if (c == ',') { while (_col++ < _width) _out.write(' '); _col = 0; return 1; }
        if (c == '\n') { _col = 0; }
        else _col++;
        return _out.write(c);
    }
};

Use, in the logger, wherever a line is echoed today:

AlignedPrint monitor(Serial);
logFile.print(line);      // CSV to the card, unchanged
monitor.print(line);      // aligned columns on the serial monitor

The header line goes through the same adapter, so column names sit over their values provided the width covers the longest name (Pressure Atmos [mBar] is 21 characters, so a default of 24).

Cost

  • About twenty lines; a few hundred bytes of flash; two bytes of RAM.
  • The serial line is roughly twice as long as the CSV line: at 38400 baud a ten-field line takes ~60 ms instead of ~30 ms. Only the serial echo is affected; the SD path is untouched. It can sit behind the same condition that gates the serial echo now.
  • No coupling to the sensor libraries or to the NW-Device-Specification work; can land independently.

Choices made here

  • Fixed-width padding, not tab characters. Terminal tab stops are eight columns and a value such as 1013.25, already fills one, so tabs align unpredictably.
  • Left-aligned fields (pad after the value). Right-aligned numbers read slightly better but require holding each field back until its comma arrives: a ~24-byte buffer and about ten more lines. Start left-aligned; revisit if wanted.

Not in scope

Changing the CSV written to the card; changing any sensor library's getHeader()/getString() output.

🤖 Generated with Claude Code

Lingua principale
C++
Stelle
1
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NorthernWidget/Okapi_Library

Tutte le issue di NorthernWidget/Okapi_Library

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.