mirror of
https://github.com/SpacehuhnTech/esp8266_deauther.git
synced 2025-12-23 15:10:06 +01:00
optimized buttons
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
|
|
||||||
#define resetPin 4 /* <-- comment out or change if you need GPIO 4 for other purposes */
|
#define resetPin 4 /* <-- comment out or change if you need GPIO 4 for other purposes */
|
||||||
//#define USE_DISPLAY /* <-- uncomment that if you want to use the display */
|
#define USE_DISPLAY /* <-- uncomment that if you want to use the display */
|
||||||
|
|
||||||
#ifdef USE_DISPLAY
|
#ifdef USE_DISPLAY
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
@@ -21,10 +21,14 @@
|
|||||||
#include "SSD1306.h"
|
#include "SSD1306.h"
|
||||||
//#include "SH1106.h"
|
//#include "SH1106.h"
|
||||||
|
|
||||||
|
//create display(Adr, SDA-pin, SCL-pin)
|
||||||
|
SSD1306 display(0x3c, 5, 4); //GPIO 5 = D1, GPIO 4 = D2
|
||||||
|
//SH1106 display(0x3c, 5, 4);
|
||||||
|
|
||||||
//button pins
|
//button pins
|
||||||
#define upBtn D6
|
#define upBtn 12 //GPIO 12 = D6
|
||||||
#define downBtn D7
|
#define downBtn 13 //GPIO 13 = D7
|
||||||
#define selectBtn D5
|
#define selectBtn 14 //GPIO 14 = D5
|
||||||
|
|
||||||
#define buttonDelay 180 //delay in ms
|
#define buttonDelay 180 //delay in ms
|
||||||
|
|
||||||
@@ -32,15 +36,14 @@
|
|||||||
#define fontSize 8
|
#define fontSize 8
|
||||||
#define rowsPerSite 8
|
#define rowsPerSite 8
|
||||||
|
|
||||||
//create display(Adr, SDA-pin, SCL-pin)
|
|
||||||
SSD1306 display(0x3c, D2, D1);
|
|
||||||
//SH1106 display(0x3c, D2, D1);
|
|
||||||
|
|
||||||
int rows = 3;
|
int rows = 3;
|
||||||
int curRow = 0;
|
int curRow = 0;
|
||||||
int sites = 1;
|
int sites = 1;
|
||||||
int curSite = 1;
|
int curSite = 1;
|
||||||
int lrow = 0;
|
int lrow = 0;
|
||||||
|
|
||||||
|
bool canBtnPress = true;
|
||||||
|
int buttonPressed = 0; //0 = UP, 1 = DOWN, 2 = SELECT, 3 = DISPLAY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String wifiMode = "";
|
String wifiMode = "";
|
||||||
@@ -541,27 +544,34 @@ void loop() {
|
|||||||
|
|
||||||
#ifdef USE_DISPLAY
|
#ifdef USE_DISPLAY
|
||||||
|
|
||||||
|
if (digitalRead(upBtn) == LOW || digitalRead(downBtn) == LOW || digitalRead(selectBtn) == LOW){
|
||||||
|
if(canBtnPress){
|
||||||
|
if(digitalRead(upBtn) == LOW) buttonPressed = 0;
|
||||||
|
else if(digitalRead(downBtn) == LOW) buttonPressed = 1;
|
||||||
|
else if(digitalRead(selectBtn) == LOW) buttonPressed = 2;
|
||||||
|
canBtnPress = false;
|
||||||
|
}
|
||||||
|
}else if(!canBtnPress){
|
||||||
|
canBtnPress = true;
|
||||||
|
|
||||||
//go up
|
// ===== UP =====
|
||||||
if (digitalRead(upBtn) == LOW && curRow > 0) {
|
if (buttonPressed == 0 && curRow > 0) {
|
||||||
curRow--;
|
curRow--;
|
||||||
if (lrow - 1 < 0) {
|
if (lrow - 1 < 0) {
|
||||||
lrow = rowsPerSite - 1;
|
lrow = rowsPerSite - 1;
|
||||||
curSite--;
|
curSite--;
|
||||||
} else lrow--;
|
} else lrow--;
|
||||||
delay(buttonDelay);
|
|
||||||
|
|
||||||
// ===== go down =====
|
// ===== DOWN =====
|
||||||
} else if (digitalRead(downBtn) == LOW && curRow < rows - 1) {
|
} else if (buttonPressed == 1 && curRow < rows - 1) {
|
||||||
curRow++;
|
curRow++;
|
||||||
if (lrow + 1 >= rowsPerSite) {
|
if (lrow + 1 >= rowsPerSite) {
|
||||||
lrow = 0;
|
lrow = 0;
|
||||||
curSite++;
|
curSite++;
|
||||||
} else lrow++;
|
} else lrow++;
|
||||||
delay(buttonDelay);
|
|
||||||
|
|
||||||
// ===== select =====
|
// ===== SELECT =====
|
||||||
} else if (digitalRead(selectBtn) == LOW) {
|
} else if (buttonPressed == 2) {
|
||||||
//WiFi on/off
|
//WiFi on/off
|
||||||
if (curRow == 0) {
|
if (curRow == 0) {
|
||||||
if (wifiMode == "ON") stopWifi();
|
if (wifiMode == "ON") stopWifi();
|
||||||
@@ -583,7 +593,7 @@ void loop() {
|
|||||||
attack.stop(0);
|
attack.stop(0);
|
||||||
apScan.select(curRow - 3);
|
apScan.select(curRow - 3);
|
||||||
}
|
}
|
||||||
delay(buttonDelay);
|
}
|
||||||
}
|
}
|
||||||
drawInterface();
|
drawInterface();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user