2025-03-07 15:13:29 +08:00
|
|
|
|
// This file was generated by SquareLine Studio
|
|
|
|
|
|
// SquareLine Studio version: SquareLine Studio 1.5.1
|
|
|
|
|
|
// LVGL version: 8.3.6
|
|
|
|
|
|
// Project name: ESP32S3_UI
|
|
|
|
|
|
|
|
|
|
|
|
#include "ui.h"
|
2025-03-07 16:26:42 +08:00
|
|
|
|
#include "driver/ledc.h"
|
|
|
|
|
|
#include "esp_err.h"
|
|
|
|
|
|
#include "esp_log.h"
|
2025-03-07 15:13:29 +08:00
|
|
|
|
|
2025-03-08 10:23:13 +08:00
|
|
|
|
#include "FluxMod.h"
|
2025-03-12 14:00:26 +08:00
|
|
|
|
#include "FluxWifi.h"
|
2025-03-13 10:26:19 +08:00
|
|
|
|
#include "FluxUart.h"
|
2025-03-13 14:04:19 +08:00
|
|
|
|
#include "FluxSD.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "esp_vfs_fat.h"
|
|
|
|
|
|
#include "sdmmc_cmd.h"
|
|
|
|
|
|
#include "driver/sdmmc_host.h"
|
2025-03-08 10:23:13 +08:00
|
|
|
|
|
2025-03-07 17:42:37 +08:00
|
|
|
|
#define LOWERST_LIGHT_LEVEL (7222)
|
|
|
|
|
|
|
2025-03-07 15:13:29 +08:00
|
|
|
|
|
2025-03-12 17:32:58 +08:00
|
|
|
|
void on_sliderLight_valueChanged(lv_event_t * e)
|
2025-03-07 15:13:29 +08:00
|
|
|
|
{
|
|
|
|
|
|
// Your code here
|
2025-03-07 17:42:37 +08:00
|
|
|
|
// Your code here
|
|
|
|
|
|
uint32_t value = 8192-lv_slider_get_value(e->target);
|
2025-03-07 16:26:42 +08:00
|
|
|
|
//ESP_LOGI("lightSliderCallback", "value = %u", value);
|
2025-03-07 17:42:37 +08:00
|
|
|
|
if (value>LOWERST_LIGHT_LEVEL)
|
|
|
|
|
|
{
|
|
|
|
|
|
value = LOWERST_LIGHT_LEVEL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-07 16:26:42 +08:00
|
|
|
|
ESP_ERROR_CHECK(ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, value));
|
|
|
|
|
|
// Update duty to apply the new value
|
|
|
|
|
|
ESP_ERROR_CHECK(ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0));
|
2025-03-07 15:13:29 +08:00
|
|
|
|
}
|
2025-03-08 14:45:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-03-12 17:32:58 +08:00
|
|
|
|
void on_dropdownDeviceType_valueChanged(lv_event_t * e)
|
2025-03-08 14:45:49 +08:00
|
|
|
|
{
|
|
|
|
|
|
char buf[32]={};
|
|
|
|
|
|
lv_dropdown_get_selected_str(e->target,buf,32);
|
2025-03-12 17:32:58 +08:00
|
|
|
|
lv_label_set_text(ui_pageHome_labelTitle, buf);
|
2025-03-08 14:45:49 +08:00
|
|
|
|
|
2025-03-11 18:55:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-12 17:32:58 +08:00
|
|
|
|
void on_buttonSearchWifi_clicked(lv_event_t * e)
|
2025-03-11 18:55:34 +08:00
|
|
|
|
{
|
2025-03-12 14:00:26 +08:00
|
|
|
|
wifi_scan();
|
2025-03-11 18:55:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-12 17:32:58 +08:00
|
|
|
|
void on_panelReadSDCard_clicked(lv_event_t * e)
|
2025-03-11 18:55:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
// Your code here
|
2025-03-12 14:00:26 +08:00
|
|
|
|
|
2025-03-11 18:55:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-12 17:32:58 +08:00
|
|
|
|
void on_dropDownWifiName_valueChanged(lv_event_t * e)
|
2025-03-11 18:55:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
// Your code here
|
2025-03-12 14:00:26 +08:00
|
|
|
|
int currentIndex=0;
|
|
|
|
|
|
|
|
|
|
|
|
currentIndex = lv_dropdown_get_selected(e->target);
|
|
|
|
|
|
|
2025-03-12 17:32:58 +08:00
|
|
|
|
lv_label_set_text_fmt(ui_pageWifiConnect_labelRssi, "RSSI:%d dBm ", ap_info[currentIndex].rssi);
|
|
|
|
|
|
lv_label_set_text_fmt(ui_pageWifiConnect_labelConnectWifi,"connect to %s",ap_info[currentIndex].ssid);
|
2025-03-12 14:00:26 +08:00
|
|
|
|
|
|
|
|
|
|
if (strcmp((char*)ap_info[currentIndex].ssid,"yuwell")==0)
|
|
|
|
|
|
{
|
2025-03-12 17:32:58 +08:00
|
|
|
|
lv_textarea_set_text(ui_pageWifiConnect_textAreaWifiPassword, "yuwell123456");
|
2025-03-12 14:00:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-11 18:55:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-12 17:32:58 +08:00
|
|
|
|
void on_buttonConnectWifi_clicked(lv_event_t * e)
|
2025-03-12 14:00:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
int currentIndex=0;
|
|
|
|
|
|
|
|
|
|
|
|
ESP_ERROR_CHECK(esp_wifi_stop());
|
|
|
|
|
|
|
2025-03-12 17:32:58 +08:00
|
|
|
|
currentIndex = lv_dropdown_get_selected(ui_pageWifiConnect_dropdownWifiName);
|
2025-03-12 14:00:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Your code here
|
|
|
|
|
|
wifi_config_t wifi_config = {
|
|
|
|
|
|
.sta = {
|
|
|
|
|
|
.ssid = "yuwell",
|
|
|
|
|
|
.password = "yuwell123456",
|
|
|
|
|
|
/* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (password len => 8).
|
|
|
|
|
|
* If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value
|
|
|
|
|
|
* to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to
|
|
|
|
|
|
* WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards.
|
|
|
|
|
|
*/
|
|
|
|
|
|
.threshold = {
|
|
|
|
|
|
.authmode = ap_info[currentIndex].authmode,
|
|
|
|
|
|
},
|
|
|
|
|
|
.sae_pwe_h2e = WPA3_SAE_PWE_BOTH,
|
|
|
|
|
|
.sae_h2e_identifier = "",
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-03-12 17:32:58 +08:00
|
|
|
|
lv_dropdown_get_selected_str(ui_pageWifiConnect_dropdownWifiName,(char*)wifi_config.sta.ssid,32);
|
2025-03-12 14:00:26 +08:00
|
|
|
|
|
2025-03-12 17:32:58 +08:00
|
|
|
|
strncpy((char*)wifi_config.sta.password,lv_textarea_get_text(ui_pageWifiConnect_textAreaWifiPassword),64);
|
2025-03-12 14:00:26 +08:00
|
|
|
|
|
|
|
|
|
|
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
|
|
|
|
|
|
|
|
|
|
|
|
ESP_ERROR_CHECK(esp_wifi_start() );
|
|
|
|
|
|
ESP_LOGI("TAG", "wifi_init_sta finished.");
|
|
|
|
|
|
|
|
|
|
|
|
esp_wifi_connect();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-12 17:32:58 +08:00
|
|
|
|
void on_buttonClearPassword_clicked(lv_event_t * e)
|
2025-03-11 18:55:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
// Your code here
|
2025-03-12 17:32:58 +08:00
|
|
|
|
lv_textarea_set_text(ui_pageWifiConnect_textAreaWifiPassword, "");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_buttonStartTest_clicked(lv_event_t * e)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Your code here
|
|
|
|
|
|
/* start to test */
|
|
|
|
|
|
lv_obj_clear_flag(ui_pageHome_spinnerStateBusy, LV_OBJ_FLAG_HIDDEN);
|
2025-03-13 15:13:27 +08:00
|
|
|
|
|
2025-03-12 14:00:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-13 10:26:19 +08:00
|
|
|
|
|
|
|
|
|
|
void on_buttonFluxRead_clicked(lv_event_t * e)
|
|
|
|
|
|
{
|
|
|
|
|
|
ModbusRTU_Send(ECHO_UART_PORT_NUM1,&flux_frame);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void on_buttonClearTextarea_clicked(lv_event_t * e)
|
|
|
|
|
|
{
|
|
|
|
|
|
lv_textarea_set_text(ui_pageDebug_textAreaContent, "");
|
2025-03-13 14:04:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_buttonReadSDCard_clicked(lv_event_t * e)
|
|
|
|
|
|
{
|
|
|
|
|
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾҳ<CABE><D2B3>*/
|
|
|
|
|
|
lv_textarea_set_text(ui_pageSDCard_textAreaSDCard,"");
|
|
|
|
|
|
esp_vfs_fat_info(MOUNT_POINT,&total_bytes,&free_bytes);
|
|
|
|
|
|
free_percent = (float)free_bytes / (float)total_bytes * 100;
|
|
|
|
|
|
|
|
|
|
|
|
printf("total:%llu free:%llu\n",total_bytes,free_bytes);
|
|
|
|
|
|
|
|
|
|
|
|
lv_label_set_text_fmt(ui_pageSDCard_labelSDCardFree,"%.2f free",free_percent);
|
|
|
|
|
|
lv_label_set_text_fmt(ui_pageSDCard_labelSDCardUsed,"used: %.2f GB",(double)(total_bytes-free_bytes)/(1024*1024*1024.0));
|
|
|
|
|
|
lv_label_set_text_fmt(ui_pageSDCard_labelSDCardSize,"size: %.2f GB",(double)total_bytes/(1024*1024*1024.0));
|
|
|
|
|
|
|
|
|
|
|
|
lv_arc_set_value(ui_pageSDCard_arcSDCardFree,free_percent);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|