mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.2.4 FastShiftOut
This commit is contained in:
parent
7b44c5ef5d
commit
97086c437b
@ -2,6 +2,11 @@ compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
- leonardo
|
||||
- due
|
||||
- zero
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
- m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
- mega2560
|
||||
|
||||
|
@ -4,10 +4,14 @@ name: Arduino CI
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
arduino_ci:
|
||||
runTest:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: Arduino-CI/action@master
|
||||
# Arduino-CI/action@v0.1.1
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
- run: |
|
||||
gem install arduino_ci
|
||||
arduino_ci.rb
|
||||
|
@ -1,10 +1,8 @@
|
||||
//
|
||||
// FILE: FastShiftOut_demo.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.01
|
||||
// PURPOSE: test sketch
|
||||
// URL: https://github.com/RobTillaart/FastShiftOut
|
||||
//
|
||||
|
||||
|
||||
#include "FastShiftOut.h"
|
||||
@ -15,10 +13,10 @@ FastShiftOut FSO(12, 13, LSBFIRST);
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.print("example fastShiftOut: ");
|
||||
Serial.print("example fastShiftOut: ");
|
||||
Serial.println(FASTSHIFTOUT_LIB_VERSION);
|
||||
|
||||
Serial.println("\nPerformance - time in us");
|
||||
Serial.println("\nPerformance - time in us");
|
||||
uint32_t start = micros();
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
|
@ -1,10 +1,8 @@
|
||||
//
|
||||
// FILE: FastShiftOut_test.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// PURPOSE: test sketch
|
||||
// URL: https://github.com/RobTillaart/FastShiftOut
|
||||
//
|
||||
|
||||
|
||||
#include "FastShiftOut.h"
|
||||
|
@ -1,11 +1,10 @@
|
||||
//
|
||||
// FILE: FastShiftOut.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.2.3
|
||||
// PURPOSE: shiftout that implements the Print interface
|
||||
// VERSION: 0.2.4
|
||||
// PURPOSE: ShiftOut that implements the Print interface
|
||||
// DATE: 2013-08-22
|
||||
// URL: https://github.com/RobTillaart/FastShiftOut
|
||||
//
|
||||
|
||||
|
||||
#include "FastShiftOut.h"
|
||||
|
@ -2,31 +2,31 @@
|
||||
//
|
||||
// FILE: FastShiftOut.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.2.3
|
||||
// PURPOSE: shiftout that implements the Print interface
|
||||
// VERSION: 0.2.4
|
||||
// PURPOSE: shiftOut class that implements the Print interface
|
||||
// DATE: 2013-08-22
|
||||
// URL: https://github.com/RobTillaart/FastShiftOut
|
||||
//
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "Print.h"
|
||||
|
||||
#define FASTSHIFTOUT_LIB_VERSION (F("0.2.3"))
|
||||
#define FASTSHIFTOUT_LIB_VERSION (F("0.2.4"))
|
||||
|
||||
|
||||
class FastShiftOut : public Print
|
||||
{
|
||||
public:
|
||||
// bitorder = { LSBFIRST, MSBFIRST };
|
||||
// bitOrder = { LSBFIRST, MSBFIRST };
|
||||
FastShiftOut(const uint8_t datapin, const uint8_t clockpin, const uint8_t bitOrder = LSBFIRST);
|
||||
|
||||
size_t write(const uint8_t data);
|
||||
uint8_t lastWritten(void) { return _value; };
|
||||
|
||||
bool setBitOrder(const uint8_t bitOrder);
|
||||
uint8_t getBitOrder(void) { return _bitorder; };
|
||||
|
||||
// overrule bitorder (most optimized).
|
||||
// overrule bitOrder (most optimized).
|
||||
size_t writeLSBFIRST(const uint8_t data);
|
||||
size_t writeMSBFIRST(const uint8_t data);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-2021 Rob Tillaart
|
||||
Copyright (c) 2013-2022 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
|
||||
|
@ -1,12 +1,14 @@
|
||||
|
||||
[![Arduino CI](https://github.com/RobTillaart/FastShiftOut/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
||||
[![Arduino-lint](https://github.com/RobTillaart/FastShiftOut/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/FastShiftOut/actions/workflows/arduino-lint.yml)
|
||||
[![JSON check](https://github.com/RobTillaart/FastShiftOut/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/FastShiftOut/actions/workflows/jsoncheck.yml)
|
||||
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/FastShiftOut/blob/master/LICENSE)
|
||||
[![GitHub release](https://img.shields.io/github/release/RobTillaart/FastShiftOut.svg?maxAge=3600)](https://github.com/RobTillaart/FastShiftOut/releases)
|
||||
|
||||
|
||||
# FastShiftOut
|
||||
|
||||
Arduino library for (AVR) optimized shiftOut - e.g. 74HC595
|
||||
Arduino library for (AVR) optimized shiftOut - e.g. 74HC595.
|
||||
|
||||
A library for FastShiftIn also exist - https://github.com/RobTillaart/FastShiftIn
|
||||
|
||||
@ -14,7 +16,7 @@ A library for FastShiftIn also exist - https://github.com/RobTillaart/FastShiftI
|
||||
## Description
|
||||
|
||||
FastShiftOut is a class that has optimized code for AVR to shift out data faster
|
||||
than the normal shiftOut() function.
|
||||
than the normal **shiftOut()** function.
|
||||
It speeds up the shift using low level ports and masks. These are predetermined
|
||||
in the constructor of the FastShiftOut object.
|
||||
|
||||
@ -34,12 +36,12 @@ It does a comparison and shows how the class is to be used.
|
||||
|
||||
The interface exists of the following functions:
|
||||
|
||||
- **size_t write(const uint8_t data);** send a byte, also the workhorse of the **Print** interface
|
||||
- **uint8_t lastWritten()** returns last byte writtem
|
||||
- **bool setBitOrder(bitOrder)** set LSBFIRST or MSBFIRST. Returns false for other values.
|
||||
- **uint8_t getBitOrder(void)** returns LSBFIRST or MSBFIRST
|
||||
- **size_t writeLSBFIRST(const uint8_t data);** most optimized
|
||||
- **size_t writeMSBFIRST(const uint8_t data);** most optimized
|
||||
- **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.
|
||||
- **uint8_t getBitOrder(void)** returns LSBFIRST or MSBFIRST.
|
||||
- **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
|
||||
@ -47,7 +49,7 @@ As a FastShiftOut object implements the Print interface, one can also call
|
||||
|
||||
to send e.g. a float with 4 digits over the line, or some text string.
|
||||
|
||||
Note: **FSO.print()** returns the characters printed, including an optional \\r or \\n.
|
||||
Note: **FSO.print()** returns the number of characters printed, including an optional \\r or \\n.
|
||||
|
||||
|
||||
## Notes
|
||||
@ -61,3 +63,11 @@ pull up resistors, especially if wires are exceeding 10 cm (4").
|
||||
|
||||
See examples
|
||||
|
||||
|
||||
## Future
|
||||
|
||||
- performance ESP32
|
||||
- check optimized ESP32
|
||||
- add **size_t write(const uint8_t \*buffer, size_t size)**
|
||||
- example schema
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Syntax Coloring Map For FastShiftOut
|
||||
# Syntax Colouring Map For FastShiftOut
|
||||
|
||||
# Datatypes (KEYWORD1)
|
||||
# Data types (KEYWORD1)
|
||||
FastShiftOut KEYWORD1
|
||||
|
||||
|
||||
|
@ -15,8 +15,9 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/FastShiftOut.git"
|
||||
},
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.4",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*"
|
||||
"platforms": "*",
|
||||
"headers": "FastShiftOut.h"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=FastShiftOut
|
||||
version=0.2.3
|
||||
version=0.2.4
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for (AVR) optimized shiftOut - e.g. 74HC595
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
fprintf(stderr, "FASTSHIFTOUT_LIB_VERSION: %s\n", (char *) FASTSHIFTOUT_LIB_VERSION);
|
||||
}
|
||||
|
||||
|
||||
@ -43,7 +44,6 @@ unittest(test_constructor)
|
||||
{
|
||||
FastShiftOut FSO(12, 13);
|
||||
|
||||
fprintf(stderr, "VERSION:\t%s\n", FASTSHIFTOUT_LIB_VERSION);
|
||||
assertEqual(LSBFIRST, FSO.getBitOrder());
|
||||
|
||||
FSO.setBitOrder(MSBFIRST);
|
||||
@ -55,7 +55,6 @@ unittest(test_constructor_LSB)
|
||||
{
|
||||
FastShiftOut FSO(12, 13, LSBFIRST);
|
||||
|
||||
fprintf(stderr, "VERSION:\t%s\n", FASTSHIFTOUT_LIB_VERSION);
|
||||
assertEqual(LSBFIRST, FSO.getBitOrder());
|
||||
|
||||
FSO.setBitOrder(MSBFIRST);
|
||||
@ -67,7 +66,6 @@ unittest(test_constructor_MSB)
|
||||
{
|
||||
FastShiftOut FSO(12, 13, MSBFIRST);
|
||||
|
||||
fprintf(stderr, "VERSION:\t%s\n", FASTSHIFTOUT_LIB_VERSION);
|
||||
assertEqual(MSBFIRST, FSO.getBitOrder());
|
||||
|
||||
FSO.setBitOrder(LSBFIRST);
|
||||
@ -79,8 +77,6 @@ unittest(test_write)
|
||||
{
|
||||
FastShiftOut FSO(12, 13);
|
||||
|
||||
fprintf(stderr, "VERSION:\t%s\n", FASTSHIFTOUT_LIB_VERSION);
|
||||
|
||||
assertEqual(1, FSO.write(0x42));
|
||||
assertEqual(1, FSO.writeLSBFIRST(0xAA));
|
||||
assertEqual(1, FSO.writeMSBFIRST(0x55));
|
||||
@ -91,14 +87,11 @@ unittest(test_print)
|
||||
{
|
||||
FastShiftOut FSO(12, 13);
|
||||
|
||||
fprintf(stderr, "VERSION:\t%s\n", FASTSHIFTOUT_LIB_VERSION);
|
||||
|
||||
assertEqual(5, FSO.print(FASTSHIFTOUT_LIB_VERSION));
|
||||
assertEqual(7, FSO.println(FASTSHIFTOUT_LIB_VERSION));
|
||||
}
|
||||
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
||||
|
Loading…
Reference in New Issue
Block a user