refais ce code et fait un soleil plus minimaliste fait en sorte que se soit un…
- User
refais ce code et fait un soleil plus minimaliste fait en sorte que se soit un indicateur en plus dans un style minimaliste pour mon interface arduino : #include "SPI.h" #include "Adafruit_GFX.h" #include "Adafruit_ILI9341.h"
#define TFT_DC 9 #define TFT_CS 10 Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void drawSun(int x, int y) { tft.fillCircle(x, y, 20, ILI9341_YELLOW); // Soleil for (int deg = 0; deg < 360; deg += 45) { float rad = deg * PI / 180; int lineLength = 10; int endX = x + cos(rad) * (20 + lineLength); int endY = y + sin(rad) * (20 + lineLength); tft.drawLine(x, y, endX, endY, ILI9341_YELLOW); } }
void clearSun(int x, int y) { int diameter = 60; // Large enough to erase the entire sun tft.fillRect(x - diameter / 2, y - diameter / 2, diameter, diameter, ILI9341_BLACK); }
void setup() { tft.begin(); tft.fillScreen(ILI9341_BLACK);
tft.setCursor(26, 120); tft.setTextColor(ILI9341_RED); tft.setTextSize(3); tft.println("Hello, TFT!");
tft.setCursor(20, 160); tft.setTextColor(ILI9341_GREEN); tft.setTextSize(2); tft.println("I can has colors?"); }
void loop() { static bool sunVisible = true; static unsigned long lastToggleTime = 0; if (millis() - lastToggleTime > 1000) { sunVisible = !sunVisible; if (sunVisible) { drawSun(120, 210); // Coordinates where the sun should be drawn } else { clearSun(120, 210); } lastToggleTime = millis(); }
static unsigned long lastUpdateTime = 0; if (millis() - lastUpdateTime > 5000) { tft.fillRect(0, 0, 320, 240, ILI9341_BLACK); // Clear the screen
codetft.setTextSize(4); tft.setCursor(0,0); tft.print("20 C"); tft.fillRect(0,0,2000,2000,ILI9341_BLACK); //Black box drawn over 'old' time data tft.setCursor(0,0); tft.setTextColor(ILI9341_BLUE); tft.setTextSize(2); tft.print("humidité : "); //je vais changé par la variable aprés tft.setCursor(0,20); tft.setTextSize(4); tft.print("50% "); //je vais changé par la variable aprés tft.setTextSize(2); tft.setCursor(0,80); tft.setTextColor(ILI9341_RED); tft.print("Température"); tft.setTextSize(4); tft.setCursor(0,100 ); tft.print("20C"); tft.setCursor(0,160); tft.setTextSize(2); tft.setTextColor(ILI9341_YELLOW); tft.print("ensoleillement : "); tft.setTextSize(4); tft.setCursor(0,180); tft.print("75% "); //call function to check on temperature and draw new data if necessary delay(1000); lastUpdateTime = millis(); - Assistant
- User
je veux que le code sois complet
- Assistant