summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-01-23 05:32:10 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-01-23 05:32:10 +0300
commit3b5d9fca703aa9c83cad5a1311b88c1fa10750c0 (patch)
tree379b8bf259444e475c2cae7ea22a76fe4a80fccc
parent8242cb40a05201a7e4b22bcc8587a05db4101274 (diff)
downloadshmotbox-3b5d9fca703aa9c83cad5a1311b88c1fa10750c0.tar.gz
some adaptions for the actual hardware I assembledHEADmaster
* poti 7 is still not working, but it's probably a physical problem * use proper tab indentions
-rw-r--r--shmotbox.ino64
1 files changed, 33 insertions, 31 deletions
diff --git a/shmotbox.ino b/shmotbox.ino
index 440d347..f90d053 100644
--- a/shmotbox.ino
+++ b/shmotbox.ino
@@ -8,8 +8,8 @@
*/
class CCPotentiometer14 : public MIDIFilteredAnalog<ContinuousCCSender14<10>> {
public:
- CCPotentiometer14(pin_t analogPin, MIDIAddress address)
- : MIDIFilteredAnalog(analogPin, address, {}) {}
+ CCPotentiometer14(pin_t analogPin, MIDIAddress address)
+ : MIDIFilteredAnalog(analogPin, address, {}) {}
};
static USBMIDI_Interface midi;
@@ -26,55 +26,57 @@ static CCPotentiometer14 pot2 {A2, 0x02};
static CCPotentiometer14 pot3 {A3, 0x03};
static CCPotentiometer14 pot4 {A4, 0x04};
static CCPotentiometer14 pot5 {A5, 0x05};
-static CCPotentiometer14 pot6 {A6, 0x06};
-static CCPotentiometer14 pot7 {A7, 0x07};
-static CCPotentiometer14 pot8 {A8, 0x08};
-static CCPotentiometer14 pot9 {A9, 0x09};
+static CCPotentiometer14 pot6 {A6, 0x06}; // D4
+// FIXME: Is this short-circuited to 5V?
+static CCPotentiometer14 pot7 {A11, 0x07}; // D12
+static CCPotentiometer14 pot8 {A8, 0x08}; // D8
+static CCPotentiometer14 pot9 {A9, 0x09}; // D9
-#if 0
-static CCPotentiometer14 pedal {A10, 0x0A};
-#endif
+static CCPotentiometer14 pedal {A10, 0x0A}; // D10
-static CCRotaryEncoder enc0 {{0, 1}, 0x10};
-/*
- * FIXME: This button does not physically work.
- */
-static CCButton enc0_button {2, 0x11};
+static CCRotaryEncoder enc0 {{3, 1}, 0x10};
+static CCButton enc0_button {0, 0x11};
#if 0
static CCRotaryEncoder enc1 {{3, 5}, 0x12};
static CCButton enc1_button {7, 0x13};
-#endif
static DistanceSensor dist0(11, 13);
static const byte DIST0_ADDRESS = 0x1F;
static const double DIST0_MAX = 40; /* cm */
+#endif
void
setup()
{
- RelativeCCSender::setMode(relativeCCmode::TWOS_COMPLEMENT);
- Control_Surface.begin();
+ RelativeCCSender::setMode(relativeCCmode::TWOS_COMPLEMENT);
+
+ pedal.map([](analog_t x) -> analog_t {
+ static const analog_t max_value = 0xFFFF >> ANALOG_FILTER_SHIFT_FACTOR;
+ return (max(x, max_value/2) - max_value/2)*2;
+ });
+
+ Control_Surface.begin();
}
void
loop()
{
#if 0
- /*
- * FIXME: Should probably be a proper class.
- */
- double dist_cm = dist0.getCM();
- static unsigned short dist_last = 0;
- unsigned short dist_short = min(dist_cm, DIST0_MAX)*0x3FFF/DIST0_MAX;
- if (dist_short != dist_last) {
- Serial.println(dist_cm);
- Serial.println(dist_short);
- midi.sendControlChange(DIST0_ADDRESS | 0x00, (dist_short >> 7) & 0x7F);
- midi.sendControlChange(DIST0_ADDRESS | 0x20, (dist_short >> 0) & 0x7F);
- dist_last = dist_short;
- }
+ /*
+ * FIXME: Should probably be a proper class.
+ */
+ double dist_cm = dist0.getCM();
+ static unsigned short dist_last = 0;
+ unsigned short dist_short = min(dist_cm, DIST0_MAX)*0x3FFF/DIST0_MAX;
+ if (dist_short != dist_last) {
+ Serial.println(dist_cm);
+ Serial.println(dist_short);
+ midi.sendControlChange(DIST0_ADDRESS | 0x00, (dist_short >> 7) & 0x7F);
+ midi.sendControlChange(DIST0_ADDRESS | 0x20, (dist_short >> 0) & 0x7F);
+ dist_last = dist_short;
+ }
#endif
- Control_Surface.loop();
+ Control_Surface.loop();
}