2016-09-30 21:14:29 +00:00
|
|
|
#ifndef SegmentDisplay_h
|
|
|
|
#define SegmentDisplay_h
|
|
|
|
|
2016-11-27 22:14:17 +00:00
|
|
|
#include "SegmentDisplayConfig.h"
|
2016-09-30 21:14:29 +00:00
|
|
|
#include "Arduino.h"
|
2016-11-27 22:14:17 +00:00
|
|
|
|
|
|
|
#if defined(SDUseSPI)
|
2016-09-30 21:14:29 +00:00
|
|
|
#include "SPI.h"
|
2016-11-27 22:14:17 +00:00
|
|
|
#endif
|
2016-09-30 21:14:29 +00:00
|
|
|
|
|
|
|
#include "SegmentDisplayChars.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Drives up to 8 digits using two 8-bit shift registers.
|
|
|
|
*
|
2016-11-27 22:14:17 +00:00
|
|
|
* 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.
|
2016-09-30 21:14:29 +00:00
|
|
|
*
|
2016-11-27 22:14:17 +00:00
|
|
|
* The order in which the shift registers are chained is determined by
|
|
|
|
* (un)defining SDPushSegmentsFirst.
|
2016-09-30 21:14:29 +00:00
|
|
|
**/
|
|
|
|
|
|
|
|
class SegmentDisplay
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void begin();
|
|
|
|
void end();
|
|
|
|
|
2016-12-05 22:42:20 +00:00
|
|
|
void clear();
|
2016-09-30 21:14:29 +00:00
|
|
|
void writeNumber(uint32_t value);
|
2016-12-05 22:42:20 +00:00
|
|
|
void writeTextLeft(char const* value);
|
|
|
|
void writeRaw(char const* value);
|
2016-09-30 21:14:29 +00:00
|
|
|
|
|
|
|
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; }
|
|
|
|
|
2016-11-27 22:14:17 +00:00
|
|
|
#if defined(SDUseSPI)
|
2016-09-30 21:14:29 +00:00
|
|
|
uint32_t getClockSpeed() { return clockSpeed; }
|
|
|
|
void setClockSpeed(uint32_t value) { clockSpeed = value; }
|
|
|
|
#endif
|
|
|
|
|
2016-11-27 22:14:17 +00:00
|
|
|
#if !defined(SDUseSPI)
|
2016-09-30 21:14:29 +00:00
|
|
|
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);
|
2016-11-29 19:00:47 +00:00
|
|
|
void writeChar(char value, byte digitMask);
|
2016-09-30 21:14:29 +00:00
|
|
|
void writeDisplay(byte characterMask, byte digitMask);
|
|
|
|
|
|
|
|
private:
|
|
|
|
byte digits = 6;
|
|
|
|
uint32_t digitDelayMicroseconds = 1000;
|
|
|
|
uint32_t latchPin = SS;
|
|
|
|
|
2016-11-27 22:14:17 +00:00
|
|
|
#if defined(SDUseSPI)
|
2016-09-30 21:14:29 +00:00
|
|
|
uint32_t clockSpeed = 20000000;
|
|
|
|
#endif
|
|
|
|
|
2016-11-27 22:14:17 +00:00
|
|
|
#if !defined(SDUseSPI)
|
2016-09-30 21:14:29 +00:00
|
|
|
uint32_t clockPin = SCK;
|
|
|
|
uint32_t dataPin = MOSI;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|