2016-09-26 21:14:03 +00:00
|
|
|
#ifndef SegmentDisplay_h
|
|
|
|
#define SegmentDisplay_h
|
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Drives up to 8 digits using two 8-bit shift registers.
|
|
|
|
*
|
|
|
|
* Pushes out the segment bits first and the display selection
|
|
|
|
* second: connect the display select register first and chain the
|
|
|
|
* segment register to it's output.
|
|
|
|
*
|
|
|
|
* Least significant bit as defined in SegmentDisplayChars.h:
|
|
|
|
* - Last digit
|
|
|
|
* - Segment A
|
|
|
|
**/
|
|
|
|
|
|
|
|
// Comment to use shiftOut. Set clockPin and dataPin instead.
|
2016-09-27 21:28:43 +00:00
|
|
|
//#define SDSupportSPI
|
2016-09-26 21:14:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SegmentDisplay
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void begin();
|
|
|
|
void end();
|
|
|
|
|
|
|
|
void writeNumber(int value);
|
|
|
|
void writeText(char* value);
|
|
|
|
|
|
|
|
int getDigits() { return digits; }
|
|
|
|
void setDigits(int value) { digits = value; }
|
|
|
|
|
|
|
|
int getLatchPin() { return latchPin; }
|
|
|
|
void setLatchPin(int value) { latchPin = value; }
|
|
|
|
|
|
|
|
#if defined(SDSupportSPI)
|
|
|
|
long getClockSpeed() { return clockSpeed; }
|
|
|
|
void setClockSpeed(long value) { clockSpeed = value; }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(SDSupportSPI)
|
|
|
|
int getClockPin() { return clockPin; }
|
|
|
|
void setClockPin(int value) { clockPin = value; }
|
|
|
|
|
|
|
|
int getDataPin() { return dataPin; }
|
|
|
|
void setDataPin(int value) { dataPin = value; }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2016-09-27 21:28:43 +00:00
|
|
|
inline void writeDigit(unsigned char value, unsigned char digitMask);
|
|
|
|
inline void writeDisplay(unsigned char characterMask, unsigned char digitMask);
|
2016-09-26 21:14:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int digits = 6;
|
|
|
|
int latchPin = SS;
|
|
|
|
|
|
|
|
#if defined(SDSupportSPI)
|
|
|
|
long clockSpeed = 20000000;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(SDSupportSPI)
|
|
|
|
int clockPin = SCK;
|
|
|
|
int dataPin = MOSI;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|