summaryrefslogtreecommitdiffstats
path: root/fiz/naloga/vodnaraketa/src/func.c
diff options
context:
space:
mode:
Diffstat (limited to 'fiz/naloga/vodnaraketa/src/func.c')
-rw-r--r--fiz/naloga/vodnaraketa/src/func.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/fiz/naloga/vodnaraketa/src/func.c b/fiz/naloga/vodnaraketa/src/func.c
new file mode 100644
index 0000000..07bfd6e
--- /dev/null
+++ b/fiz/naloga/vodnaraketa/src/func.c
@@ -0,0 +1,31 @@
+const int str2pin_map[] = {
+ D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ A0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+int str2pin(const char * s) {
+ if (s[0] >= '0' && s[0] <= '9')
+ return atoi(s);
+ return str2pin_map[atoi(s+1) + ((s[0]=='A') ? 20 : 0)];
+}
+
+/* reads settings into json object */
+void load_settings () {
+ if (LittleFS.exists("settings.json")) {
+ File s = LittleFS.open("settings.json", "r");
+ if (s)
+ deserializeJson(settings, s);
+ s.close();
+ }
+}
+
+/* stores settings from json object to file */
+void store_settings () {
+ File s = LittleFS.open("settings.json", "w");
+ serializeJson(settings, s);
+ s.close();
+}
+
+void notFound(AsyncWebServerRequest *request) {
+ request->send(404, "text/plain", "404");
+}