diff --git a/README.md b/README.md index 64a5f86038d..f5d6eb8f37f 100644 --- a/README.md +++ b/README.md @@ -36,16 +36,16 @@ NefryBTは適宜バージョンアップをしてArduinoIDEのボードマネー ## リンク -[Facebookグループ](https://www.facebook.com/nefrystudio/) -[質問等についてはこちら](https://teratail.com/tags/Nefry) -[NefryBTドキュメント](https://dotstud.io/docs/nefrybt/) -[NefryBT説明書](https://drive.google.com/file/d/0B_mvDQF8yaQRLVprUHl4WTFLWVE/view) +- [Facebookグループ](https://www.facebook.com/nefrystudio/) +- [質問等についてはこちら](https://teratail.com/tags/Nefry) +- [NefryBTドキュメント](https://dotstud.io/docs/nefrybt/) +- [NefryBT説明書](https://drive.google.com/file/d/0B_mvDQF8yaQRLVprUHl4WTFLWVE/view) ## エラーデコーダー [EspExceptionDecoder](https://github.com/me-no-dev/EspExceptionDecoder) エラーデコーダはこちらからダウンロードできます。 -## ESP32Dev Board PINMAP +## NefryBT Board PINMAP ![Pin Functions](https://nefry.studio/img/nefrybt_pinmap.png) diff --git a/cores/esp32/nefry/Nefry.cpp b/cores/esp32/nefry/Nefry.cpp index dc4c9203041..9867d177c40 100644 --- a/cores/esp32/nefry/Nefry.cpp +++ b/cores/esp32/nefry/Nefry.cpp @@ -24,7 +24,7 @@ BootMode 1 : WriteMode切替をする */ -#define LIBVERSION ("1.0.9") +#define LIBVERSION ("1.2.0") #include "Nefry.h" Adafruit_NeoPixel _NefryLED[40]; @@ -49,16 +49,19 @@ void Nefry_lib::nefry_init() { NefryDataStore.begin(); delay(500); setLed(0x00, 0x8f, 0x00); - Serial.println(F("WiFi Startup")); - if (NefryDataStore.getModuleID().equals("")) { NefryDataStore.setModuleID(getDefaultModuleId()); } - if (readSW()) { _bootMode = 2; } - setLedBlink(0, 0xbf, 0, true, 100); - NefryWiFi.begin(); - Serial.println("WiFi connected"); - Serial.print("SSID: "); - Serial.println(WiFi.SSID()); - Serial.print("IP address: "); - Serial.println(WiFi.localIP()); + + if(Nefry.getWifiEnabled()) { + Serial.println(F("WiFi Startup")); + if (NefryDataStore.getModuleID().equals("")) { NefryDataStore.setModuleID(getDefaultModuleId()); } + if (readSW()) { _bootMode = 2; } + setLedBlink(0, 0xbf, 0, true, 100); + NefryWiFi.begin(); + Serial.println("WiFi connected"); + Serial.print("SSID: "); + Serial.println(WiFi.SSID()); + Serial.print("IP address: "); + Serial.println(WiFi.localIP()); + } setLedBlink(0, 0, 0, false, 0); delay(100); setLed(0x00, 0xcf, 0x00); @@ -76,17 +79,26 @@ void Nefry_lib::nefry_init() { Serial.println(F("\nServer started")); /* Module状況表示 */ /* IPaddress display表示 */ - printDeviceInfo(); + if(Nefry.getWifiEnabled()){ + printDeviceInfo(); + } setLed(0x00, 0xff, 0xff); - + _nefryWifiWait = 0; } void Nefry_lib::nefry_loop() { - NefryWiFi.run(); + if(Nefry.getWifiEnabled()){ + _nefryWifiWait++; + if (_nefryWifiWait > 1000) {//WiFiに接続する間隔を10秒ごとに修正 + _nefryWifiWait = 0; + NefryWiFi.run(); + } + } } void Nefry_lib::printDeviceInfo() { + if(!Nefry.getDisplayStatusEnabled()) { return; } NefryDisplay.setAutoScrollFlg(true); NefryDisplay.autoScrollFunc(getNefryDisplayInfo); } @@ -400,4 +412,31 @@ void Nefry_lib::setLedBlink(int red,int green,int blue,bool EN,int wait) { _nefryLedBlinkState[3] = EN; _nefryLedBlinkState[4] = wait; } + +// Wi-FiのON/OFF +void Nefry_lib::enableWifi() { + _wifiEnableFlg = true; +} + +void Nefry_lib::disableWifi() { + _wifiEnableFlg = false; +} + +bool Nefry_lib::getWifiEnabled() { + return _wifiEnableFlg; +} + +// ディスプレイステータスのON/OFF +void Nefry_lib::enableDisplayStatus() { + _displayStatusFlg = true; +} + +void Nefry_lib::disableDisplayStatus() { + _displayStatusFlg = false; +} + +bool Nefry_lib::getDisplayStatusEnabled() { + return _displayStatusFlg; +} + Nefry_lib Nefry; \ No newline at end of file diff --git a/cores/esp32/nefry/Nefry.h b/cores/esp32/nefry/Nefry.h index 3a91f9697d4..8b556d38c5c 100644 --- a/cores/esp32/nefry/Nefry.h +++ b/cores/esp32/nefry/Nefry.h @@ -35,8 +35,10 @@ class Nefry_lib setStoreStr(String str,const int pointer), getWriteMode(), readSW(), - getPollingSW(); - + getPollingSW(), + getWifiEnabled(), + getDisplayStatusEnabled(); + String getModuleID(), getModuleClass(), @@ -79,6 +81,12 @@ class Nefry_lib enableSW(), disableSW(), + enableWifi(), + disableWifi(), + + enableDisplayStatus(), + disableDisplayStatus(), + /* Pollingでスイッチの状態をチェック */ pollingSW(), @@ -148,12 +156,15 @@ class Nefry_lib bool _swEnableFlg = false,/* SWの有効無効化 */ _swflg = false, /* SWの状態を保持 */ - _swPushingflg = false; - + _swPushingflg = false, + _wifiEnableFlg = true,/* Wi-Fiの有効無効化 */ + _displayStatusFlg = true;/* ディスプレイの状態表示の有効無効化 */ + int _bootMode = -1, /* Boot状態を管理 -1:初期化中 0:起動中 1:通常起動 2:書き込みモード */ hextonum(char c), - _nefryState = 0; + _nefryState = 0, + _nefryWifiWait; int _nefryLedBlinkState[5]; const char * program; }; diff --git a/cores/esp32/nefry/NefryDisplay.cpp b/cores/esp32/nefry/NefryDisplay.cpp index 9c9e2d0f350..f44da0bb808 100644 --- a/cores/esp32/nefry/NefryDisplay.cpp +++ b/cores/esp32/nefry/NefryDisplay.cpp @@ -59,6 +59,12 @@ void Nefry_Display::end() { _nefrySsdDisplay.end(); } + +void Nefry_Display::setColor(OLEDDISPLAY_COLOR color) +{ + _nefrySsdDisplay.setColor(color); +} + void Nefry_Display::drawString(int16_t x, int16_t y, String text, int16_t maxLineWidth) { /* スクロール機能未実装 */ diff --git a/cores/esp32/nefry/NefryDisplay.h b/cores/esp32/nefry/NefryDisplay.h index 821744ebd62..71d86c410ee 100644 --- a/cores/esp32/nefry/NefryDisplay.h +++ b/cores/esp32/nefry/NefryDisplay.h @@ -15,6 +15,9 @@ class Nefry_Display // ディスプレイで使用しているメモリを解放する void end(); + // Sets the color of all pixel operations + void setColor(OLEDDISPLAY_COLOR color); + //指定された場所に最大幅の文字列を描画します。 //指定されたStringが指定された幅よりも広い場合 //テキストはスペースまたはダッシュで次の行に折り返されます diff --git a/cores/esp32/nefry/NefrySetting.cpp b/cores/esp32/nefry/NefrySetting.cpp new file mode 100644 index 00000000000..715a943a172 --- /dev/null +++ b/cores/esp32/nefry/NefrySetting.cpp @@ -0,0 +1,24 @@ +/** +Nefry lib + +Copyright (c) 2016 wami + +This software is released under the MIT License. +http://opensource.org/licenses/mit-license.php +*/ + +#include "NefrySetting.h" + +FUNC_POINTER fsetup=nullptr; +NefrySetting::NefrySetting(){} + +NefrySetting::NefrySetting(FUNC_POINTER _Func_setup){ + fsetup = _Func_setup; +} + +void NefrySetting::setupSetting() +{ + if (fsetup != nullptr) { + fsetup(); + } +} diff --git a/cores/esp32/nefry/NefrySetting.h b/cores/esp32/nefry/NefrySetting.h new file mode 100644 index 00000000000..eeb8bfac9b1 --- /dev/null +++ b/cores/esp32/nefry/NefrySetting.h @@ -0,0 +1,14 @@ +#ifndef NefrySetting_h +#define NefrySetting_h +#include "NefrySettingBase.h" +typedef void(*FUNC_POINTER)(void); +class NefrySetting +{ +public: + NefrySetting(); + NefrySetting(FUNC_POINTER _Func_setting); + void setupSetting(); +private: + +}; +#endif diff --git a/cores/esp32/nefry/NefrySettingBase.h b/cores/esp32/nefry/NefrySettingBase.h new file mode 100644 index 00000000000..a2e209c3556 --- /dev/null +++ b/cores/esp32/nefry/NefrySettingBase.h @@ -0,0 +1,7 @@ +#ifndef Nefry_SettingBase_h +#define Nefry_SettingBase_h +typedef void(*FUNC_POINTER)(void); //֐|C^typedef +extern FUNC_POINTER fsetup, floop; + +//extern Nefry_Write NefryWriteMode; +#endif diff --git a/cores/esp32/nefry/NefryWeb.cpp b/cores/esp32/nefry/NefryWeb.cpp index b0c0bfe9fc7..8c220fc5fbc 100644 --- a/cores/esp32/nefry/NefryWeb.cpp +++ b/cores/esp32/nefry/NefryWeb.cpp @@ -70,7 +70,7 @@ void Nefry_Web::beginWeb() { content += indexlink; content += F("

