From 21164824f53e5b8af29f667b29ed860fd6f7cfa7 Mon Sep 17 00:00:00 2001 From: philsson Date: Thu, 27 Sep 2018 18:57:53 +0200 Subject: [PATCH] Removed individual NodeMCU sketches --- NodeMCU/Remote.ino/Remote.ino.ino | 183 ---------------------- NodeMCU/SerialProtocol/SerialProtocol.ino | 50 ------ 2 files changed, 233 deletions(-) delete mode 100644 NodeMCU/Remote.ino/Remote.ino.ino delete mode 100644 NodeMCU/SerialProtocol/SerialProtocol.ino diff --git a/NodeMCU/Remote.ino/Remote.ino.ino b/NodeMCU/Remote.ino/Remote.ino.ino deleted file mode 100644 index 8096310..0000000 --- a/NodeMCU/Remote.ino/Remote.ino.ino +++ /dev/null @@ -1,183 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - - Open Sound Control (OSC) library for the ESP8266/ESP32 - - Example for receiving open sound control (OSC) bundles on the ESP8266/ESP32 - Send integers '0' or '1' to the address "/led" to turn on/off the built-in LED of the esp8266. - - This example code is in the public domain. - - Inspired from https://trippylighting.com/teensy-arduino-ect/touchosc-and-arduino-oscuino/ - ---------------------------------------------------------------------------------------------- */ -#ifdef ESP8266 -#include -#else -#include -#endif -#include -#include -#include -#include - -char ssid[] = "FaRgO2G4"; // your network SSID (name) -char pass[] = "Johansson85"; // your network password - -// A UDP instance to let us send and receive packets over UDP -WiFiUDP Udp; -const IPAddress outIp(192,168,1,72); // remote IP (not needed for receive) -const unsigned int outPort = 9999; // remote port (not needed for receive) -const unsigned int localPort = 8888; // local port to listen for UDP packets (here's where we send the packets) - - -OSCErrorCode error; -unsigned int ledState = LOW; // LOW means led is *on* - -#ifndef BUILTIN_LED -#ifdef LED_BUILTIN -#define BUILTIN_LED LED_BUILTIN -#else -#define BUILTIN_LED 13 -#endif -#endif - -void setup() { - pinMode(BUILTIN_LED, OUTPUT); - digitalWrite(BUILTIN_LED, ledState); // turn *on* led - - Serial.begin(115200); - - // Connect to WiFi network - Serial.println(); - Serial.println(); - Serial.print("Connecting to "); - Serial.println(ssid); - WiFi.begin(ssid, pass); - - while (WiFi.status() != WL_CONNECTED) { - delay(500); - Serial.print("."); - } - Serial.println(""); - - Serial.println("WiFi connected"); - Serial.println("IP address: "); - Serial.println(WiFi.localIP()); - - Serial.println("Starting UDP"); - Udp.begin(localPort); - Serial.print("Local port: "); -#ifdef ESP32 - Serial.println(localPort); -#else - Serial.println(Udp.localPort()); -#endif - -} - - -void OSCMsgReceive(){ - OSCMessage msgIN; - int size; - if((size = Udp.parsePacket())>0){ - while(size--) - msgIN.fill(Udp.read()); - if(!msgIN.hasError()){ - msgIN.route("/Robot/Enable",toggleEnabled); - msgIN.route("/Fader/Throttle",funcThrottle); - msgIN.route("/Fader/Steering",funcSteering); - msgIN.route("/Gain/Kp",funcKp); - //msgIN.route("/Gain/Ki",funcKi); - //msgIN.route("/Gain/Kd",funcKd); - } - } -} - -void toggleEnabled(OSCMessage &msg, int addrOffset){ - ledState = (boolean) msg.getFloat(0); - OSCMessage msgOUT("/Robot/Enable"); - - digitalWrite(BUILTIN_LED, !ledState); - - msgOUT.add(ledState); - if (ledState) { - Serial.println("Robot enabled"); - } - else { - Serial.println("Robot disabled"); - } - - //send osc message back to controll object in TouchOSC - //Local feedback is turned off in the TouchOSC interface. - //The button is turned on in TouchOSC interface whe the conrol receives this message. - Udp.beginPacket(Udp.remoteIP(), outPort); - msgOUT.send(Udp); // send the bytes - Udp.endPacket(); // mark the end of the OSC Packet - msgOUT.empty(); // free space occupied by message -} - -void funcThrottle(OSCMessage &msg, int addrOffset ){ - - int value = msg.getFloat(0); - OSCMessage msgOUT("/Fader/Throttle"); - - Serial.print("Throttle = : "); - Serial.println(value); - - msgOUT.add(value); - - Udp.beginPacket(Udp.remoteIP(), outPort); - msgOUT.send(Udp); // send the bytes - Udp.endPacket(); // mark the end of the OSC Packet - msgOUT.empty(); // free space occupied by message -} - -void funcSteering(OSCMessage &msg, int addrOffset ){ - - int value = msg.getFloat(0); - OSCMessage msgOUT("/Fader/Steering"); - - Serial.print("Steering = : "); - Serial.println(value); - - msgOUT.add(value); - - Udp.beginPacket(Udp.remoteIP(), outPort); - msgOUT.send(Udp); // send the bytes - Udp.endPacket(); // mark the end of the OSC Packet - msgOUT.empty(); // free space occupied by message -} - - -void funcKp(OSCMessage &msg, int addrOffset ){ - - int value = msg.getFloat(0); - OSCMessage msgOUT("/Gain/Kp"); - - Serial.print("Kp = : "); - Serial.println(value); - - msgOUT.add(value); - - Udp.beginPacket(Udp.remoteIP(), outPort); - msgOUT.send(Udp); // send the bytes - Udp.endPacket(); // mark the end of the OSC Packet - msgOUT.empty(); // free space occupied by message - - // Redo this for label - OSCMessage msgLABEL("/Gain/KpOut"); - msgLABEL.add(value); - - Udp.beginPacket(Udp.remoteIP(), outPort); - msgLABEL.send(Udp); // send the bytes - Udp.endPacket(); // mark the end of the OSC Packet - msgLABEL.empty(); // free space occupied by message -} - - -void loop() { - OSCMsgReceive(); -} - - - diff --git a/NodeMCU/SerialProtocol/SerialProtocol.ino b/NodeMCU/SerialProtocol/SerialProtocol.ino deleted file mode 100644 index 8ee5d16..0000000 --- a/NodeMCU/SerialProtocol/SerialProtocol.ino +++ /dev/null @@ -1,50 +0,0 @@ - - -unsigned int ledState = LOW; - -typedef struct Packet { - int16_t MagicWordLow; - int16_t MagicWordHigh; - - int16_t Throttle; - int16_t Steering; - - int16_t Kp; - int16_t Ki; - int16_t Kd; - - bool Enabled; -}; - -void setup() { - pinMode(LED_BUILTIN, OUTPUT); - Serial.begin(57600); - Serial.println("Starting..."); - -} - -void loop() { - // put your main code here, to run repeatedly: - delay(2000); - - ledState = !ledState; - digitalWrite(BUILTIN_LED, ledState); - - int bufferSize = 15; - uint8_t buffer[bufferSize]; - - Packet* pPacket = (Packet*)buffer; - - pPacket->MagicWordLow = 0x0DED; - pPacket->MagicWordHigh = 0x0DEC; - pPacket->Throttle = 123; - pPacket->Steering = 456; - pPacket->Kp = 10; - pPacket->Ki = 20; - pPacket->Kd = 30; - pPacket->Enabled = true; - - - Serial.write(buffer, bufferSize); - -}