/*
ESP32 HTTPClient Jokes API Example
https://wokwi.com/projects/342032431249883731
Copyright (C) 2022, Uri Shaked
*/
#include <WiFi.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
Adafruit_MPU6050 mpu;
const char* ssid = "Wokwi-GUEST";
const char* password = "";
#define BTN_PIN 5
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void printLocalTime()
{
struct tm timeinfo;
if(!getLocalTime(&timeinfo)){
tft.println("Failed to obtain time");
return;
}
tft.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
}
void printHMS()
{
struct tm timeinfo;
if(!getLocalTime(&timeinfo)){
tft.println("ER:RO:R!");
return;
}
tft.println(&timeinfo, "%H:%M:%S");
}
void setup() {
tft.begin();
tft.setTextColor(0x07FF);
tft.println("KuBIX System 0.0.2 Alpha");
tft.setTextColor(0x0FF7);
tft.println("<i> boot system");
WiFi.begin(ssid, password, 6);
tft.setTextColor(ILI9341_WHITE);
//tft.setTextSize(2);
tft.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(100);
tft.print(".");
}
while (!mpu.begin()) {
tft.println("MPU6050 not connected!");
delay(1000);
}
tft.println("MPU6050 ready!");
tft.print("\nOK! IP=");
tft.println(WiFi.localIP());
configTime(0 , 0, "pool.ntp.org");
printLocalTime();
delay(1000);
}
sensors_event_t event;
void loop() {
renderHome(500, 0x000, 0x0FFF, 0xFFF0);
delay(500);
}
void printGyro(){
mpu.getAccelerometerSensor()->getEvent(&event);
tft.print("[");
tft.print(millis());
tft.print("] X: ");
tft.print(event.acceleration.x);
tft.print(", Y: ");
tft.print(event.acceleration.y);
tft.print(", Z: ");
tft.print(event.acceleration.z);
tft.println(" m/s^2");
}
void renderHome(int rdl, int bgcolor, int primary, int secondary){
//printLocalTime();
tft.setTextSize(4);
printHMS();
delay(rdl);
tft.fillRect(0, 0, 100, 100, 0x0000)
//tft.fillScreen(bgcolor);
tft.setCursor(0,0);
}
Loading
ili9341-cap-touch
ili9341-cap-touch