Russell Shomberg
/
shomberg_hw_6
HW6 for OCE560
Fork of shomberg_hw_5 by
Diff: SegDisplay.cpp
- Revision:
- 9:da0b72918880
- Child:
- 11:42914083ac70
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SegDisplay.cpp Thu Oct 25 18:12:33 2018 +0000 @@ -0,0 +1,40 @@ +/** + Temperature Sensor for hw6 + SegDisplay.cpp + + Purpose: Convert an integer value to a hex + Hex output represents binary required to make a 7-seg led show the integer value + Pin configuration for 7-Seg + ones: 12 13 14 15 16 17 18 19 + A B C D E F G P + tens: 21 22 23 24 25 26 27 28 + + @author Russell Shomberg + @created 2018-10-23 + @revised 2018-10-25 + @version 0.0 + + Issues: No Decimal point for temperature + +*/ + +// INCLUDES +#include "mbed.h" +#include "SegDisplay.h" + +char SegConvert(int SegValue) { // function 'SegConvert' + char SegByte=0x00; + switch (abs(SegValue)) { // ABCDEFGP + case 0 : SegByte= 0x3F;break; // 11111100 binary + case 1 : SegByte= 0x06;break; // 01100000 binary + case 2 : SegByte= 0x5B;break; // 11110110 binary + case 3 : SegByte= 0x4F;break; // 10011110 binary + case 4 : SegByte= 0x66;break; // 11001100 binary + case 5 : SegByte= 0x6D;break; // 11011010 binary + case 6 : SegByte= 0x7D;break; // 11111010 binary + case 7 : SegByte= 0x07;break; // 00001110 binary + case 8 : SegByte= 0x7F;break; // 11111110 binary + case 9 : SegByte= 0x6F;break; // 11011110 binary + } + return ~SegByte; +} \ No newline at end of file