Skip to content

Commit

Permalink
Lighting and Matrix fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LUTC CSNET committed Feb 23, 2018
1 parent 6af0171 commit d9a6d24
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 25 deletions.
5 changes: 3 additions & 2 deletions arduino/matrix.ino → arduino/matrix/matrix.ino 100755 → 100644
Expand Up @@ -10,7 +10,7 @@ using.
int matrix_buffer[] {255,255,255,255,255}; int matrix_buffer[] {255,255,255,255,255};
int charList[256]; int charList[256];
int matrix_populate_delay = 0; int matrix_populate_delay = 0;
int matrix_update_delay = 1000; int matrix_update_delay = 500;
int updates_per_second = 2; int updates_per_second = 2;




Expand Down Expand Up @@ -152,6 +152,7 @@ void createCharList(){
charList[97] = 126; charList[97] = 126;
charList[88] = 256; //Special Case for Do Not Update charList[88] = 256; //Special Case for Do Not Update
charList[32] = 0; //Blank charList[32] = 0; //Blank
charList[110] = 0; //Blank
charList[33] = 256; //Special Case for ! charList[33] = 256; //Special Case for !
charList[63] = 256; //Special Case for ? charList[63] = 256; //Special Case for ?
} }
Expand Down Expand Up @@ -257,4 +258,4 @@ void generateQMark(int DID){
maxOne(DID, 5, 104); maxOne(DID, 5, 104);
maxOne(DID, 6, 106); maxOne(DID, 6, 106);
maxOne(DID, 7, 106); maxOne(DID, 7, 106);
} }
2 changes: 1 addition & 1 deletion python/api.py
Expand Up @@ -9,7 +9,7 @@
url = urllib.urlopen("https://opentdb.com/api.php?amount=10&type=boolean"); url = urllib.urlopen("https://opentdb.com/api.php?amount=10&type=boolean");
question = json.loads(url.read().decode()); question = json.loads(url.read().decode());


open('../cache/data.json', 'w').close(); open('../python/data.json', 'w').close();


with open('data.json', 'w') as outfile: with open('data.json', 'w') as outfile:
json.dump(question, outfile); json.dump(question, outfile);
Expand Down
2 changes: 1 addition & 1 deletion python/data.json
@@ -1 +1 @@
{"response_code": 0, "results": [{"category": "Entertainment: Video Games", "type": "boolean", "question": "Nintendo started out as a playing card manufacturer.", "difficulty": "medium", "correct_answer": "True", "incorrect_answers": ["False"]}, {"category": "Entertainment: Cartoon & Animations", "type": "boolean", "question": "In the "Shrek" film franchise, Donkey is played by Eddie Murphy.", "difficulty": "easy", "correct_answer": "True", "incorrect_answers": ["False"]}, {"category": "History", "type": "boolean", "question": "The first televised presidential debate was between Jimmy Carter and Gerald Ford.", "difficulty": "medium", "correct_answer": "False", "incorrect_answers": ["True"]}, {"category": "Entertainment: Film", "type": "boolean", "question": "The colour of the pills in the Matrix were Blue and Yellow.", "difficulty": "medium", "correct_answer": "False", "incorrect_answers": ["True"]}, {"category": "General Knowledge", "type": "boolean", "question": ""Ananas" is mostly used as the word for Pineapple in other languages.", "difficulty": "easy", "correct_answer": "True", "incorrect_answers": ["False"]}, {"category": "Entertainment: Video Games", "type": "boolean", "question": "The 2005 video game "Call of Duty 2: Big Red One" is not available on PC.", "difficulty": "easy", "correct_answer": "True", "incorrect_answers": ["False"]}, {"category": "Animals", "type": "boolean", "question": "The Platypus is a mammal.", "difficulty": "medium", "correct_answer": "True", "incorrect_answers": ["False"]}, {"category": "Entertainment: Film", "type": "boolean", "question": ""Cube", "Cube 2: Hypercube" and "Cube Zero" were directed by the same person.", "difficulty": "hard", "correct_answer": "False", "incorrect_answers": ["True"]}, {"category": "Animals", "type": "boolean", "question": "A caterpillar has more muscles than humans do.", "difficulty": "easy", "correct_answer": "True", "incorrect_answers": ["False"]}, {"category": "History", "type": "boolean", "question": "In World War ll, Great Britian used inflatable tanks on the ports of Great Britain to divert Hitler away from Normandy/D-day landing.", "difficulty": "easy", "correct_answer": "True", "incorrect_answers": ["False"]}]} {"response_code": 0, "results": [{"category": "Science: Mathematics", "type": "boolean", "question": "The Pythagorean theorem states that the square of the hypotenuse is equal to the product of the squares of the other two sides.", "difficulty": "medium", "correct_answer": "False", "incorrect_answers": ["True"]}, {"category": "General Knowledge", "type": "boolean", "question": "French is an official language in Canada.", "difficulty": "easy", "correct_answer": "True", "incorrect_answers": ["False"]}, {"category": "History", "type": "boolean", "question": "The Spitfire originated from a racing plane.", "difficulty": "easy", "correct_answer": "True", "incorrect_answers": ["False"]}, {"category": "History", "type": "boolean", "question": "If you grab the bladed end of a longsword in a specific way, you will not cut yourself.", "difficulty": "medium", "correct_answer": "True", "incorrect_answers": ["False"]}, {"category": "Entertainment: Video Games", "type": "boolean", "question": "In Pokémon, Arbok evolves into Seviper.", "difficulty": "easy", "correct_answer": "False", "incorrect_answers": ["True"]}, {"category": "Geography", "type": "boolean", "question": "Norway has a larger land area than Sweden.", "difficulty": "medium", "correct_answer": "False", "incorrect_answers": ["True"]}, {"category": "Entertainment: Music", "type": "boolean", "question": "Scatman John's real name was John Paul Larkin.", "difficulty": "easy", "correct_answer": "True", "incorrect_answers": ["False"]}, {"category": "Science: Computers", "type": "boolean", "question": "Linus Sebastian is the creator of the Linux kernel, which went on to be used in Linux, Android, and Chrome OS.", "difficulty": "medium", "correct_answer": "False", "incorrect_answers": ["True"]}, {"category": "General Knowledge", "type": "boolean", "question": "Dihydrogen Monoxide was banned due to health risks after being discovered in 1983 inside swimming pools and drinking water.", "difficulty": "easy", "correct_answer": "False", "incorrect_answers": ["True"]}, {"category": "Entertainment: Video Games", "type": "boolean", "question": "Activision created Battlefield 1.", "difficulty": "easy", "correct_answer": "False", "incorrect_answers": ["True"]}]}
22 changes: 13 additions & 9 deletions python/lighting.py
@@ -1,6 +1,6 @@
#!/usr/bin/python #!/usr/bin/python


