starting with search_screen
- optimized partitions
This commit is contained in:
@@ -286,7 +286,7 @@
|
||||
|
||||
/*1: Show the used memory and the memory fragmentation
|
||||
* Requires LV_MEM_CUSTOM = 0*/
|
||||
#define LV_USE_MEM_MONITOR 0
|
||||
#define LV_USE_MEM_MONITOR 1
|
||||
#if LV_USE_MEM_MONITOR
|
||||
#define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
|
||||
#endif
|
||||
@@ -703,7 +703,7 @@
|
||||
#define LV_USE_IMGFONT 0
|
||||
|
||||
/*1: Enable a published subscriber based messaging system */
|
||||
#define LV_USE_MSG 0
|
||||
#define LV_USE_MSG 1
|
||||
|
||||
/*1: Enable Pinyin input method*/
|
||||
/*Requires: lv_keyboard*/
|
||||
|
@@ -1,6 +1,7 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
nvs, data, nvs, 0x9000, 0x5000,
|
||||
otadata, data, ota, 0xe000, 0x2000,
|
||||
app0, app, ota_0, 0x10000, 0x140000,
|
||||
app1, app, ota_1, 0x150000,0x140000,
|
||||
spiffs, data, spiffs, 0x290000,0x170000,
|
||||
app0, app, ota_0, 0x10000, 0x640000,
|
||||
app1, app, ota_1, 0x650000, 0x640000,
|
||||
spiffs, data, spiffs, 0xc90000, 0x360000,
|
||||
coredump, data, coredump, 0xFF0000, 0x10000,
|
||||
|
|
@@ -17,14 +17,13 @@ default_envs = wt32-sc01_plus
|
||||
[env]
|
||||
platform = espressif32 @ ^6.3.2
|
||||
framework = arduino
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:wt32-sc01_plus]
|
||||
board = wt32-sc01_plus
|
||||
board_build.partitions = partitions.csv
|
||||
build_flags =
|
||||
-D CORE_DEBUG_LEVEL=4
|
||||
-D CORE_DEBUG_LEVEL=5
|
||||
-D SCREEN_WIDTH=480
|
||||
-D SCREEN_HEIGHT=320
|
||||
-D ESP32S3
|
||||
|
@@ -18,19 +18,22 @@
|
||||
//----------------------------------------------------------------------------
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <esp32-hal-log.h>
|
||||
|
||||
#include "gfx/lv_setup.h"
|
||||
#include "lv_i18n/lv_i18n.h"
|
||||
#include "ui/launch_screen.h"
|
||||
#include "ui/screens/launch_screen.h"
|
||||
|
||||
void setup()
|
||||
{
|
||||
esp_log_level_set("*", ESP_LOG_VERBOSE);
|
||||
|
||||
lv_i18n_init(lv_i18n_language_pack);
|
||||
lv_i18n_set_locale("de-DE");
|
||||
|
||||
lv_begin();
|
||||
|
||||
LaunchScreen launchScreen;
|
||||
launchScreen.show();
|
||||
LaunchScreen().init();
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
40
src/services/wifi_service.cpp
Normal file
40
src/services/wifi_service.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// OS-Railway - Remote Control
|
||||
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#include "wifi_service.h"
|
||||
|
||||
#include <WiFi.h>
|
||||
#include <ESPmDNS.h>
|
||||
|
||||
void initWiFiTask(void *params)
|
||||
{
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
auto start = millis();
|
||||
while (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
delay(500);
|
||||
if (millis() - start > 10000)
|
||||
{
|
||||
Serial.println("Failed to connect to WiFi");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vTaskDelete(NULL);
|
||||
}
|
21
src/services/wifi_service.h
Normal file
21
src/services/wifi_service.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// OS-Railway - Remote Control
|
||||
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
void initWiFiTask(void *params);
|
@@ -18,12 +18,10 @@
|
||||
//----------------------------------------------------------------------------
|
||||
#include "launch_screen.h"
|
||||
|
||||
#include <lvgl.h>
|
||||
#include "lv_i18n/lv_i18n.h"
|
||||
#include "search_screen.h"
|
||||
|
||||
lv_obj_t *screen;
|
||||
|
||||
LaunchScreen::LaunchScreen()
|
||||
void LaunchScreen::init()
|
||||
{
|
||||
screen = lv_obj_create(NULL);
|
||||
lv_obj_clear_flag(screen, LV_OBJ_FLAG_SCROLLABLE);
|
||||
@@ -37,9 +35,25 @@ LaunchScreen::LaunchScreen()
|
||||
auto *label = lv_label_create(screen);
|
||||
lv_label_set_text(label, _("appName"));
|
||||
lv_obj_align(label, LV_ALIGN_BOTTOM_MID, 0, -25);
|
||||
{
|
||||
lv_disp_load_scr(screen);
|
||||
timer();
|
||||
}
|
||||
}
|
||||
|
||||
void LaunchScreen::show()
|
||||
void LaunchScreen::dispose()
|
||||
{
|
||||
lv_disp_load_scr(screen);
|
||||
lv_obj_del(screen);
|
||||
screen = nullptr;
|
||||
}
|
||||
|
||||
void my_timer(lv_timer_t *timer)
|
||||
{
|
||||
lv_timer_del(timer);
|
||||
SearchScreen().show();
|
||||
}
|
||||
|
||||
void LaunchScreen::timer()
|
||||
{
|
||||
lv_timer_t *timer = lv_timer_create(my_timer, 2000, NULL);
|
||||
}
|
@@ -18,9 +18,15 @@
|
||||
//----------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
class LaunchScreen
|
||||
{
|
||||
private:
|
||||
lv_obj_t *screen;
|
||||
void timer();
|
||||
|
||||
public:
|
||||
LaunchScreen();
|
||||
void show();
|
||||
void init();
|
||||
void dispose();
|
||||
};
|
41
src/ui/screens/provisioning_screen.cpp
Normal file
41
src/ui/screens/provisioning_screen.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// OS-Railway - Remote Control
|
||||
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#include "provisioning_screen.h"
|
||||
|
||||
ProvisioningScreen::ProvisioningScreen()
|
||||
{
|
||||
screen = lv_obj_create(NULL);
|
||||
|
||||
lv_color_t bg_color = lv_palette_lighten(LV_PALETTE_LIGHT_BLUE, 5);
|
||||
lv_color_t fg_color = lv_palette_darken(LV_PALETTE_BLUE, 4);
|
||||
|
||||
lv_obj_t *qr = lv_qrcode_create(screen, 150, fg_color, bg_color);
|
||||
|
||||
const char *data = "{\"ver\":\"v2\",\"name\":\"OSRW_RC\",\"pop\":\"a1000318\",\"transport\":\"ble\"}";
|
||||
lv_qrcode_update(qr, data, strlen(data));
|
||||
lv_obj_center(qr);
|
||||
|
||||
lv_obj_set_style_border_color(qr, bg_color, 0);
|
||||
lv_obj_set_style_border_width(qr, 5, 0);
|
||||
}
|
||||
|
||||
void ProvisioningScreen::show()
|
||||
{
|
||||
lv_disp_load_scr(screen);
|
||||
}
|
31
src/ui/screens/provisioning_screen.h
Normal file
31
src/ui/screens/provisioning_screen.h
Normal file
@@ -0,0 +1,31 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// OS-Railway - Remote Control
|
||||
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
class ProvisioningScreen
|
||||
{
|
||||
private:
|
||||
lv_obj_t *screen;
|
||||
|
||||
public:
|
||||
ProvisioningScreen();
|
||||
void show();
|
||||
};
|
34
src/ui/screens/search_screen.cpp
Normal file
34
src/ui/screens/search_screen.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// OS-Railway - Remote Control
|
||||
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#include "search_screen.h"
|
||||
|
||||
#include "../widgets/status_bar_widget.h"
|
||||
|
||||
SearchScreen::SearchScreen()
|
||||
{
|
||||
screen = lv_obj_create(NULL);
|
||||
lv_obj_clear_flag(screen, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_set_style_bg_color(screen, lv_color_make(0x78, 0x94, 0xa7), 0);
|
||||
}
|
||||
|
||||
void SearchScreen::show()
|
||||
{
|
||||
status_bar_widget_init();
|
||||
lv_disp_load_scr(this->screen);
|
||||
}
|
31
src/ui/screens/search_screen.h
Normal file
31
src/ui/screens/search_screen.h
Normal file
@@ -0,0 +1,31 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// OS-Railway - Remote Control
|
||||
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
class SearchScreen
|
||||
{
|
||||
private:
|
||||
lv_obj_t *screen;
|
||||
|
||||
public:
|
||||
SearchScreen();
|
||||
void show();
|
||||
};
|
38
src/ui/widgets/status_bar_widget.cpp
Normal file
38
src/ui/widgets/status_bar_widget.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// OS-Railway - Remote Control
|
||||
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#include "status_bar_widget.h"
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
#include "time_widget.h"
|
||||
|
||||
lv_obj_t *status_bar_widget;
|
||||
|
||||
void status_bar_widget_init()
|
||||
{
|
||||
status_bar_widget = lv_obj_create(lv_layer_top());
|
||||
time_widget_init(10, 10);
|
||||
}
|
||||
|
||||
void status_bar_widget_dispose()
|
||||
{
|
||||
time_widget_dispose();
|
||||
lv_obj_del(status_bar_widget);
|
||||
status_bar_widget = NULL;
|
||||
}
|
22
src/ui/widgets/status_bar_widget.h
Normal file
22
src/ui/widgets/status_bar_widget.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// OS-Railway - Remote Control
|
||||
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
void status_bar_widget_init();
|
||||
void status_bar_widget_dispose();
|
71
src/ui/widgets/time_widget.cpp
Normal file
71
src/ui/widgets/time_widget.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// OS-Railway - Remote Control
|
||||
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#include "time_widget.h"
|
||||
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
|
||||
lv_obj_t *time_widget;
|
||||
lv_timer_t *time_widget_timer;
|
||||
|
||||
void time_widget_update(lv_timer_t *timer)
|
||||
{
|
||||
lv_obj_t *label = (lv_obj_t *)timer->user_data;
|
||||
|
||||
time_t now;
|
||||
struct tm timeinfo;
|
||||
time(&now);
|
||||
localtime_r(&now, &timeinfo);
|
||||
std::string weekday[] = LV_CALENDAR_DEFAULT_DAY_NAMES;
|
||||
lv_label_set_text_fmt(label, "%s %02d:%02d:%02d\n%d-%02d-%02d", weekday[timeinfo.tm_wday].c_str(), timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec, timeinfo.tm_year + 1900, timeinfo.tm_mon + 1, timeinfo.tm_mday);
|
||||
}
|
||||
|
||||
void time_widget_init(lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
if (time_widget != NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
time_widget = lv_obj_create(lv_layer_top());
|
||||
lv_obj_align(time_widget, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||
lv_obj_set_width(time_widget, 200);
|
||||
lv_obj_set_style_bg_opa(time_widget, LV_OPA_TRANSP, 0);
|
||||
lv_obj_set_style_border_opa(time_widget, LV_OPA_TRANSP, 0);
|
||||
|
||||
lv_obj_t *label = lv_label_create(time_widget);
|
||||
lv_obj_set_pos(label, -10, -10);
|
||||
|
||||
time_widget_timer = lv_timer_create(time_widget_update, 1000, (void *)label);
|
||||
time_widget_update(time_widget_timer);
|
||||
}
|
||||
|
||||
void time_widget_dispose()
|
||||
{
|
||||
if (time_widget == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lv_timer_del(time_widget_timer);
|
||||
time_widget_timer = NULL;
|
||||
|
||||
lv_obj_del(time_widget);
|
||||
time_widget = NULL;
|
||||
}
|
24
src/ui/widgets/time_widget.h
Normal file
24
src/ui/widgets/time_widget.h
Normal file
@@ -0,0 +1,24 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// OS-Railway - Remote Control
|
||||
// Copyright (C) 2023 Peter Siegmund (https://mars3142.dev)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#pragma once
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
void time_widget_init(lv_coord_t x, lv_coord_t y);
|
||||
void time_widget_dispose();
|
Reference in New Issue
Block a user