Haute M Ultra / Lite Case RGBs (#1300)
* Initial commit of a working Haute Lite / Ultra with translated comments. Enabling/disabling the ambient light and counts will need to be moved to the web config. * Moved AnimationStation over to our actual code base instead of a library. This allows us to use protobuf, modify the file formats a bit more, and make the code a lot more dynamic. Also removed .hpp as we do not use that naming convention in our code. * Renaming some lowercases * Lowercase the folder as well * Linux is sensitive to case while Windows doesn't care :( * More casing * More capitalizations * Moved everything out of the animationstation and playerled libraries, removed as many statics as I could find. Still a few statics in Animation:: but still cleaning. DO NOT USE: This doesn't work yet, but it is getting closer * Removed the static case rgbs in favor of ambient / linkage now that we're fully integrated into the source. This is very close to where we want to be * Added COSMOX M Ultra and M Lite configs Moved all of our ambient lighting over to boardconfig defines Updated the OpenCore0 definitions to use our new ambient lighting * Almost done, changed bytes over to our RGB define for colors, touched up a lot of different things. Chase effect is now properly working with wrap-around, cycling is all much better. Removed power-on animations as we have no real reason for them right now, we can add them back in later. * Changed hotkeys for case lights a bit * Slight code clean-ups, I'm happy with this * Last bit of clean-up before moving to review * Revert back to nothing * More code cleanups. There's a known bug with linkage that will be solved in the next branch * Deprecated some proto config settings
This commit is contained in:
2
.github/workflows/cmake.yml
vendored
2
.github/workflows/cmake.yml
vendored
@@ -39,6 +39,8 @@ jobs:
|
||||
KB2040,
|
||||
KeyboardConverter,
|
||||
Haute42COSMOX,
|
||||
Haute42COSMOXMLite,
|
||||
Haute42COSMOXMUltra,
|
||||
Liatris,
|
||||
MavercadeRev1,
|
||||
MavercadeRev2,
|
||||
|
||||
@@ -150,6 +150,7 @@ src/gamepad.cpp
|
||||
src/gamepad/GamepadState.cpp
|
||||
src/addonmanager.cpp
|
||||
src/configmanager.cpp
|
||||
src/playerleds.cpp
|
||||
src/drivers/shared/xinput_host.cpp
|
||||
src/drivers/shared/xgip_protocol.cpp
|
||||
src/drivers/astro/AstroDriver.cpp
|
||||
@@ -237,6 +238,14 @@ src/addons/tilt.cpp
|
||||
src/addons/spi_analog_ads1256.cpp
|
||||
src/addons/gamepad_usb_host.cpp
|
||||
src/addons/gamepad_usb_host_listener.cpp
|
||||
src/animationstation/animation.cpp
|
||||
src/animationstation/animationstation.cpp
|
||||
src/animationstation/effects/chase.cpp
|
||||
src/animationstation/effects/customtheme.cpp
|
||||
src/animationstation/effects/customthemepressed.cpp
|
||||
src/animationstation/effects/rainbow.cpp
|
||||
src/animationstation/effects/staticcolor.cpp
|
||||
src/animationstation/effects/statictheme.cpp
|
||||
${PROTO_OUTPUT_DIR}/enums.pb.c
|
||||
${PROTO_OUTPUT_DIR}/config.pb.c
|
||||
)
|
||||
@@ -251,17 +260,16 @@ pico_stdlib
|
||||
pico_bootsel_via_double_reset
|
||||
tinyusb_host
|
||||
tinyusb_pico_pio_usb
|
||||
AnimationStation
|
||||
CRC32
|
||||
FlashPROM
|
||||
ADS1219
|
||||
ADS1256
|
||||
PlayerLEDs
|
||||
NeoPico
|
||||
OneBitDisplay
|
||||
ArduinoJson
|
||||
rndis
|
||||
hardware_adc
|
||||
hardware_pwm
|
||||
PicoPeripherals
|
||||
WiiExtension
|
||||
SNESpad
|
||||
@@ -288,6 +296,8 @@ headers/display/ui
|
||||
headers/display/ui/static
|
||||
headers/display/ui/elements
|
||||
headers/display/ui/screens
|
||||
headers/animationstation
|
||||
headers/animationstation/effects
|
||||
configs/${GP2040_BOARDCONFIG}
|
||||
${PROTO_OUTPUT_DIR}
|
||||
${CMAKE_BINARY_DIR}/headers
|
||||
|
||||
192
configs/Haute42COSMOXMLite/BoardConfig.h
Normal file
192
configs/Haute42COSMOXMLite/BoardConfig.h
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2024 OpenStickCommunity (gp2040-ce.info)
|
||||
*/
|
||||
|
||||
#ifndef PICO_BOARD_CONFIG_H_
|
||||
#define PICO_BOARD_CONFIG_H_
|
||||
|
||||
#include "enums.pb.h"
|
||||
#include "class/hid/hid.h"
|
||||
|
||||
#define BOARD_CONFIG_LABEL "Haute42 COSMOX M Ultra"
|
||||
|
||||
// Main pin mapping Configuration
|
||||
// // GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
|
||||
#define GPIO_PIN_02 GpioAction::BUTTON_PRESS_UP // UP | UP | UP | UP | UP | UP |
|
||||
#define GPIO_PIN_03 GpioAction::BUTTON_PRESS_DOWN // DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
|
||||
#define GPIO_PIN_04 GpioAction::BUTTON_PRESS_RIGHT // RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
|
||||
#define GPIO_PIN_05 GpioAction::BUTTON_PRESS_LEFT // LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
|
||||
#define GPIO_PIN_06 GpioAction::BUTTON_PRESS_B1 // B1 | A | B | Cross | 2 | K1 |
|
||||
#define GPIO_PIN_07 GpioAction::BUTTON_PRESS_B2 // B2 | B | A | Circle | 3 | K2 |
|
||||
#define GPIO_PIN_08 GpioAction::BUTTON_PRESS_R2 // R2 | RT | ZR | R2 | 8 | K3 |
|
||||
#define GPIO_PIN_09 GpioAction::BUTTON_PRESS_L2 // L2 | LT | ZL | L2 | 7 | K4 |
|
||||
#define GPIO_PIN_10 GpioAction::BUTTON_PRESS_B3 // B3 | X | Y | Square | 1 | P1 |
|
||||
#define GPIO_PIN_11 GpioAction::BUTTON_PRESS_B4 // B4 | Y | X | Triangle | 4 | P2 |
|
||||
#define GPIO_PIN_12 GpioAction::BUTTON_PRESS_R1 // R1 | RB | R | R1 | 6 | P3 |
|
||||
#define GPIO_PIN_13 GpioAction::BUTTON_PRESS_L1 // L1 | LB | L | L1 | 5 | P4 |
|
||||
#define GPIO_PIN_16 GpioAction::BUTTON_PRESS_S1 // S1 | Back | Minus | Select | 9 | Coin |
|
||||
#define GPIO_PIN_17 GpioAction::BUTTON_PRESS_S2 // S2 | Start | Plus | Start | 10 | Start |
|
||||
#define GPIO_PIN_18 GpioAction::BUTTON_PRESS_L3 // L3 | LS | LS | L3 | 11 | LS |
|
||||
#define GPIO_PIN_19 GpioAction::BUTTON_PRESS_R3 // R3 | RS | RS | R3 | 12 | RS |
|
||||
#define GPIO_PIN_20 GpioAction::BUTTON_PRESS_A1 // A1 | Guide | Home | PS | 13 | ~ |
|
||||
#define GPIO_PIN_21 GpioAction::BUTTON_PRESS_A2 // A2 | ~ | Capture | ~ | 14 | ~ |
|
||||
|
||||
// Setting GPIO pins to assigned by add-on
|
||||
//
|
||||
#define GPIO_PIN_00 GpioAction::ASSIGNED_TO_ADDON
|
||||
#define GPIO_PIN_01 GpioAction::ASSIGNED_TO_ADDON
|
||||
#define GPIO_PIN_23 GpioAction::ASSIGNED_TO_ADDON
|
||||
#define GPIO_PIN_24 GpioAction::ASSIGNED_TO_ADDON
|
||||
#define GPIO_PIN_28 GpioAction::ASSIGNED_TO_ADDON
|
||||
|
||||
// Keyboard Mapping Configuration
|
||||
// // GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
|
||||
#define KEY_DPAD_UP HID_KEY_ARROW_UP // UP | UP | UP | UP | UP | UP |
|
||||
#define KEY_DPAD_DOWN HID_KEY_ARROW_DOWN // DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
|
||||
#define KEY_DPAD_RIGHT HID_KEY_ARROW_RIGHT // RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
|
||||
#define KEY_DPAD_LEFT HID_KEY_ARROW_LEFT // LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
|
||||
#define KEY_BUTTON_B1 HID_KEY_SHIFT_LEFT // B1 | A | B | Cross | 2 | K1 |
|
||||
#define KEY_BUTTON_B2 HID_KEY_Z // B2 | B | A | Circle | 3 | K2 |
|
||||
#define KEY_BUTTON_R2 HID_KEY_X // R2 | RT | ZR | R2 | 8 | K3 |
|
||||
#define KEY_BUTTON_L2 HID_KEY_V // L2 | LT | ZL | L2 | 7 | K4 |
|
||||
#define KEY_BUTTON_B3 HID_KEY_CONTROL_LEFT // B3 | X | Y | Square | 1 | P1 |
|
||||
#define KEY_BUTTON_B4 HID_KEY_ALT_LEFT // B4 | Y | X | Triangle | 4 | P2 |
|
||||
#define KEY_BUTTON_R1 HID_KEY_SPACE // R1 | RB | R | R1 | 6 | P3 |
|
||||
#define KEY_BUTTON_L1 HID_KEY_C // L1 | LB | L | L1 | 5 | P4 |
|
||||
#define KEY_BUTTON_S1 HID_KEY_5 // S1 | Back | Minus | Select | 9 | Coin |
|
||||
#define KEY_BUTTON_S2 HID_KEY_1 // S2 | Start | Plus | Start | 10 | Start |
|
||||
#define KEY_BUTTON_L3 HID_KEY_EQUAL // L3 | LS | LS | L3 | 11 | LS |
|
||||
#define KEY_BUTTON_R3 HID_KEY_MINUS // R3 | RS | RS | R3 | 12 | RS |
|
||||
#define KEY_BUTTON_A1 HID_KEY_9 // A1 | Guide | Home | PS | 13 | ~ |
|
||||
#define KEY_BUTTON_A2 HID_KEY_F2 // A2 | ~ | Capture | ~ | 14 | ~ |
|
||||
#define KEY_BUTTON_FN -1 // Hotkey Function |
|
||||
|
||||
#define USB_PERIPHERAL_ENABLED 1
|
||||
|
||||
#define USB_PERIPHERAL_PIN_DPLUS 23
|
||||
#define USB_PERIPHERAL_PIN_ORDER 0
|
||||
|
||||
#define DEFAULT_INPUT_MODE_R1 INPUT_MODE_XBONE
|
||||
#define DEFAULT_INPUT_MODE_B4 INPUT_MODE_PS5
|
||||
#define DEFAULT_PS5AUTHENTICATION_TYPE INPUT_MODE_AUTH_TYPE_USB
|
||||
|
||||
#define TURBO_ENABLED 1
|
||||
#define GPIO_PIN_14 GpioAction::BUTTON_PRESS_TURBO
|
||||
|
||||
#define BOARD_LEDS_PIN 28
|
||||
#define LED_BRIGHTNESS_MAXIMUM 100
|
||||
#define LED_BRIGHTNESS_STEPS 5
|
||||
#define LED_FORMAT LED_FORMAT_GRB
|
||||
#define LEDS_PER_PIXEL 1
|
||||
#define LEDS_BASE_ANIMATION_INDEX 1
|
||||
#define LEDS_DPAD_LEFT 0
|
||||
#define LEDS_DPAD_DOWN 1
|
||||
#define LEDS_DPAD_RIGHT 2
|
||||
#define LEDS_DPAD_UP 3
|
||||
#define LEDS_BUTTON_B3 4
|
||||
#define LEDS_BUTTON_B4 5
|
||||
#define LEDS_BUTTON_R1 6
|
||||
#define LEDS_BUTTON_L1 7
|
||||
#define LEDS_BUTTON_B1 8
|
||||
#define LEDS_BUTTON_B2 9
|
||||
#define LEDS_BUTTON_R2 10
|
||||
#define LEDS_BUTTON_L2 11
|
||||
#define LEDS_BUTTON_A1 12
|
||||
#define LEDS_BUTTON_L3 13
|
||||
#define LEDS_BUTTON_R3 14
|
||||
#define LEDS_BUTTON_A2 15
|
||||
|
||||
// Set our default ambient light
|
||||
#define CASE_RGB_TYPE CASE_RGB_TYPE_AMBIENT
|
||||
#define CASE_RGB_INDEX 16
|
||||
#define CASE_RGB_COUNT 20
|
||||
#define AMBIENT_LIGHT_EFFECT AL_CUSTOM_EFFECT_GRADIENT
|
||||
#define AMBIENT_STATIC_COLOR ANIMATION_COLOR_PURPLE
|
||||
|
||||
#define HAS_I2C_DISPLAY 1
|
||||
#define I2C0_ENABLED 1
|
||||
#define I2C0_PIN_SDA 0
|
||||
#define I2C0_PIN_SCL 1
|
||||
#define BUTTON_LAYOUT BUTTON_LAYOUT_STICKLESS
|
||||
#define BUTTON_LAYOUT_RIGHT BUTTON_LAYOUT_STICKLESSB
|
||||
#define SPLASH_MODE SPLASH_MODE_STATIC
|
||||
#define SPLASH_DURATION 3000
|
||||
|
||||
// Additional Button Support
|
||||
#define GPIO_PIN_27 GpioAction::BUTTON_PRESS_UP
|
||||
#define GPIO_PIN_26 GpioAction::BUTTON_PRESS_L3
|
||||
|
||||
// Keyboard Host enabled by default
|
||||
#define KEYBOARD_HOST_ENABLED 1
|
||||
|
||||
#define BOARD_LED_ENABLED 1
|
||||
#define BOARD_LED_TYPE ON_BOARD_LED_MODE_MODE_INDICATOR
|
||||
|
||||
#define DEFAULT_SPLASH \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xfe, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xff, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x7f, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x7f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
#endif
|
||||
28
configs/Haute42COSMOXMLite/README.md
Normal file
28
configs/Haute42COSMOXMLite/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# GP2040 Configuration for the Haute42 COSMOX M Lite device
|
||||
|
||||

