Skip to content

Commit

Permalink
Merge pull request #38 from eurofurence/huemesh
Browse files Browse the repository at this point in the history
Huemesh
  • Loading branch information
TokenRat authored Sep 19, 2024
2 parents 5ba5db0 + f078411 commit ba179a2
Show file tree
Hide file tree
Showing 11 changed files with 499 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# EF28 Cyber LED Badge

## TBD

* Add beta game mode R. By pressing the nose you transmit your color to nearby badges. The more nose-boop, the more you 'spread' you color.

## v2024.09.07

* Initial release
2 changes: 2 additions & 0 deletions include/FSMGlobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ typedef struct {
uint8_t animHeartbeatHue = 0; //!< AnimateHeartbeat: Hue selector
uint8_t animHeartbeatSpeed = 1; //!< AnimateHeartbeat: Speed selector
uint8_t animMatrixIdx = 0; //!< AnimateMatrix: Color selector

uint8_t huemeshOwnHue = 0; //!< GameHuemesh: Own hue smelector

} FSMGlobals;

Expand Down
41 changes: 41 additions & 0 deletions include/FSMState.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,47 @@ struct OTAUpdate : public FSMState {
virtual std::unique_ptr<FSMState> touchEventFingerprintShortpress() override;
};

/**
* @brief HuemeshGame
*/
struct GameHuemesh : public FSMState {
uint32_t tick = 0;

virtual const char* getName() override;
virtual bool shouldBeRemembered() override;

virtual void entry() override;
virtual void run() override;
virtual void exit() override;

virtual std::unique_ptr<FSMState> touchEventFingerprintShortpress() override;
virtual std::unique_ptr<FSMState> touchEventFingerprintLongpress() override;
virtual std::unique_ptr<FSMState> touchEventFingerprintRelease() override;
virtual std::unique_ptr<FSMState> touchEventNoseShortpress() override;
virtual std::unique_ptr<FSMState> touchEventNoseLongpress() override;
virtual std::unique_ptr<FSMState> touchEventNoseRelease() override;
virtual std::unique_ptr<FSMState> touchEventAllLongpress() override;
};


/**
* @brief Displays matrix animation
*/
struct VUMeter : public FSMState {
uint32_t tick = 0;

virtual const char* getName() override;
virtual bool shouldBeRemembered() override;

virtual void entry() override;
virtual void run() override;

virtual std::unique_ptr<FSMState> touchEventFingerprintLongpress() override;
virtual std::unique_ptr<FSMState> touchEventFingerprintShortpress() override;
virtual std::unique_ptr<FSMState> touchEventFingerprintRelease() override;
virtual std::unique_ptr<FSMState> touchEventAllLongpress() override;
};

/**
* @brief Menu entry point
*/
Expand Down
1 change: 1 addition & 0 deletions include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@

const char* toString(EFBoardPowerState state);
const char* toString(EFTouchZone zone);
const float wave_function(float x, float start, float end, float amplitude);

#endif /* UTIL_H_ */
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ board_build.f_flash = 80000000L
framework = arduino
lib_deps =
fastled/FastLED@^3.7.4
painlessMesh
build_unflags =
-std=gnu++11
-std=gnu++14
Expand Down
12 changes: 9 additions & 3 deletions src/FSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ void FSM::resume() {
case 2: this->transition(std::make_unique<AnimateMatrix>()); break;
case 3: this->transition(std::make_unique<AnimateSnake>()); break;
case 4: this->transition(std::make_unique<AnimateHeartbeat>()); break;
case 6: this->transition(std::make_unique<GameHuemesh>()); break;
case 7: this->transition(std::make_unique<VUMeter>()); break;
default:
LOGF_WARNING("(FSM) Failed to resume to unknown state: %d\r\n", this->globals->resumeStateIdx);
this->transition(std::make_unique<DisplayPrideFlag>());
Expand Down Expand Up @@ -242,6 +244,8 @@ void FSM::persistGlobals() {
LOGF_DEBUG("(FSM) -> animMatrixIdx = %d\r\n", this->globals->animMatrixIdx);
pref.putUInt("ledBrightPcent", this->globals->ledBrightnessPercent);
LOGF_DEBUG("(FSM) -> ledBrightPcent = %d\r\n", this->globals->ledBrightnessPercent);
pref.putUInt("huemeshOwnHue", this->globals->huemeshOwnHue);
LOGF_DEBUG("(FSM) -> huemeshOwnHue = %d\r\n", this->globals->huemeshOwnHue);
pref.end();
}

Expand All @@ -262,11 +266,13 @@ void FSM::restoreGlobals() {
LOGF_DEBUG("(FSM) -> animSnakeHueIdx = %d\r\n", this->globals->animSnakeHueIdx);
this->globals->animHeartbeatHue = pref.getUInt("animHbHue", 0);
LOGF_DEBUG("(FSM) -> animHbHue = %d\r\n", this->globals->animHeartbeatHue);
this->globals->animHeartbeatSpeed= pref.getUInt("animHbSpeed", 1);
this->globals->animHeartbeatSpeed = pref.getUInt("animHbSpeed", 1);
LOGF_DEBUG("(FSM) -> animHbSpeed = %d\r\n", this->globals->animHeartbeatSpeed);
this->globals->animMatrixIdx= pref.getUInt("animMatrixIdx", 0);
this->globals->animMatrixIdx = pref.getUInt("animMatrixIdx", 0);
LOGF_DEBUG("(FSM) -> animMatrixIdx = %d\r\n", this->globals->animMatrixIdx);
this->globals->ledBrightnessPercent= pref.getUInt("ledBrightPcent", 40);
this->globals->ledBrightnessPercent = pref.getUInt("ledBrightPcent", 40);
LOGF_DEBUG("(FSM) -> ledBrightPcent = %d\r\n", this->globals->ledBrightnessPercent);
this->globals->huemeshOwnHue = pref.getUInt("huemeshOwnHue", 0);
LOGF_DEBUG("(FSM) -> huemeshOwnHue = %d\r\n", this->globals->huemeshOwnHue);
pref.end();
}
13 changes: 2 additions & 11 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,6 @@ void batteryCheck() {
}
}

/**
* @brief Calculates a wave animation. Used by bootupAnimation()
*/
float wave_function(float x, float start, float end, float amplitude) {
if (x < start || x > end) {
return 0;
}
double normalized_x = (x - start) / (end - start) * M_PI;
return amplitude * std::sin(normalized_x);
}

/**
* @brief Displays a fancy bootup animation
*/
Expand Down Expand Up @@ -268,6 +257,7 @@ void setup() {

// Get FSM going
fsm.resume();

}

/**
Expand Down Expand Up @@ -345,4 +335,5 @@ void loop() {
batteryCheck();
task_battery = millis() + INTERVAL_BATTERY_CHECK;
}

}
Loading

0 comments on commit ba179a2

Please sign in to comment.