Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitc630b3ddebebb7ee5ec3a279939e89a700d8a8ce (patch)
Author
 Syndamia <kamen@syndamia.com>
2024-05-28 11:11:47 +0300
Committer
 Syndamia <kamen@syndamia.com>
2024-05-28 11:11:47 +0300
Files75e0f51d7da970be0366ff797f9db8f375140b1d
uni-projects-c630b3ddebebb7ee5ec3a279939e89a700d8a8ce.tar
uni-projects-c630b3ddebebb7ee5ec3a279939e89a700d8a8ce.tar.gz
uni-projects-c630b3ddebebb7ee5ec3a279939e89a700d8a8ce.zip
Parentcea3ffd48f72377c99955e6e02292918fc0608ab (diff)
[iot/goam] Moved display layout to a menuconfig
diff --git a/Year 3/Internet of things/goam/main/Kconfig.projbuild b/Year 3/Internet of things/goam/main/Kconfig.projbuild
new file mode 100644
index 0000000..4ad0b48
--- /dev/null
+++ b/Year 3/Internet of things/goam/main/Kconfig.projbuild
@@ -0,0 +1,34 @@
+menu "GoAm configurations"
+ menu "Display layout"
+ config DISPLAY_ICONS_ROW
+ int "Row on which information icons will be shown"
+ range 1 4
+ default 1
+ menu "Icons row layout"
+ config CAMERA_COLUMN
+ int "Column on which the camera icon will be shown, takes two columns"
+ range 1 16
+ default 1
+ config WIFI_COLUMN
+ int "Column on which the wifi icon will be shown, takes two columns"
+ range 1 16
+ default 4
+ config SAVEIMAGE_COLUMN
+ int "Column on which the save image setting icon will be shown, takes one column"
+ range 1 16
+ default 7
+ config RESOLUTION_COLUMN
+ int "Column on which the resolution icon will be shown, takes one column"
+ range 1 16
+ default 8
+ endmenu
+ config DISPLAY_IP_ROW
+ int "Row on which the IP will be shown, takes the entire row"
+ range 1 4
+ default 2
+ config DISPLAY_SSID_ROW
+ int "Row on which the network name will be shown, takes two entire rows"
+ range 1 4
+ default 3
+ endmenu
+endmenu
diff --git a/Year 3/Internet of things/goam/main/main.c b/Year 3/Internet of things/goam/main/main.c
index 9ed0644..4d44376 100644
--- a/Year 3/Internet of things/goam/main/main.c
+++ b/Year 3/Internet of things/goam/main/main.c
@@ -63,15 +63,23 @@ void print_chip_data() {
static int32_t is = BOTH;
static void display_imagesave() {
+ const char* icon;
switch (is) {
- case SPIFFS_ONLY: display_printat(CHAR_IS_STORE, 1, 7); return;
- case WS_ONLY: display_printat(CHAR_IS_SEND, 1, 7); return;
- case BOTH: display_printat(CHAR_IS_STORE_SEND, 1, 7); return;
+ case SPIFFS_ONLY: icon = CHAR_IS_STORE; break;
+ case WS_ONLY: icon = CHAR_IS_SEND; break;
+ case BOTH: icon = CHAR_IS_STORE_SEND; break;
+ default: return;
}
+ display_printat(icon,
+ CONFIG_DISPLAY_ICONS_ROW,
+ CONFIG_SAVEIMAGE_COLUMN);
}
void main_store_saveimage(int32_t value) {
- if (value < 0 && value > BOTH) return;
+ if (value < 0 && value > BOTH) {
+ ESP_LOGW(TAG, "Invalid value for saveimage was passed, not assigning");
+ return;
+ }
nvs_write_i32("imagesave", value);
is = value;
display_imagesave();
@@ -93,9 +101,11 @@ static void debug_serial_print_image(const char* image, size_t length) {
}
static void take_photo() {
- display_printon(DCHAR_NO_CAMERA, 1);
+ display_printat(DCHAR_NO_CAMERA,
+ CONFIG_DISPLAY_ICONS_ROW,
+ CONFIG_CAMERA_COLUMN);
- ptc06_set_image_resolution(RES_640X480);
+ ptc06_set_image_resolution((enum Resolution)res);
char* image;
size_t length = ptc06_get_image(&image);
if (is != WS_ONLY) {
@@ -105,7 +115,9 @@ static void take_photo() {
ws_send_bin(image, length);
}
- display_printon(DCHAR_CAMERA, 1);
+ display_printat(DCHAR_CAMERA,
+ CONFIG_DISPLAY_ICONS_ROW,
+ CONFIG_CAMERA_COLUMN);
free(image);
}
@@ -124,7 +136,9 @@ static void init_camera(void*) {
ESP_LOGE(TAG, "Couldnt't notify main of camera init, software will hang");
}
- display_printon(DCHAR_CAMERA, 1);
+ display_printat(DCHAR_CAMERA,
+ CONFIG_DISPLAY_ICONS_ROW,
+ CONFIG_CAMERA_COLUMN);
vTaskDelete(NULL);
}
@@ -146,7 +160,9 @@ void app_main(void)
add_push_button(BTN_SHOOT_PIN, take_photo, NULL);
display_init();
- display_printon(DCHAR_NO_CAMERA, 1);
+ display_printat(DCHAR_NO_CAMERA,
+ CONFIG_DISPLAY_ICONS_ROW,
+ CONFIG_CAMERA_COLUMN);
nvs_read_i32("imagesave", &is);
display_imagesave();
diff --git a/Year 3/Internet of things/goam/main/ptc06.c b/Year 3/Internet of things/goam/main/ptc06.c
index ea345cd..6cc0182 100644
--- a/Year 3/Internet of things/goam/main/ptc06.c
+++ b/Year 3/Internet of things/goam/main/ptc06.c
@@ -6,6 +6,7 @@
#include "ptc06.h"
#include "display.h"
+#include "sdkconfig.h"
#include <string.h>
/*
@@ -157,7 +158,9 @@ static void send(enum Command comm_byte, const char data_lengths, char data[16])
#define byte_check(errmsg, compare) \
if (!(compare)) { \
ESP_LOGE(TAG, "Invalid response, " errmsg); \
- display_printon(DCHAR_NO_CAMERA_EXCLAM, 0); \
+ display_printat(DCHAR_NO_CAMERA_EXCLAM, \
+ CONFIG_DISPLAY_ICONS_ROW, \
+ CONFIG_CAMERA_COLUMN); \
}
static void recv(enum Command comm_byte, const char expectedDataSize, char ack[21]) {
@@ -324,6 +327,7 @@ void ptc06_set_image_resolution(enum Resolution res) {
temp_configuration[1] = 0x19;
temp_write_data[0] = res;
vc0706_write_data(I2C_EEPROM, 0x01, temp_configuration, temp_write_data);
+ vc0706_system_reset(); // Practice has shown this is mandatory
}
diff --git a/Year 3/Internet of things/goam/main/wifi.c b/Year 3/Internet of things/goam/main/wifi.c
index 7efa8fe..99bb03a 100644
--- a/Year 3/Internet of things/goam/main/wifi.c
+++ b/Year 3/Internet of things/goam/main/wifi.c
@@ -7,13 +7,11 @@
#include "esp_event.h"
#include "esp_log.h"
+#include "sdkconfig.h"
#include "wifi.h"
#include "display.h"
#include "nvs.h"
-#define IP_LINE 2
-#define AT_WIFI_ICON 1, 4
-
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
#define ESP_MAXIMUM_RETRY 3
@@ -71,8 +69,11 @@ static unsigned short MAX_AP = 16;
static TaskHandle_t launcher_handle = NULL;
static void scan_and_connect_task() {
- display_printat(DCHAR_NO_WIFI, AT_WIFI_ICON);
- display_printon("---.---.---.--- " "-" LINE_CLEAR LINE_CLEAR, IP_LINE);
+ display_printat(DCHAR_NO_WIFI,
+ CONFIG_DISPLAY_ICONS_ROW,
+ CONFIG_WIFI_COLUMN);
+ display_printon("---.---.---.--- ", CONFIG_DISPLAY_IP_ROW);
+ display_printon("-" LINE_CLEAR LINE_CLEAR, CONFIG_DISPLAY_SSID_ROW);
ESP_ERROR_CHECK(esp_wifi_scan_start(NULL, true));
wifi_ap_record_t ap_info[MAX_AP];
@@ -146,13 +147,17 @@ static void launcher_scan_and_connect_task(void*) {
static int connect_tries = 0;
static void sta_connected_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) {
- display_printat(DCHAR_WIFI, AT_WIFI_ICON);
+ display_printat(DCHAR_WIFI,
+ CONFIG_DISPLAY_ICONS_ROW,
+ CONFIG_WIFI_COLUMN);
}
static void sta_disconnect_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) {
if (connect_tries < ESP_MAXIMUM_RETRY) {
esp_wifi_connect();
- display_printat(DCHAR_WIFI_EXCLAM, AT_WIFI_ICON);
+ display_printat(DCHAR_WIFI_EXCLAM,
+ CONFIG_DISPLAY_ICONS_ROW,
+ CONFIG_WIFI_COLUMN);
connect_tries++;
ESP_LOGW(TAG, "Retrying to connect... Try %d/%d", connect_tries, ESP_MAXIMUM_RETRY);
vTaskDelay(200 / portTICK_PERIOD_MS);
@@ -179,8 +184,8 @@ static void ip_got_handler(void* arg, esp_event_base_t event_base, int32_t event
for (int i = strchr(ip, '\0') - ip; i < 16; i++) {
ip[i] = ' ';
}
- display_printon(ip, IP_LINE);
- display_printon((char*)config.sta.ssid, 3);
+ display_printon(ip, CONFIG_DISPLAY_IP_ROW);
+ display_printon((char*)config.sta.ssid, CONFIG_DISPLAY_SSID_ROW);
}
static void wifi_init_events() {
diff --git a/Year 3/Internet of things/goam/sdkconfig b/Year 3/Internet of things/goam/sdkconfig
index 90205f4..c85ef81 100644
--- a/Year 3/Internet of things/goam/sdkconfig
+++ b/Year 3/Internet of things/goam/sdkconfig
@@ -345,6 +345,25 @@ CONFIG_PARTITION_TABLE_MD5=y
#
#
+# Display layout
+#
+CONFIG_DISPLAY_ICONS_ROW=1
+
+#
+# Icons row layout
+#
+CONFIG_CAMERA_COLUMN=1
+CONFIG_WIFI_COLUMN=4
+CONFIG_SAVEIMAGE_COLUMN=7
+CONFIG_RESOLUTION_COLUMN=8
+# end of Icons row layout
+
+CONFIG_DISPLAY_IP_ROW=2
+CONFIG_DISPLAY_SSID_ROW=3
+# end of Display layout
+# end of GoAm configurations
+
+#
# Compiler options
#
# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set