test test / Mbed 2 deprecated calcRate
Embed: (wiki syntax)

« Back to documentation index

SSegSRDriver Class Reference

SSegSRDriver Class Reference

7-Segment Display Driver class, via a 8-bit shift register (such as the 74HC595) More...

#include <7SegSRDriver.h>

Public Member Functions

 SSegSRDriver (PinName srData, PinName srClock, PinName srLatch, bool disp_type)
 Create a 7-Segment Display Driver object connected to a 8-bit shift register on the given DigitalOut pins.
void set_type (bool disp_type)
 Change the type of 7-Segment Display.
void write (unsigned char number)
 Sets the currently shown digit on the display.
void write (unsigned char number, bool dp)
 Sets the currently shown digit on the display along with the decimal place.
void write_raw (unsigned char number)
 Sets the segments of the display directly Segments are lit by binary flags where LSB is the decimal point, then segments a-g up to the MSB e.g.
void clear ()
 Turn all segments of the display off.

Detailed Description

7-Segment Display Driver class, via a 8-bit shift register (such as the 74HC595)

Display should be hooked up to shift register as follows: Q0 : Decimal Point, Q1-Q7 : Segments a-g

Example:

 #include "mbed.h"
 #include "7SegSRDriver.h"

 SSegSRDriver display(p27,p25,p26, SSegSRDriver_COMN_ANODE);

 int main() {
     while (1) {
         // Show the chars 0-9 then A-F, flashing the decimal point on and off
         for (int i=0; i<16; i++) {
             display.write(i,i%2 == 0);
             wait(1);
         }
     }
 }

Definition at line 57 of file 7SegSRDriver.h.


Constructor & Destructor Documentation

SSegSRDriver ( PinName  srData,
PinName  srClock,
PinName  srLatch,
bool  disp_type 
)

Create a 7-Segment Display Driver object connected to a 8-bit shift register on the given DigitalOut pins.

Parameters:
srDataShift Register Data pin (DigitalOut)
srClockShift Register Clock pin (DigitalOut)
srLatchShift Register Latch pin (DigitalOut)
disp_typeDisplay Type: Common Anode/Cathode (SSegSRDriver_COMN_ANODE (0) or SSegSRDriver_COMN_CATHODE (1))

Definition at line 29 of file 7SegSRDriver.cpp.


Member Function Documentation

void clear (  )

Turn all segments of the display off.

Definition at line 38 of file 7SegSRDriver.cpp.

void set_type ( bool  disp_type )

Change the type of 7-Segment Display.

Parameters:
disp_typeDisplay Type: Common Anode/Cathode (SSegSRDriver_COMN_ANODE (0) or SSegSRDriver_COMN_CATHODE (1))

Definition at line 34 of file 7SegSRDriver.cpp.

void write ( unsigned char  number )

Sets the currently shown digit on the display.

Parameters:
numberThe digit to display (0-15) to show numbers 0-9 and letters A-F

Definition at line 42 of file 7SegSRDriver.cpp.

void write ( unsigned char  number,
bool  dp 
)

Sets the currently shown digit on the display along with the decimal place.

Parameters:
numberThe digit to display (0-15) to show numbers 0-9 and letters A-F
dpIf the decimal place should be lit (0:Off, 1:On)

Definition at line 46 of file 7SegSRDriver.cpp.

void write_raw ( unsigned char  number )

Sets the segments of the display directly Segments are lit by binary flags where LSB is the decimal point, then segments a-g up to the MSB e.g.

to light segments e, f and the decimal place = 01100001

Parameters:
bValueThe segments to light

Definition at line 56 of file 7SegSRDriver.cpp.