Very simple library for controll a 7 segment display.

Dependents:   Demo_Led7seg TP1_EJER02_FERNANDEZ_CLERICI TP1_EJER3 Ejercicio3JalleVentiades ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Led7Seg.h Source File

Led7Seg.h

00001 #include "mbed.h"
00002 //  Simple library that can controll a 7 segment led display
00003 //  Created by Michele Trombetta
00004 //  Copyright 2010 5OFT. All rights reserved.
00005 
00006 #ifndef  led_ANODE
00007 #define led_ANODE 0
00008 #define led_CATHODE 1
00009 #endif
00010 
00011 #ifndef  VAR_num_7seg
00012 #define VAR_num_7seg
00013 //Chars: 0123456789AbCdEF
00014 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};
00015 #endif
00016 
00017 #ifndef  LIB_Led7Seg
00018 #define LIB_Led7Seg
00019 class Led7Seg {
00020 public:
00021     Led7Seg(PinName a, PinName b, PinName c, PinName d, PinName e, PinName f, PinName g);
00022     Led7Seg(PinName a, PinName b, PinName c, PinName d, PinName e, PinName f, PinName g, bool led_type);
00023     void set_type(bool led_type);   // Set the tyep of the display (Anode or Cathode comm.)
00024     void write(unsigned char number);   // Write the data to the display
00025     unsigned char read();   // Read the data of the display
00026     unsigned char convert(unsigned char number);    // Only convert the data, no visualization
00027 private:
00028     BusOut _leddisp;
00029     bool    _led_type;
00030 };
00031 #endif