92 lines
1.9 KiB
C
92 lines
1.9 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "nvs_flash.h"
|
|
#include "esp_log.h"
|
|
#include "lwip/err.h"
|
|
#include "lwip/sys.h"
|
|
#include "esp_system.h"
|
|
#include "esp_err.h"
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "freertos/semphr.h"
|
|
#include "freertos/event_groups.h"
|
|
|
|
#include "driver/gpio.h"
|
|
#include "lvgl.h"
|
|
#include "sdkconfig.h"
|
|
#include "lcd.h"
|
|
|
|
|
|
#include "wifi_connect.h"
|
|
|
|
bool color = false;
|
|
static const char *TAG = "Main";
|
|
|
|
void example_lvgl_demo_ui(lv_obj_t *scr);
|
|
|
|
static void touch_event(lv_event_t *e)
|
|
{
|
|
uint8_t n = rand()%0xff;
|
|
|
|
if (e->code == LV_EVENT_CLICKED)
|
|
{
|
|
lv_obj_t *label = (lv_obj_t*)e->user_data;
|
|
if ( ! color) {
|
|
lv_obj_set_style_text_color(label, lv_color_hex(0xFFFFFF), 0);
|
|
color = true;
|
|
}
|
|
else {
|
|
lv_obj_set_style_text_color(label, lv_color_hex(0x000000), 0);
|
|
color = false;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void app_main(void)
|
|
{
|
|
|
|
ESP_ERROR_CHECK(LCDInit());
|
|
|
|
lv_obj_t *scr = lv_disp_get_scr_act(NULL);
|
|
lv_obj_set_style_bg_color(scr,lv_palette_main(LV_PALETTE_GREEN),LV_PART_MAIN);
|
|
lv_obj_t *label= lv_label_create(scr);
|
|
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
|
lv_obj_set_style_text_color(label, lv_color_hex(0x123456), 0);
|
|
//lv_obj_set_style_text_color(label, LV_COLOR_MAKE16(0xff, 0x00, 0x00), 0);
|
|
lv_label_set_text_static(label, "TheGame");
|
|
|
|
|
|
lv_obj_add_event_cb(scr, touch_event, LV_EVENT_CLICKED, label);
|
|
|
|
//
|
|
// turn on lcd backlight, to prevent displaying noise
|
|
//
|
|
gpio_set_level(LCD_PIN_BK_LIGHT, LCD_BK_LIGHT_ON_LEVEL);
|
|
|
|
//
|
|
// run the Espressif logo demo
|
|
//
|
|
//example_lvgl_demo_ui(scr);
|
|
|
|
|
|
|
|
|
|
//Initialize NVS
|
|
esp_err_t ret = nvs_flash_init();
|
|
|
|
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
|
ESP_ERROR_CHECK(nvs_flash_erase());
|
|
ret = nvs_flash_init();
|
|
}
|
|
|
|
ESP_ERROR_CHECK(ret);
|
|
ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
|
|
wifi_init_sta();
|
|
|
|
ESP_LOGI(TAG,"End of main");
|
|
}
|