mirror of
https://github.com/SpacehuhnTech/esp8266_deauther.git
synced 2025-12-23 15:10:06 +01:00
Renamed LEDController to LED
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
#include "LEDController.h"
|
||||
#include "LED.h"
|
||||
|
||||
LEDController::LEDController() {}
|
||||
LED::LED() {}
|
||||
|
||||
LEDController::~LEDController() {
|
||||
LED::~LED() {
|
||||
if (led) delete led;
|
||||
}
|
||||
|
||||
void LEDController::setup() {
|
||||
void LED::setup() {
|
||||
#ifdef DIGITAL_LED
|
||||
led = new DigitalLED(LED_PIN_R, LED_PIN_G, LED_PIN_B, LED_ANODE);
|
||||
led->setup();
|
||||
@@ -15,14 +15,14 @@ void LEDController::setup() {
|
||||
#endif // ifdef DIGITAL_LED
|
||||
|
||||
#ifdef RGB_LED
|
||||
led = new LEDController::AnalogRGBLED(LED_PIN_R, LED_PIN_G, LED_PIN_B, LED_MODE_BRIGHTNESS, LED_ANODE);
|
||||
led = new LED::AnalogRGBLED(LED_PIN_R, LED_PIN_G, LED_PIN_B, LED_MODE_BRIGHTNESS, LED_ANODE);
|
||||
led->setup();
|
||||
return;
|
||||
|
||||
#endif // ifdef RGB_LED
|
||||
|
||||
#ifdef NEOPIXEL_LED
|
||||
led = new LEDController::NeopixelLED(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, LED_MODE_BRIGHTNESS);
|
||||
led = new LED::NeopixelLED(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, LED_MODE_BRIGHTNESS);
|
||||
led->setup();
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,7 @@ void LEDController::setup() {
|
||||
prntln(L_NOT_CONFIGURED);
|
||||
}
|
||||
|
||||
void LEDController::update() {
|
||||
void LED::update() {
|
||||
if (!tempEnabled || !led) return;
|
||||
|
||||
if (!settings.getLedEnabled() && tempEnabled) tempDisable();
|
||||
@@ -42,11 +42,11 @@ void LEDController::update() {
|
||||
else setMode(LED_MODE::IDLE, false);
|
||||
}
|
||||
|
||||
void LEDController::setMode(uint8_t mode, bool force) {
|
||||
void LED::setMode(uint8_t mode, bool force) {
|
||||
if (!led) return;
|
||||
|
||||
if ((mode != LEDController::mode) || force) {
|
||||
LEDController::mode = mode;
|
||||
if ((mode != LED::mode) || force) {
|
||||
LED::mode = mode;
|
||||
|
||||
switch (mode) {
|
||||
case LED_MODE::OFF:
|
||||
@@ -72,7 +72,7 @@ void LEDController::setMode(uint8_t mode, bool force) {
|
||||
}
|
||||
}
|
||||
|
||||
void LEDController::setColor(uint8_t r, uint8_t g, uint8_t b, bool output) {
|
||||
void LED::setColor(uint8_t r, uint8_t g, uint8_t b, bool output) {
|
||||
// debug output
|
||||
if (output) {
|
||||
char s[30];
|
||||
@@ -83,36 +83,36 @@ void LEDController::setColor(uint8_t r, uint8_t g, uint8_t b, bool output) {
|
||||
led->setColor(r, g, b);
|
||||
}
|
||||
|
||||
void LEDController::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool output) {
|
||||
void LED::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool output) {
|
||||
led->setBrightness(brightness);
|
||||
setColor(r, g, b, output);
|
||||
}
|
||||
|
||||
void LEDController::tempEnable() {
|
||||
void LED::tempEnable() {
|
||||
tempEnabled = true;
|
||||
prntln(L_ENABLED);
|
||||
}
|
||||
|
||||
void LEDController::tempDisable() {
|
||||
void LED::tempDisable() {
|
||||
tempEnabled = false;
|
||||
prntln(L_DISABLED);
|
||||
}
|
||||
|
||||
bool LEDController::getTempEnabled() {
|
||||
bool LED::getTempEnabled() {
|
||||
return tempEnabled;
|
||||
}
|
||||
|
||||
// ===== DigitalLED ===== //
|
||||
LEDController::DigitalLED::DigitalLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, bool anode) {
|
||||
LEDController::DigitalLED::anode = anode;
|
||||
LEDController::DigitalLED::rPin = rPin;
|
||||
LEDController::DigitalLED::gPin = gPin;
|
||||
LEDController::DigitalLED::bPin = bPin;
|
||||
LED::DigitalLED::DigitalLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, bool anode) {
|
||||
LED::DigitalLED::anode = anode;
|
||||
LED::DigitalLED::rPin = rPin;
|
||||
LED::DigitalLED::gPin = gPin;
|
||||
LED::DigitalLED::bPin = bPin;
|
||||
}
|
||||
|
||||
LEDController::DigitalLED::~DigitalLED() {}
|
||||
LED::DigitalLED::~DigitalLED() {}
|
||||
|
||||
void LEDController::DigitalLED::setup() {
|
||||
void LED::DigitalLED::setup() {
|
||||
if (rPin < 255) pinMode(rPin, OUTPUT);
|
||||
|
||||
if (gPin < 255) pinMode(gPin, OUTPUT);
|
||||
@@ -120,7 +120,7 @@ void LEDController::DigitalLED::setup() {
|
||||
if (bPin < 255) pinMode(bPin, OUTPUT);
|
||||
}
|
||||
|
||||
void LEDController::DigitalLED::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
void LED::DigitalLED::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
if (anode) {
|
||||
if (rPin < 255) digitalWrite(rPin, r > 0);
|
||||
|
||||
@@ -136,21 +136,21 @@ void LEDController::DigitalLED::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
}
|
||||
}
|
||||
|
||||
void LEDController::DigitalLED::setBrightness(uint8_t brightness) {}
|
||||
void LED::DigitalLED::setBrightness(uint8_t brightness) {}
|
||||
|
||||
|
||||
// ===== AnalogRGBLED ===== //
|
||||
LEDController::AnalogRGBLED::AnalogRGBLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, uint8_t brightness, bool anode) {
|
||||
LEDController::AnalogRGBLED::anode = anode;
|
||||
LEDController::AnalogRGBLED::rPin = rPin;
|
||||
LEDController::AnalogRGBLED::gPin = gPin;
|
||||
LEDController::AnalogRGBLED::bPin = bPin;
|
||||
LED::AnalogRGBLED::AnalogRGBLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, uint8_t brightness, bool anode) {
|
||||
LED::AnalogRGBLED::anode = anode;
|
||||
LED::AnalogRGBLED::rPin = rPin;
|
||||
LED::AnalogRGBLED::gPin = gPin;
|
||||
LED::AnalogRGBLED::bPin = bPin;
|
||||
setBrightness(brightness);
|
||||
}
|
||||
|
||||
LEDController::AnalogRGBLED::~AnalogRGBLED() {}
|
||||
LED::AnalogRGBLED::~AnalogRGBLED() {}
|
||||
|
||||
void LEDController::AnalogRGBLED::setup() {
|
||||
void LED::AnalogRGBLED::setup() {
|
||||
analogWriteRange(0xff);
|
||||
|
||||
if (rPin < 255) pinMode(rPin, OUTPUT);
|
||||
@@ -160,7 +160,7 @@ void LEDController::AnalogRGBLED::setup() {
|
||||
if (bPin < 255) pinMode(bPin, OUTPUT);
|
||||
}
|
||||
|
||||
void LEDController::AnalogRGBLED::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
void LED::AnalogRGBLED::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
if ((r > 0) && (brightness < 100)) r = r * brightness / 100;
|
||||
|
||||
if ((g > 0) && (brightness < 100)) g = g * brightness / 100;
|
||||
@@ -178,34 +178,34 @@ void LEDController::AnalogRGBLED::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
analogWrite(bPin, b);
|
||||
}
|
||||
|
||||
void LEDController::AnalogRGBLED::setBrightness(uint8_t brightness) {
|
||||
void LED::AnalogRGBLED::setBrightness(uint8_t brightness) {
|
||||
if (brightness > 100) brightness = 100;
|
||||
LEDController::AnalogRGBLED::brightness = brightness;
|
||||
LED::AnalogRGBLED::brightness = brightness;
|
||||
}
|
||||
|
||||
// ===== NeopixelLED ===== //
|
||||
LEDController::NeopixelLED::NeopixelLED(int num, uint8_t dataPin, uint8_t brightness) {
|
||||
LED::NeopixelLED::NeopixelLED(int num, uint8_t dataPin, uint8_t brightness) {
|
||||
strip = new Adafruit_NeoPixel(num, dataPin, LED_NEOPIXEL_MODE);
|
||||
setBrightness(brightness);
|
||||
}
|
||||
|
||||
LEDController::NeopixelLED::~NeopixelLED() {
|
||||
LED::NeopixelLED::~NeopixelLED() {
|
||||
delete strip;
|
||||
}
|
||||
|
||||
void LEDController::NeopixelLED::setup() {
|
||||
void LED::NeopixelLED::setup() {
|
||||
strip->begin();
|
||||
strip->show();
|
||||
}
|
||||
|
||||
void LEDController::NeopixelLED::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
void LED::NeopixelLED::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
int num = strip->numPixels();
|
||||
|
||||
for (uint16_t i = 0; i < num; i++) strip->setPixelColor(i, strip->Color(r, g, b));
|
||||
strip->show();
|
||||
}
|
||||
|
||||
void LEDController::NeopixelLED::setBrightness(uint8_t brightness) {
|
||||
void LED::NeopixelLED::setBrightness(uint8_t brightness) {
|
||||
if (brightness > 100) brightness = 100;
|
||||
strip->setBrightness(brightness);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef LEDController_h
|
||||
#define LEDController_h
|
||||
#ifndef LED_h
|
||||
#define LED_h
|
||||
|
||||
#include "Arduino.h"
|
||||
extern "C" {
|
||||
@@ -18,12 +18,12 @@ extern Attack attack;
|
||||
extern Scan scan;
|
||||
extern Stations stations;
|
||||
|
||||
class LEDController {
|
||||
class LED {
|
||||
public:
|
||||
enum LED_MODE { OFF = 0, SCAN = 1, ATTACK = 2, DEAUTH = 3, IDLE = 4 };
|
||||
|
||||
LEDController();
|
||||
~LEDController();
|
||||
LED();
|
||||
~LED();
|
||||
|
||||
void setup();
|
||||
void update();
|
||||
@@ -102,4 +102,4 @@ class LEDController {
|
||||
StatusLED* led = NULL;
|
||||
};
|
||||
|
||||
#endif // ifndef LEDController_h
|
||||
#endif // ifndef LED_h
|
||||
@@ -16,9 +16,9 @@ extern "C" {
|
||||
#include "Scan.h"
|
||||
#include "Attack.h"
|
||||
#include "DisplayUI.h"
|
||||
#include "LEDController.h"
|
||||
#include "LED.h"
|
||||
|
||||
extern LEDController* led;
|
||||
extern LED* led;
|
||||
extern Settings settings;
|
||||
extern Names names;
|
||||
extern SSIDs ssids;
|
||||
|
||||
@@ -21,10 +21,10 @@ extern "C" {
|
||||
#include "A_config.h"
|
||||
#include "webfiles.h"
|
||||
|
||||
#include "LEDController.h"
|
||||
#include "LED.h"
|
||||
|
||||
// Run-Time Variables //
|
||||
LEDController* led;
|
||||
LED* led;
|
||||
Settings settings;
|
||||
Names names;
|
||||
SSIDs ssids;
|
||||
@@ -106,7 +106,7 @@ void setup() {
|
||||
scan.setup();
|
||||
|
||||
// setup LED
|
||||
led = new LEDController();
|
||||
led = new LED();
|
||||
led->setup();
|
||||
|
||||
// set channel
|
||||
|
||||
Reference in New Issue
Block a user