[Fw] Tested animation.

This commit is contained in:
稚晖 2021-03-04 20:18:00 +08:00
parent 93a1e798c8
commit 8bb367165f
10 changed files with 101 additions and 122 deletions

View File

@ -42,11 +42,11 @@ void setup()
String password = tf.readFileLine("/wifi.txt", 2); // line-2 for WiFi password
/*** Inflate GUI objects ***/
lv_holo_cubic_gui();
//setup_ui(&guider_ui);
//lv_holo_cubic_gui();
setup_ui(&guider_ui);
/*** Read WiFi info from SD-Card, then scan & connect WiFi ***/
#if 1
#if 0
wifi.init(ssid, password);
// Change to your BiliBili UID ¡ý
@ -54,6 +54,8 @@ void setup()
#endif
}
int frame_id = 0;
char buf[100];
void loop()
{
@ -63,5 +65,12 @@ void loop()
// 200 means update IMU data every 200ms
mpu.update(200);
delay(10);
int len = sprintf(buf, "S:/Scenes/Holo3D/frame%03d.bin", frame_id++);
buf[len] = 0;
lv_img_set_src(guider_ui.scenes_canvas, buf);
Serial.println(buf);
if (frame_id == 138) frame_id = 0;
//delay(10);
}

File diff suppressed because one or more lines are too long

View File

@ -36,9 +36,6 @@
<ClInclude Include="rgb_led.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lv_demo_encoder.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lv_cubic_gui.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -98,14 +95,17 @@
<ClCompile Include="gui_guider.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="setup_scr_screen.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lv_font_simsun_12.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="events_init.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="setup_scr_home.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="setup_scr_scenes.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -5,6 +5,9 @@
void setup_ui(lv_ui* ui)
{
setup_scr_screen(ui);
lv_scr_load(ui->screen);
setup_scr_home(ui);
lv_scr_load(ui->home);
setup_scr_scenes(ui);
lv_scr_load(ui->scenes);
}

View File

@ -7,18 +7,18 @@ extern "C" {
#include "lvgl.h"
#include "guider_fonts.h"
typedef struct
{
lv_obj_t *screen;
lv_obj_t *screen_img0;
lv_obj_t *screen_btn1;
lv_obj_t *screen_btn1_label;
}lv_ui;
typedef struct
{
lv_obj_t* home;
lv_obj_t* home_cpicker0;
lv_obj_t* scenes;
lv_obj_t* scenes_canvas;
}lv_ui;
void setup_ui(lv_ui *ui);
extern lv_ui guider_ui;
void setup_scr_screen(lv_ui *ui);
void setup_ui(lv_ui* ui);
extern lv_ui guider_ui;
void setup_scr_home(lv_ui* ui);
void setup_scr_scenes(lv_ui* ui);
#ifdef __cplusplus
}

View File

@ -19,6 +19,7 @@ void lv_holo_cubic_gui(void)
scr = lv_scr_act();
lv_obj_t* img = lv_img_create(lv_scr_act(), NULL);
lv_img_set_src(img, &logo);
//lv_img_set_src(img, &logo);
lv_img_set_src(img, "S:/pic.bin");
lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0);
}

View File

@ -1,38 +0,0 @@
/**
* @file lv_demo_keypad_encoder.h
*
*/
#ifndef LV_DEMO_KEYPAD_ENCODER_H
#define LV_DEMO_KEYPAD_ENCODER_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_demo_encoder(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_DEMO_KEYPAD_ENCODER_H*/

View File

@ -0,0 +1,30 @@
/*
* Copyright 2021 NXP
* SPDX-License-Identifier: MIT
*/
#include "lvgl.h"
#include <stdio.h>
#include "gui_guider.h"
void setup_scr_home(lv_ui* ui)
{
//Write codes home
ui->home = lv_obj_create(NULL, NULL);
//Write codes home_cpicker0
ui->home_cpicker0 = lv_cpicker_create(ui->home, NULL);
//Write style LV_CPICKER_PART_MAIN for home_cpicker0
static lv_style_t style_home_cpicker0_main;
lv_style_init(&style_home_cpicker0_main);
//Write style state: LV_STATE_DEFAULT for style_home_cpicker0_main
lv_style_set_pad_inner(&style_home_cpicker0_main, LV_STATE_DEFAULT, 10);
lv_style_set_scale_width(&style_home_cpicker0_main, LV_STATE_DEFAULT, 10);
lv_obj_add_style(ui->home_cpicker0, LV_CPICKER_PART_MAIN, &style_home_cpicker0_main);
lv_obj_set_pos(ui->home_cpicker0, 15, 16);
lv_obj_set_size(ui->home_cpicker0, 200, 200);
lv_cpicker_set_type(ui->home_cpicker0, LV_CPICKER_TYPE_DISC);
}

