2.0.2015090401

Breaking out portions of ino file into .h files...
        #include "rotator_clock_and_gps.h"
        #include "rotator_command_processing.h"
        #include "rotator_moon_and_sun.h"
        #include "rotator_ethernet.h"
        #include "rotator_stepper.h"
This commit is contained in:
Anthony Good 2015-09-04 22:06:17 -04:00
parent 077ae82ddb
commit f0fa78eb14
21 changed files with 4268 additions and 3171 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#include <LSM303.h>
#include "LSM303.h"
#include <Wire.h>
#include <math.h>
@ -567,4 +567,4 @@ int LSM303::testReg(byte address, regAddr reg)
return Wire.read();
else
return TEST_REG_NACK;
}
}

View File

@ -2,7 +2,7 @@
#ifndef K3NG_DISPLAY_H
#define K3NG_DISPLAY_H
// K3NG_DISPLAY_LIBRARY_VERSION "1.0.2015070401"
// K3NG_DISPLAY_LIBRARY_VERSION "1.0.2015071201"
#if defined(ARDUINO) && ARDUINO >= 100
@ -82,7 +82,7 @@ unsigned long next_blink_state_transition_time = TEXT_BLINK_MS;
K3NGdisplay::K3NGdisplay(int _display_columns, int _display_rows, int _update_time = 1000){
lcd.begin(_display_columns, _display_rows);
display_columns = _display_columns;
display_rows = _display_rows;
update_time_ms = _update_time;
@ -94,6 +94,8 @@ K3NGdisplay::K3NGdisplay(int _display_columns, int _display_rows, int _update_ti
void K3NGdisplay::initialize(){
lcd.begin(display_columns, display_rows);
#ifdef FEATURE_YOURDUINO_I2C_LCD
lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
lcd.setBacklight(I2C_LCD_COLOR);

View File

@ -6,10 +6,41 @@
#endif
#include "rotator_pins.h"
#include "rotator_features.h"
#define K3NG_DISPLAY_LIBRARY_VERSION "1.0.2015070401"
#ifdef HARDWARE_EA4TX_ARS_USB
#include "rotator_features_ea4tx_ars_usb.h"
#endif
#ifdef HARDWARE_WB6KCN
#include "rotator_features_wb6kcn.h"
#endif
#ifdef HARDWARE_M0UPU
#include "rotator_features_m0upu.h"
#endif
#ifdef HARDWARE_TEST
#include "rotator_features_test.h"
#endif
#if !defined(HARDWARE_CUSTOM)
#include "rotator_features.h"
#endif
#ifdef HARDWARE_EA4TX_ARS_USB
#include "rotator_pins_ea4tx_ars_usb.h"
#endif
#ifdef HARDWARE_M0UPU
#include "rotator_pins_m0upu.h"
#endif
#ifdef HARDWARE_WB6KCN
//#include "rotator_pins_wb6kcn_az_test_setup.h"
#include "rotator_pins_wb6kcn.h"
#endif
#ifdef HARDWARE_TEST
#include "rotator_pins_test.h"
#endif
#if !defined(HARDWARE_CUSTOM)
#include "rotator_pins.h"
#endif
#define K3NG_DISPLAY_LIBRARY_VERSION "1.0.2015071201"
#define MAX_SCREEN_BUFFER_COLUMNS 20
#define MAX_SCREEN_BUFFER_ROWS 4

420
rotator_clock_and_gps.h Normal file
View File

@ -0,0 +1,420 @@
#ifdef FEATURE_CLOCK
void update_time(){
unsigned long runtime = millis() - millis_at_last_calibration;
unsigned long time = (3600L * clock_hour_set) + (60L * clock_min_set) + clock_sec_set + ((runtime + (runtime * INTERNAL_CLOCK_CORRECTION)) / 1000.0);
clock_years = clock_year_set;
clock_months = clock_month_set;
clock_days = time / 86400L;
time -= clock_days * 86400L;
clock_days += clock_day_set;
clock_hours = time / 3600L;
switch (clock_months) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if (clock_days > 31) {
clock_days = 1; clock_months++;
}
break;
case 2:
if ((float(clock_years) / 4.0) == 0.0) { // do we have a leap year?
if (clock_days > 29) {
clock_days = 1; clock_months++;
}
} else {
if (clock_days > 28) {
clock_days = 1; clock_months++;
}
}
break;
case 4:
case 6:
case 9:
case 11:
if (clock_days > 30) {
clock_days = 1; clock_months++;
}
break;
} /* switch */
if (clock_months > 12) {
clock_months = 1; clock_years++;
}
time -= clock_hours * 3600L;
clock_minutes = time / 60L;
time -= clock_minutes * 60L;
clock_seconds = time;
} /* update_time */
#endif // FEATURE_CLOCK
// --------------------------------------------------------------
#ifdef FEATURE_GPS
void service_gps(){
long gps_lat, gps_lon;
unsigned long fix_age;
int gps_year;
byte gps_month, gps_day, gps_hours, gps_minutes, gps_seconds, gps_hundredths;
static byte gps_sync_pin_active = 0;
#ifdef DEBUG_GPS
char tempstring[10] = "";
#endif //#ifdef DEBUG_GPS
static unsigned long last_sync = 0;
if (gps_data_available) {
// retrieves +/- lat/long in 100000ths of a degree
gps.get_position(&gps_lat, &gps_lon, &fix_age);
gps.crack_datetime(&gps_year, &gps_month, &gps_day, &gps_hours, &gps_minutes, &gps_seconds, &gps_hundredths, &fix_age);
#ifdef DEBUG_GPS
#ifdef DEBUG_GPS_SERIAL
debug_println("");
#endif //DEBUG_GPS_SERIAL
debug_print("service_gps: fix_age:");
debug_print_int(fix_age);
debug_print(" lat:");
debug_print_float(gps_lat,4);
debug_print(" long:");
debug_print_float(gps_lon,4);
debug_print(" ");
debug_print_int(gps_year);
debug_print("-");
debug_print_int(gps_month);
debug_print("-");
debug_print_int(gps_day);
debug_print(" ");
debug_print_int(gps_hours);
debug_print(":");
debug_print_int(gps_minutes);
debug_println("");
#endif // DEBUG_GPS
if (fix_age < GPS_VALID_FIX_AGE_MS) {
if (SYNC_TIME_WITH_GPS) {
clock_year_set = gps_year;
clock_month_set = gps_month;
clock_day_set = gps_day;
clock_hour_set = gps_hours;
clock_min_set = gps_minutes;
clock_sec_set = gps_seconds;
millis_at_last_calibration = millis() - GPS_UPDATE_LATENCY_COMPENSATION_MS;
update_time();
#ifdef DEBUG_GPS
#ifdef DEBUG_GPS_SERIAL
debug_println("");
#endif //DEBUG_GPS_SERIAL
debug_print("service_gps: clock sync:");
sprintf(tempstring,"%s",clock_string());
debug_print(tempstring);
debug_println("");
#endif // DEBUG_GPS
}
#if defined(OPTION_SYNC_RTC_TO_GPS) && defined(FEATURE_RTC_DS1307)
static unsigned long last_rtc_gps_sync_time;
if ((millis() - last_rtc_gps_sync_time) >= (SYNC_RTC_TO_GPS_SECONDS * 1000)) {
rtc.adjust(DateTime(gps_year, gps_month, gps_day, gps_hours, gps_minutes, gps_seconds));
#ifdef DEBUG_RTC
debug_println("service_gps: synced RTC");
#endif // DEBUG_RTC
last_rtc_gps_sync_time = millis();
}
#endif // defined(OPTION_SYNC_RTC_TO_GPS) && defined(FEATURE_RTC_DS1307)
#if defined(OPTION_SYNC_RTC_TO_GPS) && defined(FEATURE_RTC_PCF8583)
static unsigned long last_rtc_gps_sync_time;
if ((millis() - last_rtc_gps_sync_time) >= (SYNC_RTC_TO_GPS_SECONDS * 1000)) {
rtc.year = gps_year;
rtc.month = gps_month;
rtc.day = gps_day;
rtc.hour = gps_hours;
rtc.minute = gps_minutes;
rtc.second = gps_seconds;
rtc.set_time();
#ifdef DEBUG_RTC
debug_println("service_gps: synced RTC");
#endif // DEBUG_RTC
last_rtc_gps_sync_time = millis();
}
#endif // defined(OPTION_SYNC_RTC_TO_GPS) && defined(FEATURE_RTC_PCF8583)
#if defined(FEATURE_MOON_TRACKING) || defined(FEATURE_SUN_TRACKING) || defined(FEATURE_REMOTE_UNIT_SLAVE)
if (SYNC_COORDINATES_WITH_GPS) {
latitude = float(gps_lat) / 1000000.0;
longitude = float(gps_lon) / 1000000.0;
#ifdef DEBUG_GPS
debug_print("service_gps: coord sync:");
debug_print_float(latitude,2);
debug_print(" ");
debug_print_float(longitude,2);
debug_println("");
#endif // DEBUG_GPS
}
#endif // defined(FEATURE_MOON_TRACKING) || defined(FEATURE_SUN_TRACKING)
last_sync = millis();
}
gps_data_available = 0;
}
if ((millis() > (GPS_SYNC_PERIOD_SECONDS * 1000)) && ((millis() - last_sync) < (GPS_SYNC_PERIOD_SECONDS * 1000)) && (SYNC_TIME_WITH_GPS)) {
clock_status = GPS_SYNC;
} else {
clock_status = FREE_RUNNING;
}
if (gps_sync){
if (clock_status == GPS_SYNC){
if (!gps_sync_pin_active){
digitalWriteEnhanced(gps_sync,HIGH);
gps_sync_pin_active = 1;
}
} else {
if (gps_sync_pin_active){
digitalWriteEnhanced(gps_sync,LOW);
gps_sync_pin_active = 0;
}
}
}
} /* service_gps */
#endif // FEATURE_GPS
// --------------------------------------------------------------
#if defined(OPTION_SYNC_MASTER_COORDINATES_TO_SLAVE) && (defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE))
void sync_master_coordinates_to_slave(){
static unsigned long last_sync_master_coordinates_to_slave = 10000;
if ((millis() - last_sync_master_coordinates_to_slave) >= (SYNC_MASTER_COORDINATES_TO_SLAVE_SECS * 1000)){
if (submit_remote_command(REMOTE_UNIT_RC_COMMAND, 0, 0)) {
#ifdef DEBUG_SYNC_MASTER_COORDINATES_TO_SLAVE
debug_println("sync_master_coordinates_to_slave: submitted REMOTE_UNIT_RC_COMMAND");
#endif //DEBUG_SYNC_MASTER_COORDINATES_TO_SLAVE
last_sync_master_coordinates_to_slave = millis();
}
}
}
#endif //defined(OPTION_SYNC_MASTER_COORDINATES_TO_SLAVE) && (defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE))
//------------------------------------------------------
#if defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE) && (defined(FEATURE_MASTER_WITH_SERIAL_SLAVE) || defined(FEATURE_MASTER_WITH_ETHERNET_SLAVE))
void sync_master_clock_to_slave(){
static unsigned long last_sync_master_clock_to_slave = 5000;
if ((millis() - last_sync_master_clock_to_slave) >= (SYNC_MASTER_CLOCK_TO_SLAVE_CLOCK_SECS * 1000)){
if (submit_remote_command(REMOTE_UNIT_CL_COMMAND, 0, 0)) {
#ifdef DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE
debug_println("sync_master_clock_to_slave: submitted REMOTE_UNIT_CL_COMMAND");
#endif //DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE
last_sync_master_clock_to_slave = millis();
}
}
// if REMOTE_UNIT_CL_COMMAND above was successful, issue a GS (query GPS sync command) to get GPS sync status on the remote
if (clock_synced_to_remote){
if (submit_remote_command(REMOTE_UNIT_GS_COMMAND, 0, 0)) {
#ifdef DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE
debug_println("sync_master_clock_to_slave: submitted REMOTE_UNIT_GS_COMMAND");
#endif //DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE
clock_synced_to_remote = 0;
}
}
}
#endif //defined(FEATURE_CLOCK) && defined(OPTION_SYNC_MASTER_CLOCK_TO_SLAVE)
// --------------------------------------------------------------
#ifdef FEATURE_CLOCK
char * clock_status_string(){
switch (clock_status) {
case FREE_RUNNING: return("FREE_RUNNING"); break;
case GPS_SYNC: return("GPS_SYNC"); break;
case RTC_SYNC: return("RTC_SYNC"); break;
case SLAVE_SYNC: return("SLAVE_SYNC"); break;
case SLAVE_SYNC_GPS: return("SLAVE_SYNC_GPS"); break;
}
}
#endif //FEATURE_CLOCK
// --------------------------------------------------------------
#ifdef FEATURE_CLOCK
char * clock_string(){
char return_string[32] = "";
char temp_string[16] = "";
dtostrf(clock_years, 0, 0, temp_string);
strcpy(return_string, temp_string);
strcat(return_string, "-");
if (clock_months < 10) {
strcat(return_string, "0");
}
dtostrf(clock_months, 0, 0, temp_string);
strcat(return_string, temp_string);
strcat(return_string, "-");
if (clock_days < 10) {
strcat(return_string, "0");
}
dtostrf(clock_days, 0, 0, temp_string);
strcat(return_string, temp_string);
strcat(return_string, " ");
if (clock_hours < 10) {
strcat(return_string, "0");
}
dtostrf(clock_hours, 0, 0, temp_string);
strcat(return_string, temp_string);
strcat(return_string, ":");
if (clock_minutes < 10) {
strcat(return_string, "0");
}
dtostrf(clock_minutes, 0, 0, temp_string);
strcat(return_string, temp_string);
strcat(return_string, ":");
if (clock_seconds < 10) {
strcat(return_string, "0");
}
dtostrf(clock_seconds, 0, 0, temp_string);
strcat(return_string, temp_string);
strcat(return_string,"Z");
return return_string;
} /* clock_string */
#endif // FEATURE_CLOCK
// --------------------------------------------------------------
#ifdef FEATURE_RTC
void service_rtc(){
static unsigned long last_rtc_sync_time = 0;
if (((millis() - last_rtc_sync_time) >= (SYNC_WITH_RTC_SECONDS * 1000)) || (clock_status == FREE_RUNNING)){
last_rtc_sync_time = millis();
#ifdef FEATURE_GPS
if (clock_status == GPS_SYNC) { // if we're also equipped with GPS and we're synced to it, don't sync to realtime clock
#ifdef DEBUG_RTC
debug_println("service_rtc: synced to GPS already. Exiting.");
#endif // DEBUG_RTC
return;
}
#endif // FEATURE_GPS
#ifdef FEATURE_RTC_DS1307
if (rtc.isrunning()) {
DateTime now = rtc.now();
#ifdef DEBUG_RTC
debug_print("service_rtc: syncing: ");
debug_print_int(now.year());
debug_print("/");
debug_print_int(now.month());
debug_print("/");
debug_print_int(now.day());
debug_print(" ");
debug_print_int(now.hour());
debug_print(":");
debug_print_int(now.minute());
debug_print(":");
debug_print_int(now.second());
debug_println("");
#endif // DEBUG_RTC
clock_year_set = now.year();
clock_month_set = now.month();
clock_day_set = now.day();
clock_hour_set = now.hour();
clock_min_set = now.minute();
clock_sec_set = now.second();
millis_at_last_calibration = millis();
update_time();
clock_status = RTC_SYNC;
} else {
clock_status = FREE_RUNNING;
#ifdef DEBUG_RTC
debug_println("service_rtc: error: RTC not running");
#endif // DEBUG_RTC
}
#endif //#FEATURE_RTC_DS1307
#ifdef FEATURE_RTC_PCF8583
rtc.get_time();
if ((rtc.year > 2000) && (rtc.month > 0) && (rtc.month < 13)){ // do we have a halfway reasonable date?
#ifdef DEBUG_RTC
control_port->print("service_rtc: syncing: ");
control_port->print(rtc.year, DEC);
control_port->print('/');
control_port->print(rtc.month, DEC);
control_port->print('/');
control_port->print(rtc.day, DEC);
control_port->print(' ');
control_port->print(rtc.hour, DEC);
control_port->print(':');
control_port->print(rtc.minute, DEC);
control_port->print(':');
control_port->println(rtc.second, DEC);
#endif // DEBUG_RTC
clock_year_set = rtc.year;
clock_month_set = rtc.month;
clock_day_set = rtc.day;
clock_hour_set = rtc.hour;
clock_min_set = rtc.minute;
clock_sec_set = rtc.second;
millis_at_last_calibration = millis();
update_time();
clock_status = RTC_SYNC;
} else {
clock_status = FREE_RUNNING;
#ifdef DEBUG_RTC
control_port->print("service_rtc: error: RTC not returning valid date or time: ");
control_port->print(rtc.year, DEC);
control_port->print('/');
control_port->print(rtc.month, DEC);
control_port->print('/');
control_port->print(rtc.day, DEC);
control_port->print(' ');
control_port->print(rtc.hour, DEC);
control_port->print(':');
control_port->print(rtc.minute, DEC);
control_port->print(':');
control_port->println(rtc.second, DEC);
#endif // DEBUG_RTC
}
#endif //#FEATURE_RTC_PCF8583
}
} /* service_rtc */
#endif // FEATURE_RTC
// --------------------------------------------------------------

1937
rotator_command_processing.h Normal file

File diff suppressed because it is too large Load Diff

266
rotator_ethernet.h Normal file
View File

@ -0,0 +1,266 @@
#ifdef FEATURE_ETHERNET
void service_ethernet(){
byte incoming_byte = 0;
static unsigned long last_incoming_byte_receive_time = 0;
char return_string[100] = "";
static byte ethernet_port_buffer0[COMMAND_BUFFER_SIZE];
static int ethernet_port_buffer_index0 = 0;
static byte first_connect_occurred = 0;
static long last_received_byte0 = 0;
#ifdef FEATURE_REMOTE_UNIT_SLAVE
static byte preamble_received = 0;
#endif //FEATURE_REMOTE_UNIT_SLAVE
/* this is the server side (receiving bytes from a client such as a master unit receiving commands from a computer
or a slave receiving commands from a master unit
*/
// clear things out if we received a partial message and it's been awhile
if ((ethernet_port_buffer_index0) && ((millis()-last_received_byte0) > ETHERNET_MESSAGE_TIMEOUT_MS)){
ethernet_port_buffer_index0 = 0;
#ifdef FEATURE_REMOTE_UNIT_SLAVE
preamble_received = 0;
#endif //FEATURE_REMOTE_UNIT_SLAVE
}
if (ethernetserver0.available()){
ethernetclient0 = ethernetserver0.available();
last_received_byte0 = millis();
if (!first_connect_occurred){ // clean out the cruft that's alway spit out on first connect
while(ethernetclient0.available()){ethernetclient0.read();}
first_connect_occurred = 1;
return;
}
if (ethernetclient0.available() > 0){ // the client has sent something
incoming_byte = ethernetclient0.read();
last_incoming_byte_receive_time = millis();
#ifdef DEBUG_ETHERNET
debug_print("service_ethernet: client:") ;
debug_print(" char:");
debug_print_char((char) incoming_byte);
debug_print("\n");
#endif //DEBUG_ETHERNET
if ((incoming_byte > 96) && (incoming_byte < 123)) { // uppercase it
incoming_byte = incoming_byte - 32;
}
char ethernet_preamble[] = ETHERNET_PREAMBLE;
#ifdef FEATURE_REMOTE_UNIT_SLAVE
if (preamble_received < 254){ // the master/slave ethernet link has each message prefixed with a preamble
if (ethernet_preamble[preamble_received] == 0){
preamble_received = 254;
} else {
if (incoming_byte == ethernet_preamble[preamble_received]){
preamble_received++;
} else {
preamble_received = 0;
}
}
}
// add it to the buffer if it's not a line feed or carriage return and we've received the preamble
if ((incoming_byte != 10) && (incoming_byte != 13) && (preamble_received == 254)) {
ethernet_port_buffer0[ethernet_port_buffer_index0] = incoming_byte;
ethernet_port_buffer_index0++;
}
#else
if ((incoming_byte != 10) && (incoming_byte != 13)) { // add it to the buffer if it's not a line feed or carriage return
ethernet_port_buffer0[ethernet_port_buffer_index0] = incoming_byte;
ethernet_port_buffer_index0++;
}
#endif //FEATURE_REMOTE_UNIT_SLAVE
if (((incoming_byte == 13) || (ethernet_port_buffer_index0 >= COMMAND_BUFFER_SIZE)) && (ethernet_port_buffer_index0 > 0)){ // do we have a carriage return?
if ((ethernet_port_buffer0[0] == '\\') or (ethernet_port_buffer0[0] == '/')) {
process_backslash_command(ethernet_port_buffer0, ethernet_port_buffer_index0, ETHERNET_PORT0, return_string);
} else {
#ifdef FEATURE_YAESU_EMULATION
process_yaesu_command(ethernet_port_buffer0,ethernet_port_buffer_index0,ETHERNET_PORT0,return_string);
#endif //FEATURE_YAESU_EMULATION
#ifdef FEATURE_EASYCOM_EMULATION
process_easycom_command(ethernet_port_buffer0,ethernet_port_buffer_index0,ETHERNET_PORT0,return_string);
#endif //FEATURE_EASYCOM_EMULATION
#ifdef FEATURE_REMOTE_UNIT_SLAVE
process_remote_slave_command(ethernet_port_buffer0,ethernet_port_buffer_index0,ETHERNET_PORT0,return_string);
#endif //FEATURE_REMOTE_UNIT_SLAVE
}
ethernetclient0.println(return_string);
ethernet_port_buffer_index0 = 0;
#ifdef FEATURE_REMOTE_UNIT_SLAVE
preamble_received = 0;
#endif //FEATURE_REMOTE_UNIT_SLAVE
}
}
}
#ifdef ETHERNET_TCP_PORT_1
static byte ethernet_port_buffer1[COMMAND_BUFFER_SIZE];
static int ethernet_port_buffer_index1 = 0;
if (ethernetserver1.available()){
ethernetclient1 = ethernetserver1.available();
if (ethernetclient1.available() > 0){ // the client has sent something
incoming_byte = ethernetclient1.read();
last_incoming_byte_receive_time = millis();
#ifdef DEBUG_ETHERNET
debug_print("service_ethernet: client:") ;
debug_print(" char:");
debug_print_char((char) incoming_byte);
debug_print("\n");
#endif //DEBUG_ETHERNET
if ((incoming_byte > 96) && (incoming_byte < 123)) { // uppercase it
incoming_byte = incoming_byte - 32;
}
if ((incoming_byte != 10) && (incoming_byte != 13)) { // add it to the buffer if it's not a line feed or carriage return
ethernet_port_buffer1[ethernet_port_buffer_index1] = incoming_byte;
ethernet_port_buffer_index1++;
}
if (incoming_byte == 13) { // do we have a carriage return?
if ((ethernet_port_buffer1[0] == '\\') or (ethernet_port_buffer1[0] == '/')) {
process_backslash_command(ethernet_port_buffer1, ethernet_port_buffer_index1, ETHERNET_PORT1, return_string);
} else {
#ifdef FEATURE_YAESU_EMULATION
process_yaesu_command(ethernet_port_buffer1,ethernet_port_buffer_index1,ETHERNET_PORT1,return_string);
#endif //FEATURE_YAESU_EMULATION
#ifdef FEATURE_EASYCOM_EMULATION
process_easycom_command(ethernet_port_buffer1,ethernet_port_buffer_index1,ETHERNET_PORT1,return_string);
#endif //FEATURE_EASYCOM_EMULATION
#ifdef FEATURE_REMOTE_UNIT_SLAVE
process_remote_slave_command(ethernet_port_buffer1,ethernet_port_buffer_index1,ETHERNET_PORT1,return_string);
#endif //FEATURE_REMOTE_UNIT_SLAVE
}
ethernetclient1.println(return_string);
ethernet_port_buffer_index1 = 0;
}
}
}
#endif //ETHERNET_TCP_PORT_1
#ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE
static long last_connect_try = 0;
static long last_received_byte_time = 0;
byte incoming_ethernet_byte = 0;
static byte first_ethernet_slave_connect_occurred = 0;
// are we disconnected and is it time to reconnect?
if ((ethernetslavelinkclient0_state == ETHERNET_SLAVE_DISCONNECTED) && (((millis()-last_connect_try) >= ETHERNET_SLAVE_RECONNECT_TIME_MS) || (last_connect_try == 0))){
#ifdef DEBUG_ETHERNET
debug_println("service_ethernet: master_slave_ethernet: connecting");
#endif //DEBUG_ETHERNET
if (ethernetslavelinkclient0.connect(slave_unit_ip, ETHERNET_SLAVE_TCP_PORT)){
ethernetslavelinkclient0_state = ETHERNET_SLAVE_CONNECTED;
if (!first_ethernet_slave_connect_occurred){
first_ethernet_slave_connect_occurred = 1;
ethernet_slave_reconnects = 65535;
}
} else {
ethernetslavelinkclient0.stop();
#ifdef DEBUG_ETHERNET
debug_println("service_ethernet: master_slave_ethernet: connect failed");
#endif //DEBUG_ETHERNET
}
ethernet_slave_reconnects++;
last_connect_try = millis();
}
if (ethernetslavelinkclient0.available()) {
incoming_ethernet_byte = ethernetslavelinkclient0.read();
#ifdef DEBUG_ETHERNET
debug_print("service_ethernet: slave rx: ");
debug_print_char(incoming_ethernet_byte);
debug_print(" : ");
debug_print_int(incoming_ethernet_byte);
debug_println("");
#endif //DEBUG_ETHERNET
if (remote_port_rx_sniff) {
control_port->write(incoming_ethernet_byte);
}
if ((incoming_ethernet_byte != 10) && (remote_unit_port_buffer_index < COMMAND_BUFFER_SIZE)) {
remote_unit_port_buffer[remote_unit_port_buffer_index] = incoming_ethernet_byte;
remote_unit_port_buffer_index++;
if ((incoming_ethernet_byte == 13) || (remote_unit_port_buffer_index >= COMMAND_BUFFER_SIZE)) {
remote_unit_port_buffer_carriage_return_flag = 1;
#ifdef DEBUG_ETHERNET
debug_println("service_ethernet: remote_unit_port_buffer_carriage_return_flag");
#endif //DEBUG_ETHERNET
}
}
last_received_byte_time = millis();
}
if (((millis() - last_received_byte_time) >= ETHERNET_MESSAGE_TIMEOUT_MS) && (remote_unit_port_buffer_index > 1) && (!remote_unit_port_buffer_carriage_return_flag)){
remote_unit_port_buffer_index = 0;
#ifdef DEBUG_ETHERNET
debug_println("service_ethernet: master_slave_ethernet: remote_unit_incoming_buffer_timeout");
#endif //DEBUG_ETHERNET
remote_unit_incoming_buffer_timeouts++;
}
if ((ethernetslavelinkclient0_state == ETHERNET_SLAVE_CONNECTED) && (!ethernetslavelinkclient0.connected())){
ethernetslavelinkclient0.stop();
ethernetslavelinkclient0_state = ETHERNET_SLAVE_DISCONNECTED;
remote_unit_port_buffer_index = 0;
#ifdef DEBUG_ETHERNET
debug_println("service_ethernet: master_slave_ethernet: lost connection");
#endif //DEBUG_ETHERNET
}
#endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE
}
#endif //FEATURE_ETHERNET
// --------------------------------------------------------------
#ifdef FEATURE_MASTER_WITH_ETHERNET_SLAVE
byte ethernet_slave_link_send(char * string_to_send){
if (ethernetslavelinkclient0_state == ETHERNET_SLAVE_CONNECTED){
ethernetslavelinkclient0.print(ETHERNET_PREAMBLE);
ethernetslavelinkclient0.println(string_to_send);
#ifdef DEBUG_ETHERNET
debug_print("ethernet_slave_link_send: ");
debug_println(string_to_send);
#endif //DEBUG_ETHERNET
return 1;
} else {
#ifdef DEBUG_ETHERNET
debug_print("ethernet_slave_link_send: link down not sending:");
debug_println(string_to_send);
#endif //DEBUG_ETHERNET
return 0;
}
}
#endif //FEATURE_MASTER_WITH_ETHERNET_SLAVE
//-------------------------------------------------------

22
rotator_features.h Normal file → Executable file
View File

@ -5,18 +5,18 @@
*/
/* main features */
//#define FEATURE_ELEVATION_CONTROL // uncomment this for AZ/EL rotators
#define FEATURE_ELEVATION_CONTROL // uncomment this for AZ/EL rotators
#define FEATURE_YAESU_EMULATION // uncomment this for Yaesu GS-232 emulation on control port
//#define FEATURE_EASYCOM_EMULATION // Easycom protocol emulation on control port (undefine FEATURE_YAESU_EMULATION above)
//#define FEATURE_MOON_TRACKING
//#define FEATURE_SUN_TRACKING
//#define FEATURE_CLOCK
//#define FEATURE_GPS
//#define FEATURE_RTC_DS1307
#define FEATURE_MOON_TRACKING
#define FEATURE_SUN_TRACKING
#define FEATURE_CLOCK
#define FEATURE_GPS
#define FEATURE_RTC_DS1307
//#define FEATURE_RTC_PCF8583
//#define FEATURE_ETHERNET
//#define FEATURE_STEPPER_MOTOR // requires Mega or an AVR with Timer 5 support
#define FEATURE_ETHERNET
#define FEATURE_STEPPER_MOTOR // requires Mega or an AVR with Timer 5 support
//#define FEATURE_AUTOCORRECT
#define LANGUAGE_ENGLISH
@ -45,7 +45,7 @@
//#define FEATURE_AZ_POSITION_INCREMENTAL_ENCODER
//#define FEATURE_AZ_POSITION_A2_ABSOLUTE_ENCODER
//#define FEATURE_EL_POSITION_POTENTIOMETER
#define FEATURE_EL_POSITION_POTENTIOMETER
//#define FEATURE_EL_POSITION_ROTARY_ENCODER
//#define FEATURE_EL_POSITION_PULSE_INPUT
//#define FEATURE_EL_POSITION_ADXL345_USING_LOVE_ELECTRON_LIB // Uncomment for elevation ADXL345 accelerometer support using ADXL345 library
@ -58,7 +58,7 @@
//#define FEATURE_EL_POSITION_MEMSIC_2125
//#define FEATURE_EL_POSITION_A2_ABSOLUTE_ENCODER
//#define FEATURE_4_BIT_LCD_DISPLAY //Uncomment for classic 4 bit LCD display (most common)
#define FEATURE_4_BIT_LCD_DISPLAY //Uncomment for classic 4 bit LCD display (most common)
//#define FEATURE_ADAFRUIT_I2C_LCD
//#define FEATURE_ADAFRUIT_BUTTONS // Uncomment this to use Adafruit I2C LCD buttons for manual AZ/EL instead of normal buttons
//#define FEATURE_YOURDUINO_I2C_LCD
@ -141,7 +141,7 @@
/**************** this section is for code under development ********************************/
//#define UNDER_DEVELOPMENT_REMOTE_UNIT_COMMANDS
//#define UNDER_DEVELOPMENT_K3NGDISPLAY_LIBRARY
#define UNDER_DEVELOPMENT_K3NGDISPLAY_LIBRARY
#define OPTION_DISPLAY_STATUS
#define OPTION_DISPLAY_HEADING
#define LCD_HEADING_ROW 2

0
rotator_features_m0upu.h Normal file → Executable file
View File

228
rotator_features_test.h Executable file
View File

@ -0,0 +1,228 @@
/*
TEST Hardware !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
/* main features */
#define FEATURE_ELEVATION_CONTROL // uncomment this for AZ/EL rotators
#define FEATURE_YAESU_EMULATION // uncomment this for Yaesu GS-232 emulation on control port
//#define FEATURE_EASYCOM_EMULATION // Easycom protocol emulation on control port (undefine FEATURE_YAESU_EMULATION above)
//#define FEATURE_MOON_TRACKING
//#define FEATURE_SUN_TRACKING
//#define FEATURE_CLOCK
//#define FEATURE_GPS
//#define FEATURE_RTC_DS1307
//#define FEATURE_RTC_PCF8583
//#define FEATURE_ETHERNET
//#define FEATURE_STEPPER_MOTOR // requires Mega or an AVR with Timer 5 support
//#define FEATURE_AUTOCORRECT
#define LANGUAGE_ENGLISH
//#define LANGUAGE_SPANISH
//#define LANGUAGE_CZECH
//#define LANGUAGE_ITALIAN
//#define LANGUAGE_PORTUGUESE_BRASIL
/* master and remote slave unit functionality */
//#define FEATURE_REMOTE_UNIT_SLAVE // uncomment this to make this unit a remote unit controlled by a host unit
//#define FEATURE_MASTER_WITH_SERIAL_SLAVE // [master]{remote_port}<-------serial-------->{control_port}[slave]
//#define FEATURE_MASTER_WITH_ETHERNET_SLAVE // [master]<-------------------ethernet--------------------->[slave]
/* position sensors - pick one for azimuth and one for elevation if using an az/el rotator */
#define FEATURE_AZ_POSITION_POTENTIOMETER //this is used for both a voltage from a rotator control or a homebrew rotator with a potentiometer
//#define FEATURE_AZ_POSITION_ROTARY_ENCODER
//#define FEATURE_AZ_POSITION_PULSE_INPUT
//#define FEATURE_AZ_POSITION_HMC5883L // HMC5883L digital compass support
//#define FEATURE_AZ_POSITION_GET_FROM_REMOTE_UNIT // requires FEATURE_MASTER_WITH_SERIAL_SLAVE or FEATURE_MASTER_WITH_ETHERNET_SLAVE
//#define FEATURE_AZ_POSITION_ADAFRUIT_LSM303 // Uncomment for azimuth using LSM303 compass and Adafruit library (https://github.com/adafruit/Adafruit_LSM303) (also uncomment object declaration below)
//#define FEATURE_AZ_POSITION_POLOLU_LSM303 // Uncomment for azimuth using LSM303 compass and Polulu library
//#define FEATURE_AZ_POSITION_HH12_AS5045_SSI
//#define FEATURE_AZ_POSITION_INCREMENTAL_ENCODER
#define FEATURE_EL_POSITION_POTENTIOMETER
//#define FEATURE_EL_POSITION_ROTARY_ENCODER
//#define FEATURE_EL_POSITION_PULSE_INPUT
//#define FEATURE_EL_POSITION_ADXL345_USING_LOVE_ELECTRON_LIB // Uncomment for elevation ADXL345 accelerometer support using ADXL345 library
//#define FEATURE_EL_POSITION_ADXL345_USING_ADAFRUIT_LIB // Uncomment for elevation ADXL345 accelerometer support using Adafruit library
//#define FEATURE_EL_POSITION_GET_FROM_REMOTE_UNIT // requires FEATURE_MASTER_WITH_SERIAL_SLAVE or FEATURE_MASTER_WITH_ETHERNET_SLAVE
//#define FEATURE_EL_POSITION_ADAFRUIT_LSM303 // Uncomment for elevation using LSM303 accelerometer and Adafruit library (https://github.com/adafruit/Adafruit_LSM303) (also uncomment object declaration below)
//#define FEATURE_EL_POSITION_POLOLU_LSM303 // Uncomment for elevation using LSM303 compass and Polulu library
//#define FEATURE_EL_POSITION_HH12_AS5045_SSI
//#define FEATURE_EL_POSITION_INCREMENTAL_ENCODER
//#define FEATURE_EL_POSITION_MEMSIC_2125
#define FEATURE_4_BIT_LCD_DISPLAY //Uncomment for classic 4 bit LCD display (most common)
//#define FEATURE_ADAFRUIT_I2C_LCD
//#define FEATURE_ADAFRUIT_BUTTONS // Uncomment this to use Adafruit I2C LCD buttons for manual AZ/EL instead of normal buttons
//#define FEATURE_YOURDUINO_I2C_LCD
//#define FEATURE_RFROBOT_I2C_DISPLAY
//#define FEATURE_ANALOG_OUTPUT_PINS
//#define FEATURE_YWROBOT_I2C_DISPLAY
//#define FEATURE_SUN_PUSHBUTTON_AZ_EL_CALIBRATION
//#define FEATURE_MOON_PUSHBUTTON_AZ_EL_CALIBRATION
/* preset rotary encoder features and options */
//#define FEATURE_AZ_PRESET_ENCODER // Uncomment for Rotary Encoder Azimuth Preset support
//#define FEATURE_EL_PRESET_ENCODER // Uncomment for Rotary Encoder Elevation Preset support (requires FEATURE_AZ_PRESET_ENCODER above)
#define OPTION_ENCODER_HALF_STEP_MODE
#define OPTION_ENCODER_ENABLE_PULLUPS // define to enable weak pullups on rotary encoder pins
#define OPTION_INCREMENTAL_ENCODER_PULLUPS // define to enable weak pullups on 3 phase incremental rotary encoder pins
//#define OPTION_PRESET_ENCODER_RELATIVE_CHANGE // this makes the encoder(s) change the az or el in a relative fashion rather then store an absolute setting
#define OPTION_PRESET_ENCODER_0_360_DEGREES
/* position sensor options */
#define OPTION_AZ_POSITION_ROTARY_ENCODER_HARD_LIMIT // stop azimuth at lower and upper limit rather than rolling over
#define OPTION_EL_POSITION_ROTARY_ENCODER_HARD_LIMIT // stop elevation at lower and upper limits rather than rolling over
#define OPTION_AZ_POSITION_PULSE_HARD_LIMIT // stop azimuth at lower and upper limit rather than rolling over
#define OPTION_EL_POSITION_PULSE_HARD_LIMIT // stop elevation at lower and upper limits rather than rolling over
#define OPTION_POSITION_PULSE_INPUT_PULLUPS // define to enable weak pullups on position pulse inputs
/* less often used features and options */
#define OPTION_GS_232B_EMULATION // comment this out to default to Yaesu GS-232A emulation when using FEATURE_YAESU_EMULATION above
//#define FEATURE_ROTATION_INDICATOR_PIN // activate rotation_indication_pin to indicate rotation
//#define FEATURE_LIMIT_SENSE
//#define FEATURE_TIMED_BUFFER // Support for Yaesu timed buffer commands
//#define OPTION_SERIAL_HELP_TEXT // Yaesu help command prints help
#define FEATURE_PARK
//#define OPTION_AZ_MANUAL_ROTATE_LIMITS // this option will automatically stop the L and R commands when hitting a CCW or CW limit (settings below - AZ_MANUAL_ROTATE_*_LIMIT)
//#define OPTION_EL_MANUAL_ROTATE_LIMITS
#define OPTION_EASYCOM_AZ_QUERY_COMMAND // Adds non-standard Easycom command: AZ with no parm returns current azimuth
#define OPTION_EASYCOM_EL_QUERY_COMMAND // Adds non-standard Easycom command: EL with no parm returns current elevation
//#define OPTION_C_COMMAND_SENDS_AZ_AND_EL // uncomment this when using Yaesu emulation with Ham Radio Deluxe
//#define OPTION_DELAY_C_CMD_OUTPUT // uncomment this when using Yaesu emulation with Ham Radio Deluxe
#define FEATURE_ONE_DECIMAL_PLACE_HEADINGS
//#define FEATURE_TWO_DECIMAL_PLACE_HEADINGS // under development - not working yet!
//#define FEATURE_AZIMUTH_CORRECTION // correct the azimuth using a calibration table in rotator_settings.h
//#define FEATURE_ELEVATION_CORRECTION // correct the elevation using a calibration table in rotator_settings.h
//#define FEATURE_ANCILLARY_PIN_CONTROL // control I/O pins with serial commands \F, \N, \P
//#define FEATURE_JOYSTICK_CONTROL // analog joystick support
//#define OPTION_JOYSTICK_REVERSE_X_AXIS
//#define OPTION_JOYSTICK_REVERSE_Y_AXIS
#define OPTION_EL_SPEED_FOLLOWS_AZ_SPEED // changing the azimith speed with Yaesu X commands or an azimuth speed pot will also change elevation speed
//#define OPTION_PULSE_IGNORE_AMBIGUOUS_PULSES // for azimuth and elevation position pulse input feature, ignore pulses that arrive when no rotation is active
//#define OPTION_BUTTON_RELEASE_NO_SLOWDOWN // disables slowdown when CW or CCW button is released, or stop button is depressed
#define OPTION_SYNC_RTC_TO_GPS // if both realtime clock and GPS are present, synchronize realtime clock to GPS
//#define OPTION_DISPLAY_HHMM_CLOCK // display HH:MM clock on LCD row 1 (set position with #define LCD_HHMM_CLOCK_POSITION)
//#define OPTION_DISPLAY_HHMMSS_CLOCK // display HH:MM:SS clock on LCD row 1 (set position with #define LCD_HHMMSS_CLOCK_POSITION)
//#define OPTION_DISPLAY_ALT_HHMM_CLOCK_AND_MAIDENHEAD // display alternating HH:MM clock and maidenhead on LCD row 1 (set position with #define LCD_HHMMCLOCK_POSITION)
//#define OPTION_DISPLAY_CONSTANT_HHMMSS_CLOCK_AND_MAIDENHEAD // display constant HH:MM:SS clock and maidenhead on LCD row 1 (set position with #define LCD_CONSTANT_HHMMSSCLOCK_MAIDENHEAD_POSITION)
//#define OPTION_DISPLAY_BIG_CLOCK // display date & time clock (set row with #define LCD_BIG_CLOCK_ROW)
//#define OPTION_CLOCK_ALWAYS_HAVE_HOUR_LEADING_ZERO
//#define OPTION_DISPLAY_GPS_INDICATOR // display GPS indicator on LCD - set position with LCD_GPS_INDICATOR_POSITION and LCD_GPS_INDICATOR_ROW
//#define OPTION_DISPLAY_MOON_TRACKING_CONTINUOUSLY
//#define OPTION_DISPLAY_DIRECTION_STATUS // N, W, E, S, NW, etc. direction indicator in row 1 center
//#define OPTION_DISPLAY_SUN_TRACKING_CONTINUOUSLY
//#define OPTION_DISPLAY_MOON_OR_SUN_TRACKING_CONDITIONAL
//#define OPTION_DISPLAY_VERSION_ON_STARTUP //code provided by Paolo, IT9IPQ
//#define FEATURE_POWER_SWITCH
//#define OPTION_EXTERNAL_ANALOG_REFERENCE //Activate external analog voltage reference (needed for RemoteQTH.com unit)
//#define OPTION_SYNC_MASTER_CLOCK_TO_SLAVE // use when GPS unit is connected to slave unit and you want to synchronize the master unit clock to the slave unit GPS clock
//#define OPTION_SYNC_MASTER_COORDINATES_TO_SLAVE // use when GPS unit is connected to slave unit and you want to synchronize the master unit coordinates to the slave unit GPS
//#define OPTION_DISABLE_HMC5883L_ERROR_CHECKING
//#define OPTION_HAMLIB_EASYCOM_AZ_EL_COMMAND_HACK
//#define OPTION_HAMLIB_EASYCOM_NO_TERMINATOR_CHARACTER_HACK
//#define OPTION_NO_ELEVATION_CHECK_TARGET_DELAY
//#define OPTION_BLINK_OVERLAP_LED
//#define OPTION_EL_PULSE_DEBOUNCE
//#define OPTION_SCANCON_2RMHF3600_INC_ENCODER // use with FEATURE_AZ_POSITION_INCREMENTAL_ENCODER and/or FEATURE_EL_POSITION_INCREMENTAL_ENCODER if using the ScanCon 2RMHF3600 incremental encoder
//#define OPTION_RESET_METHOD_JMP_ASM_0
/**************** this section is for code under development ********************************/
//#define UNDER_DEVELOPMENT_REMOTE_UNIT_COMMANDS
#define UNDER_DEVELOPMENT_K3NGDISPLAY_LIBRARY
#define OPTION_DISPLAY_STATUS
#define OPTION_DISPLAY_HEADING
#define LCD_HEADING_ROW 2
#define LCD_HEADING_FIELD_SIZE 16//20
//#define OPTION_LCD_HEADING_FIELD_FIXED_DECIMAL_PLACE
#define LCD_STATUS_ROW 1
#define LCD_STATUS_FIELD_SIZE 16//20
#define LCD_DIRECTION_ROW 1
#define LCD_HHMMSS_CLOCK_ROW 1
#define LCD_HHMM_CLOCK_ROW 1
#define PARKING_STRING "PARKING"
#define PARKED_STRING "PARKED"
#define PARKING_STATUS_DISPLAY_TIME_MS 5000
// TODO - eliminate unused strings from settings files
/**************** end of section for code under development ********************************/
/*
Note:
Ham Radio Deluxe expects AZ and EL in output for Yaesu C command in AZ/EL mode. I'm not sure if this is default behavior for
the Yaesu interface since the C2 command is supposed to be for AZ and EL. If you have problems with other software with this code in AZ/EL mode,
uncomment #define OPTION_C_COMMAND_SENDS_AZ_AND_EL.
*/
/* ---------------------- debug stuff - don't touch unless you know what you are doing --------------------------- */
#define DEFAULT_DEBUG_STATE 0 // 1 = activate debug mode at startup; this should be set to zero unless you're debugging something at startup
#define DEBUG_DUMP // normally compile with this activated unless you're really trying to save memory
// #define DEBUG_MEMORY
// #define DEBUG_BUTTONS
// #define DEBUG_SERIAL
// #define DEBUG_SERVICE_REQUEST_QUEUE
// #define DEBUG_EEPROM
// #define DEBUG_AZ_SPEED_POT
// #define DEBUG_AZ_PRESET_POT
// #define DEBUG_PRESET_ENCODERS
// #define DEBUG_AZ_MANUAL_ROTATE_LIMITS
// #define DEBUG_EL_MANUAL_ROTATE_LIMITS
// #define DEBUG_BRAKE
// #define DEBUG_OVERLAP
// #define DEBUG_DISPLAY
// #define DEBUG_AZ_CHECK_OPERATION_TIMEOUT
// #define DEBUG_TIMED_BUFFER
// #define DEBUG_EL_CHECK_OPERATION_TIMEOUT
// #define DEBUG_VARIABLE_OUTPUTS
// #define DEBUG_ROTATOR
// #define DEBUG_SUBMIT_REQUEST
// #define DEBUG_SERVICE_ROTATION
// #define DEBUG_POSITION_ROTARY_ENCODER
// #define DEBUG_PROFILE_LOOP_TIME
// #define DEBUG_POSITION_PULSE_INPUT
// #define DEBUG_ACCEL
// #define DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER
// #define DEBUG_SVC_REMOTE_COMM_INCOMING_BUFFER_BAD_DATA
// #define DEBUG_HEADING_READING_TIME
// #define DEBUG_JOYSTICK
// #define DEBUG_ROTATION_INDICATION_PIN
// #define DEBUG_HH12
// #define DEBUG_PARK
// #define DEBUG_LIMIT_SENSE
// #define DEBUG_AZ_POSITION_INCREMENTAL_ENCODER
// #define DEBUG_EL_POSITION_INCREMENTAL_ENCODER
// #define DEBUG_MOON_TRACKING
// #define DEBUG_SUN_TRACKING
// #define DEBUG_GPS
// #define DEBUG_GPS_SERIAL
// #define DEBUG_OFFSET
// #define DEBUG_RTC
// #define DEBUG_PROCESS_YAESU
// #define DEBUG_ETHERNET
// #define DEBUG_PROCESS_SLAVE
// #define DEBUG_MEMSIC_2125
// #define DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE
// #define DEBUG_SYNC_MASTER_COORDINATES_TO_SLAVE
// #define DEBUG_HMC5883L
// #define DEBUG_POLOLU_LSM303_CALIBRATION
// #define DEBUG_STEPPER
// #define DEBUG_AUTOCORRECT

0
rotator_features_wb6kcn.h Normal file → Executable file
View File

0
rotator_hardware.h Normal file → Executable file
View File

271
rotator_moon_and_sun.h Normal file
View File

@ -0,0 +1,271 @@
#ifdef FEATURE_MOON_TRACKING
void service_moon_tracking(){
static unsigned long last_check = 0;
static byte moon_tracking_activated_by_activate_line = 0;
static byte moon_tracking_pin_state = 0;
if (moon_tracking_active_pin) {
if ((moon_tracking_active) && (!moon_tracking_pin_state)) {
digitalWriteEnhanced(moon_tracking_active_pin, HIGH);
moon_tracking_pin_state = 1;
}
if ((!moon_tracking_active) && (moon_tracking_pin_state)) {
digitalWriteEnhanced(moon_tracking_active_pin, LOW);
moon_tracking_pin_state = 0;
}
}
if (moon_tracking_activate_line) {
if ((!moon_tracking_active) && (!digitalReadEnhanced(moon_tracking_activate_line))) {
moon_tracking_active = 1;
moon_tracking_activated_by_activate_line = 1;
}
if ((moon_tracking_active) && (digitalReadEnhanced(moon_tracking_activate_line)) && (moon_tracking_activated_by_activate_line)) {
moon_tracking_active = 0;
moon_tracking_activated_by_activate_line = 0;
}
}
if ((moon_tracking_active) && ((millis() - last_check) > MOON_TRACKING_CHECK_INTERVAL)) {
update_time();
update_moon_position();
#ifdef DEBUG_MOON_TRACKING
control_port->print(F("service_moon_tracking: AZ: "));
control_port->print(moon_azimuth);
control_port->print(" EL: ");
control_port->print(moon_elevation);
control_port->print(" lat: ");
control_port->print(latitude);
control_port->print(" long: ");
control_port->println(longitude);
#endif // DEBUG_MOON_TRACKING
if ((moon_azimuth >= MOON_AOS_AZIMUTH_MIN) && (moon_azimuth <= MOON_AOS_AZIMUTH_MAX) && (moon_elevation >= MOON_AOS_ELEVATION_MIN) && (moon_elevation <= MOON_AOS_ELEVATION_MAX)) {
submit_request(AZ, REQUEST_AZIMUTH, moon_azimuth * HEADING_MULTIPLIER, 11);
submit_request(EL, REQUEST_ELEVATION, moon_elevation * HEADING_MULTIPLIER, 12);
if (!moon_visible) {
moon_visible = 1;
#ifdef DEBUG_MOON_TRACKING
control_port->println(F("service_moon_tracking: moon AOS"));
#endif // DEBUG_MOON_TRACKING
}
} else {
if (moon_visible) {
moon_visible = 0;
#ifdef DEBUG_MOON_TRACKING
control_port->println(F("service_moon_tracking: moon loss of AOS"));
#endif // DEBUG_MOON_TRACKING
} else {
#ifdef DEBUG_MOON_TRACKING
control_port->println(F("service_moon_tracking: moon out of AOS limits"));
#endif // DEBUG_MOON_TRACKING
}
}
last_check = millis();
}
} /* service_moon_tracking */
#endif // FEATURE_MOON_TRACKING
// --------------------------------------------------------------
#ifdef FEATURE_SUN_TRACKING
void service_sun_tracking(){
static unsigned long last_check = 0;
static byte sun_tracking_pin_state = 0;
static byte sun_tracking_activated_by_activate_line = 0;
if (sun_tracking_active_pin) {
if ((sun_tracking_active) && (!sun_tracking_pin_state)) {
digitalWriteEnhanced(sun_tracking_active_pin, HIGH);
sun_tracking_pin_state = 1;
}
if ((!sun_tracking_active) && (sun_tracking_pin_state)) {
digitalWriteEnhanced(sun_tracking_active_pin, LOW);
sun_tracking_pin_state = 0;
}
}
if (sun_tracking_activate_line) {
if ((!sun_tracking_active) && (!digitalReadEnhanced(sun_tracking_activate_line))) {
sun_tracking_active = 1;
sun_tracking_activated_by_activate_line = 1;
}
if ((sun_tracking_active) && (digitalReadEnhanced(sun_tracking_activate_line)) && (sun_tracking_activated_by_activate_line)) {
sun_tracking_active = 0;
sun_tracking_activated_by_activate_line = 0;
}
}
if ((sun_tracking_active) && ((millis() - last_check) > SUN_TRACKING_CHECK_INTERVAL)) {
update_time();
update_sun_position();
#ifdef DEBUG_SUN_TRACKING
control_port->print(F("service_sun_tracking: AZ: "));
control_port->print(sun_azimuth);
control_port->print(" EL: ");
control_port->print(sun_elevation);
control_port->print(" lat: ");
control_port->print(latitude);
control_port->print(" long: ");
control_port->println(longitude);
#endif // DEBUG_SUN_TRACKING
if ((sun_azimuth >= SUN_AOS_AZIMUTH_MIN) && (sun_azimuth <= SUN_AOS_AZIMUTH_MAX) && (sun_elevation >= SUN_AOS_ELEVATION_MIN) && (sun_elevation <= SUN_AOS_ELEVATION_MAX)) {
submit_request(AZ, REQUEST_AZIMUTH, sun_azimuth * HEADING_MULTIPLIER, 13);
submit_request(EL, REQUEST_ELEVATION, sun_elevation * HEADING_MULTIPLIER, 14);
if (!sun_visible) {
sun_visible = 1;
#ifdef DEBUG_SUN_TRACKING
control_port->println(F("service_sun_tracking: sun AOS"));
#endif // DEBUG_SUN_TRACKING
}
} else {
if (sun_visible) {
sun_visible = 0;
#ifdef DEBUG_SUN_TRACKING
control_port->println(F("service_sun_tracking: sun loss of AOS"));
#endif // DEBUG_SUN_TRACKING
} else {
#ifdef DEBUG_SUN_TRACKING
control_port->println(F("service_sun_tracking: sun out of AOS limits"));
#endif // DEBUG_SUN_TRACKING
}
}
last_check = millis();
}
} /* service_sun_tracking */
#endif // FEATURE_SUN_TRACKING
// --------------------------------------------------------------
#if defined(FEATURE_MOON_PUSHBUTTON_AZ_EL_CALIBRATION) && defined(FEATURE_MOON_TRACKING)
void check_moon_pushbutton_calibration(){
static unsigned long last_update_time = 0;
if ((digitalReadEnhanced(pin_moon_pushbutton_calibration) == LOW) && ((millis() - last_update_time) > 500)){
update_moon_position();
if (calibrate_az_el(moon_azimuth, moon_elevation)) {
} else {
}
last_update_time = millis();
}
}
#endif //defined(FEATURE_MOON_PUSHBUTTON_AZ_EL_CALIBRATION) && defined(FEATURE_MOON_TRACKING)
//-------------------------------------------------------
#if defined(FEATURE_SUN_PUSHBUTTON_AZ_EL_CALIBRATION) && defined(FEATURE_SUN_TRACKING)
void check_sun_pushbutton_calibration(){
static unsigned long last_update_time = 0;
if ((digitalReadEnhanced(pin_sun_pushbutton_calibration) == LOW) && ((millis() - last_update_time) > 500)){
update_sun_position();
if (calibrate_az_el(sun_azimuth, sun_elevation)) {
} else {
}
last_update_time = millis();
}
}
#endif //defined(FEATURE_SUN_PUSHBUTTON_AZ_EL_CALIBRATION) && defined(FEATURE_SUN_TRACKING)
//-------------------------------------------------------
#if defined(FEATURE_SUN_TRACKING) || defined(FEATURE_MOON_TRACKING)
char * coordinate_string(){
char returnstring[32] = "";
char tempstring[12] = "";
dtostrf(latitude,0,4,returnstring);
strcat(returnstring," ");
dtostrf(longitude,0,4,tempstring);
strcat(returnstring,tempstring);
return returnstring;
}
#endif //defined(FEATURE_SUN_TRACKING) || defined(FEATURE_MOON_TRACKING)
// --------------------------------------------------------------
#ifdef FEATURE_MOON_TRACKING
char * moon_status_string(){
char returnstring[128] = "";
char tempstring[16] = "";
strcpy(returnstring,"\tmoon: AZ: ");
dtostrf(moon_azimuth,0,2,tempstring);
strcat(returnstring,tempstring);
strcat(returnstring," EL: ");
dtostrf(moon_elevation,0,2,tempstring);
strcat(returnstring,tempstring);
strcat(returnstring,"\tTRACKING_");
if (!moon_tracking_active) {
strcat(returnstring,"IN");
}
strcat(returnstring,"ACTIVE ");
if (moon_tracking_active) {
if (!moon_visible) {
strcat(returnstring,"NOT_");
}
strcat(returnstring,"VISIBLE");
}
return returnstring;
}
#endif // FEATURE_MOON_TRACKING
// --------------------------------------------------------------
#ifdef FEATURE_SUN_TRACKING
char * sun_status_string(){
char returnstring[128] = "";
char tempstring[16] = "";
strcpy(returnstring,"\tsun: AZ: ");
dtostrf(sun_azimuth,0,2,tempstring);
strcat(returnstring,tempstring);
strcat(returnstring," EL: ");
dtostrf(sun_elevation,0,2,tempstring);
strcat(returnstring,tempstring);
strcat(returnstring,"\tTRACKING_");
if (!sun_tracking_active) {
strcat(returnstring,"IN");
}
strcat(returnstring,"ACTIVE ");
if (sun_tracking_active) {
if (!sun_visible) {
strcat(returnstring,"NOT_");
}
strcat(returnstring,"VISIBLE");
}
return returnstring;
}
#endif // FEATURE_SUN_TRACKING
// --------------------------------------------------------------

0
rotator_pins.h Normal file → Executable file
View File

182
rotator_pins_test.h Normal file
View File

@ -0,0 +1,182 @@
/* LEDs left to right
6 - PWM
7 - NO PWM
8 - NO PWM
9 - PWM
*/
#define pins_h
#define rotate_cw 6 // goes high to activate rotator R (CW) rotation - pin 1 on Yaesu connector
#define rotate_ccw 7 // goes high to activate rotator L (CCW) rotation - pin 2 on Yaesu connector
#define rotate_cw_ccw 0 // goes high for both CW and CCW rotation
#define rotate_cw_pwm 0 // optional - PWM CW output - set to 0 to disable (must be PWM capable pin)
#define rotate_ccw_pwm 0 // optional - PWM CCW output - set to 0 to disable (must be PWM capable pin)
#define rotate_cw_ccw_pwm 0
#define rotate_cw_freq 0
#define rotate_ccw_freq 0
#define button_cw 0 //A1 // normally open button to ground for manual CW rotation
#define button_ccw 0 //A2 // normally open button to ground for manual CCW rotation
#define serial_led 13 //0 // LED blinks when command is received on serial port (set to 0 to disable)
#define rotator_analog_az A0 // reads analog azimuth voltage from rotator - pin 4 on Yaesu connector
#define azimuth_speed_voltage 0 // optional - PWM output for speed control voltage feed into rotator (on continually unlike rotate_cw_pwm and rotate_ccw_pwm)
#define overlap_led 0 // line goes high when azimuth rotator is in overlap (> 360 rotators)
#define brake_az 13 //0 // goes high to disengage azimuth brake (set to 0 to disable)
#define az_speed_pot 0 //A4 // connect to wiper of 1K to 10K potentiometer for speed control (set to 0 to disable)
#define az_preset_pot 0 // connect to wiper of 1K to 10K potentiometer for preset control (set to 0 to disable)
#define preset_start_button 0 //10 // connect to momentary switch (ground on button press) for preset start (set to 0 to disable or for preset automatic start)
#define button_stop 0 // connect to momentary switch (ground on button press) for preset stop (set to 0 to disable or for preset automatic start)
#define rotation_indication_pin 0
#define az_stepper_motor_pulse 0
#define az_stepper_motor_direction 0
// elevation pins
#ifdef FEATURE_ELEVATION_CONTROL
#define elevation_speed_voltage 0 // optional - PWM output for speed control voltage feed into rotator (on continually unlike rotate_up_pwm and rotate_down_pwm)
#define rotate_up 9//9 // goes high to activate rotator elevation up
#define rotate_down 8 // goes high to activate rotator elevation down
#define rotate_up_or_down 0
#define rotate_up_pwm 0
#define rotate_down_pwm 0
#define rotate_up_down_pwm 0
#define rotate_up_freq 0
#define rotate_down_freq 0
#define rotator_analog_el A1 // reads analog elevation voltage from rotator
#define button_up 0 // normally open button to ground for manual up elevation
#define button_down 0 // normally open button to ground for manual down rotation
#define brake_el 0 // goes high to disengage elevation brake (set to 0 to disable)
#define el_stepper_motor_pulse 0
#define el_stepper_motor_direction 0
#endif //FEATURE_ELEVATION_CONTROL
// rotary encoder pins and options
#ifdef FEATURE_AZ_PRESET_ENCODER
#define az_rotary_preset_pin1 A3 //6 // CW Encoder Pin
#define az_rotary_preset_pin2 A2 //7 // CCW Encoder Pin
#endif //FEATURE_AZ_PRESET_ENCODER
#ifdef FEATURE_EL_PRESET_ENCODER
#define el_rotary_preset_pin1 0 // A3 //6 // UP Encoder Pin
#define el_rotary_preset_pin2 0 // A2 //7 // DOWN Encoder Pin
#endif //FEATURE_EL_PRESET_ENCODER
#ifdef FEATURE_AZ_POSITION_ROTARY_ENCODER
#define az_rotary_position_pin1 A3 // CW Encoder Pin
#define az_rotary_position_pin2 A2 // CCW Encoder Pin
#endif //FEATURE_AZ_POSITION_ROTARY_ENCODER
#ifdef FEATURE_EL_POSITION_ROTARY_ENCODER
#define el_rotary_position_pin1 0 // CW Encoder Pin
#define el_rotary_position_pin2 0 // CCW Encoder Pin
#endif //FEATURE_EL_POSITION_ROTARY_ENCODER
#ifdef FEATURE_AZ_POSITION_PULSE_INPUT
#define az_position_pulse_pin 0 // must be an interrupt capable pin!
#define AZ_POSITION_PULSE_PIN_INTERRUPT 0 // Uno: pin 2 = interrupt 0, pin 3 = interrupt 1
#endif // read http://arduino.cc/en/Reference/AttachInterrupt for details on hardware and interrupts
#ifdef FEATURE_EL_POSITION_PULSE_INPUT
#define el_position_pulse_pin 0 // must be an interrupt capable pin!
#define EL_POSITION_PULSE_PIN_INTERRUPT 1 // Uno: pin 2 = interrupt 0, pin 3 = interrupt 1
#endif // read http://arduino.cc/en/Reference/AttachInterrupt for details on hardware and interrupts
#ifdef FEATURE_PARK
#define button_park 0
#endif
#define lcd_4_bit_rs_pin 12
#define lcd_4_bit_enable_pin 11
#define lcd_4_bit_d4_pin 5
#define lcd_4_bit_d5_pin 4
#define lcd_4_bit_d6_pin 3
#define lcd_4_bit_d7_pin 2
#ifdef FEATURE_JOYSTICK_CONTROL
#define pin_joystick_x A2
#define pin_joystick_y A3
#endif //FEATURE_JOYSTICK_CONTROL
#define blink_led 0 //13
#ifdef FEATURE_AZ_POSITION_HH12_AS5045_SSI
#define az_hh12_clock_pin 11
#define az_hh12_cs_pin 12
#define az_hh12_data_pin 13
#endif //FEATURE_AZ_POSITION_HH_12
#ifdef FEATURE_EL_POSITION_HH12_AS5045_SSI
#define el_hh12_clock_pin 11
#define el_hh12_cs_pin 12
#define el_hh12_data_pin 13
#endif //FEATURE_EL_POSITION_HH_12
#ifdef FEATURE_PARK
#define park_in_progress_pin 0 // goes high when a park has been initiated and rotation is in progress
#define parked_pin 0 // goes high when in a parked position
#endif //FEATURE_PARK
#define heading_reading_inhibit_pin 0 // input - a high will cause the controller to suspend taking azimuth (and elevation) readings; use when RF interferes with sensors
#ifdef FEATURE_LIMIT_SENSE
#define az_limit_sense_pin 0 // input - low stops azimuthal rotation
#define el_limit_sense_pin 0 // input - low stops elevation rotation
#endif //FEATURE_LIMIT_SENSE
#ifdef FEATURE_AZ_POSITION_INCREMENTAL_ENCODER
#define az_incremental_encoder_pin_phase_a 18 //3 must be an interrupt capable pin
#define az_incremental_encoder_pin_phase_b 19 //3 // must be an interrupt capable pin
#define az_incremental_encoder_pin_phase_z 22 //4
#define AZ_POSITION_INCREMENTAL_ENCODER_A_PIN_INTERRUPT 5 //0 // Uno: pin 2 = interrupt 0, pin 3 = interrupt 1 ; Mega: pin 2 = interrupt 0, pin 3 = interrupt 1, pin 21 = interrupt 2, pin 20 = interrupt 3, pin 19 = interrupt 4, pin 18 = interrupt 5
#define AZ_POSITION_INCREMENTAL_ENCODER_B_PIN_INTERRUPT 4 //1 // Uno: pin 2 = interrupt 0, pin 3 = interrupt 1 ; Mega: pin 2 = interrupt 0, pin 3 = interrupt 1, pin 21 = interrupt 2, pin 20 = interrupt 3, pin 19 = interrupt 4, pin 18 = interrupt 5
// read http://arduino.cc/en/Reference/AttachInterrupt for details on hardware and interrupts
#endif //FEATURE_AZ_POSITION_INCREMENTAL_ENCODER
#ifdef FEATURE_EL_POSITION_INCREMENTAL_ENCODER
#define el_incremental_encoder_pin_phase_a 2 //18 //2 // must be an interrupt capable pin
#define el_incremental_encoder_pin_phase_b 3 //19 //3 // must be an interrupt capable pin
#define el_incremental_encoder_pin_phase_z 5 //22 //4
#define EL_POSITION_INCREMENTAL_ENCODER_A_PIN_INTERRUPT 0 //5 //0 // Uno: pin 2 = interrupt 0, pin 3 = interrupt 1 ; Mega: pin 2 = interrupt 0, pin 3 = interrupt 1, pin 21 = interrupt 2, pin 20 = interrupt 3, pin 19 = interrupt 4, pin 18 = interrupt 5
#define EL_POSITION_INCREMENTAL_ENCODER_B_PIN_INTERRUPT 1 //4 //1 // Uno: pin 2 = interrupt 0, pin 3 = interrupt 1 ; Mega: pin 2 = interrupt 0, pin 3 = interrupt 1, pin 21 = interrupt 2, pin 20 = interrupt 3, pin 19 = interrupt 4, pin 18 = interrupt 5
// read http://arduino.cc/en/Reference/AttachInterrupt for details on hardware and interrupts
#endif //FEATURE_EL_POSITION_INCREMENTAL_ENCODER
#ifdef FEATURE_YOURDUINO_I2C_LCD
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#endif //FEATURE_YOURDUINO_I2C_LCD
#ifdef FEATURE_MOON_TRACKING
#define moon_tracking_active_pin 0 // goes high when moon tracking is active
#define moon_tracking_activate_line 0 // ground this pin to activate moon tracking (not for use with a button)
#define moon_tracking_button 0 // use with a normally open momentary switch to ground
#endif //FEATURE_MOON_TRACKING
#ifdef FEATURE_SUN_TRACKING
#define sun_tracking_active_pin 0 // goes high when sun tracking is active
#define sun_tracking_activate_line 0 // ground this pin to activate sun tracking (not for use with a button)
#define sun_tracking_button 0 // use with a normally open momentary switch to ground
#endif //FEATURE_SUN_TRACKING
#ifdef FEATURE_GPS
#define gps_sync 0
#endif //FEATURE_GPS
#ifdef FEATURE_POWER_SWITCH
#define power_switch 0 // use with FEATURE_POWER_SWITCH
#endif //FEATURE_POWER_SWITCH
#ifdef FEATURE_EL_POSITION_MEMSIC_2125
#define pin_memsic_2125_x 0
#define pin_memsic_2125_y 0
#endif //FEATURE_EL_POSITION_MEMSIC_2125

0
rotator_settings.h Normal file → Executable file
View File

0
rotator_settings_ea4tx_ars_usb.h Normal file → Executable file
View File

0
rotator_settings_m0upu.h Normal file → Executable file
View File

603
rotator_settings_test.h Executable file
View File

@ -0,0 +1,603 @@
/* -------------------------- rotation settings ---------------------------------------*/
#define AZIMUTH_STARTING_POINT_DEFAULT 180 // the starting point in degrees of the azimuthal rotator
#define AZIMUTH_ROTATION_CAPABILITY_DEFAULT 450 // the default rotation capability of the rotator in degrees
#define ELEVATION_MAXIMUM_DEGREES 180 // change this to set the maximum elevation in degrees
/* --------------------------- Settings ------------------------------------------------
You can tweak these, but read the online documentation!
*/
// analog voltage calibration - these are default values; you can either tweak these or set via the Yaesu O and F commands (and O2 and F2)....
#define ANALOG_AZ_FULL_CCW 4
#define ANALOG_AZ_FULL_CW 1009
#define ANALOG_EL_0_DEGREES 2
#define ANALOG_EL_MAX_ELEVATION 1018 // maximum elevation is normally 180 degrees unless change below for ELEVATION_MAXIMUM_DEGREES
#define ANALOG_AZ_OVERLAP_DEGREES 540 // if overlap_led above is enabled, turn on overlap led line if azimuth is greater than this setting
// you must use raw azimuth (if the azimuth on the rotator crosses over to 0 degrees, add 360
// for example, on a Yaesu 450 degree rotator with a starting point of 180 degrees, and an overlap LED
// turning on when going CW and crossing 180, ANALOG_AZ_OVERLAP_DEGREES should be set for 540 (180 + 360)
#define OPTION_OVERLAP_LED_BLINK_MS 100
// PWM speed voltage settings
#define PWM_SPEED_VOLTAGE_X1 64 // 0 to 255
#define PWM_SPEED_VOLTAGE_X2 128 // 0 to 255
#define PWM_SPEED_VOLTAGE_X3 191 // 0 to 255
#define PWM_SPEED_VOLTAGE_X4 253 // 0 to 255
//AZ
#define AZ_SLOWSTART_DEFAULT 0 // 0 = off ; 1 = on
#define AZ_SLOWDOWN_DEFAULT 0 // 0 = off ; 1 = on
#define AZ_SLOW_START_UP_TIME 2000 // if slow start is enabled, the unit will ramp up speed for this many milliseconds
#define AZ_SLOW_START_STARTING_PWM 1 // PWM starting value for slow start (must be < 256)
#define AZ_SLOW_START_STEPS 20 // must be < 256
#define SLOW_DOWN_BEFORE_TARGET_AZ 10.0 // if slow down is enabled, slowdown will be activated within this many degrees of target azimuth
#define AZ_SLOW_DOWN_PWM_START 200 // starting PWM value for slow down (must be < 256)
#define AZ_SLOW_DOWN_PWM_STOP 20 // ending PWM value for slow down (must be < 256)
#define AZ_SLOW_DOWN_STEPS 200 //20 // must be < 256
#define AZ_INITIALLY_IN_SLOW_DOWN_PWM 50 // PWM value to start at if we're starting in the slow down zone (1 - 255)
//EL
#define EL_SLOWSTART_DEFAULT 0 // 0 = off ; 1 = on
#define EL_SLOWDOWN_DEFAULT 0 // 0 = off ; 1 = on
#define EL_SLOW_START_UP_TIME 2000 // if slow start is enabled, the unit will ramp up speed for this many milliseconds
#define EL_SLOW_START_STARTING_PWM 1 // PWM starting value for slow start (must be < 256)
#define EL_SLOW_START_STEPS 20 // must be < 256
#define SLOW_DOWN_BEFORE_TARGET_EL 10.0 // if slow down is enabled, slowdown will be activated within this many degrees of target elevation
#define EL_SLOW_DOWN_PWM_START 200 // starting PWM value for slow down (must be < 256)
#define EL_SLOW_DOWN_PWM_STOP 20 // ending PWM value for slow down (must be < 256)
#define EL_SLOW_DOWN_STEPS 20
#define EL_INITIALLY_IN_SLOW_DOWN_PWM 50 // PWM value to start at if we're starting in the slow down zone (1 - 255)
#define TIMED_SLOW_DOWN_TIME 2000
//Variable frequency output settings - LOWEST FREQUENCY IS 31 HERTZ DUE TO ARDUINO tone() FUNCTION LIMITATIONS!
#define AZ_VARIABLE_FREQ_OUTPUT_LOW 31 // Frequency in hertz of minimum speed
#define AZ_VARIABLE_FREQ_OUTPUT_HIGH 5000 //100 // Frequency in hertz of maximum speed
#define EL_VARIABLE_FREQ_OUTPUT_LOW 31 // Frequency in hertz of minimum speed
#define EL_VARIABLE_FREQ_OUTPUT_HIGH 100 // Frequency in hertz of maximum speed
// Settings for OPTION_AZ_MANUAL_ROTATE_LIMITS
#define AZ_MANUAL_ROTATE_CCW_LIMIT 0 // if using a rotator that starts at 180 degrees, set this to something like 185
#define AZ_MANUAL_ROTATE_CW_LIMIT 535 // add 360 to this if you go past 0 degrees (i.e. 180 CW after 0 degrees = 540)
// Settings for OPTION_EL_MANUAL_ROTATE_LIMITS
#define EL_MANUAL_ROTATE_DOWN_LIMIT -1
#define EL_MANUAL_ROTATE_UP_LIMIT 181
// Speed pot settings
#define SPEED_POT_LOW 0
#define SPEED_POT_HIGH 1023
#define SPEED_POT_LOW_MAP 1
#define SPEED_POT_HIGH_MAP 255
// Azimuth preset pot settings
#define AZ_PRESET_POT_FULL_CW 0
#define AZ_PRESET_POT_FULL_CCW 1023
#define AZ_PRESET_POT_FULL_CW_MAP 180 // azimuth pot fully counter-clockwise degrees
#define AZ_PRESET_POT_FULL_CCW_MAP 630 // azimuth pot fully clockwise degrees
#define ENCODER_PRESET_TIMEOUT 5000
// various code settings
#define AZIMUTH_TOLERANCE 3.0 // rotator will stop within X degrees when doing autorotation
#define ELEVATION_TOLERANCE 0.1 //1.0
#define OPERATION_TIMEOUT 120000 // timeout for any rotation operation in mS ; 120 seconds is usually enough unless you have the speed turned down
#define TIMED_INTERVAL_ARRAY_SIZE 20
#define CONTROL_PORT_BAUD_RATE 9600
#define REMOTE_UNIT_PORT_BAUD_RATE 9600
#define GPS_PORT_BAUD_RATE 9600
#define GPS_MIRROR_PORT_BAUD_RATE 9600
#define CONTROL_PORT_MAPPED_TO &Serial // change this line to map the control port to a different serial port (Serial1, Serial2, etc.)
//#define REMOTE_PORT_MAPPED_TO &Serial1 // change this line to map the remote_unit port to a different serial port
#define GPS_PORT_MAPPED_TO &Serial2 // change this line to map the GPS port to a different serial port
//#define GPS_MIRROR_PORT &Serial1 //3 // use this to mirror output from a GPS unit into the Arduino out another port (uncomment to enable)
#define LCD_COLUMNS 16
#define LCD_ROWS 2 // this is automatically set below for HARDWARE_EA4TX_ARS_USB and HARDWARE_M0UPU
#define LCD_UPDATE_TIME 1000 // LCD update time in milliseconds
#define I2C_LCD_COLOR GREEN // default color of I2C LCD display, including Adafruit and Yourduino; some Yourduino may want this as LED_ON
#define LCD_HHMM_CLOCK_POSITION LEFT //LEFT or RIGHT
#define LCD_HHMMSS_CLOCK_POSITION LEFT //LEFT or RIGHT
#define LCD_ALT_HHMM_CLOCK_AND_MAIDENHEAD_POSITION LEFT
#define LCD_ALT_HHMM_CLOCK_AND_MAIDENHEAD_ROW 1
#define LCD_CONSTANT_HHMMSS_CLOCK_AND_MAIDENHEAD_POSITION LEFT
#define LCD_CONSTANT_HHMMSS_CLOCK_AND_MAIDENHEAD_ROW 1
#define LCD_BIG_CLOCK_ROW 4
#define LCD_GPS_INDICATOR_POSITION RIGHT //LEFT or RIGHT
#define LCD_GPS_INDICATOR_ROW 1
#define LCD_MOON_TRACKING_ROW 3 // LCD display row for OPTION_DISPLAY_MOON_TRACKING_CONTINUOUSLY
#define LCD_MOON_TRACKING_UPDATE_INTERVAL 5000
#define LCD_SUN_TRACKING_ROW 4 // LCD display row for OPTION_DISPLAY_SUN_TRACKING_CONTINUOUSLY
#define LCD_SUN_TRACKING_UPDATE_INTERVAL 5000
#define LCD_MOON_OR_SUN_TRACKING_CONDITIONAL_ROW 3 // LCD display row for OPTION_DISPLAY_MOON_OR_SUN_TRACKING_CONDITIONAL
#define SPLASH_SCREEN_TIME 3000
#define AZ_BRAKE_DELAY 3000 // in milliseconds
#define EL_BRAKE_DELAY 3000 // in milliseconds
#define BRAKE_ACTIVE_STATE HIGH
#define BRAKE_INACTIVE_STATE LOW
#define EEPROM_MAGIC_NUMBER 104
#define EEPROM_WRITE_DIRTY_CONFIG_TIME 30 //time in seconds
#if defined(FEATURE_TWO_DECIMAL_PLACE_HEADINGS)
#define HEADING_MULTIPLIER 100L
#define LCD_HEADING_MULTIPLIER 100.0
#define LCD_DECIMAL_PLACES 2
#endif //FEATURE_TWO_DECIMAL_PLACE_HEADINGS
#if defined(FEATURE_ONE_DECIMAL_PLACE_HEADINGS)
#define HEADING_MULTIPLIER 10
#define LCD_HEADING_MULTIPLIER 10.0
#define LCD_DECIMAL_PLACES 1
#endif //FEATURE_ONE_DECIMAL_PLACE_HEADINGS
#if !defined(FEATURE_ONE_DECIMAL_PLACE_HEADINGS) && !defined(FEATURE_TWO_DECIMAL_PLACE_HEADINGS)
#define HEADING_MULTIPLIER 1
#define LCD_HEADING_MULTIPLIER 1.0
#define LCD_DECIMAL_PLACES 0
#endif //!defined(FEATURE_ONE_DECIMAL_PLACE_HEADINGS) && !defined(FEATURE_TWO_DECIMAL_PLACE_HEADINGS)
#define AZ_POSITION_ROTARY_ENCODER_DEG_PER_PULSE 0.5
#define EL_POSITION_ROTARY_ENCODER_DEG_PER_PULSE 0.5
#define AZ_POSITION_PULSE_DEG_PER_PULSE 0.5
#define EL_POSITION_PULSE_DEG_PER_PULSE 0.5
#define PARK_AZIMUTH 360.0 * HEADING_MULTIPLIER // replace the 0.0 with your park azimuth; azimuth is in raw degrees (i.e. on a 180 degree starting point rotator, 0 degrees = 360)
#define PARK_ELEVATION 0.0 * HEADING_MULTIPLIER // replace the 0.0 with your park elevation
#define COMMAND_BUFFER_SIZE 50
#define REMOTE_BUFFER_TIMEOUT_MS 250
#define REMOTE_UNIT_COMMAND_TIMEOUT_MS 2000
#define AZ_REMOTE_UNIT_QUERY_TIME_MS 150 // how often we query the remote remote for azimuth
#define EL_REMOTE_UNIT_QUERY_TIME_MS 150 // how often we query the remote remote for elevation
#define ROTATE_PIN_INACTIVE_VALUE LOW
#define ROTATE_PIN_ACTIVE_VALUE HIGH
#define AZIMUTH_SMOOTHING_FACTOR 0 // value = 0 to 99.9
#define ELEVATION_SMOOTHING_FACTOR 0 // value = 0 to 99.9
#define AZIMUTH_MEASUREMENT_FREQUENCY_MS 100 // this does not apply if using FEATURE_AZ_POSITION_GET_FROM_REMOTE_UNIT
#define ELEVATION_MEASUREMENT_FREQUENCY_MS 100 // this does not apply if using FEATURE_EL_POSITION_GET_FROM_REMOTE_UNIT
#define JOYSTICK_WAIT_TIME_MS 100
#define ROTATION_INDICATOR_PIN_ACTIVE_STATE HIGH
#define ROTATION_INDICATOR_PIN_INACTIVE_STATE LOW
#define ROTATION_INDICATOR_PIN_TIME_DELAY_SECONDS 0
#define ROTATION_INDICATOR_PIN_TIME_DELAY_MINUTES 0
#define AZ_POSITION_INCREMENTAL_ENCODER_PULSES_PER_REV 2000.0
#define EL_POSITION_INCREMENTAL_ENCODER_PULSES_PER_REV 2000.0
#define AZ_INCREMENTAL_ENCODER_ZERO_PULSE_POSITION 0 // can be 0 to 4 x AZ_POSITION_INCREMENTAL_ENCODER_PULSES_PER_REV
#define EL_INCREMENTAL_ENCODER_ZERO_PULSE_POSITION 0 // can be 0 to 4 x EL_POSITION_INCREMENTAL_ENCODER_PULSES_PER_REV
#define SERIAL_LED_TIME_MS 250
#define DEFAULT_LATITUDE 40.889958
#define DEFAULT_LONGITUDE -75.585972
#define MOON_TRACKING_CHECK_INTERVAL 5000
#define MOON_AOS_AZIMUTH_MIN 0
#define MOON_AOS_AZIMUTH_MAX 360
#define MOON_AOS_ELEVATION_MIN 0
#define MOON_AOS_ELEVATION_MAX 180
#define SUN_TRACKING_CHECK_INTERVAL 5000
#define SUN_AOS_AZIMUTH_MIN 0
#define SUN_AOS_AZIMUTH_MAX 360
#define SUN_AOS_ELEVATION_MIN 0
#define SUN_AOS_ELEVATION_MAX 180
#ifdef LANGUAGE_ENGLISH // English language support (copy leading and trailing spaces when making your own language section)
#define MOON_STRING "moon "
#define SUN_STRING "sun "
#define AZ_TARGET_STRING "Az Target "
#define EL_TARGET_STRING "El Target "
#define TARGET_STRING "Target "
#define PARKED_STRING "Parked"
#define ROTATING_CW_STRING "Rotating CW"
#define ROTATING_CCW_STRING "Rotating CCW"
#define ROTATING_TO_STRING "Rotating to "
#define ELEVATING_TO_STRING "Elevating to "
#define ELEVATING_UP_STRING "Elevating Up"
#define ELEVATING_DOWN_STRING "Elevating Down"
#define ROTATING_STRING "Rotating "
#define CW_STRING "CW"
#define CCW_STRING "CCW"
#define UP_STRING "UP"
#define DOWN_STRING "DOWN"
#define AZIMUTH_STRING "Azimuth "
#define AZ_STRING "Az"
#define AZ_SPACE_STRING "Az "
#define SPACE_EL_STRING " El"
#define SPACE_EL_SPACE_STRING " El "
#define GPS_STRING "GPS"
#define N_STRING "N"
#define W_STRING "W"
#define S_STRING "S"
#define E_STRING "E"
#define NW_STRING "NW"
#define SW_STRING "SW"
#define SE_STRING "SE"
#define NE_STRING "NE"
#define NNW_STRING "NNW"
#define WNW_STRING "WNW"
#define WSW_STRING "WSW"
#define SSW_STRING "SSW"
#define SSE_STRING "SSE"
#define ESE_STRING "ESE"
#define ENE_STRING "ENE"
#define NNE_STRING "NNE"
#endif //LANGUAGE_ENGLISH
#ifdef LANGUAGE_SPANISH // Courtesy of Maximo, EA1DDO
#define MOON_STRING "Luna "
#define SUN_STRING "Sol "
#define AZ_TARGET_STRING "Az Objetivo "
#define EL_TARGET_STRING "El Objetivo "
#define TARGET_STRING "Objetivo "
#define PARKED_STRING "Aparcado"
#define ROTATING_CW_STRING "Girando Dcha"
#define ROTATING_CCW_STRING "Girando Izq"
#define ROTATING_TO_STRING "Girando a "
#define ELEVATING_TO_STRING "Elevando a "
#define ELEVATING_UP_STRING "Subiendo"
#define ELEVATING_DOWN_STRING "Bajando"
#define ROTATING_STRING "Girando "
#define CW_STRING "Dcha"
#define CCW_STRING "Izq"
#define UP_STRING "Arriba"
#define DOWN_STRING "Abajo"
#define AZIMUTH_STRING "Azimuth "
#define AZ_STRING "Az"
#define AZ_SPACE_STRING "Az "
#define SPACE_EL_STRING " El"
#define SPACE_EL_SPACE_STRING " El "
#define GPS_STRING "GPS"
#define N_STRING "N"
#define W_STRING "O"
#define S_STRING "S"
#define E_STRING "E"
#define NW_STRING "NO"
#define SW_STRING "SO"
#define SE_STRING "SE"
#define NE_STRING "NE"
#define NNW_STRING "NNO"
#define WNW_STRING "ONO"
#define WSW_STRING "OSO"
#define SSW_STRING "SSO"
#define SSE_STRING "SSE"
#define ESE_STRING "ESE"
#define ENE_STRING "ENE"
#define NNE_STRING "NNE"
#endif //LANGUAGE_SPANISH
#ifdef LANGUAGE_CZECH // courtesy of Jan, OK2ZAW
#define MOON_STRING "mesic "
#define SUN_STRING "slunce "
#define AZ_TARGET_STRING "Az cíl "
#define EL_TARGET_STRING "El cíl "
#define TARGET_STRING "Cil "
#define PARKED_STRING "Parkovat"
#define ROTATING_CW_STRING "Otacim CW"
#define ROTATING_CCW_STRING "Otacim CCW"
#define ROTATING_TO_STRING "Otacim na "
#define ELEVATING_TO_STRING "Elevovat na "
#define ELEVATING_UP_STRING "Elevovat nahoru"
#define ELEVATING_DOWN_STRING "Elevovat dolu"
#define ROTATING_STRING "Otacet "
#define CW_STRING "CW"
#define CCW_STRING "CCW"
#define UP_STRING "Nahoru"
#define DOWN_STRING "Dolu"
#define AZIMUTH_STRING "Azimut "
#define AZ_STRING "Az"
#define AZ_SPACE_STRING "Az "
#define SPACE_EL_STRING " El"
#define SPACE_EL_SPACE_STRING " El "
#define GPS_STRING "GPS"
#define N_STRING "smer ^ KL"
#define W_STRING "smer < HK"
#define S_STRING "smer v ZS"
#define E_STRING "smer > VK"
#define NW_STRING "smer < W"
#define SW_STRING "smer v VP8"
#define SE_STRING "smer > HZ"
#define NE_STRING "smer ^ JA"
#define NNW_STRING "smer ^ VE"
#define WNW_STRING "smer < CO"
#define WSW_STRING "smer < PY"
#define SSW_STRING "smer v ZD9"
#define SSE_STRING "smer v 5R"
#define ESE_STRING "smer > 8Q"
#define ENE_STRING "smer > ZL"
#define NNE_STRING "smer ^ UA0"
#endif //LANGUAGE_CZECH
#ifdef LANGUAGE_ITALIAN // courtesy of Paolo, IT9IPQ
#define MOON_STRING "luna"
#define SUN_STRING "sole "
#define AZ_TARGET_STRING "Punta Az "
#define EL_TARGET_STRING "Punta El "
#define TARGET_STRING "Punta "
#define PARKED_STRING "Posa "
#define ROTATING_CW_STRING "Ruota DX > "
#define ROTATING_CCW_STRING "Ruota SX < "
#define ROTATING_TO_STRING "Ruota verso "
#define ELEVATING_TO_STRING "Alza verso "
#define ELEVATING_UP_STRING "Alzo Su "
#define ELEVATING_DOWN_STRING "Abbasso Giu' "
#define ROTATING_STRING "Ruota "
#define CW_STRING "DX"
#define CCW_STRING "SX "
#define UP_STRING "SU"
#define DOWN_STRING "GIU'"
#define AZIMUTH_STRING "Azimuth "
#define AZ_STRING "Az"
#define AZ_SPACE_STRING "Az "
#define SPACE_EL_STRING " El"
#define SPACE_EL_SPACE_STRING " El "
#define GPS_STRING "GPS"
#define N_STRING "N"
#define W_STRING "W"
#define S_STRING "S"
#define E_STRING "E"
#define NW_STRING "NW"
#define SW_STRING "SW"
#define SE_STRING "SE"
#define NE_STRING "NE"
#define NNW_STRING "NNW"
#define WNW_STRING "WNW"
#define WSW_STRING "WSW"
#define SSW_STRING "SSW"
#define SSE_STRING "SSE"
#define ESE_STRING "ESE"
#define ENE_STRING "ENE"
#define NNE_STRING "NNE"
#endif //LANGUAGE_ITALIAN
#ifdef LANGUAGE_PORTUGUESE_BRASIL // courtesy of Ismael, PY4PI
#define MOON_STRING "lua "
#define SUN_STRING "sol "
#define AZ_TARGET_STRING "Objetivo Az "
#define EL_TARGET_STRING "Objetivo El "
#define TARGET_STRING "Objetivo "
#define PARKED_STRING "Estacionado"
#define ROTATING_CW_STRING "Rodando DIR"
#define ROTATING_CCW_STRING "Rodando ESQ"
#define ROTATING_TO_STRING "Rodando para "
#define ELEVATING_TO_STRING "Elevando para "
#define ELEVATING_UP_STRING "Subindo"
#define ELEVATING_DOWN_STRING "Descendo"
#define ROTATING_STRING "Rodando "
#define CW_STRING "DIR"
#define CCW_STRING "ESQ"
#define UP_STRING "SOBE"
#define DOWN_STRING "DESCE"
#define AZIMUTH_STRING "Azimute "
#define AZ_STRING "Az"
#define AZ_SPACE_STRING "Az "
#define SPACE_EL_STRING " El"
#define SPACE_EL_SPACE_STRING " El "
#define GPS_STRING "GPS"
#define N_STRING "N"
#define W_STRING "O"
#define S_STRING "S"
#define E_STRING "L"
#define NW_STRING "NO"
#define SW_STRING "SO"
#define SE_STRING "SL"
#define NE_STRING "NL"
#define NNW_STRING "NNO"
#define WNW_STRING "ONO"
#define WSW_STRING "OSO"
#define SSW_STRING "SSO"
#define SSE_STRING "SSL"
#define ESE_STRING "LSL"
#define ENE_STRING "LNL"
#define NNE_STRING "NNL"
#endif //LANGUAGE_PORTUGUESE_BRASIL
#define TRACKING_ACTIVE_CHAR "*"
#define TRACKING_INACTIVE_CHAR "-"
#define DISPLAY_DEGREES_STRING "\xDF"
#define INTERNAL_CLOCK_CORRECTION 0.00145
#define SYNC_TIME_WITH_GPS 1
#define SYNC_COORDINATES_WITH_GPS 1
#define GPS_SYNC_PERIOD_SECONDS 10 // how long to consider internal clock syncronized after a GPS reading
#define GPS_VALID_FIX_AGE_MS 10000 // consider a GPS reading valid if the fix age is less than this
#define GPS_UPDATE_LATENCY_COMPENSATION_MS 200
#define SYNC_WITH_RTC_SECONDS 59 // syncronize internal clock with realtime clock every x seconds
#define SYNC_RTC_TO_GPS_SECONDS 12 // synchronize realtime clock to GPS every x seconds
#define SYNC_MASTER_CLOCK_TO_SLAVE_CLOCK_SECS 10 // for OPTION_SYNC_MASTER_CLOCK_TO_SLAVE - use when GPS unit is connected to slave unit and you want to synchronize the master unit clock to the slave unit clock
#define SYNC_MASTER_COORDINATES_TO_SLAVE_SECS 20 // for OPTION_SYNC_MASTER_COORDINATES_TO_SLAVE - use when GPS unit is connected to slave unit and you want to synchronize the master unit coordinates to the slave unit GPS
#define ETHERNET_MAC_ADDRESS 0xDE,0xAD,0xBE,0xEF,0xFE,0xEE //<-DON'T FORGET TO USE DIFFERENT MAC ADDRESSES FOR MASTER AND SLAVE!!!
#define ETHERNET_IP_ADDRESS 192,168,1,172 //<-DON'T FORGET TO USE DIFFERENT IP ADDRESSES FOR MASTER AND SLAVE!!!
#define ETHERNET_IP_GATEWAY 192,168,1,1
#define ETHERNET_IP_SUBNET_MASK 255,255,255,0
#define ETHERNET_TCP_PORT_0 23
#define ETHERNET_TCP_PORT_1 24
#define ETHERNET_MESSAGE_TIMEOUT_MS 5000
#define ETHERNET_PREAMBLE "K3NG" // used only with Ethernet master/slave link
#define ETHERNET_SLAVE_IP_ADDRESS 192,168,1,173
#define ETHERNET_SLAVE_TCP_PORT 23
#define ETHERNET_SLAVE_RECONNECT_TIME_MS 250
#define POWER_SWITCH_IDLE_TIMEOUT 15 // use with FEATURE_POWER_SWITCH; units are minutes
#ifdef HARDWARE_EA4TX_ARS_USB
#define BUTTON_ACTIVE_STATE HIGH
#define BUTTON_INACTIVE_STATE LOW
#else
#define BUTTON_ACTIVE_STATE LOW
#define BUTTON_INACTIVE_STATE HIGH
#endif
/*
*
* Azimuth and Elevation calibraton tables - use with FEATURE_AZIMUTH_CORRECTION and/or FEATURE_ELEVATION_CORRECTION
*
* You must have the same number of entries in the _FROM_ and _TO_ arrays!
*
*/
#define AZIMUTH_CALIBRATION_FROM_ARRAY {180,630} /* these are in "raw" degrees, i.e. when going east past 360 degrees, add 360 degrees*/
#define AZIMUTH_CALIBRATION_TO_ARRAY {180,630}
// example: reverse rotation sensing
// #define AZIMUTH_CALIBRATION_FROM_ARRAY {0,359}
// #define AZIMUTH_CALIBRATION_TO_ARRAY {359,0}
#define ELEVATION_CALIBRATION_FROM_ARRAY {-180,0,180}
#define ELEVATION_CALIBRATION_TO_ARRAY {-180,0,180}
#define ANALOG_OUTPUT_MAX_EL_DEGREES 180
#define EL_POSITION_PULSE_DEBOUNCE 500 // in ms
/* Pololu LSM303 Calibration tables
*
*
* For use with FEATURE_AZ_POSITION_POLOLU_LSM303 and/or FEATURE_EL_POSITION_POLOLU_LSM303
*
Calibration values; the default values of +/-32767 for each axis
lead to an assumed magnetometer bias of 0. Use the Calibrate example
program to determine appropriate values for your particular unit.
min: { +59, +19, -731} max: { +909, +491, +14}
min: {32767, 32767, 32767} max: {-32768, -32768, -32768}
*/
#define POLOLU_LSM_303_MIN_ARRAY {+59, +19, -731}
#define POLOLU_LSM_303_MAX_ARRAY {+909, +491, +14}
#define AUTOCORRECT_TIME_MS_AZ 1000
#define AUTOCORRECT_TIME_MS_EL 1000
/* ---------------------------- object declarations ----------------------------------------------
Object declarations are required for several devices, including LCD displays, compass devices, and accelerometers
*/
#if !defined(UNDER_DEVELOPMENT_K3NGDISPLAY_LIBRARY)
#if defined(FEATURE_4_BIT_LCD_DISPLAY)
LiquidCrystal lcd(lcd_4_bit_rs_pin, lcd_4_bit_enable_pin, lcd_4_bit_d4_pin, lcd_4_bit_d5_pin, lcd_4_bit_d6_pin, lcd_4_bit_d7_pin);
#endif //FEATURE_4_BIT_LCD_DISPLAY
#ifdef FEATURE_ADAFRUIT_I2C_LCD
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#endif //FEATURE_ADAFRUIT_I2C_LCD
#ifdef FEATURE_YOURDUINO_I2C_LCD
#define I2C_ADDR 0x20
#define BACKLIGHT_PIN 3
#define LED_OFF 1
#define LED_ON 0
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
#endif //FEATURE_YOURDUINO_I2C_LCD
#ifdef FEATURE_RFROBOT_I2C_DISPLAY
LiquidCrystal_I2C lcd(0x27,16,2);
#endif //FEATURE_RFROBOT_I2C_DISPLAY
#ifdef FEATURE_YWROBOT_I2C_DISPLAY
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
#endif //FEATURE_YWROBOT_I2C_DISPLAY
#else
K3NGdisplay k3ngdisplay(LCD_COLUMNS,LCD_ROWS,LCD_UPDATE_TIME);
#endif //!defined(UNDER_DEVELOPMENT_K3NGDISPLAY_LIBRARY)
#ifdef FEATURE_AZ_POSITION_HMC5883L
HMC5883L compass;
#endif //FEATURE_AZ_POSITION_HMC5883L
#ifdef FEATURE_EL_POSITION_ADXL345_USING_LOVE_ELECTRON_LIB
ADXL345 accel;
#endif //FEATURE_EL_POSITION_ADXL345_USING_LOVE_ELECTRON_LIB
#ifdef FEATURE_EL_POSITION_ADXL345_USING_ADAFRUIT_LIB
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);
#endif //FEATURE_EL_POSITION_ADXL345_USING_ADAFRUIT_LIB
#if defined(FEATURE_EL_POSITION_ADAFRUIT_LSM303) || defined(FEATURE_AZ_POSITION_ADAFRUIT_LSM303)
Adafruit_LSM303 lsm;
#endif
#if defined(FEATURE_AZ_POSITION_POLOLU_LSM303) || defined(FEATURE_EL_POSITION_POLOLU_LSM303)
LSM303 compass;
LSM303::vector<int16_t> running_min = {32767, 32767, 32767}, running_max = {-32768, -32768, -32768};
char report[80];
#endif //FEATURE_AZ_POSITION_POLOLU_LSM303
#ifdef FEATURE_AZ_POSITION_HH12_AS5045_SSI
#include "hh12.h"
hh12 azimuth_hh12;
#endif //FEATURE_AZ_POSITION_HH12_AS5045_SSI
#ifdef FEATURE_EL_POSITION_HH12_AS5045_SSI
#include "hh12.h"
hh12 elevation_hh12;
#endif //FEATURE_EL_POSITION_HH12_AS5045_SSI
#ifdef FEATURE_GPS
TinyGPS gps;
#endif //FEATURE_GPS
#ifdef FEATURE_RTC_DS1307
RTC_DS1307 rtc;
#endif //FEATURE_RTC_DS1307
#ifdef FEATURE_RTC_PCF8583
PCF8583 rtc(0xA0);
#endif //FEATURE_RTC_PCF8583
#ifdef HARDWARE_EA4TX_ARS_USB
#undef LCD_COLUMNS
#undef LCD_ROWS
#define LCD_COLUMNS 16
#define LCD_ROWS 2
#endif //HARDWARE_EA4TX_ARS_USB
#ifdef HARDWARE_M0UPU
#undef LCD_ROWS
#define LCD_ROWS 2
#endif //HARDWARE_M0UPU

0
rotator_settings_wb6kcn.h Normal file → Executable file
View File

95
rotator_stepper.h Normal file
View File

@ -0,0 +1,95 @@
//------------------------------------------------------
#if defined(FEATURE_STEPPER_MOTOR)
void service_stepper_motor_pulse_pins(){
service_stepper_motor_pulse_pins_count++;
static unsigned int az_stepper_pin_transition_counter = 0;
static byte az_stepper_pin_last_state = LOW;
if (az_stepper_freq_count > 0){
az_stepper_pin_transition_counter++;
if (az_stepper_pin_transition_counter >= az_stepper_freq_count){
if (az_stepper_pin_last_state == LOW){
digitalWrite(az_stepper_motor_pulse,HIGH);
az_stepper_pin_last_state = HIGH;
} else {
digitalWrite(az_stepper_motor_pulse,LOW);
az_stepper_pin_last_state = LOW;
}
az_stepper_pin_transition_counter = 0;
}
} else {
az_stepper_pin_transition_counter = 0;
}
#ifdef FEATURE_ELEVATION_CONTROL
static unsigned int el_stepper_pin_transition_counter = 0;
static byte el_stepper_pin_last_state = LOW;
if (el_stepper_freq_count > 0){
el_stepper_pin_transition_counter++;
if (el_stepper_pin_transition_counter >= el_stepper_freq_count){
if (el_stepper_pin_last_state == LOW){
digitalWrite(el_stepper_motor_pulse,HIGH);
el_stepper_pin_last_state = HIGH;
} else {
digitalWrite(el_stepper_motor_pulse,LOW);
el_stepper_pin_last_state = LOW;
}
el_stepper_pin_transition_counter = 0;
}
} else {
el_stepper_pin_transition_counter = 0;
}
#endif //FEATURE_ELEVATION_CONTROL
}
#endif //defined(FEATURE_STEPPER_MOTOR)
//------------------------------------------------------
#ifdef FEATURE_STEPPER_MOTOR
void set_az_stepper_freq(unsigned int frequency){
if (frequency > 0) {
az_stepper_freq_count = 2000 / frequency;
} else {
az_stepper_freq_count = 0;
}
#ifdef DEBUG_STEPPER
debug_print("set_az_stepper_freq: ");
debug_print_int(frequency);
debug_print(" az_stepper_freq_count:");
debug_print_int(az_stepper_freq_count);
debug_println("");
#endif //DEBUG_STEPPER
}
#endif //FEATURE_STEPPER_MOTOR
//------------------------------------------------------
#if defined(FEATURE_ELEVATION_CONTROL) && defined(FEATURE_STEPPER_MOTOR)
void set_el_stepper_freq(unsigned int frequency){
if (frequency > 0) {
el_stepper_freq_count = 2000 / frequency;
} else {
el_stepper_freq_count = 0;
}
#ifdef DEBUG_STEPPER
debug_print("set_el_stepper_freq: ");
debug_print_int(frequency);
debug_print(" el_stepper_freq_count:");
debug_print_int(el_stepper_freq_count);
debug_println("");
#endif //DEBUG_STEPPER
}
#endif //defined(FEATURE_ELEVATION_CONTROL) && defined(FEATURE_STEPPER_MOTOR)
//------------------------------------------------------