Skip to content

Commit f4f93f6

Browse files
author
wamisnet
committed
Nefryライブラリ1.1.4までの更新を導入
1 parent 50cfe0f commit f4f93f6

File tree

10 files changed

+130
-21
lines changed

10 files changed

+130
-21
lines changed

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:

libraries/Nefry/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Nefry
2-
version=1.0.9
2+
version=1.2.0
33
author=Nefry community
44
maintainer=
55
sentence=nefry.

0 commit comments

Comments
 (0)