Nefry library:"); content += Nefry.getVersion(); - content += F("
Running ProgramName:"); + content += F("
Running Program Name:"); content += Nefry.getProgramName(); content += F("

"); NefryWebServer.getWebServer()->send(200, "text/html", createHtml(F("Nefry Menu"), "", content)); diff --git a/cores/esp32/nefry/NefryWiFi.cpp b/cores/esp32/nefry/NefryWiFi.cpp index dc2cf9daad0..4c90ac24f2b 100644 --- a/cores/esp32/nefry/NefryWiFi.cpp +++ b/cores/esp32/nefry/NefryWiFi.cpp @@ -21,6 +21,8 @@ void Nefry_WiFi::begin() { NefryDisplay.drawString(10, 14, "Scanning WiFi"); NefryDisplay.drawProgressBar(14, 44, 100, 14, 0); NefryDisplay.display(); + WiFi.disconnect(); + delay(2000); WiFi.persistent(false); WiFi.mode(WIFI_AP_STA); wifiMulti = WiFiMulti(); @@ -76,6 +78,8 @@ run関数で返す値 if (getWifiTimeout() == -1)return 1; if (getWifiTimeout() != 0 && getWifiTimeout() <= _WifiTimeOutCount)return 2; uint8_t wifiStatus = wifiMulti.run(Nefry.getBootMode()); + WiFi.setAutoConnect(true); + WiFi.setAutoReconnect(true); if (prevWifiStatus != wifiStatus) { prevWifiStatus = wifiStatus; if (wifiStatus == WL_CONNECTED) { @@ -105,6 +109,7 @@ run関数で返す値 break; case WL_NO_SSID_AVAIL: Serial.println(F("SSID Not Found")); + WiFi.disconnect(); return 4; break; case WL_SCAN_COMPLETED: diff --git a/cores/esp32/nefry/inc/WiFi/examples/WiFiMulti/WiFiMulti.ino b/cores/esp32/nefry/inc/WiFi/examples/WiFiMulti/WiFiMulti.ino index 2e490d065a8..269204bce87 100644 --- a/cores/esp32/nefry/inc/WiFi/examples/WiFiMulti/WiFiMulti.ino +++ b/cores/esp32/nefry/inc/WiFi/examples/WiFiMulti/WiFiMulti.ino @@ -5,6 +5,7 @@ #include #include +#include WiFiMulti wifiMulti; @@ -18,7 +19,7 @@ void setup() wifiMulti.addAP("ssid_from_AP_3", "your_password_for_AP_3"); Serial.println("Connecting Wifi..."); - if(wifiMulti.run() == WL_CONNECTED) { + if(wifiMulti.run(Nefry.getBootMode()) == WL_CONNECTED) { Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); @@ -28,8 +29,8 @@ void setup() void loop() { - if(wifiMulti.run() != WL_CONNECTED) { + if(wifiMulti.run(Nefry.getBootMode()) != WL_CONNECTED) { Serial.println("WiFi not connected!"); delay(1000); } -} \ No newline at end of file +} diff --git a/cores/esp32/nefry/inc/WiFi/src/WiFiMulti.cpp b/cores/esp32/nefry/inc/WiFi/src/WiFiMulti.cpp index 283a9c2a294..636208977cb 100644 --- a/cores/esp32/nefry/inc/WiFi/src/WiFiMulti.cpp +++ b/cores/esp32/nefry/inc/WiFi/src/WiFiMulti.cpp @@ -138,7 +138,7 @@ uint8_t WiFiMulti::run(int mode) // wait for connection or fail while(status != WL_CONNECTED && status != WL_NO_SSID_AVAIL && status != WL_CONNECT_FAILED) { - delay(70); + delay(200); status = WiFi.status(); wifiDisplayScroll++; if (wifiDisplayScroll > 50)break; diff --git a/libraries/Nefry/Nefry.h b/libraries/Nefry/Nefry.h index f3e8eb706f5..3a5db543945 100644 --- a/libraries/Nefry/Nefry.h +++ b/libraries/Nefry/Nefry.h @@ -15,7 +15,9 @@ class Nefry_lib setStoreStr(String str, const int pointer), getWriteMode(), readSW(), - getPollingSW(); + getPollingSW(), + getWifiEnabled(), + getDisplayStatusEnabled(); String getModuleID(), @@ -59,6 +61,12 @@ class Nefry_lib enableSW(), disableSW(), + enableWifi(), + disableWifi(), + + enableDisplayStatus(), + disableDisplayStatus(), + /* Pollingでスイッチの状態をチェック */ pollingSW(), @@ -126,8 +134,10 @@ class Nefry_lib bool _swEnableFlg = false,/* SWの有効無効化 */ _swflg = false, /* SWの状態を保持 */ - _swPushingflg = false; - + _swPushingflg = false, + _wifiEnableFlg = true,/* Wi-Fiの有効無効化 */ + _displayStatusFlg = true;/* ディスプレイの状態表示の有効無効化 */ + int _bootMode = -1, /* Boot状態を管理 -1:初期化中 0:起動中 1:通常起動 2:書き込みモード */ hextonum(char c), diff --git a/libraries/Nefry/examples/nefryBT-camera/nefryBT-camera.ino b/libraries/Nefry/examples/nefryBT-camera/nefryBT-camera.ino new file mode 100644 index 00000000000..277ff0c7fcb --- /dev/null +++ b/libraries/Nefry/examples/nefryBT-camera/nefryBT-camera.ino @@ -0,0 +1,225 @@ +#include +#include +HardwareSerial Serial1(1); + + +#define PIC_PKT_LEN 128 //data length of each read, dont set this too big because ram is limited +#define PIC_FMT_VGA 7 +#define PIC_FMT_CIF 5 +#define PIC_FMT_OCIF 3 +#define CAM_ADDR 0 +#define PIC_FMT PIC_FMT_VGA + +const byte cameraAddr = (CAM_ADDR << 5); // addr +unsigned long picTotalLen = 0; // picture length +unsigned long uptime; +const char* host = "192.168.0.2"; +const char* page = "/nefry/pic.php"; +const char* full = "https://api.imgur.com/3/image"; +//const char* clid = "44f1d313889227a"; + + + + +/*********************************************************************/ +void setup() { + /* + Nefry.setStoreTitle("Host", 0); + Nefry.setStoreTitle("Page", 1); + String hostS = Nefry.getStoreStr(0); + String pageS = Nefry.getStoreStr(1); + hostS.toCharArray(host, length(host)); + pageS.toCharArray(page, length(page)); + */ + Nefry.print(F("POST to ")); + Nefry.print(host); + Nefry.println(page); + + + Serial1.begin(115200, SERIAL_8N1, 19, 18); + initialize(); + preCapture(); + Nefry.enableSW(); +} +/*********************************************************************/ +void loop() { + Nefry.setLed(0, 255, 0); + if (Nefry.readSW()) { + delay(500); + Capture(); + GetData(); + } +} +/*********************************************************************/ +void clearRxBuf() { + while (Serial1.available()) { + Serial1.read(); + } +} +/*********************************************************************/ +void sendCmd(char cmd[], int cmd_len) { + for (int i = 0; i < cmd_len; i++) Serial1.print(cmd[i]); +} +/*********************************************************************/ +void initialize() { + char cmd[] = {0xaa, 0x0d | cameraAddr, 0x00, 0x00, 0x00, 0x00}; + unsigned char resp[6]; + + Nefry.print("initializing camera..."); + + Serial1.setTimeout(500); + while (true) { + sendCmd(cmd, 6); + if (Serial1.readBytes((char *)resp, 6) != 6) { + Nefry.print("."); + continue; + } + if (resp[0] == 0xaa && resp[1] == (0x0e | cameraAddr) && resp[2] == 0x0d && resp[4] == 0 && resp[5] == 0) { + if (Serial1.readBytes((char *)resp, 6) != 6) continue; + if (resp[0] == 0xaa && resp[1] == (0x0d | cameraAddr) && resp[2] == 0 && resp[3] == 0 && resp[4] == 0 && resp[5] == 0) break; + } + } + cmd[1] = 0x0e | cameraAddr; + cmd[2] = 0x0d; + sendCmd(cmd, 6); + Nefry.println("\nCamera initialization done."); +} +/*********************************************************************/ +void preCapture() { + char cmd[] = { 0xaa, 0x01 | cameraAddr, 0x00, 0x07, 0x00, PIC_FMT }; + unsigned char resp[6]; + + while (true) { + clearRxBuf(); + sendCmd(cmd, 6); + if (Serial1.readBytes((char *)resp, 6) != 6) continue; + if (resp[0] == 0xaa && resp[1] == (0x0e | cameraAddr) && resp[2] == 0x01 && resp[4] == 0 && resp[5] == 0) break; + } +} +void Capture() { + char cmd[] = { 0xaa, 0x06 | cameraAddr, 0x08, PIC_PKT_LEN & 0xff, (PIC_PKT_LEN>>8) & 0xff ,0}; + unsigned char resp[6]; + + while (true) { + clearRxBuf(); + sendCmd(cmd, 6); + if (Serial1.readBytes((char *)resp, 6) != 6) continue; + if (resp[0] == 0xaa && resp[1] == (0x0e | cameraAddr) && resp[2] == 0x06 && resp[4] == 0 && resp[5] == 0) break; + } + cmd[1] = 0x05 | cameraAddr; + cmd[2] = 0; + cmd[3] = 0; + cmd[4] = 0; + cmd[5] = 0; + while (true) { + clearRxBuf(); + sendCmd(cmd, 6); + if (Serial1.readBytes((char *)resp, 6) != 6) continue; + if (resp[0] == 0xaa && resp[1] == (0x0e | cameraAddr) && resp[2] == 0x05 && resp[4] == 0 && resp[5] == 0) break; + } + cmd[1] = 0x04 | cameraAddr; + cmd[2] = 0x1; + while (true) { + clearRxBuf(); + sendCmd(cmd, 6); + if (Serial1.readBytes((char *)resp, 6) != 6) continue; + if (resp[0] == 0xaa && resp[1] == (0x0e | cameraAddr) && resp[2] == 0x04 && resp[4] == 0 && resp[5] == 0) { + Serial1.setTimeout(1000); + if (Serial1.readBytes((char *)resp, 6) != 6) continue; + if (resp[0] == 0xaa && resp[1] == (0x0a | cameraAddr) && resp[2] == 0x01) { + picTotalLen = (resp[3]) | (resp[4] << 8) | (resp[5] << 16); + Nefry.print("picTotalLen:"); + Nefry.println(picTotalLen); + break; + } + } + } +} +/*********************************************************************/ +void GetData() { + unsigned int pktCnt = (picTotalLen) / (PIC_PKT_LEN - 6); + if ((picTotalLen % (PIC_PKT_LEN-6)) != 0) pktCnt += 1; + + char cmd[] = { 0xaa, 0x0e | cameraAddr, 0x00, 0x00, 0x00, 0x00 }; + unsigned char pkt[PIC_PKT_LEN]; + + + + +/*********************************************************************/ + + WiFiClient client; + //client.setCACert(test_root_ca); + reconnect: + Nefry.setLed(255, 0, 0); + Nefry.println("Try to connect.."); + if (!client.connect(host, 80)) { + Nefry.setLed(0, 0, 0); + client.stop(); + delay(1000); + goto reconnect; + } + // + Nefry.println("SendPict().."); + Nefry.setLed(255, 0, 0); + /* + client.print(String("GET ") + page + F(" HTTP/1.1\n") + + F("Host: ") + host + F("\n") + + F("Connection: close\n\n")); + */ + client.print(String("POST ") + page + F(" HTTP/1.1\n") + + F("Host: ") + host + F("\n") + + //F("Authorization: Client-ID ") + String(clid) + F("\n") + + F("Content-Type: image/jpeg\n") + + F("Content-Length: ") + String(picTotalLen) + F("\n") + + F("Connection: close\n\n")); + Nefry.print(F("Content-Length: ")); Nefry.println(picTotalLen); + Nefry.print(F("HTTP Sending..... ")); + + + + + + + + Serial1.setTimeout(1000); + for (unsigned int i = 0; i < pktCnt; i++) { + Nefry.print("."); + cmd[4] = i & 0xff; + cmd[5] = (i >> 8) & 0xff; + + int retry_cnt = 0; + retry: + delay(10); + clearRxBuf(); + sendCmd(cmd, 6); + uint16_t cnt = Serial1.readBytes((char *)pkt, PIC_PKT_LEN); + unsigned char sum = 0; + for (int y = 0; y < cnt - 2; y++) { + sum += pkt[y]; + } + if (sum != pkt[cnt-2]) { + if (++retry_cnt < 100) goto retry; + else break; + } + + client.write((const uint8_t *)&pkt[4], cnt-6); + client.flush(); + //if (cnt != PIC_PKT_LEN) break; + } + cmd[4] = 0xf0; + cmd[5] = 0xf0; + sendCmd(cmd, 6); + + + + delay(1000); + if (client.available()) { + String line = client.readStringUntil('\r'); + Nefry.print(F("Responce: ")); Nefry.println(line); + } + client.stop(); + Nefry.println("Picture sent."); +} + + diff --git a/libraries/Nefry/examples/nefryBT-camera/web/upload.php b/libraries/Nefry/examples/nefryBT-camera/web/upload.php new file mode 100644 index 00000000000..5a83194571e --- /dev/null +++ b/libraries/Nefry/examples/nefryBT-camera/web/upload.php @@ -0,0 +1,9 @@ +\r\n".''."
\r\n"; } +} elseif ($_SERVER["REQUEST_METHOD"] == "POST") { + $data = file_get_contents("php://input"); + $newfile = "./pic/".date("Ymd_His").".jpg"; + file_put_contents($newfile, $data); +} diff --git a/libraries/Nefry/library.properties b/libraries/Nefry/library.properties index d053dc820b0..42a7fd485c8 100644 --- a/libraries/Nefry/library.properties +++ b/libraries/Nefry/library.properties @@ -1,5 +1,5 @@ name=Nefry -version=1.0.9 +version=1.2.0 author=Nefry community maintainer= sentence=nefry. diff --git a/libraries/Nefry_Display/NefryDisplay.h b/libraries/Nefry_Display/NefryDisplay.h index c3fb14da636..6f776801d0a 100644 --- a/libraries/Nefry_Display/NefryDisplay.h +++ b/libraries/Nefry_Display/NefryDisplay.h @@ -15,6 +15,9 @@ class Nefry_Display // ディスプレイで使用しているメモリを解放する void end(); + // Sets the color of all pixel operations + void setColor(OLEDDISPLAY_COLOR color); + //指定された場所に最大幅の文字列を描画します。 //指定されたStringが指定された幅よりも広い場合 //テキストはスペースまたはダッシュで次の行に折り返されます diff --git a/libraries/Nefry_Display/examples/drawPictures/drawPictures.ino b/libraries/Nefry_Display/examples/drawPictures/drawPictures.ino new file mode 100644 index 00000000000..be4fcc26198 --- /dev/null +++ b/libraries/Nefry_Display/examples/drawPictures/drawPictures.ino @@ -0,0 +1,109 @@ +#include +#include +#include +void setting(){ + Nefry.disableDisplayStatus(); +} +NefrySetting nefrySetting(setting); + +void drawDotlogo() { + NefryDisplay.drawRect(14, 10, 32, 32); + NefryDisplay.drawRect(15, 11, 30, 30); + NefryDisplay.drawRect(34, 0, 32, 32); + NefryDisplay.drawRect(35, 1, 30, 30); + NefryDisplay.setFont(Arimo_12); + NefryDisplay.drawString(0, 48, "dotstudio, inc."); +} + +#define iotlogo_width 51 +#define iotlogo_height 64 +static char iotlogo_bits[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x07, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x0F, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x07, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x0F, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x07, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x0F, 0xF8, + 0xFF, 0xFF, 0xFF, 0x80, 0x07, 0x0F, 0xFE, 0xFF, 0xFF, 0xFF, 0x83, 0x07, + 0x0F, 0xF8, 0xFF, 0xFF, 0xFF, 0x80, 0x07, 0x0F, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x07, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x0F, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x07, 0x0F, 0xF8, 0xFF, 0xFF, 0xFF, 0x80, 0x07, 0x0F, + 0xFE, 0xFF, 0xFF, 0xFF, 0x83, 0x07, 0x0F, 0xF8, 0xFF, 0xFF, 0xFF, 0x80, + 0x07, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x0F, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x07, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x0F, 0xE0, + 0xFF, 0x01, 0x00, 0x80, 0x07, 0x0F, 0xFE, 0xFF, 0x1F, 0x00, 0x80, 0x07, + 0x0F, 0xFE, 0xFF, 0x1F, 0x00, 0x80, 0x07, 0x0F, 0xE0, 0xFF, 0x01, 0x00, + 0x80, 0x07, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x0F, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x07, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x0F, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x07, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0xFF, 0x0F, 0xE0, 0xFF, + 0xFF, 0xFF, 0x07, 0xFF, 0x0F, 0xF0, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0x0F, + 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, + 0x00, 0x0F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCE, 0x1F, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x70, 0x00, 0xFF, 0x8F, 0xF3, 0xFF, 0x00, 0x70, 0x00, 0xFF, 0x8F, 0xF3, + 0xFF, 0x00, 0x70, 0x00, 0xFF, 0x8F, 0xF3, 0xFF, 0x00, 0x70, 0x00, 0xF0, + 0x80, 0x03, 0x0F, 0x00, 0x70, 0x00, 0xF0, 0x80, 0x03, 0x0F, 0x00, 0x70, + 0x70, 0xF0, 0x80, 0x03, 0x0F, 0x00, 0x70, 0xFC, 0xF1, 0x80, 0x03, 0x0F, + 0x00, 0x70, 0xFE, 0xF3, 0x80, 0x03, 0x0F, 0x00, 0x70, 0x8E, 0xF7, 0x80, + 0x03, 0x0F, 0x00, 0x70, 0x07, 0xF7, 0x80, 0x03, 0x0F, 0x00, 0x70, 0x07, + 0xF7, 0x80, 0x03, 0x0F, 0x00, 0x70, 0x07, 0xF7, 0x80, 0x03, 0x0F, 0x00, + 0x70, 0x8E, 0xF7, 0x80, 0x03, 0x0F, 0x00, 0x70, 0xFE, 0xF3, 0x80, 0x7F, + 0x0F, 0x00, 0x70, 0xFC, 0xF1, 0x80, 0x7F, 0x0F, 0x00, 0x70, 0xF0, 0xF0, + 0x80, 0x7F, 0x0F, 0x00, +}; + +void drawIotlogo() { + NefryDisplay.drawXbm(0, 0, iotlogo_width, iotlogo_height, iotlogo_bits); +} + +void drawTextJDI() { + NefryDisplay.setFont(Arimo_12); + NefryDisplay.drawString(0, 0, "Just Do IT!"); + NefryDisplay.display(); + delay(1000); + + NefryDisplay.setFont(ArialMT_Plain_10); + NefryDisplay.drawString(0, 10, "Just Do IT!"); + NefryDisplay.display(); + delay(1000); + + NefryDisplay.setFont(ArialMT_Plain_16); + NefryDisplay.drawString(0, 20, "Just Do IT!"); + NefryDisplay.display(); + delay(1000); + + NefryDisplay.setFont(ArialMT_Plain_24); + NefryDisplay.drawString(0, 32, "Just"); + NefryDisplay.display(); + delay(800); + NefryDisplay.drawString(51, 32, "Do"); + NefryDisplay.display(); + delay(800); + NefryDisplay.drawString(88, 32, "IT!"); + NefryDisplay.display(); +} + +void setup() { +} + +void loop() { + NefryDisplay.clear(); + drawIotlogo(); + NefryDisplay.display(); + delay(10000); + + NefryDisplay.clear(); + drawDotlogo(); + NefryDisplay.display(); + delay(10000); + + NefryDisplay.clear(); + drawTextJDI(); + delay(10000); +} \ No newline at end of file diff --git a/libraries/Nefry_FireBase/examples/FireBaseSimple/FireBaseSimple.ino b/libraries/Nefry_FireBase/examples/FireBaseSimple/FireBaseSimple.ino new file mode 100644 index 00000000000..c81c1a596cb --- /dev/null +++ b/libraries/Nefry_FireBase/examples/FireBaseSimple/FireBaseSimple.ino @@ -0,0 +1,27 @@ +#include +//NefryのConsoleから0から4までの値を送信するとそれぞれの機能が動作します +NefryFireBase firebase; +void setup() { + firebase.begin("APPID.firebaseio.com");//FireBaseに接続するための設定をします。 + //firebase.begin("APPID.firebaseio.com", "AuthToken");//FireBaseに接続するための設定をします。認証情報追加 +} +int i = 0; +void loop() { + DataElement elem = DataElement(); + elem.setValue("sensor", i++); + elem.setValue("NefryTest", 500 + i++); + String s = Nefry.read(); + if (s.equals("0")) { + firebase.send("Nefry", &elem);//FireBaseに新規キーを追加し、そこにデータを追加します + } else if (s.equals("1")) { + firebase.write("Nefry", &elem);//FireBaseのデータを書き込みます + } else if (s.equals("2")) { + firebase.update("Nefry", &elem);//FireBaseのデータを更新します + } else if (s.equals("3")) { + firebase.remove("Nefry");//FireBaseのデータを削除します + //firebase.remove("Nefry/sensor");//FireBaseのデータを削除します + } else if (s.equals("4")) { + Serial.println( firebase.read("Nefry"));//FireBaseからデータを受信します + //Serial.println( firebase.read("Nefry/NefryTest"));//FireBaseからデータを受信します + } +} diff --git a/libraries/Nefry_Setting/NefrySetting.cpp b/libraries/Nefry_Setting/NefrySetting.cpp new file mode 100644 index 00000000000..715a943a172 --- /dev/null +++ b/libraries/Nefry_Setting/NefrySetting.cpp @@ -0,0 +1,24 @@ +/** +Nefry lib + +Copyright (c) 2016 wami + +This software is released under the MIT License. +http://opensource.org/licenses/mit-license.php +*/ + +#include "NefrySetting.h" + +FUNC_POINTER fsetup=nullptr; +NefrySetting::NefrySetting(){} + +NefrySetting::NefrySetting(FUNC_POINTER _Func_setup){ + fsetup = _Func_setup; +} + +void NefrySetting::setupSetting() +{ + if (fsetup != nullptr) { + fsetup(); + } +} diff --git a/libraries/Nefry_Setting/NefrySetting.h b/libraries/Nefry_Setting/NefrySetting.h new file mode 100644 index 00000000000..eeb8bfac9b1 --- /dev/null +++ b/libraries/Nefry_Setting/NefrySetting.h @@ -0,0 +1,14 @@ +#ifndef NefrySetting_h +#define NefrySetting_h +#include "NefrySettingBase.h" +typedef void(*FUNC_POINTER)(void); +class NefrySetting +{ +public: + NefrySetting(); + NefrySetting(FUNC_POINTER _Func_setting); + void setupSetting(); +private: + +}; +#endif diff --git a/libraries/Nefry_Setting/NefrySettingBase.h b/libraries/Nefry_Setting/NefrySettingBase.h new file mode 100644 index 00000000000..a2e209c3556 --- /dev/null +++ b/libraries/Nefry_Setting/NefrySettingBase.h @@ -0,0 +1,7 @@ +#ifndef Nefry_SettingBase_h +#define Nefry_SettingBase_h +typedef void(*FUNC_POINTER)(void); //֐|C^typedef +extern FUNC_POINTER fsetup, floop; + +//extern Nefry_Write NefryWriteMode; +#endif diff --git a/libraries/Nefry_Setting/examples/DisplayStatusDisable/DisplayStatusDisable.ino b/libraries/Nefry_Setting/examples/DisplayStatusDisable/DisplayStatusDisable.ino new file mode 100644 index 00000000000..91f19cc067a --- /dev/null +++ b/libraries/Nefry_Setting/examples/DisplayStatusDisable/DisplayStatusDisable.ino @@ -0,0 +1,17 @@ +#include +#include +#include +void setting(){ + Nefry.disableDisplayStatus(); +} +NefrySetting nefrySetting(setting); + +void setup() { + NefryDisplay.clear(); + NefryDisplay.display(); + // put your setup code here, to run once: +} + +void loop() { + // put your main code here, to run repeatedly: +} \ No newline at end of file diff --git a/libraries/Nefry_Setting/examples/Setting/Setting.ino b/libraries/Nefry_Setting/examples/Setting/Setting.ino new file mode 100644 index 00000000000..8dc3116f437 --- /dev/null +++ b/libraries/Nefry_Setting/examples/Setting/Setting.ino @@ -0,0 +1,18 @@ +#include +void setting(){ + Serial.begin(115200); + Serial.println(); + Serial.println("***************"); + Serial.println("TestSetting"); + Serial.println("***************"); +} +NefrySetting nefrySetting(setting); +void setup() { + // put your setup code here, to run once: + +} + +void loop() { + // put your main code here, to run repeatedly: + +} diff --git a/libraries/Nefry_Setting/examples/WiFi_Disable/WiFi_Disable.ino b/libraries/Nefry_Setting/examples/WiFi_Disable/WiFi_Disable.ino new file mode 100644 index 00000000000..9edfad7435c --- /dev/null +++ b/libraries/Nefry_Setting/examples/WiFi_Disable/WiFi_Disable.ino @@ -0,0 +1,15 @@ +#include +#include +void setting(){ + Nefry.disableWifi(); +} +NefrySetting nefrySetting(setting); + +void setup() { + // put your setup code here, to run once: +} + +void loop() { + // put your main code here, to run repeatedly: + +} \ No newline at end of file diff --git a/libraries/Nefry_Setting/examples/WiFi_Enable/WiFi_Enable.ino b/libraries/Nefry_Setting/examples/WiFi_Enable/WiFi_Enable.ino new file mode 100644 index 00000000000..39f51aabce8 --- /dev/null +++ b/libraries/Nefry_Setting/examples/WiFi_Enable/WiFi_Enable.ino @@ -0,0 +1,15 @@ +#include +#include +void setting(){ + Nefry.enableWifi(); +} +NefrySetting nefrySetting(setting); + +void setup() { + // put your setup code here, to run once: +} + +void loop() { + // put your main code here, to run repeatedly: + +} \ No newline at end of file diff --git a/libraries/Nefry_Setting/keywords.txt b/libraries/Nefry_Setting/keywords.txt new file mode 100644 index 00000000000..03467fdc329 --- /dev/null +++ b/libraries/Nefry_Setting/keywords.txt @@ -0,0 +1,15 @@ +####################################### +# Syntax Coloring Map For nefry +####################################### +# Class +####################################### + +NefrySetting KEYWORD1 +####################################### +# Methods and Functions +####################################### + +####################################### +# Constants +####################################### + diff --git a/libraries/Nefry_Setting/library.properties b/libraries/Nefry_Setting/library.properties new file mode 100644 index 00000000000..8ace5c959e5 --- /dev/null +++ b/libraries/Nefry_Setting/library.properties @@ -0,0 +1,10 @@ +name=Nefry Setting +version=1.0.0 +author=Nefry community +maintainer= +sentence=nefry. +paragraph=nefry. +category=Communication +url= +architectures=esp32 +includes=NefrySetting.h diff --git a/release note.md b/release note.md index 5a4edfccf63..cb9f812454e 100644 --- a/release note.md +++ b/release note.md @@ -1,5 +1,63 @@ # このノートはNefry(ESP32版)のリリースノートになります。 +## 1.2.0 + +1.0.9をベースに現状の1.1.4までのコードを反映しました。 +これ以降、マイナーバージョンが偶数(例:1.2.1 1.6.4 など)を安定版。奇数なら開発版としていきます。 + +## 1.1.4 + +1.1.3 のバグ修正、[70d0d46](https://github.com/Nefry-Community/arduino-esp32/commit/70d0d4648766cea047613062ed50a9ecfc9de31f)まで対応 2017/12/ + +新規機能 + +- [@bluetone](https://twitter.com/bluetoneinfo)さんからのプルリクでディスプレイ制御関数が追加されました。 +- ESP32ライブラリ[70d0d46]まで対応 + +バグ対応 + +- コンパイラ座標を修正 +- [@n0bisuke](https://twitter.com/n0bisuke)さんからのプルリクで表示バグが修正されました + +## 1.1.3 + +設定機能関数の追加、ネットワーク設定変更の対応 + +新規対応 + +- 設定機能関数の追加 +- WiFi無効化機能の追加 [@m2wasabiさん](https://github.com/m2wasabi)からのプルリクありがとうございます。 +- ESP32ライブラリ[a907113](https://github.com/Nefry-Community/arduino-esp32/commit/a907113ba2c67d2dc3785b1ef93e5ab298d82412)まで対応 2017/11/25まで対応 + +## 1.1.2 + +デバック版 + +## 1.1.1 + +###注意 +このバージョンは仮リリースとなります。 +captive portalが正常に動作しませんが、BLEを扱えることを優先します。 + +新規対応 + +- ESP32ライブラリ[081ca1c]まで対応 2017/10/30まで対応 + +バグ対応 + +- BLEライブラリの動作確認 + +## 1.1.0 + +BLEサポート、ESP32ライブラリ[0768590]10月25日まで対応 + +新規対応 + +- BLEサポート +- ESP32ライブラリ[0768590] +- EddystoneとiBeacon互換対応 +- Nefry BT r2追加 + ## 1.0.9 Nefry BT r2対応