Skip to content

Commit

Permalink
Merge pull request #37 from Sylensky/feature/project-configuration
Browse files Browse the repository at this point in the history
move static defines to config.h
  • Loading branch information
Th0MmyS authored Jan 29, 2025
2 parents a4389a7 + e04828f commit 725068d
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 20 deletions.
1 change: 1 addition & 0 deletions esp32_wireless_control/firmware/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
compile_commands.json
4 changes: 2 additions & 2 deletions esp32_wireless_control/firmware/axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Axis::Axis(uint8_t axis, uint8_t dirPinforAxis, bool invertDirPin) : stepTimer(4
trackingDirection = c_DIRECTION;
dirPin = dirPinforAxis;
invertDirectionPin = invertDirPin;
trackingRate = TRACKING_SIDEREAL;
trackingRate = TRACKING_RATE;
switch (axisNumber)
{
case 1:
Expand All @@ -63,7 +63,7 @@ Axis::Axis(uint8_t axis, uint8_t dirPinforAxis, bool invertDirPin) : stepTimer(4

if (DEFAULT_ENABLE_TRACKING == 1 && axisNumber == 1)
{
startTracking(TRACKING_SIDEREAL, trackingDirection);
startTracking(trackingRate, trackingDirection);
}
}

Expand Down
34 changes: 33 additions & 1 deletion esp32_wireless_control/firmware/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,42 @@
#define DEC_INVERT_DIR_PIN 0 // if need to invert direction pin set to 1
#define DEFAULT_ENABLE_TRACKING 0 // set to 1 to enable tracking at startup
#define DITHER_DISTANCE_X10_PIXELS 5 // set max distance to dither in multiple of 10 pixels
#define MAX_CUSTOM_SLEW_RATE 400 // Set max custom slew rate to X tracking rate
#define MAX_CUSTOM_SLEW_RATE 400 // Set max custom slew rate to X tracking rate
#define MIN_CUSTOM_SLEW_RATE 2 // Set min custom slew rate to X tracking rate
#define STEPPER_0_9 // uncomment this line if you have a 0.9 degree NEMA17
// #define STEPPER_1_8 //uncomment this line if you have a 1.8 degree NEMA17, and comment the
// above line

#ifndef TRACKING_RATE
// Available tracking rates:
// TRACKING_SIDEREAL
// TRACKING_SOLAR
// TRACKING_LUNAR
#define TRACKING_RATE TRACKING_SIDEREAL // default tracking rate
#endif

// Configure the wifi settings if you are not using platformio
#ifndef WIFI_SSID
#define WIFI_SSID "OG Star Tracker" // change to your SSID
#endif
#ifndef WIFI_PASS
#define WIFI_PASS "password123" // change to your password, must be 8+ characters
#endif
// If you are using AP mode, you can access the website using the below URL
#ifndef WEBSITE_NAME
#define WEBSITE_NAME "www.tracker.com"
#endif
#ifndef DNS_PORT
#define DNS_PORT 53
#endif
#ifndef WEBSERVER_PORT
#define WEBSERVER_PORT 80
#endif

// try to update every time there is breaking change
#ifndef INTERNAL_VERSION
#define INTERNAL_VERSION 7
#endif
/**********************/

/*****DO NOT MODIFY BELOW*****/
Expand Down
21 changes: 5 additions & 16 deletions esp32_wireless_control/firmware/firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,9 @@
#include "web_languages.h"
#include "website_strings.h"

// try to update every time there is breaking change
const int firmware_version = 7;

// Set your Wi-Fi credentials
const byte DNS_PORT = 53;
const char* ssid = "OG Star Tracker"; // change to your SSID
const char* password = "password123"; // change to your password, must be 8+ characters
// If you are using AP mode, you can access the website using the below URL
const String website_name = "www.tracker.com";
#define MIN_CUSTOM_SLEW_RATE 2

unsigned long blink_millis = 0;

WebServer server(80);
WebServer server(WEBSERVER_PORT);
DNSServer dnsServer;
Languages language = EN;

Expand Down Expand Up @@ -263,7 +252,7 @@ void handleStatusRequest()

void handleVersion()
{
server.send(200, MIME_TYPE_TEXT, (String) firmware_version);
server.send(200, MIME_TYPE_TEXT, (String) INTERNAL_VERSION);
}

void setup()
Expand All @@ -283,7 +272,7 @@ void setup()
intervalometer.readPresetsFromEEPROM();
#ifdef AP
WiFi.mode(WIFI_MODE_AP);
WiFi.softAP(ssid, password);
WiFi.softAP(WIFI_SSID, WIFI_PASSWORD);
delay(500);
Serial.println("Creating Wifi Network");

Expand All @@ -304,7 +293,7 @@ void setup()
// ANDROID 10 WORKAROUND==================================================
#else
WiFi.mode(WIFI_MODE_STA); // Set ESP32 in station mode
WiFi.begin(ssid, password);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.println("Connecting to Network in STA mode");
while (WiFi.status() != WL_CONNECTED)
{
Expand All @@ -314,7 +303,7 @@ void setup()
#endif
dnsServer.setTTL(300);
dnsServer.setErrorReplyCode(DNSReplyCode::ServerFailure);
dnsServer.start(DNS_PORT, website_name, WiFi.softAPIP());
dnsServer.start(DNS_PORT, WEBSITE_NAME, WiFi.softAPIP());

server.on("/", HTTP_GET, handleRoot);
server.on("/on", HTTP_GET, handleOn);
Expand Down
12 changes: 11 additions & 1 deletion esp32_wireless_control/firmware/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@ custom_debug_port = \\.\COM5

[env:ogstartracker_release]
build_type = release
extra_scripts = pre:shared/versioning.py
extra_scripts =
pre:shared/versioning.py
post:shared/generate_compiledb.py
monitor_speed = 115200
build_flags =
-D BINARY_NAME=${ogstartracker.custom_binary_name}
-D VERSION=${ogstartracker.custom_version}
-D DEBUG=0
-D BUILD_VERSION=\"${ogstartracker.custom_version}\"
-D INTERNAL_VERSION=7
-D WIFI_SSID='"OG Star Tracker"'
-D WIFI_PASSWORD='"password123"'
-D WEBSITE_NAME='"www.tracker.com"'
-D DNS_PORT=53
-D WEBSERVER_PORT=80
-D AP_MODE=1
-D TRACKING_RATE=TRACKING_SIDEREAL
-Wall -Wextra -Os
6 changes: 6 additions & 0 deletions esp32_wireless_control/firmware/shared/generate_compiledb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Import("env")

def generate_compiledb(env, *args, **kwargs):
env.Execute(f"pio run -e {env['PIOENV']} -t compiledb")

env.AddPreAction("buildprog", generate_compiledb)

0 comments on commit 725068d

Please sign in to comment.