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
10 changes: 10 additions & 0 deletions boards/m5stack-cplus2/m5stack-cplus2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ build_flags =
-DW5500_MISO_PIN=SPI_MISO_PIN
-DW5500_INT_PIN=25

;Lora setup pins
-DLORA_SCK=SPI_SCK_PIN
-DLORA_MISO=SPI_MISO_PIN
-DLORA_MOSI=SPI_MOSI_PIN
-DLORA_CS=SPI_SS_PIN
-DLORA_RST=-1
-DLORA_DIO0=25

-DBAT_PIN=38

-DFP=1
Expand Down Expand Up @@ -116,6 +124,8 @@ build_flags =
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000



;SD Card Setup pins
-DSDCARD_CS=14
-DSDCARD_SCK=0
Expand Down
45 changes: 44 additions & 1 deletion include/precompiler_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,29 @@
#ifndef TFT_WIDTH
#define TFT_WIDTH 240
#endif
#ifndef TFT_HEIGHT
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 135
#endif

#ifndef LORA_SCK
#define LORA_SCK -1
#endif
#ifndef LORA_MISO
#define LORA_MISO -1
#endif
#ifndef LORA_MOSI
#define LORA_MOSI -1
#endif
#ifndef LORA_CS
#define LORA_CS -1
#endif
#ifndef LORA_RST
#define LORA_RST -1
#endif
#ifndef LORA_DIO0
#define LORA_DIO0 -1
#endif

// Default initializers
#ifndef TFT_CS
#define TFT_CS -1
Expand Down Expand Up @@ -187,6 +206,30 @@
#define CC1101_GDO0_PIN -1
#endif

#ifndef LORA_SCK
#define LORA_SCK -1
#endif

#ifndef LORA_MISO
#define LORA_MISO -1
#endif

#ifndef LORA_MOSI
#define LORA_MOSI -1
#endif

#ifndef LORA_CS
#define LORA_CS -1
#endif

#ifndef LORA_RST
#define LORA_RST -1
#endif

#ifndef LORA_DIO0
#define LORA_DIO0 -1
#endif

// Temporary, delete after finish Interfaces

#ifndef SMOOTH_FONT
Expand Down
5 changes: 3 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[platformio]
default_envs =
;m5stack-cardputer
;m5stack-cplus2
m5stack-cplus2
;m5stack-cplus1_1
;LAUNCHER_m5stack-cplus1_1
;m5stack-core2
Expand All @@ -28,7 +28,7 @@ default_envs =
;LAUNCHER_CYD-2432S028
;LAUNCHER_CYD-2USB
;LAUNCHER_CYD-2432W328C
lilygo-t-embed-cc1101
;lilygo-t-embed-cc1101
;lilygo-t-embed
;lilygo-t-deck
;lilygo-t-watch-s3
Expand Down Expand Up @@ -119,6 +119,7 @@ extra_scripts =
post:build.py

