Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SevenSegmentDisplay.h
- Committer:
- tbjazic
- Date:
- 2014-12-11
- Revision:
- 4:21f0a3289449
- Parent:
- 3:9c9257dda979
File content as of revision 4:21f0a3289449:
#ifndef SEVEN_SEGMENT_DISPLAY_H_KEY #define SEVEN_SEGMENT_DISPLAY_H_KEY #include "mbed.h" enum ConnectionMode {CommonAnode, CommonCathode}; /** A class for controling the output of 7-segment displays connected in * common anode or common cathode mode. * * Author: Toni Bjazic, TVZ Mechatronics Team * * Example of use: * @code * #include "mbed.h" * #include "SevenSegmentDisplay.h" * * Serial pc(USBTX, USBRX); * * int main() { * SevenSegmentDisplay display(p5, p6, p7, p8, p9, p10, p11, p12, CommonCathode); * char c; * while(1) { * pc.printf("\n\rEnter character to show on 7-segment display: "); * pc.scanf("%c", &c); * display.print(c); * wait(0.2); * } * } * @endcode */ class SevenSegmentDisplay { public: /** Constructor receives pins on which the segments a, b, c, d, e, f, g and dp * are connected (respectively). Last (9th) argument is connection mode (CommonAnode * or CommonCathode), and defaults to CommonAnode. */ SevenSegmentDisplay(PinName a, PinName b, PinName c, PinName d, PinName e, PinName f, PinName g, PinName dp, ConnectionMode = CommonAnode); /** Member function which initializes the display. */ void init(); /** Member function which prints the character on the 7-segment display. */ void print(char); private: BusInOut display; ConnectionMode mode; void turnOn(int); }; #endif