-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
81 lines (70 loc) · 1.91 KB
/
main.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include"mbed.h"
DigitalOut clk(p27); //clock pin
DigitalOut rst(p28); //Reset|Clear pin
DigitalOut data(p30); //Data pin
void EdgeClock(){ //This is the function where we sync the clock with data
wait(0.000001);
clk = 1;
wait(0.000001);
clk=0;
}
int main(){
rst = 0; //Reset is set to 0, ready to take data
EdgeClock(); //Clock sequence
rst = 1; //reset
EdgeClock(); //Clock sequence
// We are using negative logic!
// segment labels: {d,g,f,e,d,c,b,a}
int arr[16][8] = {
{1,1,0,0,0,0,0,0}, //0
{1,1,1,1,1,0,0,1}, //1
{1,0,1,0,0,1,0,0}, //2
{1,0,1,1,0,0,0,0}, //3
{1,0,0,1,1,0,0,1}, //4
{1,0,0,1,0,0,1,0}, //5
{1,0,0,0,0,0,1,0}, //6
{1,1,1,1,1,0,0,0}, //7
{1,0,0,0,0,0,0,0}, //8
{1,0,0,1,1,0,0,0}, //9
{1,0,0,0,1,0,0,0}, //A
{1,0,0,0,0,0,1,1}, //B
{1,1,0,0,0,1,1,0}, //C
{1,0,1,0,0,0,0,1}, //D
{1,0,0,0,0,1,1,0}, //E
{1,0,0,0,1,1,1,0}}; //F
//{0,1,1,1,1,1,1,1}}; //dot
// We are displaying the decimal point last
int dot[2][8] = {{0,1,1,1,1,1,1,1}, //dot ON
{1,1,1,1,1,1,1,1}}; //dot OFF
// Execute while logic=1
while(1){
for (int a = 0; a < 16; a++){ //Loop going through the rows
for(int i = 0; i < 16; i++){ //Loop going through columns
for (int j = 0; j < 8 ; j++) { //Here we add data to grid
data = arr[i][j];
EdgeClock();
}
for (int j = 0; j < 8 ; j++) {
data = arr[a][j];
EdgeClock();
}
wait(0.05);
}// end for
}
//Blink dots protocal
for (int a = 1; a >= 0 ; a--){
for (int b = 0; b < 8; b++){
data = dot[a][b];
EdgeClock();
}
}
wait(0.25);
for (int a = 0; a < 2 ; a++){
for (int b = 0; b < 8; b++){
data = dot[a][b];
EdgeClock();
}
}
wait(0.25);
}//end while
}//end main