|
||||
|
||||
Configuration for the [Haute42 COSMOX GAMING](https://cosmoxgaming.com/m-lite/) M Lite device.
|
||||
|
||||
## Main Pin Mapping Configuration
|
||||
|
||||
| RP2040 Pin | Action | GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
|
||||
|------------|-------------------------------|--------|--------|--------|----------|--------|--------|
|
||||
| GPIO_PIN_02| GpioAction::BUTTON_PRESS_UP | UP | UP | UP | UP | UP | UP |
|
||||
| GPIO_PIN_03| GpioAction::BUTTON_PRESS_DOWN | DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
|
||||
| GPIO_PIN_04| GpioAction::BUTTON_PRESS_RIGHT| RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
|
||||
| GPIO_PIN_05| GpioAction::BUTTON_PRESS_LEFT | LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
|
||||
| GPIO_PIN_06| GpioAction::BUTTON_PRESS_B1 | B1 | A | B | Cross | 2 | K1 |
|
||||
| GPIO_PIN_07| GpioAction::BUTTON_PRESS_B2 | B2 | B | A | Circle | 3 | K2 |
|
||||
| GPIO_PIN_08| GpioAction::BUTTON_PRESS_R2 | R2 | RT | ZR | R2 | 8 | K3 |
|
||||
| GPIO_PIN_09| GpioAction::BUTTON_PRESS_L2 | L2 | LT | ZL | L2 | 7 | K4 |
|
||||
| GPIO_PIN_10| GpioAction::BUTTON_PRESS_B3 | B3 | X | Y | Square | 1 | P1 |
|
||||
| GPIO_PIN_11| GpioAction::BUTTON_PRESS_B4 | B4 | Y | X | Triangle| 4 | P2 |
|
||||
| GPIO_PIN_12| GpioAction::BUTTON_PRESS_R1 | R1 | RB | R | R1 | 6 | P3 |
|
||||
| GPIO_PIN_13| GpioAction::BUTTON_PRESS_L1 | L1 | LB | L | L1 | 5 | P4 |
|
||||
| GPIO_PIN_16| GpioAction::BUTTON_PRESS_S1 | S1 | Back | Minus | Select | 9 | Coin |
|
||||
| GPIO_PIN_17| GpioAction::BUTTON_PRESS_S2 | S2 | Start | Plus | Start | 10 | Start |
|
||||
| GPIO_PIN_18| GpioAction::BUTTON_PRESS_L3 | L3 | LS | LS | L3 | 11 | LS |
|
||||
| GPIO_PIN_19| GpioAction::BUTTON_PRESS_R3 | R3 | RS | RS | R3 | 12 | RS |
|
||||
| GPIO_PIN_20| GpioAction::BUTTON_PRESS_A1 | A1 | Guide | Home | PS | 13 | ~ |
|
||||
| GPIO_PIN_21| GpioAction::BUTTON_PRESS_A2 | A2 | ~ | Capture | ~ | 14 | ~ |
|
||||
BIN
configs/Haute42COSMOXMLite/assets/Haute42COSMOX_M_Lite.jpg
Normal file
BIN
configs/Haute42COSMOXMLite/assets/Haute42COSMOX_M_Lite.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
192
configs/Haute42COSMOXMUltra/BoardConfig.h
Normal file
192
configs/Haute42COSMOXMUltra/BoardConfig.h
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2024 OpenStickCommunity (gp2040-ce.info)
|
||||
*/
|
||||
|
||||
#ifndef PICO_BOARD_CONFIG_H_
|
||||
#define PICO_BOARD_CONFIG_H_
|
||||
|
||||
#include "enums.pb.h"
|
||||
#include "class/hid/hid.h"
|
||||
|
||||
#define BOARD_CONFIG_LABEL "Haute42 COSMOX M Ultra"
|
||||
|
||||
// Main pin mapping Configuration
|
||||
// // GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
|
||||
#define GPIO_PIN_02 GpioAction::BUTTON_PRESS_UP // UP | UP | UP | UP | UP | UP |
|
||||
#define GPIO_PIN_03 GpioAction::BUTTON_PRESS_DOWN // DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
|
||||
#define GPIO_PIN_04 GpioAction::BUTTON_PRESS_RIGHT // RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
|
||||
#define GPIO_PIN_05 GpioAction::BUTTON_PRESS_LEFT // LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
|
||||
#define GPIO_PIN_06 GpioAction::BUTTON_PRESS_B1 // B1 | A | B | Cross | 2 | K1 |
|
||||
#define GPIO_PIN_07 GpioAction::BUTTON_PRESS_B2 // B2 | B | A | Circle | 3 | K2 |
|
||||
#define GPIO_PIN_08 GpioAction::BUTTON_PRESS_R2 // R2 | RT | ZR | R2 | 8 | K3 |
|
||||
#define GPIO_PIN_09 GpioAction::BUTTON_PRESS_L2 // L2 | LT | ZL | L2 | 7 | K4 |
|
||||
#define GPIO_PIN_10 GpioAction::BUTTON_PRESS_B3 // B3 | X | Y | Square | 1 | P1 |
|
||||
#define GPIO_PIN_11 GpioAction::BUTTON_PRESS_B4 // B4 | Y | X | Triangle | 4 | P2 |
|
||||
#define GPIO_PIN_12 GpioAction::BUTTON_PRESS_R1 // R1 | RB | R | R1 | 6 | P3 |
|
||||
#define GPIO_PIN_13 GpioAction::BUTTON_PRESS_L1 // L1 | LB | L | L1 | 5 | P4 |
|
||||
#define GPIO_PIN_16 GpioAction::BUTTON_PRESS_S1 // S1 | Back | Minus | Select | 9 | Coin |
|
||||
#define GPIO_PIN_17 GpioAction::BUTTON_PRESS_S2 // S2 | Start | Plus | Start | 10 | Start |
|
||||
#define GPIO_PIN_18 GpioAction::BUTTON_PRESS_L3 // L3 | LS | LS | L3 | 11 | LS |
|
||||
#define GPIO_PIN_19 GpioAction::BUTTON_PRESS_R3 // R3 | RS | RS | R3 | 12 | RS |
|
||||
#define GPIO_PIN_20 GpioAction::BUTTON_PRESS_A1 // A1 | Guide | Home | PS | 13 | ~ |
|
||||
#define GPIO_PIN_21 GpioAction::BUTTON_PRESS_A2 // A2 | ~ | Capture | ~ | 14 | ~ |
|
||||
|
||||
// Setting GPIO pins to assigned by add-on
|
||||
//
|
||||
#define GPIO_PIN_00 GpioAction::ASSIGNED_TO_ADDON
|
||||
#define GPIO_PIN_01 GpioAction::ASSIGNED_TO_ADDON
|
||||
#define GPIO_PIN_23 GpioAction::ASSIGNED_TO_ADDON
|
||||
#define GPIO_PIN_24 GpioAction::ASSIGNED_TO_ADDON
|
||||
#define GPIO_PIN_28 GpioAction::ASSIGNED_TO_ADDON
|
||||
|
||||
// Keyboard Mapping Configuration
|
||||
// // GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
|
||||
#define KEY_DPAD_UP HID_KEY_ARROW_UP // UP | UP | UP | UP | UP | UP |
|
||||
#define KEY_DPAD_DOWN HID_KEY_ARROW_DOWN // DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
|
||||
#define KEY_DPAD_RIGHT HID_KEY_ARROW_RIGHT // RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
|
||||
#define KEY_DPAD_LEFT HID_KEY_ARROW_LEFT // LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
|
||||
#define KEY_BUTTON_B1 HID_KEY_SHIFT_LEFT // B1 | A | B | Cross | 2 | K1 |
|
||||
#define KEY_BUTTON_B2 HID_KEY_Z // B2 | B | A | Circle | 3 | K2 |
|
||||
#define KEY_BUTTON_R2 HID_KEY_X // R2 | RT | ZR | R2 | 8 | K3 |
|
||||
#define KEY_BUTTON_L2 HID_KEY_V // L2 | LT | ZL | L2 | 7 | K4 |
|
||||
#define KEY_BUTTON_B3 HID_KEY_CONTROL_LEFT // B3 | X | Y | Square | 1 | P1 |
|
||||
#define KEY_BUTTON_B4 HID_KEY_ALT_LEFT // B4 | Y | X | Triangle | 4 | P2 |
|
||||
#define KEY_BUTTON_R1 HID_KEY_SPACE // R1 | RB | R | R1 | 6 | P3 |
|
||||
#define KEY_BUTTON_L1 HID_KEY_C // L1 | LB | L | L1 | 5 | P4 |
|
||||
#define KEY_BUTTON_S1 HID_KEY_5 // S1 | Back | Minus | Select | 9 | Coin |
|
||||
#define KEY_BUTTON_S2 HID_KEY_1 // S2 | Start | Plus | Start | 10 | Start |
|
||||
#define KEY_BUTTON_L3 HID_KEY_EQUAL // L3 | LS | LS | L3 | 11 | LS |
|
||||
#define KEY_BUTTON_R3 HID_KEY_MINUS // R3 | RS | RS | R3 | 12 | RS |
|
||||
#define KEY_BUTTON_A1 HID_KEY_9 // A1 | Guide | Home | PS | 13 | ~ |
|
||||
#define KEY_BUTTON_A2 HID_KEY_F2 // A2 | ~ | Capture | ~ | 14 | ~ |
|
||||
#define KEY_BUTTON_FN -1 // Hotkey Function |
|
||||
|
||||
#define USB_PERIPHERAL_ENABLED 1
|
||||
|
||||
#define USB_PERIPHERAL_PIN_DPLUS 23
|
||||
#define USB_PERIPHERAL_PIN_ORDER 0
|
||||
|
||||
#define DEFAULT_INPUT_MODE_R1 INPUT_MODE_XBONE
|
||||
#define DEFAULT_INPUT_MODE_B4 INPUT_MODE_PS5
|
||||
#define DEFAULT_PS5AUTHENTICATION_TYPE INPUT_MODE_AUTH_TYPE_USB
|
||||
|
||||
#define TURBO_ENABLED 1
|
||||
#define GPIO_PIN_14 GpioAction::BUTTON_PRESS_TURBO
|
||||
|
||||
#define BOARD_LEDS_PIN 28
|
||||
#define LED_BRIGHTNESS_MAXIMUM 100
|
||||
#define LED_BRIGHTNESS_STEPS 5
|
||||
#define LED_FORMAT LED_FORMAT_GRB
|
||||
#define LEDS_PER_PIXEL 1
|
||||
#define LEDS_BASE_ANIMATION_INDEX 1
|
||||
#define LEDS_DPAD_LEFT 0
|
||||
#define LEDS_DPAD_DOWN 1
|
||||
#define LEDS_DPAD_RIGHT 2
|
||||
#define LEDS_DPAD_UP 3
|
||||
#define LEDS_BUTTON_B3 4
|
||||
#define LEDS_BUTTON_B4 5
|
||||
#define LEDS_BUTTON_R1 6
|
||||
#define LEDS_BUTTON_L1 7
|
||||
#define LEDS_BUTTON_B1 8
|
||||
#define LEDS_BUTTON_B2 9
|
||||
#define LEDS_BUTTON_R2 10
|
||||
#define LEDS_BUTTON_L2 11
|
||||
#define LEDS_BUTTON_A1 12
|
||||
#define LEDS_BUTTON_L3 13
|
||||
#define LEDS_BUTTON_R3 14
|
||||
#define LEDS_BUTTON_A2 15
|
||||
|
||||
// Set our default ambient light
|
||||
#define CASE_RGB_TYPE CASE_RGB_TYPE_AMBIENT
|
||||
#define CASE_RGB_INDEX 16
|
||||
#define CASE_RGB_COUNT 30
|
||||
#define AMBIENT_LIGHT_EFFECT AL_CUSTOM_EFFECT_GRADIENT
|
||||
#define AMBIENT_STATIC_COLOR ANIMATION_COLOR_PURPLE
|
||||
|
||||
#define HAS_I2C_DISPLAY 1
|
||||
#define I2C0_ENABLED 1
|
||||
#define I2C0_PIN_SDA 0
|
||||
#define I2C0_PIN_SCL 1
|
||||
#define BUTTON_LAYOUT BUTTON_LAYOUT_STICKLESS
|
||||
#define BUTTON_LAYOUT_RIGHT BUTTON_LAYOUT_STICKLESSB
|
||||
#define SPLASH_MODE SPLASH_MODE_STATIC
|
||||
#define SPLASH_DURATION 3000
|
||||
|
||||
// Additional Button Support
|
||||
#define GPIO_PIN_27 GpioAction::BUTTON_PRESS_UP
|
||||
#define GPIO_PIN_26 GpioAction::BUTTON_PRESS_L3
|
||||
|
||||
// Keyboard Host enabled by default
|
||||
#define KEYBOARD_HOST_ENABLED 1
|
||||
|
||||
#define BOARD_LED_ENABLED 1
|
||||
#define BOARD_LED_TYPE ON_BOARD_LED_MODE_MODE_INDICATOR
|
||||
|
||||
#define DEFAULT_SPLASH \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xfe, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xff, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x7f, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x7f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
|
||||
#endif
|
||||
28
configs/Haute42COSMOXMUltra/README.md
Normal file
28
configs/Haute42COSMOXMUltra/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# GP2040 Configuration for the Haute42 COSMOX M Ultra device
|
||||
|
||||

|
||||
|
||||
Configuration for the [Haute42 COSMOX GAMING](https://cosmoxgaming.com/m-ultra/) M Ultra device.
|
||||
|
||||
## Main Pin Mapping Configuration
|
||||
|
||||
| RP2040 Pin | Action | GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
|
||||
|------------|-------------------------------|--------|--------|--------|----------|--------|--------|
|
||||
| GPIO_PIN_02| GpioAction::BUTTON_PRESS_UP | UP | UP | UP | UP | UP | UP |
|
||||
| GPIO_PIN_03| GpioAction::BUTTON_PRESS_DOWN | DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
|
||||
| GPIO_PIN_04| GpioAction::BUTTON_PRESS_RIGHT| RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
|
||||
| GPIO_PIN_05| GpioAction::BUTTON_PRESS_LEFT | LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
|
||||
| GPIO_PIN_06| GpioAction::BUTTON_PRESS_B1 | B1 | A | B | Cross | 2 | K1 |
|
||||
| GPIO_PIN_07| GpioAction::BUTTON_PRESS_B2 | B2 | B | A | Circle | 3 | K2 |
|
||||
| GPIO_PIN_08| GpioAction::BUTTON_PRESS_R2 | R2 | RT | ZR | R2 | 8 | K3 |
|
||||
| GPIO_PIN_09| GpioAction::BUTTON_PRESS_L2 | L2 | LT | ZL | L2 | 7 | K4 |
|
||||
| GPIO_PIN_10| GpioAction::BUTTON_PRESS_B3 | B3 | X | Y | Square | 1 | P1 |
|
||||
| GPIO_PIN_11| GpioAction::BUTTON_PRESS_B4 | B4 | Y | X | Triangle| 4 | P2 |
|
||||
| GPIO_PIN_12| GpioAction::BUTTON_PRESS_R1 | R1 | RB | R | R1 | 6 | P3 |
|
||||
| GPIO_PIN_13| GpioAction::BUTTON_PRESS_L1 | L1 | LB | L | L1 | 5 | P4 |
|
||||
| GPIO_PIN_16| GpioAction::BUTTON_PRESS_S1 | S1 | Back | Minus | Select | 9 | Coin |
|
||||
| GPIO_PIN_17| GpioAction::BUTTON_PRESS_S2 | S2 | Start | Plus | Start | 10 | Start |
|
||||
| GPIO_PIN_18| GpioAction::BUTTON_PRESS_L3 | L3 | LS | LS | L3 | 11 | LS |
|
||||
| GPIO_PIN_19| GpioAction::BUTTON_PRESS_R3 | R3 | RS | RS | R3 | 12 | RS |
|
||||
| GPIO_PIN_20| GpioAction::BUTTON_PRESS_A1 | A1 | Guide | Home | PS | 13 | ~ |
|
||||
| GPIO_PIN_21| GpioAction::BUTTON_PRESS_A2 | A2 | ~ | Capture | ~ | 14 | ~ |
|
||||
BIN
configs/Haute42COSMOXMUltra/assets/Haute42COSMOX_M_Ultra.jpg
Normal file
BIN
configs/Haute42COSMOXMUltra/assets/Haute42COSMOX_M_Ultra.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -110,10 +110,11 @@
|
||||
#define TURBO_LED_TYPE PLED_TYPE_RGB
|
||||
#define TURBO_LED_COLOR ColorRed
|
||||
|
||||
#define CASE_RGB_TYPE CASE_RGB_TYPE_STATIC
|
||||
#define CASE_RGB_TYPE CASE_RGB_TYPE_AMBIENT
|
||||
#define CASE_RGB_INDEX 29
|
||||
#define CASE_RGB_COUNT 20
|
||||
#define CASE_RGB_COLOR ColorGreen
|
||||
#define AMBIENT_LIGHT_EFFECT AL_CUSTOM_EFFECT_STATIC_COLOR
|
||||
#define AMBIENT_STATIC_COLOR ANIMATION_COLOR_GREEN
|
||||
|
||||
#define HAS_I2C_DISPLAY 1
|
||||
#define I2C0_ENABLED 1
|
||||
|
||||
@@ -111,10 +111,11 @@
|
||||
#define TURBO_LED_TYPE PLED_TYPE_RGB
|
||||
#define TURBO_LED_COLOR ColorRed
|
||||
|
||||
#define CASE_RGB_TYPE CASE_RGB_TYPE_STATIC
|
||||
#define CASE_RGB_TYPE CASE_RGB_TYPE_AMBIENT
|
||||
#define CASE_RGB_INDEX 18
|
||||
#define CASE_RGB_COUNT 20
|
||||
#define CASE_RGB_COLOR ColorGreen
|
||||
#define AMBIENT_LIGHT_EFFECT AL_CUSTOM_EFFECT_STATIC_COLOR
|
||||
#define AMBIENT_STATIC_COLOR ANIMATION_COLOR_GREEN
|
||||
|
||||
#define HAS_I2C_DISPLAY 1
|
||||
#define I2C0_ENABLED 1
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
|
||||
// MPGS
|
||||
#include "BoardConfig.h"
|
||||
#include "AnimationStation.hpp"
|
||||
#include "NeoPico.hpp"
|
||||
#include "animationstation.h"
|
||||
#include "NeoPico.h"
|
||||
|
||||
#include "enums.pb.h"
|
||||
|
||||
#ifndef BOARD_LEDS_PIN
|
||||
#define BOARD_LEDS_PIN -1
|
||||
@@ -154,10 +156,57 @@
|
||||
#define LEDS_TURN_OFF_WHEN_SUSPENDED 0
|
||||
#endif
|
||||
|
||||
void configureAnimations(AnimationStation *as);
|
||||
AnimationHotkey animationHotkeys(Gamepad *gamepad);
|
||||
PixelMatrix createLedButtonLayout(ButtonLayout layout, int ledsPerPixel);
|
||||
PixelMatrix createLedButtonLayout(ButtonLayout layout, std::vector<uint8_t> *positions);
|
||||
#ifndef CASE_RGB_TYPE
|
||||
#define CASE_RGB_TYPE CASE_RGB_TYPE_NONE
|
||||
#endif
|
||||
|
||||
#ifndef CASE_RGB_INDEX
|
||||
#define CASE_RGB_INDEX -1
|
||||
#endif
|
||||
|
||||
#ifndef CASE_RGB_COUNT
|
||||
#define CASE_RGB_COUNT 0
|
||||
#endif
|
||||
|
||||
#ifndef AMBIENT_LIGHT_EFFECT
|
||||
#define AMBIENT_LIGHT_EFFECT AL_CUSTOM_EFFECT_STATIC_COLOR
|
||||
#endif
|
||||
|
||||
#ifndef AMBIENT_STATIC_COLOR_BRIGHTNESS
|
||||
#define AMBIENT_STATIC_COLOR_BRIGHTNESS 1.00f
|
||||
#endif
|
||||
|
||||
#ifndef AMBIENT_GRADIENT_COLOR_BRIGHTNESS
|
||||
#define AMBIENT_GRADIENT_COLOR_BRIGHTNESS 1.00f
|
||||
#endif
|
||||
|
||||
#ifndef AMBIENT_CHASE_COLOR_BRIGHTNESS
|
||||
#define AMBIENT_CHASE_COLOR_BRIGHTNESS 1.00f
|
||||
#endif
|
||||
|
||||
#ifndef AMBIENT_CUSTOM_THEME_BRIGHTNESS
|
||||
#define AMBIENT_CUSTOM_THEME_BRIGHTNESS 1.00f
|
||||
#endif
|
||||
|
||||
#ifndef AMBIENT_GRADIENT_SPEED
|
||||
#define AMBIENT_GRADIENT_SPEED 2
|
||||
#endif
|
||||
|
||||
#ifndef AMBIENT_CHASE_SPEED
|
||||
#define AMBIENT_CHASE_SPEED 100
|
||||
#endif
|
||||
|
||||
#ifndef AMBIENT_BREATH_SPEED
|
||||
#define AMBIENT_BREATH_SPEED 0.01f
|
||||
#endif
|
||||
|
||||
#ifndef AMBIENT_CUSTOM_THEME
|
||||
#define AMBIENT_CUSTOM_THEME 0
|
||||
#endif
|
||||
|
||||
#ifndef AMBIENT_STATIC_COLOR
|
||||
#define AMBIENT_STATIC_COLOR ANIMATION_COLOR_PURPLE
|
||||
#endif
|
||||
|
||||
// Neo Pixel needs to tie into PlayerLEDS led Levels
|
||||
class NeoPicoPlayerLEDs : public PlayerLEDs
|
||||
@@ -179,9 +228,9 @@ public:
|
||||
virtual void process();
|
||||
virtual void postprocess(bool sent) {}
|
||||
virtual void reinit() {}
|
||||
virtual std::string name() { return NeoPicoLEDName; }
|
||||
void configureLEDs();
|
||||
uint32_t frame[100];
|
||||
virtual std::string name() { return NeoPicoLEDName; }
|
||||
void ambientLightLinkage();
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> * getLEDPositions(std::string button, std::vector<std::vector<uint8_t>> *positions);
|
||||
std::vector<std::vector<Pixel>> generatedLEDButtons(std::vector<std::vector<uint8_t>> *positions);
|
||||
@@ -190,18 +239,37 @@ private:
|
||||
std::vector<std::vector<Pixel>> generatedLEDWasdFBM(std::vector<std::vector<uint8_t>> *positions);
|
||||
std::vector<std::vector<Pixel>> createLEDLayout(ButtonLayout layout, uint8_t ledsPerPixel, uint8_t ledButtonCount);
|
||||
uint8_t setupButtonPositions();
|
||||
GamepadHotkey animationHotkeys(Gamepad *gamepad);
|
||||
void ambientHotkeys(Gamepad *gamepad);
|
||||
void ambientLightCustom();
|
||||
const uint32_t intervalMS = 10;
|
||||
absolute_time_t nextRunTime;
|
||||
uint8_t ledCount;
|
||||
int ledCount;
|
||||
int buttonLedCount;
|
||||
PixelMatrix matrix;
|
||||
NeoPico *neopico;
|
||||
InputMode inputMode; // HACK
|
||||
NeoPico neopico;
|
||||
PLEDAnimationState animationState; // NeoPico can control the player LEDs
|
||||
NeoPicoPlayerLEDs * neoPLEDs = nullptr;
|
||||
AnimationStation as;
|
||||
std::map<std::string, int> buttonPositions;
|
||||
bool turnOffWhenSuspended;
|
||||
PLEDType ledType;
|
||||
GamepadHotkey lastAmbientAction;
|
||||
uint32_t frame[100];
|
||||
|
||||
// Ambient neopico leds
|
||||
float alBrightnessBreathX;
|
||||
uint8_t breathLedEffectCycle;
|
||||
bool alReverse;
|
||||
int alCurrentFrame;
|
||||
int alFrameToRGB;
|
||||
int alFrameSpeed;
|
||||
RGB ambientLight;
|
||||
absolute_time_t nextRunTimeAmbientLight;
|
||||
uint8_t chaseLightIndex;
|
||||
uint8_t chaseLightMaxIndexPos;
|
||||
|
||||
uint8_t multipleOfButtonLedsCount;
|
||||
uint8_t remainderOfButtonLedsCount;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
#include "BoardConfig.h"
|
||||
#include <stdint.h>
|
||||
#include "AnimationStation.hpp"
|
||||
#include "animationstation.h"
|
||||
#include "storagemanager.h"
|
||||
#include "PlayerLEDs.h"
|
||||
#include "playerleds.h"
|
||||
#include "gpaddon.h"
|
||||
#include "helper.h"
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef _ANIMATION_H_
|
||||
#define _ANIMATION_H_
|
||||
|
||||
#include "Pixel.hpp"
|
||||
#include "pixel.h"
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "pico/stdlib.h"
|
||||
#include <vector>
|
||||
#include "NeoPico.hpp"
|
||||
#include "NeoPico.h"
|
||||
#include <map>
|
||||
|
||||
struct RGB {
|
||||
@@ -83,6 +83,7 @@ struct RGB {
|
||||
}
|
||||
};
|
||||
|
||||
// Also defined in Enums.proto
|
||||
constexpr RGB ColorBlack(0, 0, 0);
|
||||
constexpr RGB ColorWhite(255, 255, 255);
|
||||
constexpr RGB ColorRed(255, 0, 0);
|
||||
@@ -97,11 +98,15 @@ constexpr RGB ColorBlue(0, 0, 255);
|
||||
constexpr RGB ColorPurple(128, 0, 255);
|
||||
constexpr RGB ColorPink(255, 0, 255);
|
||||
constexpr RGB ColorMagenta(255, 0, 128);
|
||||
constexpr RGB ColorIndigo(75, 0, 130);
|
||||
constexpr RGB ColorViolet(238, 130, 238);
|
||||
|
||||
inline const std::vector<RGB> colors {
|
||||
ColorBlack, ColorWhite, ColorRed, ColorOrange, ColorYellow,
|
||||
ColorLimeGreen, ColorGreen, ColorSeafoam, ColorAqua, ColorSkyBlue,
|
||||
ColorBlue, ColorPurple, ColorPink, ColorMagenta };
|
||||
ColorBlue, ColorPurple, ColorPink, ColorMagenta, ColorIndigo,
|
||||
ColorViolet
|
||||
};
|
||||
|
||||
class Animation {
|
||||
public:
|
||||
77
headers/animationstation/animationstation.h
Normal file
77
headers/animationstation/animationstation.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef _ANIMATION_STATION_H_
|
||||
#define _ANIMATION_STATION_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
#include "hardware/clocks.h"
|
||||
|
||||
#include "NeoPico.h"
|
||||
#include "animation.h"
|
||||
#include "effects/chase.h"
|
||||
#include "effects/customtheme.h"
|
||||
#include "effects/customthemepressed.h"
|
||||
#include "effects/rainbow.h"
|
||||
#include "effects/staticcolor.h"
|
||||
#include "effects/statictheme.h"
|
||||
|
||||
#include "config.pb.h"
|
||||
#include "enums.pb.h"
|
||||
|
||||
const int TOTAL_EFFECTS = 4; // Exclude custom theme until verified present
|
||||
|
||||
class AnimationStation
|
||||
{
|
||||
public:
|
||||
AnimationStation();
|
||||
void Animate();
|
||||
void HandleEvent(GamepadHotkey action);
|
||||
void Clear();
|
||||
void ChangeAnimation(int changeSize);
|
||||
void ApplyBrightness(uint32_t *frameValue);
|
||||
uint16_t AdjustIndex(int changeSize);
|
||||
void HandlePressed(std::vector<Pixel> pressed);
|
||||
void ClearPressed();
|
||||
void SetMode(uint8_t mode);
|
||||
void SetMatrix(PixelMatrix matrix);
|
||||
void ConfigureBrightness(uint8_t max, uint8_t steps);
|
||||
float GetBrightnessX();
|
||||
float GetLinkageModeOfBrightnessX();
|
||||
uint8_t GetBrightness();
|
||||
void SetBrightness(uint8_t brightness);
|
||||
void DecreaseBrightness();
|
||||
void IncreaseBrightness();
|
||||
void DimBrightnessTo0();
|
||||
uint8_t GetBrightnessSteps(){ return this->brightnessSteps; };
|
||||
uint8_t GetCustomBrightnessStepsSize(){ return (brightnessMax / brightnessSteps); };
|
||||
RGB linkageFrame[100]; // copy baseAnimation frame exclude buttonAnimation frame
|
||||
|
||||
private:
|
||||
Animation* baseAnimation;
|
||||
Animation* buttonAnimation;
|
||||
std::vector<Pixel> lastPressed;
|
||||
absolute_time_t nextChange;
|
||||
uint8_t effectCount;
|
||||
RGB frame[100];
|
||||
bool ambientLightEffectsChangeFlag = false;
|
||||
bool ambientLightOnOffFlag = false;
|
||||
bool ambientLightLinkageOnOffFlag = false;
|
||||
bool aleLedsBrightnessCustomXupFlag = false;
|
||||
bool aleLedsBrightnessCustomXDownFlag = false;
|
||||
bool aleLedsParameterCustomUpFlag = false;
|
||||
bool aleLedsParameterCustomDownFlag = false;
|
||||
bool alGradientChaseBreathSpeedUpFlag = false;
|
||||
bool alGradientChaseBreathSpeedDownFlag = false;
|
||||
bool alCustomLinkageModeFlag = false;
|
||||
uint8_t getBrightnessStepSize() { return (brightnessMax / brightnessSteps); }
|
||||
uint8_t getLinkageModeOfBrightnessStepSize() { return (255 / brightnessSteps); }
|
||||
float linkageModeOfBrightnessX;
|
||||
uint8_t brightnessMax;
|
||||
uint8_t brightnessSteps;
|
||||
float brightnessX;
|
||||
PixelMatrix matrix;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef _CONFIG_STORAGE_H_
|
||||
#define _CONFIG_STORAGE_H_
|
||||
|
||||
#include "AnimationStation.hpp"
|
||||
#ifndef _ANIMATION_STORAGE_H_
|
||||
#define _ANIMATION_STORAGE_H_
|
||||
/*
|
||||
#include "animationstation.h"
|
||||
|
||||
class AnimationStorage
|
||||
{
|
||||
@@ -11,5 +11,5 @@ class AnimationStorage
|
||||
};
|
||||
|
||||
static AnimationStorage AnimationStore;
|
||||
|
||||
*/
|
||||
#endif
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef _CHASE_H_
|
||||
#define _CHASE_H_
|
||||
|
||||
#include "../Animation.hpp"
|
||||
#include "animation.h"
|
||||
#include "hardware/clocks.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
#include "../AnimationStation.hpp"
|
||||
#include "animationstation.h"
|
||||
|
||||
class Chase : public Animation {
|
||||
public:
|
||||
@@ -2,21 +2,20 @@
|
||||
#define CUSTOM_THEME_H_
|
||||
|
||||
#include <map>
|
||||
#include "../Animation.hpp"
|
||||
#include "../AnimationStation.hpp"
|
||||
#include "animation.h"
|
||||
#include "animationstation.h"
|
||||
|
||||
class CustomTheme : public Animation {
|
||||
public:
|
||||
CustomTheme(PixelMatrix &matrix);
|
||||
~CustomTheme() { };
|
||||
|
||||
static bool HasTheme();
|
||||
static void SetCustomTheme(std::map<uint32_t, RGB> customTheme);
|
||||
bool HasTheme();
|
||||
void Animate(RGB (&frame)[100]);
|
||||
void ParameterUp();
|
||||
void ParameterDown();
|
||||
protected:
|
||||
static std::map<uint32_t, RGB> theme;
|
||||
std::map<uint32_t, RGB> theme;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -3,24 +3,22 @@
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "../Animation.hpp"
|
||||
#include "../AnimationStation.hpp"
|
||||
#include "animation.h"
|
||||
#include "animationstation.h"
|
||||
|
||||
class CustomThemePressed : public Animation {
|
||||
public:
|
||||
CustomThemePressed(PixelMatrix &matrix);
|
||||
CustomThemePressed(PixelMatrix &matrix, std::vector<Pixel> &pixels);
|
||||
~CustomThemePressed() { pixels = nullptr; };
|
||||
|
||||
static bool HasTheme();
|
||||
static void SetCustomTheme(std::map<uint32_t, RGB> customTheme);
|
||||
bool HasTheme();
|
||||
void Animate(RGB (&frame)[100]);
|
||||
void ParameterUp() { }
|
||||
void ParameterDown() { }
|
||||
protected:
|
||||
std::vector<Pixel> *pixels;
|
||||
RGB defaultColor = ColorBlack;
|
||||
static std::map<uint32_t, RGB> theme;
|
||||
std::map<uint32_t, RGB> theme;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef _RAINBOW_H_
|
||||
#define _RAINBOW_H_
|
||||
|
||||
#include "../Animation.hpp"
|
||||
#include "animation.h"
|
||||
#include "hardware/clocks.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
#include "../AnimationStation.hpp"
|
||||
#include "animationstation.h"
|
||||
|
||||
class Rainbow : public Animation {
|
||||
public:
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../Animation.hpp"
|
||||
#include "../AnimationStation.hpp"
|
||||
#include "animation.h"
|
||||
#include "animationstation.h"
|
||||
|
||||
class StaticColor : public Animation {
|
||||
public:
|
||||
@@ -7,22 +7,22 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../Animation.hpp"
|
||||
#include "../AnimationStation.hpp"
|
||||
#include "animation.h"
|
||||
#include "animationstation.h"
|
||||
|
||||
class StaticTheme : public Animation {
|
||||
public:
|
||||
StaticTheme(PixelMatrix &matrix);
|
||||
~StaticTheme() {};
|
||||
|
||||
static void AddTheme(const std::map<uint32_t, RGB>& theme) { themes.push_back(theme); }
|
||||
static void ClearThemes() { themes.clear(); }
|
||||
void AddTheme(const std::map<uint32_t, RGB>& theme) { themes.push_back(theme); }
|
||||
void ClearThemes() { themes.clear(); }
|
||||
void Animate(RGB (&frame)[100]);
|
||||
void ParameterUp();
|
||||
void ParameterDown();
|
||||
protected:
|
||||
RGB defaultColor = ColorBlack;
|
||||
static std::vector<std::map<uint32_t, RGB>> themes;
|
||||
std::vector<std::map<uint32_t, RGB>> themes;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "GPGFX_UI_widgets.h"
|
||||
#include "GPGFX_UI_types.h"
|
||||
#include "enums.pb.h"
|
||||
#include "AnimationStation.hpp"
|
||||
#include "animationstation.h"
|
||||
#include "eventmanager.h"
|
||||
|
||||
#define INPUT_MODE_XINPUT_NAME "XInput"
|
||||
|
||||
@@ -217,6 +217,7 @@ private:
|
||||
bool map48WayModeToggle;
|
||||
const HotkeyOptions & hotkeyOptions;
|
||||
|
||||
HotkeyEntry hotkeys[16];
|
||||
GamepadHotkey lastAction = HOTKEY_NONE;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "BoardConfig.h"
|
||||
#include <stdint.h>
|
||||
#include "AnimationStation.hpp"
|
||||
#include "PlayerLEDs.h"
|
||||
#include "animationstation.h"
|
||||
#include "playerleds.h"
|
||||
|
||||
// GP2040-CE Board Config (64 character limit)
|
||||
#ifndef GP2040_BOARDCONFIG
|
||||
@@ -35,22 +35,6 @@
|
||||
#define PLED_COLOR ColorWhite // White
|
||||
#endif
|
||||
|
||||
#ifndef CASE_RGB_TYPE
|
||||
#define CASE_RGB_TYPE CASE_RGB_TYPE_NONE
|
||||
#endif
|
||||
|
||||
#ifndef CASE_RGB_INDEX
|
||||
#define CASE_RGB_INDEX -1
|
||||
#endif
|
||||
|
||||
#ifndef CASE_RGB_COLOR
|
||||
#define CASE_RGB_COLOR ColorGreen // Green
|
||||
#endif
|
||||
|
||||
#ifndef CASE_RGB_COUNT
|
||||
#define CASE_RGB_COUNT 0
|
||||
#endif
|
||||
|
||||
static inline bool isValidPin(int32_t pin) {
|
||||
int32_t numBank0GPIOS = NUM_BANK0_GPIOS;
|
||||
return pin >= 0 && pin < numBank0GPIOS; }
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define STORAGE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "NeoPico.hpp"
|
||||
#include "NeoPico.h"
|
||||
#include "FlashPROM.h"
|
||||
|
||||
#include "enums.h"
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
DisplayOptions& getPreviewDisplayOptions() { return previewDisplayOptions; }
|
||||
LEDOptions& getLedOptions() { return config.ledOptions; }
|
||||
AddonOptions& getAddonOptions() { return config.addonOptions; }
|
||||
AnimationOptions_Proto& getAnimationOptions() { return config.animationOptions; }
|
||||
AnimationOptions& getAnimationOptions() { return config.animationOptions; }
|
||||
ProfileOptions& getProfileOptions() { return config.profileOptions; }
|
||||
GpioMappingInfo* getProfilePinMappings() { return functionalPinMappings; }
|
||||
PeripheralOptions& getPeripheralOptions() { return config.peripheralOptions; }
|
||||
@@ -53,11 +53,6 @@ public:
|
||||
bool save();
|
||||
bool save(const bool force);
|
||||
|
||||
// Perform saves that were enqueued from core1
|
||||
void performEnqueuedSaves();
|
||||
|
||||
void enqueueAnimationOptionsSave(const AnimationOptions& animationOptions);
|
||||
|
||||
void SetConfigMode(bool); // Config Mode (on-boot)
|
||||
bool GetConfigMode();
|
||||
|
||||
@@ -83,10 +78,6 @@ private:
|
||||
uint8_t featureData[32]; // USB X-Input Feature Data
|
||||
DisplayOptions previewDisplayOptions;
|
||||
Config config;
|
||||
std::atomic<bool> animationOptionsSavePending;
|
||||
critical_section_t animationOptionsCs;
|
||||
uint32_t animationOptionsCrc = 0;
|
||||
AnimationOptions animationOptionsToSave = {};
|
||||
GpioMappingInfo functionalPinMappings[NUM_BANK0_GPIOS];
|
||||
};
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = crlf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = false
|
||||
@@ -1,20 +0,0 @@
|
||||
add_library(AnimationStation
|
||||
src/Effects/Chase.cpp
|
||||
src/Effects/CustomTheme.cpp
|
||||
src/Effects/CustomThemePressed.cpp
|
||||
src/Effects/Rainbow.cpp
|
||||
src/Effects/StaticColor.cpp
|
||||
src/Effects/StaticTheme.cpp
|
||||
src/AnimationStation.cpp
|
||||
src/Animation.cpp
|
||||
)
|
||||
target_include_directories(AnimationStation PUBLIC
|
||||
src
|
||||
src/Effects
|
||||
)
|
||||
target_link_libraries(AnimationStation PUBLIC
|
||||
pico_stdlib
|
||||
hardware_clocks
|
||||
hardware_timer
|
||||
NeoPico
|
||||
)
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"name": "AnimationStation",
|
||||
"version": "0.0.1",
|
||||
"description": "LED Handling for GP2040",
|
||||
"keywords": "c c++ baremetal neopixel led",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jonathan Barket",
|
||||
"url": "https://jonathanbarket.com"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
#ifndef _ANIMATION_STATION_H_
|
||||
#define _ANIMATION_STATION_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
#include "hardware/clocks.h"
|
||||
|
||||
#include "NeoPico.hpp"
|
||||
#include "Animation.hpp"
|
||||
#include "Effects/Chase.hpp"
|
||||
#include "Effects/CustomTheme.hpp"
|
||||
#include "Effects/CustomThemePressed.hpp"
|
||||
#include "Effects/Rainbow.hpp"
|
||||
#include "Effects/StaticColor.hpp"
|
||||
#include "Effects/StaticTheme.hpp"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EFFECT_STATIC_COLOR,
|
||||
EFFECT_RAINBOW,
|
||||
EFFECT_CHASE,
|
||||
EFFECT_STATIC_THEME,
|
||||
EFFECT_CUSTOM_THEME,
|
||||
} AnimationEffects;
|
||||
|
||||
const int TOTAL_EFFECTS = 4; // Exclude custom theme until verified present
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HOTKEY_LEDS_NONE,
|
||||
HOTKEY_LEDS_ANIMATION_UP,
|
||||
HOTKEY_LEDS_ANIMATION_DOWN,
|
||||
HOTKEY_LEDS_PARAMETER_UP,
|
||||
HOTKEY_LEDS_PRESS_PARAMETER_UP,
|
||||
HOTKEY_LEDS_PRESS_PARAMETER_DOWN,
|
||||
HOTKEY_LEDS_PARAMETER_DOWN,
|
||||
HOTKEY_LEDS_BRIGHTNESS_UP,
|
||||
HOTKEY_LEDS_BRIGHTNESS_DOWN,
|
||||
HOTKEY_LEDS_FADETIME_UP,
|
||||
HOTKEY_LEDS_FADETIME_DOWN
|
||||
} AnimationHotkey;
|
||||
|
||||
struct __attribute__ ((__packed__)) AnimationOptions
|
||||
{
|
||||
uint32_t checksum;
|
||||
uint8_t baseAnimationIndex;
|
||||
uint8_t brightness;
|
||||
uint8_t staticColorIndex;
|
||||
uint8_t buttonColorIndex;
|
||||
int16_t chaseCycleTime;
|
||||
int16_t rainbowCycleTime;
|
||||
uint8_t themeIndex;
|
||||
bool hasCustomTheme;
|
||||
uint32_t customThemeUp;
|
||||
uint32_t customThemeDown;
|
||||
uint32_t customThemeLeft;
|
||||
uint32_t customThemeRight;
|
||||
uint32_t customThemeB1;
|
||||
uint32_t customThemeB2;
|
||||
uint32_t customThemeB3;
|
||||
uint32_t customThemeB4;
|
||||
uint32_t customThemeL1;
|
||||
uint32_t customThemeR1;
|
||||
uint32_t customThemeL2;
|
||||
uint32_t customThemeR2;
|
||||
uint32_t customThemeS1;
|
||||
uint32_t customThemeS2;
|
||||
uint32_t customThemeL3;
|
||||
uint32_t customThemeR3;
|
||||
uint32_t customThemeA1;
|
||||
uint32_t customThemeA2;
|
||||
uint32_t customThemeUpPressed;
|
||||
uint32_t customThemeDownPressed;
|
||||
uint32_t customThemeLeftPressed;
|
||||
uint32_t customThemeRightPressed;
|
||||
uint32_t customThemeB1Pressed;
|
||||
uint32_t customThemeB2Pressed;
|
||||
uint32_t customThemeB3Pressed;
|
||||
uint32_t customThemeB4Pressed;
|
||||
uint32_t customThemeL1Pressed;
|
||||
uint32_t customThemeR1Pressed;
|
||||
uint32_t customThemeL2Pressed;
|
||||
uint32_t customThemeR2Pressed;
|
||||
uint32_t customThemeS1Pressed;
|
||||
uint32_t customThemeS2Pressed;
|
||||
uint32_t customThemeL3Pressed;
|
||||
uint32_t customThemeR3Pressed;
|
||||
uint32_t customThemeA1Pressed;
|
||||
uint32_t customThemeA2Pressed;
|
||||
uint32_t buttonPressColorCooldownTimeInMs;
|
||||
};
|
||||
|
||||
class AnimationStation
|
||||
{
|
||||
public:
|
||||
AnimationStation();
|
||||
|
||||
void Animate();
|
||||
void HandleEvent(AnimationHotkey action);
|
||||
void Clear();
|
||||
void ChangeAnimation(int changeSize);
|
||||
void ApplyBrightness(uint32_t *frameValue);
|
||||
uint16_t AdjustIndex(int changeSize);
|
||||
void HandlePressed(std::vector<Pixel> pressed);
|
||||
void ClearPressed();
|
||||
|
||||
uint8_t GetMode();
|
||||
void SetMode(uint8_t mode);
|
||||
void SetMatrix(PixelMatrix matrix);
|
||||
static void ConfigureBrightness(uint8_t max, uint8_t steps);
|
||||
static float GetBrightnessX();
|
||||
static uint8_t GetBrightness();
|
||||
static void SetBrightness(uint8_t brightness);
|
||||
static void DecreaseBrightness();
|
||||
static void IncreaseBrightness();
|
||||
static void DimBrightnessTo0();
|
||||
static void SetOptions(AnimationOptions options);
|
||||
|
||||
Animation* baseAnimation;
|
||||
Animation* buttonAnimation;
|
||||
std::vector<Pixel> lastPressed;
|
||||
static AnimationOptions options;
|
||||
static absolute_time_t nextChange;
|
||||
static uint8_t effectCount;
|
||||
RGB frame[100];
|
||||
|
||||
protected:
|
||||
inline static uint8_t getBrightnessStepSize() { return (brightnessMax / brightnessSteps); }
|
||||
static uint8_t brightnessMax;
|
||||
static uint8_t brightnessSteps;
|
||||
static float brightnessX;
|
||||
PixelMatrix matrix;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,48 +0,0 @@
|
||||
#include "CustomTheme.hpp"
|
||||
|
||||
std::map<uint32_t, RGB> CustomTheme::theme;
|
||||
|
||||
CustomTheme::CustomTheme(PixelMatrix &matrix) : Animation(matrix) {
|
||||
}
|
||||
|
||||
void CustomTheme::Animate(RGB (&frame)[100]) {
|
||||
UpdateTime();
|
||||
UpdatePresses(frame);
|
||||
|
||||
for (size_t r = 0; r != matrix->pixels.size(); r++) {
|
||||
for (size_t c = 0; c != matrix->pixels[r].size(); c++) {
|
||||
if (matrix->pixels[r][c].index == NO_PIXEL.index)
|
||||
continue;
|
||||
|
||||
// Count down the timer
|
||||
DecrementFadeCounter(matrix->pixels[r][c].index);
|
||||
|
||||
auto itr = theme.find(matrix->pixels[r][c].mask);
|
||||
if (itr != theme.end()) {
|
||||
for (size_t p = 0; p != matrix->pixels[r][c].positions.size(); p++) {
|
||||
// Interpolate from hitColor (color the button was assigned when pressed) back to the theme color
|
||||
frame[matrix->pixels[r][c].positions[p]] = BlendColor(hitColor[matrix->pixels[r][c].index], itr->second, times[matrix->pixels[r][c].index]);
|
||||
}
|
||||
} else {
|
||||
for (size_t p = 0; p != matrix->pixels[r][c].positions.size(); p++) {
|
||||
frame[matrix->pixels[r][c].positions[p]] = defaultColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CustomTheme::HasTheme() {
|
||||
return CustomTheme::theme.size() > 0;
|
||||
}
|
||||
|
||||
void CustomTheme::SetCustomTheme(std::map<uint32_t, RGB> customTheme) {
|
||||
CustomTheme::theme = customTheme;
|
||||
AnimationStation::effectCount = TOTAL_EFFECTS + 1;
|
||||
}
|
||||
|
||||
void CustomTheme::ParameterUp() {
|
||||
}
|
||||
|
||||
void CustomTheme::ParameterDown() {
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
#include "CustomThemePressed.hpp"
|
||||
|
||||
std::map<uint32_t, RGB> CustomThemePressed::theme;
|
||||
|
||||
CustomThemePressed::CustomThemePressed(PixelMatrix &matrix) : Animation(matrix) {
|
||||
this->filtered = true;
|
||||
}
|
||||
|
||||
CustomThemePressed::CustomThemePressed(PixelMatrix &matrix, std::vector<Pixel> &pixels) : Animation(matrix), pixels(&pixels) {
|
||||
this->filtered = true;
|
||||
}
|
||||
|
||||
void CustomThemePressed::Animate(RGB (&frame)[100]) {
|
||||
for (size_t r = 0; r != matrix->pixels.size(); r++) {
|
||||
for (size_t c = 0; c != matrix->pixels[r].size(); c++) {
|
||||
if (matrix->pixels[r][c].index == NO_PIXEL.index || this->notInFilter(matrix->pixels[r][c]))
|
||||
continue;
|
||||
|
||||
auto itr = theme.find(matrix->pixels[r][c].mask);
|
||||
if (itr != theme.end())
|
||||
for (size_t p = 0; p != matrix->pixels[r][c].positions.size(); p++)
|
||||
frame[matrix->pixels[r][c].positions[p]] = itr->second;
|
||||
else
|
||||
for (size_t p = 0; p != matrix->pixels[r][c].positions.size(); p++)
|
||||
frame[matrix->pixels[r][c].positions[p]] = defaultColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CustomThemePressed::HasTheme() {
|
||||
return CustomThemePressed::theme.size() > 0;
|
||||
}
|
||||
|
||||
void CustomThemePressed::SetCustomTheme(std::map<uint32_t, RGB> customTheme) {
|
||||
CustomThemePressed::theme = customTheme;
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#include "StaticTheme.hpp"
|
||||
|
||||
std::vector<std::map<uint32_t, RGB>> StaticTheme::themes = {};
|
||||
|
||||
StaticTheme::StaticTheme(PixelMatrix &matrix) : Animation(matrix) {
|
||||
if (AnimationStation::options.themeIndex >= StaticTheme::themes.size()) {
|
||||
AnimationStation::options.themeIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void StaticTheme::Animate(RGB (&frame)[100]) {
|
||||
if (StaticTheme::themes.size() > 0) {
|
||||
UpdateTime();
|
||||
UpdatePresses(frame);
|
||||
|
||||
for (size_t r = 0; r != matrix->pixels.size(); r++) {
|
||||
for (size_t c = 0; c != matrix->pixels[r].size(); c++) {
|
||||
if (matrix->pixels[r][c].index == NO_PIXEL.index)
|
||||
continue;
|
||||
|
||||
// Count down the timer
|
||||
DecrementFadeCounter(matrix->pixels[r][c].index);
|
||||
|
||||
std::map<uint32_t, RGB> theme = StaticTheme::themes.at(AnimationStation::options.themeIndex);
|
||||
|
||||
auto itr = theme.find(matrix->pixels[r][c].mask);
|
||||
if (itr != theme.end()) {
|
||||
for (size_t p = 0; p != matrix->pixels[r][c].positions.size(); p++) {
|
||||
// Interpolate from hitColor (color the button was assigned when pressed) back to the theme color
|
||||
frame[matrix->pixels[r][c].positions[p]] = BlendColor(hitColor[matrix->pixels[r][c].index], itr->second, times[matrix->pixels[r][c].index]);
|
||||
}
|
||||
} else {
|
||||
for (size_t p = 0; p != matrix->pixels[r][c].positions.size(); p++) {
|
||||
frame[matrix->pixels[r][c].positions[p]] = defaultColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StaticTheme::ParameterUp() {
|
||||
if (AnimationStation::options.themeIndex < StaticTheme::themes.size() - 1) {
|
||||
AnimationStation::options.themeIndex++;
|
||||
} else {
|
||||
AnimationStation::options.themeIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void StaticTheme::ParameterDown() {
|
||||
if (AnimationStation::options.themeIndex > 0) {
|
||||
AnimationStation::options.themeIndex--;
|
||||
} else {
|
||||
AnimationStation::options.themeIndex = StaticTheme::themes.size() - 1;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
add_subdirectory(ADS1219)
|
||||
add_subdirectory(ADS1256)
|
||||
add_subdirectory(AnimationStation)
|
||||
add_subdirectory(CRC32)
|
||||
add_subdirectory(FlashPROM)
|
||||
add_subdirectory(httpd)
|
||||
@@ -9,7 +8,6 @@ add_subdirectory(nanopb)
|
||||
add_subdirectory(NeoPico)
|
||||
add_subdirectory(OneBitDisplay)
|
||||
add_subdirectory(PicoPeripherals)
|
||||
add_subdirectory(PlayerLEDs)
|
||||
add_subdirectory(rndis)
|
||||
add_subdirectory(WiiExtension)
|
||||
add_subdirectory(SNESpad)
|
||||
|
||||
@@ -12,7 +12,10 @@
|
||||
#include "pico/stdlib.h"
|
||||
#include "hardware/pio.h"
|
||||
#include "hardware/clocks.h"
|
||||
#include "NeoPico.hpp"
|
||||
#include "NeoPico.h"
|
||||
|
||||
NeoPico::NeoPico(){
|
||||
}
|
||||
|
||||
LEDFormat NeoPico::GetFormat() {
|
||||
return format;
|
||||
@@ -22,23 +25,25 @@ void NeoPico::PutPixel(uint32_t pixelData) {
|
||||
switch (format) {
|
||||
case LED_FORMAT_GRB:
|
||||
case LED_FORMAT_RGB:
|
||||
pio_sm_put_blocking(pio0, 0, pixelData << 8u);
|
||||
pio_sm_put_blocking(pio, 0, pixelData << 8u);
|
||||
break;
|
||||
case LED_FORMAT_GRBW:
|
||||
case LED_FORMAT_RGBW:
|
||||
pio_sm_put_blocking(pio0, 0, pixelData);
|
||||
pio_sm_put_blocking(pio, 0, pixelData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NeoPico::NeoPico(int ledPin, int numPixels, LEDFormat format) : format(format), numPixels(numPixels) {
|
||||
PIO pio = pio0;
|
||||
void NeoPico::Setup(int ledPin, int inNumPixels, LEDFormat inFormat, PIO inPio){
|
||||
format = inFormat;
|
||||
pio = inPio;
|
||||
numPixels = inNumPixels;
|
||||
int sm = 0;
|
||||
uint offset = pio_add_program(pio, &ws2812_program);
|
||||
bool rgbw = (format == LED_FORMAT_GRBW) || (format == LED_FORMAT_RGBW);
|
||||
ws2812_program_init(pio, sm, offset, ledPin, 800000, rgbw);
|
||||
this->Clear();
|
||||
sleep_ms(10);
|
||||
//sleep_ms(10);
|
||||
}
|
||||
|
||||
void NeoPico::Clear() {
|
||||
@@ -53,7 +58,15 @@ void NeoPico::Show() {
|
||||
for (int i = 0; i < this->numPixels; ++i) {
|
||||
this->PutPixel(this->frame[i]);
|
||||
}
|
||||
sleep_ms(10);
|
||||
|
||||
// Ambient lights
|
||||
/*
|
||||
for(int j = this->numPixels; j < 100; ++j) {
|
||||
// this->PutPixel(this->frame[j]);
|
||||
pio_sm_put_blocking(pio, 0, (this->frame[j]) << 8u);
|
||||
}
|
||||
*/
|
||||
//sleep_ms(10);
|
||||
}
|
||||
|
||||
void NeoPico::Off() {
|
||||
@@ -61,5 +74,5 @@ void NeoPico::Off() {
|
||||
for (int i = 0; i < this->numPixels; ++i) {
|
||||
this->PutPixel(this->frame[i]);
|
||||
}
|
||||
sleep_ms(10);
|
||||
//sleep_ms(10);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ typedef enum
|
||||
class NeoPico
|
||||
{
|
||||
public:
|
||||
NeoPico(int ledPin, int numPixels, LEDFormat format = LED_FORMAT_GRB);
|
||||
NeoPico();
|
||||
void Setup(int ledPin, int inNumPixels, LEDFormat inFormat, PIO inPio);
|
||||
void Show();
|
||||
void Clear();
|
||||
void Off();
|
||||
@@ -1,10 +0,0 @@
|
||||
add_library(PlayerLEDs
|
||||
src/PlayerLEDs.cpp
|
||||
)
|
||||
target_include_directories(PlayerLEDs PUBLIC
|
||||
src
|
||||
)
|
||||
target_link_libraries(PlayerLEDs
|
||||
pico_stdlib
|
||||
hardware_pwm
|
||||
)
|
||||
@@ -190,8 +190,9 @@ static void service_traffic(void)
|
||||
/* handle any packet received by tud_network_recv_cb() */
|
||||
if (received_frame)
|
||||
{
|
||||
ethernet_input(received_frame, &netif_data);
|
||||
pbuf_free(received_frame);
|
||||
if (ethernet_input(received_frame, &netif_data)!=ERR_OK) {
|
||||
pbuf_free(received_frame);
|
||||
}
|
||||
received_frame = NULL;
|
||||
tud_network_recv_renew();
|
||||
}
|
||||
|
||||
@@ -313,12 +313,12 @@ message LEDOptions
|
||||
|
||||
optional CaseRGBType caseRGBType = 36;
|
||||
optional int32 caseRGBIndex = 37;
|
||||
optional uint32 caseRGBColor = 38;
|
||||
optional uint32 caseRGBColor = 38 [deprecated = true];
|
||||
optional uint32 caseRGBCount = 39;
|
||||
};
|
||||
|
||||
// This has to be kept in sync with AnimationOptions in AnimationStation.hpp
|
||||
message AnimationOptions_Proto
|
||||
// This has to be kept in sync with AnimationOptions in animationstation.hpp
|
||||
message AnimationOptions
|
||||
{
|
||||
optional uint32 baseAnimationIndex = 1;
|
||||
optional uint32 brightness = 2;
|
||||
@@ -366,6 +366,17 @@ message AnimationOptions_Proto
|
||||
optional uint32 customThemeA1Pressed = 43;
|
||||
optional uint32 customThemeA2Pressed = 44;
|
||||
optional uint32 buttonPressColorCooldownTimeInMs = 45;
|
||||
optional uint32 ambientLightEffectsCountIndex = 46; // ambient count
|
||||
optional bool ambientLightCustomLinkageModeFlag = 47 [deprecated = true];
|
||||
optional uint32 ambientLightGradientSpeed = 48; // gradient speed
|
||||
optional int32 ambientLightChaseSpeed = 49; // chase speed
|
||||
optional float ambientLightBreathSpeed = 50; // breath speed
|
||||
optional float alGradientBrightnessCustomX = 51; // gradient brightness
|
||||
optional float alChaseBrightnessCustomX = 52; // chase brightness
|
||||
optional float alStaticColorBrightnessCustomX = 53; // static brightness
|
||||
optional float alStaticBrightnessCustomThemeX = 54; // static custom theme brightness
|
||||
optional uint32 alCustomStaticThemeIndex = 55; // custom theme index
|
||||
optional uint32 alCustomStaticColorIndex = 56; // static color index
|
||||
}
|
||||
|
||||
message BootselButtonOptions
|
||||
@@ -874,7 +885,7 @@ message Config
|
||||
optional KeyboardMapping keyboardMapping = 5;
|
||||
optional DisplayOptions displayOptions = 6;
|
||||
optional LEDOptions ledOptions = 7;
|
||||
optional AnimationOptions_Proto animationOptions = 8;
|
||||
optional AnimationOptions animationOptions = 8;
|
||||
optional AddonOptions addonOptions = 9;
|
||||
optional ForcedSetupOptions forcedSetupOptions = 10;
|
||||
optional ProfileOptions profileOptions = 11;
|
||||
|
||||
@@ -348,9 +348,40 @@ enum GamepadHotkey
|
||||
HOTKEY_MENU_NAV_SELECT = 48;
|
||||
HOTKEY_MENU_NAV_BACK = 49;
|
||||
HOTKEY_MENU_NAV_TOGGLE = 50;
|
||||
HOTKEY_LEDS_NONE = 51;
|
||||
HOTKEY_LEDS_ANIMATION_UP = 52;
|
||||
HOTKEY_LEDS_ANIMATION_DOWN = 53;
|
||||
HOTKEY_LEDS_PARAMETER_UP = 54;
|
||||
HOTKEY_LEDS_PRESS_PARAMETER_UP = 55;
|
||||
HOTKEY_LEDS_PRESS_PARAMETER_DOWN = 56;
|
||||
HOTKEY_LEDS_PARAMETER_DOWN = 57;
|
||||
HOTKEY_LEDS_BRIGHTNESS_UP = 58;
|
||||
HOTKEY_LEDS_BRIGHTNESS_DOWN = 59;
|
||||
HOTKEY_LEDS_FADETIME_UP = 60;
|
||||
HOTKEY_LEDS_FADETIME_DOWN = 61;
|
||||
HOTKEY_AMBIENT_LIGHT_EFFECTS_CHANGE = 62;
|
||||
HOTKEY_AMBIENT_LIGHT_EFFECTS_ON_OFF = 63;
|
||||
HOTKEY_AMBIENT_LIGHT_EFFECTS_BRIGHTNESS_UP = 64;
|
||||
HOTKEY_AMBIENT_LIGHT_EFFECTS_BRIGHTNESS_DOWN = 65;
|
||||
HOTKEY_AMBIENT_LIGHT_EFFECTS_PARAMETER_UP = 66;
|
||||
HOTKEY_AMBIENT_LIGHT_EFFECTS_PARAMETER_DOWN = 67;
|
||||
HOTKEY_AMBIENT_LIGHT_EFFECTS_FRAME_SPEED_UP = 68;
|
||||
HOTKEY_AMBIENT_LIGHT_EFFECTS_FRAME_SPEED_DOWN = 69;
|
||||
HOTKEY_AMBIENT_LIGHT_EFFECTS_CUSTOM_LINKAGE = 70;
|
||||
}
|
||||
|
||||
// This has to be kept in sync with LEDFormat in NeoPico.hpp
|
||||
enum AnimationEffects
|
||||
{
|
||||
option (nanopb_enumopt).long_names = false;
|
||||
|
||||
EFFECT_STATIC_COLOR = 0;
|
||||
EFFECT_RAINBOW = 1;
|
||||
EFFECT_CHASE = 2;
|
||||
EFFECT_STATIC_THEME = 3;
|
||||
EFFECT_CUSTOM_THEME = 4;
|
||||
}
|
||||
|
||||
// This has to be kept in sync with LEDFormat in NeoPico.h
|
||||
enum LEDFormat_Proto
|
||||
{
|
||||
LED_FORMAT_GRB = 0;
|
||||
@@ -381,7 +412,41 @@ enum CaseRGBType
|
||||
option (nanopb_enumopt).long_names = false;
|
||||
|
||||
CASE_RGB_TYPE_NONE = -1;
|
||||
CASE_RGB_TYPE_STATIC = 0;
|
||||
CASE_RGB_TYPE_AMBIENT = 0;
|
||||
CASE_RGB_TYPE_LINKED = 1;
|
||||
};
|
||||
|
||||
enum AmbientEffectType
|
||||
{
|
||||
option (nanopb_enumopt).long_names = false;
|
||||
|
||||
AL_CUSTOM_EFFECT_STATIC_COLOR = 0; // Static
|
||||
AL_CUSTOM_EFFECT_GRADIENT = 1; // Gradient Color
|
||||
AL_CUSTOM_EFFECT_CHASE = 2; // Chase
|
||||
AL_CUSTOM_EFFECT_BREATH = 3; // Breathing
|
||||
AL_CUSTOM_EFFECT_STATIC_THEME = 4; // Custom Static
|
||||
};
|
||||
|
||||
enum AnimationColor // Sync with Animation.h
|
||||
{
|
||||
option (nanopb_enumopt).long_names = false;
|
||||
|
||||
ANIMATION_COLOR_BLACK = 0;
|
||||
ANIMATION_COLOR_WHITE = 1;
|
||||
ANIMATION_COLOR_RED = 2;
|
||||
ANIMATION_COLOR_ORANGE = 3;
|
||||
ANIMATION_COLOR_YELLOW = 4;
|
||||
ANIMATION_COLOR_LIMEGREEN = 5;
|
||||
ANIMATION_COLOR_GREEN = 6;
|
||||
ANIMATION_COLOR_SEAFOAM = 7;
|
||||
ANIMATION_COLOR_AQUA = 8;
|
||||
ANIMATION_COLOR_SKYBLUE = 9;
|
||||
ANIMATION_COLOR_BLUE = 10;
|
||||
ANIMATION_COLOR_PURPLE = 11;
|
||||
ANIMATION_COLOR_PINK = 12;
|
||||
ANIMATION_COLOR_MAGENTA = 13;
|
||||
ANIMATION_COLOR_INDIGO = 14;
|
||||
ANIMATION_COLOR_VIOLET = 15;
|
||||
};
|
||||
|
||||
enum ForcedSetupMode
|
||||
|
||||
@@ -3,19 +3,38 @@
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2021 Jason Skuby (mytechtoybox.com)
|
||||
*/
|
||||
|
||||
#include "AnimationStation.hpp"
|
||||
#include "AnimationStorage.hpp"
|
||||
#include "NeoPico.hpp"
|
||||
#include "Pixel.hpp"
|
||||
#include "PlayerLEDs.h"
|
||||
#include "animationstation.h"
|
||||
#include "animationstorage.h"
|
||||
#include "storagemanager.h"
|
||||
#include "NeoPico.h"
|
||||
#include "pixel.h"
|
||||
#include "playerleds.h"
|
||||
#include "gp2040.h"
|
||||
#include "addons/neopicoleds.h"
|
||||
#include "addons/pleds.h"
|
||||
#include "themes.h"
|
||||
#include "usbdriver.h"
|
||||
#include "enums.h"
|
||||
#include "helper.h"
|
||||
|
||||
#define FRAME_MAX 100
|
||||
#define AL_ROW 5
|
||||
#define AL_COL 8
|
||||
#define AL_STATIC_COLOR_COUNT 14
|
||||
#define AL_EFFECT_MODE_MAX 5
|
||||
#define CHASE_LIGHTS_TURN_ON 4
|
||||
|
||||
const RGB alCustomStaticTheme[AL_ROW][AL_COL] =
|
||||
{{ColorRed, ColorOrange, ColorYellow, ColorGreen, ColorBlue, ColorIndigo, ColorViolet, ColorWhite},
|
||||
{ColorOrange, ColorRed, ColorGreen, ColorYellow, ColorIndigo, ColorBlue, ColorWhite, ColorViolet},
|
||||
{ColorYellow, ColorOrange, ColorRed, ColorIndigo, ColorBlue, ColorGreen, ColorViolet, ColorWhite},
|
||||
{ColorGreen, ColorOrange, ColorYellow, ColorRed, ColorWhite, ColorIndigo, ColorViolet, ColorBlue},
|
||||
{ColorWhite, ColorIndigo, ColorViolet, ColorOrange, ColorBlue, ColorGreen, ColorYellow, ColorRed},};
|
||||
|
||||
const RGB alCustomStaticColors[AL_STATIC_COLOR_COUNT] {
|
||||
ColorBlack, ColorWhite, ColorRed, ColorOrange, ColorYellow,
|
||||
ColorLimeGreen, ColorGreen, ColorSeafoam, ColorAqua, ColorSkyBlue,
|
||||
ColorBlue, ColorPurple, ColorPink, ColorMagenta };
|
||||
|
||||
const std::string BUTTON_LABEL_UP = "Up";
|
||||
const std::string BUTTON_LABEL_DOWN = "Down";
|
||||
const std::string BUTTON_LABEL_LEFT = "Left";
|
||||
@@ -196,15 +215,11 @@ bool NeoPicoLEDAddon::available() {
|
||||
return isValidPin(ledOptions.dataPin);
|
||||
}
|
||||
|
||||
void NeoPicoLEDAddon::setup()
|
||||
{
|
||||
void NeoPicoLEDAddon::setup() {
|
||||
// Set Default LED Options
|
||||
const LEDOptions& ledOptions = Storage::getInstance().getLedOptions();
|
||||
turnOffWhenSuspended = ledOptions.turnOffWhenSuspended;
|
||||
|
||||
// Get turbo options (turbo RGB led)
|
||||
const TurboOptions& turboOptions = Storage::getInstance().getAddonOptions().turboOptions;
|
||||
|
||||
// Setup our aux state player ID sensors
|
||||
Gamepad * gamepad = Storage::getInstance().GetProcessedGamepad();
|
||||
gamepad->auxState.playerID.enabled = true;
|
||||
gamepad->auxState.sensors.statusLight.enabled = true;
|
||||
@@ -213,30 +228,264 @@ void NeoPicoLEDAddon::setup()
|
||||
neoPLEDs = new NeoPicoPlayerLEDs();
|
||||
}
|
||||
|
||||
neopico = nullptr; // set neopico to null
|
||||
// Setup our LED matrix
|
||||
uint8_t buttonCount = setupButtonPositions();
|
||||
vector<vector<Pixel>> pixels = createLEDLayout(static_cast<ButtonLayout>(ledOptions.ledLayout), ledOptions.ledsPerButton, buttonCount);
|
||||
matrix.setup(pixels, ledOptions.ledsPerButton);
|
||||
ledCount = matrix.getLedCount();
|
||||
buttonLedCount = ledCount; // used in linkage
|
||||
|
||||
// Create a dummy Neo Pico for the initial configuration
|
||||
neopico = new NeoPico(-1, 0);
|
||||
configureLEDs();
|
||||
// Add Player LEDs to LED count
|
||||
if (ledOptions.pledType == PLED_TYPE_RGB && PLED_COUNT > 0)
|
||||
ledCount += PLED_COUNT;
|
||||
|
||||
// Add Turbo LED to LED Count
|
||||
const TurboOptions& turboOptions = Storage::getInstance().getAddonOptions().turboOptions;
|
||||
if (turboOptions.turboLedType == PLED_TYPE_RGB)
|
||||
ledCount += 1;
|
||||
|
||||
// Add Case RGB LEDs to LED Count
|
||||
if (ledOptions.caseRGBType != CASE_RGB_TYPE_NONE ) {
|
||||
ledCount += (int)ledOptions.caseRGBCount;
|
||||
}
|
||||
|
||||
// Setup NeoPico ws2812 PIO
|
||||
neopico.Setup(ledOptions.dataPin, ledCount, static_cast<LEDFormat>(ledOptions.ledFormat), pio0);
|
||||
neopico.Off(); // turn off everything
|
||||
|
||||
// Rewrite this
|
||||
Animation::format = static_cast<LEDFormat>(ledOptions.ledFormat);
|
||||
|
||||
// Configure Animation Station
|
||||
const AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
as.ConfigureBrightness(ledOptions.brightnessMaximum, ledOptions.brightnessSteps);
|
||||
as.SetMatrix(matrix);
|
||||
as.SetMode(animationOptions.baseAnimationIndex);
|
||||
as.SetBrightness(animationOptions.brightness);
|
||||
|
||||
// Next Run
|
||||
nextRunTime = make_timeout_time_ms(0); // Reset timeout
|
||||
|
||||
// Last Hot-key Action
|
||||
lastAmbientAction = HOTKEY_LEDS_NONE;
|
||||
|
||||
// Ambient lights
|
||||
alBrightnessBreathX = 1.00f;
|
||||
breathLedEffectCycle = 0;
|
||||
alReverse = false;
|
||||
alCurrentFrame = 0;
|
||||
alFrameToRGB = 0;
|
||||
alFrameSpeed = 2;
|
||||
ambientLight.r = 0x00;
|
||||
ambientLight.g = 0x00;
|
||||
ambientLight.b = 0x00;
|
||||
nextRunTimeAmbientLight = make_timeout_time_ms(0);
|
||||
|
||||
// Start of chase light index is case rgb index
|
||||
chaseLightIndex = ledOptions.caseRGBIndex;
|
||||
chaseLightMaxIndexPos = ledCount;
|
||||
|
||||
multipleOfButtonLedsCount = (ledOptions.caseRGBCount) / (buttonLedCount);
|
||||
remainderOfButtonLedsCount = (ledOptions.caseRGBCount) % (buttonLedCount);
|
||||
}
|
||||
|
||||
void NeoPicoLEDAddon::process()
|
||||
{
|
||||
void NeoPicoLEDAddon::ambientLightCustom() {
|
||||
const AnimationOptions& options = Storage::getInstance().getAnimationOptions();
|
||||
const LEDOptions& ledOptions = Storage::getInstance().getLedOptions();
|
||||
|
||||
uint8_t alStartIndex = ledOptions.caseRGBIndex;
|
||||
uint8_t multipleOfCustomStaticThemeCount;
|
||||
uint8_t remainderOfCustomStaticThemeCount;
|
||||
int maxFrame = (int)ledOptions.caseRGBCount;
|
||||
if ( maxFrame > FRAME_MAX - alStartIndex )
|
||||
maxFrame = FRAME_MAX - alStartIndex; // make sure we don't go over 100 and overflow frame[]
|
||||
|
||||
// Start-up Animations in Haute were here
|
||||
switch(options.ambientLightEffectsCountIndex) {
|
||||
case AL_CUSTOM_EFFECT_STATIC_COLOR:
|
||||
for(int i = 0; i < maxFrame; i++) {
|
||||
frame[alStartIndex + i] = alCustomStaticColors[options.alCustomStaticColorIndex].value(Animation::format, options.alStaticColorBrightnessCustomX);
|
||||
}
|
||||
break;
|
||||
|
||||
case AL_CUSTOM_EFFECT_GRADIENT:
|
||||
alFrameToRGB = 255 - alCurrentFrame; // From 0 -> 255 to 255 -> 0
|
||||
if(alFrameToRGB < 85) { // Less than 85, transitions from red to yellow. The red component starts at 255 and gradually decreases, the green component always reaches 0, and the blue component starts at 0 and increases gradually.
|
||||
ambientLight.r = 255 - alFrameToRGB * 3;
|
||||
ambientLight.g = 0;
|
||||
ambientLight.b = alFrameToRGB * 3;
|
||||
} else if(alFrameToRGB < 170) { // Between 85 and 170, there is a transition from yellow to cyan. The red component is always 0, the green component starts at 0 and gradually increases, and the blue component starts at 255 and gradually decreases.
|
||||
alFrameToRGB -= 85;
|
||||
ambientLight.r = 0;
|
||||
ambientLight.g = alFrameToRGB * 3;
|
||||
ambientLight.b = 255 - alFrameToRGB * 3;
|
||||
} else { // When greater than or equal to 170, it transitions from cyan to blue. The red component is always 0, the green component starts at 255 and gradually decreases, and the blue component starts at 0 and gradually increases.
|
||||
alFrameToRGB -= 170;
|
||||
ambientLight.r = alFrameToRGB * 3;
|
||||
ambientLight.g = 255 - alFrameToRGB * 3; // Power-on animation chase
|
||||
ambientLight.b = 0;
|
||||
}
|
||||
// Reverse color cycle if we hit the end of our cycle change
|
||||
if (alReverse) {
|
||||
alCurrentFrame -= options.ambientLightGradientSpeed;
|
||||
if(alCurrentFrame < 0) {
|
||||
alCurrentFrame = 1;
|
||||
alReverse = false;
|
||||
}
|
||||
} else {
|
||||
alCurrentFrame += options.ambientLightGradientSpeed;
|
||||
if(alCurrentFrame > 255) {
|
||||
alCurrentFrame = 254;
|
||||
alReverse = true;
|
||||
}
|
||||
}
|
||||
// Fill Frame
|
||||
for(int i = 0; i < maxFrame; i++){
|
||||
frame[alStartIndex + i] = ambientLight.value(Animation::format, options.alGradientBrightnessCustomX);
|
||||
}
|
||||
break;
|
||||
case AL_CUSTOM_EFFECT_CHASE:
|
||||
if(time_reached(nextRunTimeAmbientLight)){
|
||||
alFrameToRGB = 255 - alCurrentFrame; // 从 0 -> 255 变为 255 -> 0
|
||||
if(alFrameToRGB < 85) { // Less than 85, transitions from red to yellow. The red component starts at 255 and gradually decreases, the green component always reaches 0, and the blue component starts at 0 and increases gradually.
|
||||
ambientLight.r = 255 - alFrameToRGB * 3;
|
||||
ambientLight.g = 0;
|
||||
ambientLight.b = alFrameToRGB * 3;
|
||||
} else if (alFrameToRGB < 170) { // Between 85 and 170, there is a transition from yellow to cyan. The red component is always 0, the green component starts at 0 and gradually increases, and the blue component starts at 255 and gradually decreases.
|
||||
alFrameToRGB -= 85;
|
||||
ambientLight.r = 0;
|
||||
ambientLight.g = alFrameToRGB * 3;
|
||||
ambientLight.b = 255 - alFrameToRGB * 3;
|
||||
} else { // When greater than or equal to 170, it transitions from cyan to blue. The red component is always 0, the green component starts at 255 and gradually decreases, and the blue component starts at 0 and gradually increases.
|
||||
alFrameToRGB -= 170;
|
||||
ambientLight.r = alFrameToRGB * 3;
|
||||
ambientLight.g = 255 - alFrameToRGB * 3;
|
||||
ambientLight.b = 0;
|
||||
}
|
||||
if(alReverse) {
|
||||
alCurrentFrame -= alFrameSpeed;
|
||||
if(alCurrentFrame < 0) {
|
||||
alCurrentFrame = 1;
|
||||
alReverse = false;
|
||||
}
|
||||
} else {
|
||||
alCurrentFrame += alFrameSpeed;
|
||||
if(alCurrentFrame > 255) {
|
||||
alCurrentFrame = 254;
|
||||
alReverse = true;
|
||||
}
|
||||
}
|
||||
chaseLightIndex++;
|
||||
if(chaseLightIndex >= chaseLightMaxIndexPos) {
|
||||
chaseLightIndex = alStartIndex;
|
||||
}
|
||||
nextRunTimeAmbientLight = make_timeout_time_ms(options.ambientLightChaseSpeed);
|
||||
}
|
||||
// Blank out our caseRGBs
|
||||
for(int j = 0; j < maxFrame; j++){
|
||||
frame[alStartIndex + j] = 0x0;
|
||||
}
|
||||
// Fill up to four pixels forward
|
||||
for(int i = 0; i < CHASE_LIGHTS_TURN_ON && chaseLightIndex + i < chaseLightMaxIndexPos; i++) {
|
||||
frame[chaseLightIndex + i] = ambientLight.value(Animation::format, options.alChaseBrightnessCustomX);
|
||||
}
|
||||
// Fill up to 3 pixels in the beginning of our casergb (wrap-around)
|
||||
if ( chaseLightIndex + CHASE_LIGHTS_TURN_ON > chaseLightMaxIndexPos ) {
|
||||
for(int i = 0; i < (chaseLightIndex + CHASE_LIGHTS_TURN_ON) - chaseLightMaxIndexPos; i++) {
|
||||
frame[alStartIndex + i] = ambientLight.value(Animation::format, options.alChaseBrightnessCustomX);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AL_CUSTOM_EFFECT_BREATH:
|
||||
if(alReverse) {
|
||||
alBrightnessBreathX += options.ambientLightBreathSpeed;
|
||||
if(alBrightnessBreathX > 1.00f){
|
||||
alBrightnessBreathX = 1.00f;
|
||||
alReverse = false;
|
||||
}
|
||||
} else {
|
||||
alBrightnessBreathX -= options.ambientLightBreathSpeed;
|
||||
if(alBrightnessBreathX < 0.00f){
|
||||
alBrightnessBreathX = 0.00f;
|
||||
alReverse = true;
|
||||
breathLedEffectCycle++;
|
||||
}
|
||||
}
|
||||
|
||||
if(breathLedEffectCycle <= 1) {
|
||||
ambientLight.r = 255;
|
||||
ambientLight.g = 0;
|
||||
ambientLight.b = 255;
|
||||
} else if ((breathLedEffectCycle > 1) && (breathLedEffectCycle <= 3)) {
|
||||
ambientLight.r = 255;
|
||||
ambientLight.g = 0;
|
||||
ambientLight.b = 0;
|
||||
} else if ((breathLedEffectCycle > 3) && (breathLedEffectCycle <= 5)) {
|
||||
ambientLight.r = 0;
|
||||
ambientLight.g = 255;
|
||||
ambientLight.b = 0;
|
||||
} else if ((breathLedEffectCycle > 5) && (breathLedEffectCycle <= 7)) {
|
||||
ambientLight.r= 0;
|
||||
ambientLight.g = 0;
|
||||
ambientLight.b = 255;
|
||||
}
|
||||
else {
|
||||
breathLedEffectCycle = 0;
|
||||
}
|
||||
// Fill Frame
|
||||
for(int i = 0; i < maxFrame; i++) {
|
||||
frame[alStartIndex + i] = ambientLight.value(Animation::format, alBrightnessBreathX);
|
||||
}
|
||||
break;
|
||||
case AL_CUSTOM_EFFECT_STATIC_THEME:
|
||||
multipleOfCustomStaticThemeCount = maxFrame / AL_COL;
|
||||
remainderOfCustomStaticThemeCount = maxFrame % AL_COL;
|
||||
// Fill frame with extras on remainder
|
||||
for(int i = 0; i < multipleOfCustomStaticThemeCount; i++){
|
||||
for(int j = 0; j < AL_COL; j++){
|
||||
frame[alStartIndex + i*AL_COL + j] = alCustomStaticTheme[options.alCustomStaticThemeIndex][j].value(Animation::format, options.alStaticBrightnessCustomThemeX);
|
||||
}
|
||||
}
|
||||
if(remainderOfCustomStaticThemeCount != 0){
|
||||
for(int k = 0; k < remainderOfCustomStaticThemeCount; k++){
|
||||
frame[alStartIndex + multipleOfCustomStaticThemeCount * AL_COL + k] = alCustomStaticTheme[options.alCustomStaticThemeIndex][k].value(Animation::format, options.alStaticBrightnessCustomThemeX);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void NeoPicoLEDAddon::ambientLightLinkage() {
|
||||
const LEDOptions & ledOptions = Storage::getInstance().getLedOptions();
|
||||
uint8_t alLinkageStartIndex = ledOptions.caseRGBIndex;
|
||||
float preLinkageBrightnessX = as.GetLinkageModeOfBrightnessX();
|
||||
for(int i = 0; i < multipleOfButtonLedsCount; i++){ // Repeat buttons
|
||||
for(int j = 0; j < buttonLedCount; j++){
|
||||
frame[alLinkageStartIndex + i*buttonLedCount + j] = as.linkageFrame[j].value(Animation::format, preLinkageBrightnessX);
|
||||
}
|
||||
}
|
||||
|
||||
if(remainderOfButtonLedsCount != 0){ // Remainder
|
||||
for(int k = 0; k < remainderOfButtonLedsCount; k++){
|
||||
frame[alLinkageStartIndex + multipleOfButtonLedsCount * buttonLedCount + k] = as.linkageFrame[k].value(Animation::format, preLinkageBrightnessX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NeoPicoLEDAddon::process() {
|
||||
const LEDOptions& ledOptions = Storage::getInstance().getLedOptions();
|
||||
if (!isValidPin(ledOptions.dataPin) || !time_reached(this->nextRunTime))
|
||||
return;
|
||||
|
||||
// Get turbo options (turbo RGB led)
|
||||
const TurboOptions& turboOptions = Storage::getInstance().getAddonOptions().turboOptions;
|
||||
|
||||
Gamepad * gamepad = Storage::getInstance().GetProcessedGamepad();
|
||||
AnimationHotkey action = animationHotkeys(gamepad);
|
||||
GamepadHotkey action = animationHotkeys(gamepad);
|
||||
if (ledOptions.pledType == PLED_TYPE_RGB) {
|
||||
inputMode = gamepad->getOptions().inputMode; // HACK
|
||||
if (gamepad->auxState.playerID.enabled && gamepad->auxState.playerID.active) {
|
||||
switch (inputMode) {
|
||||
switch (gamepad->getOptions().inputMode) {
|
||||
case INPUT_MODE_XINPUT:
|
||||
animationState = getXInputAnimationNEOPICO(gamepad->auxState.playerID.ledValue);
|
||||
break;
|
||||
@@ -279,15 +528,17 @@ void NeoPicoLEDAddon::process()
|
||||
else
|
||||
as.ClearPressed();
|
||||
|
||||
// Animation Station calls Effect
|
||||
as.Animate();
|
||||
|
||||
if (turnOffWhenSuspended && get_usb_suspended()) {
|
||||
if (ledOptions.turnOffWhenSuspended && get_usb_suspended()) {
|
||||
as.DimBrightnessTo0();
|
||||
} else {
|
||||
as.SetBrightness(AnimationStation::GetBrightness());
|
||||
as.SetBrightness(as.GetBrightness());
|
||||
}
|
||||
|
||||
as.ApplyBrightness(frame);
|
||||
// Copy Animation Station to NeoPico w/ Brightness Modification
|
||||
as.ApplyBrightness(&frame[0]);
|
||||
|
||||
// Apply the player LEDs to our first 4 leds if we're in NEOPIXEL mode
|
||||
if (ledOptions.pledType == PLED_TYPE_RGB) {
|
||||
@@ -299,9 +550,9 @@ void NeoPicoLEDAddon::process()
|
||||
float level = (static_cast<float>(PLED_MAX_LEVEL - neoPLEDs->getLedLevels()[i]) / static_cast<float>(PLED_MAX_LEVEL));
|
||||
float brightness = as.GetBrightnessX() * level;
|
||||
if (gamepad->auxState.sensors.statusLight.enabled && gamepad->auxState.sensors.statusLight.active) {
|
||||
rgbPLEDValues[i] = (RGB(gamepad->auxState.sensors.statusLight.color.red, gamepad->auxState.sensors.statusLight.color.green, gamepad->auxState.sensors.statusLight.color.blue)).value(neopico->GetFormat(), brightness);
|
||||
rgbPLEDValues[i] = (RGB(gamepad->auxState.sensors.statusLight.color.red, gamepad->auxState.sensors.statusLight.color.green, gamepad->auxState.sensors.statusLight.color.blue)).value(neopico.GetFormat(), brightness);
|
||||
} else {
|
||||
rgbPLEDValues[i] = ((RGB)ledOptions.pledColor).value(neopico->GetFormat(), brightness);
|
||||
rgbPLEDValues[i] = ((RGB)ledOptions.pledColor).value(neopico.GetFormat(), brightness);
|
||||
}
|
||||
frame[pledIndexes[i]] = rgbPLEDValues[i];
|
||||
}
|
||||
@@ -312,27 +563,27 @@ void NeoPicoLEDAddon::process()
|
||||
if ( gamepad->auxState.turbo.activity == 1) { // Turbo is on (active sensor)
|
||||
if (turboOptions.turboLedIndex >= 0 && turboOptions.turboLedIndex < 100) { // Double check index value
|
||||
float brightness = as.GetBrightnessX();
|
||||
frame[turboOptions.turboLedIndex] = ((RGB)turboOptions.turboLedColor).value(neopico->GetFormat(), brightness);
|
||||
frame[turboOptions.turboLedIndex] = ((RGB)turboOptions.turboLedColor).value(neopico.GetFormat(), brightness);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Case RGB LEDs for a single static color go here
|
||||
if ( ledOptions.caseRGBType == CASE_RGB_TYPE_STATIC &&
|
||||
ledOptions.caseRGBIndex >= 0 &&
|
||||
ledOptions.caseRGBCount > 0 ) {
|
||||
float brightness = as.GetBrightnessX();
|
||||
uint32_t colorVal = ((RGB)ledOptions.caseRGBColor).value(neopico->GetFormat(), brightness);
|
||||
for(int i = 0; i < ledOptions.caseRGBCount; i++) {
|
||||
frame[ledOptions.caseRGBIndex+i] = colorVal;
|
||||
}
|
||||
}
|
||||
if ( ledOptions.caseRGBIndex >= 0 &&
|
||||
ledOptions.caseRGBCount > 0 ) {
|
||||
ambientHotkeys(gamepad);
|
||||
if ( ledOptions.caseRGBType == CASE_RGB_TYPE_AMBIENT ) {
|
||||
this->ambientLightCustom();
|
||||
} else if ( ledOptions.caseRGBType == CASE_RGB_TYPE_LINKED ) {
|
||||
this->ambientLightLinkage(); //Custom mode
|
||||
}
|
||||
}
|
||||
|
||||
neopico->SetFrame(frame);
|
||||
neopico->Show();
|
||||
AnimationStore.save();
|
||||
|
||||
this->nextRunTime = make_timeout_time_ms(NeoPicoLEDAddon::intervalMS);
|
||||
neopico.SetFrame(frame); // this might have been a thing before?
|
||||
neopico.Show();
|
||||
//Storage::getInstance().save(false);
|
||||
//AnimationStore.save();
|
||||
this->nextRunTime = make_timeout_time_ms(intervalMS);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> * NeoPicoLEDAddon::getLEDPositions(string button, std::vector<std::vector<uint8_t>> *positions)
|
||||
@@ -617,42 +868,9 @@ uint8_t NeoPicoLEDAddon::setupButtonPositions()
|
||||
return buttonCount;
|
||||
}
|
||||
|
||||
void NeoPicoLEDAddon::configureLEDs()
|
||||
GamepadHotkey NeoPicoLEDAddon::animationHotkeys(Gamepad *gamepad)
|
||||
{
|
||||
const LEDOptions& ledOptions = Storage::getInstance().getLedOptions();
|
||||
const TurboOptions& turboOptions = Storage::getInstance().getAddonOptions().turboOptions;
|
||||
uint8_t buttonCount = setupButtonPositions();
|
||||
vector<vector<Pixel>> pixels = createLEDLayout(static_cast<ButtonLayout>(ledOptions.ledLayout), ledOptions.ledsPerButton, buttonCount);
|
||||
matrix.setup(pixels, ledOptions.ledsPerButton);
|
||||
ledCount = matrix.getLedCount();
|
||||
if (ledOptions.pledType == PLED_TYPE_RGB && PLED_COUNT > 0)
|
||||
ledCount += PLED_COUNT;
|
||||
|
||||
if (turboOptions.turboLedType == PLED_TYPE_RGB)
|
||||
ledCount += 1;
|
||||
|
||||
if (ledOptions.caseRGBType == CASE_RGB_TYPE_STATIC ) {
|
||||
ledCount += ledOptions.caseRGBCount;
|
||||
}
|
||||
|
||||
// Remove the old neopico (config can call this)
|
||||
delete neopico;
|
||||
neopico = new NeoPico(ledOptions.dataPin, ledCount, static_cast<LEDFormat>(ledOptions.ledFormat));
|
||||
neopico->Off();
|
||||
|
||||
Animation::format = static_cast<LEDFormat>(ledOptions.ledFormat);
|
||||
as.ConfigureBrightness(ledOptions.brightnessMaximum, ledOptions.brightnessSteps);
|
||||
AnimationOptions animationOptions = AnimationStore.getAnimationOptions();
|
||||
addStaticThemes(ledOptions, animationOptions);
|
||||
as.SetOptions(animationOptions);
|
||||
as.SetMatrix(matrix);
|
||||
as.SetMode(as.options.baseAnimationIndex);
|
||||
}
|
||||
|
||||
AnimationHotkey animationHotkeys(Gamepad *gamepad)
|
||||
{
|
||||
AnimationHotkey action = HOTKEY_LEDS_NONE;
|
||||
|
||||
GamepadHotkey action = HOTKEY_LEDS_NONE;
|
||||
if (gamepad->pressedS1() && gamepad->pressedS2())
|
||||
{
|
||||
if (gamepad->pressedB3())
|
||||
@@ -706,6 +924,177 @@ AnimationHotkey animationHotkeys(Gamepad *gamepad)
|
||||
gamepad->state.buttons &= ~(GAMEPAD_MASK_R3 | GAMEPAD_MASK_S1 | GAMEPAD_MASK_S2);
|
||||
}
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
void NeoPicoLEDAddon::ambientHotkeys(Gamepad *gamepad)
|
||||
{
|
||||
bool reqSave = false;
|
||||
GamepadHotkey action = HOTKEY_LEDS_NONE;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
LEDOptions & ledOptions = Storage::getInstance().getLedOptions();
|
||||
|
||||
// Only allow Start + Key Ambient Changes if Case RGB is enabled
|
||||
if(gamepad->pressedS2() && (gamepad->pressedS1() == false)) // start (not start+back)
|
||||
{
|
||||
if(gamepad->pressedL1()) { // LB
|
||||
action = HOTKEY_AMBIENT_LIGHT_EFFECTS_CHANGE;
|
||||
gamepad->state.buttons &= ~(GAMEPAD_MASK_L1 | GAMEPAD_MASK_S2);
|
||||
if (lastAmbientAction != action ) {
|
||||
// Ambient changes are all done inside of neopico instead of animation station?
|
||||
animationOptions.ambientLightEffectsCountIndex++;
|
||||
if(animationOptions.ambientLightEffectsCountIndex > AL_EFFECT_MODE_MAX - 1){
|
||||
animationOptions.ambientLightEffectsCountIndex = 0;
|
||||
}
|
||||
// Reset our ambient light RGB
|
||||
ambientLight.r = 0x00;
|
||||
ambientLight.g = 0x00;
|
||||
ambientLight.b = 0x00;
|
||||
alCurrentFrame = 0;
|
||||
alFrameToRGB = 0;
|
||||
alReverse = false;
|
||||
chaseLightIndex = ledOptions.caseRGBIndex;
|
||||
alBrightnessBreathX = 1.00f;
|
||||
breathLedEffectCycle = 0;
|
||||
reqSave = true;
|
||||
}
|
||||
} else if (gamepad->pressedL2()) { // LT (Different from COSMOX, we just cycle instead of temporary disable)
|
||||
action = HOTKEY_AMBIENT_LIGHT_EFFECTS_ON_OFF;
|
||||
if (lastAmbientAction != action ) {
|
||||
// Move the other way
|
||||
if(animationOptions.ambientLightEffectsCountIndex == 0 )
|
||||
animationOptions.ambientLightEffectsCountIndex = AL_EFFECT_MODE_MAX - 1;
|
||||
else
|
||||
animationOptions.ambientLightEffectsCountIndex--;
|
||||
// Reset our ambient light RGB
|
||||
ambientLight.r = 0x00;
|
||||
ambientLight.g = 0x00;
|
||||
ambientLight.b = 0x00;
|
||||
alCurrentFrame = 0;
|
||||
alFrameToRGB = 0;
|
||||
alReverse = false;
|
||||
chaseLightIndex = ledOptions.caseRGBIndex;
|
||||
alBrightnessBreathX = 1.00f;
|
||||
breathLedEffectCycle = 0;
|
||||
reqSave = true;
|
||||
}
|
||||
// turn off brightness for ambient lights
|
||||
gamepad->state.buttons &= ~(GAMEPAD_MASK_L2 | GAMEPAD_MASK_S2);
|
||||
} else if (gamepad->pressedB4() && (gamepad->pressedB3() == false)) { // Y not X+Y
|
||||
action = HOTKEY_AMBIENT_LIGHT_EFFECTS_BRIGHTNESS_UP;
|
||||
if ( lastAmbientAction != action ) {
|
||||
float customBrightnessStep = 1.0f / as.GetBrightnessSteps();
|
||||
if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_CHASE ) {
|
||||
animationOptions.alChaseBrightnessCustomX = min(animationOptions.alChaseBrightnessCustomX+customBrightnessStep, 1.00f);
|
||||
} else if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_GRADIENT ) {
|
||||
animationOptions.alGradientBrightnessCustomX = min(animationOptions.alGradientBrightnessCustomX+customBrightnessStep, 1.00f);
|
||||
} else if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_STATIC_COLOR ) {
|
||||
animationOptions.alStaticColorBrightnessCustomX = min(animationOptions.alStaticColorBrightnessCustomX+customBrightnessStep, 1.00f);
|
||||
} else if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_STATIC_THEME ) {
|
||||
animationOptions.alStaticBrightnessCustomThemeX = min(animationOptions.alStaticBrightnessCustomThemeX+customBrightnessStep, 1.00f);
|
||||
} // do nothing for breath
|
||||
|
||||
reqSave = true;
|
||||
}
|
||||
gamepad->state.buttons &= ~(GAMEPAD_MASK_B4 | GAMEPAD_MASK_S2);
|
||||
} else if (gamepad->pressedB2()) { // B
|
||||
action = HOTKEY_AMBIENT_LIGHT_EFFECTS_BRIGHTNESS_DOWN;
|
||||
if ( lastAmbientAction != action ) {
|
||||
float customBrightnessStep = 1.0f / as.GetBrightnessSteps();
|
||||
if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_CHASE ) {
|
||||
animationOptions.alChaseBrightnessCustomX = max(animationOptions.alChaseBrightnessCustomX-customBrightnessStep, 0.00f);
|
||||
} else if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_GRADIENT ) {
|
||||
animationOptions.alGradientBrightnessCustomX = max(animationOptions.alGradientBrightnessCustomX-customBrightnessStep, 0.00f);
|
||||
} else if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_STATIC_COLOR ) {
|
||||
animationOptions.alStaticColorBrightnessCustomX = max(animationOptions.alStaticColorBrightnessCustomX-customBrightnessStep, 0.00f);
|
||||
} else if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_STATIC_THEME ) {
|
||||
animationOptions.alStaticBrightnessCustomThemeX = max(animationOptions.alStaticBrightnessCustomThemeX-customBrightnessStep, 0.00f);
|
||||
} // do nothing for breath
|
||||
reqSave = true;
|
||||
}
|
||||
gamepad->state.buttons &= ~(GAMEPAD_MASK_B2 | GAMEPAD_MASK_S2);
|
||||
} else if (gamepad->pressedR1()) { // RB
|
||||
action = HOTKEY_AMBIENT_LIGHT_EFFECTS_PARAMETER_UP;
|
||||
if ( lastAmbientAction != action ) {
|
||||
if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_STATIC_COLOR ) {
|
||||
animationOptions.alCustomStaticColorIndex++;
|
||||
if (animationOptions.alCustomStaticColorIndex > AL_STATIC_COLOR_COUNT - 1){
|
||||
animationOptions.alCustomStaticColorIndex = 0; // loop
|
||||
}
|
||||
} else if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_STATIC_THEME ) {
|
||||
animationOptions.alCustomStaticThemeIndex++;
|
||||
if (animationOptions.alCustomStaticThemeIndex > AL_ROW - 1){
|
||||
animationOptions.alCustomStaticThemeIndex = 0; // loop
|
||||
}
|
||||
}
|
||||
reqSave = true;
|
||||
}
|
||||
gamepad->state.buttons &= ~(GAMEPAD_MASK_R1 | GAMEPAD_MASK_S2);
|
||||
} else if (gamepad->pressedR2()) { // RT
|
||||
action = HOTKEY_AMBIENT_LIGHT_EFFECTS_PARAMETER_DOWN;
|
||||
if ( lastAmbientAction != action ) {
|
||||
if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_STATIC_COLOR ) {
|
||||
if (animationOptions.alCustomStaticColorIndex == 0 ) {
|
||||
animationOptions.alCustomStaticColorIndex = AL_STATIC_COLOR_COUNT - 1;
|
||||
} else {
|
||||
animationOptions.alCustomStaticColorIndex--;
|
||||
}
|
||||
} else if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_STATIC_THEME ) {
|
||||
if (animationOptions.alCustomStaticThemeIndex == 0 ) {
|
||||
animationOptions.alCustomStaticThemeIndex = AL_ROW - 1;
|
||||
} else {
|
||||
animationOptions.alCustomStaticThemeIndex--;
|
||||
}
|
||||
}
|
||||
reqSave = true;
|
||||
}
|
||||
gamepad->state.buttons &= ~(GAMEPAD_MASK_R2 | GAMEPAD_MASK_S2);
|
||||
} else if (gamepad->pressedL3()) { // LS
|
||||
action = HOTKEY_AMBIENT_LIGHT_EFFECTS_FRAME_SPEED_UP;
|
||||
if ( lastAmbientAction != action ) {
|
||||
if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_GRADIENT ) {
|
||||
animationOptions.ambientLightGradientSpeed = min(animationOptions.ambientLightGradientSpeed+1,(uint32_t)6);
|
||||
} else if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_CHASE ) {
|
||||
animationOptions.ambientLightChaseSpeed = max(animationOptions.ambientLightChaseSpeed-20,(int32_t)0);
|
||||
} else if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_BREATH ) {
|
||||
animationOptions.ambientLightBreathSpeed = min(animationOptions.ambientLightBreathSpeed+0.01f,0.05f);
|
||||
}
|
||||
reqSave = true;
|
||||
}
|
||||
gamepad->state.buttons &= ~(GAMEPAD_MASK_L3 | GAMEPAD_MASK_S2);
|
||||
} else if (gamepad->pressedR3()) { // RS
|
||||
action = HOTKEY_AMBIENT_LIGHT_EFFECTS_FRAME_SPEED_DOWN;
|
||||
if ( lastAmbientAction != action ) {
|
||||
if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_GRADIENT ) {
|
||||
animationOptions.ambientLightGradientSpeed = max(animationOptions.ambientLightGradientSpeed-1,(uint32_t)1);
|
||||
} else if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_CHASE ) {
|
||||
animationOptions.ambientLightChaseSpeed = min(animationOptions.ambientLightChaseSpeed+20,(int32_t)100);
|
||||
} else if ( animationOptions.ambientLightEffectsCountIndex == AL_CUSTOM_EFFECT_BREATH ) {
|
||||
animationOptions.ambientLightBreathSpeed = max(animationOptions.ambientLightBreathSpeed-0.01f,0.01f);
|
||||
}
|
||||
reqSave = true;
|
||||
}
|
||||
gamepad->state.buttons &= ~(GAMEPAD_MASK_R3 | GAMEPAD_MASK_S2);
|
||||
} else if (gamepad->pressedB1() && gamepad->pressedB3()) { // A + X
|
||||
// Cycle through off, ambient, and linked
|
||||
action = HOTKEY_AMBIENT_LIGHT_EFFECTS_CUSTOM_LINKAGE;
|
||||
if ( lastAmbientAction != action ) {
|
||||
if ( ledOptions.caseRGBType == CASE_RGB_TYPE_AMBIENT ) {
|
||||
ledOptions.caseRGBType = CASE_RGB_TYPE_LINKED;
|
||||
} else if ( ledOptions.caseRGBType == CASE_RGB_TYPE_LINKED ) {
|
||||
ledOptions.caseRGBType = CASE_RGB_TYPE_NONE;
|
||||
} else if ( ledOptions.caseRGBType == CASE_RGB_TYPE_NONE ) {
|
||||
ledOptions.caseRGBType = CASE_RGB_TYPE_AMBIENT;
|
||||
}
|
||||
reqSave = true;
|
||||
}
|
||||
gamepad->state.buttons &= ~(GAMEPAD_MASK_B1 | GAMEPAD_MASK_B3 | GAMEPAD_MASK_S2);
|
||||
}
|
||||
}
|
||||
|
||||
if (reqSave) {
|
||||
EventManager::getInstance().triggerEvent(new GPStorageSaveEvent(true));
|
||||
}
|
||||
|
||||
lastAmbientAction = action;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "Animation.hpp"
|
||||
|
||||
#include "AnimationStation.hpp"
|
||||
#include "animation.h"
|
||||
#include "animationstation.h"
|
||||
#include "storagemanager.h"
|
||||
|
||||
#define PRESS_COOLDOWN_INCREMENT 500
|
||||
#define PRESS_COOLDOWN_MAX 5000
|
||||
@@ -26,7 +26,8 @@ void Animation::UpdatePixels(std::vector<Pixel> inpixels) {
|
||||
}
|
||||
|
||||
void Animation::UpdateTime() {
|
||||
coolDownTimeInMs = AnimationStation::options.buttonPressColorCooldownTimeInMs;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
coolDownTimeInMs = animationOptions.buttonPressColorCooldownTimeInMs;
|
||||
|
||||
absolute_time_t currentTime = get_absolute_time();
|
||||
updateTimeInMs = absolute_time_diff_us(lastUpdateTime, currentTime) / 1000;
|
||||
@@ -90,17 +91,19 @@ RGB Animation::BlendColor(RGB start, RGB end, uint32_t timeRemainingInMs) {
|
||||
|
||||
|
||||
void Animation::FadeTimeUp() {
|
||||
AnimationStation::options.buttonPressColorCooldownTimeInMs = AnimationStation::options.buttonPressColorCooldownTimeInMs + PRESS_COOLDOWN_INCREMENT;
|
||||
AnimationOptions & anmationOptions = Storage::getInstance().getAnimationOptions();
|
||||
anmationOptions.buttonPressColorCooldownTimeInMs = anmationOptions.buttonPressColorCooldownTimeInMs + PRESS_COOLDOWN_INCREMENT;
|
||||
|
||||
if (AnimationStation::options.buttonPressColorCooldownTimeInMs > PRESS_COOLDOWN_MAX) {
|
||||
AnimationStation::options.buttonPressColorCooldownTimeInMs = PRESS_COOLDOWN_MAX;
|
||||
if (anmationOptions.buttonPressColorCooldownTimeInMs > PRESS_COOLDOWN_MAX) {
|
||||
anmationOptions.buttonPressColorCooldownTimeInMs = PRESS_COOLDOWN_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
void Animation::FadeTimeDown() {
|
||||
AnimationStation::options.buttonPressColorCooldownTimeInMs = AnimationStation::options.buttonPressColorCooldownTimeInMs - PRESS_COOLDOWN_INCREMENT;
|
||||
AnimationOptions & anmationOptions = Storage::getInstance().getAnimationOptions();
|
||||
anmationOptions.buttonPressColorCooldownTimeInMs = anmationOptions.buttonPressColorCooldownTimeInMs - PRESS_COOLDOWN_INCREMENT;
|
||||
|
||||
if (AnimationStation::options.buttonPressColorCooldownTimeInMs > PRESS_COOLDOWN_MAX) {
|
||||
AnimationStation::options.buttonPressColorCooldownTimeInMs = PRESS_COOLDOWN_MIN;
|
||||
if (anmationOptions.buttonPressColorCooldownTimeInMs > PRESS_COOLDOWN_MAX) {
|
||||
anmationOptions.buttonPressColorCooldownTimeInMs = PRESS_COOLDOWN_MIN;
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,23 @@
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "AnimationStation.hpp"
|
||||
|
||||
uint8_t AnimationStation::brightnessMax = 100;
|
||||
uint8_t AnimationStation::brightnessSteps = 5;
|
||||
float AnimationStation::brightnessX = 0;
|
||||
absolute_time_t AnimationStation::nextChange = nil_time;
|
||||
AnimationOptions AnimationStation::options = {};
|
||||
uint8_t AnimationStation::effectCount = TOTAL_EFFECTS;
|
||||
#include "animationstation.h"
|
||||
#include "animationstorage.h"
|
||||
|
||||
#include "storagemanager.h"
|
||||
|
||||
AnimationStation::AnimationStation() {
|
||||
AnimationStation::SetBrightness(1);
|
||||
brightnessMax = 100;
|
||||
brightnessSteps = 5;
|
||||
brightnessX = 0;
|
||||
linkageModeOfBrightnessX = 0;
|
||||
nextChange = nil_time;
|
||||
effectCount = TOTAL_EFFECTS;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (animationOptions.hasCustomTheme) {
|
||||
effectCount++; // increase our effect count
|
||||
}
|
||||
SetBrightness(1);
|
||||
}
|
||||
|
||||
void AnimationStation::ConfigureBrightness(uint8_t max, uint8_t steps) {
|
||||
@@ -24,57 +29,71 @@ void AnimationStation::ConfigureBrightness(uint8_t max, uint8_t steps) {
|
||||
brightnessSteps = steps;
|
||||
}
|
||||
|
||||
void AnimationStation::HandleEvent(AnimationHotkey action) {
|
||||
if (action == HOTKEY_LEDS_NONE || !time_reached(AnimationStation::nextChange)) {
|
||||
void AnimationStation::HandleEvent(GamepadHotkey action) {
|
||||
if (action == HOTKEY_LEDS_NONE || !time_reached(nextChange) ) {
|
||||
return;
|
||||
}
|
||||
AnimationStation::nextChange = make_timeout_time_ms(250);
|
||||
nextChange = make_timeout_time_ms(250);
|
||||
AnimationOptions hotkeyAnimationOptions = Storage::getInstance().getAnimationOptions();
|
||||
bool reqSave = false;
|
||||
|
||||
if (action == HOTKEY_LEDS_BRIGHTNESS_UP) {
|
||||
AnimationStation::IncreaseBrightness();
|
||||
IncreaseBrightness();
|
||||
reqSave = true;
|
||||
}
|
||||
|
||||
if (action == HOTKEY_LEDS_BRIGHTNESS_DOWN) {
|
||||
AnimationStation::DecreaseBrightness();
|
||||
DecreaseBrightness();
|
||||
reqSave = true;
|
||||
}
|
||||
|
||||
if (action == HOTKEY_LEDS_ANIMATION_UP) {
|
||||
ChangeAnimation(1);
|
||||
reqSave = true;
|
||||
}
|
||||
|
||||
if (action == HOTKEY_LEDS_ANIMATION_DOWN) {
|
||||
ChangeAnimation(-1);
|
||||
reqSave = true;
|
||||
}
|
||||
|
||||
|
||||
if (this->baseAnimation == nullptr || this->buttonAnimation == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (action == HOTKEY_LEDS_PARAMETER_UP) {
|
||||
this->baseAnimation->ParameterUp();
|
||||
reqSave = true;
|
||||
}
|
||||
|
||||
if (action == HOTKEY_LEDS_PARAMETER_DOWN) {
|
||||
this->baseAnimation->ParameterDown();
|
||||
reqSave = true;
|
||||
}
|
||||
|
||||
if (action == HOTKEY_LEDS_PRESS_PARAMETER_UP) {
|
||||
this->buttonAnimation->ParameterUp();
|
||||
reqSave = true;
|
||||
}
|
||||
|
||||
if (action == HOTKEY_LEDS_PRESS_PARAMETER_DOWN) {
|
||||
this->buttonAnimation->ParameterDown();
|
||||
reqSave = true;
|
||||
}
|
||||
|
||||
if (action == HOTKEY_LEDS_FADETIME_UP) {
|
||||
this->baseAnimation->FadeTimeUp();
|
||||
reqSave = true;
|
||||
}
|
||||
|
||||
if (action == HOTKEY_LEDS_FADETIME_DOWN) {
|
||||
this->baseAnimation->FadeTimeDown();
|
||||
}
|
||||
|
||||
reqSave = true;
|
||||
}
|
||||
|
||||
if (reqSave) {
|
||||
EventManager::getInstance().triggerEvent(new GPStorageSaveEvent(true));
|
||||
}
|
||||
}
|
||||
|
||||
void AnimationStation::ChangeAnimation(int changeSize) {
|
||||
@@ -82,14 +101,16 @@ void AnimationStation::ChangeAnimation(int changeSize) {
|
||||
}
|
||||
|
||||
uint16_t AnimationStation::AdjustIndex(int changeSize) {
|
||||
int newIndex = (int)this->options.baseAnimationIndex + changeSize;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
|
||||
if (newIndex >= AnimationStation::effectCount) {
|
||||
int newIndex = animationOptions.baseAnimationIndex + changeSize;
|
||||
|
||||
if (newIndex >= effectCount) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (newIndex < 0) {
|
||||
return (AnimationStation::effectCount - 1);
|
||||
return (effectCount - 1);
|
||||
}
|
||||
|
||||
return (uint16_t)newIndex;
|
||||
@@ -119,25 +140,35 @@ void AnimationStation::Animate() {
|
||||
}
|
||||
|
||||
baseAnimation->Animate(this->frame);
|
||||
|
||||
// Copy frame to linkage frame before button press
|
||||
memcpy(linkageFrame, frame, sizeof(RGB)*100);
|
||||
|
||||
buttonAnimation->Animate(this->frame);
|
||||
}
|
||||
|
||||
void AnimationStation::Clear() { memset(frame, 0, sizeof(frame)); }
|
||||
void AnimationStation::Clear() {
|
||||
memset(frame, 0, sizeof(frame));
|
||||
}
|
||||
|
||||
float AnimationStation::GetBrightnessX() {
|
||||
return AnimationStation::brightnessX;
|
||||
return brightnessX;
|
||||
}
|
||||
|
||||
float AnimationStation::GetLinkageModeOfBrightnessX() {
|
||||
return linkageModeOfBrightnessX;
|
||||
}
|
||||
|
||||
uint8_t AnimationStation::GetBrightness() {
|
||||
return AnimationStation::options.brightness;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
return animationOptions.brightness;
|
||||
}
|
||||
|
||||
uint8_t AnimationStation::GetMode() { return this->options.baseAnimationIndex; }
|
||||
|
||||
void AnimationStation::SetMode(uint8_t mode) {
|
||||
this->options.baseAnimationIndex = mode;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
animationOptions.baseAnimationIndex = mode;
|
||||
AnimationEffects newEffect =
|
||||
static_cast<AnimationEffects>(this->options.baseAnimationIndex);
|
||||
static_cast<AnimationEffects>(animationOptions.baseAnimationIndex);
|
||||
|
||||
if (this->baseAnimation != nullptr) {
|
||||
delete this->baseAnimation;
|
||||
@@ -176,40 +207,43 @@ void AnimationStation::SetMatrix(PixelMatrix matrix) {
|
||||
this->matrix = matrix;
|
||||
}
|
||||
|
||||
void AnimationStation::SetOptions(AnimationOptions options) {
|
||||
AnimationStation::options = options;
|
||||
AnimationStation::SetBrightness(options.brightness);
|
||||
}
|
||||
|
||||
void AnimationStation::ApplyBrightness(uint32_t *frameValue) {
|
||||
for (int i = 0; i < 100; i++)
|
||||
frameValue[i] = this->frame[i].value(Animation::format, brightnessX);
|
||||
}
|
||||
|
||||
void AnimationStation::SetBrightness(uint8_t brightness) {
|
||||
AnimationStation::options.brightness =
|
||||
(brightness > brightnessSteps) ? brightnessSteps : options.brightness;
|
||||
AnimationStation::brightnessX =
|
||||
(AnimationStation::options.brightness * getBrightnessStepSize()) / 255.0F;
|
||||
|
||||
if (AnimationStation::brightnessX > 1)
|
||||
AnimationStation::brightnessX = 1;
|
||||
else if (AnimationStation::brightnessX < 0)
|
||||
AnimationStation::brightnessX = 0;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
animationOptions.brightness =
|
||||
(brightness > brightnessSteps) ? brightnessSteps : brightness;
|
||||
brightnessX =
|
||||
(animationOptions.brightness * getBrightnessStepSize()) / 255.0F;
|
||||
linkageModeOfBrightnessX =
|
||||
(animationOptions.brightness * getLinkageModeOfBrightnessStepSize()) / 255.0F;
|
||||
if (linkageModeOfBrightnessX > 1)
|
||||
linkageModeOfBrightnessX = 1;
|
||||
else if (linkageModeOfBrightnessX < 0)
|
||||
linkageModeOfBrightnessX = 0;
|
||||
if (brightnessX > 1.0f)
|
||||
brightnessX = 1.0f;
|
||||
else if (brightnessX < 0.0f)
|
||||
brightnessX = 0.0f;
|
||||
}
|
||||
|
||||
void AnimationStation::DecreaseBrightness() {
|
||||
if (AnimationStation::options.brightness > 0)
|
||||
AnimationStation::SetBrightness(--AnimationStation::options.brightness);
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (animationOptions.brightness > 0)
|
||||
SetBrightness(animationOptions.brightness-1);
|
||||
}
|
||||
|
||||
void AnimationStation::IncreaseBrightness() {
|
||||
if (AnimationStation::options.brightness < getBrightnessStepSize())
|
||||
AnimationStation::SetBrightness(++AnimationStation::options.brightness);
|
||||
else if (AnimationStation::options.brightness > getBrightnessStepSize())
|
||||
AnimationStation::SetBrightness(brightnessSteps);
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (animationOptions.brightness < getBrightnessStepSize())
|
||||
SetBrightness(animationOptions.brightness+1);
|
||||
else if (animationOptions.brightness > getBrightnessStepSize())
|
||||
SetBrightness(brightnessSteps);
|
||||
}
|
||||
|
||||
void AnimationStation::DimBrightnessTo0() {
|
||||
AnimationStation::brightnessX = 0;
|
||||
brightnessX = 0;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Chase.hpp"
|
||||
#include "chase.h"
|
||||
#include "storagemanager.h"
|
||||
|
||||
#define CHASE_CYCLE_INCREMENT 10
|
||||
#define CHASE_CYCLE_MAX INT16_MAX/2
|
||||
@@ -57,13 +58,14 @@ void Chase::Animate(RGB (&frame)[100]) {
|
||||
}
|
||||
|
||||
// this really shouldn't be nessecary, but something outside the param down might be changing this
|
||||
if (AnimationStation::options.chaseCycleTime < CHASE_CYCLE_MIN) {
|
||||
AnimationStation::options.chaseCycleTime = CHASE_CYCLE_MIN;
|
||||
} else if (AnimationStation::options.chaseCycleTime > CHASE_CYCLE_MAX) {
|
||||
AnimationStation::options.chaseCycleTime = CHASE_CYCLE_MAX;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (animationOptions.chaseCycleTime < CHASE_CYCLE_MIN) {
|
||||
animationOptions.chaseCycleTime = CHASE_CYCLE_MIN;
|
||||
} else if (animationOptions.chaseCycleTime > CHASE_CYCLE_MAX) {
|
||||
animationOptions.chaseCycleTime = CHASE_CYCLE_MAX;
|
||||
}
|
||||
|
||||
this->nextRunTime = make_timeout_time_ms(AnimationStation::options.chaseCycleTime);
|
||||
this->nextRunTime = make_timeout_time_ms(animationOptions.chaseCycleTime);
|
||||
}
|
||||
|
||||
bool Chase::IsChasePixel(int i) {
|
||||
@@ -102,15 +104,17 @@ int Chase::WheelFrame(int i) {
|
||||
}
|
||||
|
||||
void Chase::ParameterUp() {
|
||||
AnimationStation::options.chaseCycleTime = AnimationStation::options.chaseCycleTime + CHASE_CYCLE_INCREMENT;
|
||||
if (AnimationStation::options.chaseCycleTime > CHASE_CYCLE_MAX) {
|
||||
AnimationStation::options.chaseCycleTime = CHASE_CYCLE_MAX;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
animationOptions.chaseCycleTime = animationOptions.chaseCycleTime + CHASE_CYCLE_INCREMENT;
|
||||
if (animationOptions.chaseCycleTime > CHASE_CYCLE_MAX) {
|
||||
animationOptions.chaseCycleTime = CHASE_CYCLE_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
void Chase::ParameterDown() {
|
||||
AnimationStation::options.chaseCycleTime = AnimationStation::options.chaseCycleTime - CHASE_CYCLE_INCREMENT;
|
||||
if (AnimationStation::options.chaseCycleTime < CHASE_CYCLE_MIN) {
|
||||
AnimationStation::options.chaseCycleTime = CHASE_CYCLE_MIN;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
animationOptions.chaseCycleTime =animationOptions.chaseCycleTime - CHASE_CYCLE_INCREMENT;
|
||||
if (animationOptions.chaseCycleTime < CHASE_CYCLE_MIN) {
|
||||
animationOptions.chaseCycleTime = CHASE_CYCLE_MIN;
|
||||
}
|
||||
}
|
||||
64
src/animationstation/effects/customtheme.cpp
Normal file
64
src/animationstation/effects/customtheme.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "customtheme.h"
|
||||
#include "storagemanager.h"
|
||||
|
||||
CustomTheme::CustomTheme(PixelMatrix &matrix) : Animation(matrix) {
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (animationOptions.hasCustomTheme)
|
||||
{
|
||||
theme[GAMEPAD_MASK_DU] = RGB(animationOptions.customThemeUp);
|
||||
theme[GAMEPAD_MASK_DD] = RGB(animationOptions.customThemeDown);
|
||||
theme[GAMEPAD_MASK_DL] = RGB(animationOptions.customThemeLeft);
|
||||
theme[GAMEPAD_MASK_DR] = RGB(animationOptions.customThemeRight);
|
||||
theme[GAMEPAD_MASK_B1] = RGB(animationOptions.customThemeB1);
|
||||
theme[GAMEPAD_MASK_B2] = RGB(animationOptions.customThemeB2);
|
||||
theme[GAMEPAD_MASK_B3] = RGB(animationOptions.customThemeB3);
|
||||
theme[GAMEPAD_MASK_B4] = RGB(animationOptions.customThemeB4);
|
||||
theme[GAMEPAD_MASK_L1] = RGB(animationOptions.customThemeL1);
|
||||
theme[GAMEPAD_MASK_R1] = RGB(animationOptions.customThemeR1);
|
||||
theme[GAMEPAD_MASK_L2] = RGB(animationOptions.customThemeL2);
|
||||
theme[GAMEPAD_MASK_R2] = RGB(animationOptions.customThemeR2);
|
||||
theme[GAMEPAD_MASK_S1] = RGB(animationOptions.customThemeS1);
|
||||
theme[GAMEPAD_MASK_S2] = RGB(animationOptions.customThemeS2);
|
||||
theme[GAMEPAD_MASK_A1] = RGB(animationOptions.customThemeA1);
|
||||
theme[GAMEPAD_MASK_A2] = RGB(animationOptions.customThemeA2);
|
||||
theme[GAMEPAD_MASK_L3] = RGB(animationOptions.customThemeL3);
|
||||
theme[GAMEPAD_MASK_R3] = RGB(animationOptions.customThemeR3);
|
||||
}
|
||||
}
|
||||
|
||||
void CustomTheme::Animate(RGB (&frame)[100]) {
|
||||
UpdateTime();
|
||||
UpdatePresses(frame);
|
||||
|
||||
for (size_t r = 0; r != matrix->pixels.size(); r++) {
|
||||
for (size_t c = 0; c != matrix->pixels[r].size(); c++) {
|
||||
if (matrix->pixels[r][c].index == NO_PIXEL.index)
|
||||
continue;
|
||||
|
||||
// Count down the timer
|
||||
DecrementFadeCounter(matrix->pixels[r][c].index);
|
||||
|
||||
auto itr = theme.find(matrix->pixels[r][c].mask);
|
||||
if (itr != theme.end()) {
|
||||
for (size_t p = 0; p != matrix->pixels[r][c].positions.size(); p++) {
|
||||
// Interpolate from hitColor (color the button was assigned when pressed) back to the theme color
|
||||
frame[matrix->pixels[r][c].positions[p]] = BlendColor(hitColor[matrix->pixels[r][c].index], itr->second, times[matrix->pixels[r][c].index]);
|
||||
}
|
||||
} else {
|
||||
for (size_t p = 0; p != matrix->pixels[r][c].positions.size(); p++) {
|
||||
frame[matrix->pixels[r][c].positions[p]] = defaultColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CustomTheme::HasTheme() {
|
||||
return theme.size() > 0;
|
||||
}
|
||||
|
||||
void CustomTheme::ParameterUp() {
|
||||
}
|
||||
|
||||
void CustomTheme::ParameterDown() {
|
||||
}
|
||||
55
src/animationstation/effects/customthemepressed.cpp
Normal file
55
src/animationstation/effects/customthemepressed.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "customthemepressed.h"
|
||||
#include "GamepadState.h"
|
||||
#include "storagemanager.h"
|
||||
|
||||
CustomThemePressed::CustomThemePressed(PixelMatrix &matrix) : Animation(matrix) {
|
||||
this->filtered = true;
|
||||
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (animationOptions.hasCustomTheme)
|
||||
{
|
||||
theme[GAMEPAD_MASK_DU] = RGB(animationOptions.customThemeUpPressed);
|
||||
theme[GAMEPAD_MASK_DD] = RGB(animationOptions.customThemeDownPressed);
|
||||
theme[GAMEPAD_MASK_DL] = RGB(animationOptions.customThemeLeftPressed);
|
||||
theme[GAMEPAD_MASK_DR] = RGB(animationOptions.customThemeRightPressed);
|
||||
theme[GAMEPAD_MASK_B1] = RGB(animationOptions.customThemeB1Pressed);
|
||||
theme[GAMEPAD_MASK_B2] = RGB(animationOptions.customThemeB2Pressed);
|
||||
theme[GAMEPAD_MASK_B3] = RGB(animationOptions.customThemeB3Pressed);
|
||||
theme[GAMEPAD_MASK_B4] = RGB(animationOptions.customThemeB4Pressed);
|
||||
theme[GAMEPAD_MASK_L1] = RGB(animationOptions.customThemeL1Pressed);
|
||||
theme[GAMEPAD_MASK_R1] = RGB(animationOptions.customThemeR1Pressed);
|
||||
theme[GAMEPAD_MASK_L2] = RGB(animationOptions.customThemeL2Pressed);
|
||||
theme[GAMEPAD_MASK_R2] = RGB(animationOptions.customThemeR2Pressed);
|
||||
theme[GAMEPAD_MASK_S1] = RGB(animationOptions.customThemeS1Pressed);
|
||||
theme[GAMEPAD_MASK_S2] = RGB(animationOptions.customThemeS2Pressed);
|
||||
theme[GAMEPAD_MASK_A1] = RGB(animationOptions.customThemeA1Pressed);
|
||||
theme[GAMEPAD_MASK_A2] = RGB(animationOptions.customThemeA2Pressed);
|
||||
theme[GAMEPAD_MASK_L3] = RGB(animationOptions.customThemeL3Pressed);
|
||||
theme[GAMEPAD_MASK_R3] = RGB(animationOptions.customThemeR3Pressed);
|
||||
}
|
||||
}
|
||||
|
||||
CustomThemePressed::CustomThemePressed(PixelMatrix &matrix, std::vector<Pixel> &pixels) : Animation(matrix), pixels(&pixels) {
|
||||
this->filtered = true;
|
||||
}
|
||||
|
||||
void CustomThemePressed::Animate(RGB (&frame)[100]) {
|
||||
for (size_t r = 0; r != matrix->pixels.size(); r++) {
|
||||
for (size_t c = 0; c != matrix->pixels[r].size(); c++) {
|
||||
if (matrix->pixels[r][c].index == NO_PIXEL.index || this->notInFilter(matrix->pixels[r][c]))
|
||||
continue;
|
||||
|
||||
auto itr = theme.find(matrix->pixels[r][c].mask);
|
||||
if (itr != theme.end())
|
||||
for (size_t p = 0; p != matrix->pixels[r][c].positions.size(); p++)
|
||||
frame[matrix->pixels[r][c].positions[p]] = itr->second;
|
||||
else
|
||||
for (size_t p = 0; p != matrix->pixels[r][c].positions.size(); p++)
|
||||
frame[matrix->pixels[r][c].positions[p]] = defaultColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CustomThemePressed::HasTheme() {
|
||||
return theme.size() > 0;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Rainbow.hpp"
|
||||
#include "rainbow.h"
|
||||
#include "storagemanager.h"
|
||||
|
||||
Rainbow::Rainbow(PixelMatrix &matrix) : Animation(matrix) {
|
||||
}
|
||||
@@ -41,7 +42,8 @@ void Rainbow::Animate(RGB (&frame)[100]) {
|
||||
}
|
||||
}
|
||||
|
||||
this->nextRunTime = make_timeout_time_ms(AnimationStation::options.rainbowCycleTime);
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
this->nextRunTime = make_timeout_time_ms(animationOptions.rainbowCycleTime);
|
||||
}
|
||||
|
||||
// clamp rainbowCycleTime to [1 ... INT16_MAX]
|
||||
@@ -50,17 +52,19 @@ void Rainbow::Animate(RGB (&frame)[100]) {
|
||||
#define RAINBOW_CYCLE_MIN 1 + RAINBOW_CYCLE_INCREMENT
|
||||
|
||||
void Rainbow::ParameterUp() {
|
||||
if (AnimationStation::options.rainbowCycleTime < RAINBOW_CYCLE_MAX) {
|
||||
AnimationStation::options.rainbowCycleTime = AnimationStation::options.rainbowCycleTime + RAINBOW_CYCLE_INCREMENT;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (animationOptions.rainbowCycleTime < RAINBOW_CYCLE_MAX) {
|
||||
animationOptions.rainbowCycleTime = animationOptions.rainbowCycleTime + RAINBOW_CYCLE_INCREMENT;
|
||||
} else {
|
||||
AnimationStation::options.rainbowCycleTime = INT16_MAX;
|
||||
animationOptions.rainbowCycleTime = INT16_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
void Rainbow::ParameterDown() {
|
||||
if (AnimationStation::options.rainbowCycleTime > RAINBOW_CYCLE_MIN) {
|
||||
AnimationStation::options.rainbowCycleTime = AnimationStation::options.rainbowCycleTime - RAINBOW_CYCLE_INCREMENT;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (animationOptions.rainbowCycleTime > RAINBOW_CYCLE_MIN) {
|
||||
animationOptions.rainbowCycleTime = animationOptions.rainbowCycleTime - RAINBOW_CYCLE_INCREMENT;
|
||||
} else {
|
||||
AnimationStation::options.rainbowCycleTime = 1;
|
||||
animationOptions.rainbowCycleTime = 1;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "StaticColor.hpp"
|
||||
#include "staticcolor.h"
|
||||
#include "storagemanager.h"
|
||||
|
||||
StaticColor::StaticColor(PixelMatrix &matrix) : Animation(matrix) {
|
||||
}
|
||||
@@ -33,19 +34,21 @@ void StaticColor::Animate(RGB (&frame)[100]) {
|
||||
}
|
||||
|
||||
uint8_t StaticColor::GetColor() {
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (this->filtered) {
|
||||
return AnimationStation::options.buttonColorIndex;
|
||||
return animationOptions.buttonColorIndex;
|
||||
} else {
|
||||
return AnimationStation::options.staticColorIndex;
|
||||
return animationOptions.staticColorIndex;
|
||||
}
|
||||
}
|
||||
|
||||
void StaticColor::ParameterUp() {
|
||||
uint8_t colorIndex;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (this->filtered) {
|
||||
colorIndex = AnimationStation::options.buttonColorIndex;
|
||||
colorIndex = animationOptions.buttonColorIndex;
|
||||
} else {
|
||||
colorIndex = AnimationStation::options.staticColorIndex;
|
||||
colorIndex = animationOptions.staticColorIndex;
|
||||
}
|
||||
|
||||
if (colorIndex < colors.size() - 1) {
|
||||
@@ -58,19 +61,21 @@ void StaticColor::ParameterUp() {
|
||||
}
|
||||
|
||||
void StaticColor::SaveIndexOptions(uint8_t colorIndex) {
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (this->filtered) {
|
||||
AnimationStation::options.buttonColorIndex = colorIndex;
|
||||
animationOptions.buttonColorIndex = colorIndex;
|
||||
} else {
|
||||
AnimationStation::options.staticColorIndex = colorIndex;
|
||||
animationOptions.staticColorIndex = colorIndex;
|
||||
}
|
||||
}
|
||||
|
||||
void StaticColor::ParameterDown() {
|
||||
uint8_t colorIndex;
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (this->filtered) {
|
||||
colorIndex = AnimationStation::options.buttonColorIndex;
|
||||
colorIndex = animationOptions.buttonColorIndex;
|
||||
} else {
|
||||
colorIndex = AnimationStation::options.staticColorIndex;
|
||||
colorIndex = animationOptions.staticColorIndex;
|
||||
}
|
||||
|
||||
if (colorIndex > 0) {
|
||||
@@ -1,38 +1,14 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2021 Jason Skuby (mytechtoybox.com)
|
||||
*/
|
||||
#include "statictheme.h"
|
||||
#include "storagemanager.h"
|
||||
#include "enums.pb.h"
|
||||
|
||||
#ifndef LED_THEMES_H_
|
||||
#define LED_THEMES_H_
|
||||
StaticTheme::StaticTheme(PixelMatrix &matrix) : Animation(matrix) {
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (animationOptions.themeIndex >= themes.size()) {
|
||||
animationOptions.themeIndex = 0;
|
||||
}
|
||||
|
||||
#include "BoardConfig.h"
|
||||
#include <vector>
|
||||
#include "AnimationStation.hpp"
|
||||
#include "helper.h"
|
||||
|
||||
#include "config.pb.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void addStaticThemes(const LEDOptions& options, const AnimationOptions& animationOptions)
|
||||
{
|
||||
map<uint32_t, RGB> themeStaticRainbow({
|
||||
{ GAMEPAD_MASK_DL, ColorRed },
|
||||
{ GAMEPAD_MASK_DD, ColorOrange },
|
||||
{ GAMEPAD_MASK_DR, ColorYellow },
|
||||
{ GAMEPAD_MASK_DU, ColorOrange },
|
||||
{ GAMEPAD_MASK_B3, ColorGreen },
|
||||
{ GAMEPAD_MASK_B1, ColorGreen },
|
||||
{ GAMEPAD_MASK_B4, ColorAqua },
|
||||
{ GAMEPAD_MASK_B2, ColorAqua },
|
||||
{ GAMEPAD_MASK_R1, ColorBlue },
|
||||
{ GAMEPAD_MASK_R2, ColorBlue },
|
||||
{ GAMEPAD_MASK_L1, ColorMagenta },
|
||||
{ GAMEPAD_MASK_L2, ColorMagenta },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeGuiltyGearTypeA({
|
||||
const std::map<uint32_t, RGB> themeGuiltyGearTypeA({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -44,7 +20,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_R2, ColorOrange },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeGuiltyGearTypeB({
|
||||
const std::map<uint32_t, RGB> themeGuiltyGearTypeB({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -56,7 +32,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_R2, ColorOrange },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeGuiltyGearTypeC({
|
||||
const std::map<uint32_t, RGB> themeGuiltyGearTypeC({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -68,7 +44,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_R2, ColorRed },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeGuiltyGearTypeD({
|
||||
const std::map<uint32_t, RGB> themeGuiltyGearTypeD({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -80,7 +56,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_R1, ColorOrange },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeGuiltyGearTypeE({
|
||||
const std::map<uint32_t, RGB> themeGuiltyGearTypeE({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -92,7 +68,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_R1, ColorOrange },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeNeoGeo({
|
||||
const std::map<uint32_t, RGB> themeNeoGeo({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -103,7 +79,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_L1, ColorBlue },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeNeoGeoCurved({
|
||||
const std::map<uint32_t, RGB> themeNeoGeoCurved({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -114,7 +90,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_R1, ColorBlue },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeNeoGeoModern({
|
||||
const std::map<uint32_t, RGB> themeNeoGeoModern({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -125,7 +101,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_B2, ColorBlue },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeSixButtonFighter({
|
||||
const std::map<uint32_t, RGB> themeSixButtonFighter({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -138,7 +114,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_R2, ColorRed },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeSixButtonFighterPlus({
|
||||
const std::map<uint32_t, RGB> themeSixButtonFighterPlus({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -153,7 +129,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_L2, ColorGreen },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeStreetFighter2({
|
||||
const std::map<uint32_t, RGB> themeStreetFighter2({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -168,7 +144,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_L2, ColorBlack },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeTekken({
|
||||
const std::map<uint32_t, RGB> themeTekken({
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DR, ColorWhite },
|
||||
@@ -180,7 +156,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_R1, ColorRed },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themePlayStation({
|
||||
const std::map<uint32_t, RGB> themePlayStation({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -195,7 +171,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_L2, ColorBlack },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themePlayStationAll({
|
||||
const std::map<uint32_t, RGB> themePlayStationAll({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -210,7 +186,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_L2, ColorWhite },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeSuperFamicom({
|
||||
const std::map<uint32_t, RGB> themeSuperFamicom({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -225,7 +201,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_L2, ColorBlack },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeSuperFamicomAll({
|
||||
const std::map<uint32_t, RGB> themeSuperFamicomAll({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -240,7 +216,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_L2, ColorWhite },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeXbox({
|
||||
const std::map<uint32_t, RGB> themeXbox({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -255,7 +231,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_L2, ColorBlack },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeXboxAll({
|
||||
const std::map<uint32_t, RGB> themeXboxAll({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -270,7 +246,7 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
{ GAMEPAD_MASK_L2, ColorWhite },
|
||||
});
|
||||
|
||||
const map<uint32_t, RGB> themeFightboard({
|
||||
const std::map<uint32_t, RGB> themeFightboard({
|
||||
{ GAMEPAD_MASK_DU, ColorWhite },
|
||||
{ GAMEPAD_MASK_DD, ColorWhite },
|
||||
{ GAMEPAD_MASK_DL, ColorWhite },
|
||||
@@ -286,79 +262,93 @@ void addStaticThemes(const LEDOptions& options, const AnimationOptions& animatio
|
||||
});
|
||||
|
||||
// Rainbow theme on a Stickless layout should use green for up button
|
||||
themeStaticRainbow[GAMEPAD_MASK_DU] = (options.ledLayout == BUTTON_LAYOUT_STICKLESS) ? ColorGreen : ColorOrange;
|
||||
std::map<uint32_t, RGB> themeStaticRainbow({
|
||||
{ GAMEPAD_MASK_DL, ColorRed },
|
||||
{ GAMEPAD_MASK_DD, ColorOrange },
|
||||
{ GAMEPAD_MASK_DR, ColorYellow },
|
||||
{ GAMEPAD_MASK_DU, ColorOrange },
|
||||
{ GAMEPAD_MASK_B3, ColorGreen },
|
||||
{ GAMEPAD_MASK_B1, ColorGreen },
|
||||
{ GAMEPAD_MASK_B4, ColorAqua },
|
||||
{ GAMEPAD_MASK_B2, ColorAqua },
|
||||
{ GAMEPAD_MASK_R1, ColorBlue },
|
||||
{ GAMEPAD_MASK_R2, ColorBlue },
|
||||
{ GAMEPAD_MASK_L1, ColorMagenta },
|
||||
{ GAMEPAD_MASK_L2, ColorMagenta },
|
||||
});
|
||||
|
||||
StaticTheme::ClearThemes();
|
||||
LEDOptions & ledOptions = Storage::getInstance().getLedOptions();
|
||||
themeStaticRainbow[GAMEPAD_MASK_DU] = (ledOptions.ledLayout == BUTTON_LAYOUT_STICKLESS) ? ColorGreen : ColorOrange;
|
||||
|
||||
StaticTheme::AddTheme(themeStaticRainbow);
|
||||
|
||||
StaticTheme::AddTheme(themeXbox);
|
||||
StaticTheme::AddTheme(themeXboxAll);
|
||||
StaticTheme::AddTheme(themeSuperFamicom);
|
||||
StaticTheme::AddTheme(themeSuperFamicomAll);
|
||||
StaticTheme::AddTheme(themePlayStation);
|
||||
StaticTheme::AddTheme(themePlayStationAll);
|
||||
|
||||
StaticTheme::AddTheme(themeNeoGeo);
|
||||
StaticTheme::AddTheme(themeNeoGeoCurved);
|
||||
StaticTheme::AddTheme(themeNeoGeoModern);
|
||||
StaticTheme::AddTheme(themeSixButtonFighter);
|
||||
StaticTheme::AddTheme(themeSixButtonFighterPlus);
|
||||
|
||||
StaticTheme::AddTheme(themeStreetFighter2);
|
||||
StaticTheme::AddTheme(themeTekken);
|
||||
StaticTheme::AddTheme(themeGuiltyGearTypeA);
|
||||
StaticTheme::AddTheme(themeGuiltyGearTypeB);
|
||||
StaticTheme::AddTheme(themeGuiltyGearTypeC);
|
||||
StaticTheme::AddTheme(themeGuiltyGearTypeD);
|
||||
StaticTheme::AddTheme(themeGuiltyGearTypeE);
|
||||
|
||||
StaticTheme::AddTheme(themeFightboard);
|
||||
|
||||
if (animationOptions.hasCustomTheme)
|
||||
{
|
||||
map<uint32_t, RGB> customTheme;
|
||||
customTheme[GAMEPAD_MASK_DU] = RGB(animationOptions.customThemeUp);
|
||||
customTheme[GAMEPAD_MASK_DD] = RGB(animationOptions.customThemeDown);
|
||||
customTheme[GAMEPAD_MASK_DL] = RGB(animationOptions.customThemeLeft);
|
||||
customTheme[GAMEPAD_MASK_DR] = RGB(animationOptions.customThemeRight);
|
||||
customTheme[GAMEPAD_MASK_B1] = RGB(animationOptions.customThemeB1);
|
||||
customTheme[GAMEPAD_MASK_B2] = RGB(animationOptions.customThemeB2);
|
||||
customTheme[GAMEPAD_MASK_B3] = RGB(animationOptions.customThemeB3);
|
||||
customTheme[GAMEPAD_MASK_B4] = RGB(animationOptions.customThemeB4);
|
||||
customTheme[GAMEPAD_MASK_L1] = RGB(animationOptions.customThemeL1);
|
||||
customTheme[GAMEPAD_MASK_R1] = RGB(animationOptions.customThemeR1);
|
||||
customTheme[GAMEPAD_MASK_L2] = RGB(animationOptions.customThemeL2);
|
||||
customTheme[GAMEPAD_MASK_R2] = RGB(animationOptions.customThemeR2);
|
||||
customTheme[GAMEPAD_MASK_S1] = RGB(animationOptions.customThemeS1);
|
||||
customTheme[GAMEPAD_MASK_S2] = RGB(animationOptions.customThemeS2);
|
||||
customTheme[GAMEPAD_MASK_A1] = RGB(animationOptions.customThemeA1);
|
||||
customTheme[GAMEPAD_MASK_A2] = RGB(animationOptions.customThemeA2);
|
||||
customTheme[GAMEPAD_MASK_L3] = RGB(animationOptions.customThemeL3);
|
||||
customTheme[GAMEPAD_MASK_R3] = RGB(animationOptions.customThemeR3);
|
||||
CustomTheme::SetCustomTheme(customTheme);
|
||||
|
||||
map<uint32_t, RGB> customThemePressed;
|
||||
customThemePressed[GAMEPAD_MASK_DU] = RGB(animationOptions.customThemeUpPressed);
|
||||
customThemePressed[GAMEPAD_MASK_DD] = RGB(animationOptions.customThemeDownPressed);
|
||||
customThemePressed[GAMEPAD_MASK_DL] = RGB(animationOptions.customThemeLeftPressed);
|
||||
customThemePressed[GAMEPAD_MASK_DR] = RGB(animationOptions.customThemeRightPressed);
|
||||
customThemePressed[GAMEPAD_MASK_B1] = RGB(animationOptions.customThemeB1Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_B2] = RGB(animationOptions.customThemeB2Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_B3] = RGB(animationOptions.customThemeB3Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_B4] = RGB(animationOptions.customThemeB4Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_L1] = RGB(animationOptions.customThemeL1Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_R1] = RGB(animationOptions.customThemeR1Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_L2] = RGB(animationOptions.customThemeL2Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_R2] = RGB(animationOptions.customThemeR2Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_S1] = RGB(animationOptions.customThemeS1Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_S2] = RGB(animationOptions.customThemeS2Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_A1] = RGB(animationOptions.customThemeA1Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_A2] = RGB(animationOptions.customThemeA2Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_L3] = RGB(animationOptions.customThemeL3Pressed);
|
||||
customThemePressed[GAMEPAD_MASK_R3] = RGB(animationOptions.customThemeR3Pressed);
|
||||
CustomThemePressed::SetCustomTheme(customThemePressed);
|
||||
}
|
||||
ClearThemes();
|
||||
AddTheme(themeStaticRainbow);
|
||||
AddTheme(themeXbox);
|
||||
AddTheme(themeXboxAll);
|
||||
AddTheme(themeSuperFamicom);
|
||||
AddTheme(themeSuperFamicomAll);
|
||||
AddTheme(themePlayStation);
|
||||
AddTheme(themePlayStationAll);
|
||||
AddTheme(themeNeoGeo);
|
||||
AddTheme(themeNeoGeoCurved);
|
||||
AddTheme(themeNeoGeoModern);
|
||||
AddTheme(themeSixButtonFighter);
|
||||
AddTheme(themeSixButtonFighterPlus);
|
||||
AddTheme(themeStreetFighter2);
|
||||
AddTheme(themeTekken);
|
||||
AddTheme(themeGuiltyGearTypeA);
|
||||
AddTheme(themeGuiltyGearTypeB);
|
||||
AddTheme(themeGuiltyGearTypeC);
|
||||
AddTheme(themeGuiltyGearTypeD);
|
||||
AddTheme(themeGuiltyGearTypeE);
|
||||
AddTheme(themeFightboard);
|
||||
}
|
||||
|
||||
#endif
|
||||
void StaticTheme::Animate(RGB (&frame)[100]) {
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (themes.size() > 0) {
|
||||
UpdateTime();
|
||||
UpdatePresses(frame);
|
||||
|
||||
for (size_t r = 0; r != matrix->pixels.size(); r++) {
|
||||
for (size_t c = 0; c != matrix->pixels[r].size(); c++) {
|
||||
if (matrix->pixels[r][c].index == NO_PIXEL.index)
|
||||
continue;
|
||||
|
||||
// Count down the timer
|
||||
DecrementFadeCounter(matrix->pixels[r][c].index);
|
||||
|
||||
std::map<uint32_t, RGB> theme = themes.at(animationOptions.themeIndex);
|
||||
|
||||
auto itr = theme.find(matrix->pixels[r][c].mask);
|
||||
if (itr != theme.end()) {
|
||||
for (size_t p = 0; p != matrix->pixels[r][c].positions.size(); p++) {
|
||||
// Interpolate from hitColor (color the button was assigned when pressed) back to the theme color
|
||||
frame[matrix->pixels[r][c].positions[p]] = BlendColor(hitColor[matrix->pixels[r][c].index], itr->second, times[matrix->pixels[r][c].index]);
|
||||
}
|
||||
} else {
|
||||
for (size_t p = 0; p != matrix->pixels[r][c].positions.size(); p++) {
|
||||
frame[matrix->pixels[r][c].positions[p]] = defaultColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StaticTheme::ParameterUp() {
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (animationOptions.themeIndex < StaticTheme::themes.size() - 1) {
|
||||
animationOptions.themeIndex++;
|
||||
} else {
|
||||
animationOptions.themeIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void StaticTheme::ParameterDown() {
|
||||
AnimationOptions & animationOptions = Storage::getInstance().getAnimationOptions();
|
||||
if (animationOptions.themeIndex > 0) {
|
||||
animationOptions.themeIndex--;
|
||||
} else {
|
||||
animationOptions.themeIndex = StaticTheme::themes.size() - 1;
|
||||
}
|
||||
}
|
||||
@@ -906,7 +906,7 @@ bool ConfigUtils::fromLegacyStorage(Config& config)
|
||||
{
|
||||
legacyConfigFound = true;
|
||||
|
||||
AnimationOptions_Proto& animationOptions = config.animationOptions;
|
||||
AnimationOptions& animationOptions = config.animationOptions;
|
||||
config.has_animationOptions = true;
|
||||
SET_PROPERTY(animationOptions, baseAnimationIndex, legacyAnimationOptions.baseAnimationIndex);
|
||||
SET_PROPERTY(animationOptions, brightness, legacyAnimationOptions.brightness);
|
||||
|
||||
@@ -520,7 +520,6 @@ void ConfigUtils::initUnsetPropertiesWithDefaults(Config& config)
|
||||
|
||||
INIT_UNSET_PROPERTY(config.ledOptions, caseRGBType, CASE_RGB_TYPE);
|
||||
INIT_UNSET_PROPERTY(config.ledOptions, caseRGBIndex, CASE_RGB_INDEX);
|
||||
INIT_UNSET_PROPERTY(config.ledOptions, caseRGBColor, static_cast<uint32_t>(CASE_RGB_COLOR.r) << 16 | static_cast<uint32_t>(CASE_RGB_COLOR.g) << 8 | static_cast<uint32_t>(CASE_RGB_COLOR.b));
|
||||
INIT_UNSET_PROPERTY(config.ledOptions, caseRGBCount, CASE_RGB_COUNT);
|
||||
|
||||
// animationOptions
|
||||
@@ -569,6 +568,16 @@ void ConfigUtils::initUnsetPropertiesWithDefaults(Config& config)
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, customThemeA1Pressed, 0);
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, customThemeA2Pressed, 0);
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, buttonPressColorCooldownTimeInMs, LEDS_PRESS_COLOR_COOLDOWN_TIME);
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, ambientLightEffectsCountIndex, AMBIENT_LIGHT_EFFECT);
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, alStaticColorBrightnessCustomX, AMBIENT_STATIC_COLOR_BRIGHTNESS);
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, alGradientBrightnessCustomX, AMBIENT_GRADIENT_COLOR_BRIGHTNESS);
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, alChaseBrightnessCustomX, AMBIENT_CHASE_COLOR_BRIGHTNESS);
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, alStaticBrightnessCustomThemeX, AMBIENT_CUSTOM_THEME_BRIGHTNESS);
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, ambientLightGradientSpeed, AMBIENT_GRADIENT_SPEED);
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, ambientLightChaseSpeed, AMBIENT_CHASE_SPEED);
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, ambientLightBreathSpeed, AMBIENT_BREATH_SPEED);
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, alCustomStaticThemeIndex, AMBIENT_CUSTOM_THEME);
|
||||
INIT_UNSET_PROPERTY(config.animationOptions, alCustomStaticColorIndex, AMBIENT_STATIC_COLOR);
|
||||
|
||||
// addonOptions.bootselButtonOptions
|
||||
INIT_UNSET_PROPERTY(config.addonOptions.bootselButtonOptions, enabled, !!BOOTSEL_BUTTON_ENABLED);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "eventmanager.h"
|
||||
#include "layoutmanager.h"
|
||||
#include "peripheralmanager.h"
|
||||
#include "AnimationStorage.hpp"
|
||||
#include "animationstorage.h"
|
||||
#include "system.h"
|
||||
#include "config_utils.h"
|
||||
#include "types.h"
|
||||
@@ -852,7 +852,6 @@ std::string setLedOptions()
|
||||
readDoc(ledOptions.caseRGBType, doc, "caseRGBType");
|
||||
readDoc(ledOptions.caseRGBIndex, doc, "caseRGBIndex");
|
||||
readDoc(ledOptions.caseRGBCount, doc, "caseRGBCount");
|
||||
readDoc(ledOptions.caseRGBColor, doc, "caseRGBColor");
|
||||
|
||||
Storage::getInstance().save(true);
|
||||
return serialize_json(doc);
|
||||
@@ -912,7 +911,6 @@ std::string getLedOptions()
|
||||
writeDoc(doc, "caseRGBType", ledOptions.caseRGBType);
|
||||
writeDoc(doc, "caseRGBIndex", ledOptions.caseRGBIndex);
|
||||
writeDoc(doc, "caseRGBCount", ledOptions.caseRGBCount);
|
||||
writeDoc(doc, "caseRGBColor", ((RGB)ledOptions.caseRGBColor).value(LED_FORMAT_RGB));
|
||||
|
||||
return serialize_json(doc);
|
||||
}
|
||||
@@ -1010,7 +1008,7 @@ std::string setCustomTheme()
|
||||
{
|
||||
DynamicJsonDocument doc = get_post_data();
|
||||
|
||||
AnimationOptions options = AnimationStation::options;
|
||||
AnimationOptions & options = Storage::getInstance().getAnimationOptions();
|
||||
|
||||
const auto readDocDefaultToZero = [&](const char* key0, const char* key1) -> uint32_t
|
||||
{
|
||||
@@ -1064,16 +1062,14 @@ std::string setCustomTheme()
|
||||
readDoc(pressCooldown, doc, "buttonPressColorCooldownTimeInMs");
|
||||
options.buttonPressColorCooldownTimeInMs = pressCooldown;
|
||||
|
||||
AnimationStation::SetOptions(options);
|
||||
Storage::getInstance().save(true);
|
||||
|
||||
return serialize_json(doc);
|
||||
}
|
||||
|
||||
std::string getCustomTheme()
|
||||
{
|
||||
DynamicJsonDocument doc(LWIP_HTTPD_POST_MAX_PAYLOAD_LEN);
|
||||
const AnimationOptions& options = AnimationStation::options;
|
||||
const AnimationOptions& options = Storage::getInstance().getAnimationOptions();
|
||||
|
||||
writeDoc(doc, "enabled", options.hasCustomTheme);
|
||||
writeDoc(doc, "Up", "u", options.customThemeUp);
|
||||
|
||||
@@ -28,7 +28,8 @@ uint64_t getMicro() {
|
||||
Gamepad::Gamepad() :
|
||||
options(Storage::getInstance().getGamepadOptions())
|
||||
, hotkeyOptions(Storage::getInstance().getHotkeyOptions())
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void Gamepad::setup()
|
||||
{
|
||||
@@ -167,6 +168,23 @@ void Gamepad::setup()
|
||||
}
|
||||
}
|
||||
|
||||
// Define our hotkey array
|
||||
hotkeys[0] = hotkeyOptions.hotkey01;
|
||||
hotkeys[1] = hotkeyOptions.hotkey02;
|
||||
hotkeys[2] = hotkeyOptions.hotkey03;
|
||||
hotkeys[3] = hotkeyOptions.hotkey04;
|
||||
hotkeys[4] = hotkeyOptions.hotkey05;
|
||||
hotkeys[5] = hotkeyOptions.hotkey06;
|
||||
hotkeys[6] = hotkeyOptions.hotkey07;
|
||||
hotkeys[7] = hotkeyOptions.hotkey08;
|
||||
hotkeys[8] = hotkeyOptions.hotkey09;
|
||||
hotkeys[9] = hotkeyOptions.hotkey10;
|
||||
hotkeys[10] = hotkeyOptions.hotkey11;
|
||||
hotkeys[11] = hotkeyOptions.hotkey12;
|
||||
hotkeys[12] = hotkeyOptions.hotkey13;
|
||||
hotkeys[13] = hotkeyOptions.hotkey14;
|
||||
hotkeys[14] = hotkeyOptions.hotkey15;
|
||||
hotkeys[15] = hotkeyOptions.hotkey16;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,28 +427,15 @@ void Gamepad::hotkey()
|
||||
if (options.lockHotkeys)
|
||||
return;
|
||||
|
||||
GamepadHotkey action = HOTKEY_NONE;
|
||||
if (pressedHotkey(hotkeyOptions.hotkey01)) action = selectHotkey(hotkeyOptions.hotkey01);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey02)) action = selectHotkey(hotkeyOptions.hotkey02);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey03)) action = selectHotkey(hotkeyOptions.hotkey03);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey04)) action = selectHotkey(hotkeyOptions.hotkey04);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey05)) action = selectHotkey(hotkeyOptions.hotkey05);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey06)) action = selectHotkey(hotkeyOptions.hotkey06);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey07)) action = selectHotkey(hotkeyOptions.hotkey07);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey08)) action = selectHotkey(hotkeyOptions.hotkey08);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey09)) action = selectHotkey(hotkeyOptions.hotkey09);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey10)) action = selectHotkey(hotkeyOptions.hotkey10);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey11)) action = selectHotkey(hotkeyOptions.hotkey11);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey12)) action = selectHotkey(hotkeyOptions.hotkey12);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey13)) action = selectHotkey(hotkeyOptions.hotkey13);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey14)) action = selectHotkey(hotkeyOptions.hotkey14);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey15)) action = selectHotkey(hotkeyOptions.hotkey15);
|
||||
else if (pressedHotkey(hotkeyOptions.hotkey16)) action = selectHotkey(hotkeyOptions.hotkey16);
|
||||
if ( action != HOTKEY_NONE ) {
|
||||
// processHotkeyAction checks lastAction to determine if the action is repeatable or not
|
||||
processHotkeyAction(action);
|
||||
// Look for a hot-key
|
||||
GamepadHotkey action;
|
||||
for(int i = 0; i < 16; i++) {
|
||||
if (pressedHotkey(hotkeys[i])) {
|
||||
action = selectHotkey(hotkeys[i]);
|
||||
processHotkeyAction(action);
|
||||
lastAction = action;
|
||||
}
|
||||
}
|
||||
lastAction = action;
|
||||
}
|
||||
|
||||
void Gamepad::clearState() {
|
||||
@@ -574,10 +579,14 @@ void Gamepad::processHotkeyAction(GamepadHotkey action) {
|
||||
}
|
||||
break;
|
||||
case HOTKEY_REBOOT_DEFAULT:
|
||||
System::reboot(System::BootMode::DEFAULT);
|
||||
if (action != lastAction) {
|
||||
System::reboot(System::BootMode::DEFAULT);
|
||||
}
|
||||
break;
|
||||
case HOTKEY_SAVE_CONFIG:
|
||||
Storage::getInstance().save(true);
|
||||
if (action != lastAction) {
|
||||
Storage::getInstance().save(true);
|
||||
}
|
||||
break;
|
||||
case HOTKEY_CAPTURE_BUTTON:
|
||||
state.buttons |= GAMEPAD_MASK_A2;
|
||||
|
||||
@@ -277,9 +277,6 @@ void GP2040::run() {
|
||||
|
||||
memcpy(&prevState, &gamepad->state, sizeof(GamepadState));
|
||||
|
||||
// Do any queued saves in StorageManager
|
||||
Storage::getInstance().performEnqueuedSaves();
|
||||
|
||||
// Debounce
|
||||
debounceGpioGetAll();
|
||||
// Read Gamepad
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "PlayerLEDs.h"
|
||||
#include "playerleds.h"
|
||||
#include "pico/stdlib.h"
|
||||
#include "hardware/pwm.h"
|
||||
#include <hardware/pwm.h>
|
||||
|
||||
void PlayerLEDs::animate(PLEDAnimationState animationState)
|
||||
{
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "storagemanager.h"
|
||||
|
||||
#include "BoardConfig.h"
|
||||
#include "AnimationStorage.hpp"
|
||||
#include "animationstorage.h"
|
||||
#include "FlashPROM.h"
|
||||
#include "eventmanager.h"
|
||||
#include "peripheralmanager.h"
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
void Storage::init() {
|
||||
EEPROM.start();
|
||||
critical_section_init(&animationOptionsCs);
|
||||
ConfigUtils::load(config);
|
||||
}
|
||||
|
||||
@@ -42,82 +41,6 @@ bool Storage::save(const bool force) {
|
||||
}
|
||||
}
|
||||
|
||||
static void updateAnimationOptionsProto(const AnimationOptions& options)
|
||||
{
|
||||
AnimationOptions_Proto& optionsProto = Storage::getInstance().getAnimationOptions();
|
||||
|
||||
optionsProto.baseAnimationIndex = options.baseAnimationIndex;
|
||||
optionsProto.brightness = options.brightness;
|
||||
optionsProto.staticColorIndex = options.staticColorIndex;
|
||||
optionsProto.buttonColorIndex = options.buttonColorIndex;
|
||||
optionsProto.chaseCycleTime = options.chaseCycleTime;
|
||||
optionsProto.rainbowCycleTime = options.rainbowCycleTime;
|
||||
optionsProto.themeIndex = options.themeIndex;
|
||||
optionsProto.hasCustomTheme = options.hasCustomTheme;
|
||||
optionsProto.customThemeUp = options.customThemeUp;
|
||||
optionsProto.customThemeDown = options.customThemeDown;
|
||||
optionsProto.customThemeLeft = options.customThemeLeft;
|
||||
optionsProto.customThemeRight = options.customThemeRight;
|
||||
optionsProto.customThemeB1 = options.customThemeB1;
|
||||
optionsProto.customThemeB2 = options.customThemeB2;
|
||||
optionsProto.customThemeB3 = options.customThemeB3;
|
||||
optionsProto.customThemeB4 = options.customThemeB4;
|
||||
optionsProto.customThemeL1 = options.customThemeL1;
|
||||
optionsProto.customThemeR1 = options.customThemeR1;
|
||||
optionsProto.customThemeL2 = options.customThemeL2;
|
||||
optionsProto.customThemeR2 = options.customThemeR2;
|
||||
optionsProto.customThemeS1 = options.customThemeS1;
|
||||
optionsProto.customThemeS2 = options.customThemeS2;
|
||||
optionsProto.customThemeA1 = options.customThemeA1;
|
||||
optionsProto.customThemeA2 = options.customThemeA2;
|
||||
optionsProto.customThemeL3 = options.customThemeL3;
|
||||
optionsProto.customThemeR3 = options.customThemeR3;
|
||||
optionsProto.customThemeUpPressed = options.customThemeUpPressed;
|
||||
optionsProto.customThemeDownPressed = options.customThemeDownPressed;
|
||||
optionsProto.customThemeLeftPressed = options.customThemeLeftPressed;
|
||||
optionsProto.customThemeRightPressed = options.customThemeRightPressed;
|
||||
optionsProto.customThemeB1Pressed = options.customThemeB1Pressed;
|
||||
optionsProto.customThemeB2Pressed = options.customThemeB2Pressed;
|
||||
optionsProto.customThemeB3Pressed = options.customThemeB3Pressed;
|
||||
optionsProto.customThemeB4Pressed = options.customThemeB4Pressed;
|
||||
optionsProto.customThemeL1Pressed = options.customThemeL1Pressed;
|
||||
optionsProto.customThemeR1Pressed = options.customThemeR1Pressed;
|
||||
optionsProto.customThemeL2Pressed = options.customThemeL2Pressed;
|
||||
optionsProto.customThemeR2Pressed = options.customThemeR2Pressed;
|
||||
optionsProto.customThemeS1Pressed = options.customThemeS1Pressed;
|
||||
optionsProto.customThemeS2Pressed = options.customThemeS2Pressed;
|
||||
optionsProto.customThemeA1Pressed = options.customThemeA1Pressed;
|
||||
optionsProto.customThemeA2Pressed = options.customThemeA2Pressed;
|
||||
optionsProto.customThemeL3Pressed = options.customThemeL3Pressed;
|
||||
optionsProto.customThemeR3Pressed = options.customThemeR3Pressed;
|
||||
optionsProto.buttonPressColorCooldownTimeInMs = options.buttonPressColorCooldownTimeInMs;
|
||||
}
|
||||
|
||||
void Storage::performEnqueuedSaves()
|
||||
{
|
||||
if (animationOptionsSavePending.load())
|
||||
{
|
||||
critical_section_enter_blocking(&animationOptionsCs);
|
||||
updateAnimationOptionsProto(animationOptionsToSave);
|
||||
save();
|
||||
animationOptionsSavePending.store(false);
|
||||
critical_section_exit(&animationOptionsCs);
|
||||
}
|
||||
}
|
||||
|
||||
void Storage::enqueueAnimationOptionsSave(const AnimationOptions& animationOptions)
|
||||
{
|
||||
const uint32_t crc = CRC32::calculate(&animationOptions);
|
||||
critical_section_enter_blocking(&animationOptionsCs);
|
||||
if (crc != animationOptionsCrc)
|
||||
{
|
||||
animationOptionsToSave = animationOptions;
|
||||
animationOptionsCrc = crc;
|
||||
animationOptionsSavePending.store(true);
|
||||
}
|
||||
critical_section_exit(&animationOptionsCs);
|
||||
}
|
||||
|
||||
void Storage::ResetSettings()
|
||||
{
|
||||
EEPROM.reset();
|
||||
@@ -227,64 +150,3 @@ Gamepad * Storage::GetProcessedGamepad()
|
||||
{
|
||||
return processedGamepad;
|
||||
}
|
||||
|
||||
/* Animation stuffs */
|
||||
AnimationOptions AnimationStorage::getAnimationOptions()
|
||||
{
|
||||
AnimationOptions options;
|
||||
const AnimationOptions_Proto& optionsProto = Storage::getInstance().getAnimationOptions();
|
||||
|
||||
options.checksum = 0;
|
||||
options.baseAnimationIndex = std::min<uint32_t>(optionsProto.baseAnimationIndex, 255);
|
||||
options.brightness = std::min<uint32_t>(optionsProto.brightness, 255);
|
||||
options.staticColorIndex = std::min<uint32_t>(optionsProto.staticColorIndex, 255);
|
||||
options.buttonColorIndex = std::min<uint32_t>(optionsProto.buttonColorIndex, 255);
|
||||
options.chaseCycleTime = std::min<int32_t>(optionsProto.chaseCycleTime, 65535);
|
||||
options.rainbowCycleTime = std::min<int32_t>(optionsProto.rainbowCycleTime, 65535);
|
||||
options.themeIndex = std::min<uint8_t>(optionsProto.themeIndex, 255);
|
||||
options.hasCustomTheme = optionsProto.hasCustomTheme;
|
||||
options.customThemeUp = optionsProto.customThemeUp;
|
||||
options.customThemeDown = optionsProto.customThemeDown;
|
||||
options.customThemeLeft = optionsProto.customThemeLeft;
|
||||
options.customThemeRight = optionsProto.customThemeRight;
|
||||
options.customThemeB1 = optionsProto.customThemeB1;
|
||||
options.customThemeB2 = optionsProto.customThemeB2;
|
||||
options.customThemeB3 = optionsProto.customThemeB3;
|
||||
options.customThemeB4 = optionsProto.customThemeB4;
|
||||
options.customThemeL1 = optionsProto.customThemeL1;
|
||||
options.customThemeR1 = optionsProto.customThemeR1;
|
||||
options.customThemeL2 = optionsProto.customThemeL2;
|
||||
options.customThemeR2 = optionsProto.customThemeR2;
|
||||
options.customThemeS1 = optionsProto.customThemeS1;
|
||||
options.customThemeS2 = optionsProto.customThemeS2;
|
||||
options.customThemeA1 = optionsProto.customThemeA1;
|
||||
options.customThemeA2 = optionsProto.customThemeA2;
|
||||
options.customThemeL3 = optionsProto.customThemeL3;
|
||||
options.customThemeR3 = optionsProto.customThemeR3;
|
||||
options.customThemeUpPressed = optionsProto.customThemeUpPressed;
|
||||
options.customThemeDownPressed = optionsProto.customThemeDownPressed;
|
||||
options.customThemeLeftPressed = optionsProto.customThemeLeftPressed;
|
||||
options.customThemeRightPressed = optionsProto.customThemeRightPressed;
|
||||
options.customThemeB1Pressed = optionsProto.customThemeB1Pressed;
|
||||
options.customThemeB2Pressed = optionsProto.customThemeB2Pressed;
|
||||
options.customThemeB3Pressed = optionsProto.customThemeB3Pressed;
|
||||
options.customThemeB4Pressed = optionsProto.customThemeB4Pressed;
|
||||
options.customThemeL1Pressed = optionsProto.customThemeL1Pressed;
|
||||
options.customThemeR1Pressed = optionsProto.customThemeR1Pressed;
|
||||
options.customThemeL2Pressed = optionsProto.customThemeL2Pressed;
|
||||
options.customThemeR2Pressed = optionsProto.customThemeR2Pressed;
|
||||
options.customThemeS1Pressed = optionsProto.customThemeS1Pressed;
|
||||
options.customThemeS2Pressed = optionsProto.customThemeS2Pressed;
|
||||
options.customThemeA1Pressed = optionsProto.customThemeA1Pressed;
|
||||
options.customThemeA2Pressed = optionsProto.customThemeA2Pressed;
|
||||
options.customThemeL3Pressed = optionsProto.customThemeL3Pressed;
|
||||
options.customThemeR3Pressed = optionsProto.customThemeR3Pressed;
|
||||
options.buttonPressColorCooldownTimeInMs = optionsProto.buttonPressColorCooldownTimeInMs;
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
void AnimationStorage::save()
|
||||
{
|
||||
Storage::getInstance().enqueueAnimationOptionsSave(AnimationStation::options);
|
||||
}
|
||||
|
||||
@@ -257,7 +257,6 @@ app.get('/api/getLedOptions', (req, res) => {
|
||||
pledIndex4: 15,
|
||||
pledColor: 65280,
|
||||
caseRGBType: 0,
|
||||
caseRGBColor: 65280,
|
||||
caseRGBIndex: -1,
|
||||
caseRGBCount: 0,
|
||||
turnOffWhenSuspended: 0,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Definitions in this file should match those in GP2040-CE/lib/AnimationStation/src/Animation.hpp
|
||||
// Definitions in this file should match those in GP2040-CE/lib/AnimationStation/src/animation.hpp
|
||||
|
||||
import { rgbArrayToHex } from '../Services/Utilities';
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ export default {
|
||||
'case-count-label': 'RGB LED Count',
|
||||
'case-type-label': 'Color Type',
|
||||
'case-type-off': 'Off',
|
||||
'case-type-static': 'Static',
|
||||
'case-color-label': 'Case RGB Color',
|
||||
'case-type-ambient': 'Ambient',
|
||||
'case-type-linked': 'Linked',
|
||||
},
|
||||
'pled-pin-label': 'PLED #{{pin}} Pin',
|
||||
'pled-index-label': 'PLED #{{index}} Index',
|
||||
|
||||
@@ -41,6 +41,12 @@ const PLED_LABELS = [
|
||||
{ 0: 'PLED #4 Pin', 1: 'PLED #4 Index' },
|
||||
];
|
||||
|
||||
const CASE_TYPE = [
|
||||
{ value: -1, label: 'Off'},
|
||||
{ value: 0, label: 'Ambient'},
|
||||
{ value: 1, label: 'Linked'}
|
||||
];
|
||||
|
||||
const defaultValue = {
|
||||
brightnessMaximum: 255,
|
||||
brightnessSteps: 5,
|
||||
@@ -61,7 +67,6 @@ const defaultValue = {
|
||||
caseRGBType: 0,
|
||||
caseRGBIndex: -1,
|
||||
caseRGBCount: 0,
|
||||
caseRGBColor: '#00ff00',
|
||||
ledButtonMap: {},
|
||||
};
|
||||
|
||||
@@ -142,7 +147,6 @@ const schema = yup.object().shape({
|
||||
.validateMinWhenEqualTo('pledType', 1, 0),
|
||||
turnOffWhenSuspended: yup.number().label('Turn Off When Suspended'),
|
||||
caseRGBType: yup.number().required().label('Case RGB Type'),
|
||||
caseRGBColor: yup.string().label('Case RGB LEDs').validateColor(),
|
||||
caseRGBCount: yup
|
||||
.number()
|
||||
.required()
|
||||
@@ -256,6 +260,10 @@ export default function LEDConfigPage() {
|
||||
p[1] = t(`LedConfig:pled-index-label`, { index: n });
|
||||
});
|
||||
|
||||
CASE_TYPE[0].label = t(`LedConfig:case.case-type-off`);
|
||||
CASE_TYPE[1].label = t(`LedConfig:case.case-type-ambient`);
|
||||
CASE_TYPE[2].label = t(`LedConfig:case.case-type-linked`);
|
||||
|
||||
const ledOrderChanged = (setFieldValue, ledOrderArrays, ledsPerButton) => {
|
||||
if (ledOrderArrays.length === 2) {
|
||||
setRgbLedStartIndex(ledOrderArrays[1].length * (ledsPerButton || 0));
|
||||
@@ -287,7 +295,6 @@ export default function LEDConfigPage() {
|
||||
const data = {
|
||||
...values,
|
||||
pledColor: hexToInt(values.pledColor || '#000000'),
|
||||
caseRGBColor: hexToInt(values.caseRGBColor || '#000000'),
|
||||
};
|
||||
|
||||
const success = await WebApi.setLedOptions(data);
|
||||
@@ -677,12 +684,11 @@ export default function LEDConfigPage() {
|
||||
setFieldValue('caseRGBType', parseInt(e.target.value))
|
||||
}
|
||||
>
|
||||
<option value="-1" defaultValue={true}>
|
||||
{t('LedConfig:case.case-type-off')}
|
||||
</option>
|
||||
<option value="0">
|
||||
{t('LedConfig:case.case-type-static')}
|
||||
</option>
|
||||
{CASE_TYPE.map((o, i) => (
|
||||
<option key={`caseType-option-${i}`} value={o.value}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</FormSelect>
|
||||
<FormControl
|
||||
type="number"
|
||||
@@ -714,35 +720,6 @@ export default function LEDConfigPage() {
|
||||
}
|
||||
min={0}
|
||||
/>
|
||||
<FormControl
|
||||
label={t('LedConfig:case.case-color-label')}
|
||||
hidden={parseInt(values.caseRGBType) !== 0}
|
||||
name="caseRGBColor"
|
||||
className="form-control-sm"
|
||||
groupClassName="col-sm-2 mb-3"
|
||||
value={values.caseRGBColor}
|
||||
error={errors.caseRGBColor}
|
||||
isInvalid={errors.caseRGBColor}
|
||||
onBlur={handleBlur}
|
||||
onClick={toggleRgbPledPicker}
|
||||
onChange={(e) => {
|
||||
handleChange(e);
|
||||
setShowPicker(false);
|
||||
}}
|
||||
/>
|
||||
<ColorPicker
|
||||
name="caseRGBColor"
|
||||
types={[{ value: values.caseRGBColor }]}
|
||||
onChange={(c) => setFieldValue('caseRGBColor', c)}
|
||||
onDismiss={() => setShowPicker(false)}
|
||||
placement="top"
|
||||
presetColors={LEDColors.map((c) => ({
|
||||
title: c.name,
|
||||
color: c.value,
|
||||
}))}
|
||||
show={showPicker}
|
||||
target={colorPickerTarget}
|
||||
></ColorPicker>
|
||||
</Row>
|
||||
<p>{t('LedConfig:case.sub-header-text')}</p>
|
||||
</Form.Group>
|
||||
|
||||
@@ -303,8 +303,6 @@ async function getLedOptions(setLoading) {
|
||||
setLoading(false);
|
||||
|
||||
response.data.pledColor = rgbIntToHex(response.data.pledColor) || '#ffffff';
|
||||
response.data.caseRGBColor =
|
||||
rgbIntToHex(response.data.caseRGBColor) || '#ffffff';
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user