Skip to content

Commit 36aec65

Browse files
authored
Merge pull request #98 from Nefry-Community/1.2Develop
1.2 develop
2 parents 417ecbb + 1abbd00 commit 36aec65

File tree

34 files changed

+2139
-58
lines changed

34 files changed

+2139
-58
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ tools/xtensa-esp32-elf
33
tools/dist
44
tools/esptool
55
tools/esptool.exe
6+
.vs/

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
url = https://github.com/wamisnet/ConfigurableFirmata.git
44
[submodule "libraries/Nefry_ThingSpeak/src/include"]
55
path = libraries/Nefry_ThingSpeak/src/include
6-
url=https://github.com/wamisnet/thingspeak-arduino.git
6+
url=https://github.com/wamisnet/thingspeak-arduino.git
7+
[submodule "libraries/TutorialBookExample"]
8+
path = libraries/TutorialBookExample
9+
url = https://github.com/Nefry-Community/TutorialExample.git

boards.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,58 @@ menu.DebugLevel=Core Debug Level
66

77
##############################################################
88

9+
nefrybtr3.name=Nefry BT R3
10+
11+
nefrybtr3.upload.tool=esptool
12+
nefrybtr3.upload.maximum_size=1703936
13+
nefrybtr3.upload.maximum_data_size=294912
14+
nefrybtr3.upload.wait_for_upload_port=true
15+
16+
nefrybtr3.serial.disableDTR=true
17+
nefrybtr3.serial.disableRTS=true
18+
19+
nefrybtr3.build.mcu=esp32
20+
nefrybtr3.build.core=esp32
21+
nefrybtr3.build.variant=nefrybt-r3
22+
nefrybtr3.build.board=Nefry_BT_R3
23+
nefrybtr3.build.partitions=default
24+
25+
nefrybtr3.build.f_cpu=240000000L
26+
nefrybtr3.build.flash_mode=dio
27+
nefrybtr3.build.flash_size=4MB
28+
nefrybtr3.build.boot=bootloader
29+
nefrybtr3.build.flash_freq=80m
30+
31+
nefrybtr3.menu.UploadSpeed.921600=921600
32+
nefrybtr3.menu.UploadSpeed.921600.upload.speed=921600
33+
nefrybtr3.menu.UploadSpeed.115200=115200
34+
nefrybtr3.menu.UploadSpeed.115200.upload.speed=115200
35+
nefrybtr3.menu.UploadSpeed.256000.windows=256000
36+
nefrybtr3.menu.UploadSpeed.256000.upload.speed=256000
37+
nefrybtr3.menu.UploadSpeed.230400.windows.upload.speed=256000
38+
nefrybtr3.menu.UploadSpeed.230400=230400
39+
nefrybtr3.menu.UploadSpeed.230400.upload.speed=230400
40+
nefrybtr3.menu.UploadSpeed.460800.linux=460800
41+
nefrybtr3.menu.UploadSpeed.460800.macosx=460800
42+
nefrybtr3.menu.UploadSpeed.460800.upload.speed=460800
43+
nefrybtr3.menu.UploadSpeed.512000.windows=512000
44+
nefrybtr3.menu.UploadSpeed.512000.upload.speed=512000
45+
46+
nefrybtr3.menu.DebugLevel.none=None
47+
nefrybtr3.menu.DebugLevel.none.build.code_debug=0
48+
nefrybtr3.menu.DebugLevel.error=Error
49+
nefrybtr3.menu.DebugLevel.error.build.code_debug=1
50+
nefrybtr3.menu.DebugLevel.warn=Warn
51+
nefrybtr3.menu.DebugLevel.warn.build.code_debug=2
52+
nefrybtr3.menu.DebugLevel.info=Info
53+
nefrybtr3.menu.DebugLevel.info.build.code_debug=3
54+
nefrybtr3.menu.DebugLevel.debug=Debug
55+
nefrybtr3.menu.DebugLevel.debug.build.code_debug=4
56+
nefrybtr3.menu.DebugLevel.verbose=Verbose
57+
nefrybtr3.menu.DebugLevel.verbose.build.code_debug=5
58+
59+
##############################################################
60+
961
nefrybtr2.name=Nefry BT R2
1062

1163
nefrybtr2.upload.tool=esptool

cores/esp32/nefry/Nefry.cpp

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

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

30-
Adafruit_NeoPixel _NefryLED[40];
31-
30+
Adafruit_NeoPixel _NefryLEDNeo;
31+
Adafruit_DotStar _NefryLEDStar;
32+
bool connectAnFlg = false;
3233
//main
3334

3435
void Nefry_lib::nefry_init() {
3536
/* Display設定 */
37+
connectAnFlg = false;
3638
delay(10);
3739
NefryDisplay.begin();//logo表示
38-
beginLed((const int)1, (const int)16, (uint8_t)NEO_GRBW);
40+
if (boardId == 3) {
41+
beginLed((const int)1, (const int)LED_DO, (uint8_t)DOTSTAR_BRG, LED_CLK);
42+
} else {
43+
beginLed((const int)1, (const int)16, (uint8_t)NEO_GRBW);
44+
}
3945
setLedBlink(0, 0, 0, false, 0);
4046
setLed(0x00, 0x0f, 0x00);
4147
enableSW();
@@ -92,6 +98,9 @@ void Nefry_lib::nefry_loop() {
9298
if (_nefryWifiWait > 1000) {//WiFiに接続する間隔を10秒ごとに修正
9399
_nefryWifiWait = 0;
94100
NefryWiFi.run();
101+
if (connectAnFlg != true) {
102+
connectAnFlg = setAnalyticsData("connect");
103+
}
95104
}
96105
}
97106
}
@@ -289,18 +298,34 @@ bool Nefry_lib::getPollingSW()
289298
}
290299

