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.

401 lines
7.8 KiB
C++

// 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 pot_1;
int pot_2;
int pot_3;
int pot_4;
int pot_5;
int pot_6;
int pot_7;
// B1-B7
const int BUTTON1 = 10; //B1
const int BUTTON2 = 9; //B2
const int BUTTON3 = 8; //B3
const int BUTTON4 = 7; //B4
const int BUTTON5 = 6; //B5
const int BUTTON6 = 5; //B6
const int BUTTON7 = 4; //B7
int val1= 0;
int val2= 0;
int val3= 0;
int val4= 0;
int val5= 0;
int val6= 0;
int val7= 0;
//
//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;
}
}
}
//AM
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 = "01:00 ";
const char t4[] PROGMEM = "02:00";
const char t5[] PROGMEM = "03:00";
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
//I
const char *part1[] = {"repetative", "bench ", "on", "cockroach", "", " [you are soft] ",}; //P1 [0-5]
//II
const char *part2[] = {"labour", "silhouette ", "bark ", " wind", "alligators ", "pitbulls", "", "depending, ", " dont avoid",}; //P2 [0-8]
//III
const char *part3[] = {"at night they", "like", "", "or", "dont be scared", "not ", "overdo", "street", " HANDS", "by day"}; //P3 [0-9]
//ALPHA
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 msg1[] PROGMEM = {" you did see me"};
const char msg2[] PROGMEM = {" it fell out"};
const char msg3[] PROGMEM = {" like you hear me"};
unsigned int displayInt;
char charmsg1;
char charmsg2;
char charmsg3;
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() {
pot_1 = analogRead(A0); //P1
pot_2 = analogRead(A1); //P2
pot_3 = analogRead(A2); //P3
pot_4 = analogRead(A3); //P4
pot_5 = analogRead(A4); //P5
pot_6 = analogRead(A5); //P6
pot_7 = analogRead(A6); //P7
val1 = digitalRead(BUTTON1);
val2 = digitalRead(BUTTON2);
val3 = digitalRead(BUTTON3);
val4 = digitalRead(BUTTON4);
val5 = digitalRead(BUTTON5);
val6 = digitalRead(BUTTON6);
val7 = digitalRead(BUTTON7);
//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
// \CORNER
if (val2 == HIGH) {
if (pot_4 <500){
TV.select_font(font6x8);
TV.print("corner");
TV.draw_line(20,20,60,76,WHITE);}
if(pot_4 > 500){
TV.select_font(font8x8);
TV.print(10,10,"worst-case scenario");
Serial.print("worst-case scenario"); //SEND TX
}
}
//B3
//crash CIG
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) {
if(pot_2 < 100) {
TV.clear_screen();
TV.print("dry eyes red eyes itchy eyes");
}
else if(pot_2 > 1000) {
TV.print(10,10,F(" >>>>>>>>>>>>>>>>okokokok>>>>>>>>>>>>>>>>>>>>dont be scared "));
TV.delay(50);
}
else {
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
//TX IN
if (val5 == HIGH) {
TV.print((char)Serial.read());
TV.delay(50);
}
//B6
//alpha
if (val6 == HIGH) {
if(pot_1 < 400){
TV.select_font(font6x8);
TV.print ("girls wish to risk");
Serial.print ("girls wish to risk");
}
if(pot_1 > 400){
TV.print(letters[random(0,letter)]);
}
}
//B6
//TEXT OUT
if (val7 == HIGH) {
//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);
}
}
//P5 [main]
if(pot_5 >500){
//P1
//space&slower
if (pot_1<10){
TV.select_font(font4x6);
TV.print(" ");
delay(500);
}
//map I
int p1; //animals
p1 = map(pot_1, 10, 1023, 0, 5);
TV.select_font(font4x6);
TV.print(part1[p1]);
delay(50);
//P2
//map II
int p2; //BOBZ
p2 = map(pot_2, 0, 1023, 0, 8);
TV.select_font(font4x6);
TV.print(part2[p2]);
TV.delay(50);
//P3
//map III
int p3; //words
p3 = map(pot_3, 0, 1023, 0, 9);
TV.select_font(font4x6);
TV.print(part3[p3]);
TV.delay(50);
//P4
if (pot_4>100 & pot_4<500){
TV.print("");
}
if (pot_4>100 & pot_4<500){
TV.print("SUN IS DOWN");
delay(50);
}
if (pot_4>500 & pot_4<1023){
//SHUFFLE sentance
int l = strlen(input);
shuffle(input, l );
TV.print(input);
delay(20);
Serial.print("SUN IS DOWN"); //TXT OUT
}
//P6
//draw and text
if(pot_6>0 & pot_6<100 ){
TV.invert();
TV.print(10,10,F("stretched torso abs rocks "));
}
else if(pot_6>100 & pot_6<200){
TV.print(30,50,F("where are you going"));
delay(50);
}
else if(pot_6>200 & pot_6<300){
TV.select_font(font8x8ext);
TV.print(50,50,F("TO STEP INTO A DARK PLACE"));
}
else if(pot_6>300 & pot_6<400){
TV.print("");
}
else if(pot_6>300 & pot_6<400){
TV.print("time to speak");
}
else if(pot_6>500 & pot_6<900){
TV.print(10,70," need someone to play with");
}
else if(pot_6>900 & pot_6<1023){
TV.print("scratch");
}
//P7
if (pot_7<100){
TV.clear_screen();
TV.select_font(font6x8);
for (byte k = 0; k < strlen(msg1); k++) {
charmsg1 = pgm_read_byte_near(msg1 + k);
TV.print(charmsg1);
delay(500);}
}
else if (pot_7>100 & pot_7<300){
TV.clear_screen();
TV.select_font(font6x8);
for (byte k = 0; k < strlen(msg2); k++) {
charmsg2 = pgm_read_byte_near(msg2 + k);
TV.print(charmsg2);
delay(300);}
}
else if (pot_7>300 & pot_7<500){
TV.clear_screen();
TV.select_font(font6x8);
for (byte k = 0; k < strlen(msg3); k++) {
charmsg3 = pgm_read_byte_near(msg3 + k);
TV.print(charmsg3);
delay(50);}
}
else if (pot_7>500 & pot_7<800){
TV.select_font(font8x8ext);
TV.print(30,10,F("lean on a car"));
}
else if (pot_7>800 & pot_7<999){
TV.select_font(font4x6);
TV.print("lean on a car");
}
else if (pot_7<999){
TV.select_font(font4x6);
TV.print("");
}
}
//P5
//7777777...
else if(pot_5 <100){
TV.print("7");
}
}