+ FastShiftOut version 0.1.5

+ optimized masking in inner loop
This commit is contained in:
RobTillaart 2017-04-27 00:10:51 +02:00
parent 7f8134f8f6
commit 2f5952ec05
4 changed files with 15 additions and 12 deletions

View File

@ -1,13 +1,16 @@
//
// FILE: FastShiftOut.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.04
// VERSION: 0.1.5
// PURPOSE: shiftout that implements the Print interface
// DATE: 2013-08-22
// URL:
//
// Released to the public domain
//
// HISTORY
// 0.1.5 - changed masking in inner loop
//
#include "FastShiftOut.h"
@ -37,15 +40,15 @@ FastShiftOut::FastShiftOut(const uint8_t datapin, const uint8_t clockpin, const
//
// write() must implement the virtual write of Print class
//
// approx 64us/byte
// approx 30 us/byte
size_t FastShiftOut::write(const uint8_t data)
{
_value = data;
for (uint8_t i = 0; i < 8; i++)
for (uint8_t i = 0, m = 1, n = 128; i < 8; i++, m <<= 1, n >>= 1)
{
uint8_t v;
if (_bitorder == LSBFIRST) v = (_value & (1 << i));
else v = (_value & (1 << (7 - i)));
if (_bitorder == LSBFIRST) v = (_value & m);
else v = (_value & n);
uint8_t oldSREG = SREG;
cli();
@ -61,7 +64,7 @@ size_t FastShiftOut::write(const uint8_t data)
//
// this version is twice as fast,
// but it is in CLI() mode
// approx 32 us / byte
// approx 32us / byte
// size_t FastShiftOut::write(uint8_t data)
// {
// _value = data;

View File

@ -1,7 +1,7 @@
//
// FILE: FastShiftOut.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.04
// VERSION: 0.1.5
// PURPOSE: shiftout that implements the Print interface
// DATE: 2013-08-22
// URL:
@ -18,7 +18,7 @@
#include "WProgram.h"
#endif
#define FASTSHIFTOUT_LIB_VERSION (F("0.1.04"))
#define FASTSHIFTOUT_LIB_VERSION (F("0.1.5"))
#include "Print.h"

View File

@ -1,7 +1,7 @@
{
"name": "FastShiftOut",
"keywords": "Shift out serial ",
"description": "Class for up to 2x faster shift out. Implements print() interface.",
"description": "Class for up to 3x faster shift out. Implements print() interface.",
"authors":
[
{
@ -16,7 +16,7 @@
"url": "https://github.com/RobTillaart/Arduino.git"
},
"frameworks": "arduino",
"platforms": "*",
"platforms": "AVR",
"export": {
"include": "libraries/FastShiftOut"
}

View File

@ -1,8 +1,8 @@
name=FastShiftOut
version=0.1.04
version=0.1.5
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Class for up to 2x faster shift out.
sentence=Class for up to 3x faster shift out.
paragraph=Implements print() interface.
category=Signal Input/Output
url=https://github.com/RobTillaart/Arduino/Libraries/