-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodes.cc
231 lines (201 loc) · 5.85 KB
/
Codes.cc
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#include <iostream>
#include <stdlib.h>
#include "mbed.h"
#include <stdio.h>
#include <time.h>
#include "C12832.h"
#include "Sht31.h"
int button;
bool check;
int p;
int c=0;
C12832 lcd(SPI_MOSI, SPI_SCK, SPI_MISO, p8, p11);
Sht31 sht31(I2C_SDA, I2C_SCL);
DigitalOut green(p20);
DigitalOut white(p21);
DigitalOut red(p22);
Ticker t1;
Timeout t2;
InterruptIn btn(BUTTON1);
InterruptIn reversebtn(p24);
int i, s,f,l;
void starting(){
lcd.locate(30, 0);
lcd.printf("WELCOME TO");
lcd.locate(10, 10);
lcd.printf("IOT Based Disaster");
lcd.locate(3, 20);
lcd.printf(" Prediction And Monitoring");
wait(5);
lcd.cls();
}
void topics(){
check= true;
for (i = -5; i <25 ; i++) { // scrolling text
lcd.locate(3, i);
lcd.printf("TOPIC_1: Lightnings");
wait(0.2);
lcd.cls();
i = i + 1;
white=!white;
p=1;
}
for (i = -5; i <25 ; i++) { // scrolling text
lcd.locate(10, i);
lcd.printf("TOPIC_2: Floods");
wait(0.2);
lcd.cls();
i = i + 1;
white=!white;
p=2;
}
for (i = -5; i <25 ; i++) { // scrolling text
lcd.locate(10, i);
lcd.printf("TOPIC_3: Landslides");
wait(0.2);
lcd.cls();
i = i + 1;
white=!white;
p=3;
}
for (i = -5; i <25 ; i++) { // scrolling text
lcd.locate(10, i);
lcd.printf("TOPIC_4: Volcano Eruption");
wait(0.2);
lcd.cls();
i = i + 1;
white=!white;
p=4;
}
for (i = -5; i <25 ; i++) { // scrolling text
lcd.locate(10, i);
lcd.printf("TOPIC_5: Earthquakes");
wait(0.2);
lcd.cls();
i = i + 1;
white=!white;
p=5;
}
}
void temp_local_time(){
check=true; p=4;
time_t rawtime;
struct tm *info;
float temp = sht31.readTemperature();
lcd.set_auto_up(0);
time( &rawtime );
info = localtime( &rawtime );
// printf("Current local time and date: %s", asctime(info));
lcd.locate(2, 3);
lcd.printf(" %s", asctime(info));
lcd.locate(5, 15);
lcd.printf("Local Temperature: %.2fC ", temp);
wait(3);
lcd.cls();
white=!white;
}
void reading(){
if(check==true and (p==1 or p==4)){
printf("content\n");
printf("............................................\n");
printf("Lightning is an electrical discharge btwn cloud and ground\n");
printf("There are three common types of lightning: cloud to ground\n");
printf("cloud to cloud and cloud to air. Cloud to ground lightning is the most dangerous\n");
printf("Karongi Site Lightning: 123KV\n");
printf("Status: LOW\n");
printf("Kirehe Site Lightning: 501.2KV\n");
printf("Status: HIGH\n");
printf("..................\t\t.....................\n");
p=0;
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n");
green=1;
}
if(check==true and p==2){
printf("content\n");
printf("............................................\n");
printf("Flood is an overflow of water that submerges land that is usually dry\n");
printf("Floods are an area of study in the discipline of hydrology");
printf("Burera Site Floods level: 38.9mm\n");
printf("Status: HIGH\n");
printf("Karongi Site Floods level: 88.9mm\n");
printf("Status: Very HIGH\n");
printf("..................\t\t.....................\n");
p=0;
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
green=1;
}
if(check==true and p==3){
printf("content\n");
printf("............................................\n");
printf("Landslide, the movement downslope of a mass of rock, debris, earth, or soil\n");
printf("Hazard level at Rulindo:60/100\n");
printf("Status:Intermediate\n");
printf("Hazard level at Rubavu:40/100\n");
printf("Status:LOW\n");
printf("..................\t\t.....................\n");
p=0;
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
green=1;
}
if(check==true and p==4){
printf("content\n");
printf("............................................\n");
printf("Volcanic eruptions happen when lava and gas are discharged from a volcanic vent.\n");
printf("Volcanic eruptions often cause temporary food shortages and volcanic ash landslides called Laharn");
printf("Mount Nyiragongo erupted in the Democratic Republic of Congo on May 22\n");
printf("killed 31 people and forcing 30,000 to flee their homes\n");
printf("Volcanic Alert Level:4\n");
printf("..................\t\t.....................\n");
p=0;
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
green=1;
}
if(check==true and p==5){
printf("content\n");
printf("............................................\n");
printf("An earthquake is the shaking of the surface of the Earth resulting from a sudden release of\n");
printf("energy in the Earth's lithosphere that creates seismic waves.\n");
printf("Earthquake occured at Rubavu:40/100\n");
printf("Slight damage to buildings and other structures.\n");
printf("Status: 7.0 earthquake");
printf("..................\t\t.....................\n");
p=0;
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
green=1;
}
}
int main () {
startup:
printf("\t\t****Press Button To Read****\n");
printf("\n");
btn.rise(callback(&reading));
starting();
while (1){
temp_local_time();
wait_ms(0.2);
topics();
button=btn;
if(button==1){
lcd.cls();
lcd.locate(5, 15);
lcd.printf("hello");
}
wait_ms(1);
int reversecount=reversebtn;
if(reversecount==1){
c=c+1;
printf("count is:%d\n",c);
if(c==3){
printf("Direction changed");
}
if(c==5){
printf("Resert to factory");
c=0;
red=!red;
wait(10);
goto startup;
}
}
wait(1);
}
}