summaryrefslogtreecommitdiffstats
path: root/fiz/naloga/vodnaraketa/src/func.c
blob: 07bfd6ef033115bcf26367771fb964f00c821f5e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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");
}