import sys,os import sys,os,json


args = sys.argv; args = sys.argv;


Expand All @@ -25,17 +25,23 @@
teamB = [1, 1, 1, 1, 0, 0, 0, 0]; teamB = [1, 1, 1, 1, 0, 0, 0, 0];


def lightled(BCM_pin,status): def lightled(BCM_pin,status):
os.system('gpio -g write '+str(BCM_pin)+' '+str(status) ); os.system('gpio -g mode ' + str(BCM_pin) + ' out;')
os.system('gpio -g write '+str(BCM_pin)+' '+str(status) + ";");
#print(BCM_pin, status);


def render(): def render():
try: try:
i = 0;
for i in range(0, 8): for i in range(0, 8):
if(output[i] == 0): if(output[i] == 0):
lightled(lights[i],0); lightled(lights[i],0);
#print(lights[i], "low");
else: else:
lightled(lights[i],1); lightled(lights[i],1);
return True; #print(lights[i], "high");
except: return True;
except Exception as e:
print(e);
return False; return False;


if (len(args) == 1): if (len(args) == 1):
Expand All @@ -52,8 +58,6 @@ def render():
output = starter; output = starter;
output[int(args[1])] = 0; output[int(args[1])] = 0;


success = render(); render();
if(success):
print str(output); print str(output);
else:
print "ERROR:Unable to render";
28 changes: 16 additions & 12 deletions python/scoring.py
@@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python


# FETCH CMD ARGUMENTS # FETCH CMD ARGUMENTS
import sys, json import sys, json, serial
args = sys.argv; args = sys.argv;


# DEFINE VARIABLES # DEFINE VARIABLES
Expand All @@ -22,16 +22,20 @@ def calculate():
score[answer_team] = score[answer_team] + 5; score[answer_team] = score[answer_team] + 5;
else: else:
score[answer_team] = score[answer_team]; score[answer_team] = score[answer_team];

render();
print json.dumps(score); print json.dumps(score);


def render(): def render():

output_str = "";

serPort = serial.Serial("/dev/ttyACM0", 115200, timeout=1); # open serial port serPort = serial.Serial("/dev/ttyACM0", 115200, timeout=1); # open serial port


score_a = list(score[0]); score_a = list(str(score[0]));
score_b = list(score[1]); score_b = list(str(score[1]));


output = [0,0,0,0,0,0]; output = [" ", " ", " ", " ", " ", " "];
output_str


i=0; i=0;
for i in range(0,5): for i in range(0,5):
Expand All @@ -47,17 +51,17 @@ def render():
output[2] = score_a[2]; output[2] = score_a[2];


if(len(score_b) == 1): if(len(score_b) == 1):
output[3] = score_a[3]; output[3] = score_b[0];
elif (len(score_b) == 2): elif (len(score_b) == 2):
output[3] = score_a[3]; output[3] = score_b[0];
output[4] = score_a[4]; output[4] = score_b[1];
elif (len(score_b) == 3): elif (len(score_b) == 3):
output[3] = score_a[3]; output[3] = score_b[0];
output[4] = score_a[4]; output[4] = score_b[1];
output[5] = score_a[5]; output[5] = score_b[2];


for j in range(0,5): for j in range(0,5):
output_str = output_str + output[j]; output_str = output_str + str(output[j]);


serPort.write(str.encode(str(output_str))); serPort.write(str.encode(str(output_str)));
serPort.close(); serPort.close();
Expand Down

0 comments on commit d9a6d24

Please sign in to comment.