Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ClutchplateDude committed Jul 7, 2020
2 parents 5f2201a + 4f507d4 commit ac439a8
Show file tree
Hide file tree
Showing 59 changed files with 2,142 additions and 1,896 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,5 @@ Software/Arduino code/OpenAstroTracker/__vm
test

bin/
Software/Arduino code/HW_724_TEST
Software/Arduino code/sketch_jun08a
12 changes: 4 additions & 8 deletions Software/Arduino code/OpenAstroTracker/DayTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ float DayTime::getTotalSeconds() const {
return 3600.0f * getHours() + (float)getMinutes() * 60.0f + (float)getSeconds();
}

int DayTime::getTime(int& h, int& m, int& s) const {
void DayTime::getTime(int& h, int& m, int& s) const {
h = hours;
m = mins;
s = secs;
Expand Down Expand Up @@ -228,16 +228,12 @@ float DegreeTime::getTotalDegrees() const {

void DegreeTime::checkHours() {
if (hours > 0) {
#ifdef DEBUG_MODE
logv("CheckHours: Degrees is more than 0, clamping");
#endif
LOGV1(DEBUG_GENERAL, "CheckHours: Degrees is more than 0, clamping");
hours = 0;
}
if (hours < -180) {
#ifdef DEBUG_MODE
logv("CheckHours: Degrees is less than -180, clamping");
#endif
hours = -180;
LOGV1(DEBUG_GENERAL, "CheckHours: Degrees is less than -180, clamping");
hours = -180;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Software/Arduino code/OpenAstroTracker/DayTime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DayTime {
float getTotalMinutes() const;
float getTotalSeconds() const;

int getTime(int& h, int& m, int& s) const;
void getTime(int& h, int& m, int& s) const;
void set(int h, int m, int s);
void set(const DayTime& other);

Expand Down
75 changes: 75 additions & 0 deletions Software/Arduino code/OpenAstroTracker/EPROMStore.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include <EEPROM.h>
#include "EPROMStore.hpp"
#include "Utility.hpp"

// The global instance of the platform-independant EEPROM class
EPROMStore *EPROMStore::_eepromStore = NULL;

// Initialize the EEPROM storage in a platform-independent abstraction
void EPROMStore::initialize()
{
LOGV2(DEBUG_VERBOSE, "EEPROM: Initialize. Instance is %s", _eepromStore == NULL ? "NULL" : "VALID");
if (_eepromStore == NULL)
{
LOGV1(DEBUG_VERBOSE, "EEPROM: Creating single instance");
_eepromStore = new EPROMStore();
}
}

// Get the instance of the EEPROM storage
EPROMStore *EPROMStore::Storage()
{
return _eepromStore;
}

#ifdef ESPBOARD

// Construct the EEPROM object for ESP boards, settign aside 32 bytes for storage
EPROMStore::EPROMStore()
{
LOGV1(DEBUG_VERBOSE, "EEPROM[ESP]: Startup with 32 bytes");
EEPROM.begin(32);
}

// Update the given location with the given value
void EPROMStore::update(int location, uint8_t value)
{
LOGV3(DEBUG_VERBOSE, "EEPROM[ESP]: Writing %x to %d", value, location);
EEPROM.write(location, value);
LOGV1(DEBUG_VERBOSE, "EEPROM[ESP]: Committing");
EEPROM.commit();
}

// Read the value at the given location
uint8_t EPROMStore::read(int location)
{
uint8_t value;
value = EEPROM.read(location);
LOGV3(DEBUG_VERBOSE, "EEPROM[ESP]: Read %x from %d", value, location);
return value;
}

#else

// Construct the EEPROM object for non-ESP boards
EPROMStore::EPROMStore()
{
LOGV1(DEBUG_VERBOSE, "EEPROM[UNO]: Startup ");
}

// Update the given location with the given value
void EPROMStore::update(int location, uint8_t value)
{
LOGV3(DEBUG_VERBOSE, "EEPROM[UNO]: Writing %x to %d", value, location);
EEPROM.write(location, value);
}

// Read the value at the given location
uint8_t EPROMStore::read(int location)
{
uint8_t value = EEPROM.read(location);
LOGV3(DEBUG_VERBOSE, "EEPROM[UNO]: Read %x from %d", value, location);
return value;
}

#endif
18 changes: 18 additions & 0 deletions Software/Arduino code/OpenAstroTracker/EPROMStore.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once
#include <Arduino.h>

// Platform independant abstraction of the EEPROM storage capability of the boards.
// This is needed because the ESP boards require two things that the Arduino boards don't:
// 1) It wants to know how many bytes you want to use (at most)
// 2) It wants you to call a commit() function after a write() to actual persist the data.
class EPROMStore {
static EPROMStore *_eepromStore;
public:
EPROMStore();
static void initialize();

void update(int location, uint8_t value);
uint8_t read(int location);
static EPROMStore* Storage();
};

10 changes: 1 addition & 9 deletions Software/Arduino code/OpenAstroTracker/Globals.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
#include "Globals.hpp"
#include <EEPROM.h>

void EEPROMupdate(int loc, byte val)
{
if (EEPROM.read(loc)!=val)
{
EEPROM.write(loc,val);
}
}
#include "Utility.hpp"
156 changes: 96 additions & 60 deletions Software/Arduino code/OpenAstroTracker/Globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <Arduino.h>
#include <WString.h>

void EEPROMupdate(int loc, byte val);

// Set to 1 if you are in the northern hemisphere.
#define NORTHERN_HEMISPHERE 1

Expand All @@ -19,88 +17,126 @@ void EEPROMupdate(int loc, byte val);
// Make some variables in the sketch files available to the C++ code.
extern bool inSerialControl;
extern String version;
extern int PolarisRAHour;
extern int PolarisRAMinute;
extern int PolarisRASecond;
// Comment this out to save some code space
// #define DEBUG_MODE
#ifdef DEBUG_MODE
// #define SEND_PERIODIC_UPDATES
#endif
// Uncomment to run a key diagnostic. No tracker functions are on at all.
// #define LCD_BUTTON_TEST
extern byte PolarisRAHour;
extern byte PolarisRAMinute;
extern byte PolarisRASecond;

// Debugging output control
// Each bit in the debug level specifies a kind of debug to enable.
#define DEBUG_NONE 0x00
#define DEBUG_INFO 0x01
#define DEBUG_SERIAL 0x02
#define DEBUG_WIFI 0x04
#define DEBUG_MOUNT 0x08
#define DEBUG_MOUNT_VERBOSE 0x10
#define DEBUG_GENERAL 0x20
#define DEBUG_MEADE 0x40
#define DEBUG_VERBOSE 0x80
#define DEBUG_ANY 0xFF

// Bit Name Output
// 0 DEBUG_INFO General output, like startup variables and status
// 1 DEBUG_SERIAL Serial commands and replies
// 2 DEBUG_WIFI Wifi related output
// 3 DEBUG_MOUNT Mount processing output
// 4 DEBUG_MOUNT_VERBOSE Verbose mount processing (coordinates, etc)
// 5 DEBUG_GENERAL Other misc. output
// 6 DEBUG_MEADE Meade command handling output

// Set this to specify the amount of debug output OAT should send to the serial port.
// Note that if you use an app to control OAT, ANY debug output will likely confuse that app.
// Debug output is useful if you are using Wifi to control the OAT or if you are issuing
// manual commands via a terminal.
//
// #define DEBUG_LEVEL (DEBUG_SERIAL|DEBUG_WIFI|DEBUG_INFO|DEBUG_MOUNT|DEBUG_GENERAL)
// #define DEBUG_LEVEL (DEBUG_ANY)
// #define DEBUG_LEVEL (DEBUG_INFO|DEBUG_MOUNT|DEBUG_GENERAL)
#define DEBUG_LEVEL (DEBUG_NONE)

// Uncomment to reverse the direction of RA motor
// #define INVERT_RA_DIR
// Set this to 1 to run a key diagnostic. No tracker functions are on at all.
#define LCD_BUTTON_TEST 0

// Uncomment to reverse the direction of DEC motor
// #define INVERT_DEC_DIR
// Set to 1 to reverse the direction of RA motor
#define INVERT_RA_DIR 0

////////////////////////////////////////////////////////////////
//
// FEATURE SUPPORT SECTION
//
// Since the Arduino Uno has very little memory (32KB code, 2KB data) all features
// stretch the Uno a little too far. So in order to save memory we allow you to enable
// and disable features to help manage memory usage.
// If you run the tracker with an Arduino Mega, you can uncomment all the features.
//
// If you would like to drive your OAT mount with only the LCD Shield,
// you should comment out SUPPORT_SERIAL_CONTROL
//
// If you feel comfortable with configuring the OAT at startup manually, you should comment
// out SUPPORT_GUIDED_STARTUP (maybe after you've used it for a while you know what to do).
//
// The POI menu can take a little data memory and you may not need it. If not, you can comment
// out SUPPORT_POINTS_OF_INTEREST
//
////////////////////////////////////////////////////////////////
// Set to 1 to reverse the direction of DEC motor
#define INVERT_DEC_DIR 0

// If you do not have a LCD shield on your Arduino Uno, uncomment the line below. This is
// If you do not have a LCD shield on your Arduino Uno, set this to 1 on the line below. This is
// useful if you are always going to run the mount from a laptop anyway.
// #define HEADLESS_CLIENT
#define HEADLESS_CLIENT 0

// This is set to 1 for boards that do not support interrupt timers
#define RUN_STEPPERS_IN_MAIN_LOOP 0

#ifdef ESP8266
#define HEADLESS_CLIENT
#if defined(ESP8266) || defined(ESP32)
#define ESPBOARD
#undef HEADLESS_CLIENT
#define HEADLESS_CLIENT 1
#define WIFI_ENABLED
#define INFRA_SSID "yourSSID"
#define INFRA_WPAKEY "yourWPAKey"
#define INFRA_SSID "YouSSID"
#define INFRA_WPAKEY "YourWPAKey"
#define OAT_WPAKEY "superSecret"
#define HOSTNAME "OATerScope"
// 0 - Infrastructure Only - Connecting to a Router
// 1 - AP Mode Only - Acting as a Router
// 2 - Attempt Infrastructure, Fail over to AP Mode.
#define WIFI_MODE 2
#if defined(ESP8266)
#undef RUN_STEPPERS_IN_MAIN_LOOP
#define RUN_STEPPERS_IN_MAIN_LOOP 1
#endif
#endif


// Uncomment this to enable the heating menu
////////////////////////////////////////////////////////////////
//
// FEATURE SUPPORT SECTION
//
// Since the Arduino Uno has very little memory (32KB code, 2KB data) all features
// stretch the Uno a little too far. So in order to save memory we allow you to enable
// and disable features to help manage memory usage.
// If you run the tracker with an Arduino Mega, you can set all the features to 1.
//
// If you would like to drive your OAT mount with only the LCD Shield, or are on a Uno,
// you should set SUPPORT_SERIAL_CONTROL to 0
//
// If you feel comfortable with configuring the OAT at startup manually, you should set
// SUPPORT_GUIDED_STARTUP to 0 (maybe after you've used it for a while you know what to do).
//
// The POI menu can take a little data memory and you may not need it. If not, you can set
// SUPPORT_POINTS_OF_INTEREST to 0
//
////////////////////////////////////////////////////////////////

// Set this to 1 this to enable the heating menu
// NOTE: Heating is currently not supported!
// #define SUPPORT_HEATING
#define SUPPORT_HEATING 0

#if HEADLESS_CLIENT == 0

#ifndef HEADLESS_CLIENT
// Set this to 1 to support Guided Startup
#define SUPPORT_GUIDED_STARTUP 1

// Uncomment to support Guided Startup
#define SUPPORT_GUIDED_STARTUP
// Set this to 1 to support full GO (was POI) menu.
// If this is set to 0 you still have a GO menu that has Home and Park.
#define SUPPORT_POINTS_OF_INTEREST 1

// Uncomment to support full GO (was POI) menu.
// If this is commented out you still have a GO menu that has Home and Park.
#define SUPPORT_POINTS_OF_INTEREST
// Set this to 1 to support CTRL menu, allowing you to manually slew the mount with the buttons.
#define SUPPORT_MANUAL_CONTROL 1

// Uncomment to support CTRL menu, allowing you to manually slew the mount with the buttons.
#define SUPPORT_MANUAL_CONTROL
// Set this to 1 to support CAL menu, allowing you to calibrate various things
#define SUPPORT_CALIBRATION 1

// Uncomment to support CAL menu, allowing you to calibrate various things
#define SUPPORT_CALIBRATION
// Set this to 1 to support INFO menu that displays various pieces of information about the mount.
#define SUPPORT_INFO_DISPLAY 1

// Uncomment to support INFO menu that displays various pieces of information about the mount.
// #define SUPPORT_INFO_DISPLAY
// Set this to 1 to support Serial Meade LX200 protocol support
#define SUPPORT_SERIAL_CONTROL 1

// Uncomment to support Serial Meade LX200 protocol support
// #define SUPPORT_SERIAL_CONTROL
#else
// If we are making a headleass (no screen, no keyboard) client, always enable Serial.
#define SUPPORT_SERIAL_CONTROL
#endif
#define SUPPORT_SERIAL_CONTROL 1
#endif // HEADLESS_CLIENT

#endif
#endif // _GLOBALS_HPP
Loading

0 comments on commit ac439a8

Please sign in to comment.