Compare commits
No commits in common. "ae97de4ef01d24a166223d75ad53515747b8bd18" and "5cbe653063db5a4da4d1b3fdc2e99cc9f252d835" have entirely different histories.
ae97de4ef0
...
5cbe653063
|
|
@ -6,4 +6,3 @@
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
schema/hannabox/hannabox-backups/
|
schema/hannabox/hannabox-backups/
|
||||||
schema/hannabox/*.lck
|
schema/hannabox/*.lck
|
||||||
.copilot
|
|
||||||
|
|
|
||||||
|
|
@ -44,15 +44,6 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||||
|
|
||||||
<form method="POST" action="/upload" enctype="multipart/form-data"><input type="file" name="data"/><input type="submit" name="upload" value="Upload" title="Upload File"></form>
|
<form method="POST" action="/upload" enctype="multipart/form-data"><input type="file" name="data"/><input type="submit" name="upload" value="Upload" title="Upload File"></form>
|
||||||
|
|
||||||
<h2>Edit RFID Mapping</h2>
|
|
||||||
<form id="editMappingForm">
|
|
||||||
<label for="rfid">RFID:</label>
|
|
||||||
<input type="text" id="rfid" name="rfid" required><br>
|
|
||||||
<label for="song">Song:</label>
|
|
||||||
<input type="text" id="song" name="song" required><br>
|
|
||||||
<button type="button" onclick="editMapping()">Update Mapping</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
setInterval(getState, 4000);
|
setInterval(getState, 4000);
|
||||||
setInterval(updateProgress, 500); // Update progress every second
|
setInterval(updateProgress, 500); // Update progress every second
|
||||||
|
|
@ -189,20 +180,6 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function editMapping() {
|
|
||||||
var rfid = document.getElementById('rfid').value;
|
|
||||||
var song = document.getElementById('song').value;
|
|
||||||
var xhr = new XMLHttpRequest();
|
|
||||||
xhr.open("POST", "/edit_mapping", true);
|
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
|
||||||
xhr.send("rfid=" + encodeURIComponent(rfid) + "&song=" + encodeURIComponent(song));
|
|
||||||
xhr.onreadystatechange = function() {
|
|
||||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
|
||||||
alert("Mapping updated successfully!");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>)rawliteral";
|
</html>)rawliteral";
|
||||||
34
src/main.cpp
34
src/main.cpp
|
|
@ -176,11 +176,10 @@ void handleUpload(AsyncWebServerRequest *request, String filename, size_t index,
|
||||||
|
|
||||||
uint32_t getBatteryVoltageMv() {
|
uint32_t getBatteryVoltageMv() {
|
||||||
uint32_t voltage = analogReadMilliVolts(BAT_VOLTAGE_PIN);
|
uint32_t voltage = analogReadMilliVolts(BAT_VOLTAGE_PIN);
|
||||||
voltage *= 2;//*2 because of the voltage divider.
|
|
||||||
Serial.print("Battery Voltage: ");
|
Serial.print("Battery Voltage: ");
|
||||||
Serial.println(voltage);
|
Serial.println(voltage*2);
|
||||||
Serial.println(" mV");
|
Serial.println(" mV");
|
||||||
return voltage;
|
return voltage*2;//*2 because of the voltage divider.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -366,33 +365,6 @@ String getState()
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to save the rfid_map to the mapping file
|
|
||||||
void saveMappingToFile(const char *filename) {
|
|
||||||
File file = SD.open(filename, FILE_WRITE);
|
|
||||||
if (file) {
|
|
||||||
for (const auto &pair : rfid_map) {
|
|
||||||
file.println(pair.first + "=" + pair.second);
|
|
||||||
}
|
|
||||||
file.close();
|
|
||||||
Serial.println("Mapping saved to file.");
|
|
||||||
} else {
|
|
||||||
Serial.println("Error opening file for writing.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to handle edit requests
|
|
||||||
void editMapping(AsyncWebServerRequest *request) {
|
|
||||||
if (request->hasParam("rfid", true) && request->hasParam("song", true)) {
|
|
||||||
String rfid = request->getParam("rfid", true)->value();
|
|
||||||
String song = request->getParam("song", true)->value();
|
|
||||||
rfid_map[rfid] = song;
|
|
||||||
saveMappingToFile(mapping_file.c_str());
|
|
||||||
request->send(200, "text/plain", "Mapping updated");
|
|
||||||
} else {
|
|
||||||
request->send(400, "text/plain", "Invalid parameters");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<String, String> readDataFromFile(const char *filename) {
|
std::map<String, String> readDataFromFile(const char *filename) {
|
||||||
|
|
||||||
File file = SD.open(filename);
|
File file = SD.open(filename);
|
||||||
|
|
@ -673,8 +645,6 @@ void setup()
|
||||||
|
|
||||||
server.on("/volume", HTTP_POST, volume_action);
|
server.on("/volume", HTTP_POST, volume_action);
|
||||||
|
|
||||||
server.on("/edit_mapping", HTTP_POST, editMapping);
|
|
||||||
|
|
||||||
// run handleUpload function when any file is uploaded
|
// run handleUpload function when any file is uploaded
|
||||||
server.on("/upload", HTTP_POST, [](AsyncWebServerRequest *request) {
|
server.on("/upload", HTTP_POST, [](AsyncWebServerRequest *request) {
|
||||||
request->send(200);
|
request->send(200);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue