Skip to content

Commit

Permalink
v.1.5
Browse files Browse the repository at this point in the history
- connect D0 Pin and GND pin you can enable/disable appliances via webinterface

- minor code clean up
  • Loading branch information
mxzz committed Sep 22, 2024
1 parent 80867d3 commit 7a2d3cf
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 32 deletions.
22 changes: 2 additions & 20 deletions netgotchi/buttons.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//Buttons functions

Button2 buttonUp;
Button2 buttonDown;
Button2 buttonLeft;
Button2 buttonRight;
Button2 buttonA;
Expand All @@ -17,19 +15,13 @@ void buttonsInit()
buttonB.setID(BTN_B);
buttonLeft.begin(BTN_LEFT);
buttonLeft.setID(BTN_LEFT);
buttonUp.begin(BTN_UP);
buttonUp.setID(BTN_UP);
buttonDown.begin(BTN_DOWN);
buttonDown.setID(BTN_DOWN);
buttonRight.begin(BTN_RIGHT);
buttonRight.setID(BTN_RIGHT);

buttonA.setPressedHandler(buttonPressed);
buttonB.setPressedHandler(buttonPressed);
buttonLeft.setPressedHandler(buttonPressed);
buttonRight.setPressedHandler(buttonPressed);
buttonUp.setPressedHandler(buttonPressed);
buttonDown.setPressedHandler(buttonPressed);
}

void buttonLoops() {
Expand All @@ -56,8 +48,6 @@ void controlsButtonLoop()
{
buttonA.loop();
buttonB.loop();
buttonUp.loop();
buttonDown.loop();
buttonLeft.loop();
buttonRight.loop();
}
Expand All @@ -82,20 +72,12 @@ void handleButtons(int btnID)
if(settingMode)settingCancel();
break;

case BTN_RIGHT:
case BTN_LEFT:
//RIGHT
nextScreen();
break;

case BTN_LEFT:
//LEFT
break;

case BTN_UP:
//UP
break;

case BTN_DOWN:
case BTN_RIGHT:
//DOWN
settingMode = true;
if(settingMode)
Expand Down
11 changes: 10 additions & 1 deletion netgotchi/misc.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ void countdownToRestart()
if(seconds > 360) ESP.restart();
}


void raisePinVoltage()
{
pinMode(EXT_PIN_16, OUTPUT);
digitalWrite(EXT_PIN_16, HIGH);
}
void lowerPinVoltage()
{
pinMode(EXT_PIN_16, OUTPUT);
digitalWrite(EXT_PIN_16, LOW);
}
18 changes: 11 additions & 7 deletions netgotchi/netgotchi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <WiFiManager.h> // Include the WiFiManager library
#include <Button2.h>

const float VERSION = 1.4;
const float VERSION = 1.5;

//Oled Screen Selectors
#define SCREEN_WIDTH 128
Expand All @@ -36,12 +36,13 @@ const float VERSION = 1.4;
#define oled_type_sh1106 0
#define oled_type_ssd1305 0

#define BTN_LEFT 16
#define BTN_RIGHT 13
#define BTN_UP 14
#define BTN_DOWN 12
#define BTN_LEFT 14
#define BTN_A 2
#define BTN_B 0
#define BUZZER_PIN 13
//#define BUZZER_PIN 15 //for netgotchi pro
#define EXT_PIN_16 16 // D0 on pro

#if oled_type_ssd1305
#include <Adafruit_SSD1305.h>
Expand Down Expand Up @@ -106,7 +107,6 @@ int ips[255] = {};
unsigned long lastPingTime = 0;
bool honeypotTriggered = false;
bool sounds = true;
int buzzer_pin = 13;

String externalNetworkStatus = "";
String networkStatus = "";
Expand Down Expand Up @@ -150,8 +150,8 @@ const char* password = "";

bool enableNetworkMode = true;
bool shouldSaveConfig = false;
bool useButtonToResetFlash = true;
bool hasControlsButtons = false;
bool useButtonToResetFlash = true;//false for netgotchi pro
bool hasControlsButtons = false; //true for netgotchi pro
bool debug = true;
bool headless = true;
bool hasDisplay = true;
Expand Down Expand Up @@ -237,6 +237,8 @@ static const char PROGMEM pagehtml[] = R"rawliteral(
<button onclick="sendCommand('right')">Right</button>
<button onclick="sendCommand('A')">A</button>
<button onclick="sendCommand('B')">B</button>
<button onclick="sendCommand('ON')">PIN ON</button>
<button onclick="sendCommand('OFF')">PIN OFF</button>
</div>
<p>Hosts</p>
<button onclick="getHosts()">Get Hosts Datas</button>
Expand Down Expand Up @@ -402,3 +404,5 @@ void headlessInfo() {
SerialPrintLn(headlessStatus);
}
}


10 changes: 10 additions & 0 deletions netgotchi/network.ino
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ void networkInit()
handleCommand("B");
server.send(200, "text/plain", "B command received");
});
server.on("/command/ON", HTTP_GET, [](){
raisePinVoltage();
server.send(200, "text/plain", "ON command received");
});
server.on("/command/OFF", HTTP_GET, [](){
lowerPinVoltage();
server.send(200, "text/plain", "ON command received");
});

server.begin();
}
Expand Down Expand Up @@ -273,3 +281,5 @@ String getHostsStats() {
}




8 changes: 4 additions & 4 deletions netgotchi/sounds.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ void playAlert() {
#ifdef ESP32
//to add a library for Tone
#elif defined(ESP8266)
tone(buzzer_pin, 500);
tone(BUZZER_PIN, 500);
delay(500);
noTone(buzzer_pin);
noTone(BUZZER_PIN);
delay(500);
tone(buzzer_pin, 500);
tone(BUZZER_PIN, 500);
delay(500);
noTone(buzzer_pin);
noTone(BUZZER_PIN);
#endif
}

0 comments on commit 7a2d3cf

Please sign in to comment.