Skip to content

0.6.1 ライブラリー #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 22, 2017
Merged
80 changes: 40 additions & 40 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,43 +58,43 @@ esp32.menu.DebugLevel.verbose.build.code_debug=5

##############################################################

nefryicing.name=Nefry Icing

nefryicing.upload.tool=esptool
nefryicing.upload.maximum_size=1044464
nefryicing.upload.maximum_data_size=294912
nefryicing.upload.wait_for_upload_port=true

nefryicing.serial.disableDTR=true
nefryicing.serial.disableRTS=true

nefryicing.build.mcu=esp32
nefryicing.build.core=esp32
nefryicing.build.variant=esp32
nefryicing.build.board=Nefry_Icing

nefryicing.build.f_cpu=240000000L
nefryicing.build.flash_mode=dio
nefryicing.build.flash_size=4MB

nefryicing.build.flash_freq=80m

nefryicing.menu.UploadSpeed.512000.windows=512000
nefryicing.menu.UploadSpeed.512000.upload.speed=512000
nefryicing.menu.UploadSpeed.115200=115200
nefryicing.menu.UploadSpeed.115200.upload.speed=115200
nefryicing.menu.UploadSpeed.921600=921600
nefryicing.menu.UploadSpeed.921600.upload.speed=921600

nefryicing.menu.DebugLevel.none=None
nefryicing.menu.DebugLevel.none.build.code_debug=0
nefryicing.menu.DebugLevel.error=Error
nefryicing.menu.DebugLevel.error.build.code_debug=1
nefryicing.menu.DebugLevel.warn=Warn
nefryicing.menu.DebugLevel.warn.build.code_debug=2
nefryicing.menu.DebugLevel.info=Info
nefryicing.menu.DebugLevel.info.build.code_debug=3
nefryicing.menu.DebugLevel.debug=Debug
nefryicing.menu.DebugLevel.debug.build.code_debug=4
nefryicing.menu.DebugLevel.verbose=Verbose
nefryicing.menu.DebugLevel.verbose.build.code_debug=5
nefrybt.name=Nefry BT

nefrybt.upload.tool=esptool
nefrybt.upload.maximum_size=1044464
nefrybt.upload.maximum_data_size=294912
nefrybt.upload.wait_for_upload_port=true

nefrybt.serial.disableDTR=true
nefrybt.serial.disableRTS=true

nefrybt.build.mcu=esp32
nefrybt.build.core=esp32
nefrybt.build.variant=esp32
nefrybt.build.board=Nefry_Icing

nefrybt.build.f_cpu=240000000L
nefrybt.build.flash_mode=dio
nefrybt.build.flash_size=4MB

nefrybt.build.flash_freq=80m

nefrybt.menu.UploadSpeed.512000.windows=512000
nefrybt.menu.UploadSpeed.512000.upload.speed=512000
nefrybt.menu.UploadSpeed.115200=115200
nefrybt.menu.UploadSpeed.115200.upload.speed=115200
nefrybt.menu.UploadSpeed.921600=921600
nefrybt.menu.UploadSpeed.921600.upload.speed=921600

nefrybt.menu.DebugLevel.none=None
nefrybt.menu.DebugLevel.none.build.code_debug=0
nefrybt.menu.DebugLevel.error=Error
nefrybt.menu.DebugLevel.error.build.code_debug=1
nefrybt.menu.DebugLevel.warn=Warn
nefrybt.menu.DebugLevel.warn.build.code_debug=2
nefrybt.menu.DebugLevel.info=Info
nefrybt.menu.DebugLevel.info.build.code_debug=3
nefrybt.menu.DebugLevel.debug=Debug
nefrybt.menu.DebugLevel.debug.build.code_debug=4
nefrybt.menu.DebugLevel.verbose=Verbose
nefrybt.menu.DebugLevel.verbose.build.code_debug=5
28 changes: 17 additions & 11 deletions cores/esp32/nefry/Nefry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BootMode
1 : WriteMode切替をする
*/

#define LIBVERSION ("0.6.0")
#define LIBVERSION ("0.6.1")
#include "Nefry.h"

Adafruit_NeoPixel _NefryLED[40];
Expand Down Expand Up @@ -117,21 +117,21 @@ bool Nefry_lib::setUserPass(String pass)

/* Storage */
/* Value */
bool Nefry_lib::setStorageValue(long value, int pointer)
bool Nefry_lib::setStoreValue(long value, int pointer)
{
return NefryDataStore.setStorageValue(value, pointer);
}
long Nefry_lib::getStorageValue(int pointer)
long Nefry_lib::getStoreValue(int pointer)
{
return NefryDataStore.getStorageValue(pointer);
}

