2018.02.02.01

Minor updates to DEBUG_ACCEL
This commit is contained in:
Anthony Good 2018-02-02 18:35:09 -05:00
parent 6f000b3a79
commit db699f743e

View File

@ -333,6 +333,9 @@
2018.02.01.01
Added serial port support for ARDUINO_MAPLE_MINI,ARDUINO_AVR_PROMICRO,ARDUINO_AVR_LEONARDO,ARDUINO_AVR_MICRO,ARDUINO_AVR_YUN,ARDUINO_AVR_ESPLORA,ARDUINO_AVR_LILYPAD_USB,ARDUINO_AVR_ROBOT_CONTROL,ARDUINO_AVR_ROBOT_MOTOR,ARDUINO_AVR_LEONARDO_ETH,TEENSYDUINO
2018.02.02.01
Minor updates to DEBUG_ACCEL
All library files should be placed in directories likes \sketchbook\libraries\library1\ , \sketchbook\libraries\library2\ , etc.
Anything rotator_*.* should be in the ino directory!
@ -342,7 +345,7 @@
*/
#define CODE_VERSION "2018.02.01.01"
#define CODE_VERSION "2018.02.02.01"
#include <avr/pgmspace.h>
#include <EEPROM.h>
@ -5582,7 +5585,7 @@ void el_check_operation_timeout(){
void read_elevation(byte force_read){
#ifdef FEATURE_EL_POSITION_INCREMENTAL_ENCODER
read_elevation_lock = 1;
read_elevation_lock = 1;
#endif
@ -5590,7 +5593,7 @@ void read_elevation(byte force_read){
static unsigned long last_measurement_time = 0;
#ifdef FEATURE_EL_POSITION_INCREMENTAL_ENCODER
static unsigned int incremental_encoder_previous_elevation = elevation;
static unsigned int incremental_encoder_previous_elevation = elevation;
#endif
if (heading_reading_inhibit_pin) {
@ -5600,13 +5603,13 @@ void read_elevation(byte force_read){
}
#ifdef DEBUG_HEADING_READING_TIME
static unsigned long last_time = 0;
static unsigned long last_print_time = 0;
static float average_read_time = 0;
static unsigned long last_time = 0;
static unsigned long last_print_time = 0;
static float average_read_time = 0;
#endif // DEBUG_HEADING_READING_TIME
#ifdef DEBUG_HH12
static unsigned long last_hh12_debug = 0;
static unsigned long last_hh12_debug = 0;
#endif // DEBUG_HH12
#ifndef FEATURE_EL_POSITION_GET_FROM_REMOTE_UNIT
@ -5616,56 +5619,56 @@ void read_elevation(byte force_read){
#endif
#ifdef FEATURE_EL_POSITION_POTENTIOMETER
analog_el = analogReadEnhanced(rotator_analog_el);
elevation = (map(analog_el, configuration.analog_el_0_degrees, configuration.analog_el_max_elevation, 0, (ELEVATION_MAXIMUM_DEGREES * HEADING_MULTIPLIER)));
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif // FEATURE_ELEVATION_CORRECTION
elevation = elevation + (configuration.elevation_offset * HEADING_MULTIPLIER);
if (ELEVATION_SMOOTHING_FACTOR > 0) {
elevation = (elevation * (1 - (ELEVATION_SMOOTHING_FACTOR / 100))) + (previous_elevation * (ELEVATION_SMOOTHING_FACTOR / 100));
}
if (elevation < 0) {
elevation = 0;
}
analog_el = analogReadEnhanced(rotator_analog_el);
elevation = (map(analog_el, configuration.analog_el_0_degrees, configuration.analog_el_max_elevation, 0, (ELEVATION_MAXIMUM_DEGREES * HEADING_MULTIPLIER)));
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif // FEATURE_ELEVATION_CORRECTION
elevation = elevation + (configuration.elevation_offset * HEADING_MULTIPLIER);
if (ELEVATION_SMOOTHING_FACTOR > 0) {
elevation = (elevation * (1 - (ELEVATION_SMOOTHING_FACTOR / 100))) + (previous_elevation * (ELEVATION_SMOOTHING_FACTOR / 100));
}
if (elevation < 0) {
elevation = 0;
}
#endif // FEATURE_EL_POSITION_POTENTIOMETER
#ifdef FEATURE_EL_POSITION_ROTARY_ENCODER
static byte el_position_encoder_state = 0;
el_position_encoder_state = ttable[el_position_encoder_state & 0xf][((digitalReadEnhanced(el_rotary_position_pin2) << 1) | digitalReadEnhanced(el_rotary_position_pin1))];
byte el_position_encoder_result = el_position_encoder_state & 0x30;
if (el_position_encoder_result) {
if (el_position_encoder_result == DIR_CW) {
configuration.last_elevation = configuration.last_elevation + EL_POSITION_ROTARY_ENCODER_DEG_PER_PULSE;
#ifdef DEBUG_POSITION_ROTARY_ENCODER
if (debug_mode) {
debug.print(F("read_elevation: EL_POSITION_ROTARY_ENCODER: CW/UP\n"));
static byte el_position_encoder_state = 0;
el_position_encoder_state = ttable[el_position_encoder_state & 0xf][((digitalReadEnhanced(el_rotary_position_pin2) << 1) | digitalReadEnhanced(el_rotary_position_pin1))];
byte el_position_encoder_result = el_position_encoder_state & 0x30;
if (el_position_encoder_result) {
if (el_position_encoder_result == DIR_CW) {
configuration.last_elevation = configuration.last_elevation + EL_POSITION_ROTARY_ENCODER_DEG_PER_PULSE;
#ifdef DEBUG_POSITION_ROTARY_ENCODER
if (debug_mode) {
debug.print(F("read_elevation: EL_POSITION_ROTARY_ENCODER: CW/UP\n"));
}
#endif // DEBUG_POSITION_ROTARY_ENCODER
}
#endif // DEBUG_POSITION_ROTARY_ENCODER
}
if (el_position_encoder_result == DIR_CCW) {
configuration.last_elevation = configuration.last_elevation - EL_POSITION_ROTARY_ENCODER_DEG_PER_PULSE;
#ifdef DEBUG_POSITION_ROTARY_ENCODER
if (debug_mode) {
debug.print(F("read_elevation: EL_POSITION_ROTARY_ENCODER: CCW/DWN\n"));
if (el_position_encoder_result == DIR_CCW) {
configuration.last_elevation = configuration.last_elevation - EL_POSITION_ROTARY_ENCODER_DEG_PER_PULSE;
#ifdef DEBUG_POSITION_ROTARY_ENCODER
if (debug_mode) {
debug.print(F("read_elevation: EL_POSITION_ROTARY_ENCODER: CCW/DWN\n"));
}
#endif // DEBUG_POSITION_ROTARY_ENCODER
}
#endif // DEBUG_POSITION_ROTARY_ENCODER
#ifdef OPTION_EL_POSITION_ROTARY_ENCODER_HARD_LIMIT
if (configuration.last_elevation < 0) {
configuration.last_elevation = 0;
}
if (configuration.last_elevation > ELEVATION_MAXIMUM_DEGREES) {
configuration.last_elevation = ELEVATION_MAXIMUM_DEGREES;
}
#endif
elevation = int(configuration.last_elevation * HEADING_MULTIPLIER);
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif // FEATURE_ELEVATION_CORRECTION
configuration_dirty = 1;
}
#ifdef OPTION_EL_POSITION_ROTARY_ENCODER_HARD_LIMIT
if (configuration.last_elevation < 0) {
configuration.last_elevation = 0;
}
if (configuration.last_elevation > ELEVATION_MAXIMUM_DEGREES) {
configuration.last_elevation = ELEVATION_MAXIMUM_DEGREES;
}
#endif
elevation = int(configuration.last_elevation * HEADING_MULTIPLIER);
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif // FEATURE_ELEVATION_CORRECTION
configuration_dirty = 1;
}
#endif // FEATURE_EL_POSITION_ROTARY_ENCODER
@ -5724,74 +5727,78 @@ void read_elevation(byte force_read){
#endif // FEATURE_EL_POSITION_ROTARY_ENCODER_USE_PJRC_LIBRARY
#ifdef FEATURE_EL_POSITION_ADXL345_USING_LOVE_ELECTRON_LIB
AccelerometerRaw raw = accel.ReadRawAxis();
AccelerometerScaled scaled = accel.ReadScaledAxis();
#ifdef DEBUG_ACCEL
if (debug_mode) {
debug.print(F("read_elevation: raw.ZAxis: "));
debug.println(raw.ZAxis);
}
#endif // DEBUG_ACCEL
elevation = (atan2(scaled.YAxis, scaled.ZAxis) * 180 * HEADING_MULTIPLIER) / M_PI;
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif // FEATURE_ELEVATION_CORRECTION
elevation = elevation + (configuration.elevation_offset * HEADING_MULTIPLIER);
if (ELEVATION_SMOOTHING_FACTOR > 0) {
elevation = (elevation * (1 - (ELEVATION_SMOOTHING_FACTOR / 100))) + (previous_elevation * (ELEVATION_SMOOTHING_FACTOR / 100));
}
AccelerometerRaw raw = accel.ReadRawAxis();
AccelerometerScaled scaled = accel.ReadScaledAxis();
#ifdef DEBUG_ACCEL
if (debug_mode) {
debug.print(F("read_elevation: raw.YAxis: "));
debug.print(raw.yAxis);
debug.print(F(" ZAxis: "));
debug.println(raw.ZAxis);
}
#endif // DEBUG_ACCEL
elevation = (atan2(scaled.YAxis, scaled.ZAxis) * 180 * HEADING_MULTIPLIER) / M_PI;
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif // FEATURE_ELEVATION_CORRECTION
elevation = elevation + (configuration.elevation_offset * HEADING_MULTIPLIER);
if (ELEVATION_SMOOTHING_FACTOR > 0) {
elevation = (elevation * (1 - (ELEVATION_SMOOTHING_FACTOR / 100))) + (previous_elevation * (ELEVATION_SMOOTHING_FACTOR / 100));
}
#endif // FEATURE_EL_POSITION_ADXL345_USING_LOVE_ELECTRON_LIB
#ifdef FEATURE_EL_POSITION_ADXL345_USING_ADAFRUIT_LIB
sensors_event_t event;
accel.getEvent(&event);
#ifdef DEBUG_ACCEL
if (debug_mode) {
debug.print(F("read_elevation: event.acceleration.z: "));
debug.println(event.acceleration.z);
}
#endif // DEBUG_ACCEL
elevation = (atan2(event.acceleration.y, event.acceleration.z) * 180 * HEADING_MULTIPLIER) / M_PI;
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif // FEATURE_ELEVATION_CORRECTION
elevation = elevation + (configuration.elevation_offset * HEADING_MULTIPLIER);
sensors_event_t event;
accel.getEvent(&event);
#ifdef DEBUG_ACCEL
if (debug_mode) {
debug.print(F("read_elevation: event.acceleration.y: "));
debug.print(event.acceleration.y);
debug.print(F(" z: "));
debug.println(event.acceleration.z);
}
#endif // DEBUG_ACCEL
elevation = (atan2(event.acceleration.y, event.acceleration.z) * 180 * HEADING_MULTIPLIER) / M_PI;
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif // FEATURE_ELEVATION_CORRECTION
elevation = elevation + (configuration.elevation_offset * HEADING_MULTIPLIER);
#endif // FEATURE_EL_POSITION_ADXL345_USING_ADAFRUIT_LIB
#ifdef FEATURE_EL_POSITION_ADAFRUIT_LSM303
lsm.read();
#ifdef DEBUG_ACCEL
if (debug_mode) {
debug.print(F("read_elevation: lsm.accelData.y: "));
debug.print(lsm.accelData.y);
debug.print(F(" lsm.accelData.z: "));
control_port->println(lsm.accelData.z);
}
#endif // DEBUG_ACCEL
elevation = (atan2(lsm.accelData.y, lsm.accelData.z) * 180 * HEADING_MULTIPLIER) / M_PI;
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif // FEATURE_ELEVATION_CORRECTION
elevation = elevation + (configuration.elevation_offset * HEADING_MULTIPLIER);
lsm.read();
#ifdef DEBUG_ACCEL
if (debug_mode) {
debug.print(F("read_elevation: lsm.accelData.y: "));
debug.print(lsm.accelData.y);
debug.print(F(" z: "));
control_port->println(lsm.accelData.z);
}
#endif // DEBUG_ACCEL
elevation = (atan2(lsm.accelData.y, lsm.accelData.z) * 180 * HEADING_MULTIPLIER) / M_PI;
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif // FEATURE_ELEVATION_CORRECTION
elevation = elevation + (configuration.elevation_offset * HEADING_MULTIPLIER);
#endif // FEATURE_EL_POSITION_ADAFRUIT_LSM303
#ifdef FEATURE_EL_POSITION_POLOLU_LSM303
compass.read();
#ifdef DEBUG_ACCEL
if (debug_mode) {
debug.print(F("read_elevation: compass.a.y: "));
debug.print(compass.a.y);
debug.print(F(" compass.a.z: "));
control_port->println(compass.a.z);
}
#endif // DEBUG_ACCEL
elevation = (atan2(compass.a.x, compass.a.z) * -180 * HEADING_MULTIPLIER) / M_PI; //lsm.accelData.y
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif // FEATURE_ELEVATION_CORRECTION
elevation = elevation + (configuration.elevation_offset * HEADING_MULTIPLIER);
compass.read();
#ifdef DEBUG_ACCEL
if (debug_mode) {
debug.print(F("read_elevation: compass.a.y: "));
debug.print(compass.a.y);
debug.print(F(" z: "));
control_port->println(compass.a.z);
}
#endif // DEBUG_ACCEL
elevation = (atan2(compass.a.x, compass.a.z) * -180 * HEADING_MULTIPLIER) / M_PI; //lsm.accelData.y
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif // FEATURE_ELEVATION_CORRECTION
elevation = elevation + (configuration.elevation_offset * HEADING_MULTIPLIER);
#endif // FEATURE_EL_POSITION_POLOLU_LSM303
@ -5818,7 +5825,7 @@ void read_elevation(byte force_read){
last_el_position_pulse_input_elevation = el_position_pulse_input_elevation;
elevation = int(configuration.last_elevation * HEADING_MULTIPLIER);
#ifdef FEATURE_ELEVATION_CORRECTION
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
#endif FEATURE_ELEVATION_CORRECTION
elevation = elevation + (configuration.elevation_offset * HEADING_MULTIPLIER);
}
@ -8756,7 +8763,7 @@ byte submit_remote_command(byte remote_command_to_send, byte parm1, int parm2){
}
remote_unit_port->println(parm2);
#if defined(FEATURE_REMOTE_UNIT_SLAVE) || defined(FEATURE_YAESU_EMULATION) || defined(FEATURE_EASYCOM_EMULATION)
if (remote_port_tx_sniff) {control_port->println(parm1);}
if (remote_port_tx_sniff) {control_port->println(parm2);}
#endif
#endif //FEATURE_MASTER_WITH_SERIAL_SLAVE