A class that allows you to drive an array of 7 segment displays using an array of 74XX595 ICs.
More...
#include <SevenSegmentDisplay.h>
A class that allows you to drive an array of 7 segment displays using an array of 74XX595 ICs.
exploringBB::SevenSegmentDisplay::SevenSegmentDisplay |
( |
SPIDevice * |
device, |
|
|
int |
numberSegments |
|
) |
| |
The constructor for the 7-segment display that defines the number of segments.
- Parameters
-
device | The pointer to the SPI device bus |
numberSegments | The number of 7-segment modules attached to the bus |
45 this->spidevice = device;
46 this->numberSegments = numberSegments;
47 this->numberBase = 10;
48 this->isCommonAnode =
false;
exploringBB::SevenSegmentDisplay::~SevenSegmentDisplay |
( |
| ) |
|
|
virtual |
89 this->spidevice->
close();
virtual void close()
Definition: SPIDevice.cpp:245
virtual int exploringBB::SevenSegmentDisplay::getNumberBase |
( |
| ) |
|
|
inlinevirtual |
47 {
return this->numberBase; }
virtual int exploringBB::SevenSegmentDisplay::getNumberSegments |
( |
| ) |
|
|
inlinevirtual |
48 {
return this->numberSegments; }
virtual void exploringBB::SevenSegmentDisplay::setCommonAnode |
( |
bool |
isCommonAnode | ) |
|
|
inlinevirtual |
49 { this->isCommonAnode = isCommonAnode; }
int exploringBB::SevenSegmentDisplay::setNumberBase |
( |
int |
base | ) |
|
|
virtual |
52 if (base>16 || base<2)
return -1;
53 return (this->numberBase = base);
int exploringBB::SevenSegmentDisplay::write |
( |
int |
number | ) |
|
|
virtual |
58 unsigned char output[this->numberSegments];
60 for(
int i=0; i<this->numberSegments; i++){
61 output[i] = this->symbols[number%this->numberBase];
62 if(this->isCommonAnode) output[i]=~output[i];
63 number = number/this->numberBase;
65 this->spidevice->
write(output, this->numberSegments);
virtual int write(unsigned char value)
Definition: SPIDevice.cpp:139
int exploringBB::SevenSegmentDisplay::write |
( |
float |
number, |
|
|
int |
places |
|
) |
| |
|
virtual |
71 if (places>(this->numberSegments-1))
return -1;
73 int intNumber = (int) number;
74 if (places>0) intNumber = (int)(number * places * this->numberBase);
76 unsigned char output[this->numberSegments];
78 for(
int i=0; i<this->numberSegments; i++){
79 output[i] = this->symbols[intNumber%this->numberBase];
80 if(i==places) output[i] = output[i] | 0b10000000;
81 if(this->isCommonAnode) output[i]=~output[i];
82 intNumber = intNumber/this->numberBase;
84 this->spidevice->
write(output, this->numberSegments);
virtual int write(unsigned char value)
Definition: SPIDevice.cpp:139
The documentation for this class was generated from the following files: