Skip to content

Commit

Permalink
Merge pull request #10 from Spooks4576/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Spooks4576 authored Aug 8, 2024
2 parents ee04732 + 65bb0de commit 4697362
Show file tree
Hide file tree
Showing 40 changed files with 1,550 additions and 624 deletions.
72 changes: 0 additions & 72 deletions scripts/ScriptConverter_Switch.py

This file was deleted.

Binary file added scripts/ghost_esp.fap
Binary file not shown.
2 changes: 1 addition & 1 deletion src/components/ble_module/ble_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ BLEData BLEModule::GetUniversalAdvertisementData(EBLEPayloadType Type) {
AdvData_Raw[i++] = 0x0F; // Type
AdvData_Raw[i++] = 0x05; // Length
AdvData_Raw[i++] = 0xC1; // Action Flags
const uint8_t types[] = { 0x27, 0x09, 0x02, 0x1e, 0x2b, 0x2d, 0x2f, 0x01, 0x06, 0x20, 0xc0 };
const uint8_t types[] = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 };
AdvData_Raw[i++] = types[rand() % sizeof(types)]; // Action Type
esp_fill_random(&AdvData_Raw[i], 3); // Authentication Tag
i += 3;
Expand Down
105 changes: 105 additions & 0 deletions src/components/display_module/UI/Images/Arrow.c

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions src/components/display_module/UI/Images/Bluetooth.c

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions src/components/display_module/UI/Images/Map.c

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions src/components/display_module/UI/Images/Settings.c

Large diffs are not rendered by default.

135 changes: 0 additions & 135 deletions src/components/display_module/UI/Images/bt.c

This file was deleted.

208 changes: 104 additions & 104 deletions src/components/display_module/UI/Images/led.c

Large diffs are not rendered by default.

202 changes: 101 additions & 101 deletions src/components/display_module/UI/Images/wifi.c

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/components/display_module/display_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ void DisplayModule::RenderMenuType(MenuType Type)
SM->Render();
break;
}
case MenuType::MT_GPSMenu:
{
ViewInterface* SM = new ScrollableMenu("GPSMenu");
SystemManager::getInstance().displayModule->Views.add(SM);
SM->UpdateRotationCallback = SystemManager::getInstance().displayModule->SetTouchRotation;
SM->DestroyCallback = SystemManager::getInstance().displayModule->Destroy;
SM->Render();
break;
}
case MenuType::MT_SettingsMenu:
{
// TODO Make Seperate Menu For this
break;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/components/display_module/display_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
#include "views/interface/view_scrollbar_i.h"
LV_IMG_DECLARE(ui_img_spooky_logo_png);
LV_FONT_DECLARE(ui_font_Font1);
LV_IMG_DECLARE(bt_img);
LV_IMG_DECLARE(Bluetooth_img);
LV_IMG_DECLARE(WiFi_img);
LV_IMG_DECLARE(led_img);
LV_IMG_DECLARE(LED_img);
LV_IMG_DECLARE(Map_img);
LV_IMG_DECLARE(Settings_img);

static lv_display_t * disp;

Expand Down
2 changes: 2 additions & 0 deletions src/components/display_module/views/interface/view_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ enum MenuType
MT_BluetoothMenu,
MT_WifiUtilsMenu,
MT_LEDUtils,
MT_GPSMenu,
MT_SettingsMenu
};

class ViewInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void ScrollableMenu::Render() {
lv_obj_set_style_transform_pivot_x(List, lv_obj_get_width(List) / 2, 0);
lv_obj_set_style_transform_pivot_y(List, lv_obj_get_height(List) / 2, 0);
lv_obj_set_style_transform_angle(List, 900, 0);
lv_obj_clear_flag(List, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_fade_in(status_bar, 300, 0);
lv_obj_fade_in(List, 300, 0);

Expand All @@ -30,9 +31,15 @@ void ScrollableMenu::Render() {
{
addItem("Rainbow LED");
}
else if (ViewID == "GPSMenu")
{
addItem("Street Detector\nWardrive (WiFi)\nWardrive (Bluetooth)");
}

// BackBtn = RenderImageToButton(lv_scr_act(), &Backbutton, 90, 156, 265, 70, 33);
// ConfirmButton = RenderImageToButton(lv_scr_act(), &ConfirmBtn, 90, 12, 265, 70, 33);
BackBtn = RenderImageToButton(lv_obj_get_parent(status_bar), &Arrow, 90, 40, 100, 35, 35);
// ConfirmButton = RenderImageToButton(lv_scr_act(), &Arrow, 0, 12, 285, 70, 33);
// MoveSelectUpBtn = RenderImageToButton(lv_scr_act(), &Arrow, 180, 12, 295, 70, 33);
// MoveSelectDownBtn = RenderImageToButton(lv_scr_act(), &Arrow, -180, 12, 245, 70, 33);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <LinkedList.h>
#include "view_i.h"

LV_IMAGE_DECLARE(Backbutton);
LV_IMAGE_DECLARE(ConfirmBtn);

LV_IMG_DECLARE(Arrow);

class ScrollableMenu : public ViewInterface {
public:
Expand All @@ -25,4 +25,6 @@ class ScrollableMenu : public ViewInterface {
lv_obj_t * List;
lv_obj_t * BackBtn;
lv_obj_t * ConfirmButton;
lv_obj_t * MoveSelectUpBtn;
lv_obj_t* MoveSelectDownBtn;
};
12 changes: 9 additions & 3 deletions src/components/display_module/views/mainmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ void MainMenu::Render()

void MainMenu::CreateGridButtons()
{
for (int i = 0; i < 3; i++)
for (int i = 0; i < 5; i++)
{
lv_obj_t *btn = nullptr;

lv_obj_t *btn_container = lv_obj_create(grid_container);
lv_obj_set_size(btn_container, 70, 70);

switch (i) {
case 0: btn = RenderImageToButton(btn_container, &bt_img, 45, 55, -5, 50, 50); break;
case 0: btn = RenderImageToButton(btn_container, &Bluetooth_img, 45, 55, -5, 50, 50); break;
case 1: btn = RenderImageToButton(btn_container, &WiFi_img, 45, 55, -5, 50, 50); break;
case 2: btn = RenderImageToButton(btn_container, &led_img, 45, 55, -5, 50, 50); break;
case 2: btn = RenderImageToButton(btn_container, &LED_img, 45, 55, -5, 50, 50); break;
case 3: btn = RenderImageToButton(btn_container, &Map_img, 45, 55, -5, 50, 50); break;
case 4: btn = RenderImageToButton(btn_container, &Settings_img, 45, 55, -5, 50, 50); break;
}

if (btn)
Expand Down Expand Up @@ -63,6 +65,8 @@ void MainMenu::CreateGridButtons()
case 0: lv_label_set_text(label, "BLE"); break;
case 1: lv_label_set_text(label, "WiFi"); break;
case 2: lv_label_set_text(label, "LED"); break;
case 3: lv_label_set_text(label, "GPS"); break;
case 4: lv_label_set_text(label, "SET"); break;
}

static lv_style_t label_text_style;
Expand Down Expand Up @@ -141,6 +145,8 @@ void MainMenu::HandleTouch(TS_Point P)
case 0: Destroy(MenuType::MT_BluetoothMenu); break;
case 1: Destroy(MenuType::MT_WifiUtilsMenu); break;
case 2: Destroy(MenuType::MT_LEDUtils); break;
case 3: Destroy(MenuType::MT_GPSMenu); break;
case 4: Destroy(MenuType::MT_SettingsMenu); break;
}
}
}
Expand Down
44 changes: 28 additions & 16 deletions src/components/gps_module/gps_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,15 @@ void gps_module::WarDrivingLoop()

#ifdef HAS_GPS
if (gps.location.isValid() && gps.location.isUpdated()) {
String streetName = findClosestStreet(gps.location.lat(), gps.location.lng());
Serial.println(streetName);

String streetName = "";

if (SystemManager::getInstance().sdCardModule.Initlized)
{
streetName = findClosestStreet(gps.location.lat(), gps.location.lng());
}


int Networks = WiFi.scanNetworks();

for (int i = 0; i < Networks; i++)
Expand All @@ -122,11 +129,24 @@ void gps_module::WarDrivingLoop()

String Message = G_Utils::formatString("%s, %s, %s, %s, %i, %i, %f, %f, %f, %f", BSSID.c_str(), SSID.c_str(), SecurityType.c_str(), GetDateAndTime().c_str(), Channel, RSSI, gps.location.lat(), gps.location.lng(), gps.altitude.meters(), 2.5 * gps.hdop.hdop() / 10);
String MessageWithStreet = G_Utils::formatString("%s, %s, %s, %s, %i, %i, %f, %f, %f, %f, %s", BSSID.c_str(), SSID.c_str(), SecurityType.c_str(), GetDateAndTime().c_str(), Channel, RSSI, gps.location.lat(), gps.location.lng(), gps.altitude.meters(), 2.5 * gps.hdop.hdop() / 10, streetName.c_str());
LOG_RESULTS("wardiving.csv", "gps", Message);
LOG_RESULTS("wardiving_withstreets.csv", "gps", MessageWithStreet);
Serial.println("Logged Info At " + streetName);

LOG_RESULTS("wardiving.csv", "gps", Message.c_str());
if (SystemManager::getInstance().sdCardModule.Initlized)
{
LOG_RESULTS("wardiving_withstreets.csv", "gps", MessageWithStreet.c_str());
}

if (SystemManager::getInstance().sdCardModule.Initlized)
{
Serial.println("Logged Info At " + streetName);
}
else
{
Serial.println("Logged WiFi " + SSID);
}
}
uint8_t set_channel = random(1, 13);
CurrentChannel = CurrentChannel + 1 % 13;
uint8_t set_channel = CurrentChannel;
esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
} else {
Serial.println("GPS signal not found");
Expand Down Expand Up @@ -167,7 +187,7 @@ void gps_module::streetloop()
Serial.print("Altitude: "); Serial.println(gps.altitude.kilometers());
Serial.print("Speed: "); Serial.println(gps.speed.kmph());
Serial.println(streetName);
LOG_RESULTS("streets.txt", "gps", "Visited " + streetName);
LOG_RESULTS("streets.txt", "gps", String(streetName + " Visited").c_str());
} else {
Serial.println("GPS signal not found");
}
Expand All @@ -180,8 +200,7 @@ void gps_module::streetloop()

void gps_module::setup(bool EnableBLEScans)
{
if (SystemManager::getInstance().sdCardModule.Initlized)
{

#ifdef HAS_GPS
Serial1.begin(9600, SERIAL_8N1, GPS_TX, GPS_RX);
#endif
Expand All @@ -192,11 +211,4 @@ void gps_module::setup(bool EnableBLEScans)
SystemManager::getInstance().bleModule->InitWarDriveCallback();
#endif
Serial.println("Initilized GPS Serial");
}
else
{
Initilized = false;
Stop = true;
Serial.println("Failed to Initilize GPS Serial Possible SD Card Init Failure");
}
}
1 change: 1 addition & 0 deletions src/components/gps_module/gps_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class gps_module
#endif
File MapData;
bool Initilized;
uint8_t CurrentChannel;
bool Stop;
unsigned long lastUpdate = 0;
long updateInterval = 1000;
Expand Down
51 changes: 27 additions & 24 deletions src/components/rgb_led_module/rgb_led_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,49 @@ void RGBLedModule::init() {
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
Rainbow(1, 4);
breatheLED(redPin, 400, true);
fadeOutAllPins(400);
}

void RGBLedModule::breatheLED(int ledPin, int breatheTime, bool FadeOut)
{
int fadeAmount = 5; // Amount of brightness change per step, adjust for different breathing speeds
int wait = breatheTime / (255 / fadeAmount * 2); // Calculate wait time to fit the breathe cycle into the given total time
int wait = breatheTime / ((255 / fadeAmount) * 2); // Calculate wait time to fit the breathe cycle into the given total time

if (FadeOut)
{
// Fade out
for (int brightness = 0; brightness <= 255; brightness += fadeAmount) {
analogWrite(redPin, brightness);
analogWrite(greenPin, brightness);
analogWrite(bluePin, brightness);
// Fade out (brightness increases for inverted logic)
for (int brightness = 0; brightness <= 255; brightness += fadeAmount) {
analogWrite(ledPin, brightness);
delay(wait);
}
return;
}
else
{
// Fade in (brightness decreases for inverted logic)
for (int brightness = 255; brightness >= 0; brightness -= fadeAmount) {
analogWrite(ledPin, brightness);
delay(wait);
}

// Fade in
for (int brightness = 255; brightness >= 0; brightness -= fadeAmount) {
analogWrite(ledPin, brightness);
delay(wait);
// Fade out (brightness increases for inverted logic)
for (int brightness = 0; brightness <= 255; brightness += fadeAmount) {
analogWrite(ledPin, brightness);
delay(wait);
}
}
}

// Fade out
for (int brightness = 0; brightness <= 255; brightness += fadeAmount) {
analogWrite(ledPin, brightness);
delay(wait);
}
// Fade in
for (int brightness = 255; brightness >= 0; brightness -= fadeAmount) {
analogWrite(ledPin, brightness);
delay(wait);
}

// Fade out
void RGBLedModule::fadeOutAllPins(int fadeTime)
{
int fadeAmount = 5; // Amount of brightness change per step, adjust for different fading speeds
int wait = fadeTime / (255 / fadeAmount); // Calculate wait time to fit the fade cycle into the given total time

// Fade out all pins (brightness increases for inverted logic)
for (int brightness = 0; brightness <= 255; brightness += fadeAmount) {
analogWrite(ledPin, brightness);
analogWrite(redPin, brightness);
analogWrite(greenPin, brightness);
analogWrite(bluePin, brightness);
delay(wait);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/components/rgb_led_module/rgb_led_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class RGBLedModule {
void setColor(int red, int green, int blue); // Set the RGB color
void Rainbow(int strength, int stepDelay);
void breatheLED(int ledPin, int breatheTime, bool FadeIn = false);
void fadeOutAllPins(int fadeTime);
void Song();
public:
uint8_t redPin, greenPin, bluePin;
Expand Down
Loading

0 comments on commit 4697362

Please sign in to comment.