diff options
[iot/goam] Implemented resolution setting
1 files changed, 27 insertions, 0 deletions
| -rw-r--r-- | Year 3/Internet of things/goam/main/main.c | 27 |
diff --git a/Year 3/Internet of things/goam/main/main.c b/Year 3/Internet of things/goam/main/main.c index 4d44376..bceab07 100644 --- a/Year 3/Internet of things/goam/main/main.c +++ b/Year 3/Internet of things/goam/main/main.c @@ -85,6 +85,31 @@ void main_store_saveimage(int32_t value) { display_imagesave(); } +static int32_t res = RES_640X480; + +static void display_resolution() { + const char* icon; + switch (res) { + case RES_640X480: icon = " "; break; + case RES_320X240: icon = CHAR_HALF_RES; break; + case RES_160X120: icon = CHAR_QUART_RES; break; + default: return; + } + display_printat(icon, + CONFIG_DISPLAY_ICONS_ROW, + CONFIG_RESOLUTION_COLUMN); +} + +void main_store_resolution(int32_t value) { + if (value != RES_640X480 && value != RES_320X240 && value != RES_160X120) { + ESP_LOGW(TAG, "Invalid value for resolution was passed, not assigning"); + return; + } + nvs_write_i32("resolution", value); + res = value; + display_resolution(); +} + /* * On button press */ @@ -165,6 +190,8 @@ void app_main(void) CONFIG_CAMERA_COLUMN); nvs_read_i32("imagesave", &is); display_imagesave(); + nvs_read_i32("resolution", &res); + display_resolution(); // This is really slow wifi_init(); |
