Skip to content

Commit

Permalink
Improved settings menu (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeroniemi authored Apr 11, 2024
1 parent 1867328 commit 224162c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
4 changes: 2 additions & 2 deletions assets_source/html/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1>CircleHome Settings</h1>
<h2>WiFi</h2>
<div class="form-group">
<label for="wifi_ssid">SSID</label>
<input id="wifi_ssid" name="wifi_ssid" type="text" required="required" class="form-control">
<input id="wifi_ssid" name="wifi_ssid" type="text" class="form-control">
</div>
<div class="form-group">
<label for="wifi_password">Password</label>
Expand All @@ -38,7 +38,7 @@ <h2>Home Assistant</h2>
<h2>Miscellaneous</h2>
<div class="form-group">
<label for="ntp_timezone">Timezone</label>
<input id="ntp_timezone" name="ntp_timezone" placeholder="europe/london" type="text" class="form-control">
<input id="ntp_timezone" name="ntp_timezone" placeholder="Europe/London" type="text" class="form-control">
</div>
</div>
<div class="form-group">
Expand Down
2 changes: 1 addition & 1 deletion src/assets/html/form.c
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const char *html_form = "<html style=\"box-sizing:border-box;font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:transparent\"><head style=\"box-sizing:border-box\"><body style=\'color:#fff;background-color:#1f1f1f;box-sizing:border-box;margin:0;font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";font-size:1rem;font-weight:400;line-height:1.5;text-align:left;min-width:992px!important\'><div style=\"max-width:40em;margin-left:auto;margin-right:auto;padding-top:5em;box-sizing:border-box\"><h1 style=\"box-sizing:border-box;margin-top:0;margin-bottom:.5rem;font-family:inherit;font-weight:500;line-height:1.2;color:inherit;font-size:2.5rem\">CircleHome Settings</h1><form action=\"/submit\"method=\"post\"style=\"box-sizing:border-box\"><div style=\"box-sizing:border-box\"><h2 style=\"box-sizing:border-box;margin-top:0;margin-bottom:.5rem;font-family:inherit;font-weight:500;line-height:1.2;color:inherit;font-size:2rem;orphans:3;widows:3;page-break-after:avoid\">WiFi</h2><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><label for=\"wifi_ssid\"style=\"box-sizing:border-box;display:inline-block;margin-bottom:.5rem\">SSID</label> <input class=\"form-control\"id=\"wifi_ssid\"name=\"wifi_ssid\"style=\"box-sizing:border-box;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;display:block;width:100%;height:calc(2.25rem + 2px);padding:.375rem .75rem;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out\"required></div><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><label for=\"wifi_password\"style=\"box-sizing:border-box;display:inline-block;margin-bottom:.5rem\">Password</label> <input class=\"form-control\"id=\"wifi_password\"name=\"wifi_password\"style=\"box-sizing:border-box;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;display:block;width:100%;height:calc(2.25rem + 2px);padding:.375rem .75rem;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out\"type=\"password\"></div></div><div style=\"box-sizing:border-box\"><h2 style=\"box-sizing:border-box;margin-top:0;margin-bottom:.5rem;font-family:inherit;font-weight:500;line-height:1.2;color:inherit;font-size:2rem;orphans:3;widows:3;page-break-after:avoid\">Home Assistant</h2><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><label for=\"ha_hostname\"style=\"box-sizing:border-box;display:inline-block;margin-bottom:.5rem\">Hostname</label> <input class=\"form-control\"id=\"ha_hostname\"name=\"ha_hostname\"style=\"box-sizing:border-box;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;display:block;width:100%;height:calc(2.25rem + 2px);padding:.375rem .75rem;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out\"placeholder=\"homeassistant.local\"></div><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><label for=\"ha_port\"style=\"box-sizing:border-box;display:inline-block;margin-bottom:.5rem\">Port</label> <input class=\"form-control\"id=\"ha_port\"name=\"ha_port\"style=\"box-sizing:border-box;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;display:block;width:100%;height:calc(2.25rem + 2px);padding:.375rem .75rem;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out\"placeholder=\"8123\"type=\"number\"></div><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><label for=\"ha_token\"style=\"box-sizing:border-box;display:inline-block;margin-bottom:.5rem\">Token</label> <input class=\"form-control\"id=\"ha_token\"name=\"ha_token\"style=\"box-sizing:border-box;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;display:block;width:100%;height:calc(2.25rem + 2px);padding:.375rem .75rem;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out\"type=\"password\"></div></div><div style=\"box-sizing:border-box\"><h2 style=\"box-sizing:border-box;margin-top:0;margin-bottom:.5rem;font-family:inherit;font-weight:500;line-height:1.2;color:inherit;font-size:2rem;orphans:3;widows:3;page-break-after:avoid\">Miscellaneous</h2><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><label for=\"ntp_timezone\"style=\"box-sizing:border-box;display:inline-block;margin-bottom:.5rem\">Timezone</label> <input class=\"form-control\"id=\"ntp_timezone\"name=\"ntp_timezone\"style=\"box-sizing:border-box;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;display:block;width:100%;height:calc(2.25rem + 2px);padding:.375rem .75rem;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out\"placeholder=\"europe/london\"></div></div><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><button class=\"btn btn-primary\"name=\"submit\"style=\"box-sizing:border-box;border-radius:.25rem;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;text-transform:none;-webkit-appearance:button;display:inline-block;font-weight:400;text-align:center;white-space:nowrap;vertical-align:middle;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border:1px solid transparent;padding:.375rem .75rem;transition:color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;color:#fff;background-color:#007bff;border-color:#007bff\"type=\"submit\">Apply</button></div></form></div>";
const char *html_form = "<html style=\"box-sizing:border-box;font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:transparent\"><head style=\"box-sizing:border-box\"><body style=\'color:#fff;background-color:#1f1f1f;box-sizing:border-box;margin:0;font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";font-size:1rem;font-weight:400;line-height:1.5;text-align:left;min-width:992px!important\'><div style=\"max-width:40em;margin-left:auto;margin-right:auto;padding-top:5em;box-sizing:border-box\"><h1 style=\"box-sizing:border-box;margin-top:0;margin-bottom:.5rem;font-family:inherit;font-weight:500;line-height:1.2;color:inherit;font-size:2.5rem\">CircleHome Settings</h1><form action=\"/submit\"method=\"post\"style=\"box-sizing:border-box\"><div style=\"box-sizing:border-box\"><h2 style=\"box-sizing:border-box;margin-top:0;margin-bottom:.5rem;font-family:inherit;font-weight:500;line-height:1.2;color:inherit;font-size:2rem;orphans:3;widows:3;page-break-after:avoid\">WiFi</h2><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><label for=\"wifi_ssid\"style=\"box-sizing:border-box;display:inline-block;margin-bottom:.5rem\">SSID</label> <input class=\"form-control\"id=\"wifi_ssid\"name=\"wifi_ssid\"style=\"box-sizing:border-box;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;display:block;width:100%;height:calc(2.25rem + 2px);padding:.375rem .75rem;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out\"></div><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><label for=\"wifi_password\"style=\"box-sizing:border-box;display:inline-block;margin-bottom:.5rem\">Password</label> <input class=\"form-control\"id=\"wifi_password\"name=\"wifi_password\"style=\"box-sizing:border-box;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;display:block;width:100%;height:calc(2.25rem + 2px);padding:.375rem .75rem;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out\"type=\"password\"></div></div><div style=\"box-sizing:border-box\"><h2 style=\"box-sizing:border-box;margin-top:0;margin-bottom:.5rem;font-family:inherit;font-weight:500;line-height:1.2;color:inherit;font-size:2rem;orphans:3;widows:3;page-break-after:avoid\">Home Assistant</h2><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><label for=\"ha_hostname\"style=\"box-sizing:border-box;display:inline-block;margin-bottom:.5rem\">Hostname</label> <input class=\"form-control\"id=\"ha_hostname\"name=\"ha_hostname\"style=\"box-sizing:border-box;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;display:block;width:100%;height:calc(2.25rem + 2px);padding:.375rem .75rem;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out\"placeholder=\"homeassistant.local\"></div><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><label for=\"ha_port\"style=\"box-sizing:border-box;display:inline-block;margin-bottom:.5rem\">Port</label> <input class=\"form-control\"id=\"ha_port\"name=\"ha_port\"style=\"box-sizing:border-box;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;display:block;width:100%;height:calc(2.25rem + 2px);padding:.375rem .75rem;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out\"placeholder=\"8123\"type=\"number\"></div><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><label for=\"ha_token\"style=\"box-sizing:border-box;display:inline-block;margin-bottom:.5rem\">Token</label> <input class=\"form-control\"id=\"ha_token\"name=\"ha_token\"style=\"box-sizing:border-box;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;display:block;width:100%;height:calc(2.25rem + 2px);padding:.375rem .75rem;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out\"type=\"password\"></div></div><div style=\"box-sizing:border-box\"><h2 style=\"box-sizing:border-box;margin-top:0;margin-bottom:.5rem;font-family:inherit;font-weight:500;line-height:1.2;color:inherit;font-size:2rem;orphans:3;widows:3;page-break-after:avoid\">Miscellaneous</h2><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><label for=\"ntp_timezone\"style=\"box-sizing:border-box;display:inline-block;margin-bottom:.5rem\">Timezone</label> <input class=\"form-control\"id=\"ntp_timezone\"name=\"ntp_timezone\"style=\"box-sizing:border-box;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;display:block;width:100%;height:calc(2.25rem + 2px);padding:.375rem .75rem;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out\"placeholder=\"UTC\"></div></div><div style=\"box-sizing:border-box;margin-bottom:1rem\"class=\"form-group\"><button class=\"btn btn-primary\"name=\"submit\"style=\"box-sizing:border-box;border-radius:.25rem;margin:0;font-family:inherit;font-size:1rem;line-height:1.5;overflow:visible;text-transform:none;-webkit-appearance:button;display:inline-block;font-weight:400;text-align:center;white-space:nowrap;vertical-align:middle;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border:1px solid transparent;padding:.375rem .75rem;transition:color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;color:#fff;background-color:#007bff;border-color:#007bff\"type=\"submit\">Apply</button></div></form></div>";
26 changes: 20 additions & 6 deletions src/ui/screens/Screen_Settings.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
#include <aero_preferences.h>
#include <aero_web_portal.h>
#include "Screen_Settings.h"
void Screen_Settings::resetDevice(lv_event_t *event)
{
resetPreferences();
ESP.restart();
}
void Screen_Settings::configDevice(lv_event_t *event)
{
aero_web_portal_setup();
}
void Screen_Settings::create() {
lv_obj_t *button = lv_button_create(_lv_screen);
lv_obj_center(button);
lv_obj_t *text = lv_label_create(button);
lv_label_set_text(text, "Reset Device\nSettings");
lv_obj_center(text);
lv_obj_add_event_cb(button, resetDevice, LV_EVENT_PRESSED, NULL);
lv_obj_t *reset_button = lv_button_create(_lv_screen);
lv_group_remove_obj(reset_button);
lv_obj_align(reset_button, LV_ALIGN_CENTER, 0, 60);
lv_obj_t *reset_text = lv_label_create(reset_button);
lv_label_set_text(reset_text, "Reset Device\nSettings");
lv_obj_center(reset_text);
lv_obj_add_event_cb(reset_button, resetDevice, LV_EVENT_PRESSED, NULL);

lv_obj_t *config_button = lv_button_create(_lv_screen);
lv_group_remove_obj(config_button);
lv_obj_align(config_button, LV_ALIGN_CENTER, 0, -60);
lv_obj_t *config_text = lv_label_create(config_button);
lv_label_set_text(config_text, "Configuration\nMode");
lv_obj_center(config_text);
lv_obj_add_event_cb(config_button, configDevice, LV_EVENT_PRESSED, NULL);
}
Screen_Settings screen_settings;
1 change: 1 addition & 0 deletions src/ui/screens/Screen_Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Screen_Settings : public Screen
{
void create();
static void resetDevice(lv_event_t *event);
static void configDevice(lv_event_t *event);
};
extern Screen_Settings screen_settings;

Expand Down

0 comments on commit 224162c

Please sign in to comment.