0.3.5 PrintSize

This commit is contained in:
Rob Tillaart 2024-04-11 13:23:26 +02:00
parent 796cb900cd
commit a72eae80f2
14 changed files with 53 additions and 34 deletions

View File

@ -1,4 +1,4 @@
# These are supported funding model platforms # These are supported funding model platforms
github: RobTillaart github: RobTillaart
custom: "https://www.paypal.me/robtillaart"

View File

@ -1,12 +1,12 @@
name: Arduino-lint name: Arduino-lint
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 5
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: arduino/arduino-lint-action@v1 - uses: arduino/arduino-lint-action@v1
with: with:
library-manager: update library-manager: update

View File

@ -1,4 +1,3 @@
---
name: Arduino CI name: Arduino CI
on: [push, pull_request] on: [push, pull_request]
@ -6,12 +5,14 @@ on: [push, pull_request]
jobs: jobs:
runTest: runTest:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 20
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1
with: with:
ruby-version: 2.6 ruby-version: 2.6
- run: | - run: |
sudo sysctl vm.mmap_rnd_bits=28
gem install arduino_ci gem install arduino_ci
arduino_ci.rb arduino_ci.rb

View File

@ -9,10 +9,10 @@ on:
jobs: jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 5
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: json-syntax-check - name: json-syntax-check
uses: limitusus/json-syntax-check@v1 uses: limitusus/json-syntax-check@v2
with: with:
pattern: "\\.json$" pattern: "\\.json$"

View File

@ -6,10 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.3.4] - 2024-04-11
- update GitHub actions
- minor edits
## [0.3.4] - 2023-11-15 ## [0.3.4] - 2023-11-15
- update readme.md - update readme.md
## [0.3.3] - 2022-11-22 ## [0.3.3] - 2022-11-22
- add changelog.md - add changelog.md
- add RP2040 to build-CI - add RP2040 to build-CI

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2017-2023 Rob Tillaart Copyright (c) 2017-2024 Rob Tillaart
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -2,7 +2,7 @@
// //
// FILE: PrintSize.h // FILE: PrintSize.h
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 0.3.4 // VERSION: 0.3.5
// PURPOSE: Library to determine size of a printed variable. // PURPOSE: Library to determine size of a printed variable.
// DATE: 2017-12-09 // DATE: 2017-12-09
// URL: https://github.com/RobTillaart/PrintSize // URL: https://github.com/RobTillaart/PrintSize
@ -11,7 +11,7 @@
#include "Arduino.h" #include "Arduino.h"
#include "Print.h" #include "Print.h"
#define PRINTSIZE_VERSION (F("0.3.4")) #define PRINTSIZE_VERSION (F("0.3.5"))
class PrintSize: public Print class PrintSize: public Print
@ -26,7 +26,7 @@ public:
size_t write(uint8_t c) // note: warning unused parameter size_t write(uint8_t c) // note: warning unused parameter
{ {
_total++; _total++;
return 1; return sizeof(c);
} }
@ -37,10 +37,16 @@ public:
} }
void reset() { _total = 0; } void reset()
{
_total = 0;
}
uint32_t total() { return _total; }; uint32_t total()
{
return _total;
}
private: private:

View File

@ -14,6 +14,9 @@ void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("PRINTSIZE_VERSION: ");
Serial.println(PRINTSIZE_VERSION);
Serial.println();
Serial.println("Determine length of 10 random numbers and right "); Serial.println("Determine length of 10 random numbers and right ");
Serial.println("align the numbers in a table with their sum."); Serial.println("align the numbers in a table with their sum.");
@ -39,6 +42,8 @@ void loop()
printSpaces(15 - length); printSpaces(15 - length);
Serial.println(sum); Serial.println(sum);
Serial.println(); Serial.println();
delay(1000);
} }
@ -49,4 +54,3 @@ void printSpaces(uint8_t n)
// -- END OF FILE -- // -- END OF FILE --

View File

@ -16,9 +16,10 @@ PrintSize ps;
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
Serial.println();
Serial.println();
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("PRINTSIZE_VERSION: ");
Serial.println(PRINTSIZE_VERSION);
Serial.println();
Serial.println("Determine length of 10 random numbers and right "); Serial.println("Determine length of 10 random numbers and right ");
Serial.println("align the numbers in a table with their sum."); Serial.println("align the numbers in a table with their sum.");

View File

@ -15,6 +15,9 @@ void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("PRINTSIZE_VERSION: ");
Serial.println(PRINTSIZE_VERSION);
Serial.println();
Serial.println("Determine length of 10 random numbers and right "); Serial.println("Determine length of 10 random numbers and right ");
Serial.println("align the numbers in a table with their sum."); Serial.println("align the numbers in a table with their sum.");

View File

@ -30,9 +30,10 @@ PrintSize ps;
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
Serial.println();
Serial.println();
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("PRINTSIZE_VERSION: ");
Serial.println(PRINTSIZE_VERSION);
Serial.println();
Serial.println("\nType words < 20 chars in the Serial monitor\n"); Serial.println("\nType words < 20 chars in the Serial monitor\n");
ps.reset(); ps.reset();

View File

@ -15,7 +15,7 @@
"type": "git", "type": "git",
"url": "https://github.com/RobTillaart/PrintSize.git" "url": "https://github.com/RobTillaart/PrintSize.git"
}, },
"version": "0.3.4", "version": "0.3.5",
"license": "MIT", "license": "MIT",
"frameworks": "*", "frameworks": "*",
"platforms": "*", "platforms": "*",

View File

@ -1,5 +1,5 @@
name=PrintSize name=PrintSize
version=0.3.4 version=0.3.5
author=Rob Tillaart <rob.tillaart@gmail.com> author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com> maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Library to determine size of a printed variable. sentence=Library to determine size of a printed variable.

View File

@ -21,15 +21,15 @@ This includes printing of floats, integers in decimal or hex notation.
Works for **print()**, **println()** and if supported **printf()** e.g. ESP32. Works for **print()**, **println()** and if supported **printf()** e.g. ESP32.
Finally since **0.2.0** it has a total counter to add up the characters "printed" since Since **0.2.0** it has a total counter to add up the characters "printed" since
the last **reset()** call. (see example) the last **reset()** call. See examples.
#### Related #### Related
- https://github.com/RobTillaart/PrintCharArray (captures data in a char buffer) - https://github.com/RobTillaart/PrintCharArray captures data in a char array buffer.
- https://github.com/RobTillaart/PrintSize (counts length of a number of print commands) - https://github.com/RobTillaart/PrintSize counts length of a number of print commands.
- https://github.com/RobTillaart/PrintString (captures data in a String) - https://github.com/RobTillaart/PrintString captures data in a String.
## Interface ## Interface
@ -49,9 +49,9 @@ Note: gives a warning unused parameter.
## Operational ## Operational
Example shows the right alignment of 10 random numbers. Example PrintSize1.ino shows the right alignment of 10 random numbers.
Example shows (elementary) line fitting. Example PrintSize_total.ino shows (elementary) line fitting.
## Applications ## Applications