TVZ2022 / SegDispLib

Files at this revision

API Documentation at this revision

Comitter:
apetrovic
Date:
Tue Nov 29 19:14:08 2022 +0000
Commit message:
SegDispLib

Changed in this revision

segdisp.cpp Show annotated file Show diff for this revision Revisions of this file
segdisp.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/segdisp.cpp	Tue Nov 29 19:14:08 2022 +0000
@@ -0,0 +1,55 @@
+#include "segdisp.h"
+
+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
+
+void SegInit(void)
+{
+    Segmentni= Segmentniprikaz (0); //Inicijalizacija
+}
+
+char Segmentniprikaz(int SegValue)   //funkcija za konverziju int varijable u niz bitova za ispis na 7 seg displayu
+
+{
+    char SegByte=0x00;
+    switch (SegValue) { //DP G F E D C B A
+        case 0 :
+            SegByte = 0x3F;
+            break; // 0 0 1 1 1 1 1 1 binary
+        case 1 :
+            SegByte = 0x06;
+            break; // 0 0 0 0 0 1 1 0 binary
+        case 2 :
+            SegByte = 0x5B;
+            break; // 0 1 0 1 1 0 1 1 binary
+        case 3 :
+            SegByte = 0x4F;
+            break; // 0 1 0 0 1 1 1 1 binary
+        case 4 :
+            SegByte = 0x66;
+            break; // 0 1 1 0 0 1 1 0 binary
+        case 5 :
+            SegByte = 0x6D;
+            break; // 0 1 1 0 1 1 0 1 binary
+        case 6 :
+            SegByte = 0x7D;
+            break; // 0 1 1 1 1 1 0 1 binary
+        case 7 :
+            SegByte = 0x07;
+            break; // 0 0 0 0 0 1 1 1 binary
+        case 8 :
+            SegByte = 0x7F;
+            break; // 0 1 1 1 1 1 1 1 binary
+        case 9 :
+            SegByte = 0x6F;
+            break; // 0 1 1 0 1 1 1 1 binary
+        case 10 :
+            SegByte = 0x71;
+            break; // 1 0 0 0 0 0 0 0 binary
+      
+        case 12: 
+            SegByte = 0xFF;
+            break;
+    }
+    return SegByte;
+}
+        
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/segdisp.h	Tue Nov 29 19:14:08 2022 +0000
@@ -0,0 +1,12 @@
+#ifndef SEGDISPLAY_H
+#define SEGDISPLAY_H
+
+#include "mbed.h"
+
+extern BusOut Segmentni; //dozvoljava da se "Segmentni" koriste i druge datoteke
+
+void SegInit(void); 
+
+char Segmentniprikaz(int SegValue);
+
+#endif