Skip to content

Commit

Permalink
Merge pull request #15 from jgauchia/esp32s3mf
Browse files Browse the repository at this point in the history
Add support to Makerfabs ESP32-S3 Parallel TFT with Touch 3.5'' ILI9488
  • Loading branch information
jgauchia authored Apr 9, 2023
2 parents 5fd3d65 + efb5c28 commit 56b755a
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 206 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ Specifications:
* MPU6050 Accelerometer and Gyroscope IMU
* HT1818Z3G5L GPS Module
* LVGL UI + LovyanGFX

Added support to Makerfabs ESP32-S3 Parallel TFT with Touch 3.5" ILI9488 (thanks to @hpsaturn)


6 changes: 4 additions & 2 deletions lib/lv_CUSTOMBOARD_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@
*It removes the need to manually update the tick with `lv_tick_inc()`)*/
#define LV_TICK_CUSTOM 1
#if LV_TICK_CUSTOM
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
//#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
//#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
#define LV_TICK_CUSTOM_INCLUDE "esp_timer.h"
#define LV_TICK_CUSTOM_SYS_TIME_EXPR ((esp_timer_get_time() / 1000LL))
#endif /*LV_TICK_CUSTOM*/

/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
Expand Down
8 changes: 5 additions & 3 deletions lib/lv_MAKERF_ESP32S3_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@

/*Use a custom tick source that tells the elapsed time in milliseconds.
*It removes the need to manually update the tick with `lv_tick_inc()`)*/
#define LV_TICK_CUSTOM 1
#define LV_TICK_CUSTOM 0
#if LV_TICK_CUSTOM
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
//#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
//#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
#define LV_TICK_CUSTOM_INCLUDE "esp_timer.h"
#define LV_TICK_CUSTOM_SYS_TIME_EXPR ((esp_timer_get_time() / 1000LL))
#endif /*LV_TICK_CUSTOM*/

/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
Expand Down
76 changes: 0 additions & 76 deletions lib/makefabs-esp32s3parallel/FT6236.cpp

This file was deleted.

16 changes: 0 additions & 16 deletions lib/makefabs-esp32s3parallel/FT6236.h

This file was deleted.

46 changes: 28 additions & 18 deletions lib/makefabs-esp32s3parallel/LGFX_MakerFabs_Parallel_S3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,17 @@
#include "SPI.h"
#include <LovyanGFX.hpp>

#define I2C_SCL 39
#define I2C_SDA 38

//#define NS2009_TOUCH //Resistive screen driver
#define FT6236_TOUCH //Capacitive screen driver

#ifdef NS2009_TOUCH
#include "NS2009.h"
const int i2c_touch_addr = NS2009_ADDR;
#define get_pos ns2009_pos
#endif

#ifdef FT6236_TOUCH
#include "FT6236.h"
const int i2c_touch_addr = TOUCH_I2C_ADD;
#define get_pos ft6236_pos
#endif

class LGFX : public lgfx::LGFX_Device
{
static constexpr int I2C_PORT_NUM = 0;
static constexpr int I2C_PIN_SDA = 38;
static constexpr int I2C_PIN_SCL = 39;
static constexpr int I2C_PIN_INT = 40;

// lgfx::Panel_ILI9341 _panel_instance;
lgfx::Panel_ILI9488 _panel_instance;
lgfx::Bus_Parallel16 _bus_instance; // 8ビットパラレルバスのインスタンス (ESP32のみ)
lgfx::Touch_FT5x06 _touch_instance;

public:
// コンストラクタを作成し、ここで各種設定を行います。
Expand Down Expand Up @@ -93,5 +81,27 @@ class LGFX : public lgfx::LGFX_Device
}

setPanel(&_panel_instance); // 使用するパネルをセットします。

{
auto cfg = _touch_instance.config();

cfg.x_min = 0;
cfg.x_max = 320;
cfg.y_min = 0;
cfg.y_max = 480;
cfg.pin_int = I2C_PIN_INT;
cfg.bus_shared = true;
cfg.offset_rotation = 0;

cfg.i2c_port = I2C_PORT_NUM;
cfg.i2c_addr = 0x38;
cfg.pin_sda = I2C_PIN_SDA;
cfg.pin_scl = I2C_PIN_SCL;
cfg.freq = 400000;

_touch_instance.config(cfg);
_panel_instance.setTouch(&_touch_instance);
}
setPanel(&_panel_instance);
}
};
50 changes: 0 additions & 50 deletions lib/makefabs-esp32s3parallel/NS2009.cpp