/* String */
bool Nefry_lib::setStorageStr(String str, int pointer)
bool Nefry_lib::setStoreStr(String str, int pointer)
{
return NefryDataStore.setStorageStr(str, pointer);
}
String Nefry_lib::getStorageStr(int pointer)
String Nefry_lib::getStoreStr(int pointer)
{
return NefryDataStore.getStorageStr(pointer);
}
Expand Down Expand Up @@ -214,19 +214,25 @@ bool Nefry_lib::readSW() {
return false;
}
else {
return digitalRead(4);
return !digitalRead(4);
}
return false;
}

/* SWを押されたときに割り込まれます */
void Nefry_lib::pollingSW() {
if (_swEnableFlg == true && _swflg != true && digitalRead(4) == LOW) {
if (_bootMode == 0) {
Nefry.setLed(0xff, 0x2f, 0x00);
if (_swEnableFlg == true && _swflg != true) {
if(digitalRead(4) == LOW){
if (_bootMode == 0) {
Nefry.setLed(0xff, 0x2f, 0x00);
}
_swPushingflg = true;
}
Serial.println("push SW");
_swflg = true;
if (digitalRead(4) == HIGH && _swPushingflg == true) {
_swPushingflg = false;
_swflg = true;
}

}
}
bool Nefry_lib::getPollingSW()
Expand Down
13 changes: 7 additions & 6 deletions cores/esp32/nefry/Nefry.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Nefry_lib
setModuleClass(String className),
setUser(String user),
setUserPass(String pass),
setStorageValue(long value, int pointer),
setStorageStr(String str, int pointer),
setStoreValue(long value, int pointer),
setStoreStr(String str, int pointer),
getWriteMode(),
readSW(),
getPollingSW();
Expand All @@ -38,13 +38,13 @@ class Nefry_lib
getModuleID(),
getModuleClass(),
getUser(),
getStorageStr(int pointer),
getStoreStr(int pointer),
getVersion(),
getProgramName(),
getAddressStr(IPAddress ip);

long
getStorageValue(int pointer);
getStoreValue(int pointer);


void
Expand All @@ -70,9 +70,10 @@ class Nefry_lib
pollingSW();

private:
bool
bool
_swEnableFlg = false,/* SWの有効無効化 */
_swflg = false; /* SWの状態を保持 */
_swflg = false, /* SWの状態を保持 */
_swPushingflg = false;

int
_bootMode = 0, /* Boot状態を管理 0:起動中 1:通常起動 2:書き込みモード */
Expand Down
6 changes: 3 additions & 3 deletions cores/esp32/nefry/NefryConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ ModulePass : Nefryが発信するWiFiパスワード
ModuleClass : Nefryのモジュールが属するクラス
user : Nefryでログイン機能を使うときに使用するユーザ名
userPass : Nefryでログイン機能を使うときに使用するパスワード
StorageValue: Nefryの環境変数を保存するときに使用する。(0-7)の範囲で保存する。末端に数字が追加される long型
StorageStr : Nefryの環境変数を保存するときに使用する。(0-7)の範囲で保存する。末端に数字が追加される String型
StoreValue : Nefryの環境変数を保存するときに使用する。(0-7)の範囲で保存する。末端に数字が追加される long型
StoreStr : Nefryの環境変数を保存するときに使用する。(0-7)の範囲で保存する。末端に数字が追加される String型
*/

#include "NefryConfig.h"
Expand All @@ -26,7 +26,7 @@ String Nefry_Conf::beginWeb(String link) {
if (link.equals("config")) {
String content = F("<h1>Nefry DataStore Setup</h1><p>このページはプログラム内から読み書きした値を表示、編集することができます。</p>"
"<p>わざわざプログラムを書き換えずに値を変更できるためWebサービスでアクセスキーが必要になる場合など環境変数として扱うことができます。</p>"
"<ul><li>setStorageValue or setStorageStr : 値の保存</li><li>getStorageValue or getStorageStr : 値の取得</li><li>setStoreTitle : 内容の表示</li></ul>"
"<ul><li>setStoreValue or setStoreStr : 値の保存</li><li>getStoreValue or getStoreStr : 値の取得</li><li>setStoreTitle : 内容の表示</li></ul>"
"<p>それぞれの関数の使い方はNefry公式サイトをご覧になるか、サンプルプログラムを参考にしてください。</p><form method='get'action='set_config'>");
int formNumber,printCounter = 0;
for (formNumber = 0; formNumber < 10; formNumber++) {
Expand Down
2 changes: 1 addition & 1 deletion cores/esp32/nefry/NefryWebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void Nefry_webserver::run() {
NefryDataStore.setStorageValue(s.toInt(),i);
}
resetTimer(2);
send(200, "text/html", NefryWeb.createHtml(F("Nefry DataStore Set"), "", F("<h1>Nefry Module Set</h1><p>Restart...</p><a href=\"/\">Back to top</a>")));
send(200, "text/html", NefryWeb.createHtml(F("Nefry DataStore Set"), "", F("<h1>Nefry Module Set</h1><p>Saveing & Restart...</p><a href=\"/\">Back to top</a>")));
resetTimer(2);
}
/* "/"は必ず一番下にすること */
Expand Down
75 changes: 27 additions & 48 deletions libraries/Nefry/Nefry.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#ifndef Nefry_h
#ifndef Nefry_h
#define Nefry_h



#include <Arduino.h>


class Nefry_lib
Expand All @@ -15,17 +14,23 @@ class Nefry_lib
setModuleClass(String className),
setUser(String user),
setUserPass(String pass),
setStorageValue(long value, int pointer),
setStorageStr(String str, int pointer);
setStoreValue(long value, int pointer),
setStoreStr(String str, int pointer),
getWriteMode(),
readSW(),
getPollingSW();

String
getModuleID(),
getModuleClass(),
getUser(),
getStorageStr(int pointer);
getStoreStr(int pointer),
getVersion(),
getProgramName(),
getAddressStr(IPAddress ip);

long
getStorageValue(int pointer);
getStoreValue(int pointer);


void
Expand All @@ -38,54 +43,28 @@ class Nefry_lib
addWiFi(String ssid, String pass),
deleteWiFi(int id),
saveWiFi(),
/*
println(float text),
println(double text),
println(char text),
println(int text),
println(long text),
println(unsigned char text),
println(unsigned int text),
println(unsigned long text),
print(float text),
print(double text),
print(char text),
print(int text),
print(long text),
print(unsigned char text),
print(unsigned int text),
print(unsigned long text),
print(String text, int ln = 0),
println(String text),
*/
nefry_init(),
nefry_loop(),
ndelay(unsigned long ms);
ndelay(unsigned long ms),

void enableSW();
setStoreTitle(const char set[15], const int num),

void disableSW();

bool
readSW();

void pollingSW();
bool getBootFlg();


String
getVersion(),
getProgramName(),
getAddressStr(IPAddress ip);
enableSW(),
disableSW(),

/* Pollingでスイッチの状態をチェック */
pollingSW();

private:
bool _swEnableFlg;
bool _bootMode = true, _swflg = false;
int hextonum(char c);
bool
_swEnableFlg = false,/* SWの有効無効化 */
_swflg = false; /* SWの状態を保持 */

int
_bootMode = 0, /* Boot状態を管理 0:起動中 1:通常起動 2:書き込みモード */
hextonum(char c);

const char * program;
};
extern Nefry_lib Nefry;
#endif

void _swcallback_function();
#endif
8 changes: 4 additions & 4 deletions libraries/Nefry/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ setModulePass KEYWORD2
setModuleClass KEYWORD2
setUser KEYWORD2
setUserPass KEYWORD2
setStorageValue KEYWORD2
setStorageStr KEYWORD2
setStoreValue KEYWORD2
setStoreStr KEYWORD2
setUser KEYWORD2

#######################################
Expand All @@ -30,8 +30,8 @@ setUser KEYWORD2
getModuleID KEYWORD2
getModuleClass KEYWORD2
getUser KEYWORD2
getStorageStr KEYWORD2
getStorageValue KEYWORD2
getStoreStr KEYWORD2
getStoreValue KEYWORD2
getBootFlg KEYWORD2

#######################################
Expand Down
2 changes: 1 addition & 1 deletion libraries/Nefry/library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Nefry
version=0.6.0
version=0.6.1
author=Nefry community
maintainer=
sentence=nefry.
Expand Down
38 changes: 38 additions & 0 deletions libraries/Nefy_IFTTT/NefryIFTTT.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
Nefry IFTTT lib

Copyright (c) 2015 wami

This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
*/

#include "NefryIFTTT.h"

bool Nefry_IFTTT::send(String event, String Secretkey, String data1, String data2, String data3)
{
String _data = "{\"value1\":\"";
_data += data1;
_data += "\",\"value2\":\"";
_data += data2;
_data += "\",\"value3\":\"";
_data += data3;
_data += "\"}";
WiFiClient client;
if (client.connect("maker.ifttt.com", 80)) {
//Nefry.println("connection");
client.println("POST /trigger/" + event + "/with/key/" + Secretkey + " HTTP/1.1");
client.println("Host: maker.ifttt.com");
client.println("User-Agent: ESP8266/1.0");
client.println("Connection: close");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(_data.length());
client.println();
client.println(_data);
delay(10);
return true;
}
return false;
}
Nefry_IFTTT IFTTT;
Loading