2.0.2015111501

Fixed issues with compilation under Arduino 1.6.6
This commit is contained in:
Anthony Good 2015-11-15 17:43:07 -05:00
parent 938f298eec
commit ce1b89de7f
9 changed files with 3044 additions and 3049 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,369 +0,0 @@
#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(fix_age);
debug.print(" lat:");
debug.print(gps_lat,4);
debug.print(" long:");
debug.print(gps_lon,4);
debug.print(" ");
debug.print(gps_year);
debug.print("-");
debug.print(gps_month);
debug.print("-");
debug.print(gps_day);
debug.print(" ");
debug.print(gps_hours);
debug.print(":");
debug.print(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(latitude,2);
debug.print(" ");
debug.print(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_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(now.year());
debug.print("/");
debug.print(now.month());
debug.print("/");
debug.print(now.day());
debug.print(" ");
debug.print(now.hour());
debug.print(":");
debug.print(now.minute());
debug.print(":");
debug.print(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
// --------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -1,266 +0,0 @@
#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) 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) 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(incoming_ethernet_byte);
debug.print(" : ");
debug.print(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
//-------------------------------------------------------

View File

@ -8,7 +8,7 @@
#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_EASYCOM_EMULATION // Easycom protocol emulation on control port (undefine FEATURE_YAESU_EMULATION above)
#define FEATURE_MOON_TRACKING
#define FEATURE_SUN_TRACKING
@ -60,21 +60,21 @@
//#define FEATURE_EL_POSITION_A2_ABSOLUTE_ENCODER
// All displays require k3ngdisplay.h and k3ngdisplay.cpp in the ino directory!
#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
//#define FEATURE_RFROBOT_I2C_DISPLAY
//#define FEATURE_YWROBOT_I2C_DISPLAY
#define FEATURE_ANALOG_OUTPUT_PINS
// #define FEATURE_ANALOG_OUTPUT_PINS
#define FEATURE_SUN_PUSHBUTTON_AZ_EL_CALIBRATION
#define FEATURE_MOON_PUSHBUTTON_AZ_EL_CALIBRATION
// #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 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
@ -89,10 +89,10 @@
#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 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 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)
@ -103,9 +103,9 @@
//#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_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
@ -135,8 +135,8 @@
//#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_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

View File

@ -1,271 +0,0 @@
#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
debug.print(F("service_moon_tracking: AZ: "));
debug.print(moon_azimuth);
debug.print(" EL: ");
debug.print(moon_elevation);
debug.print(" lat: ");
debug.print(latitude);
debug.print(" long: ");
debug.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
debug.println("service_moon_tracking: moon AOS");
#endif // DEBUG_MOON_TRACKING
}
} else {
if (moon_visible) {
moon_visible = 0;
#ifdef DEBUG_MOON_TRACKING
debug.println("service_moon_tracking: moon loss of AOS");
#endif // DEBUG_MOON_TRACKING
} else {
#ifdef DEBUG_MOON_TRACKING
debug.println("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
debug.print(F("service_sun_tracking: AZ: "));
debug.print(sun_azimuth);
debug.print(" EL: ");
debug.print(sun_elevation);
debug.print(" lat: ");
debug.print(latitude);
debug.print(" long: ");
debug.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
debug.println("service_sun_tracking: sun AOS");
#endif // DEBUG_SUN_TRACKING
}
} else {
if (sun_visible) {
sun_visible = 0;
#ifdef DEBUG_SUN_TRACKING
debug.println("service_sun_tracking: sun loss of AOS");
#endif // DEBUG_SUN_TRACKING
} else {
#ifdef DEBUG_SUN_TRACKING
debug.println("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
// --------------------------------------------------------------

View File

@ -17,8 +17,8 @@
#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 A3 //6 // goes high to activate rotator R (CW) rotation - pin 1 on Yaesu connector
#define rotate_ccw A2 //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)
@ -44,8 +44,8 @@
// 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 A5 //9//9 // goes high to activate rotator elevation up
#define rotate_down A4 //8 // goes high to activate rotator elevation down
#define rotate_up_or_down 0
#define rotate_up_pwm 0
#define rotate_down_pwm 0

View File

@ -7,7 +7,7 @@
/* -------------------------- rotation settings ---------------------------------------*/
#define AZIMUTH_STARTING_POINT_DEFAULT 180 // the starting point in degrees of the azimuthal rotator
#define AZIMUTH_STARTING_POINT_DEFAULT 0 //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
@ -20,10 +20,10 @@ 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_FULL_CCW 2 //4
#define ANALOG_AZ_FULL_CW 1020 //1009
#define ANALOG_EL_0_DEGREES 6 //2
#define ANALOG_EL_MAX_ELEVATION 1019 //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

View File

@ -1,95 +0,0 @@
//------------------------------------------------------
#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(frequency);
debug.print(" az_stepper_freq_count:");
debug.print(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(frequency);
debug.print(" el_stepper_freq_count:");
debug.print(el_stepper_freq_count);
debug.println("");
#endif //DEBUG_STEPPER
}
#endif //defined(FEATURE_ELEVATION_CONTROL) && defined(FEATURE_STEPPER_MOTOR)
//------------------------------------------------------