#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 2
#define TFT_CS 3
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// Define maximum colors for the gradient
const uint16_t MAX_COLORS[] = {
ILI9341_RED,
ILI9341_ORANGE,
ILI9341_YELLOW,
ILI9341_GREEN,
ILI9341_CYAN,
ILI9341_BLUE,
ILI9341_MAGENTA,
ILI9341_WHITE
};
void drawFilledHexagon(int x, int y, int size, uint16_t color) {
float angle = 0;
for (int i = 0; i < 6; ++i) {
float x1 = x + size * cos(angle);
float y1 = y + size * sin(angle);
float x2 = x + size * cos(angle + PI / 3);
float y2 = y + size * sin(angle + PI / 3);
tft.fillTriangle(x, y, x1, y1, x2, y2, color);
angle += PI / 3;
}
}
void drawColorGradient() {
int numColors = sizeof(MAX_COLORS) / sizeof(MAX_COLORS[0]);
int colorStep = tft.height() / numColors;
for (int y = 0; y < tft.height(); y++) {
int colorIndex = y / colorStep;
int color = MAX_COLORS[colorIndex];
tft.drawFastHLine(0, y, tft.width(), color);
}
}
void setup() {
Serial.begin(115200);
Serial.println(" shapes on Nucleo-32 SPI अरविन्द पाटील ...");
delay(500);
Serial.println(" इस कोड की रचना अरविन्द द्वारा 17/11/23 ");
delay(1000);
tft.begin();
// Draw a color gradient on the entire screen
drawColorGradient();
// Display a filled hexagon in the center of the screen
int hexagonSize = 50;
int centerX = tft.width() / 2;
int centerY = tft.height() / 2;
drawFilledHexagon(centerX, centerY, hexagonSize, ILI9341_MAGENTA);
// Add text by Arvind Patil in yellow color
tft.setTextColor(ILI9341_MAGENTA);
tft.setTextSize(2);
tft.setCursor(10, 230);
tft.print("Arvind Patil");
}
void loop() {
// Your main code here
}
Loading
stm32-bluepill
stm32-bluepill
अरविन्द पाटील