#include <Adafruit_ILI9341.h>
#define TFT_CS 9
#define TFT_DC 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define WIDTH 320
#define HEIGHT 240
void setup(void) {
tft.begin();
tft.setRotation(1);
}
void loop() {
float scale[6];
for (byte i = 0; i < 6; i++)
scale[i] = (float)rand() / RAND_MAX / 4;
for (int y = 0; y < HEIGHT; y++) {
for (int x = 0; x < WIDTH; x++) {
uint8_t r, g, b;
r = 15.5 + 15.5 * sin(x * scale[0] + sin(y * scale[1]));
g = 31.5 + 31.5 * cos(y * scale[2] + sin(x * scale[3]));
b = 15.5 + 15.5 * sin((x+y) * scale[4] + sin(y * scale[5]));
uint16_t rgb565 = b | (g << 5) | (r << 11);
tft.drawPixel(x, y, rgb565);
}
}
}