From 5611eb881777727d63624e255904f743e7ff59f1 Mon Sep 17 00:00:00 2001 From: Ed Walker Date: Mon, 18 Jan 2021 18:45:43 -0800 Subject: [PATCH] Update part link, and some more cleanup. --- README.md | 2 +- visca-controller/visca-controller.h | 40 +++++++++++++-------------- visca-controller/visca-controller.ino | 10 +++++-- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 962a1e1..5cd4d1d 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ camera's control port with a standard ethernet cable. |4pin Molex Housing|2| |[Link](https://www.mouser.com/ProductDetail/538-22-01-3047/)| |8pin Molex Header|2| |[Link](https://www.mouser.com/ProductDetail/538-22-23-2081/)| |8pin Molex Housing|2| |[Link](https://www.mouser.com/ProductDetail/538-22-01-3087/)| -|Crimp contacts for Molex housings|Lots| |[Link](https://www.mouser.com/ProductDetail/538-08-50-0114/)| +|Crimp contacts for Molex housings|Lots| |[Link](https://www.mouser.com/ProductDetail/538-08-51-0108-LP/)| |Crimp tool for Molex contacts|1| |[Link](https://www.amazon.com/gp/product/B078WPT5M1/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1)| |Bunch of single row 2.54 pitch pin headers|Bunch| | | |10k Ohm Resistors|10| | diff --git a/visca-controller/visca-controller.h b/visca-controller/visca-controller.h index 00d0715..0cec5a4 100644 --- a/visca-controller/visca-controller.h +++ b/visca-controller/visca-controller.h @@ -21,27 +21,27 @@ #define VISCATX 3 // Button inputs -//#define BTN1 4 -//#define BTN2 5 -//#define BTN3 6 -//#define BTN4 7 -//#define BTN5 8 -//#define BTN6 9 -//#define BTN7 10 -//#define BTN8 11 -//#define BTN9 12 -//#define BTN10 13 +#define BTN1 4 +#define BTN2 5 +#define BTN3 6 +#define BTN4 7 +#define BTN5 8 +#define BTN6 9 +#define BTN7 10 +#define BTN8 11 +#define BTN9 12 +#define BTN10 13 int buttons[] = { - 4, // BTN1 - 5, // BTN2 - 6, // BTN3 - 7, // BTN4 - 8, // BTN5 - 9, // BTN6 - 10, // BTN7 - 11, // BTN8 - 12, // BTN9 - 13 // BTN10 + BTN1, + BTN2, + BTN3, + BTN4, + BTN5, + BTN6, + BTN7, + BTN8, + BTN9, + BTN10 }; diff --git a/visca-controller/visca-controller.ino b/visca-controller/visca-controller.ino index 11e08f8..b120f06 100644 --- a/visca-controller/visca-controller.ino +++ b/visca-controller/visca-controller.ino @@ -101,9 +101,7 @@ void processButtons() { if(millis() > time_now + 100) { time_now = millis(); - for (int i = 0; i < sizeof(buttons) / sizeof (buttons [0]); i++) { - bitWrite(buttonCurrentStatus, buttons[i], (int) digitalRead(buttons[i])); - } + collectCurrentButtonStatus(); int btn1 = buttons[0]; if(buttonPressed(btn1) == true) { @@ -133,6 +131,12 @@ void processButtons() { } } +void collectCurrentButtonStatus() { + for (int i = 0; i < sizeof(buttons) / sizeof (buttons [0]); i++) { + bitWrite(buttonCurrentStatus, buttons[i], (int) digitalRead(buttons[i])); + } +} + bool buttonPressed(uint8_t button) { return getCurrentButtonStatus(button) == true && getPreviousButtonStatus(button) == false; }