Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB Mass Storage #891

Merged
merged 6 commits into from
Mar 8, 2025
Merged
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
6 changes: 3 additions & 3 deletions boards/pinouts/_New-Device-Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ static const uint8_t ADC2 = 8;
#define BAD_RX GROVE_SCL

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

#define IR_TX_PINS '{{"M5 IR Mod", GROVE_SDA}, {"Pin 1", 1}, {"Pin 2", 2}}'
#define IR_RX_PINS '{{"M5 IR Mod", GROVE_SCL}, {"Pin 1", 1}, {"Pin 2", 2}}'
#define LED -1
#define LED -1
#define LED_ON HIGH
#define LED_OFF LOW

Expand All @@ -85,7 +85,7 @@ static const uint8_t ADC2 = 8;
#define CC1101_MISO_PIN SPI_MISO_PIN

#define NRF24_CE_PIN 6
#define NRF24_SS_PIN 7
#define NRF24_SS_PIN 7
#define NRF24_MOSI_PIN SPI_MOSI_PIN
#define NRF24_SCK_PIN SPI_SCK_PIN
#define NRF24_MISO_PIN SPI_MISO_PIN
Expand Down
8 changes: 4 additions & 4 deletions boards/pinouts/lilygo-t-display-s3.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static const uint8_t SCL = GROVE_SCL;
#define TFT_WIDTH 170
#define TFT_HEIGHT 320
#define TFT_BL 38
#define TFT_CS 6
#define TFT_CS 6
#define TFT_DC 7
#define TFT_RST 5
#define TFT_D0 39
Expand Down Expand Up @@ -76,11 +76,11 @@ static const uint8_t SCL = GROVE_SCL;
#define PIN_DATA 42

// Buttons & Navigation
#define BTN_ALIAS '"OK"'
#define BTN_ALIAS "\"OK\""
#define HAS_3_BUTTONS
#define SEL_BTN 16
#define UP_BTN 0
#define DW_BTN 14
#define DW_BTN 14
#define BK_BTN 3
#define BTN_ACT LOW

Expand All @@ -90,7 +90,7 @@ static const uint8_t SCL = GROVE_SCL;
#define LED_ON HIGH
#define LED_OFF LOW

// BadUSB
// BadUSB
#define USB_as_HID 1

#endif /* Pins_Arduino_h */
20 changes: 10 additions & 10 deletions boards/pinouts/lilygo-t-embed-cc1101.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ static const uint8_t SCL = GROVE_SCL;
#define TFT_INVERSION_ON
#define TFT_WIDTH 170
#define TFT_HEIGHT 320
#define TFT_BL 21
#define TFT_MISO SPI_MISO_PIN
#define TFT_BL 21
#define TFT_MISO SPI_MISO_PIN
#define TFT_MOSI SPI_MOSI_PIN
#define TFT_SCLK SPI_SCK_PIN
#define TFT_CS 41
#define TFT_CS 41
#define TFT_DC 16
#define TFT_RST 40
#define SPI_FREQUENCY 80000000
Expand Down Expand Up @@ -67,7 +67,7 @@ static const uint8_t SCL = GROVE_SCL;

// CC1101
#define USE_CC1101_VIA_SPI
#define CC1101_GDO0_PIN 3
#define CC1101_GDO0_PIN 3
#define CC1101_GDO2_PIN 38
#define CC1101_SW1_PIN 47
#define CC1101_SW0_PIN 48
Expand All @@ -92,7 +92,7 @@ static const uint8_t SCL = GROVE_SCL;
#define MCLK PIN_CLK

// Serial
#define SERIAL_TX 43
#define SERIAL_TX 43
#define SERIAL_RX 44
static const uint8_t TX = SERIAL_TX;
static const uint8_t RX = SERIAL_RX;
Expand All @@ -111,20 +111,20 @@ static const uint8_t RX = SERIAL_RX;
#define ENCODER_INB 5
#define ENCODER_KEY 0
#define HAS_BTN 1
#define BTN_ALIAS '"Mid"'
#define BTN_ALIAS "\"Mid\""
#define SEL_BTN ENCODER_KEY
#define UP_BTN -1
#define DW_BTN -1
#define BK_BTN 6
#define BTN_ACT LOW

// IR
#define LED 2
#define RXLED 1
#define LED 2
#define RXLED 1
#define LED_ON HIGH
#define LED_OFF LOW

// RFID
// RFID

#define RFID125_RX_PIN SERIAL_RX
#define RFID125_TX_PIN SERIAL_TX
Expand All @@ -137,7 +137,7 @@ static const uint8_t RX = SERIAL_RX;
#define LED_TYPE_IS_RGBW 0
#define LED_COUNT 8

// BadUSB
// BadUSB
#define USB_as_HID 1

