diff --git a/CAD/.gitignore b/CAD/.gitignore index e96d9fc..a4228b8 100644 --- a/CAD/.gitignore +++ b/CAD/.gitignore @@ -6,4 +6,6 @@ ~$*.SLDASM # ignore OS X desktops -.DS_Store \ No newline at end of file +.DS_Store + +RFQs \ No newline at end of file diff --git a/CAD/050_ASSEMBLY.SLDASM b/CAD/050_ASSEMBLY.SLDASM index e99a615..52f163c 100644 --- a/CAD/050_ASSEMBLY.SLDASM +++ b/CAD/050_ASSEMBLY.SLDASM @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b448fcd9653bce323827064c22b6b23eeb1cb19435899f5c6738744d0e4139bc -size 3551860 +oid sha256:affdcccac6d2e9bd38d7dfb8da886ed4e39c85ef4ec38155c97f203f2412d969 +size 3563651 diff --git a/CAD/051_PCB_ASSEMBLY.SLDASM b/CAD/051_PCB_ASSEMBLY.SLDASM index 1deccea..3e9400d 100644 --- a/CAD/051_PCB_ASSEMBLY.SLDASM +++ b/CAD/051_PCB_ASSEMBLY.SLDASM @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:04f774a42df7d5a3dedcd253b2fe488ae81083016ddcfe87f3ad624f37ea2fa3 -size 400564 +oid sha256:7ac0f11ae4baa65997f28b588118555355f3110617a8206d06d72b07d6eb5d67 +size 321517 diff --git a/CAD/154_PAD.SLDPRT b/CAD/154_PAD.SLDPRT index 7859255..fd5efc2 100644 --- a/CAD/154_PAD.SLDPRT +++ b/CAD/154_PAD.SLDPRT @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b3b3f1d9a6160e67c4e00a98dfea05d36fa460361c5a8abe3d77430a216a4516 -size 282968 +oid sha256:2c6644b3771422434a15cb7cea488b18fe2c7515470bfc3dfcf779fee70da7d7 +size 226079 diff --git a/CAD/250_KNOB.SLDDRW b/CAD/250_KNOB.SLDDRW new file mode 100644 index 0000000..0de4815 Binary files /dev/null and b/CAD/250_KNOB.SLDDRW differ diff --git a/CAD/250_KNOB.SLDPRT b/CAD/250_KNOB.SLDPRT index 0a7b851..4580322 100644 --- a/CAD/250_KNOB.SLDPRT +++ b/CAD/250_KNOB.SLDPRT @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:56a01be7393a557384056919a525e0516f35f409b5f2d04a932dfd7322fad71e -size 66428 +oid sha256:27dfae256111a456cc2311ab0dbbc030890f4bb29c40746a619a80f513683c68 +size 76442 diff --git a/CAD/350_EC11E1_ENCODER.SLDPRT b/CAD/350_EC11E1_ENCODER.SLDPRT index a6a700f..4f8c082 100644 --- a/CAD/350_EC11E1_ENCODER.SLDPRT +++ b/CAD/350_EC11E1_ENCODER.SLDPRT @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:69b7bb88e83263ab6f4d2ff1f3edec412adb0e2b25cd8d49a093cd6057545321 -size 274881 +oid sha256:1c93db4ffaa16057b5bfa3d3bbcb7f2bec82a499b39e48ee14dae6fac2b31d55 +size 290395 diff --git a/CAD/350_PCB.SLDPRT b/CAD/350_PCB.SLDPRT index 11d4af1..3b89e9d 100644 --- a/CAD/350_PCB.SLDPRT +++ b/CAD/350_PCB.SLDPRT @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f6bd8034d4c437219601deda68683d2fd463a3b5deba84a29f8d44efc1416ee1 -size 219590 +oid sha256:f3c53d223282e6e3c369b79f5da461da01fc1813f5971c388473646f70fe5e76 +size 217331 diff --git a/CAD/EE Export/bitmap.png b/CAD/EE Export/bitmap.png new file mode 100644 index 0000000..6e920b4 --- /dev/null +++ b/CAD/EE Export/bitmap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7c1339f69a4efd494d1d9e4e4c5c981091ffa3b0dad7197fb177bf9d6919da2b +size 211279 diff --git a/CAD/HRO_TYPE-C-31-M-12.step b/CAD/HRO_TYPE-C-31-M-12.step new file mode 100644 index 0000000..de15c88 --- /dev/null +++ b/CAD/HRO_TYPE-C-31-M-12.step @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:77088cb61a1fb717dfe29943f591b64c29b61472b74104554725db11b5e94078 +size 717597 diff --git a/ECAD/FluxpadKicad/.gitignore b/ECAD/FluxpadKicad/.gitignore index 87ef4b5..b6f9663 100644 --- a/ECAD/FluxpadKicad/.gitignore +++ b/ECAD/FluxpadKicad/.gitignore @@ -29,4 +29,5 @@ fp-info-cache *.csv # Production Packages -*.zip \ No newline at end of file +*.zip +jlcpcb \ No newline at end of file diff --git a/FW/fluxpad_rp2040_pio/src/HIDKeyboardService.hpp b/FW/fluxpad_rp2040_pio/src/HIDKeyboardService.hpp index 8ab85d4..b01dc72 100644 --- a/FW/fluxpad_rp2040_pio/src/HIDKeyboardService.hpp +++ b/FW/fluxpad_rp2040_pio/src/HIDKeyboardService.hpp @@ -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; } } diff --git a/FW/fluxpad_rp2040_pio/src/RBGLed.h b/FW/fluxpad_rp2040_pio/src/RBGLed.h index 49561eb..61c59db 100644 --- a/FW/fluxpad_rp2040_pio/src/RBGLed.h +++ b/FW/fluxpad_rp2040_pio/src/RBGLed.h @@ -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; @@ -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(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(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); } diff --git a/FW/fluxpad_rp2040_pio/src/flux_arduino.ino b/FW/fluxpad_rp2040_pio/src/flux_arduino.ino index 9222b04..7e87b9b 100644 --- a/FW/fluxpad_rp2040_pio/src/flux_arduino.ino +++ b/FW/fluxpad_rp2040_pio/src/flux_arduino.ino @@ -94,7 +94,7 @@ StorageVars_t storage_vars; // EncoderTool::PolledEncoder encoder; RotaryEncoder encoder(ENC_A_PIN, ENC_B_PIN, RotaryEncoder::LatchMode::FOUR3); -RGBLeds rgb_leds; +RGBLeds rgb_leds(storage_vars.rgbSettings); DigitalSwitch digitalKeys[] = { DigitalSwitch(KEY0_PIN, 0), @@ -196,25 +196,9 @@ void loop() { } } - // if (curr_time_us - last_blink_time_us > blink_period_us) { - // last_blink_time_us = curr_time_us; - - // if (!TinyUSBDevice.mounted()) { - // rgb_leds.set_state(RGBState::DISCONNECTED); - // } else { - // // rgb_leds.set_state(storage_vars.rgbSettings.connectedState); - // rgb_leds.set_state(RGBState::CONNECTED); - // } - - // rgb_leds.loop_service(); - - // // Serial.printf("A: %d, B: %d, Enc pos: %d\n", digitalRead(ENC_A_PIN), digitalRead(ENC_B_PIN), - // // encoder.getPosition()); - // } + // Run RGB Lights rgb_light_service(curr_time_us); - // Keyboard.removeAll(); - for (AnalogSwitch &key : analogKeys) { // key.setCurrentReading(adc_input.); key.mainLoopService(); @@ -272,7 +256,7 @@ void loop() { encoder.setPosition(0); } - // Run Lighting + // Run Key Lighting for (KeyLighting &lighting : keyLighting) { lighting.lightingTask(curr_time_us); } @@ -310,11 +294,10 @@ void typeHIDKey(const KeyMapEntry_t *entry) { void pressHIDKey(const KeyMapEntry_t *entry) { switch (entry->keyType) { case KeyType_t::KEYBOARD: - // Keyboard.add(KeyboardKeycode(entry->keycode.keyboard)); keyboard_device.add_key(entry->keycode.keyboard); break; case KeyType_t::CONSUMER: - // Consumer.press(ConsumerKeycode(entry->keycode.consumer)); + // None, only type supported break; case KeyType_t::MOUSE: // Unsupported for now @@ -327,11 +310,12 @@ void pressHIDKey(const KeyMapEntry_t *entry) { void releaseHIDKey(const KeyMapEntry_t *entry) { switch (entry->keyType) { case KeyType_t::KEYBOARD: - // Keyboard.remove(KeyboardKeycode(entry->keycode.keyboard)); + // if (!keyboard_device.isPressed(entry->keycode.keyboard)) { keyboard_device.remove_key(entry->keycode.keyboard); + // } break; case KeyType_t::CONSUMER: - // Consumer.release(ConsumerKeycode(entry->keycode.consumer)); + // None, only type supported break; case KeyType_t::MOUSE: // Unsupported for now @@ -345,17 +329,14 @@ void rgb_light_service(uint64_t curr_time_us) { if (curr_time_us - last_blink_time_us > blink_period_us) { last_blink_time_us = curr_time_us; - if (TinyUSBDevice.mounted()) { - rgb_leds.set_state(RGBState::CONNECTED); - } else { - // rgb_leds.set_state(storage_vars.rgbSettings.connectedState); - rgb_leds.set_state(RGBState::DISCONNECTED); - } + // if (TinyUSBDevice.mounted()) { + // // rgb_leds.set_state(RGBState::CONNECTED); + // } else { + // // rgb_leds.set_state(storage_vars.rgbSettings.connectedState); + // // rgb_leds.set_state(RGBState::DISCONNECTED); + // } rgb_leds.loop_service(); - - // Serial.printf("A: %d, B: %d, Enc pos: %d\n", digitalRead(ENC_A_PIN), digitalRead(ENC_B_PIN), - // encoder.getPosition()); } } @@ -451,7 +432,14 @@ void fillDefaultStorageVars(StorageVars_t *_storage_vars) { }; // Set RGB - _storage_vars->rgbSettings.connectedState = RGBState::CONNECTED; + _storage_vars->rgbSettings = { + .mode = RGBMode::RAINBOW, + .color_1 = CRGB::Red, + .color_2 = CRGB::Green, + .color_3 = CRGB::Blue, + .brightness = 255u, + .speed_bpm = 20.0, + }; } /** @@ -669,6 +657,32 @@ void read_serial() { datastream_period_ms = request_msg["dstrm"].as(); } + // RGB Lighting settings + if (request_msg.containsKey("rgb_m")) { + storage_vars.rgbSettings.mode = static_cast(request_msg["rgb_m"].as()); + rgb_leds.new_mode(); + } + if (request_msg.containsKey("rgb_b")) { + storage_vars.rgbSettings.brightness = request_msg["rgb_b"].as(); + rgb_leds.new_mode(); + } + if (request_msg.containsKey("rgb_c1")) { + storage_vars.rgbSettings.color_1 = request_msg["rgb_c1"].as(); + rgb_leds.new_mode(); + } + if (request_msg.containsKey("rgb_c2")) { + storage_vars.rgbSettings.color_1 = request_msg["rgb_c2"].as(); + rgb_leds.new_mode(); + } + if (request_msg.containsKey("rgb_c3")) { + storage_vars.rgbSettings.color_1 = request_msg["rgb_c3"].as(); + rgb_leds.new_mode(); + } + if (request_msg.containsKey("rgb_s")) { + storage_vars.rgbSettings.speed_bpm = request_msg["rgb_s"].as(); + rgb_leds.new_mode(); + } + // Clear Flash Memory datastream mode if (request_msg.containsKey("clear")) { if (request_msg["clear"].as() == 1234u) { @@ -771,6 +785,25 @@ void read_serial() { } } + if (request_msg.containsKey("rgb_m")) { + response_msg["rgb_m"] = static_cast(storage_vars.rgbSettings.mode); + } + if (request_msg.containsKey("rgb_b")) { + response_msg["rgb_b"] = static_cast(storage_vars.rgbSettings.brightness); + } + if (request_msg.containsKey("rgb_c1")) { + response_msg["rgb_c1"] = storage_vars.rgbSettings.color_1; + } + if (request_msg.containsKey("rgb_c2")) { + response_msg["rgb_c2"] = storage_vars.rgbSettings.color_2; + } + if (request_msg.containsKey("rgb_c3")) { + response_msg["rgb_c3"] = storage_vars.rgbSettings.color_3; + } + if (request_msg.containsKey("rgb_s")) { + response_msg["rgb_s"] = storage_vars.rgbSettings.speed_bpm; + } + } // V: Get Version