lib_deps =
sandeepmistry/LoRa@^0.8.0
https://github.com/sayacom/WireGuard-ESP32-Arduino#feature/esp-netif
;WireGuard-ESP32
https://github.com/bmorcelli/IRremoteESP8266
Expand Down
37 changes: 37 additions & 0 deletions src/core/configPins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,49 @@ void BruceConfigPins::fromJson(JsonObject obj) {

JsonObject root = obj[mac].as<JsonObject>();

if (!root["LoRa_Pins"].isNull()) {
SPIPins def = LoRa_bus;
LoRa_bus.fromJson(root["LoRa_Pins"].as<JsonObject>());
if (LoRa_bus.sck == GPIO_NUM_NC && def.sck != GPIO_NUM_NC) {
LoRa_bus = def;
count++;
}
} else {
count++;
log_e("Fail");
}

if (!root["CC1101_Pins"].isNull()) {
SPIPins def = CC1101_bus;
CC1101_bus.fromJson(root["CC1101_Pins"].as<JsonObject>());
if (CC1101_bus.sck == GPIO_NUM_NC && def.sck != GPIO_NUM_NC) {
CC1101_bus = def;
count++;
}
} else {
count++;
log_e("Fail");
}

if (!root["NRF24_Pins"].isNull()) {
SPIPins def = NRF24_bus;
NRF24_bus.fromJson(root["NRF24_Pins"].as<JsonObject>());
if (NRF24_bus.sck == GPIO_NUM_NC && def.sck != GPIO_NUM_NC) {
NRF24_bus = def;
count++;
}
} else {
count++;
log_e("Fail");
}

if (!root["SDCard_Pins"].isNull()) {
SPIPins def = SDCARD_bus;
SDCARD_bus.fromJson(root["SDCard_Pins"].as<JsonObject>());
if (SDCARD_bus.sck == GPIO_NUM_NC && def.sck != GPIO_NUM_NC) {
SDCARD_bus = def;
count++;
}
} else {
count++;
log_e("Fail");
Expand Down Expand Up @@ -78,6 +105,9 @@ void BruceConfigPins::fromJson(JsonObject obj) {
void BruceConfigPins::toJson(JsonObject obj) const {
JsonObject root = obj[getMacAddress()].to<JsonObject>();

JsonObject _LoRa = root["LoRa_Pins"].to<JsonObject>();
LoRa_bus.toJson(_LoRa);

JsonObject _CC1101 = root["CC1101_Pins"].to<JsonObject>();
CC1101_bus.toJson(_CC1101);

Expand Down Expand Up @@ -191,6 +221,7 @@ void BruceConfigPins::factoryReset() {
}

void BruceConfigPins::validateConfig() {
validateSpiPins(LoRa_bus);
validateSpiPins(CC1101_bus);
validateSpiPins(NRF24_bus);
validateSpiPins(SDCARD_bus);
Expand All @@ -199,6 +230,12 @@ void BruceConfigPins::validateConfig() {
validateUARTPins(gps_bus);
}

void BruceConfigPins::setLoRaPins(SPIPins value) {
LoRa_bus = value;
validateSpiPins(LoRa_bus);
saveFile();
}

void BruceConfigPins::setCC1101Pins(SPIPins value) {
CC1101_bus = value;
validateSpiPins(CC1101_bus);
Expand Down
15 changes: 15 additions & 0 deletions src/core/configPins.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ class BruceConfigPins {
const char *filepath = "/brucePins.conf";

// SPI Buses

#ifdef LORA_SCK
SPIPins LoRa_bus = {
(gpio_num_t)LORA_SCK,
(gpio_num_t)LORA_MISO,
(gpio_num_t)LORA_MOSI,
(gpio_num_t)LORA_CS,
(gpio_num_t)LORA_RST,
(gpio_num_t)LORA_DIO0
};
#else
SPIPins LoRa_bus;
#endif

#ifdef CC1101_SCK_PIN
SPIPins CC1101_bus = {
(gpio_num_t)CC1101_SCK_PIN,
Expand Down Expand Up @@ -164,6 +178,7 @@ class BruceConfigPins {
void setCC1101Pins(SPIPins value);
void setNrf24Pins(SPIPins value);
void setSDCardPins(SPIPins value);
void setLoRaPins(SPIPins value);

void setSpiPins(SPIPins value);
void setI2CPins(I2CPins value);
Expand Down
1 change: 1 addition & 0 deletions src/core/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ MainMenu::MainMenu() {
#if !defined(LITE_VERSION) && !defined(DISABLE_INTERPRETER)
&scriptsMenu,
#endif
&loraMenu,
&othersMenu,
&clockMenu,
#if !defined(LITE_VERSION)
Expand Down
3 changes: 2 additions & 1 deletion src/core/main_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
#include "menu_items/FileMenu.h"
#include "menu_items/GpsMenu.h"
#include "menu_items/IRMenu.h"
#include "menu_items/LoRaMenu.h"
#include "menu_items/NRF24.h"
#include "menu_items/OthersMenu.h"
#include "menu_items/RFIDMenu.h"
#include "menu_items/RFMenu.h"
#include "menu_items/ScriptsMenu.h"
#include "menu_items/WifiMenu.h"

class MainMenu {
public:
FileMenu fileMenu;
Expand All @@ -35,6 +35,7 @@ class MainMenu {
RFMenu rfMenu;
ScriptsMenu scriptsMenu;
WifiMenu wifiMenu;
LoRaMenu loraMenu;
#if !defined(LITE_VERSION)
EthernetMenu ethernetMenu;
#endif
Expand Down
1 change: 1 addition & 0 deletions src/core/menu_items/ConfigMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void ConfigMenu::devMenu() {
{"I2C Finder", find_i2c_addresses },
{"CC1101 Pins", [=]() { setSPIPinsMenu(bruceConfigPins.CC1101_bus); }},
{"NRF24 Pins", [=]() { setSPIPinsMenu(bruceConfigPins.NRF24_bus); } },
{"LoRa Pins", [=]() { setSPIPinsMenu(bruceConfigPins.LoRa_bus); } },
{"SDCard Pins", [=]() { setSPIPinsMenu(bruceConfigPins.SDCARD_bus); }},
//{"SYSI2C Pins", [=]() { setI2CPinsMenu(bruceConfigPins.sys_i2c); } },
{"I2C Pins", [=]() { setI2CPinsMenu(bruceConfigPins.i2c_bus); } },
Expand Down
92 changes: 92 additions & 0 deletions src/core/menu_items/LoRaMenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include "LoRaMenu.h"
#include "core/display.h"
#include "core/utils.h"
#include "modules/lora/LoRaRF.h"

void LoRaMenu::optionsMenu() {
options = {
{"Chat", []() { lorachat(); } },
{"Change username", []() { changeusername(); }},
{"Change Frequency", []() { chfreq(); } },
};
addOptionToMainMenu();
String txt = "LoRa";
loopOptions(options, MENU_TYPE_SUBMENU, txt.c_str());
}

void LoRaMenu::drawIconImg() { drawIcon(1.0); }

void LoRaMenu::drawIcon(float scale) {
clearIconArea();
scale *= 0.75;
int cx = iconCenterX;
int cy = iconCenterY + (scale * 8);

#define CALC_X(val) (cx + ((val - 50) * scale))
#define CALC_Y(val) (cy + ((val - 50) * scale))

int lineWidth = scale * 4.5;
if (lineWidth < 2) lineWidth = 2;
int ballRad = scale * 6;

// --- LEGS UPDATED (Y changed from 95 to 85) ---

// Left Leg
tft.drawWideLine(
CALC_X(44), CALC_Y(35), CALC_X(26), CALC_Y(85), lineWidth, bruceConfig.priColor, bruceConfig.priColor
);
// Right Leg
tft.drawWideLine(
CALC_X(56), CALC_Y(35), CALC_X(74), CALC_Y(85), lineWidth, bruceConfig.priColor, bruceConfig.priColor
);

// --- CROSS BARS (Unchanged) ---

// Top Cross Bar
tft.drawWideLine(
CALC_X(44), CALC_Y(35), CALC_X(56), CALC_Y(35), lineWidth, bruceConfig.priColor, bruceConfig.priColor
);

// Middle Cross Bar
tft.drawWideLine(
CALC_X(35), CALC_Y(65), CALC_X(65), CALC_Y(65), lineWidth, bruceConfig.priColor, bruceConfig.priColor
);

// --- X-BRACING TOP (Unchanged) ---

// X-Bracing (Top Section)
tft.drawWideLine(
CALC_X(44), CALC_Y(35), CALC_X(65), CALC_Y(65), lineWidth, bruceConfig.priColor, bruceConfig.priColor
);
tft.drawWideLine(
CALC_X(56), CALC_Y(35), CALC_X(35), CALC_Y(65), lineWidth, bruceConfig.priColor, bruceConfig.priColor
);

// --- X-BRACING BOTTOM UPDATED (Y changed from 95 to 85) ---

// X-Bracing (Bottom Section)
tft.drawWideLine(
CALC_X(35), CALC_Y(65), CALC_X(74), CALC_Y(85), lineWidth, bruceConfig.priColor, bruceConfig.priColor
);
tft.drawWideLine(
CALC_X(65), CALC_Y(65), CALC_X(26), CALC_Y(85), lineWidth, bruceConfig.priColor, bruceConfig.priColor
);

// --- REST IS UNCHANGED ---

// ball
int ballY = CALC_Y(25);
tft.fillCircle(cx, ballY, ballRad, bruceConfig.priColor);

// waves
int r1 = scale * 20;
int r2 = scale * 32;

// Right Side (90 degrees +/-)
tft.drawArc(cx, ballY, r1 + lineWidth, r1, 60, 120, bruceConfig.priColor, bruceConfig.bgColor);
tft.drawArc(cx, ballY, r2 + lineWidth, r2, 60, 120, bruceConfig.priColor, bruceConfig.bgColor);

// Left Side (270 degrees +/-)
tft.drawArc(cx, ballY, r1 + lineWidth, r1, 240, 300, bruceConfig.priColor, bruceConfig.bgColor);
tft.drawArc(cx, ballY, r2 + lineWidth, r2, 240, 300, bruceConfig.priColor, bruceConfig.bgColor);
}
24 changes: 24 additions & 0 deletions src/core/menu_items/LoRaMenu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef __LORA_MENU_H__
#define __LORA_MENU_H__

#include <MenuItemInterface.h>

void lorachat();
void changeusername();
void chfreq();

class LoRaMenu : public MenuItemInterface {
private:
void configMenu(void);

public:
LoRaMenu() : MenuItemInterface("LoRa") {}

void optionsMenu(void);
void drawIcon(float scale);
void drawIconImg();
bool getTheme() { return bruceConfig.theme.lora; }
};

#endif

3 changes: 2 additions & 1 deletion src/core/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ bool BruceTheme::openThemeFile(FS *fs, String filepath, bool overwriteConfigSett
{"connect", &theme.connect, theme.paths.connect },
{"config", &theme.config, theme.paths.config },
{"boot_img", &theme.boot_img, theme.paths.boot_img },
{"boot_sound", &theme.boot_sound, theme.paths.boot_sound }
{"boot_sound", &theme.boot_sound, theme.paths.boot_sound },
{"lora", &theme.lora, theme.paths.lora }
};

JsonObject _th = jsonDoc.as<JsonObject>();
Expand Down
Loading