Rob Toulson / Mbed 2 deprecated PE_06-05_ModularCodeExample

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SegDisplay.cpp Source File

SegDisplay.cpp

00001 /* Program Example 6.6: SegDisplay.cpp file for modular 7-seg keyboard controller 
00002                                                                   */
00003 #include "SegDisplay.h"
00004 BusOut Seg1(p5,p6,p7,p8,p9,p10,p11,p12);      // A,B,C,D,E,F,G,DP
00005 BusOut Seg2(p13,p14,p15,p16,p17,p18,p19,p20); // A,B,C,D,E,F,G,DP
00006 
00007 void SegInit(void) {
00008   Seg1=SegConvert(0);        // initialise to zero
00009   Seg2=SegConvert(0);        // initialise to zero
00010 }
00011 
00012 char SegConvert(char SegValue) {         // function 'SegConvert'
00013   char SegByte=0x00;
00014   switch (SegValue) {                  //DP G F E D C B A
00015     case 0 : SegByte = 0x3F; break;    // 0 0 1 1 1 1 1 1 binary
00016     case 1 : SegByte = 0x06; break;    // 0 0 0 0 0 1 1 0 binary
00017     case 2 : SegByte = 0x5B; break;    // 0 1 0 1 1 0 1 1 binary
00018     case 3 : SegByte = 0x4F; break;    // 0 1 0 0 1 1 1 1 binary
00019     case 4 : SegByte = 0x66; break;    // 0 1 1 0 0 1 1 0 binary
00020     case 5 : SegByte = 0x6D; break;    // 0 1 1 0 1 1 0 1 binary
00021     case 6 : SegByte = 0x7D; break;    // 0 1 1 1 1 1 0 1 binary
00022     case 7 : SegByte = 0x07; break;    // 0 0 0 0 0 1 1 1 binary
00023     case 8 : SegByte = 0x7F; break;    // 0 1 1 1 1 1 1 1 binary
00024     case 9 : SegByte = 0x6F; break;    // 0 1 1 0 1 1 1 1 binary
00025   }
00026   return SegByte;
00027 }