Skip to content

Commit 417ecbb

Browse files
authored
Merge pull request #88 from Nefry-Community/1.2Develop
1.2 develop
2 parents 50cfe0f + e12af4d commit 417ecbb

File tree

29 files changed

+719
-33
lines changed

29 files changed

+719
-33
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ NefryBTは適宜バージョンアップをしてArduinoIDEのボードマネー
3636

3737
## リンク
3838

39-
[Facebookグループ](https://www.facebook.com/nefrystudio/)
40-
[質問等についてはこちら](https://teratail.com/tags/Nefry)
41-
[NefryBTドキュメント](https://dotstud.io/docs/nefrybt/)
42-
[NefryBT説明書](https://drive.google.com/file/d/0B_mvDQF8yaQRLVprUHl4WTFLWVE/view)
39+
- [Facebookグループ](https://www.facebook.com/nefrystudio/)
40+
- [質問等についてはこちら](https://teratail.com/tags/Nefry)
41+
- [NefryBTドキュメント](https://dotstud.io/docs/nefrybt/)
42+
- [NefryBT説明書](https://drive.google.com/file/d/0B_mvDQF8yaQRLVprUHl4WTFLWVE/view)
4343

4444
## エラーデコーダー
4545

4646
[EspExceptionDecoder](https://github.com/me-no-dev/EspExceptionDecoder) エラーデコーダはこちらからダウンロードできます。
4747

48-
## ESP32Dev Board PINMAP
48+
## NefryBT Board PINMAP
4949

5050
![Pin Functions](https://nefry.studio/img/nefrybt_pinmap.png)
5151

cores/esp32/nefry/Nefry.cpp

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ BootMode
2424
1 : WriteMode切替をする
2525
*/
2626

27-
#define LIBVERSION ("1.0.9")
27+
#define LIBVERSION ("1.2.0")
2828
#include "Nefry.h"
2929

3030
Adafruit_NeoPixel _NefryLED[40];
@@ -49,16 +49,19 @@ void Nefry_lib::nefry_init() {
4949
NefryDataStore.begin();
5050
delay(500);
5151
setLed(0x00, 0x8f, 0x00);
52-
Serial.println(F("WiFi Startup"));
53-
if (NefryDataStore.getModuleID().equals("")) { NefryDataStore.setModuleID(getDefaultModuleId()); }
54-
if (readSW()) { _bootMode = 2; }
55-
setLedBlink(0, 0xbf, 0, true, 100);
56-
NefryWiFi.begin();
57-
Serial.println("WiFi connected");
58-
Serial.print("SSID: ");
59-
Serial.println(WiFi.SSID());
60-
Serial.print("IP address: ");
61-
Serial.println(WiFi.localIP());
52+
53+
if(Nefry.getWifiEnabled()) {
54+
Serial.println(F("WiFi Startup"));
55+
if (NefryDataStore.getModuleID().equals("")) { NefryDataStore.setModuleID(getDefaultModuleId()); }
56+
if (readSW()) { _bootMode = 2; }
57+
setLedBlink(0, 0xbf, 0, true, 100);
58+
NefryWiFi.begin();
59+
Serial.println("WiFi connected");
60+
Serial.print("SSID: ");
61+
Serial.println(WiFi.SSID());
62+
Serial.print("IP address: ");
63+
Serial.println(WiFi.localIP());
64+
}
6265
setLedBlink(0, 0, 0, false, 0);
6366
delay(100);
6467
setLed(0x00, 0xcf, 0x00);
@@ -76,17 +79,26 @@ void Nefry_lib::nefry_init() {
7679
Serial.println(F("\nServer started"));
7780
/* Module状況表示 */
7881
/* IPaddress display表示 */
79-
printDeviceInfo();
82+
if(Nefry.getWifiEnabled()){
83+
printDeviceInfo();
84+
}
8085
setLed(0x00, 0xff, 0xff);
81-
86+
_nefryWifiWait = 0;
8287
}
8388

8489
void Nefry_lib::nefry_loop() {
85-
NefryWiFi.run();
90+
if(Nefry.getWifiEnabled()){
91+
_nefryWifiWait++;
92+
if (_nefryWifiWait > 1000) {//WiFiに接続する間隔を10秒ごとに修正
93+
_nefryWifiWait = 0;
94+
NefryWiFi.run();
95+
}
96+
}
8697
}
8798

8899
void Nefry_lib::printDeviceInfo()
89100
{
101+
if(!Nefry.getDisplayStatusEnabled()) { return; }
90102
NefryDisplay.setAutoScrollFlg(true);
91103
NefryDisplay.autoScrollFunc(getNefryDisplayInfo);
92104
}
@@ -400,4 +412,31 @@ void Nefry_lib::setLedBlink(int red,int green,int blue,bool EN,int wait) {
400412
_nefryLedBlinkState[3] = EN;
401413
_nefryLedBlinkState[4] = wait;
402414
}
415+
416+
// Wi-FiのON/OFF
417+
void Nefry_lib::enableWifi() {
418+
_wifiEnableFlg = true;
419+
}
420+
421+
void Nefry_lib::disableWifi() {
422+
_wifiEnableFlg = false;
423+
}
424+
425+
bool Nefry_lib::getWifiEnabled() {
426+
return _wifiEnableFlg;
427+
}
428+
429+
// ディスプレイステータスのON/OFF
430+
void Nefry_lib::enableDisplayStatus() {
431+
_displayStatusFlg = true;
432+
}
433+
434+
void Nefry_lib::disableDisplayStatus() {
435+
_displayStatusFlg = false;
436+
}
437+
438+
bool Nefry_lib::getDisplayStatusEnabled() {
439+
return _displayStatusFlg;
440+
}
441+
403442
Nefry_lib Nefry;

cores/esp32/nefry/Nefry.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ class Nefry_lib
3535
setStoreStr(String str,const int pointer),
3636
getWriteMode(),
3737
readSW(),
38-
getPollingSW();
39-
38+
getPollingSW(),
39+
getWifiEnabled(),
40+
getDisplayStatusEnabled();
41+
4042
String
4143
getModuleID(),
4244
getModuleClass(),
@@ -79,6 +81,12 @@ class Nefry_lib
7981
enableSW(),
8082
disableSW(),
8183

84+
enableWifi(),
85+
disableWifi(),
86+
87+
enableDisplayStatus(),
88+
disableDisplayStatus(),
89+
8290
/* Pollingでスイッチの状態をチェック */
8391
pollingSW(),
8492

@@ -148,12 +156,15 @@ class Nefry_lib
148156
bool
149157
_swEnableFlg = false,/* SWの有効無効化 */
150158
_swflg = false, /* SWの状態を保持 */
151-
_swPushingflg = false;
152-
159+
_swPushingflg = false,
160+
_wifiEnableFlg = true,/* Wi-Fiの有効無効化 */
161+
_displayStatusFlg = true;/* ディスプレイの状態表示の有効無効化 */
162+
153163
int
154164
_bootMode = -1, /* Boot状態を管理 -1:初期化中 0:起動中 1:通常起動 2:書き込みモード */
155165
hextonum(char c),
156-
_nefryState = 0;
166+
_nefryState = 0,
167+
_nefryWifiWait;
157168
int _nefryLedBlinkState[5];
158169
const char * program;
159170
};

cores/esp32/nefry/NefryDisplay.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ void Nefry_Display::end()
5959
{
6060
_nefrySsdDisplay.end();
6161
}
62+
63+
void Nefry_Display::setColor(OLEDDISPLAY_COLOR color)
64+
{
65+
_nefrySsdDisplay.setColor(color);
66+
}
67+
6268
void Nefry_Display::drawString(int16_t x, int16_t y, String text, int16_t maxLineWidth)
6369
{
6470
/* スクロール機能未実装 */

cores/esp32/nefry/NefryDisplay.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class Nefry_Display
1515
// ディスプレイで使用しているメモリを解放する
1616
void end();
1717

18+
// Sets the color of all pixel operations
19+
void setColor(OLEDDISPLAY_COLOR color);
20+
1821
//指定された場所に最大幅の文字列を描画します。
1922
//指定されたStringが指定された幅よりも広い場合
2023
//テキストはスペースまたはダッシュで次の行に折り返されます

cores/esp32/nefry/NefrySetting.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
Nefry lib
3+
4+
Copyright (c) 2016 wami
5+
6+
This software is released under the MIT License.
7+
http://opensource.org/licenses/mit-license.php
8+
*/
9+
10+
#include "NefrySetting.h"
11+
12+
FUNC_POINTER fsetup=nullptr;
13+
NefrySetting::NefrySetting(){}
14+
15+
NefrySetting::NefrySetting(FUNC_POINTER _Func_setup){
16+
fsetup = _Func_setup;
17+
}
18+
19+
void NefrySetting::setupSetting()
20+
{
21+
if (fsetup != nullptr) {
22+
fsetup();
23+
}
24+
}

cores/esp32/nefry/NefrySetting.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef NefrySetting_h
2+
#define NefrySetting_h
3+
#include "NefrySettingBase.h"
4+
typedef void(*FUNC_POINTER)(void);
5+
class NefrySetting
6+
{
7+
public:
8+
NefrySetting();
9+
NefrySetting(FUNC_POINTER _Func_setting);
10+
void setupSetting();
11+
private:
12+
13+
};
14+
#endif

cores/esp32/nefry/NefrySettingBase.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef Nefry_SettingBase_h
2+
#define Nefry_SettingBase_h
3+
typedef void(*FUNC_POINTER)(void); //ŠÖ”ƒ|ƒCƒ“ƒ^‚Ìtypedef
4+
extern FUNC_POINTER fsetup, floop;
5+
6+
//extern Nefry_Write NefryWriteMode;
7+
#endif

cores/esp32/nefry/NefryWeb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void Nefry_Web::beginWeb() {
7070
content += indexlink;
7171
content += F("</ul><p>Nefry library:");
7272
content += Nefry.getVersion();
73-
content += F("</br>Running ProgramName:");
73+
content += F("</br>Running Program Name:");
7474
content += Nefry.getProgramName();
7575
content += F("</p>");
7676
NefryWebServer.getWebServer()->send(200, "text/html", createHtml(F("Nefry Menu"), "", content));

cores/esp32/nefry/NefryWiFi.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ void Nefry_WiFi::begin() {
2121
NefryDisplay.drawString(10, 14, "Scanning WiFi");
2222
NefryDisplay.drawProgressBar(14, 44, 100, 14, 0);
2323
NefryDisplay.display();
24+
WiFi.disconnect();
25+
delay(2000);
2426
WiFi.persistent(false);
2527
WiFi.mode(WIFI_AP_STA);
2628
wifiMulti = WiFiMulti();
@@ -76,6 +78,8 @@ run関数で返す値
7678
if (getWifiTimeout() == -1)return 1;
7779
if (getWifiTimeout() != 0 && getWifiTimeout() <= _WifiTimeOutCount)return 2;
7880
uint8_t wifiStatus = wifiMulti.run(Nefry.getBootMode());
81+
WiFi.setAutoConnect(true);
82+
WiFi.setAutoReconnect(true);
7983
if (prevWifiStatus != wifiStatus) {
8084
prevWifiStatus = wifiStatus;
8185
if (wifiStatus == WL_CONNECTED) {
@@ -105,6 +109,7 @@ run関数で返す値
105109
break;
106110
case WL_NO_SSID_AVAIL:
107111
Serial.println(F("SSID Not Found"));
112+
WiFi.disconnect();
108113
return 4;
109114
break;
110115
case WL_SCAN_COMPLETED:

cores/esp32/nefry/inc/WiFi/examples/WiFiMulti/WiFiMulti.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <WiFi.h>
77
#include <WiFiMulti.h>
8+
#include <Nefry.h>
89

910
WiFiMulti wifiMulti;
1011

@@ -18,7 +19,7 @@ void setup()
1819
wifiMulti.addAP("ssid_from_AP_3", "your_password_for_AP_3");
1920

2021
Serial.println("Connecting Wifi...");
21-
if(wifiMulti.run() == WL_CONNECTED) {
22+
if(wifiMulti.run(Nefry.getBootMode()) == WL_CONNECTED) {
2223
Serial.println("");
2324
Serial.println("WiFi connected");
2425
Serial.println("IP address: ");
@@ -28,8 +29,8 @@ void setup()
2829

2930
void loop()
3031
{
31-
if(wifiMulti.run() != WL_CONNECTED) {
32+
if(wifiMulti.run(Nefry.getBootMode()) != WL_CONNECTED) {
3233
Serial.println("WiFi not connected!");
3334
delay(1000);
3435
}
35-
}
36+
}

cores/esp32/nefry/inc/WiFi/src/WiFiMulti.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ uint8_t WiFiMulti::run(int mode)
138138

139139
// wait for connection or fail
140140
while(status != WL_CONNECTED && status != WL_NO_SSID_AVAIL && status != WL_CONNECT_FAILED) {
141-
delay(70);
141+
delay(200);
142142
status = WiFi.status();
143143
wifiDisplayScroll++;
144144
if (wifiDisplayScroll > 50)break;

libraries/Nefry/Nefry.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ class Nefry_lib
1515
setStoreStr(String str, const int pointer),
1616
getWriteMode(),
1717
readSW(),
18-
getPollingSW();
18+
getPollingSW(),
19+
getWifiEnabled(),
20+
getDisplayStatusEnabled();
1921

2022
String
2123
getModuleID(),
@@ -59,6 +61,12 @@ class Nefry_lib
5961
enableSW(),
6062
disableSW(),
6163

64+
enableWifi(),
65+
disableWifi(),
66+
67+
enableDisplayStatus(),
68+
disableDisplayStatus(),
69+
6270
/* Pollingでスイッチの状態をチェック */
6371
pollingSW(),
6472

@@ -126,8 +134,10 @@ class Nefry_lib
126134
bool
127135
_swEnableFlg = false,/* SWの有効無効化 */
128136
_swflg = false, /* SWの状態を保持 */
129-
_swPushingflg = false;
130-
137+
_swPushingflg = false,
138+
_wifiEnableFlg = true,/* Wi-Fiの有効無効化 */
139+
_displayStatusFlg = true;/* ディスプレイの状態表示の有効無効化 */
140+
131141
int
132142
_bootMode = -1, /* Boot状態を管理 -1:初期化中 0:起動中 1:通常起動 2:書き込みモード */
133143
hextonum(char c),

0 commit comments

Comments
 (0)