diff --git a/platformio.ini b/platformio.ini index 5f1280c..1332a17 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,8 +10,37 @@ [platformio] globallib_dir = lib -default_envs = NerminerV2 ; esp32cam, ESP32-2432S028R, NerminerV2, ESP32-devKitv1, NerminerV2-S3-DONGLE, NerminerV2-S3-AMOLED, NerminerV2-T-QT, NerdminerV2-T-Display_V1, ESP32-2432S028R, M5-StampS3 +default_envs = NerminerV2 ; esp32cam, ESP32-2432S028R, NerminerV2, ESP32-devKitv1, NerminerV2-S3-DONGLE, NerminerV2-S3-AMOLED, NerminerV2-T-QT, NerdminerV2-T-Display_V1, ESP32-2432S028R, M5-StampS3, ESP32-S3-devKitv1 +[env:ESP32-S3-devKitv1] +platform = espressif32 +board = esp32-s3-devkitc-1 +framework = arduino +monitor_filters = + esp32_exception_decoder + time + log2file +board_build.arduino.memory_type = qio_opi +monitor_speed = 115200 +upload_speed = 115200 +board_build.partitions = huge_app.csv +build_flags = + -D BOARD_HAS_PSRAM + -D ARDUINO_USB_MODE=1 + -D ARDUINO_USB_CDC_ON_BOOT=1 + -D DEVKITV1RGB=1 + ;-D DEBUG_MINING=1 +lib_deps = + https://github.com/takkaO/OpenFontRender + bblanchon/ArduinoJson@^6.21.2 + https://github.com/tzapu/WiFiManager.git#v2.0.16-rc.2 + mathertel/OneButton @ ^2.0.3 + arduino-libraries/NTPClient + https://github.com/FastLED/FastLED +lib_ignore = + TFT_eSPI + +;-------------------------------------------------------------------- [env:NerminerV2] diff --git a/src/drivers/devices/device.h b/src/drivers/devices/device.h index 2396ea4..27b92d8 100644 --- a/src/drivers/devices/device.h +++ b/src/drivers/devices/device.h @@ -21,6 +21,8 @@ #include "esp32CAM.h" #elif defined(M5_STAMP_S3) #include "m5StampS3.h" +#elif defined(DEVKITV1RGB) +#include "esp32DevKitRGB.h" #else #error "No device defined" diff --git a/src/drivers/devices/esp32DevKitRGB.h b/src/drivers/devices/esp32DevKitRGB.h new file mode 100644 index 0000000..b6597c9 --- /dev/null +++ b/src/drivers/devices/esp32DevKitRGB.h @@ -0,0 +1,10 @@ +#ifndef _ESP32_DEV_KIT_RGB_H +#define _ESP32_DEV_KIT_RGB_H + +#define PIN_BUTTON_1 0 +#define RGB_LED_PIN 48 + +#define LED_DISPLAY +#define USE_LED + +#endif \ No newline at end of file diff --git a/src/drivers/displays/display.cpp b/src/drivers/displays/display.cpp index aa136d4..43d2474 100644 --- a/src/drivers/displays/display.cpp +++ b/src/drivers/displays/display.cpp @@ -4,6 +4,10 @@ DisplayDriver *currentDisplayDriver = &noDisplayDriver; #endif +#ifdef LED_DISPLAY +DisplayDriver *currentDisplayDriver = &ledDisplayDriver; +#endif + #ifdef T_DISPLAY DisplayDriver *currentDisplayDriver = &tDisplayDriver; #endif diff --git a/src/drivers/displays/displayDriver.h b/src/drivers/displays/displayDriver.h index efa58f4..c316939 100644 --- a/src/drivers/displays/displayDriver.h +++ b/src/drivers/displays/displayDriver.h @@ -29,6 +29,7 @@ typedef struct extern DisplayDriver *currentDisplayDriver; extern DisplayDriver noDisplayDriver; +extern DisplayDriver ledDisplayDriver; extern DisplayDriver tDisplayDriver; extern DisplayDriver amoledDisplayDriver; extern DisplayDriver dongleDisplayDriver; diff --git a/src/drivers/displays/ledDisplayDriver.cpp b/src/drivers/displays/ledDisplayDriver.cpp new file mode 100644 index 0000000..86dd79e --- /dev/null +++ b/src/drivers/displays/ledDisplayDriver.cpp @@ -0,0 +1,138 @@ +#include "displayDriver.h" + +#ifdef LED_DISPLAY + +#include +#include "monitor.h" +#include "wManager.h" + +#ifdef USE_LED +#include +#endif + +#ifdef USE_LED +#define MAX_BRIGHTNESS 16 +#define SLOW_FADE 1; +#define FAST_FADE 4; + +CRGB leds(0, 0, 0); +int brightness = 0; +int fadeDirection = 1; +int fadeAmount = 0; +#endif // USE_LED + +bool ledOn = false; +extern monitor_data mMonitor; + +void ledDisplay_Init(void) +{ + Serial.println("Led display driver initialized"); + #ifdef USE_LED + FastLED.addLeds(&leds, 1); + FastLED.show(); + #endif // USE_LED +} + +void ledDisplay_AlternateScreenState(void) +{ + Serial.println("Switching display state"); + ledOn = !ledOn; +} + +void ledDisplay_AlternateRotation(void) +{ +} + +void ledDisplay_NoScreen(unsigned long mElapsed) +{ + mining_data data = getMiningData(mElapsed); + + // Print hashrate to serial + Serial.printf(">>> Completed %s share(s), %s Khashes, avg. hashrate %s KH/s\n", + data.completedShares.c_str(), data.totalKHashes.c_str(), data.currentHashRate.c_str()); + + // Print extended data to serial for no display devices + Serial.printf(">>> Valid blocks: %s\n", data.valids.c_str()); + Serial.printf(">>> Block templates: %s\n", data.templates.c_str()); + Serial.printf(">>> Best difficulty: %s\n", data.bestDiff.c_str()); + Serial.printf(">>> 32Bit shares: %s\n", data.completedShares.c_str()); + Serial.printf(">>> Temperature: %s\n", data.temp.c_str()); + Serial.printf(">>> Total MHashes: %s\n", data.totalMHashes.c_str()); + Serial.printf(">>> Time mining: %s\n", data.timeMining.c_str()); +} +void ledDisplay_LoadingScreen(void) +{ + Serial.println("Initializing..."); +} + +void ledDisplay_SetupScreen(void) +{ + Serial.println("Setup..."); +} + +// Variables para controlar el parpadeo con millis() +unsigned long previousMillis = 0; + +void ledDisplay_DoLedStuff(unsigned long frame) +{ + +#ifdef USE_LED + + if (!ledOn) + { + FastLED.clear(true); + return; + } + + switch (mMonitor.NerdStatus) + { + case NM_waitingConfig: + brightness = MAX_BRIGHTNESS; + leds.setRGB(255, 255, 0); + fadeAmount = 0; + break; + + case NM_Connecting: + leds.setRGB(0, 0, 255); + fadeAmount = SLOW_FADE; + break; + + case NM_hashing: + leds.setRGB(0, 0, 255); + fadeAmount = FAST_FADE; + break; + } + + leds.fadeLightBy(0xFF - brightness); + FastLED.show(); + + brightness = brightness + (fadeDirection * fadeAmount); + if (brightness <= 0 || brightness >= MAX_BRIGHTNESS) + { + fadeDirection = -fadeDirection; + } + brightness = constrain(brightness, 0, MAX_BRIGHTNESS); +#endif +} + +void ledDisplay_AnimateCurrentScreen(unsigned long frame) +{ +} + +CyclicScreenFunction ledDisplayCyclicScreens[] = {ledDisplay_NoScreen}; + +DisplayDriver ledDisplayDriver = { + ledDisplay_Init, + ledDisplay_AlternateScreenState, + ledDisplay_AlternateRotation, + ledDisplay_LoadingScreen, + ledDisplay_SetupScreen, + ledDisplayCyclicScreens, + ledDisplay_AnimateCurrentScreen, + ledDisplay_DoLedStuff, + SCREENS_ARRAY_SIZE(ledDisplayCyclicScreens), + 0, + 0, + 0, +}; +#endif diff --git a/src/drivers/storage/SDCard.h b/src/drivers/storage/SDCard.h index 768fc07..0de28f9 100644 --- a/src/drivers/storage/SDCard.h +++ b/src/drivers/storage/SDCard.h @@ -29,7 +29,7 @@ #include #include "..\lib\TFT_eSPI\User_Setup_Select.h" - #ifndef NO_DISPLAY + #if !defined(NO_DISPLAY) && !defined(LED_DISPLAY) #if !defined(SDSPI_CLK) && defined(TFT_CLK) #define SDSPI_CLK TFT_CLK #endif // SDSPI_CLK @@ -41,7 +41,7 @@ #endif // SDSPI_MISO #elif !defined(SDSPI_CLK) || !defined(SDSPI_MOSI) || !defined(SDSPI_MISO) #error: Please define SDSPI pins! - #endif // NO_DISPLAY + #endif // NO_DISPLAY or LED_DISPLAY #warning SD card support in SPI mode enabled! #endif