-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : add esp32 s3 wroom 1 with rgb led
- Loading branch information
Julio
authored and
Julio MATARRANZ
committed
Nov 29, 2023
1 parent
af07816
commit 3ebba3e
Showing
7 changed files
with
187 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters