Skip to content

Commit

Permalink
Fix PLED_TYPE overriding LEDOptions.pledType (#253)
Browse files Browse the repository at this point in the history
Fix PLED_TYPE overriding LEDOptions.pledTYpe
  • Loading branch information
FeralAI authored May 16, 2023
1 parent 67c01ee commit ff1470b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
5 changes: 4 additions & 1 deletion headers/addons/pleds.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "BoardConfig.h"
#include <stdint.h>
#include "AnimationStation.hpp"
#include "storagemanager.h"
#include "PlayerLEDs.h"
#include "gpaddon.h"
#include "helper.h"
Expand Down Expand Up @@ -36,7 +37,9 @@ class PlayerLEDAddon : public GPAddon
virtual void preprocess() {}
virtual void process();
virtual std::string name() { return PLEDName; }
PlayerLEDAddon() : type(PLED_TYPE) {}
PlayerLEDAddon() {
type = static_cast<PLEDType>(Storage::getInstance().getLEDOptions().pledType);
}
PlayerLEDAddon(PLEDType type) : type(type) {}

protected:
Expand Down
10 changes: 5 additions & 5 deletions src/addons/neopicoleds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void NeoPicoLEDAddon::setup()
Storage::getInstance().setDefaultLEDOptions();
}

if ( PLED_TYPE == PLED_TYPE_RGB ) {
if ( ledOptions.pledType == PLED_TYPE_RGB ) {
neoPLEDs = new NeoPicoPlayerLEDs();
}

Expand All @@ -117,7 +117,7 @@ void NeoPicoLEDAddon::process()
Gamepad * gamepad = Storage::getInstance().GetProcessedGamepad();
uint8_t * featureData = Storage::getInstance().GetFeatureData();
AnimationHotkey action = animationHotkeys(gamepad);
if (PLED_TYPE == PLED_TYPE_RGB) {
if (ledOptions.pledType == PLED_TYPE_RGB) {
inputMode = gamepad->options.inputMode; // HACK
switch (gamepad->options.inputMode) {
case INPUT_MODE_XINPUT:
Expand Down Expand Up @@ -151,7 +151,7 @@ void NeoPicoLEDAddon::process()
as.ApplyBrightness(frame);

// Apply the player LEDs to our first 4 leds if we're in NEOPIXEL mode
if (PLED_TYPE == PLED_TYPE_RGB) {
if (ledOptions.pledType == PLED_TYPE_RGB) {
switch (inputMode) { // HACK
case INPUT_MODE_XINPUT:
auto pledPins = Storage::getInstance().getPLEDPins();
Expand Down Expand Up @@ -461,7 +461,7 @@ uint8_t NeoPicoLEDAddon::setupButtonPositions()
uint8_t buttonCount = 0;
for (auto const buttonPosition : buttonPositions)
{
if (buttonPosition.second != -1)
if (buttonPosition.second > -1)
buttonCount++;
}

Expand All @@ -475,7 +475,7 @@ void NeoPicoLEDAddon::configureLEDs()
vector<vector<Pixel>> pixels = createLEDLayout(ledOptions.ledLayout, ledOptions.ledsPerButton, buttonCount);
matrix.setup(pixels, ledOptions.ledsPerButton);
ledCount = matrix.getLedCount();
if (PLED_TYPE == PLED_TYPE_RGB && PLED_COUNT > 0)
if (ledOptions.pledType == PLED_TYPE_RGB && PLED_COUNT > 0)
ledCount += PLED_COUNT;

// Remove the old neopico (config can call this)
Expand Down
9 changes: 5 additions & 4 deletions src/addons/playerleds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ PLEDAnimationState getXInputAnimationPWM(uint8_t *data)
}

bool PlayerLEDAddon::available() {
return PLED_TYPE != PLED_TYPE_NONE;
return Storage::getInstance().getLEDOptions().pledType != PLED_TYPE_NONE;
}

void PlayerLEDAddon::setup() {

switch (PLED_TYPE)
LEDOptions ledOptions = Storage::getInstance().getLEDOptions();
switch (ledOptions.pledType)
{
case PLED_TYPE_PWM:
pwmLEDs = new PWMPlayerLEDs();
Expand All @@ -100,10 +100,11 @@ void PlayerLEDAddon::setup() {
void PlayerLEDAddon::process()
{
Gamepad * gamepad = Storage::getInstance().GetProcessedGamepad();
LEDOptions ledOptions = Storage::getInstance().getLEDOptions();

// Player LEDs can be PWM or driven by NeoPixel
uint8_t * featureData = Storage::getInstance().GetFeatureData();
if (PLED_TYPE == PLED_TYPE_PWM) { // only process the feature queue if we're on PWM
if (ledOptions.pledType == PLED_TYPE_PWM) { // only process the feature queue if we're on PWM
if (pwmLEDs != nullptr)
pwmLEDs->display();

Expand Down

0 comments on commit ff1470b

Please sign in to comment.