Added VNC@moononournation
This commit is contained in:
@@ -0,0 +1,565 @@
|
||||
/*******************************************************************************
|
||||
* LVGL Arduino VNC
|
||||
* This is a T-Deck version VNC sample
|
||||
*
|
||||
* Dependent libraries:
|
||||
* LVGL: https://github.com/lvgl/lvgl.git
|
||||
* ArduinoVNC: https://github.com/moononournation/arduinoVNC.git
|
||||
*
|
||||
* Touch libraries:
|
||||
* XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
|
||||
* TouchLib: https://github.com/mmMicky/TouchLib.git
|
||||
*
|
||||
* LVGL Configuration file:
|
||||
* Copy your_arduino_path/libraries/lvgl/lv_conf_template.h
|
||||
* to your_arduino_path/libraries/lv_conf.h
|
||||
*
|
||||
* In lv_conf.h around line 15, enable config file:
|
||||
* #if 1 // Set it to "1" to enable content
|
||||
*
|
||||
* Then find and set:
|
||||
* #define LV_COLOR_DEPTH 16
|
||||
* #define LV_TICK_CUSTOM 1
|
||||
*
|
||||
* For SPI/parallel 8 display set color swap can be faster, parallel 16/RGB screen don't swap!
|
||||
* #define LV_COLOR_16_SWAP 1 // for SPI and parallel 8
|
||||
* #define LV_COLOR_16_SWAP 0 // for parallel 16 and RGB
|
||||
******************************************************************************/
|
||||
#include <lvgl.h>
|
||||
#include "ui.h"
|
||||
|
||||
#define TRACK_SPEED 3
|
||||
|
||||
#include "TDECK_PINS.h"
|
||||
#include "WiFi.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Start of Arduino_GFX setting
|
||||
*
|
||||
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
|
||||
* Or you can define the display dev kit not in the board list
|
||||
* Defalult pin list for non display dev kit:
|
||||
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
|
||||
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
|
||||
* ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
|
||||
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
|
||||
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
|
||||
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
|
||||
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
|
||||
* RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
|
||||
* RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11
|
||||
* RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
|
||||
* RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10
|
||||
* Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9
|
||||
* Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
|
||||
******************************************************************************/
|
||||
#include <Arduino_GFX_Library.h>
|
||||
#define GFX_DEV_DEVICE LILYGO_T_DECK
|
||||
#define GFX_BL TDECK_TFT_BACKLIGHT
|
||||
Arduino_DataBus *bus = new Arduino_ESP32SPI(TDECK_TFT_DC, TDECK_TFT_CS, TDECK_SPI_SCK, TDECK_SPI_MOSI, TDECK_SPI_MISO);
|
||||
Arduino_GFX *gfx = new Arduino_ST7789(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */, false /* IPS */);
|
||||
Arduino_Canvas *canvasGfx = new Arduino_Canvas(640 /* width */, 480 /* height */, gfx);
|
||||
/*******************************************************************************
|
||||
* End of Arduino_GFX setting
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Please config the touch panel in touch.h
|
||||
******************************************************************************/
|
||||
#include "touch.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Please config the keyboard in keyboard.h
|
||||
******************************************************************************/
|
||||
#include "keyboard.h"
|
||||
|
||||
#include "VNC_GFX.h"
|
||||
#include <VNC.h>
|
||||
|
||||
enum CONNECT_STATUS
|
||||
{
|
||||
scan_wifi,
|
||||
select_wifi,
|
||||
connecting_wifi,
|
||||
select_vnc,
|
||||
connecting_vnc,
|
||||
connected_vnc
|
||||
};
|
||||
|
||||
CONNECT_STATUS status = scan_wifi;
|
||||
VNC_GFX *vnc_gfx = new VNC_GFX(canvasGfx);
|
||||
arduinoVNC vnc = arduinoVNC(vnc_gfx);
|
||||
|
||||
/* Change to your screen resolution */
|
||||
static uint32_t screenWidth;
|
||||
static uint32_t screenHeight;
|
||||
static lv_disp_draw_buf_t draw_buf;
|
||||
static lv_color_t *disp_draw_buf;
|
||||
static lv_disp_drv_t disp_drv;
|
||||
|
||||
/* Display flushing */
|
||||
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
uint32_t w = (area->x2 - area->x1 + 1);
|
||||
uint32_t h = (area->y2 - area->y1 + 1);
|
||||
|
||||
#if (LV_COLOR_16_SWAP != 0)
|
||||
gfx->draw16bitBeRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
|
||||
#else
|
||||
gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
|
||||
#endif
|
||||
|
||||
lv_disp_flush_ready(disp);
|
||||
}
|
||||
|
||||
int16_t x = 0;
|
||||
int16_t y = 0;
|
||||
bool trackball_interrupted = false;
|
||||
int16_t trackball_up_count = 1;
|
||||
int16_t trackball_down_count = 1;
|
||||
int16_t trackball_left_count = 1;
|
||||
int16_t trackball_right_count = 1;
|
||||
int16_t trackball_click_count = 0;
|
||||
void IRAM_ATTR ISR_up()
|
||||
{
|
||||
trackball_interrupted = true;
|
||||
trackball_up_count <<= TRACK_SPEED;
|
||||
}
|
||||
void IRAM_ATTR ISR_down()
|
||||
{
|
||||
trackball_interrupted = true;
|
||||
trackball_down_count <<= TRACK_SPEED;
|
||||
}
|
||||
void IRAM_ATTR ISR_left()
|
||||
{
|
||||
trackball_interrupted = true;
|
||||
trackball_left_count <<= TRACK_SPEED;
|
||||
}
|
||||
void IRAM_ATTR ISR_right()
|
||||
{
|
||||
trackball_interrupted = true;
|
||||
trackball_right_count <<= TRACK_SPEED;
|
||||
}
|
||||
void IRAM_ATTR ISR_click()
|
||||
{
|
||||
trackball_interrupted = true;
|
||||
++trackball_click_count;
|
||||
}
|
||||
void handle_trackball()
|
||||
{
|
||||
if (trackball_interrupted)
|
||||
{
|
||||
// Serial.printf("x: %d, y: %d, left: %d, right: %d, up: %d, down: %d, click: %d\n", x, y, trackball_left_count, trackball_right_count, trackball_up_count, trackball_down_count, trackball_click_count);
|
||||
x -= trackball_left_count;
|
||||
x += trackball_right_count;
|
||||
y -= trackball_up_count;
|
||||
y += trackball_down_count;
|
||||
|
||||
if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
else if (x > 639)
|
||||
{
|
||||
x = 639;
|
||||
}
|
||||
if (y < 0)
|
||||
{
|
||||
y = 0;
|
||||
}
|
||||
else if (y > 479)
|
||||
{
|
||||
y = 479;
|
||||
}
|
||||
|
||||
if (trackball_click_count)
|
||||
{
|
||||
vnc.mouseEvent(x, y, 0b001);
|
||||
vnc.mouseEvent(x, y, 0b000);
|
||||
}
|
||||
else
|
||||
{
|
||||
vnc.mouseEvent(x, y, 0b000);
|
||||
}
|
||||
|
||||
trackball_interrupted = false;
|
||||
trackball_up_count = 1;
|
||||
trackball_down_count = 1;
|
||||
trackball_left_count = 1;
|
||||
trackball_right_count = 1;
|
||||
trackball_click_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void handle_keyboard()
|
||||
{
|
||||
int key = keyboard_get_key();
|
||||
if (key > 0)
|
||||
{
|
||||
Serial.println(key);
|
||||
switch (key)
|
||||
{
|
||||
case 8:
|
||||
key = 0xff08; // BackSpace
|
||||
break;
|
||||
case 9:
|
||||
key = 0xff09; // Tab
|
||||
break;
|
||||
case 10:
|
||||
case 13:
|
||||
key = 0xff0d; // Return or Enter
|
||||
break;
|
||||
case 27:
|
||||
key = 0xff1b; // Escape
|
||||
break;
|
||||
case 180:
|
||||
key = 0xff51; // Left
|
||||
break;
|
||||
case 181:
|
||||
key = 0xff52; // Up
|
||||
break;
|
||||
case 182:
|
||||
key = 0xff54; // Down
|
||||
break;
|
||||
case 183:
|
||||
key = 0xff53; // Right
|
||||
break;
|
||||
}
|
||||
vnc.keyEvent(key, 0b001);
|
||||
vnc.keyEvent(key, 0b000);
|
||||
}
|
||||
}
|
||||
|
||||
void my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
|
||||
{
|
||||
if (touch_has_signal())
|
||||
{
|
||||
if (touch_touched())
|
||||
{
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
|
||||
/*Set the coordinates*/
|
||||
data->point.x = touch_last_x;
|
||||
data->point.y = touch_last_y;
|
||||
}
|
||||
else if (touch_released())
|
||||
{
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
}
|
||||
|
||||
void my_keyboard_read(lv_indev_drv_t *drv, lv_indev_data_t *data)
|
||||
{
|
||||
static uint32_t last_key = 0;
|
||||
if (last_key)
|
||||
{
|
||||
data->key = last_key;
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
|
||||
last_key = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t key;
|
||||
|
||||
if (trackball_up_count)
|
||||
{
|
||||
key = LV_KEY_UP;
|
||||
--trackball_up_count;
|
||||
}
|
||||
else if (trackball_down_count)
|
||||
{
|
||||
key = LV_KEY_DOWN;
|
||||
--trackball_down_count;
|
||||
}
|
||||
else if (trackball_left_count)
|
||||
{
|
||||
key = LV_KEY_LEFT;
|
||||
--trackball_left_count;
|
||||
}
|
||||
else if (trackball_right_count)
|
||||
{
|
||||
key = LV_KEY_RIGHT;
|
||||
--trackball_right_count;
|
||||
}
|
||||
else if (trackball_click_count)
|
||||
{
|
||||
key = LV_KEY_ENTER;
|
||||
--trackball_click_count;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = keyboard_get_key();
|
||||
}
|
||||
|
||||
if (key > 0)
|
||||
{
|
||||
// Serial.println(key);
|
||||
switch (key)
|
||||
{
|
||||
case 8:
|
||||
key = LV_KEY_BACKSPACE; // BackSpace
|
||||
break;
|
||||
case 9:
|
||||
key = LV_KEY_NEXT; // Tab
|
||||
break;
|
||||
case 10:
|
||||
case 13:
|
||||
key = LV_KEY_ENTER; // Return or Enter
|
||||
break;
|
||||
case 27:
|
||||
key = LV_KEY_ESC; // Escape
|
||||
break;
|
||||
case 180:
|
||||
key = LV_KEY_LEFT; // Left
|
||||
break;
|
||||
case 181:
|
||||
key = LV_KEY_UP; // Up
|
||||
break;
|
||||
case 182:
|
||||
key = LV_KEY_DOWN; // Down
|
||||
break;
|
||||
case 183:
|
||||
key = LV_KEY_RIGHT; // Right
|
||||
break;
|
||||
}
|
||||
|
||||
data->key = key;
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
|
||||
last_key = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void scanWiFi()
|
||||
{
|
||||
status = scan_wifi;
|
||||
|
||||
// WiFi.scanNetworks will return the number of networks found.
|
||||
int n = WiFi.scanNetworks();
|
||||
Serial.println("Scan done");
|
||||
if (n == 0)
|
||||
{
|
||||
lv_roller_set_options(ui_RollerWiFiAP, "No networks found!", LV_ROLLER_MODE_NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
String stringWiFiList = "";
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
// Print SSID and RSSI for each network found
|
||||
if (i > 0)
|
||||
{
|
||||
stringWiFiList += '\n';
|
||||
}
|
||||
stringWiFiList += WiFi.SSID(i);
|
||||
}
|
||||
lv_roller_set_options(ui_RollerWiFiAP, stringWiFiList.c_str(), LV_ROLLER_MODE_NORMAL);
|
||||
}
|
||||
|
||||
// Delete the scan result to free memory for code below.
|
||||
WiFi.scanDelete();
|
||||
|
||||
status = select_wifi;
|
||||
}
|
||||
|
||||
void connectWiFi(lv_event_t *e)
|
||||
{
|
||||
status = connecting_wifi;
|
||||
|
||||
lv_scr_load_anim(ui_Screen2, LV_SCR_LOAD_ANIM_MOVE_LEFT, 300, 0, false);
|
||||
|
||||
char strWiFiAP[256];
|
||||
lv_roller_get_selected_str(ui_RollerWiFiAP, strWiFiAP, sizeof(strWiFiAP));
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(strWiFiAP, lv_textarea_get_text(ui_TextWiFiPassword));
|
||||
}
|
||||
|
||||
void connectVNC(lv_event_t *e)
|
||||
{
|
||||
status = connecting_vnc;
|
||||
|
||||
lv_scr_load_anim(ui_Screen2, LV_SCR_LOAD_ANIM_MOVE_LEFT, 300, 0, false);
|
||||
|
||||
int port = atoi(lv_textarea_get_text(ui_TextVNCPort));
|
||||
|
||||
vnc.begin(lv_textarea_get_text(ui_TextVNCHost), port);
|
||||
vnc.setPassword(lv_textarea_get_text(ui_TextVNCPassword)); // optional
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
// Serial.setDebugOutput(true);
|
||||
// while(!Serial);
|
||||
Serial.println("LVGL Arduino VNC");
|
||||
|
||||
// Set WiFi to station mode and disconnect from an AP if it was previously connected.
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.disconnect();
|
||||
|
||||
//! ⚠️ The board peripheral power control pin needs to be set to HIGH when using the peripheral
|
||||
pinMode(TDECK_PERI_POWERON, OUTPUT);
|
||||
digitalWrite(TDECK_PERI_POWERON, HIGH);
|
||||
|
||||
// There needs to be a delay after power on, give LILYGO-KEYBOARD some startup time
|
||||
delay(500);
|
||||
|
||||
#ifdef GFX_EXTRA_PRE_INIT
|
||||
GFX_EXTRA_PRE_INIT();
|
||||
#endif
|
||||
|
||||
// Init Display
|
||||
if (!canvasGfx->begin(80000000))
|
||||
{
|
||||
Serial.println("gfx->begin() failed!");
|
||||
}
|
||||
gfx->fillScreen(BLACK);
|
||||
|
||||
#ifdef GFX_BL
|
||||
// pinMode(GFX_BL, OUTPUT);
|
||||
// digitalWrite(GFX_BL, HIGH);
|
||||
ledcSetup(0, 1000, 8);
|
||||
ledcAttachPin(GFX_BL, 0);
|
||||
ledcWrite(0, 191);
|
||||
#endif
|
||||
|
||||
// Init touch device
|
||||
touch_init(gfx->width(), gfx->height(), gfx->getRotation());
|
||||
|
||||
// Init keyboard device
|
||||
keyboard_init();
|
||||
|
||||
// Init touch device
|
||||
pinMode(TDECK_TRACKBALL_UP, INPUT_PULLUP);
|
||||
attachInterrupt(TDECK_TRACKBALL_UP, ISR_up, FALLING);
|
||||
pinMode(TDECK_TRACKBALL_DOWN, INPUT_PULLUP);
|
||||
attachInterrupt(TDECK_TRACKBALL_DOWN, ISR_down, FALLING);
|
||||
pinMode(TDECK_TRACKBALL_LEFT, INPUT_PULLUP);
|
||||
attachInterrupt(TDECK_TRACKBALL_LEFT, ISR_left, FALLING);
|
||||
pinMode(TDECK_TRACKBALL_RIGHT, INPUT_PULLUP);
|
||||
attachInterrupt(TDECK_TRACKBALL_RIGHT, ISR_right, FALLING);
|
||||
pinMode(TDECK_TRACKBALL_CLICK, INPUT_PULLUP);
|
||||
attachInterrupt(TDECK_TRACKBALL_CLICK, ISR_click, FALLING);
|
||||
|
||||
lv_init();
|
||||
|
||||
screenWidth = gfx->width();
|
||||
screenHeight = gfx->height();
|
||||
#ifdef ESP32
|
||||
disp_draw_buf = (lv_color_t *)heap_caps_malloc(sizeof(lv_color_t) * screenWidth * 40, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||
#else
|
||||
disp_draw_buf = (lv_color_t *)malloc(sizeof(lv_color_t) * screenWidth * 40);
|
||||
#endif
|
||||
if (!disp_draw_buf)
|
||||
{
|
||||
Serial.println("LVGL disp_draw_buf allocate failed!");
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_disp_draw_buf_init(&draw_buf, disp_draw_buf, NULL, screenWidth * 40);
|
||||
|
||||
/* Initialize the display */
|
||||
lv_disp_drv_init(&disp_drv);
|
||||
/* Change the following line to your display resolution */
|
||||
disp_drv.hor_res = screenWidth;
|
||||
disp_drv.ver_res = screenHeight;
|
||||
disp_drv.flush_cb = my_disp_flush;
|
||||
disp_drv.draw_buf = &draw_buf;
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
|
||||
/* Initialize the input device driver */
|
||||
static lv_indev_drv_t indev_drv;
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read_cb = my_touchpad_read;
|
||||
lv_indev_drv_register(&indev_drv);
|
||||
|
||||
static lv_indev_drv_t indev_drv_key;
|
||||
lv_indev_drv_init(&indev_drv_key);
|
||||
indev_drv_key.type = LV_INDEV_TYPE_KEYPAD;
|
||||
indev_drv_key.read_cb = my_keyboard_read;
|
||||
static lv_indev_t *kb_indev = lv_indev_drv_register(&indev_drv_key);
|
||||
|
||||
static lv_group_t *g = lv_group_create();
|
||||
lv_group_set_default(g);
|
||||
lv_indev_set_group(kb_indev, g);
|
||||
|
||||
/* Init SquareLine prepared UI */
|
||||
ui_init();
|
||||
|
||||
lv_obj_add_event_cb(ui_ButtonWiFiConnect, connectWiFi, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_add_event_cb(ui_ButtonVNCConnect, connectVNC, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
Serial.println("Setup done");
|
||||
|
||||
lv_timer_handler(); /* let the GUI do its work */
|
||||
|
||||
scanWiFi();
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (status == select_wifi)
|
||||
{
|
||||
// Serial.println("select_wifi");
|
||||
lv_timer_handler(); /* let the GUI do its work */
|
||||
}
|
||||
else if (status == connecting_wifi)
|
||||
{
|
||||
// Serial.println("connecting_wifi");
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
{
|
||||
lv_scr_load_anim(ui_Screen3, LV_SCR_LOAD_ANIM_MOVE_LEFT, 300, 0, false);
|
||||
status = select_vnc;
|
||||
}
|
||||
lv_timer_handler(); /* let the GUI do its work */
|
||||
}
|
||||
else if (status == select_vnc)
|
||||
{
|
||||
// Serial.println("select_vnc");
|
||||
if (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
vnc.reconnect();
|
||||
lv_scr_load_anim(ui_Screen2, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 300, 0, false);
|
||||
status = connecting_wifi;
|
||||
}
|
||||
lv_timer_handler(); /* let the GUI do its work */
|
||||
}
|
||||
else if (status == connecting_vnc)
|
||||
{
|
||||
// Serial.println("connecting_vnc");
|
||||
if (vnc.connected())
|
||||
{
|
||||
status = connected_vnc;
|
||||
}
|
||||
vnc.loop();
|
||||
lv_timer_handler(); /* let the GUI do its work */
|
||||
}
|
||||
else if (status == connected_vnc)
|
||||
{
|
||||
// Serial.println("connected_vnc");
|
||||
if (!vnc.connected())
|
||||
{
|
||||
status = connecting_vnc;
|
||||
lv_scr_load_anim(ui_Screen2, LV_SCR_LOAD_ANIM_MOVE_LEFT, 300, 0, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
handle_trackball();
|
||||
handle_keyboard();
|
||||
}
|
||||
vnc.loop();
|
||||
canvasGfx->flushQuad();
|
||||
}
|
||||
|
||||
delay(5);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
//! The board peripheral power control pin needs to be set to HIGH when using the peripheral
|
||||
#define TDECK_PERI_POWERON 10
|
||||
|
||||
#define TDECK_SPI_MOSI 41
|
||||
#define TDECK_SPI_MISO 38
|
||||
#define TDECK_SPI_SCK 40
|
||||
|
||||
#define TDECK_SDCARD_CS 39
|
||||
|
||||
#define TDECK_TFT_CS 12
|
||||
#define TDECK_TFT_DC 11
|
||||
#define TDECK_TFT_BACKLIGHT 42
|
||||
|
||||
#define TDECK_RADIO_CS 9
|
||||
#define TDECK_RADIO_BUSY 13
|
||||
#define TDECK_RADIO_RST 17
|
||||
#define TDECK_RADIO_DIO1 45
|
||||
|
||||
#define TDECK_I2C_SDA 18
|
||||
#define TDECK_I2C_SCL 8
|
||||
|
||||
#define TDECK_TOUCH_INT 16
|
||||
#define TDECK_KEYBOARD_INT 46
|
||||
|
||||
#define TDECK_KEYBOARD_ADDR 0x55
|
||||
|
||||
#define TDECK_TRACKBALL_UP 3
|
||||
#define TDECK_TRACKBALL_DOWN 15
|
||||
#define TDECK_TRACKBALL_LEFT 1
|
||||
#define TDECK_TRACKBALL_RIGHT 2
|
||||
#define TDECK_TRACKBALL_CLICK 0
|
||||
|
||||
#define TDECK_ES7210_MCLK 48
|
||||
#define TDECK_ES7210_LRCK 21
|
||||
#define TDECK_ES7210_SCK 47
|
||||
#define TDECK_ES7210_DIN 14
|
||||
|
||||
#define TDECK_I2S_WS 5
|
||||
#define TDECK_I2S_BCK 7
|
||||
#define TDECK_I2S_DOUT 6
|
||||
|
||||
#define TDECK_BAT_ADC 4
|
||||
@@ -0,0 +1,185 @@
|
||||
#ifndef _VNC_GFX_H_
|
||||
#define _VNC_GFX_H_
|
||||
|
||||
#include "Arduino_GFX_Library.h"
|
||||
#include "VNC.h"
|
||||
#include "VNC_config.h"
|
||||
|
||||
#ifdef ESP32
|
||||
// #define SEPARATE_DRAW_TASK
|
||||
#endif
|
||||
|
||||
#ifdef SEPARATE_DRAW_TASK
|
||||
|
||||
#define NUMBER_OF_DRAW_BUFFER 64
|
||||
|
||||
typedef struct
|
||||
{
|
||||
xQueueHandle xqh;
|
||||
Arduino_GFX *gfx;
|
||||
} ParamDrawTask;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t w;
|
||||
int16_t h;
|
||||
bool isBitmap;
|
||||
uint16_t *buf;
|
||||
} DrawData;
|
||||
|
||||
static xQueueHandle _xqh;
|
||||
static ParamDrawTask _pDrawTask;
|
||||
static TaskHandle_t _draw_task_handle;
|
||||
|
||||
static DrawData drawDatas[NUMBER_OF_DRAW_BUFFER];
|
||||
static int draw_queue_cnt = 0;
|
||||
|
||||
static void queueDrawTask(uint32_t x, uint32_t y, uint32_t w, uint32_t h, bool isBitmap, uint16_t *d)
|
||||
{
|
||||
log_i("queueDrawTask start.");
|
||||
DrawData *dd = &drawDatas[draw_queue_cnt % NUMBER_OF_DRAW_BUFFER];
|
||||
dd->x = x;
|
||||
dd->y = y;
|
||||
dd->w = w;
|
||||
dd->h = h;
|
||||
dd->isBitmap = isBitmap;
|
||||
log_i("copy data start.");
|
||||
uint16_t *p = &dd->buf[0];
|
||||
if (isBitmap)
|
||||
{
|
||||
log_i("copy bitmap.");
|
||||
int i = w * h;
|
||||
while (i--)
|
||||
{
|
||||
*p++ = *d++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*p = *d;
|
||||
}
|
||||
log_i("copy data end.");
|
||||
|
||||
++draw_queue_cnt;
|
||||
|
||||
log_i("xQueueSend start.");
|
||||
xQueueSend(_xqh, &dd, portMAX_DELAY);
|
||||
log_i("xQueueSend end.");
|
||||
|
||||
log_i("queueDrawTask end.");
|
||||
}
|
||||
|
||||
static void draw_task(void *arg)
|
||||
{
|
||||
DrawData *dd;
|
||||
log_i("draw_task start.");
|
||||
while (xQueueReceive(_xqh, &dd, portMAX_DELAY))
|
||||
{
|
||||
log_i("draw_task work start: x: %d, y: %d, w: %d, h: %d.", dd->x, dd->y, dd->w, dd->h);
|
||||
if (dd->isBitmap)
|
||||
{
|
||||
gfx->draw16bitBeRGBBitmap(dd->x, dd->y, &dd->buf[0], dd->w, dd->h);
|
||||
}
|
||||
else
|
||||
{
|
||||
gfx->fillRect(dd->x, dd->y, dd->w, dd->h, dd->buf[0]);
|
||||
}
|
||||
log_i("draw_task work end.");
|
||||
}
|
||||
vQueueDelete(_xqh);
|
||||
log_i("draw_task end.");
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void draw_task_setup()
|
||||
{
|
||||
_xqh = xQueueCreate(NUMBER_OF_DRAW_BUFFER, sizeof(DrawData));
|
||||
_pDrawTask.xqh = _xqh;
|
||||
_pDrawTask.gfx = gfx;
|
||||
|
||||
log_i("xTaskCreatePinnedToCore start");
|
||||
xTaskCreatePinnedToCore(
|
||||
(TaskFunction_t)draw_task,
|
||||
(const char *const)"Draw Task",
|
||||
(const uint32_t)1600,
|
||||
(void *const)&_pDrawTask,
|
||||
(UBaseType_t)configMAX_PRIORITIES - 1,
|
||||
(TaskHandle_t *const)&_draw_task_handle,
|
||||
(const BaseType_t)0);
|
||||
log_i("xTaskCreatePinnedToCore end");
|
||||
|
||||
for (int i = 0; i < NUMBER_OF_DRAW_BUFFER; i++)
|
||||
{
|
||||
if (!drawDatas[i].buf)
|
||||
{
|
||||
drawDatas[i].buf = (uint16_t *)malloc(FB_SIZE * 2);
|
||||
}
|
||||
if (drawDatas[i].buf)
|
||||
{
|
||||
log_i("#%d draw buffer allocated.", i);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_e("#%d draw buffer allocat failed.", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
class VNC_GFX : public VNCdisplay
|
||||
{
|
||||
public:
|
||||
VNC_GFX(Arduino_GFX *gfx)
|
||||
{
|
||||
_gfx = gfx;
|
||||
}
|
||||
|
||||
bool hasCopyRect(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t getHeight(void)
|
||||
{
|
||||
return _gfx->height();
|
||||
}
|
||||
uint32_t getWidth(void)
|
||||
{
|
||||
return _gfx->width();
|
||||
}
|
||||
|
||||
void draw_area(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t *data)
|
||||
{
|
||||
// DEBUG_VNC("draw_area(%d, %d, %d, %d, data)\n", x, y, w, h);
|
||||
#ifdef SEPARATE_DRAW_TASK
|
||||
queueDrawTask(x, y, w, h, true, (uint16_t *)data);
|
||||
#else
|
||||
// _gfx->draw16bitBeRGBBitmap(x, y, (uint16_t *)data, w, h);
|
||||
_gfx->draw16bitRGBBitmap(x, y, (uint16_t *)data, w, h);
|
||||
#endif
|
||||
}
|
||||
|
||||
void draw_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint16_t color)
|
||||
{
|
||||
// DEBUG_VNC("draw_rect(%d, %d, %d, %d, color)\n", x, y, w, h);
|
||||
// MSB_16_SET(color, color);
|
||||
#ifdef SEPARATE_DRAW_TASK
|
||||
queueDrawTask(x, y, w, h, false, &color);
|
||||
#else
|
||||
_gfx->fillRect(x, y, w, h, color);
|
||||
#endif
|
||||
}
|
||||
|
||||
void vnc_options_override(dfb_vnc_options *opt)
|
||||
{
|
||||
// opt->client.bigendian = 1;
|
||||
}
|
||||
|
||||
private:
|
||||
Arduino_GFX *_gfx;
|
||||
};
|
||||
|
||||
#endif /* _VNC_GFX_H_ */
|
||||
@@ -0,0 +1,25 @@
|
||||
/*******************************************************************************
|
||||
* Keyboard libraries:
|
||||
* https://github.com/Xinyuan-LilyGO/T-Deck/tree/master/examples/Keyboard_T_Deck_Master
|
||||
******************************************************************************/
|
||||
|
||||
#include "TDECK_PINS.h"
|
||||
#include <Wire.h>
|
||||
|
||||
void keyboard_init() {
|
||||
// Check keyboard
|
||||
Wire.requestFrom(TDECK_KEYBOARD_ADDR, 1);
|
||||
if (Wire.read() == -1) {
|
||||
Serial.println("LILYGO Keyboad not online!");
|
||||
}
|
||||
}
|
||||
|
||||
char keyboard_get_key() {
|
||||
// Read key value from esp32c3
|
||||
Wire.requestFrom(TDECK_KEYBOARD_ADDR, 1);
|
||||
if (Wire.available() > 0) {
|
||||
return Wire.read();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
/*******************************************************************************
|
||||
* Touch libraries:
|
||||
* XPT2046: https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
|
||||
*
|
||||
* Capacitive touchscreen libraries
|
||||
* TouchLib: https://github.com/mmMicky/TouchLib.git
|
||||
******************************************************************************/
|
||||
|
||||
/* uncomment for XPT2046 */
|
||||
// #define TOUCH_XPT2046
|
||||
// #define TOUCH_XPT2046_SCK 12
|
||||
// #define TOUCH_XPT2046_MISO 13
|
||||
// #define TOUCH_XPT2046_MOSI 11
|
||||
// #define TOUCH_XPT2046_CS 10
|
||||
// #define TOUCH_XPT2046_INT 18
|
||||
// #define TOUCH_XPT2046_ROTATION 0
|
||||
// #define TOUCH_XPT2046_SAMPLES 50
|
||||
|
||||
// uncomment for most capacitive touchscreen
|
||||
#define TOUCH_MODULES_GT911 // GT911 / CST_SELF / CST_MUTUAL / ZTW622 / L58 / FT3267 / FT5x06
|
||||
#define TOUCH_MODULE_ADDR GT911_SLAVE_ADDRESS1 // CTS328_SLAVE_ADDRESS / L58_SLAVE_ADDRESS / CTS826_SLAVE_ADDRESS / CTS820_SLAVE_ADDRESS / CTS816S_SLAVE_ADDRESS / FT3267_SLAVE_ADDRESS / FT5x06_ADDR / GT911_SLAVE_ADDRESS1 / GT911_SLAVE_ADDRESS2 / ZTW622_SLAVE1_ADDRESS / ZTW622_SLAVE2_ADDRESS
|
||||
#define TOUCH_SCL 8
|
||||
#define TOUCH_SDA 18
|
||||
#define TOUCH_RES -1
|
||||
#define TOUCH_INT 16
|
||||
|
||||
// Please fill below values from Arduino_GFX Example - TouchCalibration
|
||||
bool touch_swap_xy = false;
|
||||
int16_t touch_map_x1 = -1;
|
||||
int16_t touch_map_x2 = -1;
|
||||
int16_t touch_map_y1 = -1;
|
||||
int16_t touch_map_y2 = -1;
|
||||
|
||||
int16_t touch_max_x = 0, touch_max_y = 0;
|
||||
int16_t touch_raw_x = 0, touch_raw_y = 0;
|
||||
int16_t touch_last_x = 0, touch_last_y = 0;
|
||||
|
||||
#if defined(TOUCH_XPT2046)
|
||||
#include <XPT2046_Touchscreen.h>
|
||||
#include <SPI.h>
|
||||
XPT2046_Touchscreen ts(TOUCH_XPT2046_CS, TOUCH_XPT2046_INT);
|
||||
|
||||
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
|
||||
#include <Wire.h>
|
||||
#include <TouchLib.h>
|
||||
// TouchLib touch(Wire, TOUCH_SDA, TOUCH_SCL, TOUCH_MODULE_ADDR);
|
||||
TouchLib *touch = NULL;
|
||||
uint8_t touchAddress = GT911_SLAVE_ADDRESS2;
|
||||
#endif // TouchLib
|
||||
|
||||
|
||||
void scanDevices(TwoWire *w)
|
||||
{
|
||||
uint8_t err, addr;
|
||||
int nDevices = 0;
|
||||
uint32_t start = 0;
|
||||
for (addr = 1; addr < 127; addr++) {
|
||||
start = millis();
|
||||
w->beginTransmission(addr); delay(2);
|
||||
err = w->endTransmission();
|
||||
if (err == 0) {
|
||||
nDevices++;
|
||||
Serial.print("I2C device found at address 0x");
|
||||
if (addr < 16) {
|
||||
Serial.print("0");
|
||||
}
|
||||
Serial.print(addr, HEX);
|
||||
Serial.println(" !");
|
||||
|
||||
if (addr == GT911_SLAVE_ADDRESS2) {
|
||||
touchAddress = GT911_SLAVE_ADDRESS2;
|
||||
Serial.println("Find GT911 Drv Slave address: 0x14");
|
||||
} else if (addr == GT911_SLAVE_ADDRESS1) {
|
||||
touchAddress = GT911_SLAVE_ADDRESS1;
|
||||
Serial.println("Find GT911 Drv Slave address: 0x5D");
|
||||
}
|
||||
} else if (err == 4) {
|
||||
Serial.print("Unknow error at address 0x");
|
||||
if (addr < 16) {
|
||||
Serial.print("0");
|
||||
}
|
||||
Serial.println(addr, HEX);
|
||||
}
|
||||
}
|
||||
if (nDevices == 0)
|
||||
Serial.println("No I2C devices found\n");
|
||||
}
|
||||
|
||||
|
||||
void touch_init(int16_t w, int16_t h, uint8_t r)
|
||||
{
|
||||
touch_max_x = w - 1;
|
||||
touch_max_y = h - 1;
|
||||
if (touch_map_x1 == -1)
|
||||
{
|
||||
switch (r)
|
||||
{
|
||||
case 3:
|
||||
touch_swap_xy = true;
|
||||
touch_map_x1 = touch_max_x;
|
||||
touch_map_x2 = 0;
|
||||
touch_map_y1 = 0;
|
||||
touch_map_y2 = touch_max_y;
|
||||
break;
|
||||
case 2:
|
||||
touch_swap_xy = false;
|
||||
touch_map_x1 = touch_max_x;
|
||||
touch_map_x2 = 0;
|
||||
touch_map_y1 = touch_max_y;
|
||||
touch_map_y2 = 0;
|
||||
break;
|
||||
case 1:
|
||||
touch_swap_xy = true;
|
||||
touch_map_x1 = 0;
|
||||
touch_map_x2 = touch_max_x;
|
||||
touch_map_y1 = touch_max_y;
|
||||
touch_map_y2 = 0;
|
||||
break;
|
||||
default: // case 0:
|
||||
touch_swap_xy = false;
|
||||
touch_map_x1 = 0;
|
||||
touch_map_x2 = touch_max_x;
|
||||
touch_map_y1 = 0;
|
||||
touch_map_y2 = touch_max_y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(TOUCH_XPT2046)
|
||||
SPI.begin(TOUCH_XPT2046_SCK, TOUCH_XPT2046_MISO, TOUCH_XPT2046_MOSI, TOUCH_XPT2046_CS);
|
||||
ts.begin();
|
||||
ts.setRotation(TOUCH_XPT2046_ROTATION);
|
||||
|
||||
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
|
||||
// Reset touchscreen
|
||||
#if (TOUCH_RES > 0)
|
||||
pinMode(TOUCH_RES, OUTPUT);
|
||||
digitalWrite(TOUCH_RES, 0);
|
||||
delay(200);
|
||||
digitalWrite(TOUCH_RES, 1);
|
||||
delay(200);
|
||||
#endif
|
||||
Wire.begin(TOUCH_SDA, TOUCH_SCL);
|
||||
// touch.init();
|
||||
touch = new TouchLib(Wire, TOUCH_SDA, TOUCH_SCL, touchAddress);
|
||||
|
||||
touch->init();
|
||||
|
||||
|
||||
#endif // TouchLib
|
||||
}
|
||||
|
||||
bool touch_has_signal()
|
||||
{
|
||||
#if defined(TOUCH_XPT2046)
|
||||
return ts.tirqTouched();
|
||||
|
||||
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
|
||||
// TODO: implement TOUCH_INT
|
||||
return true;
|
||||
#endif // TouchLib
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void translate_touch_raw()
|
||||
{
|
||||
if (touch_swap_xy)
|
||||
{
|
||||
touch_last_x = map(touch_raw_y, touch_map_x1, touch_map_x2, 0, touch_max_x);
|
||||
touch_last_y = map(touch_raw_x, touch_map_y1, touch_map_y2, 0, touch_max_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
touch_last_x = map(touch_raw_x, touch_map_x1, touch_map_x2, 0, touch_max_x);
|
||||
touch_last_y = map(touch_raw_y, touch_map_y1, touch_map_y2, 0, touch_max_y);
|
||||
}
|
||||
// Serial.printf("touch_raw_x: %d, touch_raw_y: %d, touch_last_x: %d, touch_last_y: %d\n", touch_raw_x, touch_raw_y, touch_last_x, touch_last_y);
|
||||
}
|
||||
|
||||
bool touch_touched()
|
||||
{
|
||||
#if defined(TOUCH_XPT2046)
|
||||
if (ts.touched())
|
||||
{
|
||||
TS_Point p = ts.getPoint();
|
||||
touch_raw_x = p.x;
|
||||
touch_raw_y = p.y;
|
||||
int max_z = p.z;
|
||||
int count = 0;
|
||||
while ((ts.touched()) && (count < TOUCH_XPT2046_SAMPLES))
|
||||
{
|
||||
count++;
|
||||
|
||||
TS_Point p = ts.getPoint();
|
||||
if (p.z > max_z)
|
||||
{
|
||||
touch_raw_x = p.x;
|
||||
touch_raw_y = p.y;
|
||||
max_z = p.z;
|
||||
}
|
||||
// Serial.printf("touch_raw_x: %d, touch_raw_y: %d, p.z: %d\n", touch_raw_x, touch_raw_y, p.z);
|
||||
}
|
||||
translate_touch_raw();
|
||||
return true;
|
||||
}
|
||||
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
|
||||
if(!touch)return false;
|
||||
if (touch->read())
|
||||
{
|
||||
TP_Point t = touch->getPoint(0);
|
||||
touch_raw_x = t.x;
|
||||
touch_raw_y = t.y;
|
||||
|
||||
touch_last_x = touch_raw_x;
|
||||
touch_last_y = touch_raw_y;
|
||||
|
||||
translate_touch_raw();
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // TouchLib
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool touch_released()
|
||||
{
|
||||
#if defined(TOUCH_XPT2046)
|
||||
return true;
|
||||
|
||||
#elif defined(TOUCH_MODULE_ADDR) // TouchLib
|
||||
return false;
|
||||
#endif // TouchLib
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
// This file was generated by SquareLine Studio
|
||||
// SquareLine Studio version: SquareLine Studio 1.2.3
|
||||
// LVGL version: 8.3.4
|
||||
// Project name: LvglWiFiConnect
|
||||
|
||||
#include "ui.h"
|
||||
#include "ui_helpers.h"
|
||||
|
||||
///////////////////// VARIABLES ////////////////////
|
||||
lv_obj_t *ui_Screen1;
|
||||
lv_obj_t *ui_Panel1;
|
||||
lv_obj_t *ui_Label1;
|
||||
lv_obj_t *ui_RollerWiFiAP;
|
||||
lv_obj_t *ui_Label2;
|
||||
lv_obj_t *ui_TextWiFiPassword;
|
||||
lv_obj_t *ui_ButtonWiFiConnect;
|
||||
lv_obj_t *ui_Label3;
|
||||
lv_obj_t *ui_Screen2;
|
||||
lv_obj_t *ui_Panel2;
|
||||
lv_obj_t *ui_Spinner1;
|
||||
lv_obj_t *ui_Label4;
|
||||
lv_obj_t *ui_Screen3;
|
||||
lv_obj_t *ui_Panel3;
|
||||
lv_obj_t *ui_Label5;
|
||||
lv_obj_t *ui_TextVNCHost;
|
||||
lv_obj_t *ui_Label6;
|
||||
lv_obj_t *ui_TextVNCPort;
|
||||
lv_obj_t *ui_Label7;
|
||||
lv_obj_t *ui_TextVNCPassword;
|
||||
lv_obj_t *ui_ButtonVNCConnect;
|
||||
lv_obj_t *ui_Label8;
|
||||
lv_obj_t *ui____initial_actions0;
|
||||
|
||||
///////////////////// TEST LVGL SETTINGS ////////////////////
|
||||
#if LV_COLOR_DEPTH != 16
|
||||
#error "LV_COLOR_DEPTH should be 16bit to match SquareLine Studio's settings"
|
||||
#endif
|
||||
#if LV_COLOR_16_SWAP !=1
|
||||
#error "LV_COLOR_16_SWAP should be 1 to match SquareLine Studio's settings"
|
||||
#endif
|
||||
|
||||
///////////////////// ANIMATIONS ////////////////////
|
||||
|
||||
///////////////////// FUNCTIONS ////////////////////
|
||||
|
||||
///////////////////// SCREENS ////////////////////
|
||||
void ui_Screen1_screen_init(void)
|
||||
{
|
||||
ui_Screen1 = lv_obj_create(NULL);
|
||||
lv_obj_clear_flag( ui_Screen1, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
|
||||
|
||||
ui_Panel1 = lv_obj_create(ui_Screen1);
|
||||
lv_obj_set_width( ui_Panel1, 280);
|
||||
lv_obj_set_height( ui_Panel1, 200);
|
||||
lv_obj_set_align( ui_Panel1, LV_ALIGN_CENTER );
|
||||
lv_obj_clear_flag( ui_Panel1, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
|
||||
lv_obj_set_style_bg_color(ui_Panel1, lv_color_hex(0xF2F2F2), LV_PART_MAIN | LV_STATE_DEFAULT );
|
||||
lv_obj_set_style_bg_opa(ui_Panel1, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
|
||||
|
||||
ui_Label1 = lv_label_create(ui_Panel1);
|
||||
lv_obj_set_width( ui_Label1, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_height( ui_Label1, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_x( ui_Label1, -10 );
|
||||
lv_obj_set_y( ui_Label1, -85 );
|
||||
lv_obj_set_align( ui_Label1, LV_ALIGN_LEFT_MID );
|
||||
lv_label_set_text(ui_Label1,"WiFi Network");
|
||||
|
||||
ui_RollerWiFiAP = lv_roller_create(ui_Panel1);
|
||||
lv_roller_set_options( ui_RollerWiFiAP, "WiFi Scanning...", LV_ROLLER_MODE_NORMAL );
|
||||
lv_obj_set_width( ui_RollerWiFiAP, 260);
|
||||
lv_obj_set_height( ui_RollerWiFiAP, 112);
|
||||
lv_obj_set_x( ui_RollerWiFiAP, 0 );
|
||||
lv_obj_set_y( ui_RollerWiFiAP, -20 );
|
||||
lv_obj_set_align( ui_RollerWiFiAP, LV_ALIGN_CENTER );
|
||||
lv_obj_set_style_text_letter_space(ui_RollerWiFiAP, 0, LV_PART_MAIN| LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_line_space(ui_RollerWiFiAP, 0, LV_PART_MAIN| LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_font(ui_RollerWiFiAP, &ui_font_Cubic11, LV_PART_MAIN| LV_STATE_DEFAULT);
|
||||
|
||||
lv_obj_set_style_text_letter_space(ui_RollerWiFiAP, 0, LV_PART_SELECTED| LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_line_space(ui_RollerWiFiAP, 0, LV_PART_SELECTED| LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_font(ui_RollerWiFiAP, &ui_font_Cubic11, LV_PART_SELECTED| LV_STATE_DEFAULT);
|
||||
|
||||
ui_Label2 = lv_label_create(ui_Panel1);
|
||||
lv_obj_set_width( ui_Label2, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_height( ui_Label2, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_x( ui_Label2, -10 );
|
||||
lv_obj_set_y( ui_Label2, 46 );
|
||||
lv_obj_set_align( ui_Label2, LV_ALIGN_LEFT_MID );
|
||||
lv_label_set_text(ui_Label2,"Password");
|
||||
|
||||
ui_TextWiFiPassword = lv_textarea_create(ui_Panel1);
|
||||
lv_obj_set_width( ui_TextWiFiPassword, 160);
|
||||
lv_obj_set_height( ui_TextWiFiPassword, LV_SIZE_CONTENT); /// 30
|
||||
lv_obj_set_x( ui_TextWiFiPassword, -50 );
|
||||
lv_obj_set_y( ui_TextWiFiPassword, 72 );
|
||||
lv_obj_set_align( ui_TextWiFiPassword, LV_ALIGN_CENTER );
|
||||
lv_textarea_set_text(ui_TextWiFiPassword,"PleaseInputYourPasswordHere");
|
||||
lv_textarea_set_placeholder_text(ui_TextWiFiPassword,"Placeholder...");
|
||||
lv_textarea_set_one_line(ui_TextWiFiPassword,true);
|
||||
lv_textarea_set_password_mode(ui_TextWiFiPassword, true);
|
||||
|
||||
ui_ButtonWiFiConnect = lv_btn_create(ui_Panel1);
|
||||
lv_obj_set_width( ui_ButtonWiFiConnect, 90);
|
||||
lv_obj_set_height( ui_ButtonWiFiConnect, 32);
|
||||
lv_obj_set_x( ui_ButtonWiFiConnect, 85 );
|
||||
lv_obj_set_y( ui_ButtonWiFiConnect, 72 );
|
||||
lv_obj_set_align( ui_ButtonWiFiConnect, LV_ALIGN_CENTER );
|
||||
lv_obj_add_flag( ui_ButtonWiFiConnect, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags
|
||||
lv_obj_clear_flag( ui_ButtonWiFiConnect, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
|
||||
|
||||
ui_Label3 = lv_label_create(ui_Panel1);
|
||||
lv_obj_set_width( ui_Label3, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_height( ui_Label3, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_x( ui_Label3, 85 );
|
||||
lv_obj_set_y( ui_Label3, 72 );
|
||||
lv_obj_set_align( ui_Label3, LV_ALIGN_CENTER );
|
||||
lv_label_set_text(ui_Label3,"Connect");
|
||||
lv_obj_set_style_text_color(ui_Label3, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT );
|
||||
lv_obj_set_style_text_opa(ui_Label3, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
|
||||
|
||||
}
|
||||
void ui_Screen2_screen_init(void)
|
||||
{
|
||||
ui_Screen2 = lv_obj_create(NULL);
|
||||
lv_obj_clear_flag( ui_Screen2, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
|
||||
|
||||
ui_Panel2 = lv_obj_create(ui_Screen2);
|
||||
lv_obj_set_width( ui_Panel2, 280);
|
||||
lv_obj_set_height( ui_Panel2, 200);
|
||||
lv_obj_set_align( ui_Panel2, LV_ALIGN_CENTER );
|
||||
lv_obj_clear_flag( ui_Panel2, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
|
||||
lv_obj_set_style_bg_color(ui_Panel2, lv_color_hex(0xF2F2F2), LV_PART_MAIN | LV_STATE_DEFAULT );
|
||||
lv_obj_set_style_bg_opa(ui_Panel2, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
|
||||
|
||||
ui_Spinner1 = lv_spinner_create(ui_Panel2,1000,90);
|
||||
lv_obj_set_width( ui_Spinner1, 140);
|
||||
lv_obj_set_height( ui_Spinner1, 140);
|
||||
lv_obj_set_align( ui_Spinner1, LV_ALIGN_CENTER );
|
||||
lv_obj_clear_flag( ui_Spinner1, LV_OBJ_FLAG_CLICKABLE ); /// Flags
|
||||
|
||||
ui_Label4 = lv_label_create(ui_Panel2);
|
||||
lv_obj_set_width( ui_Label4, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_height( ui_Label4, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_align( ui_Label4, LV_ALIGN_CENTER );
|
||||
lv_label_set_text(ui_Label4,"Connecting...");
|
||||
lv_obj_set_style_text_font(ui_Label4, &lv_font_montserrat_14, LV_PART_MAIN| LV_STATE_DEFAULT);
|
||||
|
||||
}
|
||||
void ui_Screen3_screen_init(void)
|
||||
{
|
||||
ui_Screen3 = lv_obj_create(NULL);
|
||||
lv_obj_clear_flag( ui_Screen3, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
|
||||
|
||||
ui_Panel3 = lv_obj_create(ui_Screen3);
|
||||
lv_obj_set_width( ui_Panel3, 280);
|
||||
lv_obj_set_height( ui_Panel3, 200);
|
||||
lv_obj_set_align( ui_Panel3, LV_ALIGN_CENTER );
|
||||
lv_obj_clear_flag( ui_Panel3, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
|
||||
lv_obj_set_style_bg_color(ui_Panel3, lv_color_hex(0xF2F2F2), LV_PART_MAIN | LV_STATE_DEFAULT );
|
||||
lv_obj_set_style_bg_opa(ui_Panel3, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
|
||||
|
||||
ui_Label5 = lv_label_create(ui_Panel3);
|
||||
lv_obj_set_width( ui_Label5, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_height( ui_Label5, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_x( ui_Label5, -10 );
|
||||
lv_obj_set_y( ui_Label5, -85 );
|
||||
lv_obj_set_align( ui_Label5, LV_ALIGN_LEFT_MID );
|
||||
lv_label_set_text(ui_Label5,"VNC Host");
|
||||
|
||||
ui_TextVNCHost = lv_textarea_create(ui_Panel3);
|
||||
lv_obj_set_width( ui_TextVNCHost, 260);
|
||||
lv_obj_set_height( ui_TextVNCHost, LV_SIZE_CONTENT); /// 70
|
||||
lv_obj_set_x( ui_TextVNCHost, 0 );
|
||||
lv_obj_set_y( ui_TextVNCHost, -55 );
|
||||
lv_obj_set_align( ui_TextVNCHost, LV_ALIGN_CENTER );
|
||||
lv_textarea_set_text(ui_TextVNCHost,"192.168.1.4");
|
||||
lv_textarea_set_placeholder_text(ui_TextVNCHost,"Placeholder...");
|
||||
lv_textarea_set_one_line(ui_TextVNCHost,true);
|
||||
|
||||
ui_Label6 = lv_label_create(ui_Panel3);
|
||||
lv_obj_set_width( ui_Label6, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_height( ui_Label6, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_x( ui_Label6, -10 );
|
||||
lv_obj_set_y( ui_Label6, -20 );
|
||||
lv_obj_set_align( ui_Label6, LV_ALIGN_LEFT_MID );
|
||||
lv_label_set_text(ui_Label6,"VNC Port");
|
||||
|
||||
ui_TextVNCPort = lv_textarea_create(ui_Panel3);
|
||||
lv_obj_set_width( ui_TextVNCPort, 260);
|
||||
lv_obj_set_height( ui_TextVNCPort, LV_SIZE_CONTENT); /// 70
|
||||
lv_obj_set_x( ui_TextVNCPort, 0 );
|
||||
lv_obj_set_y( ui_TextVNCPort, 10 );
|
||||
lv_obj_set_align( ui_TextVNCPort, LV_ALIGN_CENTER );
|
||||
lv_textarea_set_text(ui_TextVNCPort,"5901");
|
||||
lv_textarea_set_placeholder_text(ui_TextVNCPort,"Placeholder...");
|
||||
lv_textarea_set_one_line(ui_TextVNCPort,true);
|
||||
|
||||
ui_Label7 = lv_label_create(ui_Panel3);
|
||||
lv_obj_set_width( ui_Label7, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_height( ui_Label7, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_x( ui_Label7, -10 );
|
||||
lv_obj_set_y( ui_Label7, 40 );
|
||||
lv_obj_set_align( ui_Label7, LV_ALIGN_LEFT_MID );
|
||||
lv_label_set_text(ui_Label7,"VNC Password");
|
||||
|
||||
ui_TextVNCPassword = lv_textarea_create(ui_Panel3);
|
||||
lv_obj_set_width( ui_TextVNCPassword, 160);
|
||||
lv_obj_set_height( ui_TextVNCPassword, LV_SIZE_CONTENT); /// 70
|
||||
lv_obj_set_x( ui_TextVNCPassword, -50 );
|
||||
lv_obj_set_y( ui_TextVNCPassword, 72 );
|
||||
lv_obj_set_align( ui_TextVNCPassword, LV_ALIGN_CENTER );
|
||||
lv_textarea_set_text(ui_TextVNCPassword,"vncpassword");
|
||||
lv_textarea_set_placeholder_text(ui_TextVNCPassword,"Placeholder...");
|
||||
lv_textarea_set_one_line(ui_TextVNCPassword,true);
|
||||
lv_textarea_set_password_mode(ui_TextVNCPassword, true);
|
||||
|
||||
ui_ButtonVNCConnect = lv_btn_create(ui_Panel3);
|
||||
lv_obj_set_width( ui_ButtonVNCConnect, 90);
|
||||
lv_obj_set_height( ui_ButtonVNCConnect, 32);
|
||||
lv_obj_set_x( ui_ButtonVNCConnect, 85 );
|
||||
lv_obj_set_y( ui_ButtonVNCConnect, 72 );
|
||||
lv_obj_set_align( ui_ButtonVNCConnect, LV_ALIGN_CENTER );
|
||||
lv_obj_add_flag( ui_ButtonVNCConnect, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags
|
||||
lv_obj_clear_flag( ui_ButtonVNCConnect, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
|
||||
|
||||
ui_Label8 = lv_label_create(ui_Panel3);
|
||||
lv_obj_set_width( ui_Label8, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_height( ui_Label8, LV_SIZE_CONTENT); /// 1
|
||||
lv_obj_set_x( ui_Label8, 85 );
|
||||
lv_obj_set_y( ui_Label8, 72 );
|
||||
lv_obj_set_align( ui_Label8, LV_ALIGN_CENTER );
|
||||
lv_label_set_text(ui_Label8,"Connect");
|
||||
lv_obj_set_style_text_color(ui_Label8, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT );
|
||||
lv_obj_set_style_text_opa(ui_Label8, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
|
||||
|
||||
}
|
||||
|
||||
void ui_init( void )
|
||||
{
|
||||
lv_disp_t *dispp = lv_disp_get_default();
|
||||
lv_theme_t *theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), false, LV_FONT_DEFAULT);
|
||||
lv_disp_set_theme(dispp, theme);
|
||||
ui_Screen1_screen_init();
|
||||
ui_Screen2_screen_init();
|
||||
ui_Screen3_screen_init();
|
||||
ui____initial_actions0 = lv_obj_create(NULL);
|
||||
lv_disp_load_scr( ui_Screen1);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// This file was generated by SquareLine Studio
|
||||
// SquareLine Studio version: SquareLine Studio 1.2.3
|
||||
// LVGL version: 8.3.4
|
||||
// Project name: LvglWiFiConnect
|
||||
|
||||
#ifndef _LVGLWIFICONNECT_UI_H
|
||||
#define _LVGLWIFICONNECT_UI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined __has_include
|
||||
#if __has_include("lvgl.h")
|
||||
#include "lvgl.h"
|
||||
#elif __has_include("lvgl/lvgl.h")
|
||||
#include "lvgl/lvgl.h"
|
||||
#else
|
||||
#include "lvgl.h"
|
||||
#endif
|
||||
#else
|
||||
#include "lvgl.h"
|
||||
#endif
|
||||
|
||||
#include "ui_events.h"
|
||||
extern lv_obj_t *ui_Screen1;
|
||||
extern lv_obj_t *ui_Panel1;
|
||||
extern lv_obj_t *ui_Label1;
|
||||
extern lv_obj_t *ui_RollerWiFiAP;
|
||||
extern lv_obj_t *ui_Label2;
|
||||
extern lv_obj_t *ui_TextWiFiPassword;
|
||||
extern lv_obj_t *ui_ButtonWiFiConnect;
|
||||
extern lv_obj_t *ui_Label3;
|
||||
extern lv_obj_t *ui_Screen2;
|
||||
extern lv_obj_t *ui_Panel2;
|
||||
extern lv_obj_t *ui_Spinner1;
|
||||
extern lv_obj_t *ui_Label4;
|
||||
extern lv_obj_t *ui_Screen3;
|
||||
extern lv_obj_t *ui_Panel3;
|
||||
extern lv_obj_t *ui_Label5;
|
||||
extern lv_obj_t *ui_TextVNCHost;
|
||||
extern lv_obj_t *ui_Label6;
|
||||
extern lv_obj_t *ui_TextVNCPort;
|
||||
extern lv_obj_t *ui_Label7;
|
||||
extern lv_obj_t *ui_TextVNCPassword;
|
||||
extern lv_obj_t *ui_ButtonVNCConnect;
|
||||
extern lv_obj_t *ui_Label8;
|
||||
extern lv_obj_t *ui____initial_actions0;
|
||||
|
||||
|
||||
|
||||
|
||||
LV_FONT_DECLARE( ui_font_Cubic11);
|
||||
|
||||
|
||||
void ui_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
// This file was generated by SquareLine Studio
|
||||
// SquareLine Studio version: SquareLine Studio 1.2.3
|
||||
// LVGL version: 8.3.4
|
||||
// Project name: LvglWiFiConnect
|
||||
|
||||
#ifndef _UI_EVENTS_H
|
||||
#define _UI_EVENTS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,232 @@
|
||||
// This file was generated by SquareLine Studio
|
||||
// SquareLine Studio version: SquareLine Studio 1.2.3
|
||||
// LVGL version: 8.3.4
|
||||
// Project name: LvglWiFiConnect
|
||||
|
||||
#include "ui_helpers.h"
|
||||
|
||||
void _ui_bar_set_property( lv_obj_t *target, int id, int val)
|
||||
{
|
||||
if (id == _UI_BAR_PROPERTY_VALUE_WITH_ANIM) lv_bar_set_value(target, val, LV_ANIM_ON);
|
||||
if (id == _UI_BAR_PROPERTY_VALUE) lv_bar_set_value(target, val, LV_ANIM_OFF);
|
||||
}
|
||||
|
||||
void _ui_basic_set_property( lv_obj_t *target, int id, int val)
|
||||
{
|
||||
if (id == _UI_BASIC_PROPERTY_POSITION_X) lv_obj_set_x(target, val);
|
||||
if (id == _UI_BASIC_PROPERTY_POSITION_Y) lv_obj_set_y(target, val);
|
||||
if (id == _UI_BASIC_PROPERTY_WIDTH) lv_obj_set_width(target, val);
|
||||
if (id == _UI_BASIC_PROPERTY_HEIGHT) lv_obj_set_height(target, val);
|
||||
}
|
||||
|
||||
|
||||
void _ui_dropdown_set_property( lv_obj_t *target, int id, int val)
|
||||
{
|
||||
if (id == _UI_DROPDOWN_PROPERTY_SELECTED) lv_dropdown_set_selected(target, val);
|
||||
}
|
||||
|
||||
void _ui_image_set_property( lv_obj_t *target, int id, uint8_t *val)
|
||||
{
|
||||
if (id == _UI_IMAGE_PROPERTY_IMAGE) lv_img_set_src(target, val);
|
||||
}
|
||||
|
||||
void _ui_label_set_property( lv_obj_t *target, int id, char *val)
|
||||
{
|
||||
if (id == _UI_LABEL_PROPERTY_TEXT) lv_label_set_text(target, val);
|
||||
}
|
||||
|
||||
|
||||
void _ui_roller_set_property( lv_obj_t *target, int id, int val)
|
||||
{
|
||||
if (id == _UI_ROLLER_PROPERTY_SELECTED_WITH_ANIM) lv_roller_set_selected(target, val, LV_ANIM_ON);
|
||||
if (id == _UI_ROLLER_PROPERTY_SELECTED) lv_roller_set_selected(target, val, LV_ANIM_OFF);
|
||||
}
|
||||
|
||||
void _ui_slider_set_property( lv_obj_t *target, int id, int val)
|
||||
{
|
||||
if (id == _UI_SLIDER_PROPERTY_VALUE_WITH_ANIM) lv_slider_set_value(target, val, LV_ANIM_ON);
|
||||
if (id == _UI_SLIDER_PROPERTY_VALUE) lv_slider_set_value(target, val, LV_ANIM_OFF);
|
||||
}
|
||||
|
||||
|
||||
void _ui_screen_change( lv_obj_t *target, lv_scr_load_anim_t fademode, int spd, int delay)
|
||||
{
|
||||
lv_scr_load_anim(target, fademode, spd, delay, false);
|
||||
}
|
||||
|
||||
void _ui_arc_increment( lv_obj_t *target, int val)
|
||||
{
|
||||
int old = lv_arc_get_value(target);
|
||||
lv_arc_set_value(target, old+val);
|
||||
lv_event_send(target,LV_EVENT_VALUE_CHANGED, 0);
|
||||
}
|
||||
|
||||
void _ui_bar_increment( lv_obj_t *target, int val, int anm)
|
||||
{
|
||||
int old = lv_bar_get_value(target);
|
||||
lv_bar_set_value(target, old+val, anm);
|
||||
}
|
||||
|
||||
void _ui_slider_increment( lv_obj_t *target, int val, int anm)
|
||||
{
|
||||
int old = lv_slider_get_value(target);
|
||||
lv_slider_set_value(target, old+val, anm);
|
||||
lv_event_send(target,LV_EVENT_VALUE_CHANGED, 0);
|
||||
}
|
||||
|
||||
void _ui_keyboard_set_target( lv_obj_t *keyboard, lv_obj_t *textarea)
|
||||
{
|
||||
lv_keyboard_set_textarea(keyboard, textarea);
|
||||
}
|
||||
|
||||
void _ui_flag_modify( lv_obj_t *target, int32_t flag, int value)
|
||||
{
|
||||
if (value==_UI_MODIFY_FLAG_TOGGLE)
|
||||
{
|
||||
if ( lv_obj_has_flag(target,flag) ) lv_obj_clear_flag(target,flag);
|
||||
else lv_obj_add_flag(target,flag);
|
||||
}
|
||||
else if (value==_UI_MODIFY_FLAG_ADD) lv_obj_add_flag(target,flag);
|
||||
else lv_obj_clear_flag(target,flag);
|
||||
}
|
||||
void _ui_state_modify( lv_obj_t *target, int32_t state, int value)
|
||||
{
|
||||
if (value==_UI_MODIFY_STATE_TOGGLE)
|
||||
{
|
||||
if ( lv_obj_has_state(target,state) ) lv_obj_clear_state(target,state);
|
||||
else lv_obj_add_state(target,state);
|
||||
}
|
||||
else if (value==_UI_MODIFY_STATE_ADD) lv_obj_add_state(target,state);
|
||||
else lv_obj_clear_state(target,state);
|
||||
}
|
||||
|
||||
void _ui_opacity_set( lv_obj_t *target, int val)
|
||||
{
|
||||
lv_obj_set_style_opa(target, val, 0);
|
||||
}
|
||||
|
||||
void _ui_anim_callback_free_user_data(lv_anim_t *a)
|
||||
{
|
||||
lv_mem_free(a->user_data);
|
||||
a->user_data=NULL;
|
||||
}
|
||||
|
||||
void _ui_anim_callback_set_x(lv_anim_t* a, int32_t v)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
lv_obj_set_x(usr->target, v);
|
||||
}
|
||||
|
||||
void _ui_anim_callback_set_y(lv_anim_t* a, int32_t v)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
lv_obj_set_y(usr->target, v);
|
||||
}
|
||||
|
||||
void _ui_anim_callback_set_width(lv_anim_t* a, int32_t v)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
lv_obj_set_width(usr->target, v);
|
||||
}
|
||||
|
||||
void _ui_anim_callback_set_height(lv_anim_t* a, int32_t v)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
lv_obj_set_height(usr->target, v);
|
||||
}
|
||||
|
||||
void _ui_anim_callback_set_opacity(lv_anim_t* a, int32_t v)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
lv_obj_set_style_opa(usr->target, v, 0);
|
||||
}
|
||||
|
||||
void _ui_anim_callback_set_image_zoom(lv_anim_t* a, int32_t v)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
lv_img_set_zoom(usr->target, v);
|
||||
}
|
||||
|
||||
void _ui_anim_callback_set_image_angle(lv_anim_t* a, int32_t v)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
lv_img_set_angle(usr->target, v);
|
||||
}
|
||||
|
||||
void _ui_anim_callback_set_image_frame(lv_anim_t* a, int32_t v)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
usr->val = v;
|
||||
if ( v<0 ) v=0;
|
||||
if ( v>=usr->imgset_size ) v=usr->imgset_size-1;
|
||||
lv_img_set_src(usr->target, usr->imgset[v]);
|
||||
}
|
||||
|
||||
int32_t _ui_anim_callback_get_x(lv_anim_t* a)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
return lv_obj_get_x_aligned(usr->target);
|
||||
}
|
||||
|
||||
int32_t _ui_anim_callback_get_y(lv_anim_t* a)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
return lv_obj_get_y_aligned(usr->target);
|
||||
}
|
||||
|
||||
int32_t _ui_anim_callback_get_width(lv_anim_t* a)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
return lv_obj_get_width(usr->target);
|
||||
}
|
||||
|
||||
int32_t _ui_anim_callback_get_height(lv_anim_t* a)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
return lv_obj_get_height(usr->target);
|
||||
}
|
||||
|
||||
int32_t _ui_anim_callback_get_opacity(lv_anim_t* a)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
return lv_obj_get_style_opa(usr->target, 0);
|
||||
}
|
||||
|
||||
int32_t _ui_anim_callback_get_image_zoom(lv_anim_t* a)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
return lv_img_get_zoom(usr->target);
|
||||
}
|
||||
|
||||
int32_t _ui_anim_callback_get_image_angle(lv_anim_t* a)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
return lv_img_get_angle(usr->target);
|
||||
}
|
||||
|
||||
int32_t _ui_anim_callback_get_image_frame(lv_anim_t* a)
|
||||
{
|
||||
ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data;
|
||||
return usr->val;
|
||||
}
|
||||
|
||||
void _ui_arc_set_text_value( lv_obj_t *trg, lv_obj_t *src, char *prefix, char *postfix)
|
||||
{
|
||||
char buf[_UI_TEMPORARY_STRING_BUFFER_SIZE];
|
||||
lv_snprintf(buf, sizeof(buf), "%s%d%s", prefix, (int)lv_arc_get_value(src), postfix);
|
||||
lv_label_set_text(trg, buf);
|
||||
}
|
||||
|
||||
void _ui_slider_set_text_value( lv_obj_t *trg, lv_obj_t *src, char *prefix, char *postfix)
|
||||
{
|
||||
char buf[_UI_TEMPORARY_STRING_BUFFER_SIZE];
|
||||
lv_snprintf(buf, sizeof(buf), "%s%d%s", prefix, (int)lv_slider_get_value(src), postfix);
|
||||
lv_label_set_text(trg, buf);
|
||||
}
|
||||
void _ui_checked_set_text_value( lv_obj_t *trg, lv_obj_t *src, char *txt_on, char *txt_off)
|
||||
{
|
||||
if (lv_obj_has_state(src,LV_STATE_CHECKED)) lv_label_set_text(trg,txt_on);
|
||||
else lv_label_set_text(trg,txt_off);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
// This file was generated by SquareLine Studio
|
||||
// SquareLine Studio version: SquareLine Studio 1.2.3
|
||||
// LVGL version: 8.3.4
|
||||
// Project name: LvglWiFiConnect
|
||||
|
||||
#ifndef _LVGLWIFICONNECT_UI_HELPERS_H
|
||||
#define _LVGLWIFICONNECT_UI_HELPERS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ui.h"
|
||||
|
||||
#define _UI_TEMPORARY_STRING_BUFFER_SIZE 32
|
||||
#define _UI_BAR_PROPERTY_VALUE 0
|
||||
#define _UI_BAR_PROPERTY_VALUE_WITH_ANIM 1
|
||||
void _ui_bar_set_property( lv_obj_t *target, int id, int val);
|
||||
|
||||
#define _UI_BASIC_PROPERTY_POSITION_X 0
|
||||
#define _UI_BASIC_PROPERTY_POSITION_Y 1
|
||||
#define _UI_BASIC_PROPERTY_WIDTH 2
|
||||
#define _UI_BASIC_PROPERTY_HEIGHT 3
|
||||
void _ui_basic_set_property( lv_obj_t *target, int id, int val);
|
||||
|
||||
#define _UI_DROPDOWN_PROPERTY_SELECTED 0
|
||||
void _ui_dropdown_set_property( lv_obj_t *target, int id, int val);
|
||||
|
||||
#define _UI_IMAGE_PROPERTY_IMAGE 0
|
||||
void _ui_image_set_property( lv_obj_t *target, int id, uint8_t *val);
|
||||
|
||||
#define _UI_LABEL_PROPERTY_TEXT 0
|
||||
void _ui_label_set_property( lv_obj_t *target, int id, char *val);
|
||||
|
||||
#define _UI_ROLLER_PROPERTY_SELECTED 0
|
||||
#define _UI_ROLLER_PROPERTY_SELECTED_WITH_ANIM 1
|
||||
void _ui_roller_set_property( lv_obj_t *target, int id, int val);
|
||||
|
||||
#define _UI_SLIDER_PROPERTY_VALUE 0
|
||||
#define _UI_SLIDER_PROPERTY_VALUE_WITH_ANIM 1
|
||||
void _ui_slider_set_property( lv_obj_t *target, int id, int val);
|
||||
|
||||
void _ui_screen_change( lv_obj_t *target, lv_scr_load_anim_t fademode, int spd, int delay);
|
||||
|
||||
void _ui_arc_increment( lv_obj_t *target, int val);
|
||||
|
||||
void _ui_bar_increment( lv_obj_t *target, int val, int anm);
|
||||
|
||||
void _ui_slider_increment( lv_obj_t *target, int val, int anm);
|
||||
|
||||
void _ui_keyboard_set_target( lv_obj_t *keyboard, lv_obj_t *textarea);
|
||||
|
||||
#define _UI_MODIFY_FLAG_ADD 0
|
||||
#define _UI_MODIFY_FLAG_REMOVE 1
|
||||
#define _UI_MODIFY_FLAG_TOGGLE 2
|
||||
void _ui_flag_modify( lv_obj_t *target, int32_t flag, int value);
|
||||
|
||||
#define _UI_MODIFY_STATE_ADD 0
|
||||
#define _UI_MODIFY_STATE_REMOVE 1
|
||||
#define _UI_MODIFY_STATE_TOGGLE 2
|
||||
void _ui_state_modify( lv_obj_t *target, int32_t state, int value);
|
||||
|
||||
void _ui_opacity_set( lv_obj_t *target, int val);
|
||||
|
||||
/** Describes an animation*/
|
||||
typedef struct _ui_anim_user_data_t {
|
||||
lv_obj_t *target;
|
||||
lv_img_dsc_t **imgset;
|
||||
int32_t imgset_size;
|
||||
int32_t val;
|
||||
} ui_anim_user_data_t;
|
||||
void _ui_anim_callback_free_user_data(lv_anim_t *a);
|
||||
|
||||
void _ui_anim_callback_set_x(lv_anim_t* a, int32_t v);
|
||||
|
||||
void _ui_anim_callback_set_y(lv_anim_t* a, int32_t v);
|
||||
|
||||
void _ui_anim_callback_set_width(lv_anim_t* a, int32_t v);
|
||||
|
||||
void _ui_anim_callback_set_height(lv_anim_t* a, int32_t v);
|
||||
|
||||
void _ui_anim_callback_set_opacity(lv_anim_t* a, int32_t v);
|
||||
|
||||
void _ui_anim_callback_set_image_zoom(lv_anim_t* a, int32_t v);
|
||||
|
||||
void _ui_anim_callback_set_image_angle(lv_anim_t* a, int32_t v);
|
||||
|
||||
void _ui_anim_callback_set_image_frame(lv_anim_t* a, int32_t v);
|
||||
|
||||
int32_t _ui_anim_callback_get_x(lv_anim_t* a);
|
||||
|
||||
int32_t _ui_anim_callback_get_y(lv_anim_t* a);
|
||||
|
||||
int32_t _ui_anim_callback_get_width(lv_anim_t* a);
|
||||
|
||||
int32_t _ui_anim_callback_get_height(lv_anim_t* a);
|
||||
|
||||
int32_t _ui_anim_callback_get_opacity(lv_anim_t* a);
|
||||
|
||||
int32_t _ui_anim_callback_get_image_zoom(lv_anim_t* a);
|
||||
|
||||
int32_t _ui_anim_callback_get_image_angle(lv_anim_t* a);
|
||||
|
||||
int32_t _ui_anim_callback_get_image_frame(lv_anim_t* a);
|
||||
|
||||
void _ui_arc_set_text_value( lv_obj_t *trg, lv_obj_t *src, char *prefix, char *postfix);
|
||||
|
||||
void _ui_slider_set_text_value( lv_obj_t *trg, lv_obj_t *src, char *prefix, char *postfix);
|
||||
|
||||
void _ui_checked_set_text_value( lv_obj_t *trg, lv_obj_t *src, char *txt_on, char *txt_off);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+2
-1
@@ -20,6 +20,7 @@ src_dir = examples/UnitTest
|
||||
; src_dir = examples/Touchpad
|
||||
; src_dir = examples/Keyboard_T_Deck_Master
|
||||
|
||||
; src_dir = examples/LvglArduinoVNC_VGA
|
||||
|
||||
|
||||
[env:T-Keyboard]
|
||||
@@ -42,4 +43,4 @@ build_flags =
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
|
||||
; Enable UARDUINO_USB_CDC_ON_BOOT will turn off printing and will not block when using the battery
|
||||
; -UARDUINO_USB_CDC_ON_BOOT
|
||||
; -UARDUINO_USB_CDC_ON_BOOT
|
||||
Reference in New Issue
Block a user