HW6 for OCE560

Dependencies:   mbed

Fork of shomberg_hw_5 by Russell Shomberg

Committer:
rshomberg
Date:
Thu Oct 25 18:12:33 2018 +0000
Revision:
9:da0b72918880
Child:
11:42914083ac70
does not compile

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rshomberg 9:da0b72918880 1 /**
rshomberg 9:da0b72918880 2 Temperature Sensor for hw6
rshomberg 9:da0b72918880 3 SegDisplay.cpp
rshomberg 9:da0b72918880 4
rshomberg 9:da0b72918880 5 Purpose: Convert an integer value to a hex
rshomberg 9:da0b72918880 6 Hex output represents binary required to make a 7-seg led show the integer value
rshomberg 9:da0b72918880 7 Pin configuration for 7-Seg
rshomberg 9:da0b72918880 8 ones: 12 13 14 15 16 17 18 19
rshomberg 9:da0b72918880 9 A B C D E F G P
rshomberg 9:da0b72918880 10 tens: 21 22 23 24 25 26 27 28
rshomberg 9:da0b72918880 11
rshomberg 9:da0b72918880 12 @author Russell Shomberg
rshomberg 9:da0b72918880 13 @created 2018-10-23
rshomberg 9:da0b72918880 14 @revised 2018-10-25
rshomberg 9:da0b72918880 15 @version 0.0
rshomberg 9:da0b72918880 16
rshomberg 9:da0b72918880 17 Issues: No Decimal point for temperature
rshomberg 9:da0b72918880 18
rshomberg 9:da0b72918880 19 */
rshomberg 9:da0b72918880 20
rshomberg 9:da0b72918880 21 // INCLUDES
rshomberg 9:da0b72918880 22 #include "mbed.h"
rshomberg 9:da0b72918880 23 #include "SegDisplay.h"
rshomberg 9:da0b72918880 24
rshomberg 9:da0b72918880 25 char SegConvert(int SegValue) { // function 'SegConvert'
rshomberg 9:da0b72918880 26 char SegByte=0x00;
rshomberg 9:da0b72918880 27 switch (abs(SegValue)) { // ABCDEFGP
rshomberg 9:da0b72918880 28 case 0 : SegByte= 0x3F;break; // 11111100 binary
rshomberg 9:da0b72918880 29 case 1 : SegByte= 0x06;break; // 01100000 binary
rshomberg 9:da0b72918880 30 case 2 : SegByte= 0x5B;break; // 11110110 binary
rshomberg 9:da0b72918880 31 case 3 : SegByte= 0x4F;break; // 10011110 binary
rshomberg 9:da0b72918880 32 case 4 : SegByte= 0x66;break; // 11001100 binary
rshomberg 9:da0b72918880 33 case 5 : SegByte= 0x6D;break; // 11011010 binary
rshomberg 9:da0b72918880 34 case 6 : SegByte= 0x7D;break; // 11111010 binary
rshomberg 9:da0b72918880 35 case 7 : SegByte= 0x07;break; // 00001110 binary
rshomberg 9:da0b72918880 36 case 8 : SegByte= 0x7F;break; // 11111110 binary
rshomberg 9:da0b72918880 37 case 9 : SegByte= 0x6F;break; // 11011110 binary
rshomberg 9:da0b72918880 38 }
rshomberg 9:da0b72918880 39 return ~SegByte;
rshomberg 9:da0b72918880 40 }