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

Tweak a bunch of values #24

Merged
merged 1 commit into from
Sep 6, 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
1 change: 1 addition & 0 deletions include/FSMGlobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
typedef struct {
uint8_t resumeStateIdx = 0; //!< Index of the state that should be resumed upon reboot
uint8_t menuMainPointerIdx = 0; //!< MenuMain: Index of the menu cursor

uint8_t prideFlagModeIdx = 1; //!< DisplayPrideFlag: Mode selector
uint8_t animRainbowIdx = 0; //!< AnimateRainbow: Mode selector
uint8_t animSnakeIdx = 0; //!< AnimateSnake: Mode selector
Expand Down
2 changes: 1 addition & 1 deletion include/FSMState.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ struct AnimateSnake : public FSMState {
};

/**
* @brief Displays pusling color
* @brief Displays pulsing color
*/
struct AnimateHeartbeat : public FSMState {
uint32_t tick = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/EFLed/EFLed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void EFLedClass::init() {
this->init(EFLED_MAX_BRIGHTNESS_DEFAULT);
}

void EFLedClass::init(const uint8_t max_brightness) {
void EFLedClass::init(const uint8_t absolute_max_brightness) {
for (uint8_t i = 0; i < EFLED_TOTAL_NUM; i++) {
this->led_data[i] = CRGB::Black;
}
Expand All @@ -71,7 +71,7 @@ void EFLedClass::init(const uint8_t max_brightness) {
FastLED.addLeds<WS2812B, EFLED_PIN_LED_DATA, GRB>(this->led_data, EFLED_TOTAL_NUM);
LOGF_DEBUG("(EFLed) Added new WS2812B: %d LEDs @ PIN %d\r\n", EFLED_TOTAL_NUM, EFLED_PIN_LED_DATA);

this->max_brightness = max_brightness;
this->max_brightness = absolute_max_brightness;
FastLED.setBrightness(this->max_brightness);
LOGF_DEBUG("(EFLed) Set max_brightness=%d\r\n", this->max_brightness)

Expand Down
4 changes: 2 additions & 2 deletions lib/EFLed/EFLed.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ class EFLedClass {
* @brief Initializes this EFLed instance. Creates internal data structures,
* resets FastLED library and initializes power circuit.
*
* @param max_brightness Maximum raw brightness (0-255) the LEDs will
* @param absolute_max_brightness Maximum raw brightness (0-255) the LEDs will
* be allowed to be set to.
*/
void init(const uint8_t max_brightness);
void init(const uint8_t absolute_max_brightness);

/**
* @brief Enables the +5V power domain
Expand Down
4 changes: 2 additions & 2 deletions lib/EFTouch/EFTouch.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#define EFTOUCH_PIN_TOUCH_NOSE 1

#define EFTOUCH_CALIBRATE_NUM_SAMPLES 10
#define EFTOUCH_SHORTPRESS_DURATION_MS 500
#define EFTOUCH_LONGPRESS_DURATION_MS 2000
#define EFTOUCH_SHORTPRESS_DURATION_MS 450
#define EFTOUCH_LONGPRESS_DURATION_MS 1800

/**
* @brief Driver for touch sensors
Expand Down
27 changes: 14 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <EFBoard.h>
#include <EFLogging.h>
#include <EFLed.h>
#include <EFPrideFlags.h>
#include <EFTouch.h>

#include "FSM.h"
Expand All @@ -41,6 +40,8 @@

// Global objects and states
constexpr unsigned int INTERVAL_BATTERY_CHECK = 60000;
// Initalizing the board with a brightness above 49 can cause stability issues!
constexpr uint8_t ABSOLUTE_MAX_BRIGHTNESS = 45;
FSM fsm(10);
EFBoardPowerState pwrstate;

Expand Down Expand Up @@ -115,7 +116,7 @@ void _softBrownOutHandler() {
EFBoard.disableWifi();
EFLed.clear();
EFLed.enablePower();
EFLed.setBrightnessPercent(50);
EFLed.setBrightnessPercent(40);

// Soft brown out can only be cleared by board reset but can escalate to hard brown out
while (1) {
Expand Down Expand Up @@ -166,18 +167,18 @@ void bootupAnimation() {
delay(100);

// Origin point. Power-Button is 11, 25. Make it originate from where the hand is
constexpr int16_t pwrX = -20;
constexpr int16_t pwrY = 26;
constexpr int16_t pwrX = -30;
constexpr int16_t pwrY = 16;
uint8_t hue = 120; // Green

for (uint16_t n = 0; n < 30; n++) {
uint16_t n_scaled = n * 8;
uint16_t n_scaled = n * 7;
for (uint8_t i = 0; i < EFLED_TOTAL_NUM; i++) {
int16_t dx = EFLedClass::getLEDPosition(i).x - pwrX;
int16_t dy = EFLedClass::getLEDPosition(i).y - pwrY;
float distance = sqrt(dx * dx + dy * dy);

float intensity = wave_function(distance, n_scaled / 2 - 60, n_scaled * 2 + 20, 1.0);
float intensity = wave_function(distance, n_scaled / 2 - 30, n_scaled * 2 + 20, 1.0);
intensity = intensity * intensity; // sharpen wave

// energy front
Expand All @@ -188,23 +189,23 @@ void bootupAnimation() {
delay(15);
}
EFLed.clear();
delay(200);
delay(400);

// dragon awakens ;-)
EFLed.setDragonEye(CRGB(10,0, 0));
delay(50);
delay(60);
EFLed.setDragonEye(CRGB(50,0, 0));
delay(80);
EFLed.setDragonEye(CRGB(100,0, 0));
delay(150);
EFLed.setDragonEye(CRGB(200,0, 0));
delay(600);
delay(700);
EFLed.setDragonEye(CRGB(100,0, 0));
delay(100);
delay(80);
EFLed.setDragonEye(CRGB(50,0, 0));
delay(100);
EFLed.setDragonEye(CRGB(10,0, 0));
delay(80);
EFLed.setDragonEye(CRGB(10,0, 0));
delay(60);
EFLed.setDragonNose(CRGB::Black);
delay(200);
}
Expand All @@ -215,7 +216,7 @@ void bootupAnimation() {
void setup() {
// Init board
EFBoard.setup();
EFLed.init(30);
EFLed.init(ABSOLUTE_MAX_BRIGHTNESS);
bootupAnimation();

// Touchy stuff
Expand Down
2 changes: 1 addition & 1 deletion src/states/AnimateHeartbeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool AnimateHeartbeat::shouldBeRemembered() {
}

const unsigned int AnimateHeartbeat::getTickRateMs() {
return 70;
return 60;
}

void AnimateHeartbeat::entry() {
Expand Down
Loading