Skip to content

Commit

Permalink
Merge pull request #11 from arntsonl/inputauth_update
Browse files Browse the repository at this point in the history
Force merging main into branch
  • Loading branch information
arntsonl committed Mar 20, 2024
2 parents e303a28 + 05793ec commit b7efe14
Show file tree
Hide file tree
Showing 47 changed files with 1,807 additions and 640 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ src/display/ui/screens/SplashScreen.cpp
src/display/GPGFX.cpp
src/display/GPGFX_UI.cpp
src/drivermanager.cpp
src/layoutmanager.cpp
src/peripheralmanager.cpp
src/storagemanager.cpp
src/system.cpp
Expand All @@ -210,6 +211,7 @@ src/addons/display.cpp
src/addons/neopicoleds.cpp
src/addons/playernum.cpp
src/addons/playerleds.cpp
src/addons/rotaryencoder.cpp
src/addons/reverse.cpp
src/addons/turbo.cpp
src/addons/slider_socd.cpp
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

## Links

[Downloads](https://gp2040-ce.info/downloads/download-page) | [Installation](https://gp2040-ce.info/installation) | [Wiring](https://gp2040-ce.info/controller-build/wiring) | [Usage](https://gp2040-ce.info/usage) | [FAQ](https://gp2040-ce.info/faq/faq-general) | [GitHub](https://github.com/OpenStickCommunity/GP2040-CE)
[Downloads](https://gp2040-ce.info/downloads) | [Installation](https://gp2040-ce.info/installation) | [Wiring](https://gp2040-ce.info/controller-build/wiring) | [Usage](https://gp2040-ce.info/usage) | [FAQ](https://gp2040-ce.info/faq/faq-general) | [GitHub](https://github.com/OpenStickCommunity/GP2040-CE)

Full documentation can be found at [https://gp2040-ce.info](https://gp2040-ce.info)

Expand Down
4 changes: 2 additions & 2 deletions configs/BentoBox/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@

#define HAS_I2C_DISPLAY 1
#define I2C1_ENABLED 1
#define I2C1_SDA 26
#define I2C1_SCL 27
#define I2C1_PIN_SDA 26
#define I2C1_PIN_SCL 27
#define DISPLAY_I2C_BLOCK i2c1
#define I2C_SPEED 800000

Expand Down
4 changes: 2 additions & 2 deletions configs/FightboardV3/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@

#define HAS_I2C_DISPLAY 1
#define I2C1_ENABLED 1
#define I2C1_SDA 14
#define I2C1_SCL 15
#define I2C1_PIN_SDA 14
#define I2C1_PIN_SCL 15
#define DISPLAY_I2C_BLOCK i2c1

#define BUTTON_LAYOUT BUTTON_LAYOUT_FIGHTBOARD_STICK
Expand Down
4 changes: 2 additions & 2 deletions configs/FightboardV3Mirrored/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@

#define HAS_I2C_DISPLAY 1
#define I2C1_ENABLED 1
#define I2C1_SDA 10
#define I2C1_SCL 11
#define I2C1_PIN_SDA 10
#define I2C1_PIN_SCL 11
#define DISPLAY_I2C_BLOCK i2c1

#define BUTTON_LAYOUT BUTTON_LAYOUT_FIGHTBOARD_MIRRORED
Expand Down
4 changes: 2 additions & 2 deletions configs/Liatris/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@

#define HAS_I2C_DISPLAY 1
#define I2C0_ENABLED 1
#define I2C0_SDA 12
#define I2C0_SCL 13
#define I2C0_PIN_SDA 12
#define I2C0_PIN_SCL 13
#define DISPLAY_I2C_BLOCK i2c0

#define BUZZER_ENABLED 1
Expand Down
4 changes: 2 additions & 2 deletions configs/OpenCore0/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@

#define HAS_I2C_DISPLAY 1
#define I2C0_ENABLED 1
#define I2C0_SDA 0
#define I2C0_SCL 1
#define I2C0_PIN_SDA 0
#define I2C0_PIN_SCL 1
#define DISPLAY_I2C_BLOCK i2c0
#define DISPLAY_FLIP 3

Expand Down
4 changes: 2 additions & 2 deletions configs/OpenCore0WASD/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@

#define HAS_I2C_DISPLAY 1
#define I2C0_ENABLED 1
#define I2C0_SDA 0
#define I2C0_SCL 1
#define I2C0_PIN_SDA 0
#define I2C0_PIN_SCL 1
#define DISPLAY_I2C_BLOCK i2c0
#define DISPLAY_FLIP 3

Expand Down
7 changes: 4 additions & 3 deletions configs/PicoAnn/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@
#define PLED4_PIN 19

#define HAS_I2C_DISPLAY 0
#define I2C_SDA_PIN 26
#define I2C_SCL_PIN 27
#define I2C_BLOCK i2c1
#define I2C1_ENABLED 1
#define I2C1_PIN_SDA 26
#define I2C1_PIN_SCL 27
#define DISPLAY_I2C_BLOCK i2c1

#define BUTTON_LAYOUT BUTTON_LAYOUT_STICK
#define BUTTON_LAYOUT_RIGHT BUTTON_LAYOUT_VEWLIX
Expand Down
4 changes: 2 additions & 2 deletions configs/PicoFightingBoard/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@

#define HAS_I2C_DISPLAY 1
#define I2C1_ENABLED 1
#define I2C1_SDA 26
#define I2C1_SCL 27
#define I2C1_PIN_SDA 26
#define I2C1_PIN_SCL 27
#define DISPLAY_I2C_BLOCK i2c1


Expand Down
4 changes: 2 additions & 2 deletions configs/RP2040AdvancedBreakoutBoard/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@

#define HAS_I2C_DISPLAY 1
#define I2C0_ENABLED 1
#define I2C0_SDA 0
#define I2C0_SCL 1
#define I2C0_PIN_SDA 0
#define I2C0_PIN_SCL 1
#define DISPLAY_I2C_BLOCK i2c0

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@

#define HAS_I2C_DISPLAY 1
#define I2C0_ENABLED 1
#define I2C0_SDA 0
#define I2C0_SCL 1
#define I2C0_PIN_SDA 0
#define I2C0_PIN_SCL 1
#define DISPLAY_I2C_BLOCK i2c0

#define PSPASSTHROUGH_ENABLED 1
Expand Down
4 changes: 2 additions & 2 deletions configs/ReflexEncodeV1.2/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@

#define HAS_I2C_DISPLAY 1
#define I2C0_ENABLED 1
#define I2C0_SDA 0
#define I2C0_SCL 1
#define I2C0_PIN_SDA 0
#define I2C0_PIN_SCL 1
#define DISPLAY_I2C_BLOCK i2c0
#define SPLASH_MODE SPLASH_MODE_STATIC

Expand Down
4 changes: 2 additions & 2 deletions configs/ReflexEncodeV2.0/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@

#define HAS_I2C_DISPLAY 1
#define I2C0_ENABLED 1
#define I2C0_SDA 0
#define I2C0_SCL 1
#define I2C0_PIN_SDA 0
#define I2C0_PIN_SCL 1
#define DISPLAY_I2C_BLOCK i2c0
#define SPLASH_MODE SPLASH_MODE_STATIC

Expand Down
6 changes: 6 additions & 0 deletions headers/addons/buzzerspeaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#define BUZZER_PIN -1
#endif

#ifndef BUZZER_ENABLE_PIN
#define BUZZER_ENABLE_PIN -1
#endif

#ifndef BUZZER_VOLUME
#define BUZZER_VOLUME 100
#endif
Expand Down Expand Up @@ -137,12 +141,14 @@ class BuzzerSpeakerAddon : public GPAddon
void stop();
uint32_t pwmSetFreqDuty(uint slice, uint channel, uint32_t frequency, float duty);
uint8_t buzzerPin;
uint8_t buzzerEnablePin;
uint8_t buzzerPinSlice;
uint8_t buzzerPinChannel;
uint8_t buzzerVolume;
uint32_t startedSongMils;
Song *currentSong;
bool introPlayed;
bool isSpeakerOn = false;
};

#endif
128 changes: 128 additions & 0 deletions headers/addons/rotaryencoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#ifndef _ROTARYENCODER_H
#define _ROTARYENCODER_H

#include "gpaddon.h"

#include "GamepadEnums.h"
#include "types.h"

#ifndef ROTARY_ENCODER_ENABLED
#define ROTARY_ENCODER_ENABLED 0
#endif

#ifndef ENCODER_ONE_ENABLED
#define ENCODER_ONE_ENABLED 0
#endif

#ifndef ENCODER_ONE_PPR
#define ENCODER_ONE_PPR 24
#endif

#ifndef ENCODER_ONE_PIN_A
#define ENCODER_ONE_PIN_A -1
#endif

#ifndef ENCODER_ONE_PIN_B
#define ENCODER_ONE_PIN_B -1
#endif

#ifndef ENCODER_ONE_MODE
#define ENCODER_ONE_MODE ENCODER_MODE_NONE
#endif

#ifndef ENCODER_ONE_WRAP
#define ENCODER_ONE_WRAP 0
#endif

#ifndef ENCODER_ONE_MULTIPLIER
#define ENCODER_ONE_MULTIPLIER 1
#endif

#ifndef ENCODER_TWO_ENABLED
#define ENCODER_TWO_ENABLED 0
#endif

#ifndef ENCODER_TWO_PPR
#define ENCODER_TWO_PPR 24
#endif

#ifndef ENCODER_TWO_PIN_A
#define ENCODER_TWO_PIN_A -1
#endif

#ifndef ENCODER_TWO_PIN_B
#define ENCODER_TWO_PIN_B -1
#endif

#ifndef ENCODER_TWO_MODE
#define ENCODER_TWO_MODE ENCODER_MODE_NONE
#endif

#ifndef ENCODER_TWO_WRAP
#define ENCODER_TWO_WRAP 0
#endif

#ifndef ENCODER_TWO_MULTIPLIER
#define ENCODER_TWO_MULTIPLIER 1
#endif

#define MAX_ENCODERS 2
#define ENCODER_RADIUS 1440 // 4 phases * 360
#define ENCODER_PRECISION 16

// RotaryEncoderName Module Name
#define RotaryEncoderName "Rotary"

class RotaryEncoderInput : public GPAddon {
public:
virtual bool available();
virtual void setup(); // Rotary Setup
virtual void preprocess() {}
virtual void process(); // Rotary process
virtual std::string name() { return RotaryEncoderName; }

typedef struct {
bool enabled = false;
int8_t pinA = -1;
int8_t pinB = -1;
// encoder properties
uint16_t pulsesPerRevolution = 24;
RotaryEncoderPinMode mode = ENCODER_MODE_NONE;
int32_t minRange = -1;
int32_t maxRange = -1;
uint32_t resetAfter = 0;
bool allowWrapAround = false;
double multiplier = 0;
} EncoderPinMap;

typedef struct {
bool pinA = false;
bool pinB = false;
bool prevA = false;
bool prevB = false;
uint32_t updateTime = 0;
uint32_t changeTime = 0;
uint8_t delay = 1;
} EncoderPinState;
private:
EncoderPinState encoderState[MAX_ENCODERS];
int32_t encoderValues[MAX_ENCODERS];
int32_t prevValues[MAX_ENCODERS];
EncoderPinMap encoderMap[MAX_ENCODERS] = {
{false, -1, -1, 24, ENCODER_MODE_NONE, -1, -1},
{false, -1, -1, 24, ENCODER_MODE_NONE, -1, -1},
};

int32_t map(int32_t x, int32_t in_min, int32_t in_max, int32_t out_min, int32_t out_max);
int32_t bounds(int32_t x, int32_t out_min, int32_t out_max);
uint16_t mapEncoderValueStick(int8_t index, int32_t encoderValue, uint16_t ppr);
uint16_t mapEncoderValueTrigger(int8_t index, int32_t encoderValue, uint16_t ppr);
int8_t mapEncoderValueDPad(int8_t index, int32_t encoderValue, uint16_t ppr);

bool dpadUp = false;
bool dpadDown = false;
bool dpadLeft = false;
bool dpadRight = false;
};

#endif // _ROTARYENCODER_H
2 changes: 1 addition & 1 deletion headers/addons/turbo.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class TurboInput : public GPAddon {
uint32_t debChargeTime[4]; // Debounce Charge Button Time
uint16_t lastPressed; // Last buttons pressed (for Turbo Enable)
uint8_t lastDpad; // Last d-pad pressed (for Turbo Change)
uint16_t turboButtonsPressed; // Turbo Buttons Enabled
uint16_t turboButtonsMask; // Turbo Buttons Enabled
uint16_t alwaysEnabled; // Turbo SHMUP Always Enabled
uint32_t uIntervalUS; // Turbo Interval in microseconds
uint32_t chargeState; // Turbo Charge Button States
Expand Down
7 changes: 0 additions & 7 deletions headers/display/GPGFX_UI_layouts.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,4 @@
#include "config.pb.h"
#include "enums.pb.h"

#define GPELEMENT_PARAM_COUNT 12

typedef struct {
GPElement elementType;
uint16_t parameters[GPELEMENT_PARAM_COUNT];
} GPButtonLayout;

#endif
Loading

0 comments on commit b7efe14

Please sign in to comment.