0.3.1 FastShiftOut

This commit is contained in:
rob tillaart 2023-02-20 17:37:06 +01:00
parent d3cb255b01
commit c1e371adeb
13 changed files with 119 additions and 39 deletions

View File

@ -6,7 +6,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update

View File

@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

View File

@ -10,7 +10,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: json-syntax-check
uses: limitusus/json-syntax-check@v1
with:

View File

@ -6,16 +6,23 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.3.1] - 2023-02-20
- update readme.md
- update GitHub actions
- update license 2023
- minor edits
## [0.3.0] - 2022-11-05
- major refactor
----
## [0.2.5] - 2022-11-05
- add changelog.md
- add rp2040 to build-CI
- update readme.md
## [0.2.4] - 2021-12-17
- license

View File

@ -0,0 +1,30 @@
IDE: 1.8.19
Board: UNO
example fastShiftOut: 0.3.1
Performance - time in us
write: 23.41
write: 45.89
Delta: 22.48
writeLSBFIRST: 22.51
writeLSBFIRST: 45.88
Delta: 23.37
writeMSBFIRST: 23.02
writeMSBFIRST: 44.88
Delta: 21.86
Standard shiftOut1: 89.85
Standard shiftOut2: 179.59
Delta: 89.74
Test print interface
println("Hello world"): 328.92
println(1357): 313.56
println(3.14159265, 4): 717.36
done ...

View File

@ -1,12 +1,10 @@
//
// FILE: FastShiftOut.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.2.5
// VERSION: 0.3.1
// PURPOSE: ShiftOut that implements the Print interface
// DATE: 2013-08-22
// URL: https://github.com/RobTillaart/FastShiftOut
//
// HISTORY: see changelog.md
#include "FastShiftOut.h"
@ -33,7 +31,7 @@ FastShiftOut::FastShiftOut(uint8_t dataOut, uint8_t clockPin, uint8_t bitOrder)
#else // reference implementation
_dataPinOut = dataOut;
_clockPin = clockPin;
_clockPin = clockPin;
#endif
}
@ -41,7 +39,6 @@ FastShiftOut::FastShiftOut(uint8_t dataOut, uint8_t clockPin, uint8_t bitOrder)
size_t FastShiftOut::write(uint8_t data)
{
_value = data;
if (_bitOrder == LSBFIRST)
{
return writeLSBFIRST(data);
@ -50,11 +47,35 @@ size_t FastShiftOut::write(uint8_t data)
}
/* experimental
size_t write(const uint8_t \*buffer, size_t size)
{
size_t n = 0;
if (_bitOrder == LSBFIRST)
{
for (size_t i = size; i > 0; ) // from end to begin ????
{
i--;
n += writeLSBFIRST(buffer[i]);
}
}
else
{
for (size_t i = 0; i < size; i++) // from begin to end..
{
n += writeMSBFIRST(buffer[i]);
}
}
return n;
}
*/
size_t FastShiftOut::writeLSBFIRST(uint8_t data)
{
uint8_t value = data;
_value = value;
_lastValue = value;
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR)
uint8_t cbmask1 = _clockBit;
@ -86,8 +107,8 @@ size_t FastShiftOut::writeLSBFIRST(uint8_t data)
size_t FastShiftOut::writeMSBFIRST(uint8_t data)
{
uint8_t value = data;
_value = value;
_lastValue = value;
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR)
uint8_t cbmask1 = _clockBit;
@ -113,14 +134,13 @@ size_t FastShiftOut::writeMSBFIRST(uint8_t data)
#endif
return 1;
}
uint8_t FastShiftOut::lastWritten(void)
{
return _value;
};
return _lastValue;
}
bool FastShiftOut::setBitOrder(const uint8_t bitOrder)
@ -137,8 +157,8 @@ bool FastShiftOut::setBitOrder(const uint8_t bitOrder)
uint8_t FastShiftOut::getBitOrder(void)
{
return _bitOrder;
};
}
// -- END OF FILE --
// -- END OF FILE --

View File