#endif /* Pins_Arduino_h */
8 changes: 4 additions & 4 deletions boards/pinouts/lilygo-t-embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ static const uint8_t SCL = GROVE_SCL;
#define TFT_WIDTH 170
#define TFT_HEIGHT 320
#define TFT_BL 15
#define TFT_MISO -1
#define TFT_MISO -1
#define TFT_MOSI 11
#define TFT_SCLK 12
#define TFT_CS 10
#define TFT_CS 10
#define TFT_DC 13
#define TFT_RST 9
#define TOUCH_CS -1
Expand Down Expand Up @@ -100,7 +100,7 @@ static const uint8_t SCL = GROVE_SCL;
#define ENCODER_INB 1
#define ENCODER_KEY 0
#define HAS_BTN 1
#define BTN_ALIAS '"Mid"'
#define BTN_ALIAS "\"Mid\""
#define SEL_BTN ENCODER_KEY
#define UP_BTN 1
#define DW_BTN 1
Expand All @@ -127,7 +127,7 @@ static const uint8_t SCL = GROVE_SCL;
#define LED_TYPE_IS_RGBW 0
#define LED_COUNT 8

// BadUSB
// BadUSB
#define USB_as_HID 1

#endif /* Pins_Arduino_h */
4 changes: 2 additions & 2 deletions boards/pinouts/m5stack-cores3.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static const uint8_t G46 = 46;

static const uint8_t ADC = 10;

#define HAS_RTC
#define HAS_RTC
#define USB_as_HID

#define HAS_TOUCH
Expand Down Expand Up @@ -102,7 +102,7 @@ static const uint8_t ADC = 10;
#define SPI_TOUCH_FREQUENCY 2500000


#define BTN_ALIAS '"Ok"'
#define BTN_ALIAS "\"Ok\""
#define BTN_PIN -1
#define BTN_ACT LOW

Expand Down
10 changes: 5 additions & 5 deletions boards/pinouts/smoochiee-board.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,31 @@ static const uint8_t ADC2 = 8;
#define BAD_TX SERIAL_TX
#define USB_as_HID 1

#define BTN_ALIAS '"OK"'
#define BTN_ALIAS "\"OK\""
#define HAS_5_BUTTONS
#define SEL_BTN 0
#define UP_BTN 40
#define DW_BTN 41
#define DW_BTN 41
#define R_BTN 38
#define L_BTN 39
#define BTN_ACT LOW

#define RXLED 4
#define LED 5
#define LED_ON HIGH
#define LED_OFF LOW

#define USE_CC1101_VIA_SPI
#define CC1101_GDO0_PIN 9
#define CC1101_GDO2_PIN 10
#define CC1101_GDO2_PIN 10
#define CC1101_SS_PIN 46
#define CC1101_MOSI_PIN SPI_MOSI_PIN
#define CC1101_SCK_PIN SPI_SCK_PIN
#define CC1101_MISO_PIN SPI_MISO_PIN

#define USE_NRF24_VIA_SPI
#define NRF24_CE_PIN 21
#define NRF24_SS_PIN 14
#define NRF24_SS_PIN 14
#define NRF24_MOSI_PIN SPI_MOSI_PIN
#define NRF24_SCK_PIN SPI_SCK_PIN
#define NRF24_MISO_PIN SPI_MISO_PIN
Expand Down
2 changes: 1 addition & 1 deletion lib/utility/bq27220.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
#include <Arduino.h>
#include <Wire.h>

typedef enum OP_STATUS{
enum OP_STATUS{
SEALED = 0b11,
UNSEALED = 0b10,
FULL = 0b01,
Expand Down
5 changes: 4 additions & 1 deletion src/core/connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ void onDataSent(const uint8_t* mac_addr, esp_now_send_status_t status) {

void onDataRecv(const uint8_t* mac, const uint8_t* incomingData, int len) {
DeviceConnection::FileMessage recvFileMessage;
memcpy(&recvFileMessage, incomingData, sizeof(recvFileMessage));

// Use reinterpret_cast and copy assignment
const DeviceConnection::FileMessage* incomingMessage = reinterpret_cast<const DeviceConnection::FileMessage*>(incomingData);
recvFileMessage = *incomingMessage; // Use copy assignment

if (recvFileMessage.ping) return sendPong(mac);
if (recvFileMessage.pong) return appendPeerToList(mac);
Expand Down
16 changes: 10 additions & 6 deletions src/core/connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@ class DeviceConnection {
ABORTED,
};

typedef struct {
struct FileMessage {
String filename;
String filepath;
size_t totalBytes;
size_t bytesSent;
char data[PAGE_BYTES];
size_t dataSize = 0;
bool done = false;
bool ping = false;
bool pong = false;
} FileMessage;
size_t dataSize;
bool done;
bool ping;
bool pong;

// Constructor to initialize defaults
FileMessage()
: totalBytes(0), bytesSent(0), dataSize(0), done(false), ping(false), pong(false) {}
};

/////////////////////////////////////////////////////////////////////////////////////
// Constructor
Expand Down
2 changes: 1 addition & 1 deletion src/core/led_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void setLedColorConfig() {


void setLedBrightnessConfig() {
int idx;
int idx = 0;
if (bruceConfig.ledBright==10) idx=0;
else if (bruceConfig.ledBright==25) idx=1;
else if (bruceConfig.ledBright==50) idx=2;
Expand Down
Loading