Russell Shomberg
/
shomberg_hw_6
HW6 for OCE560
Fork of shomberg_hw_5 by
SegDisplay.cpp@11:42914083ac70, 2018-10-25 (annotated)
- Committer:
- rshomberg
- Date:
- Thu Oct 25 18:58:41 2018 +0000
- Revision:
- 11:42914083ac70
- Parent:
- 9:da0b72918880
- Child:
- 12:ea407dcaff78
compiles, but using extern
Who changed what in which revision?
User | Revision | Line number | New 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 | 11:42914083ac70 | 25 | BusOut Seg1(p12,p13,p14,p15,p16,p17,p18,p19); //01 02 03 04 05 06 07 08 09 10 |
rshomberg | 11:42914083ac70 | 26 | BusOut Seg2(p21,p22,p23,p24,p25,p26,p27,p28); //E D CC C DP B A CC F G |
rshomberg | 11:42914083ac70 | 27 | |
rshomberg | 9:da0b72918880 | 28 | char SegConvert(int SegValue) { // function 'SegConvert' |
rshomberg | 9:da0b72918880 | 29 | char SegByte=0x00; |
rshomberg | 9:da0b72918880 | 30 | switch (abs(SegValue)) { // ABCDEFGP |
rshomberg | 9:da0b72918880 | 31 | case 0 : SegByte= 0x3F;break; // 11111100 binary |
rshomberg | 9:da0b72918880 | 32 | case 1 : SegByte= 0x06;break; // 01100000 binary |
rshomberg | 9:da0b72918880 | 33 | case 2 : SegByte= 0x5B;break; // 11110110 binary |
rshomberg | 9:da0b72918880 | 34 | case 3 : SegByte= 0x4F;break; // 10011110 binary |
rshomberg | 9:da0b72918880 | 35 | case 4 : SegByte= 0x66;break; // 11001100 binary |
rshomberg | 9:da0b72918880 | 36 | case 5 : SegByte= 0x6D;break; // 11011010 binary |
rshomberg | 9:da0b72918880 | 37 | case 6 : SegByte= 0x7D;break; // 11111010 binary |
rshomberg | 9:da0b72918880 | 38 | case 7 : SegByte= 0x07;break; // 00001110 binary |
rshomberg | 9:da0b72918880 | 39 | case 8 : SegByte= 0x7F;break; // 11111110 binary |
rshomberg | 9:da0b72918880 | 40 | case 9 : SegByte= 0x6F;break; // 11011110 binary |
rshomberg | 9:da0b72918880 | 41 | } |
rshomberg | 9:da0b72918880 | 42 | return ~SegByte; |
rshomberg | 9:da0b72918880 | 43 | } |