78 lines
2.0 KiB
C++
78 lines
2.0 KiB
C++
#ifndef SegmentDisplay_h
|
|
#define SegmentDisplay_h
|
|
|
|
#include "SegmentDisplayConfig.h"
|
|
#include "Arduino.h"
|
|
|
|
#if defined(SDUseSPI)
|
|
#include "SPI.h"
|
|
#endif
|
|
|
|
#include "SegmentDisplayChars.h"
|
|
|
|
/**
|
|
* Drives up to 8 digits using two 8-bit shift registers.
|
|
*
|
|
* Least significant bit ends up at output pin 0 of the shift register,
|
|
* which correlates to Segment A (as defined in SegmentDisplayChars.h).
|
|
* The last digit is also assumed to be at output pin 0 of the chained
|
|
* shift register.
|
|
*
|
|
* The order in which the shift registers are chained is determined by
|
|
* (un)defining SDPushSegmentsFirst.
|
|
**/
|
|
|
|
class SegmentDisplay
|
|
{
|
|
public:
|
|
void begin();
|
|
void end();
|
|
|
|
void clear();
|
|
void writeNumber(uint32_t value);
|
|
void writeTextLeft(char const* value);
|
|
void writeRaw(char const* value);
|
|
|
|
byte getDigits() { return digits; }
|
|
void setDigits(byte value) { digits = value; }
|
|
|
|
uint32_t getLatchPin() { return latchPin; }
|
|
void setLatchPin(uint32_t value) { latchPin = value; }
|
|
|
|
uint32_t getDigitDelayMicroseconds() { return digitDelayMicroseconds; }
|
|
void setDigitDelayMicroseconds(uint32_t value) { digitDelayMicroseconds = value; }
|
|
|
|
#if defined(SDUseSPI)
|
|
uint32_t getClockSpeed() { return clockSpeed; }
|
|
void setClockSpeed(uint32_t value) { clockSpeed = value; }
|
|
#endif
|
|
|
|
#if !defined(SDUseSPI)
|
|
uint32_t getClockPin() { return clockPin; }
|
|
void setClockPin(uint32_t value) { clockPin = value; }
|
|
|
|
uint32_t getDataPin() { return dataPin; }
|
|
void setDataPin(uint32_t value) { dataPin = value; }
|
|
#endif
|
|
|
|
protected:
|
|
void writeDigit(byte value, byte digitMask);
|
|
void writeChar(char value, byte digitMask);
|
|
void writeDisplay(byte characterMask, byte digitMask);
|
|
|
|
private:
|
|
byte digits = 6;
|
|
uint32_t digitDelayMicroseconds = 1000;
|
|
uint32_t latchPin = SS;
|
|
|
|
#if defined(SDUseSPI)
|
|
uint32_t clockSpeed = 20000000;
|
|
#endif
|
|
|
|
#if !defined(SDUseSPI)
|
|
uint32_t clockPin = SCK;
|
|
uint32_t dataPin = MOSI;
|
|
#endif
|
|
};
|
|
|
|
#endif |