You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
5.9 KiB
Arduino

// TV.OUT LIBRARY
#include <TVout.h>
#include <fontALL.h>
// for incoming serial data
int incomingByte = 0;
// TV.OUT LIBRARY
TVout TV;
unsigned char x,y;
int zOff = 150;
int xOff = 0;
int yOff = 0;
int cSize = 50;
int view_plane = 64;
float angle = PI/60;
// P1-P7
int toggle_1;
int toggle_2;
int toggle_3;
int toggle_4;
int toggle_5;
int toggle_6;
int toggle_7;
//SHUFFLE TEXT
void shuffle(char *array, size_t n)
{
if (n > 1)
{
size_t i;
for (i = 0; i < n - 1; i++)
{
size_t j = i + rand() / (RAND_MAX / (n - i) + 1);
int t = array[j];
array[j] = array[i];
array[i] = t;
}
}
}
const char t0[] PROGMEM = "20:00"; // "String 0" etc are strings to store - change to suit.
const char t1[] PROGMEM = "21:00";
const char t2[] PROGMEM = "22:00";
const char t3[] PROGMEM = "sun";
const char t4[] PROGMEM = "is";
const char t5[] PROGMEM = "down";
const char t6[] PROGMEM = "23:00";
const char t7[] PROGMEM = "00:00";
const char t8[] PROGMEM = "PAVEMENT";
// Then set up a table to refer to your strings.
const char *const string_table[] PROGMEM = {t0, t1, t2, t3, t4, t5, t6, t7, t8};
const char *const string_table2[] PROGMEM = {t0, t1, t2};
char input[] = "sundown9";
char buffer[255] = "";
//TEXT
const char *animals[] = {"repetative", " ", "on", "cockroach"}; //A0
const char *BOBZ[] = {"labour", "silhouette", "bark", "or", "alligators ", "pitbulls", "depending"}; //A1
const char *part3[] = {"like", "wind", "not", "overdo"}; //A2
const char *part4[] = {
"dont be scared",
" dont avoid",
"you are soft",
" HANDS"
};
const byte letter = 25;
char *letters[letter] = {"RUFF","A","B","C","D","RUDE","E","F","G","K","L","repetitive labour","M","N","O","P","R","S","T","U","V","W","Y","Z"};
const char *words[] ={"street", "at night they", "by day"};
const int BUTTON1 = 4; //B1
const int BUTTON2 = 5; //B2
const int BUTTON3 = 6; //B3
const int BUTTON4 = 7; //B4
const int BUTTON5 = 8; //B5
const int BUTTON6 = 9; //B6
const int BUTTON7 = 10; //B7
int val1= 0;
int val2= 0;
int val3= 0;
int val4= 0;
int val5= 0;
int val6= 0;
int val7= 0;
void setup() {
TV.begin(PAL);
TV.select_font(font4x6);
//Serial.begin(9600);
//TV.println(input);
//TV.println(input);
pinMode(BUTTON1, INPUT);
pinMode(BUTTON2, INPUT);
pinMode(BUTTON3, INPUT);
pinMode(BUTTON4, INPUT);
pinMode(BUTTON5, INPUT);
pinMode(BUTTON6, INPUT);
pinMode(BUTTON7, INPUT);
}
void loop() {
toggle_1 = analogRead(A6); //P1
toggle_2 = analogRead(A5); //P2
toggle_3 = analogRead(A4); //P3
toggle_4 = analogRead(A3); //P4
toggle_5 = analogRead(A2); //P5
toggle_6 = analogRead(A1); //P6
toggle_7 = analogRead(A0); //P7
val1 = digitalRead(BUTTON1);
val2 = digitalRead(BUTTON2);
val3 = digitalRead(BUTTON3);
val4 = digitalRead(BUTTON4);
val5 = digitalRead(BUTTON5);
val6 = digitalRead(BUTTON6);
val7 = digitalRead(BUTTON7);
//int l = strlen(string_table);
//shuffle(input, l );
//TV.println(input);
//delay(200);
//B1
if (val1 == HIGH) {
TV.select_font(font4x6);
TV.print("POETRY");
Serial.print("POETRY"); //SEND TX
TV.draw_line(60,20,60,76,WHITE);
} //done
//B2
if (val2 == HIGH) {
TV.select_font(font6x8);
TV.print("corner");
TV.draw_line(20,20,60,76,WHITE);
if(toggle_4 < 500){
TV.print("worst-case scenario",10,10);
Serial.print("worst-case scenario"); //SEND TX
}
}
//B3
//crash
if (val3 == HIGH) {
for (int i=0; i<TV.hres(); i++) {
TV.print(i,44,F("cigarette"));
TV.select_font(font8x8ext);
TV.print(i,i,F("TTTTTTTTTTTTTT"));
TV.delay(200);
Serial.print("cigarette"); ////SEND TX
}
}
//B4
//blinking
if (val4 == HIGH) {
TV.print(letters[random(0,letter)]);
TV.select_font(font4x6);
TV.print(10,10,F("good evening"));
TV.draw_rect(20,20,33,76,0,0);
TV.draw_line(20,20,33,76,1);
TV.clear_screen();
}
//B5
//RECEIVES TX
if (val5 == HIGH) {
TV.print((char)Serial.read());
TV.delay(20);
}
//B6
//alpha
if (val6 == HIGH) {
TV.print(letters[random(0,letter)]);
}
//B6
//TEXT OUT
if (val7 == HIGH) {
//SHUFFLE sentance
//int l = strlen(input);
//shuffle(input, l );
//TV.println(input);
//delay(100);
//Serial.print("SUN IS DOWN"); //TXT OUT
//SHUFFLE list/ times
for (int i = 0; i < 9; i++) {
strcpy_P(buffer, (char *)pgm_read_word(&(string_table[i])));
shuffle(buffer, strlen(buffer));
TV.print(buffer);
delay(100);
}
}
if(toggle_5 >500){
//P1
//map
int animal; //animals
animal = map(toggle_1, 10, 1023, 0, 3);
TV.print(animals[animal]);
delay(50);
if (toggle_1<10){
TV.select_font(font4x6);
TV.print(" ");
delay(500);
}
//P2
//string list
int BOB; //BOBZ
BOB = map(toggle_2, 0, 1023, 0, 6);
TV.print(BOBZ[BOB]);
TV.delay(50);
//P3
//map
int w1; //words
w1 = map(toggle_3, 0, 1023, 0, 3);
TV.print(words[w1]);
TV.delay(50);
//P6
//draw and text
if(toggle_6>0 & toggle_6<100 ){
TV.invert();
TV.print(10,10,F("stretched torso abs rocks "));
}
else if(toggle_6>100 & toggle_6<200){
TV.print(30,50,F("where are you going"));
delay(50);
}
else if(toggle_6>200 & toggle_6<300){
TV.select_font(font8x8ext);
TV.print(50,50,F("to step into a dark place"));
}
else if(toggle_6>350 & toggle_6<500){
TV.print(10,70,"need someone to play with");
}
else if(toggle_6>500 & toggle_6<1023){
TV.print("scratch");
}
//P7
//
//int p4;
//p4 = map(toggle_7, 0, 250, 0, 3);
//TV.print(part4[p4]);
//delay(100);
if (toggle_7>0 & toggle_7<500){
for (int i = 0; i < 3; i++) {
strcpy_P(buffer, (char *)pgm_read_word(&(string_table2[i])));
shuffle(buffer, strlen(buffer));
TV.print(buffer);
delay(300);
}
}
else if (toggle_7>500 & toggle_7<800){
TV.select_font(font8x8ext);
TV.print(30,10,F("lean on a car"));
}
else if (toggle_7>800 & toggle_7<1023){
//TV.select_font(font8x8ext);
TV.print("lean on a car");
}
}
//P5
//7777777...
else if(toggle_5 <100){
TV.print("7");
}
}