-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigCommands.js
78 lines (69 loc) · 1.87 KB
/
configCommands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//ALL DATA SENT OUT FROM THE GUI TOO THE BOARD HERE
// to sanitize strings **********
function checkUserString(userString, lengthCheck) {
if (match(userString, "#") != null || match(userString, ",") != null) {
return 'error no # or comma';
}
if (userString.length >= lengthCheck) {
return 'error too long';
}
return null;
}
function saveWiFi() {
let sanitizer = checkUserString(ssidInput.value(), 50);
if (sanitizer != null) {
ssidInput.value(sanitizer);
return;
}
sanitizer = checkUserString(pwInput.value(), 50);
if (sanitizer != null) {
ssidInput.value(sanitizer);
return;
}
if (pwInput.value().length < 8) {
ssidInput.value('error pw too short');
return;
}
if (ssidInput.value() == "debugshow") {
DebugInput.show();
DebugButton.show();
} else if (ssidInput.value() == "debughide") {
DebugInput.hide();
DebugButton.hide();
} else {
sendData("#wifi," + ssidInput.value() + "," + pwInput.value()) + ",";
}
}
function mouseReleased() {
if (lastSliderStatus != AlexaStatusSlider.value()) {
if (AlexaStatusSlider.value() == "0" && wifiConnected) {
sendData("#alexaOff");
} else {
sendData("#alexaOn");
}
lastSliderStatus = AlexaStatusSlider.value();
}
}
function pickerColorChanged(){
colorMode(HSB,255);
//console.log(hue(ColorPicker.value()));
hueInput = hue(color(ColorPicker.value()));
satInput = saturation(color(ColorPicker.value()));
briInput = brightness(color(ColorPicker.value()));
sendData('#setColor,'+hueInput+','+satInput+','+briInput);
colorMode(RGB,255);
}
function resetCommand() {
sendData("#reset,");
disconnectBle();
}
function sendDebugData() {
sendData(DebugInput.value());
}
function openTab() {
window.open("https://github.com/S-A-M-J/wordclockUpdater/releases", "_blank");
}
function activateOTA() {
sendData("#OTAOn,");
otaStatus = "off";
}