291300
//LED
292-
void Nefry_lib::beginLed(const int num, const int pin, uint8_t t = NEO_GRB) {
293-
_NefryLED[pin] = Adafruit_NeoPixel(num, pin, t);
294-
_NefryLED[pin].begin();
301+
void Nefry_lib::beginLed(const int num, const int DataOut, uint8_t t ,const int clk) {
302+
if (boardId == 3) { // Nefry BT r3
303+
_NefryLEDStar = Adafruit_DotStar(num, DataOut, clk, DOTSTAR_BRG);
304+
_NefryLEDStar.begin();
305+
_NefryLEDStar.show();
306+
}
307+
else {
308+
_NefryLEDNeo = Adafruit_NeoPixel(num, DataOut, t);
309+
_NefryLEDNeo.begin();
310+
_NefryLEDNeo.show();
311+
}
295312
}
313+
296314
void Nefry_lib::setLed(const int r, const int g, const int b, const char w, const int pin, const int num) {
297-
_NefryLED[pin].setPixelColor(num,0, 0, 0);
298-
delay(1);
299-
_NefryLED[pin].show();
300-
_NefryLED[pin].setBrightness(w);
301-
_NefryLED[pin].setPixelColor(num, map(r,0,255,0,150), g, b);
302-
delay(1);
303-
_NefryLED[pin].show();
315+
if (boardId == 3) { // Nefry BT r3
316+
_NefryLEDStar.setBrightness(w);
317+
_NefryLEDStar.setPixelColor(num, r, g, b);
318+
_NefryLEDStar.show();
319+
}
320+
else {
321+
_NefryLEDNeo.setPixelColor(num, 0, 0, 0);
322+
delay(1);
323+
_NefryLEDNeo.show();
324+
_NefryLEDNeo.setBrightness(w);
325+
_NefryLEDNeo.setPixelColor(num, map(r, 0, 255, 0, 150), g, b);
326+
delay(1);
327+
_NefryLEDNeo.show();
328+
}
304329
}
305330
void Nefry_lib::setLed(String _colorStr, const char w, const int pin, const int num) {
306331
int _color[3];
@@ -343,7 +368,10 @@ String Nefry_lib::getDefaultModuleId() {
343368
String _devstr,ms;
344369
switch (boardId)
345370
{
346-
case 0:case 1:
371+
case 0:
372+
case 1:
373+
case 2:
374+
case 3:
347375
moduleName = "NefryBT";
348376
break;
349377
}
@@ -439,4 +467,85 @@ bool Nefry_lib::getDisplayStatusEnabled() {
439467
return _displayStatusFlg;
440468
}
441469

470+
bool Nefry_lib::setAnalyticsData(String action) {
471+
bool state = false;
472+
if (WiFi.status() == WL_CONNECTED) {
473+
WiFiClient client;
474+
const int httpPort = 80;
475+
if (!client.connect("google-analytics.com", httpPort)) {
476+
//Serial.println("connection failed");
477+
return state;
478+
}
479+
480+
// We now create a URI for the request
481+
String url = "/collect?v=1&t=event&tid=UA-78080011-2&cid=NefryBT&ec=";
482+
url += "NefryBT";
483+
switch (boardId) {
484+
case 1:
485+
url += "r1";
486+
break;
487+
case 2:
488+
url += "r2";
489+
break;
490+
case 3:
491+
url += "r3";
492+
break;
493+
default:
494+
url += "error";
495+
break;
496+
}
497+
url += "&el=v";
498+
url += getVersion();
499+
url += "&ea=";
500+
url += action;
501+
url += "&ds=";
502+
503+
String _devstr;
504+
_devstr = WiFi.macAddress();
505+
_devstr.replace(":", "");
506+
url += (String)"NefryBT-" + _devstr.substring(8);
507+
//Serial.print("Requesting URL: ");
508+
//Serial.println(url);
509+
510+
// This will send the request to the server
511+
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
512+
"Host: google-analytics.com\r\n" +
513+
"Connection: close\r\n\r\n");
514+
unsigned long timeout = millis();
515+
while (client.available() == 0) {
516+
if (millis() - timeout > 5000) {
517+
//Serial.println(">>> Client Timeout !");
518+
client.stop();
519+
return state;
520+
}
521+
}
522+
523+
// Read all the lines of the reply from server and print them to Serial
524+
while (client.available()) {
525+
size_t len = client.available();
526+
if (len > 0) {
527+
String headerLine = client.readStringUntil('\n');
528+
headerLine.trim(); // remove \r
529+
//Serial.print(headerLine);
530+
log_d("[HTTP-Client][handleHeaderResponse] RX: '%s'", headerLine.c_str());
531+
532+
if (headerLine.startsWith("HTTP/1.")) {
533+
int _returnCode = headerLine.substring(9, headerLine.indexOf(' ', 9)).toInt();
534+
//Serial.printf("[HTTP] GET... code: %d\n", _returnCode);
535+
if (_returnCode == 200) {
536+
state = true;
537+
break;
538+
}
539+
else {
540+
state = false;
541+
break;
542+
}
543+
}
544+
}
545+
}
546+
client.stop();
547+
}
548+
return state;
549+
}
550+
442551
Nefry_lib Nefry;

cores/esp32/nefry/Nefry.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define Nefry_h
33

44
#include <Esp.h>
5+
#include "./inc/led/Adafruit_DotStar.h"
56
#include "./inc/led/Adafruit_NeoPixel.h"
67
#include "./inc/Preferences/src/Preferences.h"
78
#include "NefryWiFi.h"
@@ -11,6 +12,8 @@
1112
#include "NefryDisplay.h"
1213
#include "NefryWeb.h"
1314
#include "NefryWebServer.h"
15+
#include "./inc/WiFi/src/WiFiClient.h"
16+
1417

1518
// Offset: W R G B
1619
#define NEO_RGB ((0 << 6) | (0 << 4) | (1 << 2) | (2))
@@ -65,8 +68,8 @@ class Nefry_lib
6568
void
6669
reset(),
6770
sleep(const int sec),
68-
setProgramName(const char * pn),
69-
beginLed(const int num, const int pin, uint8_t t),
71+
setProgramName(const char * pn),
72+
beginLed(const int num, const int dataOut, uint8_t t = 0, const int clk = -1),
7073
setLed(const int r, const int g, const int b, const char w = 80, const int pin = 16, const int num = 0),
7174
setLed(String _colorStr, const char w = 122, const int pin = 16, const int num = 0),
7275
addWiFi(String ssid, String pass),
@@ -159,6 +162,8 @@ class Nefry_lib
159162
_swPushingflg = false,
160163
_wifiEnableFlg = true,/* Wi-Fiの有効無効化 */
161164
_displayStatusFlg = true;/* ディスプレイの状態表示の有効無効化 */
165+
166+
bool setAnalyticsData(String action);
162167

163168
int
164169
_bootMode = -1, /* Boot状態を管理 -1:初期化中 0:起動中 1:通常起動 2:書き込みモード */

cores/esp32/nefry/NefryDisplay.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
SSD1306 _nefrySsdDisplay(0x3c, SDA2, SCL2);
66
String _nefryPrintDisplay1 = "", _nefryPrintDisplay2 = "", _nefryPrintDisplay3 = "";
7-
7+
String _dialogTitle = "Nefry PrintDialog";
88
/* 初期化 */
99
bool Nefry_Display::begin()
1010
{
@@ -19,9 +19,13 @@ bool Nefry_Display::begin()
1919
return true;
2020
}
2121

22+
void Nefry_Display::setTitle(String title) {
23+
_dialogTitle = title;
24+
}
25+
2226
void setPrintDialogDisplay() {
2327
NefryDisplay.setFont(Arimo_12);
24-
NefryDisplay.drawString(15, 0,"Nefry PrintDialog");
28+
NefryDisplay.drawString(15, 0, _dialogTitle);
2529
NefryDisplay.drawStringWithHScroll(0, 20, _nefryPrintDisplay1,10);
2630
NefryDisplay.drawStringWithHScroll(0, 35, _nefryPrintDisplay2, 10);
2731
NefryDisplay.drawStringWithHScroll(0, 50, _nefryPrintDisplay3, 10);

cores/esp32/nefry/NefryDisplay.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class Nefry_Display
110110

111111
void autoScrollTask ();
112112

113+
void setTitle(String title);
114+
113115
private:
114116
GeneralFunction _func = NULL;
115117
uint16_t _scrollTextCount = 0;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#######################################
2+
# Syntax Coloring Map SPI
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
SPI KEYWORD1
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
begin KEYWORD2
15+
end KEYWORD2
16+
transfer KEYWORD2
17+
setBitOrder KEYWORD2
18+
setDataMode KEYWORD2
19+
setClockDivider KEYWORD2
20+
21+
22+
#######################################
23+
# Constants (LITERAL1)
24+
#######################################
25+
SPI_CLOCK_DIV4 LITERAL1
26+
SPI_CLOCK_DIV16 LITERAL1
27+
SPI_CLOCK_DIV64 LITERAL1
28+
SPI_CLOCK_DIV128 LITERAL1
29+
SPI_CLOCK_DIV2 LITERAL1
30+
SPI_CLOCK_DIV8 LITERAL1
31+
SPI_CLOCK_DIV32 LITERAL1
32+
SPI_CLOCK_DIV64 LITERAL1
33+
SPI_MODE0 LITERAL1
34+
SPI_MODE1 LITERAL1
35+
SPI_MODE2 LITERAL1
36+
SPI_MODE3 LITERAL1
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=SPI
2+
version=1.0
3+
author=Hristo Gochkov
4+
maintainer=Hristo Gochkov <hristo@espressif.com>
5+
sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. For all Arduino boards, BUT Arduino DUE.
6+
paragraph=
7+
category=Signal Input/Output
8+
url=http://arduino.cc/en/Reference/SPI
9+
architectures=esp32

0 commit comments

Comments
 (0)