diff --git a/faa_yellow/faa_yellow.ino b/faa_yellow/faa_yellow.ino index 0980a8e..bcb69ce 100644 --- a/faa_yellow/faa_yellow.ino +++ b/faa_yellow/faa_yellow.ino @@ -15,19 +15,23 @@ // taskscheduler 기반으로 cnmat/osc/udp 로 esp8266에서 led를 on/off 하는 sub장치를 만드는데.. taskscheduler는 우선 필요없지만.. .. ? 그렇네.. + wifimanager를 넣어주고.. arduinoota도 기본으로 넣어주고.. taskscheduler는.. 그러니까... 모터 움직임 패턴을 읽어서.. 그대로 모터를 한번 돌려주는 걸로하고... 읽는 시간 rate 일정한 값 + 패턴 값 저장하는 어레이 2개.. 모터 2개 드라이브. roller2.. // // 1 taskschduler + array + roller2 기반.. reset되면 몇 초 후에.. 패턴 1을 재생하도록. -> DONE -// 2 여기에 osc_udp 추가해서.. 외부에서, 패턴을 실행시킬 수 있도록. (pd로 osc로 전송) -// 3 pd에서 패턴값과.. 기본 파라미터를 조정하는 메세지 주기.. (+ 패턴값 체크하는 기능도 있으면 좋음...) +// 2 여기에 osc_udp 추가해서.. 외부에서, 패턴을 실행시킬 수 있도록. (pd로 osc로 전송) -> DONE +// 3 여기에 wifimanager를 더해서.. 외부에서, 와이파이 설정도 하고, 상태 업데이트 할 수 있도록. (근데 이걸 위해서, 특수한 버튼 눌러야 한다면 flash버튼을 이용해 보던가.) +// 4 이 모듈이 접속할 웹 공간 준비. 도메인 + 서비스. 그곳에 world energy 패치 준비.. (pd 여도 좋음.) - 아니면, 웹페이지여도 좋음. / 여기서 WE가 취합되고, 평균되고, 발표됨. 각 모듈은 이 값을 읽어감. (여기까지가 기존의 셋업 -> 인터넷으로 옮겨간 상태임.) // // -- 우선은 여기까지 하면, 갈수 있을지도 -- // -// 4 여기에 wifimanager를 더해서.. 외부에서, 와이파이 설정도 하고, 상태 업데이트 할 수 있도록. (근데 이걸 위해서, 특수한 버튼 눌러야 한다면 flash버튼을 이용해 보던가.) -// 5 이 모듈이 접속할 웹 공간 준비. 도메인 + 서비스. 그곳에 world energy 패치 준비.. (pd 여도 좋음.) - 아니면, 웹페이지여도 좋음. / 여기서 WE가 취합되고, 평균되고, 발표됨. 각 모듈은 이 값을 읽어감. (여기까지가 기존의 셋업 -> 인터넷으로 옮겨간 상태임.) +// 5 pd에서 패턴값과.. 기본 파라미터를 조정하는 메세지 주기.. (+ 패턴값 체크하는 기능도 있으면 좋음...) // // ** IDENTITY ** #define MY_SPECIES ("YELLOW") #define MY_NAME ("YELOWEE {a.k.a. yellow1}") +// ** WIFI ** +char ssid[] = "TEEPOT"; +char pass[] = "3333388888"; + //arduino #include @@ -40,15 +44,10 @@ // WiFiUDP Udp; // -const IPAddress outIp(192,168,88,100); -const unsigned int outPort = 9999; -const unsigned int localPort = 8888; +const IPAddress outIp(192,168,199,179); // server ip +const unsigned int outPort = 9999; // server port +const unsigned int localPort = 8888; // my port opened (<== expecting connection) OSCErrorCode error; -//// -unsigned int ledState = LOW; -//// -char ssid[] = "nosignal 2G"; -char pass[] = "1111100000"; //task #include @@ -275,63 +274,37 @@ Task conductor_lonely_task(1000, TASK_FOREVER, &conductor_lonely, &runner, false // Task blink_task(0, TASK_FOREVER, &blink, &runner, true); // -> ENABLED, at start-up. //task #1 : osc processing -// void route_note(OSCMessage& msg, int offset) { -// //swap_println("got route_note!"); -// // (1) --> /onoff -// if (msg.fullMatch("/onoff", offset)) { -// // -// note.clear(); -// // -// note.onoff = msg.getFloat(0); -// // if (note.onoff != 0) note.onoff = 1; -// } -// // (2) --> /velocity -// if (msg.fullMatch("/velocity", offset)) { -// note.velocity = msg.getFloat(0); -// } -// // (3) --> /pitch -// if (msg.fullMatch("/pitch", offset)) { -// note.pitch = msg.getFloat(0); -// } -// // (4) --> /id -// if (msg.fullMatch("/id", offset)) { -// note.id = msg.getInt(0); -// } -// // (5) --> /x -// if (msg.fullMatch("/x", offset)) { -// note.x1 = msg.getFloat(0); -// note.x2 = msg.getFloat(1); -// note.x3 = msg.getFloat(2); -// note.x4 = msg.getFloat(3); -// note.ps = msg.getFloat(4); -// } -// } -// extern Task osc_task; -// void osc() -// { -// //osc -// OSCBundle bundleIN; -// int size; -// if (SLIPSerial.available()) { -// while(!SLIPSerial.endofPacket()) { -// if( (size = SLIPSerial.available()) > 0) { -// while(size--) { -// bundleIN.fill(SLIPSerial.read()); -// } -// } -// } -// if(!bundleIN.hasError()) { -// // on '/note' -// bundleIN.route("/note", route_note); -// #if defined(ESP32) -// static int a = 0; -// screen_text = String(a) + " => \n" + String(bundleIN.timetag.seconds-2208988800UL) + "\n" + String(bundleIN.timetag.fractionofseconds); -// a++; -// #endif -// } -// } -// } -// Task osc_task(0, TASK_FOREVER, &osc, &runner, true); // -> ENABLED, at start-up. +void route_note(OSCMessage& msg, int offset) { + if (msg.fullMatch("/word", offset)) { + wordA = msg.getFloat(0); + wordB = msg.getFloat(0); + riff_A_start_task.restartDelayed(100); + riff_B_start_task.restartDelayed(100); + // + Serial.print("OSC: /word : "); + Serial.print(wordA); + Serial.print(", "); + Serial.println(wordB); + } +} +extern Task osc_task; +void osc() +{ + //osc + OSCMessage msg; + int size = Udp.parsePacket(); + if (size > 0) { + while (size--) { + msg.fill(Udp.read()); + } + if(!msg.hasError()) { + // on '/yellow' + msg.route("/yellow", route_note); + Serial.println("OSC: /yellow"); + } + } +} +Task osc_task(0, TASK_FOREVER, &osc, &runner, true); // -> ENABLED, at start-up. // void setup() { @@ -361,6 +334,21 @@ void setup() { // WiFiMode_t node_type = WIFI_STA; // WiFi.mode(node_type); + // test wifi udp + 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: "); + Serial.println(Udp.localPort()); + // Serial.println("-"); Serial.println("\".-.-.-. :)\""); @@ -378,7 +366,7 @@ void setup() { // wordB = 0; // riff_B_start_task.restartDelayed(1000); // - conductor_lonely_task.restartDelayed(5000); + // conductor_lonely_task.restartDelayed(5000); // // for (int idx = 0; idx < yellowA.size(); idx++) Serial.println(yellowA[idx].size()); // for (int idx = 0; idx < yellowB.size(); idx++) Serial.println(yellowB[idx].size());