librerija za cetvero segmentni displej
Displej.cpp@0:9c0145823064, 2022-05-04 (annotated)
- Committer:
- IsusKrist
- Date:
- Wed May 04 15:40:54 2022 +0000
- Revision:
- 0:9c0145823064
Librerija za cetvero segmentni displej
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IsusKrist | 0:9c0145823064 | 1 | #include "Displej.h" |
IsusKrist | 0:9c0145823064 | 2 | |
IsusKrist | 0:9c0145823064 | 3 | BusOut LSegment(D11,D10,D9,D8,D7,D6,D5,D4); |
IsusKrist | 0:9c0145823064 | 4 | BusOut QSegment(D15,D14,D13,D12); |
IsusKrist | 0:9c0145823064 | 5 | |
IsusKrist | 0:9c0145823064 | 6 | char SegConvert(int broj,int znamenka) { |
IsusKrist | 0:9c0145823064 | 7 | int c[2]; |
IsusKrist | 0:9c0145823064 | 8 | char SegByte=0x00; |
IsusKrist | 0:9c0145823064 | 9 | |
IsusKrist | 0:9c0145823064 | 10 | if(broj>9){ |
IsusKrist | 0:9c0145823064 | 11 | for(int i=0;i<2;i++){ |
IsusKrist | 0:9c0145823064 | 12 | c[i]=broj%10; |
IsusKrist | 0:9c0145823064 | 13 | broj/=10; |
IsusKrist | 0:9c0145823064 | 14 | } |
IsusKrist | 0:9c0145823064 | 15 | }else{ |
IsusKrist | 0:9c0145823064 | 16 | c[znamenka]=znamenka==1?0:broj; |
IsusKrist | 0:9c0145823064 | 17 | } |
IsusKrist | 0:9c0145823064 | 18 | |
IsusKrist | 0:9c0145823064 | 19 | switch(c[znamenka]) { |
IsusKrist | 0:9c0145823064 | 20 | case 0 : SegByte = 0xC0;break; |
IsusKrist | 0:9c0145823064 | 21 | case 1 : SegByte = 0xF9;break; |
IsusKrist | 0:9c0145823064 | 22 | case 2 : SegByte = 0xA4;break; |
IsusKrist | 0:9c0145823064 | 23 | case 3 : SegByte = 0xB0;break; |
IsusKrist | 0:9c0145823064 | 24 | case 4 : SegByte = 0x99;break; |
IsusKrist | 0:9c0145823064 | 25 | case 5 : SegByte = 0x92;break; |
IsusKrist | 0:9c0145823064 | 26 | case 6 : SegByte = 0x82;break; |
IsusKrist | 0:9c0145823064 | 27 | case 7 : SegByte = 0xF8;break; |
IsusKrist | 0:9c0145823064 | 28 | case 8 : SegByte = 0x80;break; |
IsusKrist | 0:9c0145823064 | 29 | case 9 : SegByte = 0x90;break; |
IsusKrist | 0:9c0145823064 | 30 | case -1 : SegByte = 0x7F;break; |
IsusKrist | 0:9c0145823064 | 31 | |
IsusKrist | 0:9c0145823064 | 32 | } |
IsusKrist | 0:9c0145823064 | 33 | return SegByte; |
IsusKrist | 0:9c0145823064 | 34 | } |