Skip to content

Commit ac439a8

Browse files
Merge branch 'develop'
2 parents 5f2201a + 4f507d4 commit ac439a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2142
-1896
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,5 @@ Software/Arduino code/OpenAstroTracker/__vm
366366
test
367367

368368
bin/
369+
Software/Arduino code/HW_724_TEST
370+
Software/Arduino code/sketch_jun08a

Software/Arduino code/OpenAstroTracker/DayTime.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ float DayTime::getTotalSeconds() const {
6767
return 3600.0f * getHours() + (float)getMinutes() * 60.0f + (float)getSeconds();
6868
}
6969

70-
int DayTime::getTime(int& h, int& m, int& s) const {
70+
void DayTime::getTime(int& h, int& m, int& s) const {
7171
h = hours;
7272
m = mins;
7373
s = secs;
@@ -228,16 +228,12 @@ float DegreeTime::getTotalDegrees() const {
228228

229229
void DegreeTime::checkHours() {
230230
if (hours > 0) {
231-
#ifdef DEBUG_MODE
232-
logv("CheckHours: Degrees is more than 0, clamping");
233-
#endif
231+
LOGV1(DEBUG_GENERAL, "CheckHours: Degrees is more than 0, clamping");
234232
hours = 0;
235233
}
236234
if (hours < -180) {
237-
#ifdef DEBUG_MODE
238-
logv("CheckHours: Degrees is less than -180, clamping");
239-
#endif
240-
hours = -180;
235+
LOGV1(DEBUG_GENERAL, "CheckHours: Degrees is less than -180, clamping");
236+
hours = -180;
241237
}
242238
}
243239

Software/Arduino code/OpenAstroTracker/DayTime.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DayTime {
3333
float getTotalMinutes() const;
3434
float getTotalSeconds() const;
3535

36-
int getTime(int& h, int& m, int& s) const;
36+
void getTime(int& h, int& m, int& s) const;
3737
void set(int h, int m, int s);
3838
void set(const DayTime& other);
3939

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include <EEPROM.h>
2+
#include "EPROMStore.hpp"
3+
#include "Utility.hpp"
4+
5+
// The global instance of the platform-independant EEPROM class
6+
EPROMStore *EPROMStore::_eepromStore = NULL;
7+
8+
// Initialize the EEPROM storage in a platform-independent abstraction
9+
void EPROMStore::initialize()
10+
{
11+
LOGV2(DEBUG_VERBOSE, "EEPROM: Initialize. Instance is %s", _eepromStore == NULL ? "NULL" : "VALID");
12+
if (_eepromStore == NULL)
13+
{
14+
LOGV1(DEBUG_VERBOSE, "EEPROM: Creating single instance");
15+
_eepromStore = new EPROMStore();
16+
}
17+
}
18+
19+
// Get the instance of the EEPROM storage
20+
EPROMStore *EPROMStore::Storage()
21+
{
22+
return _eepromStore;
23+
}
24+
25+
#ifdef ESPBOARD
26+
27+
// Construct the EEPROM object for ESP boards, settign aside 32 bytes for storage
28+
EPROMStore::EPROMStore()
29+
{
30+
LOGV1(DEBUG_VERBOSE, "EEPROM[ESP]: Startup with 32 bytes");
31+
EEPROM.begin(32);
32+
}
33+
34+
// Update the given location with the given value
35+
void EPROMStore::update(int location, uint8_t value)
36+
{
37+
LOGV3(DEBUG_VERBOSE, "EEPROM[ESP]: Writing %x to %d", value, location);
38+
EEPROM.write(location, value);
39+
LOGV1(DEBUG_VERBOSE, "EEPROM[ESP]: Committing");
40+
EEPROM.commit();
41+
}
42+
43+
// Read the value at the given location
44+
uint8_t EPROMStore::read(int location)
45+
{
46+
uint8_t value;
47+
value = EEPROM.read(location);
48+
LOGV3(DEBUG_VERBOSE, "EEPROM[ESP]: Read %x from %d", value, location);
49+
return value;
50+
}
51+
52+
#else
53+
54+
// Construct the EEPROM object for non-ESP boards
55+
EPROMStore::EPROMStore()
56+
{
57+
LOGV1(DEBUG_VERBOSE, "EEPROM[UNO]: Startup ");
58+
}
59+
60+
// Update the given location with the given value
61+
void EPROMStore::update(int location, uint8_t value)
62+
{
63+
LOGV3(DEBUG_VERBOSE, "EEPROM[UNO]: Writing %x to %d", value, location);
64+
EEPROM.write(location, value);
65+
}
66+
67+
// Read the value at the given location
68+
uint8_t EPROMStore::read(int location)
69+
{
70+
uint8_t value = EEPROM.read(location);
71+
LOGV3(DEBUG_VERBOSE, "EEPROM[UNO]: Read %x from %d", value, location);
72+
return value;
73+
}
74+
75+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
#include <Arduino.h>
3+
4+
// Platform independant abstraction of the EEPROM storage capability of the boards.
5+
// This is needed because the ESP boards require two things that the Arduino boards don't:
6+
// 1) It wants to know how many bytes you want to use (at most)
7+
// 2) It wants you to call a commit() function after a write() to actual persist the data.
8+
class EPROMStore {
9+
static EPROMStore *_eepromStore;
10+
public:
11+
EPROMStore();
12+
static void initialize();
13+
14+
void update(int location, uint8_t value);
15+
uint8_t read(int location);
16+
static EPROMStore* Storage();
17+
};
18+
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
11
#include "Globals.hpp"
2-
#include <EEPROM.h>
3-
4-
void EEPROMupdate(int loc, byte val)
5-
{
6-
if (EEPROM.read(loc)!=val)
7-
{
8-
EEPROM.write(loc,val);
9-
}
10-
}
2+
#include "Utility.hpp"

Software/Arduino code/OpenAstroTracker/Globals.hpp

Lines changed: 96 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#include <Arduino.h>
55
#include <WString.h>
66

7-
void EEPROMupdate(int loc, byte val);
8-
97
// Set to 1 if you are in the northern hemisphere.
108
#define NORTHERN_HEMISPHERE 1
119

@@ -19,88 +17,126 @@ void EEPROMupdate(int loc, byte val);
1917
// Make some variables in the sketch files available to the C++ code.
2018
extern bool inSerialControl;
2119
extern String version;
22-
extern int PolarisRAHour;
23-
extern int PolarisRAMinute;
24-
extern int PolarisRASecond;
25-
// Comment this out to save some code space
26-
// #define DEBUG_MODE
27-
#ifdef DEBUG_MODE
28-
// #define SEND_PERIODIC_UPDATES
29-
#endif
30-
// Uncomment to run a key diagnostic. No tracker functions are on at all.
31-
// #define LCD_BUTTON_TEST
20+
extern byte PolarisRAHour;
21+
extern byte PolarisRAMinute;
22+
extern byte PolarisRASecond;
23+
24+
// Debugging output control
25+
// Each bit in the debug level specifies a kind of debug to enable.
26+
#define DEBUG_NONE 0x00
27+
#define DEBUG_INFO 0x01
28+
#define DEBUG_SERIAL 0x02
29+
#define DEBUG_WIFI 0x04
30+
#define DEBUG_MOUNT 0x08
31+
#define DEBUG_MOUNT_VERBOSE 0x10
32+
#define DEBUG_GENERAL 0x20
33+
#define DEBUG_MEADE 0x40
34+
#define DEBUG_VERBOSE 0x80
35+
#define DEBUG_ANY 0xFF
36+
37+
// Bit Name Output
38+
// 0 DEBUG_INFO General output, like startup variables and status
39+
// 1 DEBUG_SERIAL Serial commands and replies
40+
// 2 DEBUG_WIFI Wifi related output
41+
// 3 DEBUG_MOUNT Mount processing output
42+
// 4 DEBUG_MOUNT_VERBOSE Verbose mount processing (coordinates, etc)
43+
// 5 DEBUG_GENERAL Other misc. output
44+
// 6 DEBUG_MEADE Meade command handling output
45+
46+
// Set this to specify the amount of debug output OAT should send to the serial port.
47+
// Note that if you use an app to control OAT, ANY debug output will likely confuse that app.
48+
// Debug output is useful if you are using Wifi to control the OAT or if you are issuing
49+
// manual commands via a terminal.
50+
//
51+
// #define DEBUG_LEVEL (DEBUG_SERIAL|DEBUG_WIFI|DEBUG_INFO|DEBUG_MOUNT|DEBUG_GENERAL)
52+
// #define DEBUG_LEVEL (DEBUG_ANY)
53+
// #define DEBUG_LEVEL (DEBUG_INFO|DEBUG_MOUNT|DEBUG_GENERAL)
54+
#define DEBUG_LEVEL (DEBUG_NONE)
3255

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

36-
// Uncomment to reverse the direction of DEC motor
37-
// #define INVERT_DEC_DIR
59+
// Set to 1 to reverse the direction of RA motor
60+
#define INVERT_RA_DIR 0
3861

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

59-
// If you do not have a LCD shield on your Arduino Uno, uncomment the line below. This is
65+
// If you do not have a LCD shield on your Arduino Uno, set this to 1 on the line below. This is
6066
// useful if you are always going to run the mount from a laptop anyway.
61-
// #define HEADLESS_CLIENT
67+
#define HEADLESS_CLIENT 0
68+
69+
// This is set to 1 for boards that do not support interrupt timers
70+
#define RUN_STEPPERS_IN_MAIN_LOOP 0
6271

63-
#ifdef ESP8266
64-
#define HEADLESS_CLIENT
72+
#if defined(ESP8266) || defined(ESP32)
73+
#define ESPBOARD
74+
#undef HEADLESS_CLIENT
75+
#define HEADLESS_CLIENT 1
6576
#define WIFI_ENABLED
66-
#define INFRA_SSID "yourSSID"
67-
#define INFRA_WPAKEY "yourWPAKey"
77+
#define INFRA_SSID "YouSSID"
78+
#define INFRA_WPAKEY "YourWPAKey"
6879
#define OAT_WPAKEY "superSecret"
6980
#define HOSTNAME "OATerScope"
7081
// 0 - Infrastructure Only - Connecting to a Router
7182
// 1 - AP Mode Only - Acting as a Router
7283
// 2 - Attempt Infrastructure, Fail over to AP Mode.
7384
#define WIFI_MODE 2
85+
#if defined(ESP8266)
86+
#undef RUN_STEPPERS_IN_MAIN_LOOP
87+
#define RUN_STEPPERS_IN_MAIN_LOOP 1
88+
#endif
7489
#endif
7590

7691

77-
// Uncomment this to enable the heating menu
92+
////////////////////////////////////////////////////////////////
93+
//
94+
// FEATURE SUPPORT SECTION
95+
//
96+
// Since the Arduino Uno has very little memory (32KB code, 2KB data) all features
97+
// stretch the Uno a little too far. So in order to save memory we allow you to enable
98+
// and disable features to help manage memory usage.
99+
// If you run the tracker with an Arduino Mega, you can set all the features to 1.
100+
//
101+
// If you would like to drive your OAT mount with only the LCD Shield, or are on a Uno,
102+
// you should set SUPPORT_SERIAL_CONTROL to 0
103+
//
104+
// If you feel comfortable with configuring the OAT at startup manually, you should set
105+
// SUPPORT_GUIDED_STARTUP to 0 (maybe after you've used it for a while you know what to do).
106+
//
107+
// The POI menu can take a little data memory and you may not need it. If not, you can set
108+
// SUPPORT_POINTS_OF_INTEREST to 0
109+
//
110+
////////////////////////////////////////////////////////////////
111+
112+
// Set this to 1 this to enable the heating menu
78113
// NOTE: Heating is currently not supported!
79-
// #define SUPPORT_HEATING
114+
#define SUPPORT_HEATING 0
115+
116+
#if HEADLESS_CLIENT == 0
80117

81-
#ifndef HEADLESS_CLIENT
118+
// Set this to 1 to support Guided Startup
119+
#define SUPPORT_GUIDED_STARTUP 1
82120

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

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

90-
// Uncomment to support CTRL menu, allowing you to manually slew the mount with the buttons.
91-
#define SUPPORT_MANUAL_CONTROL
128+
// Set this to 1 to support CAL menu, allowing you to calibrate various things
129+
#define SUPPORT_CALIBRATION 1
92130

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

96-
// Uncomment to support INFO menu that displays various pieces of information about the mount.
97-
// #define SUPPORT_INFO_DISPLAY
134+
// Set this to 1 to support Serial Meade LX200 protocol support
135+
#define SUPPORT_SERIAL_CONTROL 1
98136

99-
// Uncomment to support Serial Meade LX200 protocol support
100-
// #define SUPPORT_SERIAL_CONTROL
101137
#else
102138
// If we are making a headleass (no screen, no keyboard) client, always enable Serial.
103-
#define SUPPORT_SERIAL_CONTROL
104-
#endif
139+
#define SUPPORT_SERIAL_CONTROL 1
140+
#endif // HEADLESS_CLIENT
105141

106-
#endif
142+
#endif // _GLOBALS_HPP

0 commit comments

Comments
 (0)