Hi everyone
I would like to do water level monitoring. I am using a 2.8 TFT display library ILI9341
I already have bitmaps created.
Could someone help me with what the code should look like in the loop to have the same effect as in the link?
I'm not sure whether I need to create the entire bitmap or just a fragment?
#define STATUS_LED_GPIO 2
#define BUTTON_CFG_RELAY_GPIO 4
#define TFT_RST 14
#define TFT_DC 15
#define TFT_CS 17
#include <Arduino.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include "SPI.h"
#include <Adafruit_ILI9341.h>
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// If using the breakout, change pins as desired
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
void setup() {
Serial.begin(115200);
tft.begin();
tft.fillScreen(ILI9341_BLACK);
tft.drawBitmap(6, 6, logo32_glcd_bmp, 32, 32, ILI9341_GREEN);
}
void loop() {
if (water_value < 10) {
Serial.println("Empty");
tft.drawBitmap(25, 26, epd_bitmap_lvl_0, 190, 254, ILI9341_YELLOW);
}
if ((water_value >= 10) && (water_value < 20)) {
Serial.println("Level 10 %");
tft.drawBitmap(25, 26, epd_bitmap_lvl_10, 190, 254, ILI9341_YELLOW);
}
if ((water_value >= 20) && (water_value < 30)) {
Serial.println("Level 20 %");
tft.drawBitmap(25, 26, epd_bitmap_lvl_20, 190, 254, ILI9341_YELLOW);
}
if ((water_value >= 30) && (water_value < 40)) {
Serial.println("Level 30 %");
tft.drawBitmap(25, 26, epd_bitmap_lvl_30, 190, 254, ILI9341_YELLOW);
}
if ((water_value >= 40) && (water_value < 50)) {
Serial.println("Level 40 %");
tft.drawBitmap(25, 26, epd_bitmap_lvl_40, 190, 254, ILI9341_YELLOW);
}
}