aboutsummaryrefslogtreecommitdiffstats
path: root/Lab3.X/display.c
blob: 5ad9c4f193ce54e977998ebcae83686c7cbd1135 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "xc.h"
#include "display.h"
//Functions used for Display

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 ^= (0b11111111 << 2);
            break;
    }   //END OF SWITCH
    LATB |= myDigit;
}