177 lines
4.4 KiB
C
177 lines
4.4 KiB
C
// 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"
|
||
#include "driver/ledc.h"
|
||
#include "esp_err.h"
|
||
#include "esp_log.h"
|
||
|
||
#include "FluxMod.h"
|
||
#include "FluxWifi.h"
|
||
#include "FluxUart.h"
|
||
#include "FluxSD.h"
|
||
|
||
#include "esp_vfs_fat.h"
|
||
#include "sdmmc_cmd.h"
|
||
#include "driver/sdmmc_host.h"
|
||
|
||
// #include "spi_cxx.hpp"
|
||
// #include "wifi_station.h"
|
||
// #include "ssid_manager.h"
|
||
// #include "wifi_configuration_ap.h"
|
||
|
||
|
||
#if 0
|
||
#include "wifi_station.h"
|
||
#include "wifi_configuration_ap.h"
|
||
#include "ssid_manager.h"
|
||
#include "dns_server.h"
|
||
#endif
|
||
|
||
|
||
#define LOWERST_LIGHT_LEVEL (7222)
|
||
|
||
|
||
void on_sliderLight_valueChanged(lv_event_t * e)
|
||
{
|
||
// Your code here
|
||
// Your code here
|
||
uint32_t value = 8192-lv_slider_get_value(e->target);
|
||
//ESP_LOGI("lightSliderCallback", "value = %u", value);
|
||
if (value>LOWERST_LIGHT_LEVEL)
|
||
{
|
||
value = LOWERST_LIGHT_LEVEL;
|
||
}
|
||
|
||
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));
|
||
}
|
||
|
||
|
||
void on_dropdownDeviceType_valueChanged(lv_event_t * e)
|
||
{
|
||
char buf[32]={};
|
||
lv_dropdown_get_selected_str(e->target,buf,32);
|
||
lv_label_set_text(ui_pageHome_labelTitle, buf);
|
||
|
||
}
|
||
|
||
|
||
void on_buttonSearchWifi_clicked(lv_event_t * e)
|
||
{
|
||
wifi_scan();
|
||
}
|
||
|
||
void on_panelReadSDCard_clicked(lv_event_t * e)
|
||
{
|
||
// Your code here
|
||
|
||
}
|
||
|
||
void on_dropDownWifiName_valueChanged(lv_event_t * e)
|
||
{
|
||
// Your code here
|
||
int currentIndex=0;
|
||
|
||
currentIndex = lv_dropdown_get_selected(e->target);
|
||
|
||
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);
|
||
|
||
if (strcmp((char*)ap_info[currentIndex].ssid,"yuwell")==0)
|
||
{
|
||
lv_textarea_set_text(ui_pageWifiConnect_textAreaWifiPassword, "yuwell123456");
|
||
}
|
||
|
||
}
|
||
|
||
void on_buttonConnectWifi_clicked(lv_event_t * e)
|
||
{
|
||
int currentIndex=0;
|
||
|
||
ESP_ERROR_CHECK(esp_wifi_stop());
|
||
|
||
currentIndex = lv_dropdown_get_selected(ui_pageWifiConnect_dropdownWifiName);
|
||
|
||
|
||
// 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 = "",
|
||
},
|
||
};
|
||
|
||
lv_dropdown_get_selected_str(ui_pageWifiConnect_dropdownWifiName,(char*)wifi_config.sta.ssid,32);
|
||
|
||
strncpy((char*)wifi_config.sta.password,lv_textarea_get_text(ui_pageWifiConnect_textAreaWifiPassword),64);
|
||
|
||
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();
|
||
|
||
}
|
||
|
||
void on_buttonClearPassword_clicked(lv_event_t * e)
|
||
{
|
||
// Your code here
|
||
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);
|
||
|
||
}
|
||
|
||
|
||
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, "");
|
||
}
|
||
|
||
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);
|
||
|
||
}
|
||
|
||
void on_buttonGetWifi_clicked(lv_event_t * e)
|
||
{
|
||
|
||
} |