/*
ESP32 + ILI9341 LCD Basic Example
https://wokwi.com/projects/325324981270479442
*/
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
//+++++++++++++++++++++> my icons
#include "warning02bhex.h"
#include "power.h"
//++++++++++++++++++++< my icons
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
//++++++++++++++++ icon varibles
uint16_t enter_icon;
uint16_t chang_icon_warning[576];
void setup() {
//++++++++++++ TFT LCD
tft.begin();
//++++++++++++++++++++++background color
tft.fillScreen(0xffff);
tft.setRotation(3); // 0 is defult . 1,2,3 are other rotation numbers
/*
tft.setCursor(100,0);
int count=0;
for (int i=0;i<12;i++){
for(int j=0;j<48;j++){
enter_icon= dragonBitmap[count];
chang_icon_warning[count]=enter_icon;
tft.drawPixel(i,j,chang_icon_warning[count]);
count++;
}
}
*/
//extern uint8_t myBitmap[];
drawBitmap(0,0,warning48x48,48,48,tft.color565(26,147,122));
drawBitmap(50,50,syrange48x48,48,48,tft.color565(255,0,0));
drawBitmap(100,100,serum48x48,48,48,tft.color565(0,255,0));
}
void loop() {
delay(1000); // delay 1 seconds
}
void drawBitmap(int16_t x, int16_t y,
const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color) {
int16_t i, j, byteWidth = (w + 7) / 8;
Serial.println(byteWidth);
uint8_t byte;
for(j=0; j<h; j++) {
for(i=0; i<w; i++) {
if(i & 7) byte <<= 1;
else byte = pgm_read_byte(bitmap + j * byteWidth + i / 8);
if(byte & 0x80) tft.drawPixel(x+i, y+j, color);
}
}
}