TVZ2022 / SegDispLib
Committer:
apetrovic
Date:
Tue Nov 29 19:14:08 2022 +0000
Revision:
0:7e3c26a81f6c
SegDispLib

Who changed what in which revision?

UserRevisionLine numberNew contents of line
apetrovic 0:7e3c26a81f6c 1 #include "segdisp.h"
apetrovic 0:7e3c26a81f6c 2
apetrovic 0:7e3c26a81f6c 3 BusOut Segmentni (PB_4,PB_10,PA_8,PA_9,PC_7,PB_6,PA_7,PA_6); // A,B,C,D,E,F,G,DP
apetrovic 0:7e3c26a81f6c 4
apetrovic 0:7e3c26a81f6c 5 void SegInit(void)
apetrovic 0:7e3c26a81f6c 6 {
apetrovic 0:7e3c26a81f6c 7 Segmentni= Segmentniprikaz (0); //Inicijalizacija
apetrovic 0:7e3c26a81f6c 8 }
apetrovic 0:7e3c26a81f6c 9
apetrovic 0:7e3c26a81f6c 10 char Segmentniprikaz(int SegValue) //funkcija za konverziju int varijable u niz bitova za ispis na 7 seg displayu
apetrovic 0:7e3c26a81f6c 11
apetrovic 0:7e3c26a81f6c 12 {
apetrovic 0:7e3c26a81f6c 13 char SegByte=0x00;
apetrovic 0:7e3c26a81f6c 14 switch (SegValue) { //DP G F E D C B A
apetrovic 0:7e3c26a81f6c 15 case 0 :
apetrovic 0:7e3c26a81f6c 16 SegByte = 0x3F;
apetrovic 0:7e3c26a81f6c 17 break; // 0 0 1 1 1 1 1 1 binary
apetrovic 0:7e3c26a81f6c 18 case 1 :
apetrovic 0:7e3c26a81f6c 19 SegByte = 0x06;
apetrovic 0:7e3c26a81f6c 20 break; // 0 0 0 0 0 1 1 0 binary
apetrovic 0:7e3c26a81f6c 21 case 2 :
apetrovic 0:7e3c26a81f6c 22 SegByte = 0x5B;
apetrovic 0:7e3c26a81f6c 23 break; // 0 1 0 1 1 0 1 1 binary
apetrovic 0:7e3c26a81f6c 24 case 3 :
apetrovic 0:7e3c26a81f6c 25 SegByte = 0x4F;
apetrovic 0:7e3c26a81f6c 26 break; // 0 1 0 0 1 1 1 1 binary
apetrovic 0:7e3c26a81f6c 27 case 4 :
apetrovic 0:7e3c26a81f6c 28 SegByte = 0x66;
apetrovic 0:7e3c26a81f6c 29 break; // 0 1 1 0 0 1 1 0 binary
apetrovic 0:7e3c26a81f6c 30 case 5 :
apetrovic 0:7e3c26a81f6c 31 SegByte = 0x6D;
apetrovic 0:7e3c26a81f6c 32 break; // 0 1 1 0 1 1 0 1 binary
apetrovic 0:7e3c26a81f6c 33 case 6 :
apetrovic 0:7e3c26a81f6c 34 SegByte = 0x7D;
apetrovic 0:7e3c26a81f6c 35 break; // 0 1 1 1 1 1 0 1 binary
apetrovic 0:7e3c26a81f6c 36 case 7 :
apetrovic 0:7e3c26a81f6c 37 SegByte = 0x07;
apetrovic 0:7e3c26a81f6c 38 break; // 0 0 0 0 0 1 1 1 binary
apetrovic 0:7e3c26a81f6c 39 case 8 :
apetrovic 0:7e3c26a81f6c 40 SegByte = 0x7F;
apetrovic 0:7e3c26a81f6c 41 break; // 0 1 1 1 1 1 1 1 binary
apetrovic 0:7e3c26a81f6c 42 case 9 :
apetrovic 0:7e3c26a81f6c 43 SegByte = 0x6F;
apetrovic 0:7e3c26a81f6c 44 break; // 0 1 1 0 1 1 1 1 binary
apetrovic 0:7e3c26a81f6c 45 case 10 :
apetrovic 0:7e3c26a81f6c 46 SegByte = 0x71;
apetrovic 0:7e3c26a81f6c 47 break; // 1 0 0 0 0 0 0 0 binary
apetrovic 0:7e3c26a81f6c 48
apetrovic 0:7e3c26a81f6c 49 case 12:
apetrovic 0:7e3c26a81f6c 50 SegByte = 0xFF;
apetrovic 0:7e3c26a81f6c 51 break;
apetrovic 0:7e3c26a81f6c 52 }
apetrovic 0:7e3c26a81f6c 53 return SegByte;
apetrovic 0:7e3c26a81f6c 54 }
apetrovic 0:7e3c26a81f6c 55