by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   mbed

Committer:
robt
Date:
Mon Oct 15 21:23:48 2012 +0000
Revision:
0:507436d37d5e
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
robt 0:507436d37d5e 1 /* Program Example 6.6: SegDisplay.cpp file for modular 7-seg keyboard controller
robt 0:507436d37d5e 2 */
robt 0:507436d37d5e 3 #include "SegDisplay.h"
robt 0:507436d37d5e 4 BusOut Seg1(p5,p6,p7,p8,p9,p10,p11,p12); // A,B,C,D,E,F,G,DP
robt 0:507436d37d5e 5 BusOut Seg2(p13,p14,p15,p16,p17,p18,p19,p20); // A,B,C,D,E,F,G,DP
robt 0:507436d37d5e 6
robt 0:507436d37d5e 7 void SegInit(void) {
robt 0:507436d37d5e 8 Seg1=SegConvert(0); // initialise to zero
robt 0:507436d37d5e 9 Seg2=SegConvert(0); // initialise to zero
robt 0:507436d37d5e 10 }
robt 0:507436d37d5e 11
robt 0:507436d37d5e 12 char SegConvert(char SegValue) { // function 'SegConvert'
robt 0:507436d37d5e 13 char SegByte=0x00;
robt 0:507436d37d5e 14 switch (SegValue) { //DP G F E D C B A
robt 0:507436d37d5e 15 case 0 : SegByte = 0x3F; break; // 0 0 1 1 1 1 1 1 binary
robt 0:507436d37d5e 16 case 1 : SegByte = 0x06; break; // 0 0 0 0 0 1 1 0 binary
robt 0:507436d37d5e 17 case 2 : SegByte = 0x5B; break; // 0 1 0 1 1 0 1 1 binary
robt 0:507436d37d5e 18 case 3 : SegByte = 0x4F; break; // 0 1 0 0 1 1 1 1 binary
robt 0:507436d37d5e 19 case 4 : SegByte = 0x66; break; // 0 1 1 0 0 1 1 0 binary
robt 0:507436d37d5e 20 case 5 : SegByte = 0x6D; break; // 0 1 1 0 1 1 0 1 binary
robt 0:507436d37d5e 21 case 6 : SegByte = 0x7D; break; // 0 1 1 1 1 1 0 1 binary
robt 0:507436d37d5e 22 case 7 : SegByte = 0x07; break; // 0 0 0 0 0 1 1 1 binary
robt 0:507436d37d5e 23 case 8 : SegByte = 0x7F; break; // 0 1 1 1 1 1 1 1 binary
robt 0:507436d37d5e 24 case 9 : SegByte = 0x6F; break; // 0 1 1 0 1 1 1 1 binary
robt 0:507436d37d5e 25 }
robt 0:507436d37d5e 26 return SegByte;
robt 0:507436d37d5e 27 }