Skip to content

Commit

Permalink
general updates
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyWu98 committed Sep 10, 2023
1 parent fa0e326 commit 7d99a46
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 107 deletions.
4 changes: 3 additions & 1 deletion CAD/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
~$*.SLDASM

# ignore OS X desktops
.DS_Store
.DS_Store

RFQs
4 changes: 2 additions & 2 deletions CAD/050_ASSEMBLY.SLDASM
Git LFS file not shown
4 changes: 2 additions & 2 deletions CAD/051_PCB_ASSEMBLY.SLDASM
Git LFS file not shown
4 changes: 2 additions & 2 deletions CAD/154_PAD.SLDPRT
Git LFS file not shown
Binary file added CAD/250_KNOB.SLDDRW
Binary file not shown.
4 changes: 2 additions & 2 deletions CAD/250_KNOB.SLDPRT
Git LFS file not shown
4 changes: 2 additions & 2 deletions CAD/350_EC11E1_ENCODER.SLDPRT
Git LFS file not shown
4 changes: 2 additions & 2 deletions CAD/350_PCB.SLDPRT
Git LFS file not shown
3 changes: 3 additions & 0 deletions CAD/EE Export/bitmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions CAD/HRO_TYPE-C-31-M-12.step
Git LFS file not shown
3 changes: 2 additions & 1 deletion ECAD/FluxpadKicad/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ fp-info-cache
*.csv

# Production Packages
*.zip
*.zip
jlcpcb
21 changes: 18 additions & 3 deletions FW/fluxpad_rp2040_pio/src/HIDKeyboardService.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,29 @@ class HIDKeyboard {
}

/**
* @brief Get whether key is currently pressed or released
* @brief Get whether the given key is currently pressed or released
*
* @return true
* @return false
*/
bool isPressed(uint8_t key) const {
for (const auto &pressed_key : pressed_keys) {
if (pressed_key == key) {
return true;
}
}
return false;
}

/**
* @brief Get whether the any key is currently pressed or released
*
* @return true
* @return false
*/
bool isPressed() const {
for (const auto &key : pressed_keys) {
if (key != 0) {
for (const auto &pressed_key : pressed_keys) {
if (pressed_key != 0) {
return true;
}
}
Expand Down
95 changes: 38 additions & 57 deletions FW/fluxpad_rp2040_pio/src/RBGLed.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@ constexpr uint8_t DATA_PIN = 11u;

CRGB leds[NUM_LEDS];

enum class RGBState {
OFF,
DISCONNECTED,
CONNECTED,
};

enum class RGBMode { OFF, STATIC, RAINBOW };

typedef struct {
RGBState connectedState;
RGBMode mode;
uint32_t color_1;
uint32_t color_2;
uint32_t color_3;
Expand All @@ -35,82 +29,69 @@ class RGBLeds {

private:
// uint8_t data_pin;
RGBState state;

void rainbow() {
// FastLED's built-in rainbow generator
uint8_t thisHue = beat8(20); // A simple rainbow march.
fill_rainbow(leds, NUM_LEDS, thisHue, 255 / 10);
}

void addGlitter(fract8 chanceOfGlitter) {
if (random8() < chanceOfGlitter) {
leds[random16(NUM_LEDS)] += CRGB::White;
}
}

void rainbowWithGlitter() {
// built-in FastLED rainbow, plus some random sparkly glitter
rainbow();
// addGlitter(80);
}
RGBSettings &settings;

public:
RGBLeds() : state(RGBState::OFF){};
RGBLeds(RGBSettings &settings) : settings(settings){};

void setup() {
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); // GRB ordering is assumed
new_mode();
}

void loop_service() {
switch (state) {
case RGBState::OFF:
switch (settings.mode) {
case RGBMode::OFF:
// Nothing
break;
case RGBState::CONNECTED:
connected_state();
break;
case RGBState::DISCONNECTED:
case RGBMode::STATIC:
// Nothing
break;
case RGBMode::RAINBOW:
rainbow_mode();
break;
}
}

void set_state(RGBState new_state) {
switch (new_state) {
case RGBState::OFF:
if (state != RGBState::OFF) {
state = RGBState::OFF;
turn_off();
}
void assign_settings(RGBSettings &new_settings) {
settings = new_settings;
new_mode();
}

void new_mode() {
Serial.printf("newmode");
switch (settings.mode) {
case RGBMode::OFF:
turn_off();
break;
case RGBState::CONNECTED:
if (state != RGBState::CONNECTED) {
state = RGBState::CONNECTED;
}
case RGBMode::STATIC:
static_mode();
break;
case RGBState::DISCONNECTED:
if (state != RGBState::DISCONNECTED) {
state = RGBState::DISCONNECTED;
show_disconnected_state();
}
case RGBMode::RAINBOW:
settings.mode = RGBMode::RAINBOW;
break;
}
}

void connected_state() {
// leds[0] = CRGB::Red;
// leds[1] = CRGB::Green;
// leds[2] = CRGB::Blue;
// rainbowWithGlitter();
rainbow();
void rainbow_mode() {
// FastLED's built-in rainbow generator
uint8_t thisHue = beat8(static_cast<accum88>(settings.speed_bpm)); // A simple rainbow march.
fill_rainbow(leds, NUM_LEDS, thisHue, 255 / 10);

FastLED.show(settings.brightness);
}

FastLED.show(100);
void static_mode() {
Serial.print("static");
leds[0].setColorCode(settings.color_1);
leds[1].setColorCode(settings.color_2);
leds[2].setColorCode(settings.color_3);
FastLED.show(settings.brightness);
}

void show_disconnected_state() {
for (auto &led : leds) {
led = CRGB::Crimson;
led = CRGB::Red;
}
FastLED.show(20);
}
Expand Down
Loading

0 comments on commit 7d99a46

Please sign in to comment.