diff options
Diffstat (limited to '')
-rw-r--r-- | Lab3.X/display.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Lab3.X/display.c b/Lab3.X/display.c new file mode 100644 index 0000000..2c2fd1f --- /dev/null +++ b/Lab3.X/display.c @@ -0,0 +1,72 @@ +#include "xc.h"
+#include "display.h"
+//Functions used for Display
+
+
+void delay(long num) {
+ long i;
+ for (i; i < num; i++) {
+ asm("nop");
+ }
+}
+void init7seg(void) {
+ TRISB = 0b0000000000000011; //and port B to outputs
+ LATB = 0x0000; //and all of port B to LOW
+}
+void showChar7seg(char myChar, enum DIGIT myDigit) {
+ LATB &= 0x00;
+ switch (myChar) {
+ case '0':
+ LATB ^= (0b11 << 2);
+ break;
+ case '1':
+ LATB ^= (0b10011111 << 2);
+ break;
+ case '2':
+ LATB ^= (0b00100101 << 2);
+ break;
+ case '3':
+ LATB ^= (0b1101 << 2);
+ break;
+ case '4':
+ LATB ^= (0b10011001 << 2);
+ break;
+ case '5':
+ LATB ^= (0b1001001 << 2);
+ break;
+ case '6':
+ LATB ^= (0b1000001 << 2);
+ break;
+ case '7':
+ LATB ^= (0b11111 << 2);
+ break;
+ case '8':
+ LATB ^= (0b1 << 2);
+ break;
+ case '9':
+ LATB ^= (0b1001 << 2);
+ break;
+ case 'A':
+ LATB ^= (0b10001 << 2);
+ break;
+ case 'b':
+ LATB ^= (0b11000001 << 2);
+ break;
+ case 'C':
+ LATB ^= (0b01100011 << 2);
+ break;
+ case 'd':
+ LATB ^= (0b10000101 << 2);
+ break;
+ case 'E':
+ LATB ^= (0b01100001 << 2);
+ break;
+ case 'F':
+ LATB ^= (0b01110001 << 2);
+ break;
+ default:
+ LATB ^= (0b1010001 << 2);
+ break;
+ } //END OF SWITCH
+ LATB |= myDigit;
+}
\ No newline at end of file |