add RTC
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
|
||||
<div class="row mb-3">
|
||||
|
||||
<div class="col-lg-4 col-12">
|
||||
<div class="col-lg-3 col-12">
|
||||
<h3 class="mt-4">Parameters</h3>
|
||||
|
||||
<form>
|
||||
@@ -94,11 +94,41 @@
|
||||
<!--<button type="submit" class="btn btn-primary">Submit</button>-->
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- CLOCK-->
|
||||
<div class="col-lg-3 col-12">
|
||||
|
||||
<h3 class="mt-4">Clock</h3>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input class="form-check-input" type="checkbox" value="" id="check_RTC" onchange="update_config('i2c_RTC', this.checked)">
|
||||
<label class="form-check-label" for="check_RTC">
|
||||
RTC module (DS3231)
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="sys_local_time" class="form-label">System time (local)</label>
|
||||
<input type="text" class="form-control" id="sys_local_time" disabled>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="sys_UTC_time" class="form-label">System time (UTC)</label>
|
||||
<input type="text" class="form-control" id="sys_UTC_time" disabled>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="RTC_utc_time" class="form-label">RTC time (UTC)</label>
|
||||
<input type="text" class="form-control" id="RTC_utc_time" disabled>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- UPDATE-->
|
||||
|
||||
<div class="col-lg-4 col-12">
|
||||
<h3 class="mt-4">Updates</h3>
|
||||
|
||||
|
||||
<button type="submit" class="btn btn-primary" onclick="updateGitPull()">Update firmware</button>
|
||||
|
||||
</div>
|
||||
@@ -137,6 +167,7 @@
|
||||
});
|
||||
|
||||
window.onload = function() {
|
||||
|
||||
fetch('../config.json') // Replace 'deviceID.txt' with 'config.json'
|
||||
.then(response => response.json()) // Parse response as JSON
|
||||
.then(data => {
|
||||
@@ -156,6 +187,10 @@ window.onload = function() {
|
||||
const checkbox = document.getElementById("check_bme280");
|
||||
checkbox.checked = data.i2c_BME;
|
||||
|
||||
//get BME check
|
||||
const checkbox_RTC = document.getElementById("check_RTC");
|
||||
checkbox_RTC.checked = data.i2c_RTC;
|
||||
|
||||
//loop activation
|
||||
const flex_loop = document.getElementById("flex_loop");
|
||||
flex_loop.checked = data.loop_activation;
|
||||
@@ -176,20 +211,37 @@ window.onload = function() {
|
||||
const device_ID = document.getElementById("device_ID");
|
||||
device_ID.value = data.deviceID.toUpperCase();
|
||||
|
||||
//get local RTC
|
||||
$.ajax({
|
||||
url: 'launcher.php?type=RTC_time',
|
||||
dataType: 'text', // Specify that you expect a JSON response
|
||||
method: 'GET', // Use GET or POST depending on your needs
|
||||
success: function(response) {
|
||||
console.log("Local RTC: " + response);
|
||||
const RTC_Element = document.getElementById("RTC_time");
|
||||
RTC_Element.textContent = response;
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('AJAX request failed:', status, error);
|
||||
}
|
||||
});
|
||||
//get system time and RTC module
|
||||
$.ajax({
|
||||
url: 'launcher.php?type=sys_RTC_module_time',
|
||||
dataType: 'json', // Specify that you expect a JSON response
|
||||
method: 'GET', // Use GET or POST depending on your needs
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
// Update the input fields with the received JSON data
|
||||
document.getElementById("sys_local_time").value = response.system_local_time;
|
||||
document.getElementById("sys_UTC_time").value = response.system_utc_time;
|
||||
document.getElementById("RTC_utc_time").value = response.rtc_module_time;
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('AJAX request failed:', status, error);
|
||||
}
|
||||
});
|
||||
|
||||
//get local RTC
|
||||
$.ajax({
|
||||
url: 'launcher.php?type=RTC_time',
|
||||
dataType: 'text', // Specify that you expect a JSON response
|
||||
method: 'GET', // Use GET or POST depending on your needs
|
||||
success: function(response) {
|
||||
console.log("Local RTC: " + response);
|
||||
const RTC_Element = document.getElementById("RTC_time");
|
||||
RTC_Element.textContent = response;
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('AJAX request failed:', status, error);
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
.catch(error => console.error('Error loading config.json:', error));
|
||||
@@ -202,6 +254,7 @@ function update_config(param, value){
|
||||
url: 'launcher.php?type=update_config¶m='+param+'&value='+value,
|
||||
dataType: 'text', // Specify that you expect a JSON response
|
||||
method: 'GET', // Use GET or POST depending on your needs
|
||||
cache: false, // Prevent AJAX from caching
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
},
|
||||
@@ -217,6 +270,8 @@ function updateGitPull(){
|
||||
$.ajax({
|
||||
url: 'launcher.php?type=git_pull',
|
||||
method: 'GET', // Use GET or POST depending on your needs
|
||||
dataType: 'text', // Specify that you expect a JSON response
|
||||
|
||||
success: function(response) {
|
||||
// Handle success response if needed
|
||||
console.log(response);
|
||||
|
||||
Reference in New Issue
Block a user