Exploring BeagleBone  V1.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SevenSegmentDisplay.h
Go to the documentation of this file.
1 /*
2  * SevenSegmentDisplay.h Created on: 6 Jun 2014
3  * Copyright (c) 2014 Derek Molloy (www.derekmolloy.ie)
4  * Made available for the book "Exploring BeagleBone"
5  * See: www.exploringbeaglebone.com
6  * Licensed under the EUPL V.1.1
7  *
8  * This Software is provided to You under the terms of the European
9  * Union Public License (the "EUPL") version 1.1 as published by the
10  * European Union. Any use of this Software, other than as authorized
11  * under this License is strictly prohibited (to the extent such use
12  * is covered by a right of the copyright holder of this Software).
13  *
14  * This Software is provided under the License on an "AS IS" basis and
15  * without warranties of any kind concerning the Software, including
16  * without limitation merchantability, fitness for a particular purpose,
17  * absence of defects or errors, accuracy, and non-infringement of
18  * intellectual property rights other than copyright. This disclaimer
19  * of warranty is an essential part of the License and a condition for
20  * the grant of any rights to this Software.
21  *
22  * For more details, see http://www.derekmolloy.ie/
23  */
24 
25 #ifndef SEVENSEGMENTDISPLAY_H_
26 #define SEVENSEGMENTDISPLAY_H_
27 #include "../bus/SPIDevice.h"
28 
29 namespace exploringBB {
30 
36 private:
37  SPIDevice *spidevice;
38  int numberSegments;
39  int numberBase;
40  bool isCommonAnode;
41 
42 public:
43  SevenSegmentDisplay(SPIDevice *device, int numberSegments);
44  virtual int write(int number); // writes an integer
45  virtual int write(float number, int places); // uses the "decimal" point
46  virtual int setNumberBase(int base);
47  virtual int getNumberBase() { return this->numberBase; }
48  virtual int getNumberSegments() { return this->numberSegments; }
49  virtual void setCommonAnode(bool isCommonAnode) { this->isCommonAnode = isCommonAnode; }
50  virtual ~SevenSegmentDisplay(); // closes the SPI device
51 
52 private:
53  const static unsigned char symbols[];
54 };
55 
56 } /* namespace exploringBB */
57 
58 #endif /* SEVENSEGMENTDISPLAY_H_ */
virtual int write(int number)
Definition: SevenSegmentDisplay.cpp:56
virtual void setCommonAnode(bool isCommonAnode)
Definition: SevenSegmentDisplay.h:49
SevenSegmentDisplay(SPIDevice *device, int numberSegments)
Definition: SevenSegmentDisplay.cpp:44
virtual int getNumberSegments()
Definition: SevenSegmentDisplay.h:48
A class that allows you to drive an array of 7 segment displays using an array of 74XX595 ICs...
Definition: SevenSegmentDisplay.h:35
Generic SPI Device class that can be used to connect to any type of SPI device and read or write to i...
Definition: SPIDevice.h:39
virtual int setNumberBase(int base)
Definition: SevenSegmentDisplay.cpp:51
Definition: BusDevice.cpp:27
virtual ~SevenSegmentDisplay()
Definition: SevenSegmentDisplay.cpp:88
virtual int getNumberBase()
Definition: SevenSegmentDisplay.h:47