Commit 28ce8829 authored by Nick Price's avatar Nick Price

ok

parent 8c724820
......@@ -6,32 +6,168 @@
#include <Adafruit_ST77xx.h>
#include <LinkedList.h>
#define TFT_CS 10 // Chip select line for TFT display
#define TFT_RST 9 // Reset line for TFT (or see below...)
#define TFT_DC 8 // Data/command line for TFT
#define TFT_CS 10 // Chip select line for TFT display
#define TFT_RST 9 // Reset line for TFT (or see below...)
#define TFT_DC 8 // Data/command line for TFT
#define WIDTH 128
#define HEIGHT 160
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
void(* resetMCU) (void) = 0;
void (*resetMCU)(void) = 0;
struct Cell {
struct Cell
{
int x;
int y;
};
LinkedList<Cell> *cells;
void setup() {
void rainbow(int count)
{
for (int x = 0; x < count; x++)
{
Serial.println(x);
tft.setRotation(random(0, 4));
tft.fillScreen(random(0, 65535));
}
}
void text(int count)
{
tft.setRotation(random(0, 4));
tft.fillScreen(ST77XX_BLACK);
tft.setCursor(0, 0);
for (int i = 0; i < count; i++)
{
tft.setTextColor(random(0, 65535));
tft.print("TELEPHREAK");
}
}
void randomize()
{
tft.setRotation(random(0, 4));
tft.fillScreen(ST77XX_BLACK);
//this is hacky but the display will just drop pixels it doesn't have lol
for (int x = 0; x < 160; x++)
{
for (int y = 0; y < 160; y++)
{
tft.startWrite();
tft.writePixel(x, y, random(0, 65535));
tft.endWrite();
}
}
}
void rule30()
{
uint16_t color = random(0, 65536);
int prev_row[128];
tft.setRotation(0);
tft.fillScreen(ST77XX_BLACK);
//initial seed
for (int x = 0; x < 128; x++)
{
tft.startWrite();
if (random(0, 2) == 0)
{
prev_row[x] = 0;
tft.writePixel(x, 0, ST77XX_BLACK);
}
else
{
prev_row[x] = 1;
tft.writePixel(x, 0, color);
}
tft.endWrite();
}
//100 011 010 001
for (int y = 1; y < 160; y++)
{
int a, b, c;
int this_row[128];
for (int x = 0; x < 128; x++)
{
a = x - 1;
b = x;
c = x + 1;
if (a == -1)
{
a = 127;
}
if (c == 128)
{
c = 0;
}
tft.startWrite();
if (
(prev_row[a] == 1 && prev_row[b] == 0 && prev_row[c] == 0) ||
(prev_row[a] == 0 && prev_row[b] == 1 && prev_row[c] == 1) ||
(prev_row[a] == 0 && prev_row[b] == 1 && prev_row[c] == 0) ||
(prev_row[a] == 0 && prev_row[b] == 0 && prev_row[c] == 1))
{
this_row[x] = 1;
tft.writePixel(x, y, color);
continue;
}
this_row[x] = 0;
tft.writePixel(x, y, ST77XX_BLACK);
tft.endWrite();
}
for (int i=0; i<128; i++) {
prev_row[i] = this_row[i];
}
}
}
void setup()
{
Serial.begin(9600);
tft.initR(INITR_BLACKTAB);
tft.setRotation(0);
tft.setAddrWindow(0, 0, 127, 159);
tft.fillScreen(ST77XX_BLACK);
cells = new LinkedList<Cell>();
}
void loop() {
// put your main code here, to run repeatedly:
}
\ No newline at end of file
void flash(int count)
{
for (int i = 0; i < count; i++)
{
tft.invertDisplay(true);
delay(300);
tft.invertDisplay(false);
delay(300);
}
}
void maybeInvert() {
if(random(0,2) == 1) {
tft.invertDisplay(true);
} else {
tft.invertDisplay(false);
}
}
void loop()
{
randomSeed(analogRead(0));
maybeInvert();
rule30();
delay(2000);
maybeInvert();
text(1000);
flash(3);
delay(200);
randomize();
delay(200);
rainbow(35);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment