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
49 changes: 49 additions & 0 deletions boards/_boards_json/lord-board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"build": {
"arduino": {
"ldscript": "esp32s3_out.ld",
"partitions": "default_16MB.csv"
},
"core": "esp32",
"extra_flags": [
"-DSMOOCHIEE_BOARD",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1",
"-DARDUINO_USB_CDC_ON_BOOT",
"-DARDUINO_USB_MODE=1",
"-DBOARD_HAS_PSRAM"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"hwids": [
[
"0x303A",
"0x1001"
]
],
"mcu": "esp32s3",
"variant": "pinouts"
},
"connectivity": [
"bluetooth",
"wifi"
],
"debug": {
"openocd_target": "esp32s3.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Smoochiee Board",
"upload": {
"flash_size": "16MB",
"maximum_ram_size": 327680,
"maximum_size": 16777216,
"require_upload_port": true,
"speed": 460800
},
"url": "https://docs.m5stack.com/en/core/StampS3",
"vendor": "Smoochiee"
}
Binary file added boards/lord-board/circuit_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
162 changes: 162 additions & 0 deletions boards/lord-board/interface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#include "core/powerSave.h"
#include "core/utils.h"
#include <interface.h>

/***************************************************************************************
** Function name: _setup_gpio()
** Location: main.cpp
** Description: initial setup for the device
***************************************************************************************/
void _setup_gpio() {

pinMode(TFT_CS, OUTPUT);
digitalWrite(TFT_CS, HIGH);
pinMode(TFT_MOSI, OUTPUT);
digitalWrite(TFT_MOSI, HIGH);
pinMode(TFT_SCLK, OUTPUT);

pinMode(TFT_BL, OUTPUT);
digitalWrite(TFT_BL, HIGH);
pinMode(TFT_RST, OUTPUT);
pinMode(TFT_DC, OUTPUT);
digitalWrite(TFT_DC, HIGH);

pinMode(NRF24_SS_PIN, OUTPUT);
pinMode(CC1101_SS_PIN, OUTPUT);
pinMode(SDCARD_CS, OUTPUT);
pinMode(TFT_CS, OUTPUT);

digitalWrite(NRF24_SS_PIN, HIGH);
digitalWrite(CC1101_SS_PIN, HIGH);
digitalWrite(SDCARD_CS, HIGH);
digitalWrite(TFT_CS, HIGH);

bruceConfig.colorInverted = 0;
}
/***************************************************************************************
** Function name: _post_setup_gpio()
** Location: main.cpp
** Description: second stage gpio setup to make a few functions work
***************************************************************************************/
void _post_setup_gpio() {
pinMode(TOUCH_CS, OUTPUT);
uint16_t calData[5];
File caldata = LittleFS.open("/calData", "r");

if (!caldata) {
tft.setRotation(ROTATION);
tft.calibrateTouch(calData, TFT_WHITE, TFT_BLACK, 10);

caldata = LittleFS.open("/calData", "w");
if (caldata) {
caldata.printf(
"%d\n%d\n%d\n%d\n%d\n", calData[0], calData[1], calData[2], calData[3], calData[4]
);
caldata.close();
}
} else {
Serial.print("\ntft Calibration data: ");
for (int i = 0; i < 5; i++) {
String line = caldata.readStringUntil('\n');
calData[i] = line.toInt();
Serial.printf("%d, ", calData[i]);
}
Serial.println();
caldata.close();
}
tft.setTouch(calData);
}

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

/***************************************************************************************
** Function name: isCharging()
** Description: Default implementation that returns false
***************************************************************************************/
bool isCharging() { return false; }

/*********************************************************************
** Function: setBrightness
** location: settings.cpp
** set brightness value
**********************************************************************/
void _setBrightness(uint8_t brightval) {
if (brightval == 0) {
analogWrite(TFT_BL, brightval);
} else {
int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval / 100));
analogWrite(TFT_BL, bl);
}
}

/*********************************************************************
** Function: InputHandler
** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
**********************************************************************/
void InputHandler(void) {
static unsigned long tm = 0;
if (millis() - tm < 200 && !LongPress) return;

TouchPoint t;
checkPowerSaveTime();
bool _IH_touched = tft.getTouch(&t.x, &t.y);
if (_IH_touched) {
NextPress = false;
PrevPress = false;
UpPress = false;
DownPress = false;
SelPress = false;
EscPress = false;
AnyKeyPress = false;
NextPagePress = false;
PrevPagePress = false;
touchPoint.pressed = false;
_IH_touched = false;
Serial.printf("\nRAW: Touch Pressed on x=%d, y=%d", t.x, t.y);
if (bruceConfig.rotation == 3) {
t.y = (tftHeight + 20) - t.y;
t.x = tftWidth - t.x;
}
if (bruceConfig.rotation == 0) {
uint16_t tmp = t.x;
t.x = map((tftHeight + 20) - t.y, 0, 320, 0, 240);
t.y = map(tmp, 0, 240, 0, 320);
}
if (bruceConfig.rotation == 2) {
uint16_t tmp = t.x;
t.x = map(t.y, 0, 320, 0, 240);
t.y = map(tftWidth - tmp, 0, 240, 0, 320);
}

Serial.printf("\nROT: Touch Pressed on x=%d, y=%d, rot=%d\n", t.x, t.y, bruceConfig.rotation);

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

// Touch point global variable
touchPoint.x = t.x;
touchPoint.y = t.y;
touchPoint.pressed = true;
touchHeatMap(touchPoint);
tm = millis();
}
}

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

/*********************************************************************
** Function: checkReboot
** location: mykeyboard.cpp
** Btn logic to turnoff the device (name is odd btw)
**********************************************************************/
void checkReboot() {}
32 changes: 32 additions & 0 deletions boards/lord-board/lord-board.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html



;Little Offensive Reconnaissance Device Board
[env:lord-board]
board = lord-board
build_src_filter =${env.build_src_filter} +<../boards/lord-board>
board_build.arduino.memory_type = qio_opi
board_build.partitions = custom_16Mb.csv
build_flags =
${env.build_flags}
-Iboards/lord-board
-Os
-DCORE_DEBUG_LEVEL=5
-DARDUINO_USB_CDC_ON_BOOT=1 ; Used only in ESP32-S3 to make Serial Comands work
-DDEVICE_NAME='"Lord Board"'



lib_deps =
${env.lib_deps}
lewisxhe/XPowersLib @0.2.6
; fastled/FastLED @3.9.4
133 changes: 133 additions & 0 deletions boards/lord-board/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

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

// ---------------- CONFIG --------------------
#define USB_VID 0x303a
#define USB_PID 0x1001
#define USER_SETUP_LOADED 1
#define USE_HSPI_PORT 1
#define HAS_SCREEN 1
#define HAS_TOUCH 1
#define HAS_SD 0
#define FP 1
#define FM 2
#define FG 3

// ---------------- UART --------------------
// UART0: Programming via CH343 USB-Serial (default)
static const uint8_t TX = 43; // CH343 USB-Serial TX
static const uint8_t RX = 44; // CH343 USB-Serial

// UART1: GPS NEO‑6M
static const uint8_t GPS_TX = 41; // ESP32 TX1 -> GPS RX
static const uint8_t GPS_RX = 40; // ESP32 RX1 <- GPS TX

//------------------BAD USB ----------------
#define SERIAL_RX 44 // CH343 USB-serial RX
#define SERIAL_TX 43 // CH343 USB-serial TX
#define BAD_RX SERIAL_RX
#define BAD_TX SERIAL_TX
#define USB_as_HID 1

// ---------------- I2C -------------------------
// PN532 NFC (I2C)
static const uint8_t SDA = 45;
static const uint8_t SCL = 42; // Safe choice, avoids SPI/Touch conflicts

// ---------------- Shared VSPI Bus ---------------
// VSPI for TFT (ILI9341), Touch (XPT2046), SD card
static const uint8_t SS = 14;
static const uint8_t SCK = 13;
static const uint8_t MOSI = 12;
static const uint8_t MISO = 11;
#define SPI_FREQUENCY 16000000
#define SPI_READ_FREQUENCY 16000000
#define SPI_TOUCH_FREQUENCY 2000000

// ---------------- ILI9341 TFT ---------------
#define ILI9341_DRIVER 1
#define TFT_RGB_ORDER 0
#define TFT_WIDTH 240
#define TFT_HEIGHT 320
#define TFT_BACKLIGHT_ON 1
#define TFT_BL 10
#define TFT_RST 9
#define TFT_DC 3
#define TFT_MISO MISO
#define TFT_MOSI MOSI
#define TFT_SCLK SCK
#define TFT_CS 8
#define SMOOTH_FONT 1
#define ROTATION 1
#define MINBRIGHT (uint8_t)1

// ---------------- XPT2046 Touch ---------------

#define USE_TFT_eSPI_TOUCH 1 // touchscreen uses same tft spi bus
#define HAS_TOUCH 1
#define TOUCH_INT 39
#define TOUCH_CS 38
#define BTN_ACT LOW
#define DEEPSLEEP_WAKEUP_PIN 0

// ---------------- SD CARD --------------------
#define SDCARD_CS -1
#define SDCARD_SCK SCK
#define SDCARD_MISO MISO
#define SDCARD_MOSI MOSI

// ----------------Onboard RGB LED --------------------
#define LED_BUILTIN 48 // WS2812 data pin
#define HAS_RGB_LED 1
#define RGB_LED 48
#define LED_TYPE WS2812B
#define LED_ORDER GRB
#define LED_TYPE_IS_RGBW 0
#define LED_COUNT 1
#define LED_COLOR_STEP 15

// ----------------Button --------------------
#define HAS_BTN 0
#define BTN_ALIAS "\"Ok\""
#define BTN_PIN -1

// ---------------- Shared HSPI Bus ---------------
// HSPI for CC1101 , NRF24+
static const uint8_t SPI_SCK_PIN = 18;
static const uint8_t SPI_MOSI_PIN = 17;
static const uint8_t SPI_MISO_PIN = 16;

// ---------------- CC1101 Radio ----------------
#define USE_CC1101_VIA_SPI
#define CC1101_SS_PIN 15
#define CC1101_GDO0_PIN 7 // No longer conflict with TFT_BL
#define CC1101_GDO2_PIN 6 // Moved from GPIO4 → avoids backlight & reserved pins
#define CC1101_SCK_PIN SPI_SCK_PIN
#define CC1101_MOSI_PIN SPI_MOSI_PIN
#define CC1101_MISO_PIN SPI_MISO_PIN

// ---------------- nRF24L01+ Radio --------------
#define USE_NRF24_VIA_SPI
#define NRF24_SS_PIN 5
#define NRF24_CE_PIN 4
#define NRF24_SCK_PIN SPI_SCK_PIN
#define NRF24_MOSI_PIN SPI_MOSI_PIN
#define NRF24_MISO_PIN SPI_MISO_PIN

// ---------------- IR Transmitter/Receiver -----
#define GROVE_SDA 45
#define GROVE_SCL 42
#define IR_RX_PIN 1 // digital input (connect IR receiver OUT here)
#define IR_TX_PIN 2 // digital output (PWM capable, for IR LED)
#define RXLED 1
#define LED 2 // Renamed from LED to avoid conflicts
#define LED_ON HIGH
#define LED_OFF LOW

// ---------------- ALIAS -----
#define SPI_SS_PIN TFT_CS

#endif /* Pins_Arduino_h */
Loading