Created
May 23, 2016 23:05
-
-
Save lmccart/c5b19da26f141be4772024aead75f38b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal.h> | |
// initialize the library with the numbers of the interface pins | |
LiquidCrystal lcd1(12, 11, 16, 17, 18, 19); | |
LiquidCrystal lcd2(12, 5, 6, 7, 8, 9); | |
LiquidCrystal lcds[2] = { lcd1, lcd2 }; | |
int leds[2] = { 2, 10 }; | |
static String cues[60] = { | |
"play", "doubt", "compliment", "accommodate", "empathize", "look away", | |
"reveal", "chime in", "digress", "confide", "forget", "wink", "insult", "relate to", "confess", | |
"joke", "brag", "care", "challenge", "maintain eye contact", "reminisce", "interrupt", "praise", | |
"raise eyebrows", "suggest", "laugh", "give advice", "contradict", "aggravate", "nod", "compare", | |
"criticize", "commiserate", "frown", "wish", "accuse", "make fun", "agree", "offer", "consider", | |
"dismiss", "smile", "change topic", "listen", "lie", "disagree", "complain", "touch", "plan", | |
"challenge", "argue", "exaggerate", "predict", "shake head", "question", "defend", "share", "debate", "change subject", "notice" | |
}; | |
//static String cues[2] = { | |
// "talk it out", "visit the bathroom" | |
//}; | |
char cue_chars[34]; | |
int time = -1; | |
String cue_word = String(34); | |
int cue_interval = 3000; // 1 per second to test | |
boolean cur_user = 0; | |
int e; | |
String werd = String(34); | |
String remix = String(34); | |
boolean break_line = false; | |
void setup() { | |
//LED - Backlight | |
pinMode(leds[0], OUTPUT); | |
pinMode(leds[1], OUTPUT); | |
// set up the LCD's number of columns and rows: | |
lcds[0].begin(16, 2); | |
lcds[1].begin(16, 2); | |
} | |
void loop() { | |
if (time == -1 || time >= cue_interval) { | |
time = 0; | |
pickCue(); | |
handleCueOut(); | |
} | |
time++; | |
delay(10); | |
} | |
void pickCue() { | |
cur_user = !cur_user; | |
cue_word = cues[random(60)]; | |
break_line = cue_word.indexOf(" ") != -1 && cue_word.length() > 16 ? true : false; | |
} | |
void handleCueOut() { | |
// turn off both screens - Backlight | |
for (int i = 0; i < 2; i++) { | |
lcds[i].noDisplay(); | |
digitalWrite(leds[i], LOW); | |
} | |
// prepare cue for display | |
remixCue(cue_word, break_line, true).toCharArray(cue_chars, sizeof(cue_chars)); | |
// display cue | |
lcds[cur_user].clear(); | |
delay(5); | |
lcds[cur_user].print(cue_chars); | |
delay(5); | |
if (break_line) { | |
remixCue(cue_word, true, false).toCharArray(cue_chars, sizeof(cue_chars)); | |
lcds[cur_user].setCursor(0, 1); | |
lcds[cur_user].print(cue_chars); | |
delay(5); | |
} | |
digitalWrite(leds[cur_user], HIGH); | |
lcds[cur_user].display(); | |
} | |
// This function adds padding to properly print cues that need to break over two lines. | |
// This might need to change based on size and spec of screens used. | |
String remixCue(String c, boolean db, boolean first) { | |
werd = ""; | |
remix = ""; | |
if (!db) | |
werd = c; | |
else if (db && first) | |
werd = c.substring(0, c.indexOf(" ")); | |
else | |
werd = c.substring(c.indexOf(" ") + 1, c.length()); | |
if (werd.length() % 2 == 1) | |
e = 1 + (15 - werd.length()) / 2; | |
else | |
e = (16 - werd.length()) / 2; | |
for (int i = 0; i < e; i++) | |
remix.concat(" "); | |
remix.concat(werd); | |
remix.toUpperCase(); | |
return remix; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment