-
Notifications
You must be signed in to change notification settings - Fork 0
/
subhashini.ino
145 lines (119 loc) · 5.37 KB
/
subhashini.ino
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
#include <LCDWIKI_GUI.h> // Core graphics library
#include <LCDWIKI_KBV.h> // Hardware-specific library
#include "DHT.h"
LCDWIKI_KBV mylcd(ILI9486, A3, A2, A1, A0, A4); // Model, CS, CD, WR, RD, Reset
#define BLACK 0x0000
#define WHITE 0xFFFF
#define GREEN 0x0FF0
const char* slokas[] = {
"Sathyameveshware loke\nsathyam padmashritha sadaa\nSathyamulaani sarvani\nsathyannasthi param padam",
"Kimapyasthi swabhaavena\nsundaram vaapyasundaram\nYadeva rochathe yasmai\nthadbavethasya sundaram",
"Krodhaha prithim pranashayathi\nmaano vinayanaashanaha\nMaaya mithrani naashayathi\nmobhaha sarvavinaashanaha",
"Gopaayitharam daathaaram\ndamanithyamathandritham\nAkaamadweshasamyuktha\nmanurajyanthi maanavaha",
"Sarva paravasham dukham\nsarva athmavasham sukham\nYethadwidyaathsamasena\nlakshanam sukhadukhayoho",
"Loke kulam kulam\nthaavadyavathpurvasamanvayaha\nGunaprabhave vichinne\nsamaaptham sakalam kulam"
};
const char* subhashithas[] = {
"Pruthvivyam thrini rathnani\njalam annam subhashitham\nmudeihi paashanakhandeshu\nrathnasajnaa pradiyathe",
"Himalayaam samaarabya\nyaavath indu sarovaram\ntham devanirmitham desham\nhindustanam prachakshathe",
"Ayam nijaha paro vethi\ngananaa laguchethasaam\nudaaracharithanam thu\ndusudeiva kutumbakam",
"Astadashapuranaanam saaram\nvyasena karthikam\nparopakaraha punyayaha\npaapaaya paripidanam",
"Ashwasya bhushanam vegoo\nmatham syad gajabhudshanam\nchathuryam bhushanam naaya\nudyoge narabhushanam",
"Na abhisheko na samsaraha\nsimhasya kriyathe vane\nvikramarjithasathvasya\nswayameva mrugedratha",
};
const int SlokaButtonPin = 53; // Digital pin to connect the button for slokas
const int SubhashithaButtonPin = 52; // Digital pin to connect the button for subhashithas
int currentSlokaIndex = 0; // Tracks the currently displayed sloka
int currentSubhashithaIndex = 0; // Tracks the currently displayed subhashitha
const int SensorButtonPin = 51;
DHT dht(50, DHT22);
void setup() {
Serial.begin(9600);
mylcd.Init_LCD();
mylcd.Set_Rotation(3); // Rotate display to landscape mode
Serial.println(mylcd.Read_ID(), HEX);
for (int progress = 0; progress <= 100; progress += 10) {
drawLoadingScreen(progress);
delay(200);
}
pinMode(SlokaButtonPin, INPUT_PULLUP); // Set the button pin for slokas as an input with a pull-up resistor
pinMode(SubhashithaButtonPin, INPUT_PULLUP); // Set the button pin for subhashithas as an input with a pull-up resistor
drawHomeScreen();
pinMode(SensorButtonPin, INPUT_PULLUP); // Set the button pin for sensor readings as an input with a pull-up resistor
dht.begin(); // Initialize the DHT sensor
}
void drawLoadingScreen(int progress) {
mylcd.Set_Text_Mode(0);
mylcd.Set_Text_Size(3);
mylcd.Set_Text_colour(BLACK);
mylcd.Set_Text_Back_colour(WHITE);
mylcd.Fill_Screen(WHITE);
mylcd.Print_String("Loading...", 50, 100);
// Draw a black progress bar
int barX = 50;
int barY = 150;
int barWidth = 220;
int barHeight = 20;
mylcd.Set_Draw_color(BLACK);
mylcd.Fill_Rectangle(barX, barY, barX + barWidth, barY + barHeight);
// Fill the progress bar based on the given progress
int fillWidth = map(progress, 0, 100, 0, barWidth);
mylcd.Set_Draw_color(GREEN);
mylcd.Fill_Rectangle(barX, barY, barX + fillWidth, barY + barHeight);
}
void drawHomeScreen() {
mylcd.Set_Text_Mode(0);
mylcd.Set_Text_Size(2);
mylcd.Set_Text_colour(BLACK);
mylcd.Set_Text_Back_colour(WHITE);
mylcd.Fill_Screen(WHITE);
mylcd.Set_Text_Size(3);
mylcd.Print_String("I am Subhashini", 80, 100);
mylcd.Set_Text_Size(2); // Set a larger text size
mylcd.Print_String("Made by Sanskrit Department", 80, 200);
mylcd.Set_Text_Size(2); // Set a larger text size
mylcd.Print_String("KSS College Subrahmanya.", 80, 250);
}
void displaySloka(const char* sloka) {
mylcd.Print_String(sloka, 50, 100);
}
void displaySensorData(float temperature, float humidity) {
mylcd.Set_Text_Mode(0);
mylcd.Set_Text_Size(2);
mylcd.Set_Text_colour(BLACK);
mylcd.Set_Text_Back_colour(WHITE);
mylcd.Print_String("Temperature: " + String(temperature, 1) + " C", 50, 100);
mylcd.Print_String("Humidity: " + String(humidity, 1) + " %", 50, 150);
}
void displaySubhashitha(const char* subhashitha) {
mylcd.Print_String(subhashitha, 50, 100);
}
void loop() {
// Check the button state for slokas
if (digitalRead(SlokaButtonPin) == LOW) {
mylcd.Set_Text_Size(3);
mylcd.Fill_Screen(WHITE); // Replace WHITE with the desired background color
currentSlokaIndex = (currentSlokaIndex + 1) % (sizeof(slokas) / sizeof(slokas[0]));
delay(200); // Debounce the button
displaySloka(slokas[currentSlokaIndex]);
delay(3000);
}
// Check the button state for subhashithas
if (digitalRead(SubhashithaButtonPin) == LOW) {
mylcd.Set_Text_Size(3);
currentSubhashithaIndex = (currentSubhashithaIndex + 1) % (sizeof(subhashithas) / sizeof(subhashithas[0]));
delay(200); // Debounce the button
displaySubhashitha(subhashithas[currentSubhashithaIndex]);
delay(3000);
}
if (digitalRead(SensorButtonPin) == LOW) {
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
drawHomeScreen(); // Clear the screen
displaySensorData(temperature, humidity); // Display temperature and humidity data
delay(5000); // Display the data for 5 seconds
drawHomeScreen(); // Clear the screen again
}
// Delay to avoid rapid changes when the buttons are held down
delay(500);
}