This file was deleted.

20 changes: 0 additions & 20 deletions lib/makefabs-esp32s3parallel/NS2009.h

This file was deleted.

7 changes: 4 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ default_envs = CUSTOMBOARD
[common]
platform = espressif32
framework = arduino
version = 0.1.1
revision = 7
version = 0.1.2
revision = 10
monitor_speed = 115200
monitor_rts = 0
monitor_dtr = 0
Expand All @@ -40,7 +40,7 @@ lib_deps =
adafruit/Adafruit BME280 Library@^2.2.2
paulstoffregen/Time@^1.6.1
me-no-dev/ESP Async WebServer@^1.2.3
lvgl/lvgl@^8.3.2
lvgl/lvgl@^8.3.4
lovyan03/LovyanGFX@^1.1.5
jchristensen/Timezone@^1.2.4

Expand All @@ -66,6 +66,7 @@ build_flags =
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
-D ENABLE_COMPASS=1
-D ENABLE_BME=1
-D TFT_WIDTH=320
-D TFT_HEIGHT=480
-D TFT_BL=33
Expand Down
2 changes: 2 additions & 0 deletions src/gui/events/main_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ void update_main_screen(lv_timer_t *t)
switch (act_tile)
{
case COMPASS:
#ifdef ENABLE_COMPASS
heading = read_compass();
lv_event_send(compass_heading, LV_EVENT_VALUE_CHANGED, NULL);
#endif

if (GPS.location.isUpdated())
{
Expand Down
2 changes: 2 additions & 0 deletions src/gui/events/notify_bar.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ void update_notify_bar(lv_timer_t *t)
sat_count_old = GPS.satellites.value();
}

#ifdef ENABLE_BME
if (int(bme.readTemperature()) != temp_old)
{
lv_label_set_text_fmt(temp, "%02d\xC2\xB0", int(bme.readTemperature()));
temp_old = int(bme.readTemperature());
}
#endif
}
13 changes: 0 additions & 13 deletions src/gui/lvgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,7 @@ void disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
void touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
{
uint16_t touchX, touchY;

#ifndef MAKERF_ESP32S3
bool touched = tft.getTouch(&touchX, &touchY);
#else
int pos[2] = {0, 0};
bool touched = false;
get_pos(pos);
if (pos[0]!=0 && pos[1]!=0)
{
touched = true;
touchX = pos[0];
touchY = pos[1];
}
#endif
if (!touched)
data->state = LV_INDEV_STATE_RELEASED;
else
Expand Down
1 change: 1 addition & 0 deletions src/gui/screens-lvgl/main_scr.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void create_main_scr()
lv_obj_set_align(compass_heading, LV_ALIGN_CENTER);
lv_obj_set_y(compass_heading, 35);
lv_obj_set_style_text_font(compass_heading, &lv_font_montserrat_48, 0);
lv_label_set_text(compass_heading, "-----\xC2\xB0");

lv_obj_t *arrow_img = lv_img_create(compass_tile);
lv_img_set_src(arrow_img, "F:/arrow.bin");
Expand Down
1 change: 1 addition & 0 deletions src/gui/screens-lvgl/notify_bar.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void create_notify_bar()
temp = lv_label_create(lv_scr_act());
lv_obj_set_size(temp, 50, 20);
lv_obj_set_pos(temp, TFT_WIDTH - 145, 2);
lv_label_set_text(temp, "--\xC2\xB0");

gps_time = lv_label_create(lv_scr_act());
lv_obj_set_size(gps_time, 100, 20);
Expand Down
6 changes: 3 additions & 3 deletions src/hardware/tft.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <LGFX_TFT_eSPI.hpp>

int brightness_level = 255;
uint8_t brightness_level = 255;

static TFT_eSPI tft;
#define LVGL_BKG 0x10A2
Expand All @@ -27,7 +27,7 @@ static TFT_eSPI tft;
*
* @param brightness -> 0..255
*/
void set_brightness(int brightness)
void set_brightness(uint8_t brightness)
{
if (brightness <= 255)
{
Expand All @@ -41,7 +41,7 @@ void set_brightness(int brightness)
*
* @return int -> brightness value 0..255
*/
int get_brightness()
uint8_t get_brightness()
{
return brightness_level;
}
Expand Down
Loading

0 comments on commit 56b755a

Please sign in to comment.