diff --git a/printer-jam.ino b/printer-jam.ino index 1275ccd..24dce4b 100644 --- a/printer-jam.ino +++ b/printer-jam.ino @@ -1,7 +1,5 @@ #include #include -#include - const int C_WHITEHEAD = 1; const int C_WHITEFEED = 2; @@ -23,11 +21,6 @@ const IPAddress ip(192, 168, 1, 171); const IPAddress gateway(192, 168, 1, 1); const IPAddress subnet(255, 255, 255, 0); -Button button1(D3); -Button button2(D7); -Button button3(D8); -Button button4(D4); -Button button5(D5); const int recv_port = 10000; const int send_port = 6060; @@ -69,13 +62,6 @@ void setup() { ; }; - Serial.println("Setting up the buttons"); - button1.begin(); - button2.begin(); - button3.begin(); - button4.begin(); - button5.begin(); - Serial.println(""); Serial.println("WiFi connected."); Serial.print("IP address: "); @@ -201,175 +187,10 @@ void setup() { }; }); - /* OscWiFi.subscribe(recv_port, "/scanner/\*", */ - /* [](const OscMessage& m) { */ - /* float tidalSpeed = m.arg(0); */ - /* String address = m.address(); */ - /* // Serial.println(address); */ - - /* if (STATE_SOLO == C_WHITEFEED || STATE_SOLO == 0) { */ - /* Serial.println(address); */ - /* if (address == "/scanner/f") { */ - /* whiteFeed->run(FORWARD); */ - /* } else if (address == "/scanner/b") { */ - /* whiteFeed->run(BACKWARD); */ - /* } else if (address == "/scanner/~") { */ - /* whiteFeed->run(RELEASE); */ - /* } else if (address == "/scanner/speed") { */ - /* whiteFeedSpeed = tidalSpeed; */ - /* whiteFeed->setSpeed(whiteFeedSpeed); */ - /* } else { */ - /* Serial.println("dont know what to do with this OSC"); */ - /* }; */ - /* } else { */ - /* Serial.println("dont mind me, scanners not part of this solo"); */ - /* }; */ - /* }); */ - } void loop() { OscWiFi.update(); - - bool b1p = button1.pressed(); - bool b2p = button2.pressed(); - bool b4p = button4.pressed(); - bool b5p = button5.pressed(); - - bool b1 = button1.read(); - bool b2 = button2.read(); - bool b4 = button4.read(); - bool b5 = button5.read(); - // Serial.print("b4p"); - // Serial.println(b4p); - - // Give dibs to button 1 - if (b1p && b2 != Button::PRESSED && b4 != Button::PRESSED && b5 != Button::PRESSED) { - Serial.println("solo has dibs"); - featureSolo = true; - } - if (button1.released()) { - Serial.println("solo finished dibs"); - featureSolo = false; - - // handle ending of feature solo; - if (STATE_SOLO != 0) { - Serial.println("stop the solo"); - STATE_SOLO = 0; - blackFeed->run(blackFeedSpeed); - blackHead->run(blackHeadSpeed); - whiteFeed->run(whiteFeedSpeed); - whiteHead->run(whiteHeadSpeed); - } - } - - // give dibs to button 2 - if (b2p && b1 != Button::PRESSED && b4 != Button::PRESSED && b5 != Button::PRESSED) { - Serial.println("B2 has dibs"); - featureB2 = true; - } - if (button2.released()) { - Serial.println("B2 finished dibs"); - - // handle ending of feature B2; - if (featureB2) { - Serial.print("did many calculations and now sending the value of "); - Serial.println(b2Val); - OscWiFi.send(host, send_port, "/ctrl", "b2Val", b2Val); - b2Val = 1; - featureB2 = false; - } - } - - // give dibs to button 4 (and do the thing rightaway); - if (b4p && b1 != Button::PRESSED && b2 != Button::PRESSED && b5 != Button::PRESSED) { - Serial.println("button4 has dibs"); - featureB4 = true; - - int index = random(9); - b4Val = b4choices[index]; - Serial.print("sending feature b4: "); - Serial.println(b4Val); - } - if (button4.released()) { - Serial.println("button4 finished dibs"); - if (featureB4) { - featureB4 = false; - b4Val = "feed"; - } - } - - // feature: SOLO! - if (b1 == Button::PRESSED && featureSolo) { - if (b2p) { - Serial.println("solo feed"); - STATE_SOLO = C_BLACKFEED; - blackHead->run(RELEASE); - blackHead->setSpeed(0); - whiteHead->run(RELEASE); - whiteHead->setSpeed(0); - } - - if (b4p) { - Serial.println("solo head"); - STATE_SOLO = C_BLACKHEAD; - blackFeed->run(RELEASE); - blackFeed->setSpeed(0); - whiteFeed->run(RELEASE); - whiteFeed->setSpeed(0); - } - - /* if (b5p) { */ - /* Serial.println("solo scanner"); */ - /* STATE_SOLO = C_WHITEFEED; */ - /* blackHead->run(RELEASE); */ - /* blackFeed->run(RELEASE); */ - /* blackHead->setSpeed(0); */ - /* blackFeed->setSpeed(0); */ - /* } */ - } - - // feature: Send B2 OSC - if (b2 == Button::PRESSED && featureB2) { - if (b1p) { - float newVal = b2Val * .5; - b2Val = newVal; - Serial.print("2 + 1: "); - Serial.println(b2Val); - } - - if (b4p) { - float newVal = b2Val * 2; - b2Val = newVal; - Serial.print("2 + 4: "); - Serial.println(b2Val); - } - - if (b5p) { - float newVal = b2Val * 4; - b2Val = newVal; - Serial.print("2 + 5: "); - Serial.println(b2Val); - } - } - - // feature: Send a string - if (b4 == Button::PRESSED && featureB4) { - if (b1p) { - Serial.println("sending the string via button 1"); - OscWiFi.send(host, send_port, "/ctrl", "featureB41", b4Val); - } - - if (b2p) { - Serial.println("sending the string via button 1"); - OscWiFi.send(host, send_port, "/ctrl", "featureB42", b4Val); - } - - /* if (b5p) { */ - /* Serial.println("sending the string via button 1"); */ - /* OscWiFi.send(host, send_port, "/ctrl", "featureB43", b4Val); */ - /* } */ - } }