Add shared JC3636W518 board library and PlatformIO config
- shared/lib/JC3636W518: display/touch/backlight init with LVGL 9 glue (from scr_st77916.h), pin map, perf monitor (FPS/refresh/CPU) - shared/include/lv_conf.h: LVGL 9.6 config for all projects - shared/jc3636w518.ini: common platform/board/build settings - display_gif_embedded uses it (23.2 fps, 86% CPU) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9684ab39f2
commit
d6982ab7e7
14 files changed
+799
-2357
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -1,38 +0,0 @@
|
||||
#ifndef _PINCFG_H_
|
||||
#define _PINCFG_H_
|
||||
|
||||
#define TFT_BLK 15
|
||||
|
||||
#define TFT_RST 47
|
||||
#define TFT_CS 10
|
||||
#define TFT_SCK 9
|
||||
#define TFT_SDA0 11
|
||||
#define TFT_SDA1 12
|
||||
#define TFT_SDA2 13
|
||||
#define TFT_SDA3 14
|
||||
|
||||
#define BTN_PIN 0
|
||||
|
||||
#define TOUCH_PIN_NUM_I2C_SCL 8
|
||||
#define TOUCH_PIN_NUM_I2C_SDA 7
|
||||
#define TOUCH_PIN_NUM_INT 41
|
||||
#define TOUCH_PIN_NUM_RST 40
|
||||
|
||||
#define SD_MMC_D0_PIN 2
|
||||
#define SD_MMC_D1_PIN 1
|
||||
#define SD_MMC_D2_PIN 6
|
||||
#define SD_MMC_D3_PIN 5
|
||||
#define SD_MMC_CLK_PIN 3
|
||||
#define SD_MMC_CMD_PIN 4
|
||||
|
||||
#define AUDIO_I2S_MCK_IO -1 // MCK
|
||||
#define AUDIO_I2S_BCK_IO 18 // BCK
|
||||
#define AUDIO_I2S_WS_IO 16 // LCK
|
||||
#define AUDIO_I2S_DO_IO 17 // DIN
|
||||
#define AUDIO_MUTE_PIN 48 // 低电平静音
|
||||
|
||||
#define MIC_I2S_WS 45
|
||||
#define MIC_I2S_SD 46
|
||||
#define MIC_I2S_SCK 42
|
||||
|
||||
#endif
|
||||
@@ -1,442 +0,0 @@
|
||||
#ifndef _SCR_ST77916_H_
|
||||
#define _SCR_ST77916_H_
|
||||
|
||||
#include "pincfg.h"
|
||||
#include <lvgl.h>
|
||||
#include <ESP_IOExpander.h>
|
||||
#include <ESP_Panel_Library.h>
|
||||
|
||||
#define SCREEN_RES_HOR 360
|
||||
#define SCREEN_RES_VER 360
|
||||
|
||||
static uint8_t *disp_draw_buf;
|
||||
static uint8_t *disp_draw_buf2; // second buffer: LVGL renders into one while the other is sent to the LCD
|
||||
static lv_display_t *disp = NULL;
|
||||
static lv_indev_t *indev_touchpad;
|
||||
static ESP_PanelBacklight *backlight = NULL;
|
||||
static ESP_PanelLcd *lcd = NULL;
|
||||
static ESP_PanelTouch *touch = NULL;
|
||||
|
||||
#define USE_CUSTOM_INIT_CMD 0 // 是否用自定义的初始化代码
|
||||
|
||||
#if TOUCH_PIN_NUM_INT >= 0
|
||||
|
||||
IRAM_ATTR bool onTouchInterruptCallback(void *user_data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
const esp_lcd_panel_vendor_init_cmd_t lcd_init_cmd[] = {
|
||||
{0xF0, (uint8_t[]){0x08}, 1, 0},
|
||||
{0xF2, (uint8_t[]){0x08}, 1, 0},
|
||||
{0x9B, (uint8_t[]){0x51}, 1, 0},
|
||||
{0x86, (uint8_t[]){0x53}, 1, 0},
|
||||
{0xF2, (uint8_t[]){0x80}, 1, 0},
|
||||
{0xF0, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xF0, (uint8_t[]){0x01}, 1, 0},
|
||||
{0xF1, (uint8_t[]){0x01}, 1, 0},
|
||||
{0xB0, (uint8_t[]){0x54}, 1, 0},
|
||||
{0xB1, (uint8_t[]){0x3F}, 1, 0},
|
||||
{0xB2, (uint8_t[]){0x2A}, 1, 0},
|
||||
{0xB4, (uint8_t[]){0x46}, 1, 0},
|
||||
{0xB5, (uint8_t[]){0x34}, 1, 0},
|
||||
{0xB6, (uint8_t[]){0xD5}, 1, 0},
|
||||
{0xB7, (uint8_t[]){0x30}, 1, 0},
|
||||
{0xBA, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xBB, (uint8_t[]){0x08}, 1, 0},
|
||||
{0xBC, (uint8_t[]){0x08}, 1, 0},
|
||||
{0xBD, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xC0, (uint8_t[]){0x80}, 1, 0},
|
||||
{0xC1, (uint8_t[]){0x10}, 1, 0},
|
||||
{0xC2, (uint8_t[]){0x37}, 1, 0},
|
||||
{0xC3, (uint8_t[]){0x80}, 1, 0},
|
||||
{0xC4, (uint8_t[]){0x10}, 1, 0},
|
||||
{0xC5, (uint8_t[]){0x37}, 1, 0},
|
||||
{0xC6, (uint8_t[]){0xA9}, 1, 0},
|
||||
{0xC7, (uint8_t[]){0x41}, 1, 0},
|
||||
{0xC8, (uint8_t[]){0x51}, 1, 0},
|
||||
{0xC9, (uint8_t[]){0xA9}, 1, 0},
|
||||
{0xCA, (uint8_t[]){0x41}, 1, 0},
|
||||
{0xCB, (uint8_t[]){0x51}, 1, 0},
|
||||
{0xD0, (uint8_t[]){0x91}, 1, 0},
|
||||
{0xD1, (uint8_t[]){0x68}, 1, 0},
|
||||
{0xD2, (uint8_t[]){0x69}, 1, 0},
|
||||
{0xF5, (uint8_t[]){0x00, 0xA5}, 2, 0},
|
||||
{0xDD, (uint8_t[]){0x3F}, 1, 0},
|
||||
{0xDE, (uint8_t[]){0x3F}, 1, 0},
|
||||
{0xF1, (uint8_t[]){0x10}, 1, 0},
|
||||
{0xF0, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xF0, (uint8_t[]){0x02}, 1, 0},
|
||||
{0xE0, (uint8_t[]){0x70, 0x09, 0x12, 0x0C, 0x0B, 0x27, 0x38, 0x54, 0x4E, 0x19, 0x15, 0x15, 0x2C, 0x2F}, 14, 0},
|
||||
{0xE1, (uint8_t[]){0x70, 0x08, 0x11, 0x0C, 0x0B, 0x27, 0x38, 0x43, 0x4C, 0x18, 0x14, 0x14, 0x2B, 0x2D}, 14, 0},
|
||||
{0xF0, (uint8_t[]){0x10}, 1, 0},
|
||||
{0xF3, (uint8_t[]){0x10}, 1, 0},
|
||||
{0xE0, (uint8_t[]){0x08}, 1, 0},
|
||||
{0xE1, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xE2, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xE3, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xE4, (uint8_t[]){0xE0}, 1, 0},
|
||||
{0xE5, (uint8_t[]){0x06}, 1, 0},
|
||||
{0xE6, (uint8_t[]){0x21}, 1, 0},
|
||||
{0xE7, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xE8, (uint8_t[]){0x05}, 1, 0},
|
||||
{0xE9, (uint8_t[]){0x82}, 1, 0},
|
||||
{0xEA, (uint8_t[]){0xDF}, 1, 0},
|
||||
{0xEB, (uint8_t[]){0x89}, 1, 0},
|
||||
{0xEC, (uint8_t[]){0x20}, 1, 0},
|
||||
{0xED, (uint8_t[]){0x14}, 1, 0},
|
||||
{0xEE, (uint8_t[]){0xFF}, 1, 0},
|
||||
{0xEF, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xF8, (uint8_t[]){0xFF}, 1, 0},
|
||||
{0xF9, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xFA, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xFB, (uint8_t[]){0x30}, 1, 0},
|
||||
{0xFC, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xFD, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xFE, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xFF, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x60, (uint8_t[]){0x42}, 1, 0},
|
||||
{0x61, (uint8_t[]){0xE0}, 1, 0},
|
||||
{0x62, (uint8_t[]){0x40}, 1, 0},
|
||||
{0x63, (uint8_t[]){0x40}, 1, 0},
|
||||
{0x64, (uint8_t[]){0x02}, 1, 0},
|
||||
{0x65, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x66, (uint8_t[]){0x40}, 1, 0},
|
||||
{0x67, (uint8_t[]){0x03}, 1, 0},
|
||||
{0x68, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x69, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x6A, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x6B, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x70, (uint8_t[]){0x42}, 1, 0},
|
||||
{0x71, (uint8_t[]){0xE0}, 1, 0},
|
||||
{0x72, (uint8_t[]){0x40}, 1, 0},
|
||||
{0x73, (uint8_t[]){0x40}, 1, 0},
|
||||
{0x74, (uint8_t[]){0x02}, 1, 0},
|
||||
{0x75, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x76, (uint8_t[]){0x40}, 1, 0},
|
||||
{0x77, (uint8_t[]){0x03}, 1, 0},
|
||||
{0x78, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x79, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x7A, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x7B, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x80, (uint8_t[]){0x48}, 1, 0},
|
||||
{0x81, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x82, (uint8_t[]){0x05}, 1, 0},
|
||||
{0x83, (uint8_t[]){0x02}, 1, 0},
|
||||
{0x84, (uint8_t[]){0xDD}, 1, 0},
|
||||
{0x85, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x86, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x87, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x88, (uint8_t[]){0x48}, 1, 0},
|
||||
{0x89, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x8A, (uint8_t[]){0x07}, 1, 0},
|
||||
{0x8B, (uint8_t[]){0x02}, 1, 0},
|
||||
{0x8C, (uint8_t[]){0xDF}, 1, 0},
|
||||
{0x8D, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x8E, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x8F, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x90, (uint8_t[]){0x48}, 1, 0},
|
||||
{0x91, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x92, (uint8_t[]){0x09}, 1, 0},
|
||||
{0x93, (uint8_t[]){0x02}, 1, 0},
|
||||
{0x94, (uint8_t[]){0xE1}, 1, 0},
|
||||
{0x95, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x96, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x97, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x98, (uint8_t[]){0x48}, 1, 0},
|
||||
{0x99, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x9A, (uint8_t[]){0x0B}, 1, 0},
|
||||
{0x9B, (uint8_t[]){0x02}, 1, 0},
|
||||
{0x9C, (uint8_t[]){0xE3}, 1, 0},
|
||||
{0x9D, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x9E, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x9F, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xA0, (uint8_t[]){0x48}, 1, 0},
|
||||
{0xA1, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xA2, (uint8_t[]){0x04}, 1, 0},
|
||||
{0xA3, (uint8_t[]){0x02}, 1, 0},
|
||||
{0xA4, (uint8_t[]){0xDC}, 1, 0},
|
||||
{0xA5, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xA6, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xA7, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xA8, (uint8_t[]){0x48}, 1, 0},
|
||||
{0xA9, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xAA, (uint8_t[]){0x06}, 1, 0},
|
||||
{0xAB, (uint8_t[]){0x02}, 1, 0},
|
||||
{0xAC, (uint8_t[]){0xDE}, 1, 0},
|
||||
{0xAD, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xAE, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xAF, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xB0, (uint8_t[]){0x48}, 1, 0},
|
||||
{0xB1, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xB2, (uint8_t[]){0x08}, 1, 0},
|
||||
{0xB3, (uint8_t[]){0x02}, 1, 0},
|
||||
{0xB4, (uint8_t[]){0xE0}, 1, 0},
|
||||
{0xB5, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xB6, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xB7, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xB8, (uint8_t[]){0x48}, 1, 0},
|
||||
{0xB9, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xBA, (uint8_t[]){0x0A}, 1, 0},
|
||||
{0xBB, (uint8_t[]){0x02}, 1, 0},
|
||||
{0xBC, (uint8_t[]){0xE2}, 1, 0},
|
||||
{0xBD, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xBE, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xBF, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xC0, (uint8_t[]){0x12}, 1, 0},
|
||||
{0xC1, (uint8_t[]){0xAA}, 1, 0},
|
||||
{0xC2, (uint8_t[]){0x65}, 1, 0},
|
||||
{0xC3, (uint8_t[]){0x74}, 1, 0},
|
||||
{0xC4, (uint8_t[]){0x47}, 1, 0},
|
||||
{0xC5, (uint8_t[]){0x56}, 1, 0},
|
||||
{0xC6, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xC7, (uint8_t[]){0x88}, 1, 0},
|
||||
{0xC8, (uint8_t[]){0x99}, 1, 0},
|
||||
{0xC9, (uint8_t[]){0x33}, 1, 0},
|
||||
{0xD0, (uint8_t[]){0x21}, 1, 0},
|
||||
{0xD1, (uint8_t[]){0xAA}, 1, 0},
|
||||
{0xD2, (uint8_t[]){0x65}, 1, 0},
|
||||
{0xD3, (uint8_t[]){0x74}, 1, 0},
|
||||
{0xD4, (uint8_t[]){0x47}, 1, 0},
|
||||
{0xD5, (uint8_t[]){0x56}, 1, 0},
|
||||
{0xD6, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xD7, (uint8_t[]){0x88}, 1, 0},
|
||||
{0xD8, (uint8_t[]){0x99}, 1, 0},
|
||||
{0xD9, (uint8_t[]){0x33}, 1, 0},
|
||||
{0xF3, (uint8_t[]){0x01}, 1, 0},
|
||||
{0xF0, (uint8_t[]){0x00}, 1, 0},
|
||||
{0xF0, (uint8_t[]){0x01}, 1, 0},
|
||||
{0xF1, (uint8_t[]){0x01}, 1, 0},
|
||||
{0xA0, (uint8_t[]){0x0B}, 1, 0},
|
||||
{0xA3, (uint8_t[]){0x2A}, 1, 0},
|
||||
{0xA5, (uint8_t[]){0xC3}, 1, 1},
|
||||
{0xA3, (uint8_t[]){0x2B}, 1, 0},
|
||||
{0xA5, (uint8_t[]){0xC3}, 1, 1},
|
||||
{0xA3, (uint8_t[]){0x2C}, 1, 0},
|
||||
{0xA5, (uint8_t[]){0xC3}, 1, 1},
|
||||
{0xA3, (uint8_t[]){0x2D}, 1, 0},
|
||||
{0xA5, (uint8_t[]){0xC3}, 1, 1},
|
||||
{0xA3, (uint8_t[]){0x2E}, 1, 0},
|
||||
{0xA5, (uint8_t[]){0xC3}, 1, 1},
|
||||
{0xA3, (uint8_t[]){0x2F}, 1, 0},
|
||||
{0xA5, (uint8_t[]){0xC3}, 1, 1},
|
||||
{0xA3, (uint8_t[]){0x30}, 1, 0},
|
||||
{0xA5, (uint8_t[]){0xC3}, 1, 1},
|
||||
{0xA3, (uint8_t[]){0x31}, 1, 0},
|
||||
{0xA5, (uint8_t[]){0xC3}, 1, 1},
|
||||
{0xA3, (uint8_t[]){0x32}, 1, 0},
|
||||
{0xA5, (uint8_t[]){0xC3}, 1, 1},
|
||||
{0xA3, (uint8_t[]){0x33}, 1, 0},
|
||||
{0xA5, (uint8_t[]){0xC3}, 1, 1},
|
||||
{0xA0, (uint8_t[]){0x09}, 1, 0},
|
||||
{0xF1, (uint8_t[]){0x10}, 1, 0},
|
||||
{0xF0, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x2A, (uint8_t[]){0x00, 0x00, 0x01, 0x67}, 4, 0},
|
||||
{0x2B, (uint8_t[]){0x01, 0x68, 0x01, 0x68}, 4, 0},
|
||||
{0x4D, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x4E, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x4F, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x4C, (uint8_t[]){0x01}, 1, 10},
|
||||
{0x4C, (uint8_t[]){0x00}, 1, 0},
|
||||
{0x2A, (uint8_t[]){0x00, 0x00, 0x01, 0x67}, 4, 0},
|
||||
{0x2B, (uint8_t[]){0x00, 0x00, 0x01, 0x67}, 4, 0},
|
||||
{0x21, (uint8_t[]){0x00}, 1, 0},
|
||||
//{0x3A, (uint8_t[]){0x55}, 1, 0}, // color=16
|
||||
{0x11, (uint8_t[]){0x00}, 1, 120},
|
||||
{0x29, (uint8_t[]){0x00}, 1, 0},
|
||||
};
|
||||
|
||||
#define TFT_SPI_FREQ_HZ (50 * 1000 * 1000)
|
||||
|
||||
// LVGL tick source (replaces LV_TICK_CUSTOM of LVGL 8)
|
||||
static uint32_t lv_tick_millis(void)
|
||||
{
|
||||
return millis();
|
||||
}
|
||||
|
||||
static void my_disp_flush(lv_display_t *disp, const lv_area_t *area, uint8_t *px_map)
|
||||
{
|
||||
ESP_PanelLcd *lcd = (ESP_PanelLcd *)lv_display_get_user_data(disp);
|
||||
const int w = lv_area_get_width(area);
|
||||
const int h = lv_area_get_height(area);
|
||||
// LVGL 9 renders little-endian RGB565, the ST77916 expects big-endian (LVGL 8 used LV_COLOR_16_SWAP)
|
||||
lv_draw_rgb565_swap(px_map, w * h);
|
||||
lcd->drawBitmap(area->x1, area->y1, w, h, (const uint8_t *)px_map);
|
||||
}
|
||||
|
||||
IRAM_ATTR bool onRefreshFinishCallback(void *user_data)
|
||||
{
|
||||
lv_display_flush_ready((lv_display_t *)user_data);
|
||||
return false;
|
||||
}
|
||||
|
||||
void setRotation(uint8_t rot)
|
||||
{
|
||||
if (rot > 3)
|
||||
return;
|
||||
if (lcd == NULL || touch == NULL)
|
||||
return;
|
||||
|
||||
switch (rot)
|
||||
{
|
||||
case 1: // 顺时针90度
|
||||
lcd->swapXY(true);
|
||||
lcd->mirrorX(true);
|
||||
lcd->mirrorY(false);
|
||||
touch->swapXY(true);
|
||||
touch->mirrorX(true);
|
||||
touch->mirrorY(false);
|
||||
break;
|
||||
case 2:
|
||||
lcd->swapXY(false);
|
||||
lcd->mirrorX(true);
|
||||
lcd->mirrorY(true);
|
||||
touch->swapXY(false);
|
||||
touch->mirrorX(true);
|
||||
touch->mirrorY(true);
|
||||
break;
|
||||
case 3:
|
||||
lcd->swapXY(true);
|
||||
lcd->mirrorX(false);
|
||||
lcd->mirrorY(true);
|
||||
touch->swapXY(true);
|
||||
touch->mirrorX(false);
|
||||
touch->mirrorY(true);
|
||||
break;
|
||||
default:
|
||||
lcd->swapXY(false);
|
||||
lcd->mirrorX(false);
|
||||
lcd->mirrorY(false);
|
||||
touch->swapXY(false);
|
||||
touch->mirrorX(false);
|
||||
touch->mirrorY(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void screen_switch(bool on)
|
||||
{
|
||||
if (NULL == backlight)
|
||||
return;
|
||||
if (on)
|
||||
backlight->on();
|
||||
else
|
||||
backlight->off();
|
||||
}
|
||||
|
||||
// 输入值为0-100
|
||||
void set_brightness(uint8_t bri)
|
||||
{
|
||||
if (NULL == backlight)
|
||||
return;
|
||||
backlight->setBrightness(bri);
|
||||
}
|
||||
|
||||
static void touchpad_read(lv_indev_t *indev, lv_indev_data_t *data)
|
||||
{
|
||||
ESP_PanelTouch *tp = (ESP_PanelTouch *)lv_indev_get_user_data(indev);
|
||||
ESP_PanelTouchPoint point;
|
||||
|
||||
int read_touch_result = tp->readPoints(&point, 1);
|
||||
if (read_touch_result > 0)
|
||||
{
|
||||
data->point.x = point.x;
|
||||
data->point.y = point.y;
|
||||
data->state = LV_INDEV_STATE_PRESSED;
|
||||
}
|
||||
else
|
||||
{
|
||||
data->state = LV_INDEV_STATE_RELEASED;
|
||||
}
|
||||
}
|
||||
|
||||
static lv_indev_t *indev_init(ESP_PanelTouch *tp)
|
||||
{
|
||||
ESP_PANEL_CHECK_FALSE_RET(tp != nullptr, nullptr, "Invalid touch device");
|
||||
ESP_PANEL_CHECK_FALSE_RET(tp->getHandle() != nullptr, nullptr, "Touch device is not initialized");
|
||||
lv_indev_t *indev = lv_indev_create();
|
||||
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
|
||||
lv_indev_set_read_cb(indev, touchpad_read);
|
||||
lv_indev_set_user_data(indev, (void *)tp);
|
||||
return indev;
|
||||
}
|
||||
|
||||
void scr_lvgl_init()
|
||||
{
|
||||
ledc_timer_config_t ledc_timer = {
|
||||
.speed_mode = LEDC_LOW_SPEED_MODE,
|
||||
.duty_resolution = LEDC_TIMER_13_BIT,
|
||||
.timer_num = LEDC_TIMER_0,
|
||||
.freq_hz = 5000,
|
||||
.clk_cfg = LEDC_AUTO_CLK};
|
||||
ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer));
|
||||
|
||||
ledc_channel_config_t ledc_channel = {
|
||||
.gpio_num = (TFT_BLK),
|
||||
.speed_mode = LEDC_LOW_SPEED_MODE,
|
||||
.channel = LEDC_CHANNEL_0,
|
||||
.intr_type = LEDC_INTR_DISABLE,
|
||||
.timer_sel = LEDC_TIMER_0,
|
||||
.duty = 0,
|
||||
.hpoint = 0};
|
||||
|
||||
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel));
|
||||
|
||||
backlight = new ESP_PanelBacklight(ledc_timer, ledc_channel);
|
||||
backlight->begin();
|
||||
backlight->off();
|
||||
|
||||
ESP_PanelBus_I2C *touch_bus = new ESP_PanelBus_I2C(TOUCH_PIN_NUM_I2C_SCL, TOUCH_PIN_NUM_I2C_SDA, ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG());
|
||||
touch_bus->configI2cFreqHz(400000);
|
||||
touch_bus->begin();
|
||||
|
||||
touch = new ESP_PanelTouch_CST816S(touch_bus, SCREEN_RES_HOR, SCREEN_RES_VER, TOUCH_PIN_NUM_RST, TOUCH_PIN_NUM_INT);
|
||||
|
||||
touch->init();
|
||||
touch->begin();
|
||||
|
||||
#if TOUCH_PIN_NUM_INT >= 0
|
||||
touch->attachInterruptCallback(onTouchInterruptCallback, NULL);
|
||||
#endif
|
||||
|
||||
ESP_PanelBus_QSPI *panel_bus = new ESP_PanelBus_QSPI(TFT_CS, TFT_SCK, TFT_SDA0, TFT_SDA1, TFT_SDA2, TFT_SDA3);
|
||||
panel_bus->configQspiFreqHz(TFT_SPI_FREQ_HZ);
|
||||
panel_bus->begin();
|
||||
|
||||
lcd = new ESP_PanelLcd_ST77916(panel_bus, 16, TFT_RST);
|
||||
// 注意,初始化代码的设置必须在INIT之前
|
||||
// lcd->configVendorCommands(lcd_init_cmd, sizeof(lcd_init_cmd) / sizeof(lcd_init_cmd[0]));
|
||||
lcd->init();
|
||||
lcd->reset();
|
||||
lcd->begin();
|
||||
|
||||
lcd->invertColor(true);
|
||||
// setRotation(0); //设置屏幕方向
|
||||
lcd->displayOn();
|
||||
|
||||
screen_switch(true);
|
||||
backlight->setBrightness(100); // 设置亮度
|
||||
|
||||
size_t lv_cache_rows = 72;
|
||||
|
||||
size_t buf_bytes = lv_cache_rows * SCREEN_RES_HOR * 2; // RGB565
|
||||
disp_draw_buf = (uint8_t *)heap_caps_malloc(buf_bytes, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||
disp_draw_buf2 = (uint8_t *)heap_caps_malloc(buf_bytes, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||
lv_init();
|
||||
lv_tick_set_cb(lv_tick_millis);
|
||||
|
||||
disp = lv_display_create(SCREEN_RES_HOR, SCREEN_RES_VER);
|
||||
lv_display_set_flush_cb(disp, my_disp_flush);
|
||||
lv_display_set_buffers(disp, disp_draw_buf, disp_draw_buf2, buf_bytes, LV_DISPLAY_RENDER_MODE_PARTIAL);
|
||||
lv_display_set_user_data(disp, (void *)lcd);
|
||||
|
||||
if (lcd->getBus()->getType() != ESP_PANEL_BUS_TYPE_RGB)
|
||||
{
|
||||
lcd->attachRefreshFinishCallback(onRefreshFinishCallback, (void *)disp);
|
||||
}
|
||||
indev_touchpad = indev_init(touch);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,34 +1,12 @@
|
||||
; JC3636W518 — ESP32-S3R8, 16 MB QIO flash, 8 MB OPI PSRAM, 360x360 ST77916 QSPI + CST816S
|
||||
; Settings mirror the vendor Arduino IDE setup (2-Program Example/Demo_Arduino/docs/Arduino set up.png)
|
||||
|
||||
[env:jc3636w518]
|
||||
; pioarduino = Arduino core 3.0.5 (ESP32_Display_Panel 0.1.4 needs core 3.x)
|
||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/51.03.05/platform-espressif32.zip
|
||||
board = esp32-s3-devkitc-1
|
||||
framework = arduino
|
||||
|
||||
board_build.arduino.memory_type = qio_opi
|
||||
board_build.flash_mode = qio
|
||||
board_upload.flash_size = 16MB
|
||||
; GIF compiled into firmware -> 3.4 MB, too big for huge_app (3 MB); 6.25 MB app slots
|
||||
board_build.partitions = default_16MB.csv
|
||||
|
||||
; optimise for speed instead of size (faster GIF decoding)
|
||||
build_unflags = -Os
|
||||
build_flags =
|
||||
-O2
|
||||
-DBOARD_HAS_PSRAM
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
; LVGL (also when compiled as a library) picks up include/lv_conf.h of this project
|
||||
-DLV_CONF_INCLUDE_SIMPLE
|
||||
-Iinclude
|
||||
|
||||
; vendor-bundled libraries: ESP32_Display_Panel 0.1.4, ESP32_IO_Expander 0.0.2
|
||||
; (the vendor folder also has lvgl 8.3.11 - ignored here, this project uses LVGL 9 from lib_deps)
|
||||
lib_extra_dirs = ../../2-Program Example/Demo_Arduino/library
|
||||
lib_deps = lvgl/lvgl@9.6.0
|
||||
|
||||
upload_port = COM21
|
||||
monitor_port = COM21
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder
|
||||
; GIF compiled into the firmware — JC3636W518, common settings in shared/jc3636w518.ini
|
||||
|
||||
[platformio]
|
||||
extra_configs = ../../shared/jc3636w518.ini
|
||||
|
||||
[shared]
|
||||
dir = ../../shared
|
||||
|
||||
[env:jc3636w518]
|
||||
extends = jc3636w518
|
||||
; GIF compiled into firmware -> 3.5 MB, too big for huge_app (3 MB); 6.25 MB app slots
|
||||
board_build.partitions = default_16MB.csv
|
||||
@@ -1,231 +1,188 @@
|
||||
#include <Arduino.h>
|
||||
#include "scr_st77916.h"
|
||||
#include "SD_MMC.h"
|
||||
|
||||
|
||||
// https://randomnerdtutorials.com/esp32-client-server-wi-fi/
|
||||
#include <WiFi.h>
|
||||
#include <HTTPClient.h>
|
||||
|
||||
const char* ssid = "ESP32-Access-Point";
|
||||
const char* password = "123456789";
|
||||
|
||||
String httpGETRequest(const char* serverName);
|
||||
|
||||
// FPS measurement: counts screen refreshes that actually rendered something (= one GIF frame here)
|
||||
static volatile uint32_t refr_count = 0;
|
||||
static volatile uint32_t refr_time_ms = 0;
|
||||
static uint32_t busy_us = 0; // time spent inside lv_timer_handler()
|
||||
|
||||
static void refr_event_cb(lv_event_t* e) {
|
||||
static uint32_t refr_start_ms = 0;
|
||||
static bool rendered = false;
|
||||
switch (lv_event_get_code(e)) {
|
||||
case LV_EVENT_REFR_START:
|
||||
refr_start_ms = millis();
|
||||
rendered = false;
|
||||
break;
|
||||
case LV_EVENT_RENDER_START:
|
||||
rendered = true;
|
||||
break;
|
||||
case LV_EVENT_REFR_READY:
|
||||
if (rendered) {
|
||||
refr_count++;
|
||||
refr_time_ms += millis() - refr_start_ms;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void print_fps() {
|
||||
static uint32_t last_ms = 0;
|
||||
uint32_t now = millis();
|
||||
if (now - last_ms < 1000) return;
|
||||
// decode = busy time not spent refreshing the screen (mostly GIF decoding)
|
||||
Serial.printf("FPS: %.1f avg refresh: %lu ms avg decode: %lu ms\n", refr_count * 1000.0f / (now - last_ms),
|
||||
refr_count ? refr_time_ms / refr_count : 0,
|
||||
refr_count ? (busy_us / 1000 - refr_time_ms) / refr_count : 0);
|
||||
refr_count = 0;
|
||||
refr_time_ms = 0;
|
||||
busy_us = 0;
|
||||
last_ms = now;
|
||||
}
|
||||
|
||||
|
||||
void my_print(const char* buf) {
|
||||
Serial.println(buf); // Print logs to the serial monitor
|
||||
}
|
||||
|
||||
void display_animation() {
|
||||
lv_obj_t* img;
|
||||
|
||||
LV_IMAGE_DECLARE(loligod);
|
||||
|
||||
img = lv_gif_create(lv_screen_active());
|
||||
|
||||
Serial.print("Available Heap before: ");
|
||||
Serial.println(esp_get_free_heap_size());
|
||||
|
||||
lv_mem_monitor_t mem_mon;
|
||||
lv_mem_monitor(&mem_mon);
|
||||
printf("Free memory: %d bytes\n", mem_mon.free_size);
|
||||
|
||||
// lv_fs_file_t file;
|
||||
// if (lv_fs_open(&file, "A:wallpaper.gif", LV_FS_MODE_RD) == LV_FS_RES_OK) {
|
||||
// lv_fs_close(&file); // File exists, proceed with loading
|
||||
// lv_gif_set_src(img, "A:wallpaper.gif");
|
||||
// Serial.println("GIF Loaded Successfully");
|
||||
// } else {
|
||||
// Serial.println("Failed to Load GIF: File not found or inaccessible");
|
||||
// }
|
||||
lv_gif_set_src(img, &loligod);
|
||||
|
||||
Serial.print("Available Heap after: ");
|
||||
Serial.println(esp_get_free_heap_size());
|
||||
|
||||
lv_mem_monitor(&mem_mon);
|
||||
printf("Free memory: %d bytes\n", mem_mon.free_size);
|
||||
|
||||
lv_obj_align(img, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
lv_obj_t* label1;
|
||||
|
||||
void display_text() {
|
||||
// Create a style for the text
|
||||
static lv_style_t style_text;
|
||||
lv_style_init(&style_text);
|
||||
|
||||
// Set the text color to white
|
||||
lv_style_set_text_color(&style_text, lv_color_white());
|
||||
|
||||
// // Set the shadow color to black (this will simulate the outline)
|
||||
// lv_style_set_shadow_color(&style_text, lv_color_black());
|
||||
|
||||
// // Set the shadow width to create the outline effect
|
||||
// lv_style_set_shadow_width(&style_text, 2); // Adjust for desired outline thickness
|
||||
|
||||
// // Set the shadow offset to 0 so it surrounds the text evenly
|
||||
// lv_style_set_shadow_ofs_x(&style_text, 0);
|
||||
// lv_style_set_shadow_ofs_y(&style_text, 0);
|
||||
|
||||
label1 = lv_label_create(lv_screen_active());
|
||||
|
||||
// Apply the style to the label
|
||||
lv_obj_add_style(label1, &style_text, LV_PART_MAIN);
|
||||
|
||||
// lv_style_set_text_font(&label1, &Montserrat); /*Set a larger font*/
|
||||
lv_label_set_long_mode(label1, LV_LABEL_LONG_WRAP); /*Break the long lines*/
|
||||
lv_label_set_text(label1, "0");
|
||||
lv_obj_set_width(label1, 150); /*Set smaller width to make the lines wrap*/
|
||||
lv_obj_set_style_text_align(label1, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_align(label1, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_style_transform_zoom(label1, 256 * 2, 0); // Zoom: 256 = 1x scale (default)
|
||||
}
|
||||
|
||||
void connectToWifi() {
|
||||
WiFi.begin(ssid, password);
|
||||
Serial.println("Connecting");
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
Serial.println("Wifi not connected");
|
||||
return;
|
||||
}
|
||||
int timeout = 0;
|
||||
while (WiFi.status() != WL_CONNECTED && timeout <= 20) {
|
||||
timeout++;
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println("");
|
||||
Serial.print("Connected to WiFi network with IP Address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void setup() {
|
||||
delay(200);
|
||||
Serial.begin(115200);
|
||||
scr_lvgl_init();
|
||||
lv_display_add_event_cb(lv_display_get_default(), refr_event_cb, LV_EVENT_ALL, NULL);
|
||||
|
||||
//lv_log_register_print_cb(my_print); // Register print function for LVGL logs
|
||||
|
||||
// Get the active screen (root object for the display)
|
||||
lv_obj_t* screen = lv_screen_active();
|
||||
|
||||
// Set the background color of the entire screen to black
|
||||
lv_obj_set_style_bg_color(screen, lv_color_black(), 0); // 0 is the part ID for the main part
|
||||
lv_obj_set_style_bg_opa(screen, LV_OPA_COVER, 0); // Set opacity to fully opaque
|
||||
|
||||
// GIF is compiled into the firmware, so start it before (and independent of) the SD card
|
||||
display_animation();
|
||||
|
||||
// Configure the SDMMC host
|
||||
SD_MMC.setPins(SD_MMC_CLK_PIN, SD_MMC_CMD_PIN, SD_MMC_D0_PIN, SD_MMC_D1_PIN, SD_MMC_D2_PIN, SD_MMC_D3_PIN);
|
||||
|
||||
if (!SD_MMC.begin()) {
|
||||
Serial.println("Card Mount Failed");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t cardType = SD_MMC.cardType();
|
||||
if (cardType == CARD_NONE) {
|
||||
Serial.println("No SD card attached");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.println("SD Card initialized successfully.");
|
||||
|
||||
//connectToWifi();
|
||||
|
||||
//display_text();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
uint32_t t0 = micros();
|
||||
lv_timer_handler();
|
||||
busy_us += micros() - t0;
|
||||
vTaskDelay(1);
|
||||
print_fps();
|
||||
|
||||
|
||||
// if (WiFi.status() == WL_CONNECTED) {
|
||||
// String speed = httpGETRequest("http://192.168.4.1/speed");
|
||||
|
||||
// Serial.print("Speed: ");
|
||||
// Serial.println(speed);
|
||||
|
||||
// lv_label_set_text(label1, speed.c_str());
|
||||
// } else {
|
||||
// Serial.println("WiFi Disconnected");
|
||||
// connectToWifi();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
String httpGETRequest(const char* serverName) {
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
|
||||
// Your Domain name with URL path or IP address with path
|
||||
http.begin(client, serverName);
|
||||
|
||||
// Send HTTP POST request
|
||||
int httpResponseCode = http.GET();
|
||||
|
||||
String payload = "--";
|
||||
|
||||
if (httpResponseCode > 0) {
|
||||
Serial.print("HTTP Response code: ");
|
||||
Serial.println(httpResponseCode);
|
||||
payload = http.getString();
|
||||
} else {
|
||||
Serial.print("Error code: ");
|
||||
Serial.println(httpResponseCode);
|
||||
}
|
||||
// Free resources
|
||||
http.end();
|
||||
|
||||
return payload;
|
||||
#include <Arduino.h>
|
||||
#include "jc3636w518.h"
|
||||
#include "perf_monitor.h"
|
||||
#include "SD_MMC.h"
|
||||
|
||||
|
||||
// https://randomnerdtutorials.com/esp32-client-server-wi-fi/
|
||||
#include <WiFi.h>
|
||||
#include <HTTPClient.h>
|
||||
|
||||
const char* ssid = "ESP32-Access-Point";
|
||||
const char* password = "123456789";
|
||||
|
||||
String httpGETRequest(const char* serverName);
|
||||
|
||||
void my_print(const char* buf) {
|
||||
Serial.println(buf); // Print logs to the serial monitor
|
||||
}
|
||||
|
||||
void display_animation() {
|
||||
lv_obj_t* img;
|
||||
|
||||
LV_IMAGE_DECLARE(loligod);
|
||||
|
||||
img = lv_gif_create(lv_screen_active());
|
||||
|
||||
Serial.print("Available Heap before: ");
|
||||
Serial.println(esp_get_free_heap_size());
|
||||
|
||||
lv_mem_monitor_t mem_mon;
|
||||
lv_mem_monitor(&mem_mon);
|
||||
printf("Free memory: %d bytes\n", mem_mon.free_size);
|
||||
|
||||
// lv_fs_file_t file;
|
||||
// if (lv_fs_open(&file, "A:wallpaper.gif", LV_FS_MODE_RD) == LV_FS_RES_OK) {
|
||||
// lv_fs_close(&file); // File exists, proceed with loading
|
||||
// lv_gif_set_src(img, "A:wallpaper.gif");
|
||||
// Serial.println("GIF Loaded Successfully");
|
||||
// } else {
|
||||
// Serial.println("Failed to Load GIF: File not found or inaccessible");
|
||||
// }
|
||||
lv_gif_set_src(img, &loligod);
|
||||
|
||||
Serial.print("Available Heap after: ");
|
||||
Serial.println(esp_get_free_heap_size());
|
||||
|
||||
lv_mem_monitor(&mem_mon);
|
||||
printf("Free memory: %d bytes\n", mem_mon.free_size);
|
||||
|
||||
lv_obj_align(img, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
lv_obj_t* label1;
|
||||
|
||||
void display_text() {
|
||||
// Create a style for the text
|
||||
static lv_style_t style_text;
|
||||
lv_style_init(&style_text);
|
||||
|
||||
// Set the text color to white
|
||||
lv_style_set_text_color(&style_text, lv_color_white());
|
||||
|
||||
// // Set the shadow color to black (this will simulate the outline)
|
||||
// lv_style_set_shadow_color(&style_text, lv_color_black());
|
||||
|
||||
// // Set the shadow width to create the outline effect
|
||||
// lv_style_set_shadow_width(&style_text, 2); // Adjust for desired outline thickness
|
||||
|
||||
// // Set the shadow offset to 0 so it surrounds the text evenly
|
||||
// lv_style_set_shadow_ofs_x(&style_text, 0);
|
||||
// lv_style_set_shadow_ofs_y(&style_text, 0);
|
||||
|
||||
label1 = lv_label_create(lv_screen_active());
|
||||
|
||||
// Apply the style to the label
|
||||
lv_obj_add_style(label1, &style_text, LV_PART_MAIN);
|
||||
|
||||
// lv_style_set_text_font(&label1, &Montserrat); /*Set a larger font*/
|
||||
lv_label_set_long_mode(label1, LV_LABEL_LONG_WRAP); /*Break the long lines*/
|
||||
lv_label_set_text(label1, "0");
|
||||
lv_obj_set_width(label1, 150); /*Set smaller width to make the lines wrap*/
|
||||
lv_obj_set_style_text_align(label1, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_align(label1, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_style_transform_zoom(label1, 256 * 2, 0); // Zoom: 256 = 1x scale (default)
|
||||
}
|
||||
|
||||
void connectToWifi() {
|
||||
WiFi.begin(ssid, password);
|
||||
Serial.println("Connecting");
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
Serial.println("Wifi not connected");
|
||||
return;
|
||||
}
|
||||
int timeout = 0;
|
||||
while (WiFi.status() != WL_CONNECTED && timeout <= 20) {
|
||||
timeout++;
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println("");
|
||||
Serial.print("Connected to WiFi network with IP Address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void setup() {
|
||||
delay(200);
|
||||
Serial.begin(115200);
|
||||
lv_display_t* disp = scr_lvgl_init();
|
||||
perf_monitor_begin(disp);
|
||||
|
||||
//lv_log_register_print_cb(my_print); // Register print function for LVGL logs
|
||||
|
||||
// Get the active screen (root object for the display)
|
||||
lv_obj_t* screen = lv_screen_active();
|
||||
|
||||
// Set the background color of the entire screen to black
|
||||
lv_obj_set_style_bg_color(screen, lv_color_black(), 0); // 0 is the part ID for the main part
|
||||
lv_obj_set_style_bg_opa(screen, LV_OPA_COVER, 0); // Set opacity to fully opaque
|
||||
|
||||
// GIF is compiled into the firmware, so start it before (and independent of) the SD card
|
||||
display_animation();
|
||||
|
||||
// Configure the SDMMC host
|
||||
SD_MMC.setPins(SD_MMC_CLK_PIN, SD_MMC_CMD_PIN, SD_MMC_D0_PIN, SD_MMC_D1_PIN, SD_MMC_D2_PIN, SD_MMC_D3_PIN);
|
||||
|
||||
if (!SD_MMC.begin()) {
|
||||
Serial.println("Card Mount Failed");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t cardType = SD_MMC.cardType();
|
||||
if (cardType == CARD_NONE) {
|
||||
Serial.println("No SD card attached");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.println("SD Card initialized successfully.");
|
||||
|
||||
//connectToWifi();
|
||||
|
||||
//display_text();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
perf_timer_handler();
|
||||
vTaskDelay(1);
|
||||
perf_monitor_print();
|
||||
|
||||
|
||||
// if (WiFi.status() == WL_CONNECTED) {
|
||||
// String speed = httpGETRequest("http://192.168.4.1/speed");
|
||||
|
||||
// Serial.print("Speed: ");
|
||||
// Serial.println(speed);
|
||||
|
||||
// lv_label_set_text(label1, speed.c_str());
|
||||
// } else {
|
||||
// Serial.println("WiFi Disconnected");
|
||||
// connectToWifi();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
String httpGETRequest(const char* serverName) {
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
|
||||
// Your Domain name with URL path or IP address with path
|
||||
http.begin(client, serverName);
|
||||
|
||||
// Send HTTP POST request
|
||||
int httpResponseCode = http.GET();
|
||||
|
||||
String payload = "--";
|
||||
|
||||
if (httpResponseCode > 0) {
|
||||
Serial.print("HTTP Response code: ");
|
||||
Serial.println(httpResponseCode);
|
||||
payload = http.getString();
|
||||
} else {
|
||||
Serial.print("Error code: ");
|
||||
Serial.println(httpResponseCode);
|
||||
}
|
||||
// Free resources
|
||||
http.end();
|
||||
|
||||
return payload;
|
||||
}
|
||||
Reference in new issue
Block a user