ddad

Dependencies:   mbed

Fork of class_7segment_serial by tatiuc embedded

Files at this revision

API Documentation at this revision

Comitter:
mijimy
Date:
Tue Jun 06 10:00:51 2017 +0000
Parent:
1:65d57cc8cb22
Commit message:
sdsfsgdf

Changed in this revision

HostIO.cpp Show annotated file Show diff for this revision Revisions of this file
HostIO.h 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
SegDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HostIO.cpp	Tue Jun 06 10:00:51 2017 +0000
@@ -0,0 +1,12 @@
+#include "HostIO.h"
+
+
+void HostInit(void) {
+pc.printf("\n\rType two digit numbers to be displayed on the 7-seg display\n\r");
+}
+
+char GetKeyInput(void) {
+char c = pc.getc(); // get keyboard data (note numerical ascii range 0x30-0x39)
+pc.printf("%c",c); // print ascii value to host PC terminal
+return (c&0x0F); // return value as non-ascii (bitmask c with value 0x0F)
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HostIO.h	Tue Jun 06 10:00:51 2017 +0000
@@ -0,0 +1,9 @@
+#ifndef HOSTIO_H
+#define HOSTIO_H
+#include "mbed.h"
+
+void HostInit(void); // function prototype
+char GetKeyInput(void); // function prototype
+extern Serial pc;
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SegDisp.h	Tue Jun 06 10:00:51 2017 +0000
@@ -0,0 +1,11 @@
+#ifndef SEGDISP_H
+#define SEGDISP_H
+#include "mbed.h"
+
+char SegConvert(char SegValue); // functionprototype
+
+void SegInit(void); // function prototype
+extern BusOut Seg1;
+extern BusOut Seg2;
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SegDisplay.cpp	Tue Jun 06 10:00:51 2017 +0000
@@ -0,0 +1,24 @@
+#include "SegDisp.h"
+
+
+char SegConvert(char SegValue) { // function 'SegConvert'
+char SegByte=0x00;
+switch (SegValue) { //DPGFEDCBA
+case 0 : SegByte = 0x3F;break; // 00111111 binary
+case 1 : SegByte = 0x06;break; // 00000110 binary
+case 2 : SegByte = 0x5B;break; // 01011011 binary
+case 3 : SegByte = 0x4F;break; // 01001111 binary
+case 4 : SegByte = 0x66;break; // 01100110 binary
+case 5 : SegByte = 0x6D;break; // 01101101 binary
+case 6 : SegByte = 0x7D;break; // 01111101 binary
+case 7 : SegByte = 0x07;break; // 00000111 binary
+case 8 : SegByte = 0x7F;break; // 01111111 binary
+case 9 : SegByte = 0x6F;break; // 01101111 binary
+   }
+    return SegByte;
+}
+
+void SegInit(void) {
+Seg1=SegConvert(0); // initialise to zero
+Seg2=SegConvert(0); // initialise to zero
+}
--- a/main.cpp	Tue Jun 06 09:26:52 2017 +0000
+++ b/main.cpp	Tue Jun 06 10:00:51 2017 +0000
@@ -1,12 +1,9 @@
 #include "mbed.h"
+#include "HostIO.h"
+#include "SegDisp.h"
 Serial pc(USBTX, USBRX);
 BusOut Seg1(PC_9,PC_8,PB_8,PC_6,PB_9,PC_5,PA_5,PA_12);// A,B,C,D,E,F,G,DP
 BusOut Seg2(PA_8,PB_1,PB_10,PB_15,PB_4,PB_14,PB_5,PB_13);// A,B,C,D,E,F,G,DP
-char SegConvert(char SegValue); // functionprototype
-
-void SegInit(void); // function prototype
-void HostInit(void); // function prototype
-char GetKeyInput(void); // function prototype
 char data1, data2; // variable declarations
 
 int main() 
@@ -22,35 +19,3 @@
             pc.printf(" "); // display spaces between 2 digit numbers
         }
 }
-
-char SegConvert(char SegValue) { // function 'SegConvert'
-char SegByte=0x00;
-switch (SegValue) { //DPGFEDCBA
-case 0 : SegByte = 0x3F;break; // 00111111 binary
-case 1 : SegByte = 0x06;break; // 00000110 binary
-case 2 : SegByte = 0x5B;break; // 01011011 binary
-case 3 : SegByte = 0x4F;break; // 01001111 binary
-case 4 : SegByte = 0x66;break; // 01100110 binary
-case 5 : SegByte = 0x6D;break; // 01101101 binary
-case 6 : SegByte = 0x7D;break; // 01111101 binary
-case 7 : SegByte = 0x07;break; // 00000111 binary
-case 8 : SegByte = 0x7F;break; // 01111111 binary
-case 9 : SegByte = 0x6F;break; // 01101111 binary
-   }
-    return SegByte;
-}
-
-void SegInit(void) {
-Seg1=SegConvert(0); // initialise to zero
-Seg2=SegConvert(0); // initialise to zero
-}
-
-void HostInit(void) {
-pc.printf("\n\rType two digit numbers to be displayed on the 7-seg display\n\r");
-}
-
-char GetKeyInput(void) {
-char c = pc.getc(); // get keyboard data (note numerical ascii range 0x30-0x39)
-pc.printf("%c",c); // print ascii value to host PC terminal
-return (c&0x0F); // return value as non-ascii (bitmask c with value 0x0F)
-}
\ No newline at end of file