From f17606eaef93e58c06d481974155a4b828890679 Mon Sep 17 00:00:00 2001 From: Dooho Yi Date: Thu, 15 Oct 2020 19:43:49 +0900 Subject: [PATCH] test --- bell/platformio.ini | 30 +++ bell/src/main.cpp | 427 ++++++++++++++++++++++++++++++++++ buoyfly/src/main.cpp | 5 +- crickets/platformio.ini | 12 + crickets/src/crickets.h | 12 +- crickets/src/main.cpp | 39 +++- gastank/src/main.cpp | 5 +- osc/src/main.cpp | 3 +- postman-monitor/src/main.cpp | 3 +- puredata/piano_access_mesh.pd | 273 ++++++++++++++-------- sampler/src/main.cpp | 16 +- src/main.cpp | 3 +- 12 files changed, 711 insertions(+), 117 deletions(-) create mode 100644 bell/platformio.ini create mode 100644 bell/src/main.cpp diff --git a/bell/platformio.ini b/bell/platformio.ini new file mode 100644 index 0000000..82bcb25 --- /dev/null +++ b/bell/platformio.ini @@ -0,0 +1,30 @@ +[platformio] +default_envs = nodemcuv2 + +[env] +framework = arduino +upload_speed = 921600 +upload_port = + /dev/ttyUSB0 + /dev/tty.SLAB_USBtoUART +lib_deps = + SPI + Wire + 64 ; ArduinoJson + 1269 ; Painless Mesh + +[env:nodemcuv2] +platform = espressif8266 +board = nodemcuv2 +lib_deps = + ${env.lib_deps} + ESP8266WiFi + Servo(esp8266) + +[env:huzzah] +platform = espressif8266 +board = huzzah +lib_deps = + ${env.lib_deps} + ESP8266WiFi + Servo(esp8266) diff --git a/bell/src/main.cpp b/bell/src/main.cpp new file mode 100644 index 0000000..dedb3eb --- /dev/null +++ b/bell/src/main.cpp @@ -0,0 +1,427 @@ +// +// wirelessly connected cloud (Wireless Mesh Networking) +// MIDI-like +// spacial +// sampler keyboard +// + +// +// Forest all/around @ MMCA, Seoul +// + +// +// 2020 10 14 +// + +//===================== +// +// 'DISABLE_AP' +// --> disabling AP is for teensy audio samplers. +// they need this to reduce noise from AP beacon signals. +// but, then they cannot build-up net. by themselves. +// we need who can do AP.. +// ==> TODO! just prepare some 'dummy' postmans around. w/ AP activated. +// +// 'DISABLE_I2C_REQ' +// --> a quirk.. due to bi-directional I2C hardship. +// ideally, we want to make this sampler node also speak. +// but, I2C doesn't work. maybe middleware bug.. we later want to change to diff. proto. +// for example, UART or so. +// ==> BEWARE! yet, still we need to take off this.. for 'osc' node. +// +// 'SET_ROOT' +// 'SET_CONTAINSROOT' +// --> for the network stability +// declare 1 root node and branches(constricted to 'contains the root') +// to improve the stability of the net +// +//==================== + +//===================== +#define SET_CONTAINSROOT +//==================== + +//======================== +#define BELL_HIT_KEY 105 +//======================= + +//======================== +#define MESH_SSID "forest-all/around" +#define MESH_PASSWORD "cc*vvvv/kkk" +#define MESH_PORT 5555 +#define MESH_CHANNEL 5 +#define LONELY_TO_DIE (1000) +//======================= + +// +// LED status indication +// phase 0 +// - LED => steady on +// - booted. and running. no connection. scanning. +// phase 1 +// - LED => slow blinking (syncronized) +// - + connected. +// +#if defined(ARDUINO_ESP8266_NODEMCU) // nodemcuv2 +#define LED_PIN 2 +#elif defined(ARDUINO_ESP8266_ESP12) // huzzah +#define LED_PIN 2 +#elif defined(ARDUINO_FEATHER_ESP32) // featheresp32 +#define LED_PIN 13 +#elif defined(ARDUINO_NodeMCU_32S) // nodemcu-32s +#define LED_PIN 2 +#endif +#define LED_PERIOD (1111) +#define LED_ONTIME (1) + +//arduino +#include + +//i2c +#include +#include "../../post.h" + +//painlessmesh +#include +painlessMesh mesh; + +//scheduler +Scheduler runner; + +//task #0 : connection indicator +bool onFlag = false; +bool isConnected = false; +//prototypes +void taskStatusBlink_steadyOn(); +void taskStatusBlink_slowblink_insync(); +void taskStatusBlink_steadyOff(); +//the task +Task statusblinks(0, 1, &taskStatusBlink_steadyOn); // at start, steady on. default == disabled. ==> setup() will enable. +// when disconnected, and trying, steadyon. +void taskStatusBlink_steadyOn() { + onFlag = true; +} +// when connected, blink per 1s. sync-ed. (== default configuration) +void taskStatusBlink_slowblink_insync() { + // toggler + onFlag = !onFlag; + // on-time + statusblinks.delay(LED_ONTIME); + // re-enable & sync. + if (statusblinks.isLastIteration()) { + statusblinks.setIterations(2); //refill iteration counts + statusblinks.enableDelayed(LED_PERIOD - (mesh.getNodeTime() % (LED_PERIOD*1000))/1000); //re-enable with sync-ed delay + } +} +// when connected, steadyoff. (== alternative configuration) +void taskStatusBlink_steadyOff() { + onFlag = false; +} + +//task #1 : happy or lonely +// --> automatic reset after some time of 'loneliness (disconnected from any node)' +void nothappyalone() { + static bool isConnected_prev = false; + static unsigned long lonely_time_start = 0; + // oh.. i m lost the signal(==connection) + if (isConnected_prev != isConnected && isConnected == false) { + lonely_time_start = millis(); + Serial.println("oh.. i m lost!"); + } + // .... how long we've been lonely? + if (isConnected == false) { + if (millis() - lonely_time_start > LONELY_TO_DIE) { + // okay. i m fed up. bye the world. + Serial.println("okay. i m fed up. bye the world."); + Serial.println(); +#if defined(ESP8266) + ESP.reset(); +#elif defined(ESP32) + ESP.restart(); + // esp32 doesn't support 'reset()' yet... + // (restart() is framework-supported, reset() is more forced hardware-reset-action) +#else +#error unknown esp. +#endif + } + } + // + isConnected_prev = isConnected; +} +// Task nothappyalone_task(1000, TASK_FOREVER, ¬happyalone, &runner, true); // by default, ENABLED. +Task nothappyalone_task(100, TASK_FOREVER, ¬happyalone); // by default, ENABLED. + +// servo +#define SERVO_PIN D6 +#include +Servo myservo; +#define HITTING_ANGLE 87 +#define RELEASE_ANGLE 60 +#define STABILIZE_ANGLE 53 + +// +extern Task hit_task; + +// +extern Task pcontrol_task; +bool pcontrol_new = false; +int pcontrol_start = 0; +int pcontrol_target = 0; +int control_count = 0; + +// +extern Task servo_release_task; + +// my tasks +// hit! +void hit() { + static int count = 0; + if (hit_task.isFirstIteration()) { + count = 0; + Serial.println("hit! start."); + } + if (count % 3 == 0) { + // + myservo.attach(SERVO_PIN); + myservo.write(RELEASE_ANGLE); + // servo_release_task.restartDelayed(200); + // + } else if (count % 3 == 1) { + // + myservo.attach(SERVO_PIN); + myservo.write(HITTING_ANGLE); + // servo_release_task.restartDelayed(200); + // + Serial.print("bell, bell, bell! : "); + Serial.print(HITTING_ANGLE); + Serial.println(" deg."); + // + } else { + // + myservo.attach(SERVO_PIN); + myservo.write(RELEASE_ANGLE); + servo_release_task.restartDelayed(200); + // + Serial.print("release to .. : "); + Serial.print(RELEASE_ANGLE); + Serial.println(" deg."); + // start stablizing.. + pcontrol_new = true; + pcontrol_start = RELEASE_ANGLE; + pcontrol_target = STABILIZE_ANGLE; + pcontrol_task.restartDelayed(80); + // + control_count = 0; + } + // + count++; +} +Task hit_task(100, 3, &hit); + +// pcontrol +void pcontrol() { + static int angle; + if (pcontrol_new == true) { + pcontrol_new = false; + angle = pcontrol_start; + } + int error = pcontrol_target - angle; + int sign = (error >= 0 ? 1 : -1); + // + Serial.print("step-by-step to.. : "); + Serial.println(sign); + // + if (error != 0) { + angle = angle + sign; // most gentle move : 1 step each time. + // + Serial.print("stablizing in action ==> next angle : "); + Serial.print(angle); + Serial.println(" deg."); + // + myservo.attach(SERVO_PIN); + myservo.write(angle); + servo_release_task.restartDelayed(50); + pcontrol_task.restartDelayed(400); + } + else { + // stand-by processes + if (control_count % 2 == 0) { + pcontrol_new = true; + pcontrol_start = STABILIZE_ANGLE; + pcontrol_target = RELEASE_ANGLE; + pcontrol_task.restartDelayed(300); + } else if (control_count % 2 == 1) { + pcontrol_new = true; + pcontrol_start = RELEASE_ANGLE; + pcontrol_target = STABILIZE_ANGLE; + pcontrol_task.restartDelayed(300); + } + // + control_count++; + } +} +Task pcontrol_task(0, TASK_ONCE, &pcontrol); // hit -> 100ms -> step back -> 50ms -> slowly move to rest pos. + +// pcontrol release +void servo_release() { + myservo.detach(); +} +Task servo_release_task(0, TASK_ONCE, &servo_release); + +// mesh callbacks +void receivedCallback(uint32_t from, String & msg) { // REQUIRED + Serial.print("got msg.: "); + Serial.println(msg); + //parse now. + + //parse letter string. + + // letter frame ( '[' + 30 bytes + ']' ) + // : [123456789012345678901234567890] + + // 'MIDI' letter frame + // : [123456789012345678901234567890] + // : [KKKVVVG.......................] + // : KKK - Key + // .substring(1, 4); + // : VVV - Velocity (volume/amp.) + // .substring(4, 7); + // : G - Gate (note on/off) + // .substring(7, 8); + + String str_key = msg.substring(1, 4); + String str_velocity = msg.substring(4, 7); + String str_gate = msg.substring(7, 8); + + int key = str_key.toInt(); + int velocity = str_velocity.toInt(); // 0 ~ 127 + int gate = str_gate.toInt(); + + //is it for me, the bell? + if (key == BELL_HIT_KEY && gate == 1) { + hit_task.restartDelayed(10); + } +} +void changedConnectionCallback() { + Serial.println(mesh.getNodeList().size()); + // check status -> modify status LED + if (mesh.getNodeList().size() > 0) { + // (still) connected. + onFlag = false; //reset flag stat. + statusblinks.set(LED_PERIOD, 2, &taskStatusBlink_slowblink_insync); + // statusblinks.set(0, 1, &taskStatusBlink_steadyOff); + statusblinks.enable(); + Serial.println("connected!"); + // + isConnected = true; + runner.addTask(nothappyalone_task); + nothappyalone_task.enable(); + } + else { + // disconnected!! + statusblinks.set(0, 1, &taskStatusBlink_steadyOn); + statusblinks.enable(); + // + isConnected = false; + } + // let I2C device know + ///// + Serial.println("hi. client, we ve got a change in the net."); +} +void newConnectionCallback(uint32_t nodeId) { + Serial.println(mesh.getNodeList().size()); + Serial.println("newConnectionCallback."); + changedConnectionCallback(); +} + +void setup() { + //led + pinMode(LED_PIN, OUTPUT); + + //mesh + WiFiMode_t node_type = WIFI_AP_STA; +#if defined(DISABLE_AP) + system_phy_set_max_tpw(0); + node_type = WIFI_STA; +#endif + // mesh.setDebugMsgTypes(ERROR | DEBUG | CONNECTION); + mesh.setDebugMsgTypes( ERROR | STARTUP ); + mesh.init(MESH_SSID, MESH_PASSWORD, &runner, MESH_PORT, node_type, MESH_CHANNEL); + + // + // void init(String ssid, String password, Scheduler *baseScheduler, uint16_t port = 5555, WiFiMode_t connectMode = WIFI_AP_STA, uint8_t channel = 1, uint8_t hidden = 0, uint8_t maxconn = MAX_CONN); + // void init(String ssid, String password, uint16_t port = 5555, WiFiMode_t connectMode = WIFI_AP_STA, uint8_t channel = 1, uint8_t hidden = 0, uint8_t maxconn = MAX_CONN); + // + +#if defined(SET_ROOT) + mesh.setRoot(true); +#endif +#if defined(SET_CONTAINSROOT) + mesh.setContainsRoot(true); +#endif + //callbacks + mesh.onReceive(&receivedCallback); + mesh.onNewConnection(&newConnectionCallback); + mesh.onChangedConnections(&changedConnectionCallback); + Serial.println(mesh.getNodeList().size()); + + //tasks + runner.addTask(statusblinks); + statusblinks.enable(); + + //serial + Serial.begin(115200); + delay(100); + Serial.println("hi, postman ready."); +#if defined(DISABLE_AP) + Serial.println("!NOTE!: we are in the WIFI_STA mode!"); +#endif + + //understanding what is 'the nodeId' ==> last 4 bytes of 'softAPmacAddress' + // uint32_t nodeId = tcp::encodeNodeId(MAC); + Serial.print("nodeId (dec) : "); + Serial.println(mesh.getNodeId(), DEC); + Serial.print("nodeId (hex) : "); + Serial.println(mesh.getNodeId(), HEX); + uint8_t MAC[] = {0, 0, 0, 0, 0, 0}; + if (WiFi.softAPmacAddress(MAC) == 0) { + Serial.println("init(): WiFi.softAPmacAddress(MAC) failed."); + } + Serial.print("MAC : "); + Serial.print(MAC[0], HEX); Serial.print(", "); + Serial.print(MAC[1], HEX); Serial.print(", "); + Serial.print(MAC[2], HEX); Serial.print(", "); + Serial.print(MAC[3], HEX); Serial.print(", "); + Serial.print(MAC[4], HEX); Serial.print(", "); + Serial.println(MAC[5], HEX); + + // for instance, + + // a huzzah board + // nodeId (dec) : 3256120530 + // nodeId (hex) : C21474D2 + // MAC : BE, DD, C2, 14, 74, D2 + + // a esp8266 board (node mcu) + // nodeId (dec) : 758581767 + // nodeId (hex) : 2D370A07 + // MAC : B6, E6, 2D, 37, A, 7 + + //i2c master + Wire.begin(); + + //tasks + runner.addTask(hit_task); + runner.addTask(pcontrol_task); + runner.addTask(servo_release_task); +} + +void loop() { + runner.execute(); + mesh.update(); +#if defined(ESP32) + digitalWrite(LED_PIN, onFlag); // value == true is ON. +#else + digitalWrite(LED_PIN, !onFlag); // value == false is ON. so onFlag == true is ON. (pull-up) +#endif +} diff --git a/buoyfly/src/main.cpp b/buoyfly/src/main.cpp index 8cc06e2..56c2c41 100644 --- a/buoyfly/src/main.cpp +++ b/buoyfly/src/main.cpp @@ -6,12 +6,11 @@ // // -// COSMO40 @ Incheon w/ Factory2 -// RTA @ Seoul w/ Post Territory Ujeongguk +// Forest all/around @ MMCA, Seoul // // -// 2019 12 15 +// 2020 10 14 // //===================== diff --git a/crickets/platformio.ini b/crickets/platformio.ini index 82bcb25..d9d93d6 100755 --- a/crickets/platformio.ini +++ b/crickets/platformio.ini @@ -28,3 +28,15 @@ lib_deps = ${env.lib_deps} ESP8266WiFi Servo(esp8266) + +[env:esp32] +build_unflags = -std=gnu++11 +build_flags = -std=gnu++14 ; AsyncTCP wants this. +platform = espressif32 +board = esp32doit-devkit-v1 +upload_speed = 921600 +; upload_port = /dev/ttyUSB0 +lib_deps = + ${env.lib_deps} + 1826@1.0.3 ; AsyncTCP + ESP32Servo diff --git a/crickets/src/crickets.h b/crickets/src/crickets.h index 85d6827..a30b014 100644 --- a/crickets/src/crickets.h +++ b/crickets/src/crickets.h @@ -1,10 +1,12 @@ //======================== -#define CRICKET_A_KEY 120 -#define CRICKET_E_KEY 121 -#define CRICKET_I_KEY 122 -#define CRICKET_O_KEY 123 +#define CRICKET_A_KEY 120 // geared (esp8266) +#define CRICKET_E_KEY 121 // geared (esp8266) +#define CRICKET_I_KEY 122 // geared (esp8266) +#define CRICKET_O_KEY 123 // geared (esp8266) // servo pin is different (D7) #define CRICKET_U_KEY 124 #define CRICKET_W_KEY 125 #define CRICKET_Y_KEY 126 -#define CRICKET_N_KEY 127 +#define CRICKET_N_KEY 127 // fishing-fly (esp32) //======================= + +#define CRICKET_KEY CRICKET_N_KEY // A-E-I-O-U-W-Y-N (up to 8 crickets) - KEY 120 ~ 127 diff --git a/crickets/src/main.cpp b/crickets/src/main.cpp index 12c303c..6430139 100755 --- a/crickets/src/main.cpp +++ b/crickets/src/main.cpp @@ -10,7 +10,7 @@ // // -// 2020 10 17 +// 2020 10 14 // //===================== @@ -43,7 +43,7 @@ //======================== #include "crickets.h" -#define CRICKET_KEY CRICKET_A_KEY // A-E-I-O-U-W-Y-N (up to 7 crickets) +#define CRICKET_KEY CRICKET_N_KEY // A-E-I-O-U-W-Y-N (up to 8 crickets) - KEY 120 ~ 127 //======================= //======================== @@ -71,6 +71,8 @@ #define LED_PIN 13 #elif defined(ARDUINO_NodeMCU_32S) // nodemcu-32s #define LED_PIN 2 +#elif defined(ARDUINO_ESP32_DEV) // esp32doit-devkit-v1 +#define LED_PIN 2 #endif #define LED_PERIOD (1111) #define LED_ONTIME (1) @@ -153,9 +155,16 @@ void nothappyalone() { Task nothappyalone_task(100, TASK_FOREVER, ¬happyalone); // by default, ENABLED. // servo -#define SERVO_PIN D6 -#include -static Servo myservo; +#if defined(ESP8266) + #define SERVO_PIN 12 //D6 + #if (CRICKET_KEY==CRICKET_O_KEY) + #undef SERVO_PIN + #define SERVO_PIN 13 //D7 + #endif + #include +#elif defined(ESP32) + #define SERVO_PIN 5 +#endif // my tasks extern Task set_speed_task; @@ -163,14 +172,22 @@ extern Task rest_task; int speed = 0; void set_speed() { int r = speed; - analogWrite(12,r); +#if defined(ESP32) + ledcWrite(0, r); +#elif defined(ESP8266) + analogWrite(SERVO_PIN, r); +#endif Serial.print("set_speed:"); Serial.println(r); } Task set_speed_task(0, TASK_ONCE, &set_speed); void rest() { - analogWrite(12,0); +#if defined(ESP32) + ledcWrite(0, 0); +#elif defined(ESP8266) + analogWrite(SERVO_PIN, 0); +#endif } Task rest_task(0, TASK_ONCE, &rest); @@ -204,6 +221,9 @@ void receivedCallback(uint32_t from, String & msg) { // REQUIRED int gate = str_gate.toInt(); speed = velocity * 4; // 0 ~ 508 +#if defined(ESP32) + speed = velocity; // 10 bit (esp8266) ==> 8 bit (esp32-ledc) +#endif //is it for me? if (key == CRICKET_KEY) { @@ -250,6 +270,11 @@ void setup() { //led pinMode(LED_PIN, OUTPUT); +#if defined(ESP32) + ledcSetup(0, 1000, 8); // 8bit + ledcAttachPin(SERVO_PIN, 0); +#endif + //mesh WiFiMode_t node_type = WIFI_AP_STA; #if defined(DISABLE_AP) diff --git a/gastank/src/main.cpp b/gastank/src/main.cpp index a2f9de6..d915a9e 100644 --- a/gastank/src/main.cpp +++ b/gastank/src/main.cpp @@ -6,12 +6,11 @@ // // -// COSMO40 @ Incheon w/ Factory2 -// RTA @ Seoul w/ Post Territory Ujeongguk +// Forest all/around @ MMCA, Seoul // // -// 2019 12 15 +// 2020 10 14 // //===================== diff --git a/osc/src/main.cpp b/osc/src/main.cpp index 7b2a4f3..83797c2 100644 --- a/osc/src/main.cpp +++ b/osc/src/main.cpp @@ -6,8 +6,7 @@ // // -// COSMO40 @ Incheon w/ Factory2 -// RTA @ Seoul w/ Post Territory Ujeongguk +// Forest all/around @ MMCA, Seoul // // diff --git a/postman-monitor/src/main.cpp b/postman-monitor/src/main.cpp index d70c3a5..30f9fd8 100644 --- a/postman-monitor/src/main.cpp +++ b/postman-monitor/src/main.cpp @@ -6,8 +6,7 @@ // // -// COSMO40 @ Incheon w/ Factory2 -// RTA @ Seoul w/ Post Territory Ujeongguk +// Forest all/around @ MMCA, Seoul // // diff --git a/puredata/piano_access_mesh.pd b/puredata/piano_access_mesh.pd index 022e958..898c165 100644 --- a/puredata/piano_access_mesh.pd +++ b/puredata/piano_access_mesh.pd @@ -66,10 +66,6 @@ #X restore 156 222 pd midi-in; #X obj 941 135 r NOTE; #X msg 1010 297 /note/onoff \$1; -#X obj 418 386 metro 1000; -#X obj 418 364 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 -1; -#X text 417 334 auto play; #X floatatom 975 272 5 0 0 0 - - -; #X obj 1090 119 loadbang; #X msg 1090 144 127; @@ -86,27 +82,6 @@ #X text 1197 197 BIG; #X text 1198 321 SMALL; #X msg 1175 146 180; -#X msg 281 388 100 100 1; -#X msg 283 443 101 100 1; -#X text 292 367 gastank; -#X text 287 418 float; -#X msg 460 314 0; -#X msg 502 336 1000; -#X obj 314 253 metro 1000; -#X obj 314 231 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 -1; -#X floatatom 393 238 5 0 0 0 - - -; -#X text 313 201 auto play; -#X msg 356 181 0; -#X msg 398 203 1000; -#X msg 314 275 101 127 1; -#X msg 418 408 100 127 1; -#X msg 497 307 500; -#X msg 533 305 2000; -#X msg 521 281 300; -#X msg 551 261 3000; -#X msg 538 52 devicename /dev/ttyACM0 \, baud 57600 \, pollintervall -1 \, verbose 1; #X obj 1107 72 s NOTE; #X msg 1107 46 68 100 1; #X obj 941 163 print NOTE; @@ -124,27 +99,159 @@ #X obj 664 163 print CTRL; #X obj 664 135 r CTRL; #X obj 664 203 r CTRL; -#X obj 418 432 s CTRL; -#X obj 314 299 s CTRL; -#N canvas 569 297 358 255 crickets 1; -#X msg 31 159 120 \$1 \$2; -#X obj 31 130 pack f f; -#X obj 76 104 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +#N canvas 423 89 853 810 crickets 1; +#X obj 89 292 pack f f; +#X obj 134 266 tgl 15 0 empty \$0-c-tgl r:0-c-tgl 17 7 0 10 -262144 +-1 -1 0 1; +#X obj 92 220 hsl 128 15 50 300 0 0 empty empty empty -2 -8 0 10 -262144 +-1 -1 0 1; +#X obj 89 353 s CTRL; +#X floatatom 99 240 5 0 0 0 - - -; +#X msg 89 321 120 \$1 \$2; +#X obj 239 292 pack f f; +#X obj 284 266 tgl 15 0 empty \$0-c-tgl r:0-c-tgl 17 7 0 10 -262144 +-1 -1 0 1; +#X obj 242 220 hsl 128 15 50 300 0 0 empty empty empty -2 -8 0 10 -262144 +-1 -1 0 1; +#X obj 239 353 s CTRL; +#X floatatom 249 240 5 0 0 0 - - -; +#X msg 239 321 121 \$1 \$2; +#X obj 371 56 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; -#X obj 34 58 hsl 128 15 50 300 0 0 empty empty empty -2 -8 0 10 -262144 --1 -1 400 1; -#X floatatom 31 27 5 0 0 0 - - -; -#X obj 31 191 s CTRL; -#X floatatom 31 78 5 0 0 0 - - -; +#X obj 371 80 t b a; +#X msg 319 67 0; +#X obj 389 292 pack f f; +#X obj 434 266 tgl 15 0 empty \$0-c-tgl r:0-c-tgl 17 7 0 10 -262144 +-1 -1 0 1; +#X obj 392 220 hsl 128 15 50 300 0 0 empty empty empty -2 -8 0 10 -262144 +-1 -1 2500 1; +#X obj 389 353 s CTRL; +#X floatatom 399 240 5 0 0 0 - - -; +#X msg 389 321 122 \$1 \$2; +#X obj 539 292 pack f f; +#X obj 584 266 tgl 15 0 empty \$0-c-tgl r:0-c-tgl 17 7 0 10 -262144 +-1 -1 0 1; +#X obj 542 220 hsl 128 15 50 300 0 0 empty empty empty -2 -8 0 10 -262144 +-1 -1 900 1; +#X obj 539 353 s CTRL; +#X floatatom 549 240 5 0 0 0 - - -; +#X msg 539 321 123 \$1 \$2; +#X obj 539 502 pack f f; +#X obj 584 476 tgl 15 0 empty \$0-c-tgl r:0-c-tgl 17 7 0 10 -262144 +-1 -1 0 1; +#X obj 542 430 hsl 128 15 0 255 0 0 empty empty empty -2 -8 0 10 -262144 +-1 -1 0 1; +#X obj 539 563 s CTRL; +#X floatatom 549 450 5 0 0 0 - - -; +#X msg 539 531 127 \$1 \$2; +#X text 605 398 fishing-fly; +#X obj 689 292 pack f f; +#X obj 734 266 tgl 15 0 empty \$0-c-tgl r:0-c-tgl 17 7 0 10 -262144 +-1 -1 0 1; +#X obj 692 220 hsl 128 15 50 300 0 0 empty empty empty -2 -8 0 10 -262144 +-1 -1 0 1; +#X obj 689 353 s CTRL; +#X floatatom 699 240 5 0 0 0 - - -; +#X msg 689 321 105 \$1 \$2; +#X obj 299 635 metro 1000; +#X obj 299 613 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X text 298 583 auto play; +#X msg 162 637 100 100 1; +#X msg 164 692 101 100 1; +#X text 173 616 gastank; +#X text 168 667 float; +#X msg 341 563 0; +#X msg 383 585 1000; +#X obj 175 492 metro 1000; +#X obj 175 470 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 +1; +#X floatatom 254 477 5 0 0 0 - - -; +#X text 174 440 auto play; +#X msg 217 420 0; +#X msg 259 442 1000; +#X msg 175 514 101 127 1; +#X msg 299 657 100 127 1; +#X msg 378 556 500; +#X msg 414 554 2000; +#X msg 402 530 300; +#X msg 432 510 3000; +#X obj 299 681 s CTRL; +#X obj 175 538 s CTRL; +#X text 150 58 cricket drummers; +#X obj 408 109 tgl 15 0 \$0-c-tgl empty s:0-c-tgl 17 7 0 10 -262144 +-1 -1 0 1; +#X floatatom 539 189 5 0 0 0 r:0-c-sld #0-c-sld -; +#X floatatom 389 189 5 0 0 0 r:0-c-sld #0-c-sld -; +#X floatatom 239 189 5 0 0 0 r:0-c-sld #0-c-sld -; +#X floatatom 89 189 5 0 0 0 r:0-c-sld #0-c-sld -; +#X floatatom 689 189 5 0 0 0 r:0-c-sld #0-c-sld -; +#X floatatom 371 109 5 0 0 0 s:0-c-sld - #0-c-sld; +#X floatatom 539 399 5 0 0 0 r:0-c-sld #0-c-sld -; #X connect 0 0 5 0; -#X connect 1 0 0 0; -#X connect 2 0 1 1; -#X connect 3 0 1 0; -#X connect 3 0 6 0; -#X connect 4 0 3 0; +#X connect 1 0 0 1; +#X connect 2 0 0 0; +#X connect 2 0 4 0; +#X connect 5 0 3 0; +#X connect 6 0 11 0; +#X connect 7 0 6 1; +#X connect 8 0 6 0; +#X connect 8 0 10 0; +#X connect 11 0 9 0; +#X connect 12 0 13 0; +#X connect 13 0 70 0; +#X connect 13 1 64 0; +#X connect 14 0 12 0; +#X connect 15 0 20 0; +#X connect 16 0 15 1; +#X connect 17 0 15 0; +#X connect 17 0 19 0; +#X connect 20 0 18 0; +#X connect 21 0 26 0; +#X connect 22 0 21 1; +#X connect 23 0 21 0; +#X connect 23 0 25 0; +#X connect 26 0 24 0; +#X connect 27 0 32 0; +#X connect 28 0 27 1; +#X connect 29 0 27 0; +#X connect 29 0 31 0; +#X connect 32 0 30 0; +#X connect 34 0 39 0; +#X connect 35 0 34 1; +#X connect 36 0 34 0; +#X connect 36 0 38 0; +#X connect 39 0 37 0; +#X connect 40 0 56 0; +#X connect 41 0 40 0; +#X connect 43 0 61 0; +#X connect 44 0 61 0; +#X connect 47 0 40 0; +#X connect 48 0 40 1; +#X connect 49 0 55 0; +#X connect 50 0 49 0; +#X connect 51 0 49 1; +#X connect 53 0 49 0; +#X connect 54 0 49 1; +#X connect 55 0 62 0; +#X connect 56 0 61 0; +#X connect 57 0 40 1; +#X connect 58 0 40 1; +#X connect 59 0 40 1; +#X connect 60 0 40 1; +#X connect 65 0 23 0; +#X connect 66 0 17 0; +#X connect 67 0 8 0; +#X connect 68 0 2 0; +#X connect 69 0 36 0; +#X connect 71 0 29 0; #X restore 651 467 pd crickets ctrl; #X obj 382 106 print OSC; #X obj 698 295 int; +#X msg 538 52 devicename /dev/portD \, baud 57600 \, pollintervall +1 \, verbose 1; +#X obj 1167 72 s NOTE; +#X msg 1167 46 62 100 1; #X connect 0 0 3 0; #X connect 2 0 7 1; #X connect 3 0 12 0; @@ -172,59 +279,43 @@ #X connect 27 1 32 0; #X connect 28 0 29 0; #X connect 29 0 27 0; -#X connect 29 1 46 0; +#X connect 29 1 43 0; #X connect 29 2 23 0; #X connect 31 0 33 0; #X connect 32 0 33 0; #X connect 34 0 25 0; -#X connect 34 0 96 0; +#X connect 34 0 72 0; #X connect 36 0 35 0; -#X connect 37 0 78 0; +#X connect 37 0 56 0; #X connect 38 0 33 0; -#X connect 39 0 70 0; -#X connect 40 0 39 0; -#X connect 42 0 31 0; -#X connect 43 0 44 0; -#X connect 44 0 42 0; -#X connect 46 0 42 0; -#X connect 47 0 42 0; -#X connect 48 0 42 0; -#X connect 49 0 42 0; -#X connect 50 0 42 0; -#X connect 51 0 42 0; -#X connect 52 0 42 0; -#X connect 53 0 42 0; -#X connect 56 0 42 0; -#X connect 57 0 93 0; -#X connect 58 0 93 0; -#X connect 61 0 39 0; -#X connect 62 0 39 1; -#X connect 63 0 69 0; -#X connect 64 0 63 0; -#X connect 65 0 63 1; -#X connect 67 0 63 0; -#X connect 68 0 63 1; -#X connect 69 0 94 0; -#X connect 70 0 93 0; -#X connect 71 0 39 1; -#X connect 72 0 39 1; -#X connect 73 0 39 1; -#X connect 74 0 39 1; -#X connect 75 0 14 1; -#X connect 77 0 76 0; -#X connect 79 0 88 0; -#X connect 79 1 80 0; -#X connect 80 0 87 0; -#X connect 81 0 87 0; -#X connect 82 0 81 0; -#X connect 82 1 86 0; -#X connect 83 0 82 0; -#X connect 83 1 89 0; -#X connect 83 2 79 0; -#X connect 85 0 87 0; -#X connect 86 0 87 0; -#X connect 88 0 87 0; -#X connect 89 0 97 0; -#X connect 91 0 90 0; -#X connect 92 0 83 0; -#X connect 97 0 85 0; +#X connect 39 0 31 0; +#X connect 40 0 41 0; +#X connect 41 0 39 0; +#X connect 43 0 39 0; +#X connect 44 0 39 0; +#X connect 45 0 39 0; +#X connect 46 0 39 0; +#X connect 47 0 39 0; +#X connect 48 0 39 0; +#X connect 49 0 39 0; +#X connect 50 0 39 0; +#X connect 53 0 39 0; +#X connect 55 0 54 0; +#X connect 57 0 66 0; +#X connect 57 1 58 0; +#X connect 58 0 65 0; +#X connect 59 0 65 0; +#X connect 60 0 59 0; +#X connect 60 1 64 0; +#X connect 61 0 60 0; +#X connect 61 1 67 0; +#X connect 61 2 57 0; +#X connect 63 0 65 0; +#X connect 64 0 65 0; +#X connect 66 0 65 0; +#X connect 67 0 73 0; +#X connect 69 0 68 0; +#X connect 70 0 61 0; +#X connect 73 0 63 0; +#X connect 74 0 14 1; +#X connect 76 0 75 0; diff --git a/sampler/src/main.cpp b/sampler/src/main.cpp index 7f0dc1a..8114991 100644 --- a/sampler/src/main.cpp +++ b/sampler/src/main.cpp @@ -6,8 +6,7 @@ // // -// COSMO40 @ Incheon w/ Factory2 -// RTA @ Seoul w/ Post Territory Ujeongguk +// Forest all/around @ MMCA, Seoul // // @@ -16,6 +15,11 @@ // (part-3) teensy35 : 'client:sampler' (mesh post --> play sounds) // +//======================== +//optionally pin3 will go HIGH/LOW in sync w/ sound PLAY/STOP +#define MOTOR_PIN 3 +//======================= + //HACK: let auto-poweroff speakers stay turned ON! - (creative muvo mini) #define IDLE_FREQ 22000 #define IDLE_AMP 0 // --> creative muvo 2 doesn't need this. they just stay on! @@ -81,6 +85,8 @@ void sample_player_start() // if (playSdWav1.isPlaying() == false) { playSdWav1.play(filename); // } + //fan action + digitalWrite(MOTOR_PIN, HIGH); //mark the indicator : HIGH: ON digitalWrite(13, HIGH); //to wait a bit for updating isPlaying() @@ -108,6 +114,8 @@ void sample_player_stop() { //stop the player. if (playSdWav1.isPlaying() == true) { playSdWav1.stop(); + //fan stop + digitalWrite(MOTOR_PIN, LOW); } } void sample_player_check() { @@ -230,6 +238,10 @@ void setup() { // while (!Serial) {} // --> use this.. to capture start-up messages, properly. very handy. + //motor + pinMode(MOTOR_PIN, OUTPUT); + digitalWrite(MOTOR_PIN, LOW); + //i2c Wire.begin(I2C_ADDR); Wire.onReceive(receiveEvent); diff --git a/src/main.cpp b/src/main.cpp index 9ca9b69..22a15d6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,8 +6,7 @@ // // -// COSMO40 @ Incheon w/ Factory2 -// RTA @ Seoul w/ Post Territory Ujeongguk +// Forest all/around @ MMCA, Seoul // //