Permalink
Browse files

Lighting and Matrix fixes

  • Loading branch information...
LUTC CSNET
LUTC CSNET committed Feb 23, 2018
1 parent 6af0171 commit d9a6d24cd7ca10580b673292cb31173bf809956d
Showing with 34 additions and 25 deletions.
  1. +3 −2 arduino/{ → matrix}/matrix.ino
  2. +1 −1 python/api.py
  3. +1 −1 python/data.json
  4. +13 −9 python/lighting.py
  5. +16 −12 python/scoring.py
@@ -10,7 +10,7 @@ using.
int matrix_buffer[] {255,255,255,255,255};
int charList[256];
int matrix_populate_delay = 0;
int matrix_update_delay = 1000;
int matrix_update_delay = 500;
int updates_per_second = 2;
@@ -152,6 +152,7 @@ void createCharList(){
charList[97] = 126;
charList[88] = 256; //Special Case for Do Not Update
charList[32] = 0; //Blank
charList[110] = 0; //Blank
charList[33] = 256; //Special Case for !
charList[63] = 256; //Special Case for ?
}
@@ -257,4 +258,4 @@ void generateQMark(int DID){
maxOne(DID, 5, 104);
maxOne(DID, 6, 106);
maxOne(DID, 7, 106);
}
}
@@ -9,7 +9,7 @@
url = urllib.urlopen("https://opentdb.com/api.php?amount=10&type=boolean");
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:
json.dump(question, outfile);
@@ -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"]}]}
@@ -1,6 +1,6 @@
#!/usr/bin/python
import sys,os
import sys,os,json
args = sys.argv;
@@ -25,17 +25,23 @@
teamB = [1, 1, 1, 1, 0, 0, 0, 0];
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():
try:
i = 0;
for i in range(0, 8):
if(output[i] == 0):
lightled(lights[i],0);
#print(lights[i], "low");
else:
lightled(lights[i],1);
return True;
except:
#print(lights[i], "high");
return True;
except Exception as e:
print(e);
return False;
if (len(args) == 1):
@@ -52,8 +58,6 @@ def render():
output = starter;
output[int(args[1])] = 0;
success = render();
if(success):
print str(output);
else:
print "ERROR:Unable to render";
render();
print str(output);
@@ -1,7 +1,7 @@
#!/usr/bin/python
# FETCH CMD ARGUMENTS
import sys, json
import sys, json, serial
args = sys.argv;
# DEFINE VARIABLES
@@ -22,16 +22,20 @@ def calculate():
score[answer_team] = score[answer_team] + 5;
else:
score[answer_team] = score[answer_team];
render();
print json.dumps(score);
def render():
output_str = "";
serPort = serial.Serial("/dev/ttyACM0", 115200, timeout=1); # open serial port
score_a = list(score[0]);
score_b = list(score[1]);
score_a = list(str(score[0]));
score_b = list(str(score[1]));
output = [0,0,0,0,0,0];
output_str
output = [" ", " ", " ", " ", " ", " "];
i=0;
for i in range(0,5):
@@ -47,17 +51,17 @@ def render():
output[2] = score_a[2];
if(len(score_b) == 1):
output[3] = score_a[3];
output[3] = score_b[0];
elif (len(score_b) == 2):
output[3] = score_a[3];
output[4] = score_a[4];
output[3] = score_b[0];
output[4] = score_b[1];
elif (len(score_b) == 3):
output[3] = score_a[3];
output[4] = score_a[4];
output[5] = score_a[5];
output[3] = score_b[0];
output[4] = score_b[1];
output[5] = score_b[2];
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.close();

0 comments on commit d9a6d24

Please sign in to comment.