Simple library for controll a matrix of 7 segment displays. It also support the Hexadecimal and the Decimal visualisation.
Diff: Multi7Seg.h
- Revision:
- 0:9db0be7962dd
- Child:
- 1:4ee2f3c3cf46
diff -r 000000000000 -r 9db0be7962dd Multi7Seg.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Multi7Seg.h Sat Apr 23 10:17:01 2011 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" +#define format_DEC 1 +#define format_HEX 0 +// Simple library that can controll a matrix of 7 segment led displays +// Created by Michele Trombetta +// Copyright 2010 5OFT. All rights reserved. + +#ifdef led_ANODE +#else + //Chars: 0123456789AbCdEF + const unsigned char num_7seg[24] = {0x3F, 0x6, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x7, 0x7F, 0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00}; + #define led_ANODE 0 + #define led_CATHODE 1 +#endif + +class Multi7Seg { +public: + Multi7Seg(PinName a, PinName b, PinName c, PinName d, PinName e, PinName f, PinName g, PinName disp1, PinName disp2, bool led_type); + Multi7Seg(PinName a, PinName b, PinName c, PinName d, PinName e, PinName f, PinName g, PinName disp1, PinName disp2, PinName disp3, bool led_type); + Multi7Seg(PinName a, PinName b, PinName c, PinName d, PinName e, PinName f, PinName g, PinName disp1, PinName disp2, PinName disp3, PinName disp4, bool led_type); + Multi7Seg(PinName a, PinName b, PinName c, PinName d, PinName e, PinName f, PinName g, PinName disp1, PinName disp2, PinName disp3, PinName disp4, PinName disp5, bool led_type); + void write(unsigned int number); // Write the number to the led displays + void setformat(bool format); // Set the format (0-Dec 1-Hex) + void setspeed(float speed); // Set the delay time for digits scanning + void setenabled(unsigned char enabled); // Enable or disable a single led display (by setting the bit of the argument "enabled") +private: + BusOut _disps; + BusOut _led_7seg; + unsigned char _ndisp, _enabled; + bool _format, _led_type; + float _speed; + unsigned int _num1, _num2, _num3, _num4, _num5; + void led_write(unsigned char number); +}; \ No newline at end of file