Aligned columns on the serial monitor while keeping CSV on the SD card
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- arduino, cpp
- 领域
- embedded-iot
调研方向
从 logger 代码开始检查:目前同一个 String 会被发送到 SD 文件和 Serial;然后检查 Arduino Print 接口以及现有的串行回显条件。在该回显点添加适配器,同时保持文件写入不变,并验证 Serial 上的表头和数据保持对齐,而卡仍然接收原始 CSV。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- C++
- 星标
- 1
- 派生
- 0
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NorthernWidget/Okapi_Library 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 1/5 1 小时以内 新手友好度 88/100
-
难度 3/5 1-2 天 新手友好度 56/100
-
难度 4/5 3-5 天 新手友好度 48/100
-
难度 4/5 3-5 天 新手友好度 45/100
查看 NorthernWidget/Okapi_Library 的全部 Issue
相似的 Issue
-
[Cleanup] Include the public header in work_split.cpp可能已有人在做 @blozano-tt 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
tenstorrent/tt-metal#60850 ·
维护者通常 1 天内回复
-
bug core p3
难度 2/5 1-3 小时 新手友好度 70/100
RunanywhereAI/runanywhere-sdks#1083 ·
维护者通常 5 天内回复
-
难度 1/5 1 小时以内 新手友好度 75/100
tesseract-ocr/tesseract#4653 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
-
comp-datalake performance
难度 2/5 1-3 小时 新手友好度 85/100
ClickHouse/ClickHouse#126044 ·
维护者通常 1 天内回复