Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit7bd9f1df7f9636e3b63ed40c16966d1e54377a98 (patch)
Author
 Syndamia <kamen@syndamia.com>
2024-05-28 11:32:19 +0300
Committer
 Syndamia <kamen@syndamia.com>
2024-05-28 11:32:19 +0300
Files95ab57cc9fb25e4db919d4e96fbda76f51921c0e
uni-projects-7bd9f1df7f9636e3b63ed40c16966d1e54377a98.tar
uni-projects-7bd9f1df7f9636e3b63ed40c16966d1e54377a98.tar.gz
uni-projects-7bd9f1df7f9636e3b63ed40c16966d1e54377a98.zip
Parent07b7e346615102fc90dac86d6a7dcff71a3dac16 (diff)
[iot/goam] Added display invertion setting
diff --git a/Year 3/Internet of things/goam/main/main.c b/Year 3/Internet of things/goam/main/main.c
index bceab07..32a49a2 100644
--- a/Year 3/Internet of things/goam/main/main.c
+++ b/Year 3/Internet of things/goam/main/main.c
@@ -110,6 +110,18 @@ void main_store_resolution(int32_t value) {
display_resolution();
}
+static int32_t inv = NORMAL;
+
+void main_store_invertion(int32_t value) {
+ if (value != NORMAL && value != INVERSE) {
+ ESP_LOGW(TAG, "Invalid value for invertion was passed, not assigning");
+ return;
+ }
+ nvs_write_i32("invertion", value);
+ inv = value;
+ display_invertion((enum Inversion)inv);
+}
+
/*
* On button press
*/
@@ -192,6 +204,8 @@ void app_main(void)
display_imagesave();
nvs_read_i32("resolution", &res);
display_resolution();
+ nvs_read_i32("invertion", &inv);
+ display_invertion((enum Inversion)inv);
// This is really slow
wifi_init();
diff --git a/Year 3/Internet of things/goam/main/main.h b/Year 3/Internet of things/goam/main/main.h
index b08e83f..3745494 100644
--- a/Year 3/Internet of things/goam/main/main.h
+++ b/Year 3/Internet of things/goam/main/main.h
@@ -2,3 +2,4 @@
void main_store_saveimage(uint32_t value);
void main_store_resolution(int32_t value);
+void main_store_invertion(int32_t value);
diff --git a/Year 3/Internet of things/goam/main/webserver.c b/Year 3/Internet of things/goam/main/webserver.c
index 6da93ef..b2a4843 100644
--- a/Year 3/Internet of things/goam/main/webserver.c
+++ b/Year 3/Internet of things/goam/main/webserver.c
@@ -151,6 +151,24 @@ static const httpd_uri_t post_resolution = {
.handler = post_resolution_handler,
};
+static esp_err_t post_invertion_handler(httpd_req_t *req) {
+ char* buffer = malloc(req->content_len + 1);
+ httpd_req_recv(req, buffer, req->content_len);
+
+ main_store_invertion((int32_t)(strtol(strchr(buffer, '=') + 2, NULL, 16)));
+
+ httpd_resp_send(req, "", 0);
+ free(buffer);
+
+ logi_post(req);
+ return ESP_OK;
+}
+static const httpd_uri_t post_invertion = {
+ .uri = "/invertion",
+ .method = HTTP_POST,
+ .handler = post_invertion_handler,
+};
+
static esp_err_t ws_camera_handler(httpd_req_t *req) {
if (req->method == HTTP_GET) {
ESP_LOGI(TAG, "Established websocket connection");
@@ -233,6 +251,7 @@ void webserver_start()
httpd_register_uri_handler(server, &post_network);
httpd_register_uri_handler(server, &post_imagesave);
httpd_register_uri_handler(server, &post_resolution);
+ httpd_register_uri_handler(server, &post_invertion);
httpd_register_uri_handler(server, &ws_camera);
ESP_LOGI(TAG, "Started server on port %d", config.httpd.server_port);
diff --git a/Year 3/Internet of things/goam/webserver/index.html b/Year 3/Internet of things/goam/webserver/index.html
index 27f24df..a8cdff6 100644
--- a/Year 3/Internet of things/goam/webserver/index.html
+++ b/Year 3/Internet of things/goam/webserver/index.html
@@ -87,6 +87,14 @@ iframe {
</select>
<input class="button" type="submit" value="Apply">
</form>
+ <br>
+ <form action="/invertion" target="dummyframe" method="POST">
+ <select name="invertion">
+ <option value="&#xA6;" selected>Normal</option>
+ <option value="&#xA7;">Inverted</option>
+ </select>
+ <input class="button" type="submit" value="Apply">
+ </form>
</article>
<script>
const dummyframe = document.getElementById("dummyframe");