Compare commits
No commits in common. "c79e15d7a1f5090bb8cf5e74d387a6cb93bc1699" and "3185b5ba277bf6651f8d88ec52fb1a6d165dcc0a" have entirely different histories.
c79e15d7a1
...
3185b5ba27
5 changed files with 64 additions and 72 deletions
15
.vscode/arduino.json
vendored
15
.vscode/arduino.json
vendored
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"configuration": "xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,eesz=4M2M,led=2,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=460800",
|
|
||||||
"board": "esp8266:esp8266:nodemcuv2",
|
|
||||||
"port": "/dev/tty.usbserial-110",
|
|
||||||
"programmer": "AVRISP mkII",
|
|
||||||
"sketch": "firmware/firmware.ino",
|
|
||||||
"includePath": [
|
|
||||||
"/Users/klaute/Documents/Arduino/libraries",
|
|
||||||
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include",
|
|
||||||
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/lib",
|
|
||||||
"/Applications/Arduino.app//Contents/Java/hardware/arduino/avr/libraries"
|
|
||||||
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/include",
|
|
||||||
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/x86_64-apple-darwin16.1.0/avr/include"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -272,23 +272,15 @@ if (document.getElementById('tab-tde').classList.contains('visible')) {
|
||||||
loadTCGraphData();
|
loadTCGraphData();
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
function updateLightStateAndPWMValues() {
|
function updateLightState() {
|
||||||
console.log('----> setting bri, power switch, and pwm data <----');
|
console.log('----> setting bri and power switch <----');
|
||||||
const promises = [];
|
|
||||||
for (let i = 1; i <= {{LIGHT_COUNT}}; i++) {
|
for (let i = 1; i <= {{LIGHT_COUNT}}; i++) {
|
||||||
const lightURL = `http://{{IP_ADDRESS}}/state?light=${i}`;
|
const lightURL = `http://{{IP_ADDRESS}}/state?light=${i}`;
|
||||||
promises.push(fetch(lightURL).then(response => response.json()));
|
fetch(lightURL).then(response => response.json()).then(data => {
|
||||||
}
|
|
||||||
Promise.all(promises)
|
|
||||||
.then(dataArray => {
|
|
||||||
for (let i = 1; i <= {{LIGHT_COUNT}}; i++) {
|
|
||||||
const data = dataArray[i - 1];
|
|
||||||
const briSlider = document.getElementById(`bri${i - 1}`);
|
const briSlider = document.getElementById(`bri${i - 1}`);
|
||||||
const briSliderVal = document.getElementById(`bri${i - 1}_val`);
|
const briSliderVal = document.getElementById(`bri${i - 1}_val`);
|
||||||
const onLinkOn = document.getElementById(`on${i - 1}_on`);
|
const onLinkOn = document.getElementById(`on${i - 1}_on`);
|
||||||
const onLinkOff = document.getElementById(`on${i - 1}_off`);
|
const onLinkOff = document.getElementById(`on${i - 1}_off`);
|
||||||
const pwmElement = document.getElementById(`light${i - 1}_pwm`);
|
|
||||||
const pwmElementTxt = document.getElementById(`light${i - 1}_pwm_txt`);
|
|
||||||
briSlider.value = data.bri;
|
briSlider.value = data.bri;
|
||||||
briSliderVal.innerHTML = (Math.round((data.bri * 100.0 / 255.0) * 100) / 100).toFixed(2);
|
briSliderVal.innerHTML = (Math.round((data.bri * 100.0 / 255.0) * 100) / 100).toFixed(2);
|
||||||
if (data.on == true) {
|
if (data.on == true) {
|
||||||
|
@ -298,18 +290,30 @@ onLinkOff.classList.remove('pure-button-primary');
|
||||||
onLinkOn.classList.remove('pure-button-primary');
|
onLinkOn.classList.remove('pure-button-primary');
|
||||||
onLinkOff.classList.add('pure-button-primary');
|
onLinkOff.classList.add('pure-button-primary');
|
||||||
}
|
}
|
||||||
|
}).catch(error => console.error(error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setInterval(updateLightState, 10000);
|
||||||
|
updateLightState();
|
||||||
|
function updatePWMValues() {
|
||||||
|
console.log('----> setting pwm data <----');
|
||||||
|
for (let i = 0; i < {{LIGHT_COUNT}}; i++) {
|
||||||
|
const lightID = i + 1;
|
||||||
|
const pwmElement = document.getElementById(`light${i}_pwm`);
|
||||||
|
const pwmElementTxt = document.getElementById(`light${i}_pwm_txt`);
|
||||||
if (pwmElement) {
|
if (pwmElement) {
|
||||||
|
const url = `http://{{IP_ADDRESS}}/state?light=${lightID}`;
|
||||||
|
fetch(url).then(response => response.json()).then(data => {
|
||||||
const pwmValue = ((Math.round((data.curpwm - ((data.curpwm >= {{PWM_MIN}}) ? {{PWM_MIN}} : 0)) / {{PWM_MAX}} * 10000) / 100).toFixed(2));
|
const pwmValue = ((Math.round((data.curpwm - ((data.curpwm >= {{PWM_MIN}}) ? {{PWM_MIN}} : 0)) / {{PWM_MAX}} * 10000) / 100).toFixed(2));
|
||||||
pwmElement.innerText = pwmValue.toString();
|
pwmElement.innerText = pwmValue.toString();
|
||||||
pwmElement.value = pwmValue;
|
pwmElement.value = pwmValue;
|
||||||
pwmElementTxt.innerText = pwmValue.toString();
|
pwmElementTxt.innerText = pwmValue.toString();
|
||||||
|
}).catch(error => console.error(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch(error => console.error(error));
|
|
||||||
}
|
}
|
||||||
updateLightStateAndPWMValues();
|
updatePWMValues();
|
||||||
setInterval(updateLightStateAndPWMValues, 5000);
|
setInterval(updatePWMValues, 5000);
|
||||||
var links = document.querySelectorAll('[id^="on"][id$="_off"]');
|
var links = document.querySelectorAll('[id^="on"][id$="_off"]');
|
||||||
links.forEach(function(link) {
|
links.forEach(function(link) {
|
||||||
link.addEventListener('click', function(event) {
|
link.addEventListener('click', function(event) {
|
||||||
|
@ -350,7 +354,7 @@ console.log('Error while sending data to server.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.send();
|
xhr.send();
|
||||||
updateLightStateAndPWMValues();
|
updateLightState();
|
||||||
this.classList.add('pure-button-primary');
|
this.classList.add('pure-button-primary');
|
||||||
document.getElementById('on'+id+'_on').classList.remove('pure-button-primary');
|
document.getElementById('on'+id+'_on').classList.remove('pure-button-primary');
|
||||||
});
|
});
|
||||||
|
@ -395,7 +399,7 @@ console.log('Error while sending data to server.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.send();
|
xhr.send();
|
||||||
updateLightStateAndPWMValues();
|
updateLightState();
|
||||||
this.classList.add('pure-button-primary');
|
this.classList.add('pure-button-primary');
|
||||||
document.getElementById('on'+id+'_off').classList.remove('pure-button-primary');
|
document.getElementById('on'+id+'_off').classList.remove('pure-button-primary');
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
<br>
|
||||||
<a href="#" id="save-button" class="pure-button pure-button-primary" onclick="sendDataToServer();">save</a>
|
<a href="#" id="save-button" class="pure-button pure-button-primary" onclick="sendDataToServer();">save</a>
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- end of tab-tde -->
|
</div> <!-- end of tab-tde -->
|
||||||
|
|
|
@ -317,26 +317,15 @@ setInterval(function() {
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
function updateLightStateAndPWMValues() {
|
function updateLightState() {
|
||||||
console.log('----> setting bri, power switch, and pwm data <----');
|
console.log('----> setting bri and power switch <----');
|
||||||
const promises = [];
|
|
||||||
|
|
||||||
for (let i = 1; i <= {{LIGHT_COUNT}}; i++) {
|
for (let i = 1; i <= {{LIGHT_COUNT}}; i++) {
|
||||||
const lightURL = `http://{{IP_ADDRESS}}/state?light=${i}`;
|
const lightURL = `http://{{IP_ADDRESS}}/state?light=${i}`;
|
||||||
promises.push(fetch(lightURL).then(response => response.json()));
|
fetch(lightURL).then(response => response.json()).then(data => {
|
||||||
}
|
|
||||||
|
|
||||||
Promise.all(promises)
|
|
||||||
.then(dataArray => {
|
|
||||||
for (let i = 1; i <= {{LIGHT_COUNT}}; i++) {
|
|
||||||
const data = dataArray[i - 1];
|
|
||||||
const briSlider = document.getElementById(`bri${i - 1}`);
|
const briSlider = document.getElementById(`bri${i - 1}`);
|
||||||
const briSliderVal = document.getElementById(`bri${i - 1}_val`);
|
const briSliderVal = document.getElementById(`bri${i - 1}_val`);
|
||||||
const onLinkOn = document.getElementById(`on${i - 1}_on`);
|
const onLinkOn = document.getElementById(`on${i - 1}_on`);
|
||||||
const onLinkOff = document.getElementById(`on${i - 1}_off`);
|
const onLinkOff = document.getElementById(`on${i - 1}_off`);
|
||||||
const pwmElement = document.getElementById(`light${i - 1}_pwm`);
|
|
||||||
const pwmElementTxt = document.getElementById(`light${i - 1}_pwm_txt`);
|
|
||||||
|
|
||||||
briSlider.value = data.bri;
|
briSlider.value = data.bri;
|
||||||
briSliderVal.innerHTML = (Math.round((data.bri * 100.0 / 255.0) * 100) / 100).toFixed(2);
|
briSliderVal.innerHTML = (Math.round((data.bri * 100.0 / 255.0) * 100) / 100).toFixed(2);
|
||||||
if (data.on == true) {
|
if (data.on == true) {
|
||||||
|
@ -346,20 +335,32 @@ function updateLightStateAndPWMValues() {
|
||||||
onLinkOn.classList.remove('pure-button-primary');
|
onLinkOn.classList.remove('pure-button-primary');
|
||||||
onLinkOff.classList.add('pure-button-primary');
|
onLinkOff.classList.add('pure-button-primary');
|
||||||
}
|
}
|
||||||
|
}).catch(error => console.error(error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setInterval(updateLightState, 10000);
|
||||||
|
updateLightState();
|
||||||
|
|
||||||
|
function updatePWMValues() {
|
||||||
|
console.log('----> setting pwm data <----');
|
||||||
|
for (let i = 0; i < {{LIGHT_COUNT}}; i++) {
|
||||||
|
const lightID = i + 1;
|
||||||
|
const pwmElement = document.getElementById(`light${i}_pwm`);
|
||||||
|
const pwmElementTxt = document.getElementById(`light${i}_pwm_txt`);
|
||||||
if (pwmElement) {
|
if (pwmElement) {
|
||||||
|
const url = `http://{{IP_ADDRESS}}/state?light=${lightID}`;
|
||||||
|
fetch(url).then(response => response.json()).then(data => {
|
||||||
const pwmValue = ((Math.round((data.curpwm - ((data.curpwm >= {{PWM_MIN}}) ? {{PWM_MIN}} : 0)) / {{PWM_MAX}} * 10000) / 100).toFixed(2));
|
const pwmValue = ((Math.round((data.curpwm - ((data.curpwm >= {{PWM_MIN}}) ? {{PWM_MIN}} : 0)) / {{PWM_MAX}} * 10000) / 100).toFixed(2));
|
||||||
|
//console.log('curpwm[' + i + '] = ' + data.curpwm + ' = ' + pwmValue);
|
||||||
pwmElement.innerText = pwmValue.toString();
|
pwmElement.innerText = pwmValue.toString();
|
||||||
pwmElement.value = pwmValue;
|
pwmElement.value = pwmValue;
|
||||||
pwmElementTxt.innerText = pwmValue.toString();
|
pwmElementTxt.innerText = pwmValue.toString();
|
||||||
|
}).catch(error => console.error(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch(error => console.error(error));
|
|
||||||
}
|
}
|
||||||
|
updatePWMValues();
|
||||||
updateLightStateAndPWMValues();
|
setInterval(updatePWMValues, 5000);
|
||||||
setInterval(updateLightStateAndPWMValues, 5000);
|
|
||||||
|
|
||||||
// Suche nach allen Links auf der Seite mit IDs von on0_off bis on3_off
|
// Suche nach allen Links auf der Seite mit IDs von on0_off bis on3_off
|
||||||
var links = document.querySelectorAll('[id^="on"][id$="_off"]');
|
var links = document.querySelectorAll('[id^="on"][id$="_off"]');
|
||||||
|
@ -409,7 +410,7 @@ links.forEach(function(link) {
|
||||||
|
|
||||||
// Sende die Anfrage im Hintergrund
|
// Sende die Anfrage im Hintergrund
|
||||||
xhr.send();
|
xhr.send();
|
||||||
updateLightStateAndPWMValues();
|
updateLightState();
|
||||||
this.classList.add('pure-button-primary');
|
this.classList.add('pure-button-primary');
|
||||||
document.getElementById('on'+id+'_on').classList.remove('pure-button-primary');
|
document.getElementById('on'+id+'_on').classList.remove('pure-button-primary');
|
||||||
});
|
});
|
||||||
|
@ -462,7 +463,7 @@ links.forEach(function(link) {
|
||||||
|
|
||||||
// Sende die Anfrage im Hintergrund
|
// Sende die Anfrage im Hintergrund
|
||||||
xhr.send();
|
xhr.send();
|
||||||
updateLightStateAndPWMValues();
|
updateLightState();
|
||||||
this.classList.add('pure-button-primary');
|
this.classList.add('pure-button-primary');
|
||||||
document.getElementById('on'+id+'_off').classList.remove('pure-button-primary');
|
document.getElementById('on'+id+'_off').classList.remove('pure-button-primary');
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<br>
|
||||||
<a href="#" id="save-button" class="pure-button pure-button-primary" onclick="sendDataToServer();">save</a>
|
<a href="#" id="save-button" class="pure-button pure-button-primary" onclick="sendDataToServer();">save</a>
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- end of tab-tde -->
|
</div> <!-- end of tab-tde -->
|
||||||
|
|
Loading…
Reference in a new issue