2021-05-30 08:25:11 -04:00
|
|
|
#pragma once
|
|
|
|
//
|
|
|
|
// FILE: ShiftInSlow.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
2022-11-24 06:49:27 -05:00
|
|
|
// VERSION: 0.1.2
|
2021-05-30 08:25:11 -04:00
|
|
|
// PURPOSE: Arduino library for shiftIn with build-in delay
|
|
|
|
// DATE: 2021-05-11
|
|
|
|
// URL: https://github.com/RobTillaart/ShiftInSlow
|
|
|
|
|
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
|
|
|
|
|
2022-11-24 06:49:27 -05:00
|
|
|
#define SHIFTINSLOW_LIB_VERSION (F("0.1.2"))
|
2021-05-30 08:25:11 -04:00
|
|
|
|
|
|
|
|
|
|
|
class ShiftInSlow
|
|
|
|
{
|
|
|
|
public:
|
2022-11-24 06:49:27 -05:00
|
|
|
// bitOrder = { LSBFIRST, MSBFIRST }; defined in Arduino.h.
|
2021-05-30 08:25:11 -04:00
|
|
|
ShiftInSlow(const uint8_t dataPin, const uint8_t clockPin, const uint8_t bitOrder = LSBFIRST);
|
|
|
|
|
|
|
|
int read(void);
|
|
|
|
int lastRead(void) { return _value; };
|
|
|
|
|
|
|
|
bool setBitOrder(const uint8_t bitOrder);
|
|
|
|
uint8_t getBitOrder(void) { return _bitOrder; };
|
|
|
|
|
2021-12-28 05:35:20 -05:00
|
|
|
void setDelay(uint16_t microseconds) { _delay = microseconds; };
|
2021-05-30 08:25:11 -04:00
|
|
|
uint16_t getDelay() { return _delay; };
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t _clockPin = 0 ;
|
|
|
|
uint8_t _dataPin = 0;
|
|
|
|
uint8_t _bitOrder = LSBFIRST;
|
|
|
|
uint16_t _delay = 0;
|
|
|
|
uint8_t _value = 0;
|
|
|
|
};
|
|
|
|
|
2021-12-28 05:35:20 -05:00
|
|
|
|
2021-05-30 08:25:11 -04:00
|
|
|
// -- END OF FILE --
|
2021-12-28 05:35:20 -05:00
|
|
|
|