summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruser <user@node5.net>2024-05-07 10:27:44 +0200
committeruser <user@node5.net>2024-05-07 10:27:44 +0200
commit7f9c68adb243fd3550b6847b491c604be704ad12 (patch)
treeb90290b7dcbf82d51660dbf7048176d848e4b46a
parent923bfa12a3859e65a5f62c8e7b726692fd9a6e14 (diff)
Custom keyboard v2 - MCP23017 split breadboard, research QMK support
-rwxr-xr-xCustom keyboard V2/index.md78
1 files changed, 75 insertions, 3 deletions
diff --git a/Custom keyboard V2/index.md b/Custom keyboard V2/index.md
index d01e060..90dc5a2 100755
--- a/Custom keyboard V2/index.md
+++ b/Custom keyboard V2/index.md
@@ -272,8 +272,8 @@ And i followed the wiring described therein. Namely, tie `A0`, `A1` and `A2` to
### MCP23017 C++ code snippet
```c++
-https://blog.node5.net/Custom%20keyboard%20V2#mcp23017-c-code-snippet
-Based on: https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library/blob/master/examples/mcp23xxx_blink/mcp23xxx_blink.ino
+// https://blog.node5.net/Custom%20keyboard%20V2#mcp23017-c-code-snippet
+// Based on: https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library/blob/master/examples/mcp23xxx_blink/mcp23xxx_blink.ino
// Blinks an LED attached to a MCP23017 pin.
#include <Adafruit_MCP23X17.h>
@@ -322,4 +322,76 @@ I've iterated on the thumb cluster design (based on the amazing work by the [Dyg
and I've reached a design that works for me.
![Thumb cluster CAD based on Dygma Defy](Thumb cluster CAD based on Dygma Defy.png)
-![Thumb cluster itterations](Thumb cluster itterations.jpg) \ No newline at end of file
+![Thumb cluster itterations](Thumb cluster itterations.jpg)
+
+### Other QMK keyboards using MCP23017
+
+MCP23017 working principle has been tested. Now it's time to make it work with QMK.
+The following keyboards implement the MCP23017.
+
+```bash
+~/qmk $ grep --color=always -rnie "mcp23017" | cut -d'/' -f2 | uniq
+```
+- [nek_type_a](https://github.com/qmk/qmk_firmware/tree/master/keyboards/nek_type_a)
+- [hotdox](https://github.com/qmk/qmk_firmware/tree/master/keyboards/hotdox)
+- [ergodox_stm32](https://github.com/qmk/qmk_firmware/tree/master/keyboards/ergodox_stm32)
+- [ingrained](https://github.com/qmk/qmk_firmware/tree/master/keyboards/ingrained)
+- [ferris](https://github.com/qmk/qmk_firmware/tree/master/keyboards/ferris)
+
+### MCP23017 breadboard TRRS cable
+
+![MCP23017 breadboard TRRS cable](MCP23017 breadboard TRRS cable.jpg)
+
+I've now moved to using 2 separate breadboards to test if the I²C is stable over the cable (it seems to be).
+Pulling the TRRS cable while powered, doesn't break it, but does require a power cycle to function again.
+
+### MCP23017 button code
+
+```c++
+// https://blog.node5.net/Custom%20keyboard%20V2#mcp23017-button-code
+// Based on: https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library/blob/master/examples/mcp23xxx_combo/mcp23xxx_combo.ino
+#include <Adafruit_MCP23X17.h>
+
+
+#define BLINK_FREQUENCY 1000 // Milliseconds
+#define LED_PIN 8 // LED pin on MCP23017
+#define BUTTON_PIN 7 // Button pin on MCP23017
+
+Adafruit_MCP23X17 mcp;
+int blink_frequency; // Milliseconds
+
+void setup() {
+ Serial.begin(9600);
+ //while (!Serial);
+ Serial.println("MCP23017 Blink Test!");
+ int i = 0;
+ while (!mcp.begin_I2C(i)) {
+ Serial.print("Error with ID:");
+ Serial.println(i);
+ i++;
+ delay(10);
+ }
+ Serial.print("Success with ID:");
+ Serial.println(i);
+
+ mcp.pinMode(LED_PIN, OUTPUT);
+ mcp.pinMode(BUTTON_PIN, INPUT_PULLUP);
+
+ Serial.println("Looping...");
+}
+
+void loop() {
+ // What is an interupt?
+ if (!mcp.digitalRead(BUTTON_PIN)) {
+ // Button pushed, light LED
+ blink_frequency = BLINK_FREQUENCY / 20;
+ } else {
+ blink_frequency = BLINK_FREQUENCY; // Milliseconds
+ }
+ // Alternate state every blink_frequency milliseconds
+ bool state = (millis() % (blink_frequency * 2)) > blink_frequency;
+ Serial.print("State: ");
+ Serial.println(state);
+ mcp.digitalWrite(LED_PIN, state);
+}
+```