View File

@ -0,0 +1,31 @@
/*
* Copyright 2021 NXP
* SPDX-License-Identifier: MIT
*/
#include "lvgl.h"
#include <stdio.h>
#include "gui_guider.h"
void setup_scr_scenes(lv_ui* ui)
{
//Write codes scenes
ui->scenes = lv_obj_create(NULL, NULL);
//Write codes scenes_canvas
ui->scenes_canvas = lv_img_create(ui->scenes, NULL);
//Write style LV_IMG_PART_MAIN for scenes_canvas
static lv_style_t style_scenes_canvas_main;
lv_style_init(&style_scenes_canvas_main);
lv_style_set_bg_color(&style_scenes_canvas_main, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_style_set_bg_color(&style_scenes_canvas_main, LV_STATE_PRESSED, LV_COLOR_GRAY);
lv_style_set_bg_color(&style_scenes_canvas_main, LV_STATE_FOCUSED, LV_COLOR_BLACK);
//Write style state: LV_STATE_DEFAULT for style_scenes_canvas_main
lv_obj_add_style(ui->scenes, LV_BTN_PART_MAIN, &style_scenes_canvas_main);
lv_img_set_src(ui->scenes_canvas, "S:/Scenes/Holo3D/frame000.bin");
lv_obj_align(ui->scenes_canvas, NULL, LV_ALIGN_CENTER, 0, 0);
}

View File

@ -1,57 +0,0 @@
#include "lvgl.h"
#include <stdio.h>
#include "gui_guider.h"
#include "events_init.h"
void setup_scr_screen(lv_ui* ui)
{
//Write codes screen
ui->screen = lv_obj_create(NULL, NULL);
//Write codes screen_img0
ui->screen_img0 = lv_img_create(ui->screen, NULL);
//Write style LV_IMG_PART_MAIN for screen_img0
static lv_style_t style_screen_img0_main;
lv_style_init(&style_screen_img0_main);
//Write style state: LV_STATE_DEFAULT for style_screen_img0_main
lv_style_set_image_recolor(&style_screen_img0_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
lv_style_set_image_recolor_opa(&style_screen_img0_main, LV_STATE_DEFAULT, 0);
lv_style_set_image_opa(&style_screen_img0_main, LV_STATE_DEFAULT, 255);
lv_obj_add_style(ui->screen_img0, LV_IMG_PART_MAIN, &style_screen_img0_main);
lv_obj_set_pos(ui->screen_img0, 0, 0);
lv_obj_set_size(ui->screen_img0, 240, 240);
lv_obj_set_click(ui->screen_img0, true);
lv_img_set_src(ui->screen_img0, "S:/logo.bin");
lv_img_set_pivot(ui->screen_img0, 0, 0);
lv_img_set_angle(ui->screen_img0, 0);
//Write codes screen_btn1
ui->screen_btn1 = lv_btn_create(ui->screen, NULL);
//Write style LV_BTN_PART_MAIN for screen_btn1
static lv_style_t style_screen_btn1_main;
lv_style_init(&style_screen_btn1_main);
//Write style state: LV_STATE_DEFAULT for style_screen_btn1_main
lv_style_set_radius(&style_screen_btn1_main, LV_STATE_DEFAULT, 50);
lv_style_set_bg_color(&style_screen_btn1_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
lv_style_set_bg_grad_color(&style_screen_btn1_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
lv_style_set_bg_grad_dir(&style_screen_btn1_main, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
lv_style_set_bg_opa(&style_screen_btn1_main, LV_STATE_DEFAULT, 255);
lv_style_set_border_color(&style_screen_btn1_main, LV_STATE_DEFAULT, lv_color_make(0x01, 0xa2, 0xb1));
lv_style_set_border_width(&style_screen_btn1_main, LV_STATE_DEFAULT, 2);
lv_style_set_border_opa(&style_screen_btn1_main, LV_STATE_DEFAULT, 255);
lv_style_set_outline_color(&style_screen_btn1_main, LV_STATE_DEFAULT, lv_color_make(0xd4, 0xd7, 0xd9));
lv_style_set_outline_opa(&style_screen_btn1_main, LV_STATE_DEFAULT, 255);
lv_obj_add_style(ui->screen_btn1, LV_BTN_PART_MAIN, &style_screen_btn1_main);
lv_obj_set_pos(ui->screen_btn1, 81, 159);
lv_obj_set_size(ui->screen_btn1, 100, 50);
ui->screen_btn1_label = lv_label_create(ui->screen_btn1, NULL);
lv_label_set_text(ui->screen_btn1_label, "default");
lv_obj_set_style_local_text_color(ui->screen_btn1_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(0x00, 0x00, 0x00));
lv_obj_set_style_local_text_font(ui->screen_btn1_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_simsun_12);
}