From 702efe42131ad3a2cc794501edab8322e987c5c9 Mon Sep 17 00:00:00 2001 From: rob tillaart Date: Mon, 14 Nov 2022 20:50:36 +0100 Subject: [PATCH] 0.1.5 LineFormetter --- libraries/LineFormatter/.arduino-ci.yml | 16 ++++++++ libraries/LineFormatter/CHANGELOG.md | 38 +++++++++++++++++++ libraries/LineFormatter/LineFormatter.cpp | 34 +++++++---------- libraries/LineFormatter/LineFormatter.h | 24 ++++++------ libraries/LineFormatter/README.md | 10 +++-- .../LineFormatter_SDcard/.arduino-ci.yml | 14 +++++++ .../LineFormatter_test_table/.arduino-ci.yml | 14 +++++++ libraries/LineFormatter/library.json | 2 +- libraries/LineFormatter/library.properties | 2 +- .../LineFormatter/test/unit_test_001.cpp | 4 +- 10 files changed, 118 insertions(+), 40 deletions(-) create mode 100644 libraries/LineFormatter/CHANGELOG.md create mode 100644 libraries/LineFormatter/examples/LineFormatter_SDcard/.arduino-ci.yml create mode 100644 libraries/LineFormatter/examples/LineFormatter_test_table/.arduino-ci.yml diff --git a/libraries/LineFormatter/.arduino-ci.yml b/libraries/LineFormatter/.arduino-ci.yml index 96747733..8d1cb26f 100644 --- a/libraries/LineFormatter/.arduino-ci.yml +++ b/libraries/LineFormatter/.arduino-ci.yml @@ -1,3 +1,18 @@ +platforms: + rpipico: + board: rp2040:rp2040:rpipico + package: rp2040:rp2040 + gcc: + features: + defines: + - ARDUINO_ARCH_RP2040 + warnings: + flags: + +packages: + rp2040:rp2040: + url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + compile: # Choosing to run compilation tests on 2 different Arduino platforms platforms: @@ -9,6 +24,7 @@ compile: - esp32 # - esp8266 # - mega2560 + - rpipico libraries: - "Ethernet" - "SD" diff --git a/libraries/LineFormatter/CHANGELOG.md b/libraries/LineFormatter/CHANGELOG.md new file mode 100644 index 00000000..0d2936ca --- /dev/null +++ b/libraries/LineFormatter/CHANGELOG.md @@ -0,0 +1,38 @@ +# Change Log lineFormatter + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + + +## [0.1.5] - 2022-11-14 +- Add RP2040 support to build-CI. +- Add CHANGELOG.md +- update readme.md +- minor edits unit tests +- bump version to 0.1.5. +- fix build-CI for examples. + + +## [0.1.4] - 2021-12-20 +- not released (why?) +- update library.json +- update license +- minor edits + +## [0.1.3] - 2021-11-06 +- update Arduino-CI, badges +- update readme.md +- add reset(); + +## [0.1.2] - 2020-12-30 +- Arduino-ci + unit tests + +## [0.1.1] - 2020-06-19 +- fix library.json + +## [0.1.0] - 2020-05-14 +- initial version + + diff --git a/libraries/LineFormatter/LineFormatter.cpp b/libraries/LineFormatter/LineFormatter.cpp index 9ce25404..89e14206 100644 --- a/libraries/LineFormatter/LineFormatter.cpp +++ b/libraries/LineFormatter/LineFormatter.cpp @@ -1,18 +1,12 @@ // // FILE: LineFormatter.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.1.4 +// VERSION: 0.1.5 // PURPOSE: Simple positioning wrapper class for Serial // DATE: 2020-05-14 // URL: https://github.com/RobTillaart/LineFormatter // -// HISTORY: -// 0.1.0 2020-05-14 initial version -// 0.1.1 2020-06-19 fix library.json -// 0.1.2 2020-12-30 Arduino-ci + unit tests -// 0.1.3 2021-11-06 update Arduino-CI, badges -// update readme.md, add reset(); -// 0.1.4 2021-12-20 update library.json, license, minor edits +// HISTORY: see changelog.md #include "LineFormatter.h" @@ -38,17 +32,17 @@ void LineFormatter::reset() /////////////////////////////////////////// // -// WRITE - the core +// WRITE - the core // size_t LineFormatter::write(uint8_t c) { - // handle tabs. + // handle tabs. if (_tabCount && c == '\t') { write(' '); for (int i = 0; i < _tabCount; i++) { - if (_tabStop[i] > _pos + 1) // assume sorted + if (_tabStop[i] > _pos + 1) // assume sorted { gotoPos(_tabStop[i] - 1); break; @@ -61,7 +55,7 @@ size_t LineFormatter::write(uint8_t c) _pos++; } - // handle return + // handle return if (c == '\n') { _pos = 0; @@ -69,13 +63,13 @@ size_t LineFormatter::write(uint8_t c) _anl++; } - // handle maxpos + // handle maxpos if (_maxPos && _pos == _maxPos) { write('\n'); } - // handle autoNewLine + // handle autoNewLine if (_autoNewLine && (_anl == _autoNewLine)) { write('\n'); @@ -87,7 +81,7 @@ size_t LineFormatter::write(uint8_t c) /////////////////////////////////////////// // -// REPEAT +// REPEAT // void LineFormatter::repeat(uint8_t n, char c, uint8_t newLine) { @@ -105,7 +99,7 @@ void LineFormatter::repeat(uint8_t n, const char* str, uint8_t newLine) /////////////////////////////////////////// // -// AUTONEWLINE +// AUTONEWLINE // void LineFormatter::setAutoNewLine(uint8_t n) { @@ -116,7 +110,7 @@ void LineFormatter::setAutoNewLine(uint8_t n) /////////////////////////////////////////// // -// TAB +// TAB // void LineFormatter::clearTabs() { @@ -149,12 +143,12 @@ bool LineFormatter::addRelTab(uint8_t n) /////////////////////////////////////////// // -// DEBUGGING +// DEBUGGING // void LineFormatter::printRuler(uint8_t n) { - // for (int i = 0; i < _tabCount; i++) _stream->println(_tabStop[i]); - // return; + // for (int i = 0; i < _tabCount; i++) _stream->println(_tabStop[i]); + // return; uint8_t t = 0; for (int i = 1; i <= n; i++) diff --git a/libraries/LineFormatter/LineFormatter.h b/libraries/LineFormatter/LineFormatter.h index 39a4b236..5bf931f0 100644 --- a/libraries/LineFormatter/LineFormatter.h +++ b/libraries/LineFormatter/LineFormatter.h @@ -2,7 +2,7 @@ // // FILE: LineFormatter.h // AUTHOR: Rob Tillaart -// VERSION: 0.1.4 +// VERSION: 0.1.5 // PURPOSE: Simple positioning wrapper class for Serial / Stream // DATE: 2020-05-14 // URL: https://github.com/RobTillaart/LineFormatter @@ -15,7 +15,7 @@ #define MAX_TAB_STOPS 12 #endif -#define LINEFORMATTER_LIB_VERSION (F("0.1.4")) +#define LINEFORMATTER_LIB_VERSION (F("0.1.5")) class LineFormatter: public Print @@ -28,36 +28,36 @@ public: size_t write(uint8_t c); - // set the maximum line length - bold cut off + // set the maximum line length - bold cut off void setMaxLength(uint8_t maxPos) { _maxPos = maxPos; }; uint8_t getMaxLength() { return _maxPos; }; - // if position is smaller than n, move to the right + // if position is smaller than n, move to the right uint8_t gotoPos(uint8_t pos) { while (_pos < pos) write(' '); return _pos; }; - // repeat a char or a "string" n times - // followed by 0 or more newlines. + // repeat a char or a "string" n times + // followed by 0 or more newlines. void repeat(uint8_t n, char c, uint8_t newLine = 0); void repeat(uint8_t n, const char* str, uint8_t newLine = 0); - // n = 0 switches autoNewLine off + // n = 0 switches autoNewLine off void setAutoNewLine(uint8_t n); uint8_t getAutoNewLine() { return _autoNewLine; }; - // Add a tab at (absolute/relative) position - // returns true on success + // Add a tab at (absolute/relative) position + // returns true on success bool addTab(uint8_t n); bool addRelTab(uint8_t n); - // remove all the tabs, + // remove all the tabs, void clearTabs(); - // print zero or more tabs, similar as e.g. "\t\t\t" + // print zero or more tabs, similar as e.g. "\t\t\t" void tab(uint8_t n = 1) { while (n--) write('\t'); }; - // DEBUGGING + // DEBUGGING uint8_t getPos() { return _pos; }; void resetLineCount() { _lineCount = 0; }; uint16_t getLineCount() { return _lineCount; }; diff --git a/libraries/LineFormatter/README.md b/libraries/LineFormatter/README.md index 29048445..6f5b5d42 100644 --- a/libraries/LineFormatter/README.md +++ b/libraries/LineFormatter/README.md @@ -94,15 +94,17 @@ See examples ## Future +#### must - improve documentation + +#### should - add examples -- add reset(); -- set defaults for functions - add **rmTab(position)** -- + +#### could +- set defaults for functions #### Wont - - check if print interface is completely covered. - due to tab parsing it is, so no speed up. diff --git a/libraries/LineFormatter/examples/LineFormatter_SDcard/.arduino-ci.yml b/libraries/LineFormatter/examples/LineFormatter_SDcard/.arduino-ci.yml new file mode 100644 index 00000000..93b62a90 --- /dev/null +++ b/libraries/LineFormatter/examples/LineFormatter_SDcard/.arduino-ci.yml @@ -0,0 +1,14 @@ +compile: + # Choosing to run compilation tests on 2 different Arduino platforms + platforms: + - uno + # - due + # - zero + # - leonardo + - m4 + # - esp32 # has other server code + # - esp8266 + # - mega2560 + libraries: + - "Ethernet" + - "SD" diff --git a/libraries/LineFormatter/examples/LineFormatter_test_table/.arduino-ci.yml b/libraries/LineFormatter/examples/LineFormatter_test_table/.arduino-ci.yml new file mode 100644 index 00000000..93b62a90 --- /dev/null +++ b/libraries/LineFormatter/examples/LineFormatter_test_table/.arduino-ci.yml @@ -0,0 +1,14 @@ +compile: + # Choosing to run compilation tests on 2 different Arduino platforms + platforms: + - uno + # - due + # - zero + # - leonardo + - m4 + # - esp32 # has other server code + # - esp8266 + # - mega2560 + libraries: + - "Ethernet" + - "SD" diff --git a/libraries/LineFormatter/library.json b/libraries/LineFormatter/library.json index 3146fa1a..88208104 100644 --- a/libraries/LineFormatter/library.json +++ b/libraries/LineFormatter/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/LineFormatter.git" }, - "version": "0.1.4", + "version": "0.1.5", "license": "MIT", "frameworks": "arduino", "platforms": "*", diff --git a/libraries/LineFormatter/library.properties b/libraries/LineFormatter/library.properties index 1c32fbb4..8f2311d7 100644 --- a/libraries/LineFormatter/library.properties +++ b/libraries/LineFormatter/library.properties @@ -1,5 +1,5 @@ name=LineFormatter -version=0.1.4 +version=0.1.5 author=Rob Tillaart maintainer=Rob Tillaart sentence=Wrapper class for Serial to enhance layout of tabular data. diff --git a/libraries/LineFormatter/test/unit_test_001.cpp b/libraries/LineFormatter/test/unit_test_001.cpp index 6040e171..9d58e9f9 100644 --- a/libraries/LineFormatter/test/unit_test_001.cpp +++ b/libraries/LineFormatter/test/unit_test_001.cpp @@ -95,9 +95,9 @@ unittest(test_tab) fprintf(stderr, "tab test - !! cur position is one before tab position\n"); for (int i = 0; i < Line.getTabCount(); i++) { - fprintf(stderr, "%d\t", 8 + i*8); // tab positions + fprintf(stderr, "%d\t", 8 + i*8); // tab positions Line.write('\t'); - assertEqual(8 + i*8, (int)Line.getPos() + 1 ); // current position is just before tab + assertEqual(8 + i*8, (int)Line.getPos() + 1 ); // current position is just before tab } }