Skip to content

Commit

Permalink
0.14.00: major modification:
Browse files Browse the repository at this point in the history
- need to update readme to explain changes
- favicon and icons: now created seeparately and per environment (platformio) - readme to be updated.
- changed web page (index.htm) for led device name handling
  • Loading branch information
tobi01001 committed Nov 13, 2020
1 parent 22f121b commit 26ceb77
Show file tree
Hide file tree
Showing 78 changed files with 1,091 additions and 144 deletions.
89 changes: 51 additions & 38 deletions data/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ ws.onmessage = function(evt) {
{
if(DEBUGME) console.log("Received field data for field " + data.name + " with " + data.value);
updateFieldValue(data.name, data.value);

} else if (data.Client != undefined) {
if(DEBUGME) console.log("Received Client info with from ID " + data.Client + ", Status: " + data.Status);
} else {
Expand Down Expand Up @@ -120,46 +119,60 @@ function updateStatus(newStatus, keepMessage = false, timeout = 4000)
}

$(document).ready(function() {
updateStatus("Connecting, please wait...", true);

$.get(urlBase + "/all", function(data) {
updateStatus("Loading, please wait...", true);

$.each(data, function(index, field) {
//if(DEBUGME) console.log("Field " + field.label + " with type " + field.type);
if (field.type == fieldtype.NumberFieldType) {
addNumberField(field);
} else if (field.type == fieldtype.TitleFieldType) {
if (document.title != field.label) {
document.title = field.label;
$("#nameLink").html(field.label);
}
} else if (field.type == fieldtype.BooleanFieldType) {
addBooleanField(field);
} else if (field.type == fieldtype.SelectFieldType) {
addSelectField(field);
} else if (field.type == fieldtype.ColorFieldType) {
// addColorFieldPalette(field); // removed this to save space on the page. no need currently
addColorFieldPicker(field);
} else if (field.type == fieldtype.SectionFieldType) {
addSectionField(field);
updateStatus("Connecting, please wait...", true);
$.get(urlBase + "/all", function(data) {
updateStatus("Loading, please wait...", true);

$.each(data, function(index, field) {
//if(DEBUGME) console.log("Field " + field.label + " with type " + field.type);
if (field.type == fieldtype.NumberFieldType) {
addNumberField(field);
} else if (field.type == fieldtype.TitleFieldType) {
/*
if (document.title != field.label) {
document.title = field.label;
$("#nameLink").html(field.label);
}
});

$(".minicolors").minicolors({
theme: "bootstrap",
changeDelay: 200,
control: "brightness", // changed to sqare one with brightness to the side
format: "rgb",
inline: true,
swatches: ["FF0000", "FF8000", "FFFF00", "00FF00", "00FFFF", "0000FF", "FF00FF", "FFFFFF"] // some colors from the previous list
});

updateStatus("Ready", true);
*/
} else if (field.type == fieldtype.BooleanFieldType) {
addBooleanField(field);
} else if (field.type == fieldtype.SelectFieldType) {
addSelectField(field);
} else if (field.type == fieldtype.ColorFieldType) {
// addColorFieldPalette(field); // removed this to save space on the page. no need currently
addColorFieldPicker(field);
} else if (field.type == fieldtype.SectionFieldType) {
addSectionField(field);
}
});
$(".minicolors").minicolors({
theme: "bootstrap",
changeDelay: 200,
control: "brightness", // changed to sqare one with brightness to the side
format: "rgb",
inline: true,
swatches: ["FF0000", "FF8000", "FFFF00", "00FF00", "00FFFF", "0000FF", "FF00FF", "FFFFFF"] // some colors from the previous list
});
})
.fail(function(errorThrown) {
console.log("error: " + errorThrown);
});
console.log("error: " + errorThrown);
})
.done(function(name, value, test) {
updateStatus("Structure ready, updating values", true);
$.get(urlBase + "/allvalues", function(rec) {
updateStatus("Loading, status...", true);
for(i=0; i<rec.values.length; i++) {
if(DEBUGME) console.log("Name: " + rec.values[i].name + " value " + rec.values[i].value);
updateFieldValue( rec.values[i].name, rec.values[i].value);
}
})
.fail(function(errorThrown) {
console.log("error: " + errorThrown);
})
.done(function(name, value, test) {
updateStatus("Ready", true);
});
});
});

function addNumberField(field) {
Expand Down
Binary file modified data/favicon.ico
Binary file not shown.
Binary file removed data/images/atom196.png
Binary file not shown.
139 changes: 139 additions & 0 deletions favicon_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
Import("env", "projenv")

print(env)
print(projenv)

import fileinput
from shutil import copy
from os import listdir
from os.path import isfile, join, isdir
from random import random

def_src = "./images/default/"
env_src = "./images/" + env['PIOENV'] + "/"

dest = "./data/images/"

## files (names) in the default folder are expected in the env folder
files_to_copy = [f for f in listdir(def_src) if isfile(join(def_src, f))]

print("\nRUNNING SCRIPT\n")

print("\tFiles to copy:")
for fi in files_to_copy :
print("\t\t" + fi)

if(isdir(env_src)) :
print("\nFound " + env['PIOENV'] + " folder. Will use favicons within.\n")
path = env_src
else :
print("\nNo " + env['PIOENV'] + " folder. Will use default icons from " + def_src + "\n")
path = def_src

def before_buildfs(source, target, env):
print("Copy files before the building littlefs:")
led_name = env.GetProjectOption("led_name")
## files not in env specific folder will be copied from default
for f in files_to_copy:
src = join(path , f)
dst = join(dest , f)
if(isfile(src)):
print("\t\tCOPY favicon: " + src + "\tto " + dst)
copy(src, dst)
else:
print("\t\tCOPY from default: " + join(def_src, f) + "\tto " + dst)
copy(join(def_src, f) , dst)


fav = join(path , "favicon.ico")
if(isfile(fav)):
print("\t\tCOPY: " + fav + "\tto " + "./data/favicon.ico")
copy(fav, "./data/favicon.ico")

print("\n\tPreparing index.htm")

print("\t\tLED Name: " + led_name)
if(led_name == ""):
led_name = "LED Control"

if(isfile("./images/index.htm")):
copy("./images/index.htm", "./data/index.htm")

if(isfile("./images/browserconfig.xml")):
copy("./images/browserconfig.xml", "./data/images/browserconfig.xml")

if(isfile("./images/site.webmanifest")):
copy("./images/site.webmanifest", "./data/images/site.webmanifest")

with fileinput.FileInput("./data/index.htm", inplace=True) as file:
for line in file:
print(line.replace("%TITLE%", led_name), end='')

with fileinput.FileInput("./data/index.htm", inplace=True) as file:
for line in file:
print(line.replace("%RANDOM%", str(random())), end='')

with fileinput.FileInput("./data/images/site.webmanifest", inplace=True) as file:
for line in file:
print(line.replace("%TITLE%", led_name), end='')


print("\nFINISHED Script before building littlefs\n\n")

def before_build(source, target, env):
print("Preparing Build")
led_name = env.GetProjectOption("led_name")
## additional defines
import urllib

if(led_name == ""):
led_name = "LED Control"

print("\t\tLED Name: " + led_name)

led_name_url = str(led_name)
led_name_url = led_name_url.replace(" ","_")

led_name_url = urllib.parse.quote(led_name_url)

print("\t\tLED URL: " + led_name_url)

if(isfile("./images/defaults.h")):
copy("./images/defaults.h", "./include/defaults.h")

with fileinput.FileInput("./include/defaults.h", inplace=True) as file:
for line in file:
print(line.replace("%LEDNAME%", led_name_url), end='')
print("\nFINISHED Script Before Build\n\n")

def after_build(source, target, env):
print("Build done, deleting copied files...")
from os import remove
remove("./include/defaults.h")
print("\nFINISHED Script After Build\n\n")

def after_buildfs(source, target, env):
print("\nlittlefs.bin finished, deleting copied files...")
from os import remove
if(isfile("./data/images/site.webmanifest")):
remove("./data/images/site.webmanifest")
if(isfile("./data/index.htm")):
remove("./data/index.htm")
if(isfile("./data/images/browserconfig.xml")):
remove("./data/images/browserconfig.xml")
for f in files_to_copy:
dst = join(dest , f)
if(isfile(dst)):
remove(dst)

print("\nFINISHED Script After FS Build\n\n")

env.AddPreAction("$BUILD_DIR/littlefs.bin", before_buildfs)
env.AddPostAction("$BUILD_DIR/littlefs.bin", after_buildfs)

#env.AddPreAction("", before_build)
env.AddPostAction("buildprog", after_build)

before_build("","",env)

print("\nFINISHED Script\n\n")
3 changes: 3 additions & 0 deletions git_rev_macro.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import subprocess
import urllib

revision = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()

Expand All @@ -8,3 +9,5 @@

print("'-DPIO_SRC_REV=\"%s\"'" % revision)
print("'-DPIO_SRC_BRANCH=\"%s\"'" % branch)


Binary file added images/Flur/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Flur/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Flur/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Flur/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Flur/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Flur/favicon.ico
Binary file not shown.
52 changes: 52 additions & 0 deletions images/Flur/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Flur/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions images/Flur/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Norah/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Norah/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Norah/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Norah/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Norah/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Norah/favicon.ico
Binary file not shown.
Loading

0 comments on commit 26ceb77

Please sign in to comment.