@ -2,7 +2,7 @@
//
// FILE: FastShiftOut.h
// AUTHOR: Rob Tillaart
// VERSION: 0.3.0
// VERSION: 0.3.1
// PURPOSE: shiftOut class that implements the Print interface
// DATE: 2013-08-22
// URL: https://github.com/RobTillaart/FastShiftOut
@ -11,7 +11,7 @@
#include "Arduino.h"
#include "Print.h"
#define FASTSHIFTOUT_LIB_VERSION (F("0.3.0"))
#define FASTSHIFTOUT_LIB_VERSION (F("0.3.1"))
class FastShiftOut : public Print
@ -21,6 +21,8 @@ public:
FastShiftOut(uint8_t dataOut, uint8_t clockPin, uint8_t bitOrder = LSBFIRST);
size_t write(uint8_t data);
// experimental
// size_t write(const uint8_t \*buffer, size_t size);
uint8_t lastWritten(void);
bool setBitOrder(uint8_t bitOrder);
@ -32,7 +34,7 @@ public:
private:
uint8_t _bitOrder;
int _value;
int _lastValue;
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR)

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2013-2022 Rob Tillaart
Copyright (c) 2013-2023 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

View File

@ -35,20 +35,28 @@ The performance of **write()** is substantially faster than the default Arduino
Exact how big the performance gain is can be seen with the example sketch.
It does a comparison and shows how the class is to be used.
test 0.2.4 Arduino UNO
Time in microseconds, Arduino UNO
| function | time (us) |
|:----------------------|----------:|
| write() | 21.66 |
| writeLSBFIRST() | 22.94 |
| writeMSBFIRST() | 20.30 |
| reference shiftOut() | 89.74 |
| function | 0.2.4 | 0.3.1 |
|:-------------------------|--------:|---------:|
| write() | 21.66 | 22.48 |
| writeLSBFIRST() | 22.94 | 23.37 |
| writeMSBFIRST() | 20.30 | 21.86 |
| reference shiftOut() | 89.74 | 89.74 |
| println("Hello world") | | 328.92 |
| println(1357) | | 313.56 |
| println(3.14159265, 4) | | 717.36 |
## Interface
The interface exists of the following functions:
```cpp
#include "FastShiftOut.h"
```
#### Functions
- **FastShiftOut(uint8_t dataOut, uint8_t clockPin, uint8_t bitOrder = LSBFIRST)** Constructor.
- **size_t write(const uint8_t data)** send a byte, also the workhorse of the **Print** interface.
- **uint8_t lastWritten()** returns last byte written.
- **bool setBitOrder(uint8_t bitOrder)** set LSBFIRST or MSBFIRST. Returns false for other values.
@ -56,7 +64,9 @@ The interface exists of the following functions:
- **size_t writeLSBFIRST(const uint8_t data);** most optimized.
- **size_t writeMSBFIRST(const uint8_t data);** most optimized.
As a FastShiftOut object implements the Print interface, one can also call
- **FSO.print(any type);** or
- **FSO.println(any type);**
@ -72,15 +82,21 @@ Note: **FSO.print()** returns the number of characters printed, including an opt
pull up resistors, especially if wires are exceeding 10 cm (4").
## Operation
See examples
## Future
#### Must
#### Should
- extend unit tests
#### Could
- performance ESP32
- check optimized ESP32
- add **size_t write(const uint8_t \*buffer, size_t size)**
- example schema
#### Wont

View File

@ -6,9 +6,12 @@ FastShiftOut KEYWORD1
# Methods and Functions (KEYWORD2)
write KEYWORD2
lastWritten KEYWORD2
setBitOrder KEYWORD2
getBitOrder KEYWORD2
writeLSBFIRST KEYWORD2
writeMSBFIRST KEYWORD2

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/FastShiftOut.git"
},
"version": "0.3.0",
"version": "0.3.1",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=FastShiftOut
version=0.3.0
version=0.3.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for (AVR) optimized shiftOut - e.g. 74HC595

View File

@ -3,7 +3,7 @@
// AUTHOR: Rob Tillaart
// DATE: 2020-12-03
// PURPOSE: unit tests for the FastShiftIn library
// https://github.com/RobTillaart/FastShiftIn
// https://github.com/RobTillaart/FastShiftOut
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md
//
@ -94,4 +94,6 @@ unittest(test_print)
unittest_main()
// --------
// -- END OF FILE --