initial version 0.1.0

This commit is contained in:
RobTillaart 2017-12-09 19:52:49 +01:00
parent 69e7c90d84
commit e78a45f39c
4 changed files with 114 additions and 0 deletions

View File

@ -0,0 +1,28 @@
//
// FILE: PrintSize.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: Class that determines printSize
// DATE: 2017-12-09
// URL:
// HISTORY: 0.1.0 2017-12-09 initial version
//
// Released to the public domain
//
#ifndef PrintSize_h
#define PrintSize_h
#include "Print.h"
#define PRINTSIZE_VERSION "0.1.0"
class PrintSize: public Print
{
public:
PrintSize() {};
size_t write(uint8_t c) { return 1; }
};
#endif
// -- END OF FILE --

View File

@ -0,0 +1,53 @@
//
// FILE: PrintSize1.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo printSize
//
// HISTORY:
// 0.1.0 2017-12-09 initial version
//
#include "PrintSize.h"
PrintSize ps;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.println("Determine length of 10 random numbers and right ");
Serial.println("align the numbers in a table with their sum.");
Serial.println();
uint32_t sum = 0;
for (int i = 0; i < 10; i++)
{
uint32_t rn = random(100000000);
int length = ps.println(rn);
printSpaces(15 - length);
sum += rn;
Serial.println(rn);
}
Serial.print("================ +\n");
int length = ps.println(sum);
printSpaces(15 - length);
Serial.println(sum);
}
void loop()
{
}
void printSpaces(int n)
{
if (n <= 0) return;
while (n)
{
Serial.print(' ');
n--;
}
}

View File

@ -0,0 +1,23 @@
{
"name": "PrintSize",
"keywords": "Size print ",
"description": "Library to determine size of a printed variable.",
"authors":
[
{
"name": "Rob Tillaart",
"email": "Rob.Tillaart@gmail.com",
"maintainer": true
}
],
"repository":
{
"type": "git",
"url": "https://github.com/RobTillaart/Arduino.git"
},
"frameworks": "arduino",
"platforms": "*",
"export": {
"include": "libraries/PrintSize"
}
}

View File

@ -0,0 +1,10 @@
name=PrintSize
version=0.1.0
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Library to determine size of a printed variable.
paragraph=
category=Data Processing
url=https://github.com/RobTillaart/Arduino/tree/master/libraries
architectures=*