From 11e21ba386f4c2b27143c1575e410b1cfb383eb6 Mon Sep 17 00:00:00 2001 From: Dooho Yi Date: Wed, 5 May 2021 12:22:51 +0900 Subject: [PATCH] testing --- @bell/platformio.ini | 37 ++++++++---- @bell/src/main.cpp | 123 +++++++++------------------------------- crickets/src/main.cpp | 2 +- puredata/radio_toner.pd | 98 ++++++++++++++++++++++++++------ roller/src/main.cpp | 2 +- 5 files changed, 137 insertions(+), 125 deletions(-) diff --git a/@bell/platformio.ini b/@bell/platformio.ini index 82bcb25..a2d1d62 100644 --- a/@bell/platformio.ini +++ b/@bell/platformio.ini @@ -1,30 +1,45 @@ +; < NOTE > + +; to enable verbose output add option --> +; $ platformio run --verbose + +; to make this permanent for the proj. --> +; $ platformio settings set force_verbose Yes + +; then confirm the change --> +; $ platformio settings get + + +; // pio v 4.0 'Build options' +; - build_type +; - build_flags +; - src_build_flags +; - build_unflags +; - src_filter +; - targets + + [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 + 721 ; TaskScheduler [env:nodemcuv2] platform = espressif8266 board = nodemcuv2 lib_deps = ${env.lib_deps} - ESP8266WiFi - Servo(esp8266) +upload_speed = 921600 ; 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600 -[env:huzzah] +[env:d1_mini_pro] platform = espressif8266 -board = huzzah +board = d1_mini_pro lib_deps = ${env.lib_deps} - ESP8266WiFi - Servo(esp8266) +upload_speed = 460800 ; 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600 diff --git a/@bell/src/main.cpp b/@bell/src/main.cpp index 4782024..09b123a 100644 --- a/@bell/src/main.cpp +++ b/@bell/src/main.cpp @@ -46,114 +46,47 @@ //======================= //======================== -#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_PERIOD (11111) #define LED_ONTIME (1) +#define LED_GAPTIME (222) +// +#define WIFI_CHANNEL 5 +// +// 'MONITORING_SERIAL' +// +// --> sometimes, the 'Serial' is in use (for example, 'osc' node) +// then, use 'Serial1' - D4/GPIO2/TDX1 @ nodemcu (this is TX only.) +// +// --> otherwise, MONITORING_SERIAL == Serial. +// +#if defined(SERIAL_SWAP) +#define MONITORING_SERIAL (Serial1) +#else +#define MONITORING_SERIAL (Serial) +#endif +// +//======================= //arduino #include -//i2c -#include +//post & addresses #include "../../post.h" -//painlessmesh -#include -painlessMesh mesh; +//espnow +#include +#include -//scheduler +//task +#include 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 + +#define SERVO_PIN D6 Servo myservo; // #define HITTING_ANGLE 87 #define HITTING_ANGLE 90 diff --git a/crickets/src/main.cpp b/crickets/src/main.cpp index 2c03dfc..1ec1fe7 100755 --- a/crickets/src/main.cpp +++ b/crickets/src/main.cpp @@ -21,7 +21,7 @@ //======================== // #define MY_GROUP_ID (3000) -#define MY_ID (MY_GROUP_ID + 789) +#define MY_ID (MY_GROUP_ID + 122) #define MY_SIGN ("CRICKET") // //======================== diff --git a/puredata/radio_toner.pd b/puredata/radio_toner.pd index 5700012..0a80eae 100644 --- a/puredata/radio_toner.pd +++ b/puredata/radio_toner.pd @@ -1,5 +1,5 @@ -#N canvas 437 95 568 438 12; -#N canvas 78 143 1133 383 roundly 1; +#N canvas 642 89 797 725 12; +#N canvas 200 472 1133 383 roundly 0; #X msg 364 139 \$1 5000; #X obj 364 162 unpack f f; #X obj 364 185 s X1; @@ -7,16 +7,16 @@ #X obj 54 208 r HELLO; #X obj 54 254 unpack f f f f; #X floatatom 85 283 5 0 0 0 - - -; -#X obj 107 311 hsl 1000 15 -50000 50000 0 0 empty empty empty -2 -8 -0 10 -260097 -262144 -1 0 1; -#X obj 107 331 hsl 1000 15 -50000 50000 0 0 empty empty empty -2 -8 -0 10 -13381 -262144 -1 0 1; +#X obj 107 311 hsl 1000 15 -500000 500000 0 0 empty empty empty -2 +-8 0 10 -260097 -262144 -1 0 1; +#X obj 107 331 hsl 1000 15 -500000 500000 0 0 empty empty empty -2 +-8 0 10 -13381 -262144 -1 0 1; #X obj 164 254 unpack f f f f; #X floatatom 195 283 5 0 0 0 - - -; #X floatatom 263 99 5 0 0 0 target_pos - -; -#X obj 107 31 hsl 1000 15 -50000 50000 0 0 empty empty empty -2 -8 +#X obj 107 31 hsl 1000 15 -500000 500000 0 0 empty empty empty -2 -8 0 10 -260097 -262144 -1 49950 1; -#X obj 107 51 hsl 1000 15 -50000 50000 0 0 empty empty empty -2 -8 +#X obj 107 51 hsl 1000 15 -500000 500000 0 0 empty empty empty -2 -8 0 10 -13381 -262144 -1 49950 1; #X obj 263 121 t b a; #X msg 714 139 \$1 5000; @@ -96,17 +96,81 @@ #X obj 222 204 metro 2000; #X obj 62 343 s NOTE; #X obj 222 343 s NOTE; -#X obj 222 238 riff 200 3001; #X msg 127 157 symbol riff10; #X msg 287 157 symbol riff11; #X obj 62 238 riff 170 3120; +#N canvas 0 23 450 278 (subpatch) 0; +#X array riff13 10 float 3; +#A 0 -0.380956 0.752384 0.819052 0.619048 1.00953 0.761905 0.609524 +0.657143 0.419048 0.809528; +#X coords 0 1 10 0 150 105 1 0 0; +#X restore 412 136 graph; +#X obj 412 284 tgl 20 0 empty empty empty 17 7 0 10 -262130 -1 -1 0 +1; +#X obj 536 304 tgl 20 0 empty empty empty 17 7 0 10 -257985 -1 -1 0 +1; +#X obj 412 309 metro 2000; +#X obj 412 448 s NOTE; +#X obj 412 343 riff 600 3791; +#X msg 479 255 symbol riff10; +#N canvas 0 23 450 278 (subpatch) 0; +#X array riff12 10 float 3; +#A 0 0.4 0.133332 -0.180956 0.142857 -0.257145 0.295238 0.104762 -0.161906 +-0.361908 0.466668; +#X coords 0 1 10 0 150 105 1 0 0; +#X restore 593 140 graph; +#X obj 593 288 tgl 20 0 empty empty empty 17 7 0 10 -262130 -1 -1 0 +1; +#X obj 717 308 tgl 20 0 empty empty empty 17 7 0 10 -257985 -1 -1 0 +1; +#X obj 593 313 metro 2000; +#X obj 593 452 s NOTE; +#X msg 660 259 symbol riff10; +#X msg 469 276 symbol riff13; +#X msg 650 280 symbol riff12; +#X obj 56 390 radio_bongbong; +#X obj 593 347 riff 600 4200; +#X obj 222 238 riff 200 3791; +#N canvas 0 23 450 278 (subpatch) 0; +#X array riff22 10 float 3; +#A 0 -0.161907 0.104762 -0.257147 0.304763 0.190476 -0.285718 0.390476 +-0.371432 0.323809 -0.238097; +#X coords 0 1 10 0 150 105 1 0 0; +#X restore 389 502 graph; +#X obj 389 650 tgl 20 0 empty empty empty 17 7 0 10 -262130 -1 -1 0 +1; +#X obj 513 670 tgl 20 0 empty empty empty 17 7 0 10 -257985 -1 -1 0 +1; +#X obj 389 675 metro 2000; +#X obj 389 814 s NOTE; +#X msg 456 621 symbol riff10; +#X obj 389 709 riff 600 4203; +#X msg 446 642 symbol riff22; #X connect 3 0 5 0; -#X connect 4 0 14 3; -#X connect 5 0 14 0; +#X connect 4 0 13 3; +#X connect 5 0 13 0; #X connect 6 0 8 0; -#X connect 7 0 11 3; -#X connect 8 0 11 0; -#X connect 11 0 10 0; -#X connect 12 0 14 1; -#X connect 13 0 11 1; -#X connect 14 0 9 0; +#X connect 7 0 31 3; +#X connect 8 0 31 0; +#X connect 11 0 13 1; +#X connect 12 0 31 1; +#X connect 13 0 9 0; +#X connect 15 0 17 0; +#X connect 16 0 19 3; +#X connect 17 0 19 0; +#X connect 19 0 18 0; +#X connect 20 0 19 1; +#X connect 22 0 24 0; +#X connect 23 0 30 3; +#X connect 24 0 30 0; +#X connect 26 0 30 1; +#X connect 27 0 19 1; +#X connect 28 0 30 1; +#X connect 30 0 25 0; +#X connect 31 0 10 0; +#X connect 33 0 35 0; +#X connect 34 0 38 3; +#X connect 35 0 38 0; +#X connect 37 0 38 1; +#X connect 38 0 36 0; +#X connect 39 0 38 1; diff --git a/roller/src/main.cpp b/roller/src/main.cpp index 511b638..8174dee 100644 --- a/roller/src/main.cpp +++ b/roller/src/main.cpp @@ -21,7 +21,7 @@ //======================== // #define MY_GROUP_ID (4000) -#define MY_ID (MY_GROUP_ID + 100) +#define MY_ID (MY_GROUP_ID + 200) #define MY_SIGN ("ROLLER") // //========================