summaryrefslogtreecommitdiffstats
path: root/fiz/naloga/vodnaraketa/src/func.c
diff options
context:
space:
mode:
authorsijanec <anton@sijanec.eu>2021-05-25 07:07:16 +0200
committersijanec <anton@sijanec.eu>2021-05-25 07:07:16 +0200
commit71a466c66b3476d5aa58c3fc6de2d77d10d625d3 (patch)
tree2a608e45350a2dc7e266963eb3ae201feb94f211 /fiz/naloga/vodnaraketa/src/func.c
parenthttps://zapiski.xn--ijanec-9jb.eu/p/psi# (diff)
downloadsola-gimb-2-71a466c66b3476d5aa58c3fc6de2d77d10d625d3.tar
sola-gimb-2-71a466c66b3476d5aa58c3fc6de2d77d10d625d3.tar.gz
sola-gimb-2-71a466c66b3476d5aa58c3fc6de2d77d10d625d3.tar.bz2
sola-gimb-2-71a466c66b3476d5aa58c3fc6de2d77d10d625d3.tar.lz
sola-gimb-2-71a466c66b3476d5aa58c3fc6de2d77d10d625d3.tar.xz
sola-gimb-2-71a466c66b3476d5aa58c3fc6de2d77d10d625d3.tar.zst
sola-gimb-2-71a466c66b3476d5aa58c3fc6de2d77d10d625d3.zip
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");
+}