Skip to content

Commit 7a2d3cf

Browse files
author
mxzz
committed
v.1.5
- connect D0 Pin and GND pin you can enable/disable appliances via webinterface - minor code clean up
1 parent 80867d3 commit 7a2d3cf

File tree

5 files changed

+37
-32
lines changed

5 files changed

+37
-32
lines changed

netgotchi/buttons.ino

+2-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//Buttons functions
22

3-
Button2 buttonUp;
4-
Button2 buttonDown;
53
Button2 buttonLeft;
64
Button2 buttonRight;
75
Button2 buttonA;
@@ -17,19 +15,13 @@ void buttonsInit()
1715
buttonB.setID(BTN_B);
1816
buttonLeft.begin(BTN_LEFT);
1917
buttonLeft.setID(BTN_LEFT);
20-
buttonUp.begin(BTN_UP);
21-
buttonUp.setID(BTN_UP);
22-
buttonDown.begin(BTN_DOWN);
23-
buttonDown.setID(BTN_DOWN);
2418
buttonRight.begin(BTN_RIGHT);
2519
buttonRight.setID(BTN_RIGHT);
2620

2721
buttonA.setPressedHandler(buttonPressed);
2822
buttonB.setPressedHandler(buttonPressed);
2923
buttonLeft.setPressedHandler(buttonPressed);
3024
buttonRight.setPressedHandler(buttonPressed);
31-
buttonUp.setPressedHandler(buttonPressed);
32-
buttonDown.setPressedHandler(buttonPressed);
3325
}
3426

3527
void buttonLoops() {
@@ -56,8 +48,6 @@ void controlsButtonLoop()
5648
{
5749
buttonA.loop();
5850
buttonB.loop();
59-
buttonUp.loop();
60-
buttonDown.loop();
6151
buttonLeft.loop();
6252
buttonRight.loop();
6353
}
@@ -82,20 +72,12 @@ void handleButtons(int btnID)
8272
if(settingMode)settingCancel();
8373
break;
8474

85-
case BTN_RIGHT:
75+
case BTN_LEFT:
8676
//RIGHT
8777
nextScreen();
8878
break;
8979

90-
case BTN_LEFT:
91-
//LEFT
92-
break;
93-
94-
case BTN_UP:
95-
//UP
96-
break;
97-
98-
case BTN_DOWN:
80+
case BTN_RIGHT:
9981
//DOWN
10082
settingMode = true;
10183
if(settingMode)

netgotchi/misc.ino

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,13 @@ void countdownToRestart()
44
if(seconds > 360) ESP.restart();
55
}
66

7-
7+
void raisePinVoltage()
8+
{
9+
pinMode(EXT_PIN_16, OUTPUT);
10+
digitalWrite(EXT_PIN_16, HIGH);
11+
}
12+
void lowerPinVoltage()
13+
{
14+
pinMode(EXT_PIN_16, OUTPUT);
15+
digitalWrite(EXT_PIN_16, LOW);
16+
}

netgotchi/netgotchi.ino

+11-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <WiFiManager.h> // Include the WiFiManager library
2525
#include <Button2.h>
2626

27-
const float VERSION = 1.4;
27+
const float VERSION = 1.5;
2828

2929
//Oled Screen Selectors
3030
#define SCREEN_WIDTH 128
@@ -36,12 +36,13 @@ const float VERSION = 1.4;
3636
#define oled_type_sh1106 0
3737
#define oled_type_ssd1305 0
3838

39-
#define BTN_LEFT 16
4039
#define BTN_RIGHT 13
41-
#define BTN_UP 14
42-
#define BTN_DOWN 12
40+
#define BTN_LEFT 14
4341
#define BTN_A 2
4442
#define BTN_B 0
43+
#define BUZZER_PIN 13
44+
//#define BUZZER_PIN 15 //for netgotchi pro
45+
#define EXT_PIN_16 16 // D0 on pro
4546

4647
#if oled_type_ssd1305
4748
#include <Adafruit_SSD1305.h>
@@ -106,7 +107,6 @@ int ips[255] = {};
106107
unsigned long lastPingTime = 0;
107108
bool honeypotTriggered = false;
108109
bool sounds = true;
109-
int buzzer_pin = 13;
110110

111111
String externalNetworkStatus = "";
112112
String networkStatus = "";
@@ -150,8 +150,8 @@ const char* password = "";
150150

151151
bool enableNetworkMode = true;
152152
bool shouldSaveConfig = false;
153-
bool useButtonToResetFlash = true;
154-
bool hasControlsButtons = false;
153+
bool useButtonToResetFlash = true;//false for netgotchi pro
154+
bool hasControlsButtons = false; //true for netgotchi pro
155155
bool debug = true;
156156
bool headless = true;
157157
bool hasDisplay = true;
@@ -237,6 +237,8 @@ static const char PROGMEM pagehtml[] = R"rawliteral(
237237
<button onclick="sendCommand('right')">Right</button>
238238
<button onclick="sendCommand('A')">A</button>
239239
<button onclick="sendCommand('B')">B</button>
240+
<button onclick="sendCommand('ON')">PIN ON</button>
241+
<button onclick="sendCommand('OFF')">PIN OFF</button>
240242
</div>
241243
<p>Hosts</p>
242244
<button onclick="getHosts()">Get Hosts Datas</button>
@@ -402,3 +404,5 @@ void headlessInfo() {
402404
SerialPrintLn(headlessStatus);
403405
}
404406
}
407+
408+

netgotchi/network.ino

+10
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ void networkInit()
7676
handleCommand("B");
7777
server.send(200, "text/plain", "B command received");
7878
});
79+
server.on("/command/ON", HTTP_GET, [](){
80+
raisePinVoltage();
81+
server.send(200, "text/plain", "ON command received");
82+
});
83+
server.on("/command/OFF", HTTP_GET, [](){
84+
lowerPinVoltage();
85+
server.send(200, "text/plain", "ON command received");
86+
});
7987

8088
server.begin();
8189
}
@@ -273,3 +281,5 @@ String getHostsStats() {
273281
}
274282

275283

284+
285+

netgotchi/sounds.ino

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ void playAlert() {
55
#ifdef ESP32
66
//to add a library for Tone
77
#elif defined(ESP8266)
8-
tone(buzzer_pin, 500);
8+
tone(BUZZER_PIN, 500);
99
delay(500);
10-
noTone(buzzer_pin);
10+
noTone(BUZZER_PIN);
1111
delay(500);
12-
tone(buzzer_pin, 500);
12+
tone(BUZZER_PIN, 500);
1313
delay(500);
14-
noTone(buzzer_pin);
14+
noTone(BUZZER_PIN);
1515
#endif
1616
}

0 commit comments

Comments
 (0)