mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.3.1 FastShiftOut
This commit is contained in:
parent
d3cb255b01
commit
c1e371adeb
@ -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
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 ...
|
||||
|
@ -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"
|
||||
@ -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,10 +47,34 @@ 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)
|
||||
|
||||
@ -86,7 +107,7 @@ 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)
|
||||
|
||||
@ -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,7 +157,7 @@ bool FastShiftOut::setBitOrder(const uint8_t bitOrder)
|
||||
uint8_t FastShiftOut::getBitOrder(void)
|
||||
{
|
||||
return _bitOrder;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// -- END OF 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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -6,9 +6,12 @@ FastShiftOut KEYWORD1
|
||||
|
||||
# Methods and Functions (KEYWORD2)
|
||||
write KEYWORD2
|
||||
|
||||
lastWritten KEYWORD2
|
||||
|
||||
setBitOrder KEYWORD2
|
||||
getBitOrder KEYWORD2
|
||||
|
||||
writeLSBFIRST KEYWORD2
|
||||
writeMSBFIRST KEYWORD2
|
||||
|
||||
|
@ -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": "*",
|
||||
|
@ -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
|
||||
|
@ -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 --
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user