Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions boards/_boards_json/freenove-fnk0103.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"build": {
"arduino": {
"ldscript": "esp32_out.ld"
},
"core": "esp32",
"extra_flags": [
"-DARDUINO_ESP32_DEV",
"-DFREENOVE_FNK0103",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1"
],
"f_cpu": "240000000L",
"f_flash": "40000000L",
"flash_mode": "dio",
"mcu": "esp32",
"variant": "pinouts"
},
"connectivity": [
"wifi",
"bluetooth"
],
"debug": {
"openocd_board": "esp-wroom-32.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Freenove FNK0103",
"upload": {
"flash_size": "4MB",
"maximum_ram_size": 327680,
"maximum_size": 4194304,
"require_upload_port": true,
"speed": 460800
},
"url": "https://docs.freenove.com/projects/fnk0103/",
"vendor": "Freenove"
}
26 changes: 26 additions & 0 deletions boards/freenove-fnk0103/freenove-fnk0103.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
; PlatformIO Project Configuration File

[env:freenove-fnk0103]
board = freenove-fnk0103
board_build.partitions = custom_4Mb_full.csv
build_src_filter = ${env.build_src_filter} +<../boards/freenove-fnk0103>
build_flags =
${env.build_flags}
${env_4mb.build_flags}
-Iboards/freenove-fnk0103
-DFREENOVE_FNK0103=1
-DDEVICE_NAME='"Freenove FNK0103 3.2 ST7789"'

; Touch controller (resistive)
-DTOUCH_XPT2046_SPI
-DXPT2046_TOUCH_CONFIG_INT_GPIO_NUM=-1
-DXPT2046_SPI_BUS_MISO_IO_NUM=39
-DXPT2046_SPI_BUS_MOSI_IO_NUM=32
-DXPT2046_SPI_BUS_SCLK_IO_NUM=25
-DXPT2046_SPI_CONFIG_CS_GPIO_NUM=33

lib_deps =
${env.lib_deps}

lib_ignore =
${env_4mb.lib_ignore}
91 changes: 91 additions & 0 deletions boards/freenove-fnk0103/interface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#include "core/powerSave.h"
#include "core/utils.h"
#include <CYD28_TouchscreenR.h>
#include <interface.h>

CYD28_TouchR touch(320, 240);

/***************************************************************************************
** Function name: _setup_gpio()
** Description: initial setup for the device
***************************************************************************************/
void _setup_gpio() {
bruceConfig.colorInverted = 0;
pinMode(TFT_BL, OUTPUT);
digitalWrite(TFT_BL, HIGH);
}

/***************************************************************************************
** Function name: _post_setup_gpio()
** Description: second stage gpio setup to make touch work
***************************************************************************************/
void _post_setup_gpio() {
if (!touch.begin(&tft.getSPIinstance())) {
Serial.println("Touch IC not Started");
log_i("Touch IC not Started");
} else Serial.println("Touch IC Started");
}

/***************************************************************************************
** Function name: getBattery()
** Description: Delivers the battery value from 1-100
***************************************************************************************/
int getBattery() { return 0; }

/*********************************************************************
** Function: setBrightness
** set brightness value
**********************************************************************/
void _setBrightness(uint8_t brightval) {
if (brightval > 5) digitalWrite(TFT_BL, HIGH);
else digitalWrite(TFT_BL, LOW);
}

/*********************************************************************
** Function: InputHandler
** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
**********************************************************************/
void InputHandler(void) {
static unsigned long tm = millis();
if (millis() - tm > 300 || LongPress) {
if (touch.touched()) {
auto t = touch.getPointScaled();
t = touch.getPointScaled();
tm = millis();
if (bruceConfigPins.rotation == 3) {
t.y = (tftHeight + 20) - t.y;
t.x = tftWidth - t.x;
}
if (bruceConfigPins.rotation == 0) {
int tmp = t.x;
t.x = tftWidth - t.y;
t.y = tmp;
}
if (bruceConfigPins.rotation == 2) {
int tmp = t.x;
t.x = t.y;
t.y = (tftHeight + 20) - tmp;
}

if (!wakeUpScreen()) AnyKeyPress = true;
else return;

touchPoint.x = t.x;
touchPoint.y = t.y;
touchPoint.pressed = true;
touchHeatMap(touchPoint);
} else touchPoint.pressed = false;
}
}

/*********************************************************************
** Function: powerOff
** Turns off the device (or try to)
**********************************************************************/
void powerOff() {}

/*********************************************************************
** Function: checkReboot
** Btn logic to turn off the device
**********************************************************************/
void checkReboot() {}
82 changes: 82 additions & 0 deletions boards/freenove-fnk0103/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include "soc/soc_caps.h"
#include <stdint.h>

#define USB_VID 0x303a
#define USB_PID 0x1001

static const uint8_t TX = 1;
static const uint8_t RX = 3;

static const uint8_t TXD2 = 17;
static const uint8_t RXD2 = 16;

static const uint8_t SDA = 21;
static const uint8_t SCL = 22;

static const uint8_t SS = -1;
static const uint8_t MOSI = -1;
static const uint8_t MISO = -1;
static const uint8_t SCK = -1;

#define BAD_TX GROVE_SDA
#define BAD_RX GROVE_SCL

#define SERIAL_TX 1
#define SERIAL_RX 3
#define GPS_SERIAL_TX SERIAL_TX
#define GPS_SERIAL_RX SERIAL_RX

#define HAS_BTN 0
#define BTN_ALIAS "\"Ok\""
#define BTN_PIN 0
#define BTN_ACT LOW

#define TXLED -1
#define LED_ON HIGH
#define LED_OFF LOW

#define FP 1
#define FM 2
#define FG 3

#define HAS_SCREEN 1
#define HAS_TOUCH 1
#define ROTATION 1
#define MINBRIGHT 160

#define USER_SETUP_LOADED 1
#define USE_HSPI_PORT 1
#define ST7789_DRIVER 1
#define TFT_WIDTH 240
#define TFT_HEIGHT 320
#define TFT_MISO 39
#define TFT_MOSI 32
#define TFT_SCLK 25
#define TFT_CS 26
#define TFT_DC 27
#define TFT_RST 14
#define TFT_BL 21
#define TFT_BACKLIGHT_ON HIGH
#define SMOOTH_FONT 1
#define SPI_FREQUENCY 40000000
#define SPI_READ_FREQUENCY 20000000
#define SPI_TOUCH_FREQUENCY 2500000
#define TOUCH_CS 33

#define SDCARD_CS -1
#define SDCARD_SCK -1
#define SDCARD_MISO -1
#define SDCARD_MOSI -1

#define GROVE_SDA 22
#define GROVE_SCL 21

#define SPI_SCK_PIN 25
#define SPI_MISO_PIN 39
#define SPI_MOSI_PIN 32
#define SPI_SS_PIN 33

#endif /* Pins_Arduino_h */
2 changes: 2 additions & 0 deletions boards/pinouts/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@
#include "../ESP32-C5/pins_arduino.h"
#elif NM_CYD_ESP32C5
#include "../nm-cyd-c5/pins_arduino.h"
#elif FREENOVE_FNK0103
#include "../freenove-fnk0103/pins_arduino.h"
#endif
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ default_envs =
;elecrow-28B
;elecrow-35B
;elecrow-35Bv2_2
;freenove-fnk0103


;uncomment to not use global dirs to avoid possible conflicts
Expand Down