#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <Wire.h>
//define OLED screen width and height
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
//define OLED display I2C address
#define OLED_I2C_ADDRESS 0x3C
//set display screen size and I2C address
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_I2C_ADDRESS);
static const unsigned char PROGMEM bitWiFi[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char PROGMEM image_check_contour_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x50, 0x20, 0x88, 0x51, 0x10, 0x8a, 0x20, 0x44, 0x40, 0x20, 0x80, 0x11, 0x00, 0x0a, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
void displayInit() {
if (!display.begin(SSD1306_SWITCHCAPVCC, OLED_I2C_ADDRESS)) {
// Serial.println(F("SSD1306 allocation failed"));
for (;;)
;
}
delay(100);
}
void buzzerOnScreen(int volume) {
if (volume == 1) {
static const unsigned char PROGMEM volume_loud_icon[] = { 0x12, 0x31, 0xf5, 0xf5, 0x31, 0x12 };
display.drawBitmap(84, 2, volume_loud_icon, 8, 6, 1);
} else {
static const unsigned char PROGMEM volume_mute_icon[] = { 0x10, 0x30, 0xf4, 0xf4, 0x30, 0x10 };
display.drawBitmap(84, 2, volume_mute_icon, 8, 6, 1);
}
}
void valveStatusOnScreen(int valve) {
if (valve == 0) {
static const unsigned char PROGMEM valve_icon[] = { 0x7f, 0x18, 0xbd, 0xff, 0x81, 0xff, 0x81 };
display.drawBitmap(2, 1, valve_icon, 8, 7, 1);
} else {
// nothing to do here
}
}
void WiFiOnScreen(int wifi_rssi) {
if (wifi_rssi >= -50) { //Excellent Netwrok
display.drawBitmap(128, 64, bitWiFi, -127, -63, 1);
display.drawPixel(98, 4, 1);
display.drawPixel(103, 4, 1);
display.drawPixel(99, 3, 1);
display.drawPixel(98, 1, 1);
display.drawPixel(103, 1, 1);
display.drawLine(102, 3, 100, 3, 1);
display.drawLine(102, 1, 99, 1, 1);
display.drawPixel(97, 2, 1);
display.drawPixel(96, 3, 1);
display.drawPixel(104, 2, 1);
display.drawPixel(105, 3, 1);
display.drawLine(100, 5, 101, 5, 1);
display.drawLine(100, 7, 101, 7, 1);
display.drawLine(100, 8, 101, 8, 1);
} else if (wifi_rssi >= -60) { // Good network signal
display.drawBitmap(128, 64, bitWiFi, -127, -63, 1);
display.drawPixel(98, 4, 1);
display.drawPixel(103, 4, 1);
display.drawPixel(99, 3, 1);
display.drawLine(102, 3, 100, 3, 1);
display.drawLine(100, 5, 101, 5, 1);
display.drawLine(100, 7, 101, 7, 1);
display.drawLine(100, 8, 101, 8, 1);
} else if (wifi_rssi >= -70) { // Fair network signal
display.drawBitmap(128, 64, bitWiFi, -127, -63, 1);
display.drawLine(100, 5, 101, 5, 1);
display.drawLine(100, 7, 101, 7, 1);
display.drawLine(100, 8, 101, 8, 1);
} else if (wifi_rssi >= -80) { // Poor network signal
display.drawBitmap(128, 64, bitWiFi, -127, -63, 1);
display.drawLine(100, 7, 101, 7, 1);
display.drawLine(100, 8, 101, 8, 1);
}
}
void networkOnScreen(int status) {
display.drawLine(114, 2, 114, 8, 1);
display.drawLine(111, 1, 117, 1, 1);
display.drawLine(111, 2, 113, 4, 1);
display.drawLine(115, 4, 117, 2, 1);
//if (sim_ready == true) {
if (status > 0 && status < 2) {
// Poor network
display.drawLine(116, 8, 116, 7, 1);
} else if (status >= 3 && status < 20) {
// Fair network
display.drawLine(116, 8, 116, 7, 1);
display.drawLine(118, 8, 118, 6, 1);
} else if (status >= 20 && status < 30) {
// Good network
display.drawLine(116, 8, 116, 7, 1);
display.drawLine(118, 8, 118, 6, 1);
display.drawLine(120, 8, 120, 4, 1);
} else if (status >= 30 && status < 98) {
// excellent network
display.drawLine(116, 8, 116, 7, 1);
display.drawLine(118, 8, 118, 6, 1);
display.drawLine(120, 8, 120, 4, 1);
display.drawLine(122, 8, 122, 2, 1);
} else if (status >= 99) {
display.drawLine(114, 2, 114, 8, 1);
display.drawLine(111, 1, 117, 1, 1);
display.drawLine(111, 2, 113, 4, 1);
display.drawLine(115, 4, 117, 2, 1);
// Serial.println("Network is not detectable!");
}
// }
}
void sensor1LevelShifter(int sensor_value) {
display.setTextColor(1);
display.setTextSize(1);
display.setCursor(13, 17);
display.setTextWrap(false);
display.print(sensor_value);
display.drawRect(37, 16, 78, 9, 1);
int steps = sensor_value / 40;
int x = 39, y = 18;
switch (steps) {
case 1:
x = 39, y = 18;
display.fillRect(x, y, 2, 5, 1);
break;
case 2:
x = 39, y = 18;
for (int i = 0; i < 2; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 3:
x = 39, y = 18;
for (int i = 0; i < 3; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 4:
x = 39, y = 18;
for (int i = 0; i < 4; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 5:
x = 39, y = 18;
for (int i = 0; i < 5; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 6:
x = 39, y = 18;
for (int i = 0; i < 6; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 7:
x = 39, y = 18;
for (int i = 0; i < 7; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 8:
x = 39, y = 18;
for (int i = 0; i < 8; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 9:
x = 39, y = 18;
for (int i = 0; i < 9; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 10:
x = 39, y = 18;
for (int i = 0; i < 10; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 11:
x = 39, y = 18;
for (int i = 0; i < 11; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 12:
x = 39, y = 18;
for (int i = 0; i < 12; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 13:
x = 39, y = 18;
for (int i = 0; i < 13; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 14:
x = 39, y = 18;
for (int i = 0; i < 14; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 15:
x = 39, y = 18;
for (int i = 0; i < 15; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 16:
x = 39, y = 18;
for (int i = 0; i < 16; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 17:
x = 39, y = 18;
for (int i = 0; i < 17; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 18:
x = 39, y = 18;
for (int i = 0; i < 18; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 19:
x = 39, y = 18;
for (int i = 0; i < 19; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 20:
x = 39, y = 18;
for (int i = 0; i < 20; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 21:
x = 39, y = 18;
for (int i = 0; i < 21; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 22:
x = 39, y = 18;
for (int i = 0; i < 22; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 23:
x = 39, y = 18;
for (int i = 0; i < 23; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 24:
x = 39, y = 18;
for (int i = 0; i < 24; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 25:
x = 39, y = 18;
for (int i = 0; i < 25; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
default:
break;
}
}
void sensor2LevelShifter(int sensor_value) {
display.setTextColor(1);
display.setTextSize(1);
display.setCursor(13, 28);
display.setTextWrap(false);
display.print(sensor_value);
display.drawRect(37, 27, 78, 9, 1);
int steps = sensor_value / 40;
int x = 39, y = 29;
switch (steps) {
case 1:
x = 39, y = 29;
display.fillRect(x, y, 2, 5, 1);
break;
case 2:
x = 39, y = 29;
for (int i = 0; i < 2; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 3:
x = 39, y = 29;
for (int i = 0; i < 3; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 4:
x = 39, y = 29;
for (int i = 0; i < 4; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 5:
x = 39, y = 29;
for (int i = 0; i < 5; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 6:
x = 39, y = 29;
for (int i = 0; i < 6; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 7:
x = 39, y = 29;
for (int i = 0; i < 7; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 8:
x = 39, y = 29;
for (int i = 0; i < 8; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 9:
x = 39, y = 29;
for (int i = 0; i < 9; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 10:
x = 39, y = 29;
for (int i = 0; i < 10; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 11:
x = 39, y = 29;
for (int i = 0; i < 11; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 12:
x = 39, y = 29;
for (int i = 0; i < 12; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 13:
x = 39, y = 29;
for (int i = 0; i < 13; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 14:
x = 39, y = 29;
for (int i = 0; i < 14; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 15:
x = 39, y = 29;
for (int i = 0; i < 15; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 16:
x = 39, y = 29;
for (int i = 0; i < 16; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 17:
x = 39, y = 29;
for (int i = 0; i < 17; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 18:
x = 39, y = 29;
for (int i = 0; i < 18; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 19:
x = 39, y = 29;
for (int i = 0; i < 19; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 20:
x = 39, y = 29;
for (int i = 0; i < 20; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 21:
x = 39, y = 29;
for (int i = 0; i < 21; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 22:
x = 39, y = 29;
for (int i = 0; i < 22; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 23:
x = 39, y = 29;
for (int i = 0; i < 23; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 24:
x = 39, y = 29;
for (int i = 0; i < 24; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 25:
x = 39, y = 29;
for (int i = 0; i < 25; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
default:
break;
}
}
void sensor3LevelShifter(int sensor_value) {
display.setTextColor(1);
display.setTextSize(1);
display.setCursor(13, 38);
display.setTextWrap(false);
display.print(sensor_value);
display.drawRect(37, 38, 78, 9, 1);
int steps = sensor_value / 40;
int x = 39, y = 40;
switch (steps) {
case 1:
x = 39, y = 40;
display.fillRect(x, y, 2, 5, 1);
break;
case 2:
x = 39, y = 40;
for (int i = 0; i < 2; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 3:
x = 39, y = 40;
for (int i = 0; i < 3; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 4:
x = 39, y = 40;
for (int i = 0; i < 4; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 5:
x = 39, y = 40;
for (int i = 0; i < 5; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 6:
x = 39, y = 40;
for (int i = 0; i < 6; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 7:
x = 39, y = 40;
for (int i = 0; i < 7; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 8:
x = 39, y = 40;
for (int i = 0; i < 8; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 9:
x = 39, y = 40;
for (int i = 0; i < 9; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 10:
x = 39, y = 40;
for (int i = 0; i < 10; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 11:
x = 39, y = 40;
for (int i = 0; i < 11; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 12:
x = 39, y = 40;
for (int i = 0; i < 12; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 13:
x = 39, y = 40;
for (int i = 0; i < 13; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 14:
x = 39, y = 40;
for (int i = 0; i < 14; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 15:
x = 39, y = 40;
for (int i = 0; i < 15; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 16:
x = 39, y = 40;
for (int i = 0; i < 16; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 17:
x = 39, y = 40;
for (int i = 0; i < 17; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 18:
x = 39, y = 40;
for (int i = 0; i < 18; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 19:
x = 39, y = 40;
for (int i = 0; i < 19; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 20:
x = 39, y = 40;
for (int i = 0; i < 20; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 21:
x = 39, y = 40;
for (int i = 0; i < 21; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 22:
x = 39, y = 40;
for (int i = 0; i < 22; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 23:
x = 39, y = 40;
for (int i = 0; i < 23; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 24:
x = 39, y = 40;
for (int i = 0; i < 24; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 25:
x = 39, y = 40;
for (int i = 0; i < 25; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
default:
break;
}
}
void sensor4LevelShifter(int sensor_value) {
display.setTextColor(1);
display.setTextSize(1);
display.setCursor(13, 49);
display.setTextWrap(false);
display.print(sensor_value);
display.drawRect(37, 49, 78, 9, 1);
int steps = sensor_value / 40;
int x = 39, y = 51;
switch (steps) {
case 1:
x = 39, y = 51;
display.fillRect(x, y, 2, 5, 1);
break;
case 2:
x = 39, y = 51;
for (int i = 0; i < 2; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 3:
x = 39, y = 51;
for (int i = 0; i < 3; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 4:
x = 39, y = 51;
for (int i = 0; i < 4; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 5:
x = 39, y = 51;
for (int i = 0; i < 5; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 6:
x = 39, y = 51;
for (int i = 0; i < 6; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 7:
x = 39, y = 51;
for (int i = 0; i < 7; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 8:
x = 39, y = 51;
for (int i = 0; i < 8; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 9:
x = 39, y = 51;
for (int i = 0; i < 9; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 10:
x = 39, y = 51;
for (int i = 0; i < 10; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 11:
x = 39, y = 51;
for (int i = 0; i < 11; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 12:
x = 39, y = 51;
for (int i = 0; i < 12; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 13:
x = 39, y = 51;
for (int i = 0; i < 13; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 14:
x = 39, y = 51;
for (int i = 0; i < 14; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 15:
x = 39, y = 51;
for (int i = 0; i < 15; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 16:
x = 39, y = 51;
for (int i = 0; i < 16; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 17:
x = 39, y = 51;
for (int i = 0; i < 17; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 18:
x = 39, y = 51;
for (int i = 0; i < 18; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 19:
x = 39, y = 51;
for (int i = 0; i < 19; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 20:
x = 39, y = 51;
for (int i = 0; i < 20; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 21:
x = 39, y = 51;
for (int i = 0; i < 21; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 22:
x = 39, y = 51;
for (int i = 0; i < 22; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 23:
x = 39, y = 51;
for (int i = 0; i < 23; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 24:
x = 39, y = 51;
for (int i = 0; i < 24; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
case 25:
x = 39, y = 51;
for (int i = 0; i < 25; i++) {
display.fillRect(x, y, 2, 5, 1);
x = x + 3;
}
break;
default:
break;
}
}
void alarmOnScreen() {
display.clearDisplay();
static const unsigned char PROGMEM image_Warning_30x23_bits[] = { 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x1f, 0xe0, 0x00, 0x00, 0x3c, 0xf0, 0x00, 0x00, 0x3c, 0xf0, 0x00, 0x00, 0x7c, 0xf8, 0x00, 0x00, 0xfc, 0xfc, 0x00, 0x00, 0xfc, 0xfc, 0x00, 0x01, 0xfc, 0xfe, 0x00, 0x03, 0xfc, 0xff, 0x00, 0x03, 0xfc, 0xff, 0x00, 0x07, 0xfc, 0xff, 0x80, 0x0f, 0xfc, 0xff, 0xc0, 0x0f, 0xfc, 0xff, 0xc0, 0x1f, 0xfc, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xf0, 0x7f, 0xfc, 0xff, 0xf8, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xf8 };
display.drawBitmap(14, 11, image_Warning_30x23_bits, 30, 23, 1);
display.setTextColor(1);
display.setTextSize(2);
display.setCursor(47, 20);
display.setTextWrap(false);
display.print("ALERT!");
display.setTextColor(1);
display.setTextSize(1);
display.setCursor(16, 39);
display.setTextWrap(false);
display.print("Gas Leak Detected");
display.drawRect(7, 9, 115, 43, 1);
display.display();
display.clearDisplay();
}
void sensorDataOnScreen(int sensor1, int sensor2, int sensor3, int sensor4) {
sensor1LevelShifter(sensor1);
sensor2LevelShifter(sensor2);
sensor3LevelShifter(sensor3);
sensor4LevelShifter(sensor4);
}
void welcomeOnScreen() {
display.clearDisplay();
display.setTextColor(1);
display.setTextSize(2);
display.setCursor(22, 24);
display.setTextWrap(false);
display.print("WELCOME");
display.drawRect(18, 21, 89, 20, 1);
display.display();
}
void restartDevice() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(1);
display.setCursor(11, 28);
display.print("Restart the device");
display.display();
}
void successOnScreen() {
display.clearDisplay();
static const unsigned char PROGMEM image_check_contour_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x50, 0x20, 0x88, 0x51, 0x10, 0x8a, 0x20, 0x44, 0x40, 0x20, 0x80, 0x11, 0x00, 0x0a, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
display.drawBitmap(55, 23, image_check_contour_bits, 13, 16, 1);
display.drawCircle(61, 30, 11, 1);
display.display();
}
void simErrorOnScreen() {
display.clearDisplay();
display.setTextColor(1);
display.setTextSize(1);
display.setCursor(22, 20);
display.print("SIM Card Error!");
display.setCursor(21, 31);
display.print("Insert SIM Card");
display.display();
}
void failedOnScreen() {
display.clearDisplay();
display.setTextColor(1);
display.setTextSize(1);
display.setCursor(14, 23);
display.print("Server Connection");
display.setCursor(40, 34);
display.print("Failed");
display.display();
}
void loadingOnScreen() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(1);
display.setCursor(23, 25);
display.print("Initializing");
display.display();
}
void dashboard() {
display.clearDisplay();
display.setTextColor(1);
display.setTextSize(1);
display.setCursor(24, 22);
display.print("Portal Online");
display.setCursor(33, 33);
display.print("sgd.local");
display.display();
}
void wrongCredentials() {
display.clearDisplay();
display.setTextColor(1);
display.setTextSize(1);
display.setCursor(19, 23);
display.print("Couldn't Connect");
display.setCursor(27, 33);
display.print("Try Again...");
display.display();
}
void setup() {
displayInit();
delay(1000);
// display.clearDisplay();
// sensorDataOnScreen(500, 700, 630, 620);
// networkOnScreen(40);
// WiFiOnScreen(-60);
// buzzerOnScreen(1);
// valveStatusOnScreen(0);
// display.display();
// successOnScreen();
alarmOnScreen();
}
void loop() {
// Nothing to do here
}