librerija za cetvero segmentni displej
Revision 0:9c0145823064, committed 2022-05-04
- Comitter:
- IsusKrist
- Date:
- Wed May 04 15:40:54 2022 +0000
- Commit message:
- Librerija za cetvero segmentni displej
Changed in this revision
Displej.cpp | Show annotated file Show diff for this revision Revisions of this file |
Displej.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 9c0145823064 Displej.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Displej.cpp Wed May 04 15:40:54 2022 +0000 @@ -0,0 +1,34 @@ +#include "Displej.h" + +BusOut LSegment(D11,D10,D9,D8,D7,D6,D5,D4); +BusOut QSegment(D15,D14,D13,D12); + +char SegConvert(int broj,int znamenka) { + int c[2]; + char SegByte=0x00; + + if(broj>9){ + for(int i=0;i<2;i++){ + c[i]=broj%10; + broj/=10; + } + }else{ + c[znamenka]=znamenka==1?0:broj; + } + + switch(c[znamenka]) { + case 0 : SegByte = 0xC0;break; + case 1 : SegByte = 0xF9;break; + case 2 : SegByte = 0xA4;break; + case 3 : SegByte = 0xB0;break; + case 4 : SegByte = 0x99;break; + case 5 : SegByte = 0x92;break; + case 6 : SegByte = 0x82;break; + case 7 : SegByte = 0xF8;break; + case 8 : SegByte = 0x80;break; + case 9 : SegByte = 0x90;break; + case -1 : SegByte = 0x7F;break; + + } + return SegByte; +}
diff -r 000000000000 -r 9c0145823064 Displej.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Displej.h Wed May 04 15:40:54 2022 +0000 @@ -0,0 +1,7 @@ +#ifndef DISPLEJ_H +#define DISPLEJ_H +#include "mbed.h" +extern BusOut LSegment; +extern BusOut QSegment; +char SegConvert(int broj,int znamenka); +#endif