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

CC1101 for Cardputer, BLE Spam and fixes #194

Merged
merged 7 commits into from
Aug 19, 2024
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
2 changes: 1 addition & 1 deletion custom_4Mb_full.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x6000,
app0, app, ota_0, 0x10000, 0x2F0000,
spiffs, data, spiffs, 0x300000,0x400000,
spiffs, data, spiffs, 0x300000,0x100000,
19 changes: 11 additions & 8 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ build_flags =
-DLH=8
-DLW=6
-DCONFIG_FILE='"/config.conf"'
-w

lib_deps =
WireGuard-ESP32
IRremoteESP8266
Expand All @@ -49,7 +51,8 @@ lib_deps =
TinyGPSPlus
tinyu-zhao/FFT@^0.0.1
;lsatan/SmartRC-CC1101-Driver-Lib@^2.5.7
https://github.com/bmorcelli/SmartRC-CC1101-Driver-Lib
SmartRC-CC1101-Driver-Lib=https://github.com/bmorcelli/SmartRC-CC1101-Driver-Lib/archive/refs/heads/Bruce.zip
h2zero/NimBLE-Arduino@^1.4.0

[env:m5stack-cplus2]
platform = espressif32
Expand All @@ -62,9 +65,9 @@ board_upload.maximum_size = 8388608
build_flags =
${common.build_flags}
-DCORE_DEBUG_LEVEL=5
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
-mfix-esp32-psram-cache-strategy=memw
;-DBOARD_HAS_PSRAM
;-mfix-esp32-psram-cache-issue
;-mfix-esp32-psram-cache-strategy=memw

-DSTICK_C_PLUS2=1

Expand Down Expand Up @@ -318,7 +321,7 @@ build_flags =
-DRF_TX_PINS='{ {"M5 RF433T", GROVE_SDA}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}'
-DRF_RX_PINS='{ {"M5 RF433R", GROVE_SCL}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}'
; connection pins using microSD sniffer module https://www.sparkfun.com/products/9419 https://docs.m5stack.com/en/core/Cardputer
;-DUSE_CC1101_VIA_SPI
-DUSE_CC1101_VIA_SPI
-DCC1101_GDO0_PIN=GROVE_SDA
-DCC1101_SS_PIN=GROVE_SCL ; chip select
-DCC1101_MOSI_PIN=14
Expand Down Expand Up @@ -382,7 +385,7 @@ build_flags =
-DCORE_DEBUG_LEVEL=5

-DM5STACK=1 ;key for new device,
;mykeyboard.cpp: need map buttons an/or touchscreen,
-DCORE=1 ;mykeyboard.cpp: need map buttons an/or touchscreen,
;display.cpp: need map battery status value,
;settings.cpp: need map brighness control
;main.cpp: need set startup
Expand Down Expand Up @@ -499,7 +502,7 @@ build_flags =
-DCORE_DEBUG_LEVEL=5

-DM5STACK=1 ;key for new device,
;mykeyboard.cpp: need map buttons an/or touchscreen,
-DCORE=1 ;mykeyboard.cpp: need map buttons an/or touchscreen,
;display.cpp: need map battery status value,
;settings.cpp: need map brighness control
;main.cpp: need set startup
Expand Down Expand Up @@ -613,7 +616,7 @@ build_flags =
-DCORE_DEBUG_LEVEL=5

-DM5STACK=1 ;key for new device,
;mykeyboard.cpp: need map buttons an/or touchscreen,
-DCORE=1 ;mykeyboard.cpp: need map buttons an/or touchscreen,
;display.cpp: need map battery status value,
;settings.cpp: need map brighness control
;main.cpp: need set startup
Expand Down
8 changes: 0 additions & 8 deletions src/core/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ void setTftDisplay(int x, int y, uint16_t fc, int size, uint16_t bg) {
tft.setTextColor(fc,bg);
}

/***************************************************************************************
** Function name: BootScreen
** Description: Start Display functions and display bootscreen
***************************************************************************************/
void initDisplay(int i) {
tft.drawXBitmap(1,1,bits, bits_width, bits_height,TFT_BLACK,FGCOLOR+i);
}

/***************************************************************************************
** Function name: displayRedStripe
** Description: Display Red Stripe with information
Expand Down
4 changes: 2 additions & 2 deletions src/core/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

#define PADX 10

void initDisplay(int i = 0); // Início da função e mostra bootscreen

//Funções para economizar linhas nas outras funções
void resetTftDisplay(int x = 0, int y = 0, uint16_t fc = FGCOLOR, int size = FM, uint16_t bg = BGCOLOR, uint16_t screen = BGCOLOR);
void setTftDisplay(int x = 0, int y = 0, uint16_t fc = tft.textcolor, int size = tft.textsize, uint16_t bg = tft.textbgcolor);
Expand Down Expand Up @@ -94,6 +92,7 @@ void TouchFooter(uint16_t color = FGCOLOR);

void MegaFooter(uint16_t color = FGCOLOR);

#if !defined(LITE_VERSION)
#define bruce_small_width 60
#define bruce_small_height 34
PROGMEM const unsigned char bruce_small_bits[] = {
Expand Down Expand Up @@ -461,3 +460,4 @@ PROGMEM const unsigned char bits[] = {


#endif
#endif
4 changes: 2 additions & 2 deletions src/core/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern char16_t FGCOLOR;
#include <Arduino.h>
#include <functional>
#include <vector>
//#include <SPIFFS.h>
#include <SPI.h>
#include <LittleFS.h>
#include <NTPClient.h>
#include <Timezone.h>
Expand Down Expand Up @@ -54,7 +54,7 @@ extern char16_t FGCOLOR;
#endif

extern char timeStr[10];

extern SPIClass sdcardSPI;
extern bool clock_set;
extern time_t localTime;
extern struct tm* timeInfo;
Expand Down
8 changes: 7 additions & 1 deletion src/core/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,20 @@ void wifiOptions() {
**********************************************************************/
void bleOptions() {
options = {
#if !defined(CORE)
#if !defined(LITE_VERSION)
{"BLE Beacon", [=]() { ble_test(); }},
{"BLE Scan", [=]() { ble_scan(); }},
#endif
{"AppleJuice", [=]() { aj_adv(0); }},
{"SwiftPair", [=]() { aj_adv(1); }},
{"Samsung Spam", [=]() { aj_adv(2); }},
{"SourApple", [=]() { aj_adv(3); }},
{"Android Spam", [=]() { aj_adv(4); }},
{"BT Maelstrom", [=]() { aj_adv(5); }},
#else
{"In Development", [=]() { backToMenu(); }},
#endif
{"Main Menu", [=]() { backToMenu(); }},
};
delay(200);
Expand Down Expand Up @@ -302,7 +308,7 @@ void drawMainMenu(int index) {

tft.setTextSize(FM);
tft.fillRect(10,30+80+(HEIGHT-134)/2, WIDTH-20,LH*FM, BGCOLOR);
tft.drawCentreString(texts[index],WIDTH/2, 30+80+(HEIGHT-134)/2, SMOOTH_FONT);
tft.drawCentreString(texts[index],WIDTH/2, 30+80+(HEIGHT-134)/2, 1);
tft.setTextSize(FG);
tft.drawChar('<',10,HEIGHT/2+10);
tft.drawChar('>',WIDTH-(LW*FG+10),HEIGHT/2+10);
Expand Down
6 changes: 3 additions & 3 deletions src/core/sd_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct FilePage {
};


SPIClass sdcardSPI;
//SPIClass sdcardSPI;
String fileToCopy;
String fileList[MAXFILES][3];
FilePage filePages[100]; // Maximum of 100 pages
Expand Down Expand Up @@ -134,7 +134,7 @@ bool renameFile(FS fs, String path, String filename) {
***************************************************************************************/
bool copyToFs(FS from, FS to, String path) {
// Tamanho do buffer para leitura/escrita
const size_t bufferSize = 2048*2; // Ajuste conforme necessário para otimizar a performance
const size_t bufferSize = 1024; // Ajuste conforme necessário para otimizar a performance
uint8_t buffer[bufferSize];
bool result;

Expand Down Expand Up @@ -209,7 +209,7 @@ bool copyFile(FS fs, String path) {
***************************************************************************************/
bool pasteFile(FS fs, String path) {
// Tamanho do buffer para leitura/escrita
const size_t bufferSize = 2048*2; // Ajuste conforme necessário para otimizar a performance
const size_t bufferSize = 1024; // Ajuste conforme necessário para otimizar a performance
uint8_t buffer[bufferSize];

// Abrir o arquivo original
Expand Down
2 changes: 1 addition & 1 deletion src/core/sd_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@



extern SPIClass sdcardSPI;
//extern SPIClass sdcardSPI;

bool setupSdCard();

Expand Down
5 changes: 3 additions & 2 deletions src/core/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ void getConfigs() {

log_i("Brightness: %d", bright);
setBrightness(bright);
if(dimmerSet<10) dimmerSet=10;
if(dimmerSet<0) dimmerSet=10;
file.close();
if(count>0) saveConfigs();

Expand All @@ -762,7 +762,8 @@ void getConfigs() {
//If something changed, saves the changes on EEPROM.
if(count>0) {
if(!EEPROM.commit()) log_i("fail to write EEPROM"); // Store data to EEPROM
} else log_i("Wrote new conf to EEPROM");
else log_i("Wrote new conf to EEPROM");
}
EEPROM.end();
log_i("Using config.conf setup file");
} else {
Expand Down
31 changes: 18 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <string>
#include "esp32-hal-psram.h"


SPIClass sdcardSPI;
// Public Globals Variables
unsigned long previousMillis = millis();
int prog_handler; // 0 - Flash, 1 - LittleFS, 3 - Download
Expand Down Expand Up @@ -113,7 +115,7 @@ void setup_gpio() {
#if defined(BACKLIGHT)
pinMode(BACKLIGHT, OUTPUT);
#endif
initCC1101once(); // Sets GPIO in the CC1101 lib
initCC1101once(&sdcardSPI); // Sets GPIO in the CC1101 lib
}


Expand Down Expand Up @@ -151,6 +153,7 @@ void boot_screen() {
int i = millis();
char16_t bgcolor = BGCOLOR;
while(millis()<i+7000) { // boot image lasts for 5 secs
#if !defined(LITE_VERSION)
if((millis()-i>2000) && (millis()-i)<2200) tft.fillRect(0,45,WIDTH,HEIGHT-45,BGCOLOR);
if((millis()-i>2200) && (millis()-i)<2700) tft.drawRect(2*WIDTH/3,HEIGHT/2,2,2,FGCOLOR);
if((millis()-i>2700) && (millis()-i)<2900) tft.fillRect(0,45,WIDTH,HEIGHT-45,BGCOLOR);
Expand All @@ -163,7 +166,7 @@ void boot_screen() {
if((millis()-i>3400) && (millis()-i)<3600) tft.fillRect(0,0,WIDTH,HEIGHT,BGCOLOR);
if((millis()-i>3600)) tft.drawXBitmap((WIDTH-238)/2,(HEIGHT-133)/2,bits, bits_width, bits_height,TFT_BLACK,FGCOLOR);
#endif

#endif
if(checkAnyKeyPress()) // If any key or M5 key is pressed, it'll jump the boot screen
{
tft.fillScreen(TFT_BLACK);
Expand All @@ -172,17 +175,19 @@ void boot_screen() {
}
}

#if defined(BUZZ_PIN)
// Bip M5 just because it can. Does not bip if splashscreen is bypassed
_tone(5000, 50);
delay(200);
_tone(5000, 50);
/* 2fix: menu infinite loop */
#elif defined(HAS_NS4168_SPKR)
// play a boot sound
if(SD.exists("/boot.wav")) playAudioFile(&SD, "/boot.wav");
else if(LittleFS.exists("/boot.wav")) playAudioFile(&LittleFS, "/boot.wav");
setup_gpio(); // temp fix for menu inf. loop
#if !defined(LITE_VERSION)
#if defined(BUZZ_PIN)
// Bip M5 just because it can. Does not bip if splashscreen is bypassed
_tone(5000, 50);
delay(200);
_tone(5000, 50);
/* 2fix: menu infinite loop */
#elif defined(HAS_NS4168_SPKR)
// play a boot sound
if(SD.exists("/boot.wav")) playAudioFile(&SD, "/boot.wav");
else if(LittleFS.exists("/boot.wav")) playAudioFile(&LittleFS, "/boot.wav");
setup_gpio(); // temp fix for menu inf. loop
#endif
#endif
}

Expand Down
Loading
Loading