48 lines
1.0 KiB
C
Raw Normal View History

2021-05-30 14:25:53 +02:00
#pragma once
//
// FILE: ShiftOutSlow.h
// AUTHOR: Rob Tillaart
2023-02-21 14:13:13 +01:00
// VERSION: 0.1.4
2021-05-30 14:25:53 +02:00
// PURPOSE: Arduino library for shiftOut with build-in delay
// DATE: 2021-05-11
// URL: https://github.com/RobTillaart/ShiftOutSlow
#include "Arduino.h"
2023-02-21 14:13:13 +01:00
#define SHIFTOUTSLOW_LIB_VERSION (F("0.1.4"))
2021-05-30 14:25:53 +02:00
class ShiftOutSlow : public Print
{
public:
2022-11-24 12:51:14 +01:00
// bitOrder = { LSBFIRST, MSBFIRST }; defined in Arduino.h
2021-05-30 14:25:53 +02:00
ShiftOutSlow(const uint8_t dataPin, const uint8_t clockPin, const uint8_t bitOrder = LSBFIRST);
2022-11-24 12:51:14 +01:00
// PRINT INTERFACE
2023-02-21 14:13:13 +01:00
virtual size_t write(const uint8_t data) override;
virtual size_t write(const uint8_t *buffer, size_t size) override;
2021-08-16 19:25:37 +02:00
2023-02-21 14:13:13 +01:00
uint8_t lastWritten();
2021-05-30 14:25:53 +02:00
2023-02-21 14:13:13 +01:00
bool setBitOrder(const uint8_t bitOrder = LSBFIRST);
uint8_t getBitOrder();
2021-08-16 19:25:37 +02:00
2022-11-24 12:51:14 +01:00
// microSeconds = 0..65535
2023-02-21 14:13:13 +01:00
void setDelay(uint16_t microSeconds = 0);
uint16_t getDelay();
2021-05-30 14:25:53 +02:00
private:
2021-12-28 11:53:42 +01:00
uint8_t _clockPin = 0;
2021-05-30 14:25:53 +02:00
uint8_t _dataPin = 0;
uint8_t _bitOrder = LSBFIRST;
uint16_t _delay = 0;
uint8_t _value = 0;
};
2021-12-28 11:53:42 +01:00
2022-11-24 12:51:14 +01:00
// -- END OF FILE --
2021-12-28 11:53:42 +01:00