delete, move files
This commit is contained in:
parent
ae97de4ef0
commit
ec5610c919
|
|
@ -7,3 +7,5 @@
|
|||
schema/hannabox/hannabox-backups/
|
||||
schema/hannabox/*.lck
|
||||
.copilot
|
||||
|
||||
.codegpt
|
||||
|
|
@ -121,6 +121,9 @@ Chip to use: MCP73837?
|
|||
|
||||
### Amplifier
|
||||
|
||||
The Chip is a MAX98357 Class D Amp.
|
||||
Pin 1 is on the lower left side, seen from the letters in correct orientation.
|
||||
|
||||
#### SD / MODE
|
||||
|
||||
This pin is used for shutdown mode but is also used for setting which channel is output. It's a little confusing but essentially:
|
||||
|
|
@ -133,6 +136,7 @@ This is compounded by an internal 100K pulldown resistor on SD so you need to us
|
|||
|
||||
For the breakout board, there's a 1Mohm resistor from SD to Vin which, when powering from 5V will give you the 'stereo average' output. If you want left or right channel only, or if you are powering from non-5V power, you may need to experiment with different resistors to get the desired voltage on SD
|
||||
|
||||
|
||||

|
||||
|
||||
## Links
|
||||
|
|
|
|||
30
src/main.cpp
30
src/main.cpp
|
|
@ -174,6 +174,33 @@ void handleUpload(AsyncWebServerRequest *request, String filename, size_t index,
|
|||
}
|
||||
}
|
||||
|
||||
void handleMoveFile(AsyncWebServerRequest *request) {
|
||||
String from = request->arg("from");
|
||||
String to = request->arg("to");
|
||||
|
||||
if (SD.exists(from)) {
|
||||
SD.rename(from.c_str(), to.c_str());
|
||||
Serial.println("Moved file: " + from + " to " + to);
|
||||
request->send(200, "text/plain", "File moved successfully.");
|
||||
} else {
|
||||
Serial.println("File not found: " + from);
|
||||
request->send(404, "text/plain", "File not found.");
|
||||
}
|
||||
}
|
||||
|
||||
void handleDeleteFile(AsyncWebServerRequest *request) {
|
||||
String filename = request->arg("filename");
|
||||
|
||||
if (SD.exists(filename)) {
|
||||
SD.remove(filename.c_str());
|
||||
Serial.println("Deleted file: " + filename);
|
||||
request->send(200, "text/plain", "File deleted successfully.");
|
||||
} else {
|
||||
Serial.println("File not found: " + filename);
|
||||
request->send(404, "text/plain", "File not found.");
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t getBatteryVoltageMv() {
|
||||
uint32_t voltage = analogReadMilliVolts(BAT_VOLTAGE_PIN);
|
||||
voltage *= 2;//*2 because of the voltage divider.
|
||||
|
|
@ -680,6 +707,9 @@ void setup()
|
|||
request->send(200);
|
||||
}, handleUpload);
|
||||
|
||||
server.on("/move_file", HTTP_GET, handleMoveFile);
|
||||
server.on("/delete_file", HTTP_GET, handleDeleteFile);
|
||||
|
||||
server.begin();
|
||||
Serial.println("Wifi initialized.");
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue