feat : add esp32 s3 wroom 1 with rgb led

This commit is contained in:
Julio 2023-11-09 22:11:42 +01:00 committed by Julio MATARRANZ
parent af0781699d
commit 3ebba3e47a
7 changed files with 187 additions and 3 deletions

View File

@ -10,8 +10,37 @@
[platformio] [platformio]
globallib_dir = lib 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] [env:NerminerV2]

View File

@ -21,6 +21,8 @@
#include "esp32CAM.h" #include "esp32CAM.h"
#elif defined(M5_STAMP_S3) #elif defined(M5_STAMP_S3)
#include "m5StampS3.h" #include "m5StampS3.h"
#elif defined(DEVKITV1RGB)
#include "esp32DevKitRGB.h"
#else #else
#error "No device defined" #error "No device defined"

View File

@ -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

View File

@ -4,6 +4,10 @@
DisplayDriver *currentDisplayDriver = &noDisplayDriver; DisplayDriver *currentDisplayDriver = &noDisplayDriver;
#endif #endif
#ifdef LED_DISPLAY
DisplayDriver *currentDisplayDriver = &ledDisplayDriver;
#endif
#ifdef T_DISPLAY #ifdef T_DISPLAY
DisplayDriver *currentDisplayDriver = &tDisplayDriver; DisplayDriver *currentDisplayDriver = &tDisplayDriver;
#endif #endif

View File

@ -29,6 +29,7 @@ typedef struct
extern DisplayDriver *currentDisplayDriver; extern DisplayDriver *currentDisplayDriver;
extern DisplayDriver noDisplayDriver; extern DisplayDriver noDisplayDriver;
extern DisplayDriver ledDisplayDriver;
extern DisplayDriver tDisplayDriver; extern DisplayDriver tDisplayDriver;
extern DisplayDriver amoledDisplayDriver; extern DisplayDriver amoledDisplayDriver;
extern DisplayDriver dongleDisplayDriver; extern DisplayDriver dongleDisplayDriver;

View File

@ -0,0 +1,138 @@
#include "displayDriver.h"
#ifdef LED_DISPLAY
#include <Arduino.h>
#include "monitor.h"
#include "wManager.h"
#ifdef USE_LED
#include <FastLED.h>
#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<WS2812B, RGB_LED_PIN, BGR>(&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

View File

@ -29,7 +29,7 @@
#include <SD.h> #include <SD.h>
#include "..\lib\TFT_eSPI\User_Setup_Select.h" #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) #if !defined(SDSPI_CLK) && defined(TFT_CLK)
#define SDSPI_CLK TFT_CLK #define SDSPI_CLK TFT_CLK
#endif // SDSPI_CLK #endif // SDSPI_CLK
@ -41,7 +41,7 @@
#endif // SDSPI_MISO #endif // SDSPI_MISO
#elif !defined(SDSPI_CLK) || !defined(SDSPI_MOSI) || !defined(SDSPI_MISO) #elif !defined(SDSPI_CLK) || !defined(SDSPI_MOSI) || !defined(SDSPI_MISO)
#error: Please define SDSPI pins! #error: Please define SDSPI pins!
#endif // NO_DISPLAY #endif // NO_DISPLAY or LED_DISPLAY
#warning SD card support in SPI mode enabled! #warning SD card support in SPI mode enabled!
#endif #endif