mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-12 15:50:36 -08:00
Add Neopixel support
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
|
||||
#include <TFT_eSPI.h>
|
||||
|
||||
#define TFT_SHIELD
|
||||
//#define TFT_DIY
|
||||
//#define TFT_SHIELD
|
||||
#define TFT_DIY
|
||||
|
||||
#define SCREEN_WIDTH 240
|
||||
#define SCREEN_HEIGHT 320
|
||||
@@ -56,7 +56,7 @@ class Display
|
||||
TFT_eSPI tft = TFT_eSPI();
|
||||
TFT_eSprite img = TFT_eSprite(&tft);
|
||||
TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
|
||||
String version_number = "v0.6.3";
|
||||
String version_number = "v0.6.4";
|
||||
|
||||
bool printing = false;
|
||||
bool loading = false;
|
||||
|
||||
41
esp32_marauder/LedInterface.cpp
Normal file
41
esp32_marauder/LedInterface.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "LedInterface.h"
|
||||
|
||||
LedInterface::LedInterface() {
|
||||
|
||||
}
|
||||
|
||||
void LedInterface::RunSetup() {
|
||||
Serial.println("Setting neopixel to black...");
|
||||
strip.begin();
|
||||
strip.setBrightness(50);
|
||||
strip.setPixelColor(0, strip.Color(0, 0, 0));
|
||||
strip.show();
|
||||
delay(100);
|
||||
strip.setPixelColor(0, strip.Color(255, 0, 0));
|
||||
strip.show();
|
||||
this->initTime = millis();
|
||||
}
|
||||
|
||||
void LedInterface::main(uint32_t currentTime) {
|
||||
strip.setPixelColor(0, this->Wheel((0 * 256 / 100 + this->wheel_pos) % 256));
|
||||
strip.show();
|
||||
|
||||
this->current_fade_itter++;
|
||||
|
||||
this->wheel_pos = this->wheel_pos - this->wheel_speed;
|
||||
if (this->wheel_pos < 0)
|
||||
this->wheel_pos = 255;
|
||||
};
|
||||
|
||||
uint32_t LedInterface::Wheel(byte WheelPos) {
|
||||
WheelPos = 255 - WheelPos;
|
||||
if(WheelPos < 85) {
|
||||
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
|
||||
}
|
||||
if(WheelPos < 170) {
|
||||
WheelPos -= 85;
|
||||
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
|
||||
}
|
||||
WheelPos -= 170;
|
||||
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
|
||||
}
|
||||
31
esp32_marauder/LedInterface.h
Normal file
31
esp32_marauder/LedInterface.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef LedInterface_h
|
||||
#define LedInterface_h
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
#define PIN 25
|
||||
#define Pixels 1
|
||||
|
||||
extern Adafruit_NeoPixel strip;
|
||||
|
||||
class LedInterface {
|
||||
|
||||
private:
|
||||
uint32_t initTime = 0;
|
||||
|
||||
int current_fade_itter = 1;
|
||||
int wheel_pos = 255;
|
||||
int wheel_speed = 1; // lower = slower
|
||||
|
||||
uint32_t Wheel(byte WheelPos);
|
||||
|
||||
public:
|
||||
LedInterface();
|
||||
|
||||
void RunSetup();
|
||||
void main(uint32_t currentTime);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -25,6 +25,7 @@ https://www.online-utility.org/image/convert/to/XBM
|
||||
#include "Buffer.h"
|
||||
#include "BatteryInterface.h"
|
||||
#include "TemperatureInterface.h"
|
||||
#include "LedInterface.h"
|
||||
//#include "icons.h"
|
||||
|
||||
/*
|
||||
@@ -46,6 +47,9 @@ Web web_obj;
|
||||
Buffer buffer_obj;
|
||||
BatteryInterface battery_obj;
|
||||
TemperatureInterface temp_obj;
|
||||
LedInterface led_obj;
|
||||
|
||||
Adafruit_NeoPixel strip = Adafruit_NeoPixel(Pixels, PIN, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
uint32_t currentTime = 0;
|
||||
|
||||
@@ -71,6 +75,9 @@ void setup()
|
||||
|
||||
//Serial.println("Internal Temp: " + (String)((temprature_sens_read() - 32) / 1.8));
|
||||
|
||||
// Do some LED stuff
|
||||
led_obj.RunSetup();
|
||||
|
||||
// Do some SD stuff
|
||||
if(sd_obj.initSD())
|
||||
Serial.println("SD Card supported");
|
||||
@@ -96,6 +103,8 @@ void setup()
|
||||
}
|
||||
else
|
||||
Serial.println("IP5306 I2C Supported: false");
|
||||
|
||||
Serial.println(wifi_scan_obj.freeRAM());
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +124,7 @@ void loop()
|
||||
sd_obj.main();
|
||||
battery_obj.main(currentTime);
|
||||
temp_obj.main(currentTime);
|
||||
//led_obj.main(currentTime);
|
||||
//if ((wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM))
|
||||
if ((wifi_scan_obj.currentScanMode != WIFI_PACKET_MONITOR) &&
|
||||
(wifi_scan_obj.currentScanMode != WIFI_SCAN_EAPOL))
|
||||
|
||||
Reference in New Issue
Block a user