#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 setup() {
Serial.begin(115200);
Serial.println(" shapes on Nucleo-32 SPI अरविन्द पाटील ...");
delay(500);
Serial.println(" इस कोड की रचना अरविन्द द्वारा 17/11/23 ");
delay(1000);
tft.begin();
// Display three filled circles with different colors
tft.fillCircle(60, 200, 20, ILI9341_RED); // Circle 1 (x=60, y=100, radius=20)
tft.fillCircle(120, 200, 20, ILI9341_GREEN); // Circle 2 (x=120, y=100, radius=20)
tft.fillCircle(180, 200, 20, ILI9341_BLUE); // Circle 3 (x=180, y=100, radius=20)
// Draw a color gradient triangle
drawColorGradientTriangle();
// Add text by Arvind Patil in yellow color
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(3);
tft.setCursor(10, 230);
tft.print("Arvind Patil");
tft.setTextColor(ILI9341_CYAN);
tft.setTextSize(2);
tft.setCursor(10, 10);
tft.print("by simulation");
}
void drawColorGradientTriangle() {
int triangleSize = 120;
int startX = 60;
int startY = 30;
// Draw the triangle using interpolated colors along the edges
for (int i = 0; i < triangleSize; i++) {
int color1 = colorRangeMap(i, 0, triangleSize, ILI9341_RED, ILI9341_GREEN);
int color2 = colorRangeMap(i, 0, triangleSize, ILI9341_GREEN, ILI9341_BLUE);
int color3 = colorRangeMap(i, 0, triangleSize, ILI9341_BLUE, ILI9341_RED);
int x1 = startX + i;
int y1 = startY + i;
int x2 = startX + triangleSize;
int y2 = startY + triangleSize;
tft.drawLine(x1, y1, x2, y2, color1);
tft.drawLine(x1, y1, startX, startY + triangleSize, color2);
tft.drawLine(x2, y2, startX, startY + triangleSize, color3);
}
}
int colorRangeMap(int value, int in_min, int in_max, int out_min, int out_max) {
return (value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
void loop() {
// Your main code here
}