mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.3.5 PrintSize
This commit is contained in:
parent
796cb900cd
commit
a72eae80f2
2
libraries/PrintSize/.github/FUNDING.yml
vendored
2
libraries/PrintSize/.github/FUNDING.yml
vendored
@ -1,4 +1,4 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: RobTillaart
|
||||
|
||||
custom: "https://www.paypal.me/robtillaart"
|
||||
|
@ -1,13 +1,13 @@
|
||||
|
||||
name: Arduino-lint
|
||||
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: arduino/arduino-lint-action@v1
|
||||
with:
|
||||
library-manager: update
|
||||
compliance: strict
|
||||
compliance: strict
|
@ -1,4 +1,3 @@
|
||||
---
|
||||
name: Arduino CI
|
||||
|
||||
on: [push, pull_request]
|
||||
@ -6,12 +5,14 @@ on: [push, pull_request]
|
||||
jobs:
|
||||
runTest:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
- run: |
|
||||
sudo sysctl vm.mmap_rnd_bits=28
|
||||
gem install arduino_ci
|
||||
arduino_ci.rb
|
||||
|
@ -9,10 +9,10 @@ on:
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
uses: limitusus/json-syntax-check@v2
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
||||
pattern: "\\.json$"
|
@ -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/).
|
||||
|
||||
|
||||
## [0.3.4] - 2024-04-11
|
||||
- update GitHub actions
|
||||
- minor edits
|
||||
|
||||
## [0.3.4] - 2023-11-15
|
||||
- update readme.md
|
||||
|
||||
|
||||
## [0.3.3] - 2022-11-22
|
||||
- add changelog.md
|
||||
- add RP2040 to build-CI
|
||||
|
@ -1,6 +1,6 @@
|
||||
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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: PrintSize.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.4
|
||||
// VERSION: 0.3.5
|
||||
// PURPOSE: Library to determine size of a printed variable.
|
||||
// DATE: 2017-12-09
|
||||
// URL: https://github.com/RobTillaart/PrintSize
|
||||
@ -11,7 +11,7 @@
|
||||
#include "Arduino.h"
|
||||
#include "Print.h"
|
||||
|
||||
#define PRINTSIZE_VERSION (F("0.3.4"))
|
||||
#define PRINTSIZE_VERSION (F("0.3.5"))
|
||||
|
||||
|
||||
class PrintSize: public Print
|
||||
@ -26,7 +26,7 @@ public:
|
||||
size_t write(uint8_t c) // note: warning unused parameter
|
||||
{
|
||||
_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:
|
||||
|
@ -14,6 +14,9 @@ void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
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("align the numbers in a table with their sum.");
|
||||
@ -39,6 +42,8 @@ void loop()
|
||||
printSpaces(15 - length);
|
||||
Serial.println(sum);
|
||||
Serial.println();
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
@ -48,5 +53,4 @@ void printSpaces(uint8_t n)
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -16,9 +16,10 @@ PrintSize ps;
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
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("align the numbers in a table with their sum.");
|
||||
|
@ -15,6 +15,9 @@ void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
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("align the numbers in a table with their sum.");
|
||||
|
@ -30,9 +30,10 @@ PrintSize ps;
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("PRINTSIZE_VERSION: ");
|
||||
Serial.println(PRINTSIZE_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Serial.println("\nType words < 20 chars in the Serial monitor\n");
|
||||
ps.reset();
|
||||
@ -64,7 +65,7 @@ void process(char * w, uint8_t maxLength)
|
||||
{
|
||||
// skip empty words.
|
||||
if (strlen(w) == 0) return;
|
||||
|
||||
|
||||
// remember position
|
||||
uint8_t prev = ps.total();
|
||||
|
||||
@ -87,5 +88,5 @@ void process(char * w, uint8_t maxLength)
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/PrintSize.git"
|
||||
},
|
||||
"version": "0.3.4",
|
||||
"version": "0.3.5",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=PrintSize
|
||||
version=0.3.4
|
||||
version=0.3.5
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Library to determine size of a printed variable.
|
||||
|
@ -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.
|
||||
|
||||
Finally since **0.2.0** it has a total counter to add up the characters "printed" since
|
||||
the last **reset()** call. (see example)
|
||||
Since **0.2.0** it has a total counter to add up the characters "printed" since
|
||||
the last **reset()** call. See examples.
|
||||
|
||||
|
||||
#### Related
|
||||
|
||||
- https://github.com/RobTillaart/PrintCharArray (captures data in a char buffer)
|
||||
- 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/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/PrintString captures data in a String.
|
||||
|
||||
|
||||
## Interface
|
||||
@ -49,9 +49,9 @@ Note: gives a warning unused parameter.
|
||||
|
||||
## 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
|
||||
|
Loading…
Reference in New Issue
Block a user