..
This commit is contained in:
parent
a30e1312c6
commit
02e3872303
1 changed files with 112 additions and 54 deletions
|
|
@ -12,11 +12,76 @@
|
|||
//
|
||||
// NOTES
|
||||
//
|
||||
// taskscheduler 기반으로 cnmat/osc/udp 로 esp8266에서 led를 on/off 하는 sub장치를 만드는데.. taskscheduler는 우선 필요없지만.. .. ? 그렇네.. + wifimanager를 넣어주고.. arduinoota도 기본으로 넣어주고.. taskscheduler는.. 그러니까... 모터 움직임 패턴을 읽어서.. 그대로 모터를 한번 돌려주는 걸로하고... 읽는 시간 rate 일정한 값 + 패턴 값 저장하는 어레이 2개.. 모터 2개 드라이브. roller2..
|
||||
//
|
||||
|
||||
// taskscheduler 기반으로 cnmat/osc/udp로 esp8266에서 led를 on/off 하는 sub 장치를 만드는데..
|
||||
// taskscheduler 우선 필요없지만.. ? 그렇네.. + wifi manager를 넣어주고..
|
||||
// arduino-ota도 기본으로 넣어주고..
|
||||
// taskscheduler는.. 그러니까... 모터 움직임 패턴을 읽어서.. 그대로 모터를 한번 돌려주는 걸로하고...
|
||||
// 읽는 시간 rate 일정한 값 + 패턴 값 저장하는 어레이 2개.. 모터 2개 드라이브. roller2..
|
||||
|
||||
// 1 taskschduler + array + roller2 기반.. reset되면 몇 초 후에.. 패턴 1을 재생하도록. -> DONE
|
||||
// 2 여기에 osc_udp 추가해서.. 외부에서, 패턴을 실행시킬 수 있도록. (pd로 osc로 전송) -> DONE
|
||||
// 3 여기에 wifimanager를 더해서.. 외부에서, 와이파이 설정도 하고, 상태 업데이트 할 수 있도록. (근데 이걸 위해서, 특수한 버튼 눌러야 한다면 flash버튼을 이용해 보던가.)
|
||||
|
||||
// 3 여기에 wifimanager를 더해서.. 외부에서, 와이파이 설정을 할 수 있게 한다.
|
||||
// ==> 이것 자체는 어렵지 않아. 지금도 되고.
|
||||
// ==> 패턴을 보낼 수 있으면 좋겠는데..
|
||||
// 1) 라이브로 패턴을 보낸다. 이 패턴은 바로 어레이(벡터)에 담고, 즉시 q를 갈 수 있게 준비가 된다.
|
||||
// 2) 라이브로 패턴 번호를 고른다. 이때, 1에서 보낸 패턴이.. 저장이 안되어있다면.. 그것은 날아간다? 아니면?
|
||||
|
||||
// 1과2가 공존하는 시스템..?
|
||||
|
||||
// 그럼 이렇게 해보지.. 우선 라이브로 보내는 패턴은 언제나 (-1)번에 저장됨.
|
||||
// 나중에 저장을 한다는 것은 이 (-1)의 패턴을 0,1,2,3... 중에 하나를 골라서 저장한다는 의미임.
|
||||
// 혹은 저장 전에 -1을 플레이 시키면 우선 들어보는 것도 물론 가능함.
|
||||
// 도중에 다른 번호를 불러서 들어본다고 -1의 패턴정보가 날아가는 것도 아님.
|
||||
// 그리고, 마찬가지로... 어떤 패턴을 피디의 어레이로 가져오는 것도 필요. reload. 이때도 번호를 주면서 reload 함.
|
||||
// 그리고 수정하고, 다시 저장 가능..
|
||||
|
||||
// 이렇게 생각해보면, 우선은.. 파라미터가 array 보다는 dictionary에 더 적합하게 아닌가 하는 생각도 들게 됨.
|
||||
// key, value 구조.
|
||||
// 그렇게 생각이 되면, 이걸 저장하는 구조도 일종의 json 등을 데이터 오브젝트, 딕셔너리를 바로 저장하는 방식이 아닐까 생각하게 되고,
|
||||
// 그러면 자연스럽게 json이 떠오름!
|
||||
// 마지막은.. 이 json을 어떻게 저장하거나 업데이트할것인가 하는것인데...
|
||||
// 그럼 개별 패턴을 개별 '파일'로 저장할 수 있을것인가? ... 그러는 편이 편리할까. 아니면..? ...
|
||||
|
||||
// 만약 이런 구조가 된다면, 사실상 -1을 라이브 셋이라고 했던 부분은 더이상 '특수상황'이 아니라
|
||||
// 그냥 general 한 모든 허용된 상황중에서 한가지 특수한 값을 지정해서 사용하고 있는 것에 지나지 않게 되어 바람직하다는 느낌이다.
|
||||
|
||||
// 그럼, 여기서 이슈는
|
||||
|
||||
// 1 osc로 어레이 패턴을 보내고 받고 reload revise... 통신하는 법.
|
||||
// 2 이것을 저장하고 다시 불러오는 구조
|
||||
|
||||
// 우선은 ArduinoJson을 활용하면 1과 2에 상당한 문제들이 해결이 되는데. 2를 저장할때 littlefs를 쓸지, spiffs를 쓸지는 선택의 몫이다.
|
||||
|
||||
// -------- //
|
||||
|
||||
// (a quick save example)
|
||||
|
||||
// #include <LittleFS.h>
|
||||
// #include <ArduinoJson.h>
|
||||
//
|
||||
// void saveConfig() {
|
||||
// // 1. Create a JSON document
|
||||
// JsonDocument doc;
|
||||
// doc["ssid"] = "MyWiFi";
|
||||
// doc["password"] = "12345678";
|
||||
//
|
||||
// // 2. Open file for writing
|
||||
// File configFile = LittleFS.open("/config.json", "w");
|
||||
// if (!configFile) {
|
||||
// Serial.println("Failed to open config file for writing");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // 3. Serialize JSON to file
|
||||
// serializeJson(doc, configFile);
|
||||
// configFile.close();
|
||||
// }
|
||||
|
||||
//
|
||||
|
||||
// ... 도 하고, 상태 업데이트 할 수 있도록. (근데 이걸 위해서, 특수한 버튼 눌러야 한다면 flash버튼을 이용해 볼 수도 있겠다. pin0)
|
||||
// 4 이 모듈이 접속할 웹 공간 준비. 도메인 + 서비스. 그곳에 world energy 패치 준비.. (pd 여도 좋음.) - 아니면, 웹페이지여도 좋음. / 여기서 WE가 취합되고, 평균되고, 발표됨. 각 모듈은 이 값을 읽어감. (여기까지가 기존의 셋업 -> 인터넷으로 옮겨간 상태임.)
|
||||
//
|
||||
// -- 우선은 여기까지 하면, 갈수 있을지도 --
|
||||
|
|
@ -28,13 +93,12 @@
|
|||
#define MY_SPECIES ("YELLOW")
|
||||
#define MY_NAME ("YELOWEE {a.k.a. yellow1}")
|
||||
|
||||
// ** WIFI **
|
||||
char ssid[] = "TEEPOT";
|
||||
char pass[] = "3333388888";
|
||||
|
||||
//arduino
|
||||
#include <Arduino.h>
|
||||
|
||||
//wifi manager
|
||||
#include <WiFiManager.h>
|
||||
|
||||
//osc over UDP
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiUdp.h>
|
||||
|
|
@ -208,37 +272,37 @@ void riff_B_start() {
|
|||
Task riff_B_start_task(0, TASK_ONCE, &riff_B_start, &runner, false);
|
||||
//*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
|
||||
//*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
// conductor for today (temporary conductor until wifi enabled.)
|
||||
//
|
||||
extern Task conductor_lonely_task;
|
||||
float lonelytime = 5000; //ms
|
||||
void conductor_lonely() {
|
||||
//
|
||||
static int count = 0;
|
||||
if (count == yellowA.size()) count = 0;
|
||||
//
|
||||
if (isactive == false) { // if no more movement, then start another lonely song.
|
||||
//
|
||||
isactive = true;
|
||||
//
|
||||
lonelytime = random(3, 10) * 10000.0; //ms
|
||||
//
|
||||
wordA = count;
|
||||
riff_A_start_task.restartDelayed(lonelytime);
|
||||
wordB = count;
|
||||
riff_B_start_task.restartDelayed(lonelytime);
|
||||
//
|
||||
Serial.print("conductor_lonely with lonelytime => ");
|
||||
Serial.println(lonelytime);
|
||||
Serial.print("conductor_lonely with count #");
|
||||
Serial.println(count);
|
||||
//
|
||||
count++;
|
||||
}
|
||||
}
|
||||
Task conductor_lonely_task(1000, TASK_FOREVER, &conductor_lonely, &runner, false); //check every 10 sec.
|
||||
//*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
// //*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
// // conductor for today (temporary conductor until wifi enabled.)
|
||||
// //
|
||||
// extern Task conductor_lonely_task;
|
||||
// float lonelytime = 5000; //ms
|
||||
// void conductor_lonely() {
|
||||
// //
|
||||
// static int count = 0;
|
||||
// if (count == yellowA.size()) count = 0;
|
||||
// //
|
||||
// if (isactive == false) { // if no more movement, then start another lonely song.
|
||||
// //
|
||||
// isactive = true;
|
||||
// //
|
||||
// lonelytime = random(3, 10) * 10000.0; //ms
|
||||
// //
|
||||
// wordA = count;
|
||||
// riff_A_start_task.restartDelayed(lonelytime);
|
||||
// wordB = count;
|
||||
// riff_B_start_task.restartDelayed(lonelytime);
|
||||
// //
|
||||
// Serial.print("conductor_lonely with lonelytime => ");
|
||||
// Serial.println(lonelytime);
|
||||
// Serial.print("conductor_lonely with count #");
|
||||
// Serial.println(count);
|
||||
// //
|
||||
// count++;
|
||||
// }
|
||||
// }
|
||||
// Task conductor_lonely_task(1000, TASK_FOREVER, &conductor_lonely, &runner, false); //check every 10 sec.
|
||||
// //*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
|
||||
// ==[DISABLE]==
|
||||
// //task #0 : blink led
|
||||
|
|
@ -329,27 +393,21 @@ void setup() {
|
|||
Serial.println("- mac address: " + WiFi.macAddress());
|
||||
Serial.println("-");
|
||||
|
||||
// //wifi-manager
|
||||
// system_phy_set_max_tpw(0);
|
||||
// WiFiMode_t node_type = WIFI_STA;
|
||||
// WiFi.mode(node_type);
|
||||
//wifi-manager
|
||||
Serial.println("- calling.. wifimanager");
|
||||
WiFiManager wm;
|
||||
if (!wm.autoConnect()) ESP.restart();
|
||||
Serial.println("- i m connected!");
|
||||
|
||||
// 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: ");
|
||||
//open up udp connection
|
||||
Serial.println("- IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
Serial.println("Starting UDP");
|
||||
Serial.println("- Starting UDP");
|
||||
Udp.begin(localPort);
|
||||
Serial.print("Local port: ");
|
||||
Serial.print("- Local port: ");
|
||||
Serial.println(Udp.localPort());
|
||||
|
||||
//
|
||||
//all done.
|
||||
Serial.println("-");
|
||||
Serial.println("\".-.-.-. :)\"");
|
||||
Serial.println();
|
||||
|
|
|
|||
Loading…
Reference in a new issue