Le support aux utilisateurs et les demandes de création de comptes externes doivent être faites depuis les issues du projet GitLab HEFR (https://gitlab.forge.hefr.ch/forge-hefr/gitlab-hefr)

Commit fc9ff8b2 authored by Samuel Baula's avatar Samuel Baula
Browse files

Code for coach

parent 0748efc8
# A web-base interface to generate led patterns
code for the coach : https://gitlab.forge.hefr.ch/samuel.baula/coachinterface
No preview for this file type
No preview for this file type
......@@ -12,7 +12,7 @@ router.get('/', function (req, res, next) {
res.status(200);
//TO DO
res.end(JSON.stringify(pattern));
getPattern = false;
//getPattern = false;
}
else {
res.setHeader('Content-Type', 'application/json');
......@@ -58,18 +58,27 @@ function hexToRgb(hex) {
function generateCode() {
//initialisation
pattern.code = "from matrix_lite import led\nimport time\nfrom time import sleep\n#init\neverloop = ['black'] * led.length\n";
for (var i = 0; i < 18; i++) {
var rgb = hexToRgb(pattern.colors[0][i]);
pattern.code += "everloop[" + i + "] = {'r':" + rgb.r + ", 'g':" + rgb.g + ", 'b':" + rgb.b + ", 'w':0 }\n";
}
pattern.code += "everloop.append(everloop.pop(0))\n";
pattern.code += "led.set(everloop)\ni = 0\n";
//function
pattern.code += "def " + pattern.patternName + "():\n";
pattern.code += "def execute_pattern():\n";
pattern.code += "\tglobal i\n";
for (var i = 0; i < pattern.colors.length; i++) {
pattern.code += "\tif i == " + i + " :\n";
for (var j = 0; j < 18; j++) {
var rgb = hexToRgb(pattern.colors[i][j]);
var rgb;
if (j == 17) {
rgb = hexToRgb(pattern.colors[i][0]);
}
else {
rgb = hexToRgb(pattern.colors[i][j+1]);
}
pattern.code += "\t\teverloop[" + j + "] = {'r':" + rgb.r + ", 'g':" + rgb.g + ", 'b':" + rgb.b + ", 'w':0 }\n";
pattern.code += "\t\tled.set(everloop)\n";
}
......@@ -81,6 +90,8 @@ function generateCode() {
}
pattern.code += "\t\tsleep(" + pattern.times[i] + ")\n";
}
pattern.code += "\tif i == " + pattern.times.length + " :\n";
pattern.code += "\t\ti = 0\n";
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment