Troubleshoot GPS and adapt TinyGPS to handle GNXXX sentences
TinyGPS only handled GPRMC and GPGGA messages. Added code to make it handle both GP and GN versions to support any sat system.
6
.vscode/c_cpp_properties.json
vendored
@ -4,10 +4,12 @@
|
||||
"name": "Win32",
|
||||
"includePath": [
|
||||
"C:\\Program Files (x86)\\Arduino\\tools\\**",
|
||||
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**"
|
||||
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**",
|
||||
"c:/Users/k7mdl/Documents/GitHub/k3ng_rotator_controller/libraries/"
|
||||
],
|
||||
"forcedInclude": [
|
||||
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h"
|
||||
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h",
|
||||
"c:\\Users\\k7mdl/Documents\\GitHub\\k3ng_rotator_controller\\libraries\\TinyGPS\\TinyGPS.h"
|
||||
],
|
||||
"intelliSenseMode": "msvc-x64"
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
|
||||
#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 DEFAULT_DEBUG_STATE 1 // 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_LOOP
|
||||
@ -53,7 +53,7 @@
|
||||
// #define DEBUG_MEMSIC_2125
|
||||
// #define DEBUG_SYNC_MASTER_CLOCK_TO_SLAVE
|
||||
// #define DEBUG_SYNC_MASTER_COORDINATES_TO_SLAVE
|
||||
// #define DEBUG_HMC5883L
|
||||
#define DEBUG_HMC5883L
|
||||
// #define DEBUG_POLOLU_LSM303_CALIBRATION
|
||||
// #define DEBUG_STEPPER
|
||||
// #define DEBUG_AUTOCORRECT
|
||||
|
@ -113,7 +113,7 @@
|
||||
//#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 OPTION_SERIAL_HELP_TEXT // Yaesu help command prints help
|
||||
//#define FEATURE_PARK
|
||||
//#define FEATURE_AUTOPARK // Requires 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 are AZ_MANUAL_ROTATE_CCW_LIMIT, AZ_MANUAL_ROTATE_CW_LIMIT)
|
||||
@ -131,7 +131,7 @@
|
||||
// #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_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_STATUS
|
||||
@ -160,7 +160,7 @@
|
||||
// #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_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
|
||||
|
@ -139,11 +139,11 @@
|
||||
#endif //FEATURE_AZ_POSITION_INCREMENTAL_ENCODER
|
||||
|
||||
#ifdef FEATURE_EL_POSITION_INCREMENTAL_ENCODER
|
||||
#define el_incremental_encoder_pin_phase_a 18 //18 //2 // must be an interrupt capable pin
|
||||
#define el_incremental_encoder_pin_phase_b 19 //19 //3 // must be an interrupt capable pin
|
||||
#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 0 //22 //4
|
||||
#define EL_POSITION_INCREMENTAL_ENCODER_A_PIN_INTERRUPT 5 //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 4 //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
|
||||
#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
|
||||
|
||||
|
@ -43,8 +43,8 @@ You can tweak these, but read the online documentation!
|
||||
#define PWM_SPEED_VOLTAGE_X4 253 // 0 to 255
|
||||
|
||||
//AZ
|
||||
#define AZ_SLOWSTART_DEFAULT 1 // 0 = off ; 1 = on
|
||||
#define AZ_SLOWDOWN_DEFAULT 1 // 0 = off ; 1 = on
|
||||
#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 60 // PWM starting value for slow start (must be < 256)
|
||||
#define AZ_SLOW_START_STEPS 20 // must be < 256
|
||||
@ -318,7 +318,7 @@ You can tweak these, but read the online documentation!
|
||||
#define STALL_CHECK_FREQUENCY_MS_EL 1000
|
||||
#define STALL_CHECK_DEGREES_THRESHOLD_EL 2
|
||||
|
||||
//#define SET_I2C_BUS_SPEED 800000L // Can set up to 800 kHz, depending on devices. 800000L = 800 khz, 400000L = 400 khz. Default is 100 khz
|
||||
#define SET_I2C_BUS_SPEED 400000L // Can set up to 800 kHz, depending on devices. 800000L = 800 khz, 400000L = 400 khz. Default is 100 khz
|
||||
|
||||
#define ROTATIONAL_AND_CONFIGURATION_CMD_IGNORE_TIME_MS 5000 // if OPTION_ALLOW_ROTATIONAL_AND_CONFIGURATION_CMDS_AT_BOOT_UP is enabled, ignore configuration and rotational command for this many mS after boot up
|
||||
|
||||
@ -335,16 +335,16 @@ You can tweak these, but read the online documentation!
|
||||
// Changed in 2020.06.26.02
|
||||
// Serial Port Settings
|
||||
#define CONTROL_PORT_MAPPED_TO &Serial // change this line to map the control port to a different serial port (Serial1, Serial2, etc.)
|
||||
#define CONTROL_PORT_BAUD_RATE 9600
|
||||
//#define REMOTE_PORT Serial3 // used to control remote unit
|
||||
#define REMOTE_UNIT_PORT_BAUD_RATE 9600
|
||||
#define CONTROL_PORT_BAUD_RATE 115200
|
||||
// #define REMOTE_PORT Serial3 // used to control remote unit
|
||||
// #define REMOTE_UNIT_PORT_BAUD_RATE 9600
|
||||
#define GPS_PORT Serial2
|
||||
#define GPS_PORT_BAUD_RATE 38400
|
||||
#define GPS_PORT_BAUD_RATE 9600
|
||||
// #define GPS_MIRROR_PORT Serial1 // use this to mirror output from a GPS unit into the Arduino out another port (uncomment to enable)
|
||||
// #define GPS_MIRROR_PORT_BAUD_RATE 9600
|
||||
#define nexSerial Serial3
|
||||
#define NEXTION_SERIAL_BAUD 115200
|
||||
#define OPTION_SEND_STRING_OUT_CONTROL_PORT_WHEN_INITIALIZING_STRING ("test\n\r")
|
||||
// #define OPTION_SEND_STRING_OUT_CONTROL_PORT_WHEN_INITIALIZING_STRING ("test\n\r")
|
||||
|
||||
// Added in 2020.07.19.02
|
||||
#define SUN_UPDATE_POSITION_INTERVAL_MS 5000
|
||||
@ -389,4 +389,3 @@ You can tweak these, but read the online documentation!
|
||||
#define SATELLITE_CALC_STAGE_1_RESOLUTION_SECS 120
|
||||
#define SATELLITE_CALC_STAGE_2_RESOLUTION_SECS 10
|
||||
#define SATELLITE_CALC_STAGE_3_RESOLUTION_SECS 1
|
||||
|
||||
|
19
libraries/Arduino-HMC5883L-master/CHANGELOG
Normal file
@ -0,0 +1,19 @@
|
||||
HMC5883L Arduino Library 1.1.0 / 26.10.2014
|
||||
======================================================================
|
||||
|
||||
* Adding tilt compensation examples for MPU6050 / ADXL345
|
||||
* Adding calibrate script and processing
|
||||
* Adding example to work with GY-86 / GY-87 modules
|
||||
* Adding setOffset() method for calibration
|
||||
* Removing fixAngle() from examples
|
||||
* Cleanups codes
|
||||
|
||||
HMC5883L Arduino Library 1.0.1 / 26.01.2014
|
||||
======================================================================
|
||||
|
||||
* Fix typedefs & structs names
|
||||
|
||||
HMC5883L Arduino Library 1.0.0 / 25.01.2014
|
||||
======================================================================
|
||||
|
||||
* First release
|
278
libraries/Arduino-HMC5883L-master/HMC5883L.cpp
Normal file
@ -0,0 +1,278 @@
|
||||
/*
|
||||
HMC5883L.cpp - Class file for the HMC5883L Triple Axis Digital Compass Arduino Library.
|
||||
|
||||
Version: 1.1.0
|
||||
(c) 2014 Korneliusz Jarzebski
|
||||
www.jarzebski.pl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the version 3 GNU General Public License as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
#include "HMC5883L.h"
|
||||
|
||||
bool HMC5883L::begin()
|
||||
{
|
||||
Wire.begin();
|
||||
|
||||
if ((fastRegister8(HMC5883L_REG_IDENT_A) != 0x48)
|
||||
|| (fastRegister8(HMC5883L_REG_IDENT_B) != 0x34)
|
||||
|| (fastRegister8(HMC5883L_REG_IDENT_C) != 0x33))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
setRange(HMC5883L_RANGE_1_3GA);
|
||||
setMeasurementMode(HMC5883L_CONTINOUS);
|
||||
setDataRate(HMC5883L_DATARATE_15HZ);
|
||||
setSamples(HMC5883L_SAMPLES_1);
|
||||
|
||||
mgPerDigit = 0.92f;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector HMC5883L::readRaw(void)
|
||||
{
|
||||
v.XAxis = readRegister16(HMC5883L_REG_OUT_X_M) - xOffset;
|
||||
v.YAxis = readRegister16(HMC5883L_REG_OUT_Y_M) - yOffset;
|
||||
v.ZAxis = readRegister16(HMC5883L_REG_OUT_Z_M);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
Vector HMC5883L::readNormalize(void)
|
||||
{
|
||||
v.XAxis = ((float)readRegister16(HMC5883L_REG_OUT_X_M) - xOffset) * mgPerDigit;
|
||||
v.YAxis = ((float)readRegister16(HMC5883L_REG_OUT_Y_M) - yOffset) * mgPerDigit;
|
||||
v.ZAxis = (float)readRegister16(HMC5883L_REG_OUT_Z_M) * mgPerDigit;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
void HMC5883L::setOffset(int xo, int yo)
|
||||
{
|
||||
xOffset = xo;
|
||||
yOffset = yo;
|
||||
}
|
||||
|
||||
void HMC5883L::setRange(hmc5883l_range_t range)
|
||||
{
|
||||
switch(range)
|
||||
{
|
||||
case HMC5883L_RANGE_0_88GA:
|
||||
mgPerDigit = 0.073f;
|
||||
break;
|
||||
|
||||
case HMC5883L_RANGE_1_3GA:
|
||||
mgPerDigit = 0.92f;
|
||||
break;
|
||||
|
||||
case HMC5883L_RANGE_1_9GA:
|
||||
mgPerDigit = 1.22f;
|
||||
break;
|
||||
|
||||
case HMC5883L_RANGE_2_5GA:
|
||||
mgPerDigit = 1.52f;
|
||||
break;
|
||||
|
||||
case HMC5883L_RANGE_4GA:
|
||||
mgPerDigit = 2.27f;
|
||||
break;
|
||||
|
||||
case HMC5883L_RANGE_4_7GA:
|
||||
mgPerDigit = 2.56f;
|
||||
break;
|
||||
|
||||
case HMC5883L_RANGE_5_6GA:
|
||||
mgPerDigit = 3.03f;
|
||||
break;
|
||||
|
||||
case HMC5883L_RANGE_8_1GA:
|
||||
mgPerDigit = 4.35f;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
writeRegister8(HMC5883L_REG_CONFIG_B, range << 5);
|
||||
}
|
||||
|
||||
hmc5883l_range_t HMC5883L::getRange(void)
|
||||
{
|
||||
return (hmc5883l_range_t)((readRegister8(HMC5883L_REG_CONFIG_B) >> 5));
|
||||
}
|
||||
|
||||
void HMC5883L::setMeasurementMode(hmc5883l_mode_t mode)
|
||||
{
|
||||
uint8_t value;
|
||||
|
||||
value = readRegister8(HMC5883L_REG_MODE);
|
||||
value &= 0b11111100;
|
||||
value |= mode;
|
||||
|
||||
writeRegister8(HMC5883L_REG_MODE, value);
|
||||
}
|
||||
|
||||
hmc5883l_mode_t HMC5883L::getMeasurementMode(void)
|
||||
{
|
||||
uint8_t value;
|
||||
|
||||
value = readRegister8(HMC5883L_REG_MODE);
|
||||
value &= 0b00000011;
|
||||
|
||||
return (hmc5883l_mode_t)value;
|
||||
}
|
||||
|
||||
void HMC5883L::setDataRate(hmc5883l_dataRate_t dataRate)
|
||||
{
|
||||
uint8_t value;
|
||||
|
||||
value = readRegister8(HMC5883L_REG_CONFIG_A);
|
||||
value &= 0b11100011;
|
||||
value |= (dataRate << 2);
|
||||
|
||||
writeRegister8(HMC5883L_REG_CONFIG_A, value);
|
||||
}
|
||||
|
||||
hmc5883l_dataRate_t HMC5883L::getDataRate(void)
|
||||
{
|
||||
uint8_t value;
|
||||
|
||||
value = readRegister8(HMC5883L_REG_CONFIG_A);
|
||||
value &= 0b00011100;
|
||||
value >>= 2;
|
||||
|
||||
return (hmc5883l_dataRate_t)value;
|
||||
}
|
||||
|
||||
void HMC5883L::setSamples(hmc5883l_samples_t samples)
|
||||
{
|
||||
uint8_t value;
|
||||
|
||||
value = readRegister8(HMC5883L_REG_CONFIG_A);
|
||||
value &= 0b10011111;
|
||||
value |= (samples << 5);
|
||||
|
||||
writeRegister8(HMC5883L_REG_CONFIG_A, value);
|
||||
}
|
||||
|
||||
hmc5883l_samples_t HMC5883L::getSamples(void)
|
||||
{
|
||||
uint8_t value;
|
||||
|
||||
value = readRegister8(HMC5883L_REG_CONFIG_A);
|
||||
value &= 0b01100000;
|
||||
value >>= 5;
|
||||
|
||||
return (hmc5883l_samples_t)value;
|
||||
}
|
||||
|
||||
// Write byte to register
|
||||
void HMC5883L::writeRegister8(uint8_t reg, uint8_t value)
|
||||
{
|
||||
Wire.beginTransmission(HMC5883L_ADDRESS);
|
||||
#if ARDUINO >= 100
|
||||
Wire.write(reg);
|
||||
Wire.write(value);
|
||||
#else
|
||||
Wire.send(reg);
|
||||
Wire.send(value);
|
||||
#endif
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
// Read byte to register
|
||||
uint8_t HMC5883L::fastRegister8(uint8_t reg)
|
||||
{
|
||||
uint8_t value;
|
||||
Wire.beginTransmission(HMC5883L_ADDRESS);
|
||||
#if ARDUINO >= 100
|
||||
Wire.write(reg);
|
||||
#else
|
||||
Wire.send(reg);
|
||||
#endif
|
||||
Wire.endTransmission();
|
||||
|
||||
Wire.requestFrom(HMC5883L_ADDRESS, 1);
|
||||
#if ARDUINO >= 100
|
||||
value = Wire.read();
|
||||
#else
|
||||
value = Wire.receive();
|
||||
#endif;
|
||||
Wire.endTransmission();
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// Read byte from register
|
||||
uint8_t HMC5883L::readRegister8(uint8_t reg)
|
||||
{
|
||||
uint8_t value;
|
||||
Wire.beginTransmission(HMC5883L_ADDRESS);
|
||||
#if ARDUINO >= 100
|
||||
Wire.write(reg);
|
||||
#else
|
||||
Wire.send(reg);
|
||||
#endif
|
||||
Wire.endTransmission();
|
||||
|
||||
Wire.beginTransmission(HMC5883L_ADDRESS);
|
||||
Wire.requestFrom(HMC5883L_ADDRESS, 1);
|
||||
while(!Wire.available()) {};
|
||||
#if ARDUINO >= 100
|
||||
value = Wire.read();
|
||||
#else
|
||||
value = Wire.receive();
|
||||
#endif;
|
||||
Wire.endTransmission();
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// Read word from register
|
||||
int16_t HMC5883L::readRegister16(uint8_t reg)
|
||||
{
|
||||
int16_t value;
|
||||
Wire.beginTransmission(HMC5883L_ADDRESS);
|
||||
#if ARDUINO >= 100
|
||||
Wire.write(reg);
|
||||
#else
|
||||
Wire.send(reg);
|
||||
#endif
|
||||
Wire.endTransmission();
|
||||
|
||||
Wire.beginTransmission(HMC5883L_ADDRESS);
|
||||
Wire.requestFrom(HMC5883L_ADDRESS, 2);
|
||||
while(!Wire.available()) {};
|
||||
#if ARDUINO >= 100
|
||||
uint8_t vha = Wire.read();
|
||||
uint8_t vla = Wire.read();
|
||||
#else
|
||||
uint8_t vha = Wire.receive();
|
||||
uint8_t vla = Wire.receive();
|
||||
#endif;
|
||||
Wire.endTransmission();
|
||||
|
||||
value = vha << 8 | vla;
|
||||
|
||||
return value;
|
||||
}
|
128
libraries/Arduino-HMC5883L-master/HMC5883L.h
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
HMC5883L.h - Header file for the HMC5883L Triple Axis Digital Compass Arduino Library.
|
||||
|
||||
Version: 1.1.0
|
||||
(c) 2014 Korneliusz Jarzebski
|
||||
www.jarzebski.pl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the version 3 GNU General Public License as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef HMC5883L_h
|
||||
#define HMC5883L_h
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#define HMC5883L_ADDRESS (0x1E)
|
||||
#define HMC5883L_REG_CONFIG_A (0x00)
|
||||
#define HMC5883L_REG_CONFIG_B (0x01)
|
||||
#define HMC5883L_REG_MODE (0x02)
|
||||
#define HMC5883L_REG_OUT_X_M (0x03)
|
||||
#define HMC5883L_REG_OUT_X_L (0x04)
|
||||
#define HMC5883L_REG_OUT_Z_M (0x05)
|
||||
#define HMC5883L_REG_OUT_Z_L (0x06)
|
||||
#define HMC5883L_REG_OUT_Y_M (0x07)
|
||||
#define HMC5883L_REG_OUT_Y_L (0x08)
|
||||
#define HMC5883L_REG_STATUS (0x09)
|
||||
#define HMC5883L_REG_IDENT_A (0x0A)
|
||||
#define HMC5883L_REG_IDENT_B (0x0B)
|
||||
#define HMC5883L_REG_IDENT_C (0x0C)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HMC5883L_SAMPLES_8 = 0b11,
|
||||
HMC5883L_SAMPLES_4 = 0b10,
|
||||
HMC5883L_SAMPLES_2 = 0b01,
|
||||
HMC5883L_SAMPLES_1 = 0b00
|
||||
} hmc5883l_samples_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HMC5883L_DATARATE_75HZ = 0b110,
|
||||
HMC5883L_DATARATE_30HZ = 0b101,
|
||||
HMC5883L_DATARATE_15HZ = 0b100,
|
||||
HMC5883L_DATARATE_7_5HZ = 0b011,
|
||||
HMC5883L_DATARATE_3HZ = 0b010,
|
||||
HMC5883L_DATARATE_1_5HZ = 0b001,
|
||||
HMC5883L_DATARATE_0_75_HZ = 0b000
|
||||
} hmc5883l_dataRate_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HMC5883L_RANGE_8_1GA = 0b111,
|
||||
HMC5883L_RANGE_5_6GA = 0b110,
|
||||
HMC5883L_RANGE_4_7GA = 0b101,
|
||||
HMC5883L_RANGE_4GA = 0b100,
|
||||
HMC5883L_RANGE_2_5GA = 0b011,
|
||||
HMC5883L_RANGE_1_9GA = 0b010,
|
||||
HMC5883L_RANGE_1_3GA = 0b001,
|
||||
HMC5883L_RANGE_0_88GA = 0b000
|
||||
} hmc5883l_range_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HMC5883L_IDLE = 0b10,
|
||||
HMC5883L_SINGLE = 0b01,
|
||||
HMC5883L_CONTINOUS = 0b00
|
||||
} hmc5883l_mode_t;
|
||||
|
||||
#ifndef VECTOR_STRUCT_H
|
||||
#define VECTOR_STRUCT_H
|
||||
struct Vector
|
||||
{
|
||||
float XAxis;
|
||||
float YAxis;
|
||||
float ZAxis;
|
||||
};
|
||||
#endif
|
||||
|
||||
class HMC5883L
|
||||
{
|
||||
public:
|
||||
|
||||
bool begin(void);
|
||||
|
||||
Vector readRaw(void);
|
||||
Vector readNormalize(void);
|
||||
|
||||
void setOffset(int xo, int yo);
|
||||
|
||||
void setRange(hmc5883l_range_t range);
|
||||
hmc5883l_range_t getRange(void);
|
||||
|
||||
void setMeasurementMode(hmc5883l_mode_t mode);
|
||||
hmc5883l_mode_t getMeasurementMode(void);
|
||||
|
||||
void setDataRate(hmc5883l_dataRate_t dataRate);
|
||||
hmc5883l_dataRate_t getDataRate(void);
|
||||
|
||||
void setSamples(hmc5883l_samples_t samples);
|
||||
hmc5883l_samples_t getSamples(void);
|
||||
|
||||
private:
|
||||
|
||||
float mgPerDigit;
|
||||
Vector v;
|
||||
int xOffset, yOffset;
|
||||
|
||||
void writeRegister8(uint8_t reg, uint8_t value);
|
||||
uint8_t readRegister8(uint8_t reg);
|
||||
uint8_t fastRegister8(uint8_t reg);
|
||||
int16_t readRegister16(uint8_t reg);
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
Calibrate HMC5883L. Output for HMC5883L_calibrate_processing.pde
|
||||
Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
GIT: https://github.com/jarzebski/Arduino-HMC5883L
|
||||
Web: http://www.jarzebski.pl
|
||||
(c) 2014 by Korneliusz Jarzebski
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <HMC5883L.h>
|
||||
|
||||
HMC5883L compass;
|
||||
|
||||
int minX = 0;
|
||||
int maxX = 0;
|
||||
int minY = 0;
|
||||
int maxY = 0;
|
||||
int offX = 0;
|
||||
int offY = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
|
||||
// Initialize Initialize HMC5883L
|
||||
while (!compass.begin())
|
||||
{
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// Set measurement range
|
||||
compass.setRange(HMC5883L_RANGE_1_3GA);
|
||||
|
||||
// Set measurement mode
|
||||
compass.setMeasurementMode(HMC5883L_CONTINOUS);
|
||||
|
||||
// Set data rate
|
||||
compass.setDataRate(HMC5883L_DATARATE_30HZ);
|
||||
|
||||
// Set number of samples averaged
|
||||
compass.setSamples(HMC5883L_SAMPLES_8);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Vector mag = compass.readRaw();
|
||||
|
||||
// Determine Min / Max values
|
||||
if (mag.XAxis < minX) minX = mag.XAxis;
|
||||
if (mag.XAxis > maxX) maxX = mag.XAxis;
|
||||
if (mag.YAxis < minY) minY = mag.YAxis;
|
||||
if (mag.YAxis > maxY) maxY = mag.YAxis;
|
||||
|
||||
// Calculate offsets
|
||||
offX = (maxX + minX)/2;
|
||||
offY = (maxY + minY)/2;
|
||||
|
||||
Serial.print(mag.XAxis);
|
||||
Serial.print(":");
|
||||
Serial.print(mag.YAxis);
|
||||
Serial.print(":");
|
||||
Serial.print(minX);
|
||||
Serial.print(":");
|
||||
Serial.print(maxX);
|
||||
Serial.print(":");
|
||||
Serial.print(minY);
|
||||
Serial.print(":");
|
||||
Serial.print(maxY);
|
||||
Serial.print(":");
|
||||
Serial.print(offX);
|
||||
Serial.print(":");
|
||||
Serial.print(offY);
|
||||
Serial.print("\n");
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
Calibrate HMC5883L + MPU6050 (GY-86 / GY-87). Output for HMC5883L_calibrate_processing.pde
|
||||
Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
GIT: https://github.com/jarzebski/Arduino-HMC5883L
|
||||
Web: http://www.jarzebski.pl
|
||||
(c) 2014 by Korneliusz Jarzebski
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <HMC5883L.h>
|
||||
#include <MPU6050.h>
|
||||
|
||||
HMC5883L compass;
|
||||
MPU6050 mpu;
|
||||
|
||||
int minX = 0;
|
||||
int maxX = 0;
|
||||
int minY = 0;
|
||||
int maxY = 0;
|
||||
int offX = 0;
|
||||
int offY = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
|
||||
// Initialize MPU6050
|
||||
while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
|
||||
{
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// Enable bypass mode
|
||||
mpu.setI2CMasterModeEnabled(false);
|
||||
mpu.setI2CBypassEnabled(true);
|
||||
mpu.setSleepEnabled(false);
|
||||
|
||||
// Initialize Initialize HMC5883L
|
||||
while (!compass.begin())
|
||||
{
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// Set measurement range
|
||||
compass.setRange(HMC5883L_RANGE_1_3GA);
|
||||
|
||||
// Set measurement mode
|
||||
compass.setMeasurementMode(HMC5883L_CONTINOUS);
|
||||
|
||||
// Set data rate
|
||||
compass.setDataRate(HMC5883L_DATARATE_30HZ);
|
||||
|
||||
// Set number of samples averaged
|
||||
compass.setSamples(HMC5883L_SAMPLES_8);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Vector mag = compass.readRaw();
|
||||
|
||||
// Determine Min / Max values
|
||||
if (mag.XAxis < minX) minX = mag.XAxis;
|
||||
if (mag.XAxis > maxX) maxX = mag.XAxis;
|
||||
if (mag.YAxis < minY) minY = mag.YAxis;
|
||||
if (mag.YAxis > maxY) maxY = mag.YAxis;
|
||||
|
||||
// Calculate offsets
|
||||
offX = (maxX + minX)/2;
|
||||
offY = (maxY + minY)/2;
|
||||
|
||||
Serial.print(mag.XAxis);
|
||||
Serial.print(":");
|
||||
Serial.print(mag.YAxis);
|
||||
Serial.print(":");
|
||||
Serial.print(minX);
|
||||
Serial.print(":");
|
||||
Serial.print(maxX);
|
||||
Serial.print(":");
|
||||
Serial.print(minY);
|
||||
Serial.print(":");
|
||||
Serial.print(maxY);
|
||||
Serial.print(":");
|
||||
Serial.print(offX);
|
||||
Serial.print(":");
|
||||
Serial.print(offY);
|
||||
Serial.print("\n");
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
HMC5883L Triple Axis Digital Compass. Compass Example.
|
||||
Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
GIT: https://github.com/jarzebski/Arduino-HMC5883L
|
||||
Web: http://www.jarzebski.pl
|
||||
(c) 2014 by Korneliusz Jarzebski
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <HMC5883L.h>
|
||||
|
||||
HMC5883L compass;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
// Initialize Initialize HMC5883L
|
||||
Serial.println("Initialize HMC5883L");
|
||||
while (!compass.begin())
|
||||
{
|
||||
Serial.println("Could not find a valid HMC5883L sensor, check wiring!");
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// Set measurement range
|
||||
compass.setRange(HMC5883L_RANGE_1_3GA);
|
||||
|
||||
// Set measurement mode
|
||||
compass.setMeasurementMode(HMC5883L_CONTINOUS);
|
||||
|
||||
// Set data rate
|
||||
compass.setDataRate(HMC5883L_DATARATE_30HZ);
|
||||
|
||||
// Set number of samples averaged
|
||||
compass.setSamples(HMC5883L_SAMPLES_8);
|
||||
|
||||
// Set calibration offset. See HMC5883L_calibration.ino
|
||||
compass.setOffset(0, 0);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Vector norm = compass.readNormalize();
|
||||
|
||||
// Calculate heading
|
||||
float heading = atan2(norm.YAxis, norm.XAxis);
|
||||
|
||||
// Set declination angle on your location and fix heading
|
||||
// You can find your declination on: http://magnetic-declination.com/
|
||||
// (+) Positive or (-) for negative
|
||||
// For Bytom / Poland declination angle is 4'26E (positive)
|
||||
// Formula: (deg + (min / 60.0)) / (180 / M_PI);
|
||||
float declinationAngle = (4.0 + (26.0 / 60.0)) / (180 / M_PI);
|
||||
heading += declinationAngle;
|
||||
|
||||
// Correct for heading < 0deg and heading > 360deg
|
||||
if (heading < 0)
|
||||
{
|
||||
heading += 2 * PI;
|
||||
}
|
||||
|
||||
if (heading > 2 * PI)
|
||||
{
|
||||
heading -= 2 * PI;
|
||||
}
|
||||
|
||||
// Convert to degrees
|
||||
float headingDegrees = heading * 180/M_PI;
|
||||
|
||||
// Output
|
||||
Serial.print(" Heading = ");
|
||||
Serial.print(heading);
|
||||
Serial.print(" Degress = ");
|
||||
Serial.print(headingDegrees);
|
||||
Serial.println();
|
||||
|
||||
delay(100);
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
HMC5883L Triple Axis Digital Compass + MPU6050 (GY-86 / GY-87). Compass Example.
|
||||
Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
GIT: https://github.com/jarzebski/Arduino-HMC5883L
|
||||
Web: http://www.jarzebski.pl
|
||||
(c) 2014 by Korneliusz Jarzebski
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <HMC5883L.h>
|
||||
#include <MPU6050.h>
|
||||
|
||||
HMC5883L compass;
|
||||
MPU6050 mpu;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
|
||||
// If you have GY-86 or GY-87 module.
|
||||
// To access HMC5883L you need to disable the I2C Master Mode and Sleep Mode, and enable I2C Bypass Mode
|
||||
|
||||
while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
|
||||
{
|
||||
Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
|
||||
delay(500);
|
||||
}
|
||||
|
||||
mpu.setI2CMasterModeEnabled(false);
|
||||
mpu.setI2CBypassEnabled(true) ;
|
||||
mpu.setSleepEnabled(false);
|
||||
|
||||
// Initialize Initialize HMC5883L
|
||||
Serial.println("Initialize HMC5883L");
|
||||
while (!compass.begin())
|
||||
{
|
||||
Serial.println("Could not find a valid HMC5883L sensor, check wiring!");
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// Set measurement range
|
||||
compass.setRange(HMC5883L_RANGE_1_3GA);
|
||||
|
||||
// Set measurement mode
|
||||
compass.setMeasurementMode(HMC5883L_CONTINOUS);
|
||||
|
||||
// Set data rate
|
||||
compass.setDataRate(HMC5883L_DATARATE_30HZ);
|
||||
|
||||
// Set number of samples averaged
|
||||
compass.setSamples(HMC5883L_SAMPLES_8);
|
||||
|
||||
// Set calibration offset. See HMC5883L_calibration.ino
|
||||
compass.setOffset(0, 0);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Vector norm = compass.readNormalize();
|
||||
|
||||
// Calculate heading
|
||||
float heading = atan2(norm.YAxis, norm.XAxis);
|
||||
|
||||
// Set declination angle on your location and fix heading
|
||||
// You can find your declination on: http://magnetic-declination.com/
|
||||
// (+) Positive or (-) for negative
|
||||
// For Bytom / Poland declination angle is 4'26E (positive)
|
||||
// Formula: (deg + (min / 60.0)) / (180 / M_PI);
|
||||
float declinationAngle = (4.0 + (26.0 / 60.0)) / (180 / M_PI);
|
||||
heading += declinationAngle;
|
||||
|
||||
// Correct for heading < 0deg and heading > 360deg
|
||||
if (heading < 0)
|
||||
{
|
||||
heading += 2 * PI;
|
||||
}
|
||||
|
||||
if (heading > 2 * PI)
|
||||
{
|
||||
heading -= 2 * PI;
|
||||
}
|
||||
|
||||
// Convert to degrees
|
||||
float headingDegrees = heading * 180/M_PI;
|
||||
|
||||
// Output
|
||||
Serial.print(" Heading = ");
|
||||
Serial.print(heading);
|
||||
Serial.print(" Degress = ");
|
||||
Serial.print(headingDegrees);
|
||||
Serial.println();
|
||||
|
||||
delay(100);
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
/*
|
||||
Tilt compensated HMC5883L + ADXL345 (GY-80). Output for HMC5883L_compensation_processing.pde
|
||||
Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
GIT: https://github.com/jarzebski/Arduino-HMC5883L
|
||||
Web: http://www.jarzebski.pl
|
||||
(c) 2014 by Korneliusz Jarzebski
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <HMC5883L.h>
|
||||
#include <ADXL345.h>
|
||||
|
||||
HMC5883L compass;
|
||||
ADXL345 accelerometer;
|
||||
|
||||
float heading1;
|
||||
float heading2;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
|
||||
// Initialize ADXL345
|
||||
|
||||
if (!accelerometer.begin())
|
||||
{
|
||||
delay(500);
|
||||
}
|
||||
|
||||
accelerometer.setRange(ADXL345_RANGE_2G);
|
||||
|
||||
// Initialize Initialize HMC5883L
|
||||
while (!compass.begin())
|
||||
{
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// Set measurement range
|
||||
compass.setRange(HMC5883L_RANGE_1_3GA);
|
||||
|
||||
// Set measurement mode
|
||||
compass.setMeasurementMode(HMC5883L_CONTINOUS);
|
||||
|
||||
// Set data rate
|
||||
compass.setDataRate(HMC5883L_DATARATE_30HZ);
|
||||
|
||||
// Set number of samples averaged
|
||||
compass.setSamples(HMC5883L_SAMPLES_8);
|
||||
|
||||
// Set calibration offset. See HMC5883L_calibration.ino
|
||||
compass.setOffset(0, 0);
|
||||
}
|
||||
|
||||
// No tilt compensation
|
||||
float noTiltCompensate(Vector mag)
|
||||
{
|
||||
float heading = atan2(mag.YAxis, mag.XAxis);
|
||||
return heading;
|
||||
}
|
||||
|
||||
// Tilt compensation
|
||||
float tiltCompensate(Vector mag, Vector normAccel)
|
||||
{
|
||||
// Pitch & Roll
|
||||
|
||||
float roll;
|
||||
float pitch;
|
||||
|
||||
roll = asin(normAccel.YAxis);
|
||||
pitch = asin(-normAccel.XAxis);
|
||||
|
||||
if (roll > 0.78 || roll < -0.78 || pitch > 0.78 || pitch < -0.78)
|
||||
{
|
||||
return -1000;
|
||||
}
|
||||
|
||||
// Some of these are used twice, so rather than computing them twice in the algorithem we precompute them before hand.
|
||||
float cosRoll = cos(roll);
|
||||
float sinRoll = sin(roll);
|
||||
float cosPitch = cos(pitch);
|
||||
float sinPitch = sin(pitch);
|
||||
|
||||
// Tilt compensation
|
||||
float Xh = mag.XAxis * cosPitch + mag.ZAxis * sinPitch;
|
||||
float Yh = mag.XAxis * sinRoll * sinPitch + mag.YAxis * cosRoll - mag.ZAxis * sinRoll * cosPitch;
|
||||
|
||||
float heading = atan2(Yh, Xh);
|
||||
|
||||
return heading;
|
||||
}
|
||||
|
||||
// Correct angle
|
||||
float correctAngle(float heading)
|
||||
{
|
||||
if (heading < 0) { heading += 2 * PI; }
|
||||
if (heading > 2 * PI) { heading -= 2 * PI; }
|
||||
|
||||
return heading;
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Read vectors
|
||||
Vector mag = compass.readNormalize();
|
||||
Vector acc = accelerometer.readScaled();
|
||||
|
||||
// Calculate headings
|
||||
heading1 = noTiltCompensate(mag);
|
||||
heading2 = tiltCompensate(mag, acc);
|
||||
|
||||
if (heading2 == -1000)
|
||||
{
|
||||
heading2 = heading1;
|
||||
}
|
||||
|
||||
// Set declination angle on your location and fix heading
|
||||
// You can find your declination on: http://magnetic-declination.com/
|
||||
// (+) Positive or (-) for negative
|
||||
// For Bytom / Poland declination angle is 4'26E (positive)
|
||||
// Formula: (deg + (min / 60.0)) / (180 / M_PI);
|
||||
float declinationAngle = (4.0 + (26.0 / 60.0)) / (180 / M_PI);
|
||||
heading1 += declinationAngle;
|
||||
heading2 += declinationAngle;
|
||||
|
||||
// Correct for heading < 0deg and heading > 360deg
|
||||
heading1 = correctAngle(heading1);
|
||||
heading2 = correctAngle(heading2);
|
||||
|
||||
// Convert to degrees
|
||||
heading1 = heading1 * 180/M_PI;
|
||||
heading2 = heading2 * 180/M_PI;
|
||||
|
||||
// Output
|
||||
Serial.print(heading1);
|
||||
Serial.print(":");
|
||||
Serial.println(heading2);
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
@ -0,0 +1,142 @@
|
||||
/*
|
||||
Tilt compensated HMC5883L + MPU6050 (GY-86 / GY-87). Output for HMC5883L_compensation_processing.pde
|
||||
Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
GIT: https://github.com/jarzebski/Arduino-HMC5883L
|
||||
Web: http://www.jarzebski.pl
|
||||
(c) 2014 by Korneliusz Jarzebski
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <HMC5883L.h>
|
||||
#include <MPU6050.h>
|
||||
|
||||
HMC5883L compass;
|
||||
MPU6050 mpu;
|
||||
|
||||
float heading1;
|
||||
float heading2;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
|
||||
// Initialize MPU6050
|
||||
while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
|
||||
{
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// Enable bypass mode
|
||||
mpu.setI2CMasterModeEnabled(false);
|
||||
mpu.setI2CBypassEnabled(true) ;
|
||||
mpu.setSleepEnabled(false);
|
||||
|
||||
// Initialize Initialize HMC5883L
|
||||
while (!compass.begin())
|
||||
{
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// Set measurement range
|
||||
compass.setRange(HMC5883L_RANGE_1_3GA);
|
||||
|
||||
// Set measurement mode
|
||||
compass.setMeasurementMode(HMC5883L_CONTINOUS);
|
||||
|
||||
// Set data rate
|
||||
compass.setDataRate(HMC5883L_DATARATE_30HZ);
|
||||
|
||||
// Set number of samples averaged
|
||||
compass.setSamples(HMC5883L_SAMPLES_8);
|
||||
|
||||
// Set calibration offset. See HMC5883L_calibration.ino
|
||||
compass.setOffset(0, 0);
|
||||
}
|
||||
|
||||
// No tilt compensation
|
||||
float noTiltCompensate(Vector mag)
|
||||
{
|
||||
float heading = atan2(mag.YAxis, mag.XAxis);
|
||||
return heading;
|
||||
}
|
||||
|
||||
// Tilt compensation
|
||||
float tiltCompensate(Vector mag, Vector normAccel)
|
||||
{
|
||||
// Pitch & Roll
|
||||
|
||||
float roll;
|
||||
float pitch;
|
||||
|
||||
roll = asin(normAccel.YAxis);
|
||||
pitch = asin(-normAccel.XAxis);
|
||||
|
||||
if (roll > 0.78 || roll < -0.78 || pitch > 0.78 || pitch < -0.78)
|
||||
{
|
||||
return -1000;
|
||||
}
|
||||
|
||||
// Some of these are used twice, so rather than computing them twice in the algorithem we precompute them before hand.
|
||||
float cosRoll = cos(roll);
|
||||
float sinRoll = sin(roll);
|
||||
float cosPitch = cos(pitch);
|
||||
float sinPitch = sin(pitch);
|
||||
|
||||
// Tilt compensation
|
||||
float Xh = mag.XAxis * cosPitch + mag.ZAxis * sinPitch;
|
||||
float Yh = mag.XAxis * sinRoll * sinPitch + mag.YAxis * cosRoll - mag.ZAxis * sinRoll * cosPitch;
|
||||
|
||||
float heading = atan2(Yh, Xh);
|
||||
|
||||
return heading;
|
||||
}
|
||||
|
||||
// Correct angle
|
||||
float correctAngle(float heading)
|
||||
{
|
||||
if (heading < 0) { heading += 2 * PI; }
|
||||
if (heading > 2 * PI) { heading -= 2 * PI; }
|
||||
|
||||
return heading;
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Read vectors
|
||||
Vector mag = compass.readNormalize();
|
||||
Vector acc = mpu.readScaledAccel();
|
||||
|
||||
// Calculate headings
|
||||
heading1 = noTiltCompensate(mag);
|
||||
heading2 = tiltCompensate(mag, acc);
|
||||
|
||||
if (heading2 == -1000)
|
||||
{
|
||||
heading2 = heading1;
|
||||
}
|
||||
|
||||
// Set declination angle on your location and fix heading
|
||||
// You can find your declination on: http://magnetic-declination.com/
|
||||
// (+) Positive or (-) for negative
|
||||
// For Bytom / Poland declination angle is 4'26E (positive)
|
||||
// Formula: (deg + (min / 60.0)) / (180 / M_PI);
|
||||
float declinationAngle = (4.0 + (26.0 / 60.0)) / (180 / M_PI);
|
||||
heading1 += declinationAngle;
|
||||
heading2 += declinationAngle;
|
||||
|
||||
// Correct for heading < 0deg and heading > 360deg
|
||||
heading1 = correctAngle(heading1);
|
||||
heading2 = correctAngle(heading2);
|
||||
|
||||
// Convert to degrees
|
||||
heading1 = heading1 * 180/M_PI;
|
||||
heading2 = heading2 * 180/M_PI;
|
||||
|
||||
// Output
|
||||
Serial.print(heading1);
|
||||
Serial.print(":");
|
||||
Serial.println(heading2);
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
@ -0,0 +1,112 @@
|
||||
/*
|
||||
HMC5883L Triple Axis Digital Compass. Output for HMC5883L_processing.pde
|
||||
Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
GIT: https://github.com/jarzebski/Arduino-HMC5883L
|
||||
Web: http://www.jarzebski.pl
|
||||
(c) 2014 by Korneliusz Jarzebski
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <HMC5883L.h>
|
||||
|
||||
HMC5883L compass;
|
||||
|
||||
int previousDegree;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
|
||||
// Initialize HMC5883L
|
||||
while (!compass.begin())
|
||||
{
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// Set measurement range
|
||||
compass.setRange(HMC5883L_RANGE_1_3GA);
|
||||
|
||||
// Set measurement mode
|
||||
compass.setMeasurementMode(HMC5883L_CONTINOUS);
|
||||
|
||||
// Set data rate
|
||||
compass.setDataRate(HMC5883L_DATARATE_30HZ);
|
||||
|
||||
// Set number of samples averaged
|
||||
compass.setSamples(HMC5883L_SAMPLES_8);
|
||||
|
||||
// Set calibration offset. See HMC5883L_calibration.ino
|
||||
compass.setOffset(0, 0);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
long x = micros();
|
||||
Vector norm = compass.readNormalize();
|
||||
|
||||
// Calculate heading
|
||||
float heading = atan2(norm.YAxis, norm.XAxis);
|
||||
|
||||
// Set declination angle on your location and fix heading
|
||||
// You can find your declination on: http://magnetic-declination.com/
|
||||
// (+) Positive or (-) for negative
|
||||
// For Bytom / Poland declination angle is 4'26E (positive)
|
||||
// Formula: (deg + (min / 60.0)) / (180 / M_PI);
|
||||
float declinationAngle = (4.0 + (26.0 / 60.0)) / (180 / M_PI);
|
||||
heading += declinationAngle;
|
||||
|
||||
// Correct for heading < 0deg and heading > 360deg
|
||||
if (heading < 0)
|
||||
{
|
||||
heading += 2 * PI;
|
||||
}
|
||||
|
||||
if (heading > 2 * PI)
|
||||
{
|
||||
heading -= 2 * PI;
|
||||
}
|
||||
|
||||
// Convert to degrees
|
||||
float headingDegrees = heading * 180/M_PI;
|
||||
|
||||
// Fix HMC5883L issue with angles
|
||||
float fixedHeadingDegrees;
|
||||
|
||||
if (headingDegrees >= 1 && headingDegrees < 240)
|
||||
{
|
||||
fixedHeadingDegrees = map(headingDegrees, 0, 239, 0, 179);
|
||||
} else
|
||||
if (headingDegrees >= 240)
|
||||
{
|
||||
fixedHeadingDegrees = map(headingDegrees, 240, 360, 180, 360);
|
||||
}
|
||||
|
||||
// Smooth angles rotation for +/- 3deg
|
||||
int smoothHeadingDegrees = round(fixedHeadingDegrees);
|
||||
|
||||
if (smoothHeadingDegrees < (previousDegree + 3) && smoothHeadingDegrees > (previousDegree - 3))
|
||||
{
|
||||
smoothHeadingDegrees = previousDegree;
|
||||
}
|
||||
|
||||
previousDegree = smoothHeadingDegrees;
|
||||
|
||||
// Output
|
||||
Serial.print(norm.XAxis);
|
||||
Serial.print(":");
|
||||
Serial.print(norm.YAxis);
|
||||
Serial.print(":");
|
||||
Serial.print(norm.ZAxis);
|
||||
Serial.print(":");
|
||||
Serial.print(headingDegrees);
|
||||
Serial.print(":");
|
||||
Serial.print(fixedHeadingDegrees);
|
||||
Serial.print(":");
|
||||
Serial.print(smoothHeadingDegrees);
|
||||
Serial.println();
|
||||
|
||||
// One loop: ~5ms @ 115200 serial.
|
||||
// We need delay ~28ms for allow data rate 30Hz (~33ms)
|
||||
delay(30);
|
||||
}
|
||||
|
@ -0,0 +1,125 @@
|
||||
/*
|
||||
HMC5883L Triple Axis Digital Compass + MPU6050 (GY-86 / GY-87). Output for HMC5883L_processing.pde
|
||||
Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
GIT: https://github.com/jarzebski/Arduino-HMC5883L
|
||||
Web: http://www.jarzebski.pl
|
||||
(c) 2014 by Korneliusz Jarzebski
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <HMC5883L.h>
|
||||
#include <MPU6050.h>
|
||||
|
||||
HMC5883L compass;
|
||||
MPU6050 mpu;
|
||||
|
||||
int previousDegree;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
|
||||
// Initialize MPU6050
|
||||
while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
|
||||
{
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// Enable bypass mode
|
||||
mpu.setI2CMasterModeEnabled(false);
|
||||
mpu.setI2CBypassEnabled(true);
|
||||
mpu.setSleepEnabled(false);
|
||||
|
||||
// Initialize HMC5883L
|
||||
while (!compass.begin())
|
||||
{
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// Set measurement range
|
||||
compass.setRange(HMC5883L_RANGE_1_3GA);
|
||||
|
||||
// Set measurement mode
|
||||
compass.setMeasurementMode(HMC5883L_CONTINOUS);
|
||||
|
||||
// Set data rate
|
||||
compass.setDataRate(HMC5883L_DATARATE_30HZ);
|
||||
|
||||
// Set number of samples averaged
|
||||
compass.setSamples(HMC5883L_SAMPLES_8);
|
||||
|
||||
// Set calibration offset. See HMC5883L_calibration.ino
|
||||
compass.setOffset(0, 0);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
long x = micros();
|
||||
Vector norm = compass.readNormalize();
|
||||
|
||||
// Calculate heading
|
||||
float heading = atan2(norm.YAxis, norm.XAxis);
|
||||
|
||||
// Set declination angle on your location and fix heading
|
||||
// You can find your declination on: http://magnetic-declination.com/
|
||||
// (+) Positive or (-) for negative
|
||||
// For Bytom / Poland declination angle is 4'26E (positive)
|
||||
// Formula: (deg + (min / 60.0)) / (180 / M_PI);
|
||||
float declinationAngle = (4.0 + (26.0 / 60.0)) / (180 / M_PI);
|
||||
heading += declinationAngle;
|
||||
|
||||
// Correct for heading < 0deg and heading > 360deg
|
||||
if (heading < 0)
|
||||
{
|
||||
heading += 2 * PI;
|
||||
}
|
||||
|
||||
if (heading > 2 * PI)
|
||||
{
|
||||
heading -= 2 * PI;
|
||||
}
|
||||
|
||||
// Convert to degrees
|
||||
float headingDegrees = heading * 180/M_PI;
|
||||
|
||||
// Fix HMC5883L issue with angles
|
||||
float fixedHeadingDegrees;
|
||||
|
||||
if (headingDegrees >= 1 && headingDegrees < 240)
|
||||
{
|
||||
fixedHeadingDegrees = map(headingDegrees, 0, 239, 0, 179);
|
||||
} else
|
||||
if (headingDegrees >= 240)
|
||||
{
|
||||
fixedHeadingDegrees = map(headingDegrees, 240, 360, 180, 360);
|
||||
}
|
||||
|
||||
// Smooth angles rotation for +/- 3deg
|
||||
int smoothHeadingDegrees = round(fixedHeadingDegrees);
|
||||
|
||||
if (smoothHeadingDegrees < (previousDegree + 3) && smoothHeadingDegrees > (previousDegree - 3))
|
||||
{
|
||||
smoothHeadingDegrees = previousDegree;
|
||||
}
|
||||
|
||||
previousDegree = smoothHeadingDegrees;
|
||||
|
||||
// Output
|
||||
Serial.print(norm.XAxis);
|
||||
Serial.print(":");
|
||||
Serial.print(norm.YAxis);
|
||||
Serial.print(":");
|
||||
Serial.print(norm.ZAxis);
|
||||
Serial.print(":");
|
||||
Serial.print(headingDegrees);
|
||||
Serial.print(":");
|
||||
Serial.print(fixedHeadingDegrees);
|
||||
Serial.print(":");
|
||||
Serial.print(smoothHeadingDegrees);
|
||||
Serial.println();
|
||||
|
||||
// One loop: ~5ms @ 115200 serial.
|
||||
// We need delay ~28ms for allow data rate 30Hz (~33ms)
|
||||
delay(30);
|
||||
}
|
||||
|
@ -0,0 +1,135 @@
|
||||
/*
|
||||
HMC5883L Triple Axis Digital Compass. Simple Example.
|
||||
Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
GIT: https://github.com/jarzebski/Arduino-HMC5883L
|
||||
Web: http://www.jarzebski.pl
|
||||
(c) 2014 by Korneliusz Jarzebski
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <HMC5883L.h>
|
||||
|
||||
HMC5883L compass;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
|
||||
// Initialize HMC5883L
|
||||
Serial.println("Initialize HMC5883L");
|
||||
while (!compass.begin())
|
||||
{
|
||||
Serial.println("Could not find a valid HMC5883L sensor, check wiring!");
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// Set measurement range
|
||||
// +/- 0.88 Ga: HMC5883L_RANGE_0_88GA
|
||||
// +/- 1.30 Ga: HMC5883L_RANGE_1_3GA (default)
|
||||
// +/- 1.90 Ga: HMC5883L_RANGE_1_9GA
|
||||
// +/- 2.50 Ga: HMC5883L_RANGE_2_5GA
|
||||
// +/- 4.00 Ga: HMC5883L_RANGE_4GA
|
||||
// +/- 4.70 Ga: HMC5883L_RANGE_4_7GA
|
||||
// +/- 5.60 Ga: HMC5883L_RANGE_5_6GA
|
||||
// +/- 8.10 Ga: HMC5883L_RANGE_8_1GA
|
||||
compass.setRange(HMC5883L_RANGE_1_3GA);
|
||||
|
||||
// Set measurement mode
|
||||
// Idle mode: HMC5883L_IDLE
|
||||
// Single-Measurement: HMC5883L_SINGLE
|
||||
// Continuous-Measurement: HMC5883L_CONTINOUS (default)
|
||||
compass.setMeasurementMode(HMC5883L_CONTINOUS);
|
||||
|
||||
// Set data rate
|
||||
// 0.75Hz: HMC5883L_DATARATE_0_75HZ
|
||||
// 1.50Hz: HMC5883L_DATARATE_1_5HZ
|
||||
// 3.00Hz: HMC5883L_DATARATE_3HZ
|
||||
// 7.50Hz: HMC5883L_DATARATE_7_50HZ
|
||||
// 15.00Hz: HMC5883L_DATARATE_15HZ (default)
|
||||
// 30.00Hz: HMC5883L_DATARATE_30HZ
|
||||
// 75.00Hz: HMC5883L_DATARATE_75HZ
|
||||
compass.setDataRate(HMC5883L_DATARATE_15HZ);
|
||||
|
||||
// Set number of samples averaged
|
||||
// 1 sample: HMC5883L_SAMPLES_1 (default)
|
||||
// 2 samples: HMC5883L_SAMPLES_2
|
||||
// 4 samples: HMC5883L_SAMPLES_4
|
||||
// 8 samples: HMC5883L_SAMPLES_8
|
||||
compass.setSamples(HMC5883L_SAMPLES_1);
|
||||
|
||||
// Check settings
|
||||
checkSettings();
|
||||
}
|
||||
|
||||
void checkSettings()
|
||||
{
|
||||
Serial.print("Selected range: ");
|
||||
|
||||
switch (compass.getRange())
|
||||
{
|
||||
case HMC5883L_RANGE_0_88GA: Serial.println("0.88 Ga"); break;
|
||||
case HMC5883L_RANGE_1_3GA: Serial.println("1.3 Ga"); break;
|
||||
case HMC5883L_RANGE_1_9GA: Serial.println("1.9 Ga"); break;
|
||||
case HMC5883L_RANGE_2_5GA: Serial.println("2.5 Ga"); break;
|
||||
case HMC5883L_RANGE_4GA: Serial.println("4 Ga"); break;
|
||||
case HMC5883L_RANGE_4_7GA: Serial.println("4.7 Ga"); break;
|
||||
case HMC5883L_RANGE_5_6GA: Serial.println("5.6 Ga"); break;
|
||||
case HMC5883L_RANGE_8_1GA: Serial.println("8.1 Ga"); break;
|
||||
default: Serial.println("Bad range!");
|
||||
}
|
||||
|
||||
Serial.print("Selected Measurement Mode: ");
|
||||
switch (compass.getMeasurementMode())
|
||||
{
|
||||
case HMC5883L_IDLE: Serial.println("Idle mode"); break;
|
||||
case HMC5883L_SINGLE: Serial.println("Single-Measurement"); break;
|
||||
case HMC5883L_CONTINOUS: Serial.println("Continuous-Measurement"); break;
|
||||
default: Serial.println("Bad mode!");
|
||||
}
|
||||
|
||||
Serial.print("Selected Data Rate: ");
|
||||
switch (compass.getDataRate())
|
||||
{
|
||||
case HMC5883L_DATARATE_0_75_HZ: Serial.println("0.75 Hz"); break;
|
||||
case HMC5883L_DATARATE_1_5HZ: Serial.println("1.5 Hz"); break;
|
||||
case HMC5883L_DATARATE_3HZ: Serial.println("3 Hz"); break;
|
||||
case HMC5883L_DATARATE_7_5HZ: Serial.println("7.5 Hz"); break;
|
||||
case HMC5883L_DATARATE_15HZ: Serial.println("15 Hz"); break;
|
||||
case HMC5883L_DATARATE_30HZ: Serial.println("30 Hz"); break;
|
||||
case HMC5883L_DATARATE_75HZ: Serial.println("75 Hz"); break;
|
||||
default: Serial.println("Bad data rate!");
|
||||
}
|
||||
|
||||
Serial.print("Selected number of samples: ");
|
||||
switch (compass.getSamples())
|
||||
{
|
||||
case HMC5883L_SAMPLES_1: Serial.println("1"); break;
|
||||
case HMC5883L_SAMPLES_2: Serial.println("2"); break;
|
||||
case HMC5883L_SAMPLES_4: Serial.println("4"); break;
|
||||
case HMC5883L_SAMPLES_8: Serial.println("8"); break;
|
||||
default: Serial.println("Bad number of samples!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Vector raw = compass.readRaw();
|
||||
Vector norm = compass.readNormalize();
|
||||
|
||||
Serial.print(" Xraw = ");
|
||||
Serial.print(raw.XAxis);
|
||||
Serial.print(" Yraw = ");
|
||||
Serial.print(raw.YAxis);
|
||||
Serial.print(" Zraw = ");
|
||||
Serial.print(raw.ZAxis);
|
||||
Serial.print(" Xnorm = ");
|
||||
Serial.print(norm.XAxis);
|
||||
Serial.print(" Ynorm = ");
|
||||
Serial.print(norm.YAxis);
|
||||
Serial.print(" ZNorm = ");
|
||||
Serial.print(norm.ZAxis);
|
||||
Serial.println();
|
||||
|
||||
delay(100);
|
||||
}
|
674
libraries/Arduino-HMC5883L-master/LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{one line to give the program's name and a brief idea of what it does.}
|
||||
Copyright (C) {year} {name of author}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
HMC5883L Triple Axis Digital Compass.
|
||||
Processing for HMC5883L_calibrate.ino
|
||||
Processing for HMC5883L_calibrate_MPU6050.ino
|
||||
Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
GIT: https://github.com/jarzebski/Arduino-HMC5883L
|
||||
Web: http://www.jarzebski.pl
|
||||
(c) 2014 by Korneliusz Jarzebski
|
||||
*/
|
||||
|
||||
import processing.serial.*;
|
||||
|
||||
Serial myPort;
|
||||
|
||||
// Data samples
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
|
||||
float minX = 0;
|
||||
float maxX = 0;
|
||||
float minY = 0;
|
||||
float maxY = 0;
|
||||
float offX = 0;
|
||||
float offY = 0;
|
||||
|
||||
void setup ()
|
||||
{
|
||||
size(500, 500, P2D);
|
||||
background(0);
|
||||
stroke(255);
|
||||
|
||||
strokeWeight(2);
|
||||
|
||||
line(250, 0, 250, 500);
|
||||
line(0, 250, 500, 250);
|
||||
|
||||
strokeWeight(3);
|
||||
textSize(12);
|
||||
|
||||
myPort = new Serial(this, Serial.list()[0], 9600);
|
||||
myPort.bufferUntil(10);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
strokeWeight(0);
|
||||
fill(0); // Set fill to white
|
||||
rect(0, 0, 240, 50);
|
||||
|
||||
strokeWeight(2);
|
||||
fill(255); // Set fill to white
|
||||
text(minX+" "+maxX+" = "+offX, 10, 20);
|
||||
text(minY+" "+maxY+" = "+offY, 10, 35);
|
||||
point((x*0.5)+250, (y*0.5)+250);
|
||||
}
|
||||
|
||||
void serialEvent (Serial myPort)
|
||||
{
|
||||
String inString = myPort.readStringUntil(10);
|
||||
|
||||
if (inString != null)
|
||||
{
|
||||
inString = trim(inString);
|
||||
String[] list = split(inString, ':');
|
||||
String testString = trim(list[0]);
|
||||
|
||||
if (list.length != 8) return;
|
||||
|
||||
x = (float(list[0]));
|
||||
y = (float(list[1]));
|
||||
minX = (float(list[2]));
|
||||
maxX = (float(list[3]));
|
||||
minY = (float(list[4]));
|
||||
maxY = (float(list[5]));
|
||||
offX = (float(list[6]));
|
||||
offY = (float(list[7]));
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 32 KiB |
@ -0,0 +1,330 @@
|
||||
/*
|
||||
HMC5883L Triple Axis Digital Compass.
|
||||
Processing for HMC5883L_compensation_MPU6050.ino
|
||||
Processing for HMC5883L_compensation_ADXL345.ino
|
||||
Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
GIT: https://github.com/jarzebski/Arduino-HMC5883L
|
||||
Web: http://www.jarzebski.pl
|
||||
(c) 2014 by Korneliusz Jarzebski
|
||||
*/
|
||||
|
||||
import processing.serial.*;
|
||||
|
||||
Serial myPort;
|
||||
|
||||
// Data samples
|
||||
int actualSample = 0;
|
||||
int maxSamples = 500;
|
||||
int sampleStep = 1;
|
||||
boolean hasData = false;
|
||||
|
||||
// Charts
|
||||
PGraphics pgChart;
|
||||
int[] colors = { #ff4444, #33ff99 };
|
||||
String[] headingSeries = { "Normal", "Compensated"};
|
||||
|
||||
// Data for compare
|
||||
float[][] headingValues = new float[2][maxSamples];
|
||||
|
||||
// Artificial Horizon
|
||||
PGraphics pgCompassPlate;
|
||||
PImage imgCompass;
|
||||
PImage imgCompassRing;
|
||||
PImage imgCompassPlateWhite;
|
||||
PImage imgCompassPlateBlack;
|
||||
int compassWidth;
|
||||
int compassHeight;
|
||||
|
||||
void setup ()
|
||||
{
|
||||
size(570, 550, P2D);
|
||||
background(0);
|
||||
|
||||
// Init
|
||||
initCompass();
|
||||
|
||||
// Serial
|
||||
myPort = new Serial(this, Serial.list()[0], 9600);
|
||||
myPort.bufferUntil(10);
|
||||
}
|
||||
|
||||
void drawChart(String title, String[] series, float[][] chart, int x, int y, int h, boolean symmetric, boolean fixed, int fixedMin, int fixedMax, int hlines)
|
||||
{
|
||||
int actualColor = 0;
|
||||
|
||||
int maxA = 0;
|
||||
int maxB = 0;
|
||||
int maxAB = 0;
|
||||
|
||||
int min = 0;
|
||||
int max = 0;
|
||||
int step = 0;
|
||||
int divide = 0;
|
||||
|
||||
if (fixed)
|
||||
{
|
||||
min = fixedMin;
|
||||
max = fixedMax;
|
||||
step = hlines;
|
||||
} else
|
||||
{
|
||||
if (hlines > 2)
|
||||
{
|
||||
divide = (hlines - 2);
|
||||
} else
|
||||
{
|
||||
divide = 1;
|
||||
}
|
||||
|
||||
if (symmetric)
|
||||
{
|
||||
maxA = (int)abs(getMin(chart));
|
||||
maxB = (int)abs(getMax(chart));
|
||||
maxAB = max(maxA, maxB);
|
||||
step = (maxAB * 2) / divide;
|
||||
min = -maxAB-step;
|
||||
max = maxAB+step;
|
||||
} else
|
||||
{
|
||||
min = (int)(getMin(chart));
|
||||
max = (int)(getMax(chart));
|
||||
|
||||
if ((max >= 0) && (min <= 0)) step = (abs(min) + abs(max)) / divide;
|
||||
if ((max < 0) && (min < 0)) step = abs(min - max) / divide;
|
||||
if ((max > 0) && (min > 0)) step = (max - min) / divide;
|
||||
|
||||
if (divide > 1)
|
||||
{
|
||||
min -= step;
|
||||
max += step;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pgChart = createGraphics((maxSamples*sampleStep)+50, h+60);
|
||||
|
||||
pgChart.beginDraw();
|
||||
|
||||
// Draw chart area and title
|
||||
pgChart.background(0);
|
||||
pgChart.strokeWeight(1);
|
||||
pgChart.noFill();
|
||||
pgChart.stroke(50);
|
||||
pgChart.rect(0, 0, (maxSamples*sampleStep)+49, h+59);
|
||||
pgChart.text(title, ((maxSamples*sampleStep)/2)-(textWidth(title)/2)+40, 20);
|
||||
|
||||
// Draw chart description
|
||||
String Description[] = new String[chart.length];
|
||||
int DescriptionWidth[] = new int[chart.length];
|
||||
int DesctiptionTotalWidth = 0;
|
||||
int DescriptionOffset = 0;
|
||||
|
||||
for (int j = 0; j < chart.length; j++)
|
||||
{
|
||||
Description[j] = " "+series[j]+" = ";
|
||||
DescriptionWidth[j] += textWidth(Description[j]+"+0000.00");
|
||||
Description[j] += nf(chart[j][actualSample-1], 0, 2)+" ";
|
||||
DesctiptionTotalWidth += DescriptionWidth[j];
|
||||
}
|
||||
|
||||
actualColor = 0;
|
||||
|
||||
for (int j = 0; j < chart.length; j++)
|
||||
{
|
||||
pgChart.fill(colors[actualColor]);
|
||||
pgChart.text(Description[j], ((maxSamples*sampleStep)/2)-(DesctiptionTotalWidth/2)+DescriptionOffset+40, h+50);
|
||||
DescriptionOffset += DescriptionWidth[j];
|
||||
actualColor++;
|
||||
if (actualColor >= colors.length) actualColor = 0;
|
||||
}
|
||||
|
||||
// Draw H-Lines
|
||||
pgChart.stroke(100);
|
||||
|
||||
for (float t = min; t <= max; t=t+step)
|
||||
{
|
||||
float line = map(t, min, max, 0, h);
|
||||
pgChart.line(40, h-line+30, (maxSamples*sampleStep)+40, h-line+30);
|
||||
pgChart.fill(200, 200, 200);
|
||||
pgChart.textSize(12);
|
||||
pgChart.text(int(t), 5, h-line+34);
|
||||
}
|
||||
|
||||
// Draw data series
|
||||
pgChart.strokeWeight(2);
|
||||
|
||||
for (int i = 1; i < actualSample; i++)
|
||||
{
|
||||
actualColor = 0;
|
||||
|
||||
for (int j = 0; j < chart.length; j++)
|
||||
{
|
||||
pgChart.stroke(colors[actualColor]);
|
||||
|
||||
float d0 = chart[j][i-1];
|
||||
float d1 = chart[j][i];
|
||||
|
||||
if (d0 < min) d0 = min;
|
||||
if (d0 > max) d0 = max;
|
||||
if (d1 < min) d1 = min;
|
||||
if (d1 > max) d1 = max;
|
||||
|
||||
float v0 = map(d0, min, max, 0, h);
|
||||
float v1 = map(d1, min, max, 0, h);
|
||||
|
||||
pgChart.line(((i-1)*sampleStep)+40, h-v0+30, (i*sampleStep)+40, h-v1+30);
|
||||
|
||||
actualColor++;
|
||||
|
||||
if (actualColor >= colors.length) actualColor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pgChart.endDraw();
|
||||
|
||||
image(pgChart, x, y);
|
||||
}
|
||||
|
||||
void initCompass()
|
||||
{
|
||||
imgCompass = loadImage("compass.png");
|
||||
imgCompassRing = loadImage("compassRing.png");
|
||||
imgCompassPlateWhite = loadImage("compassPlateWhite.png");
|
||||
imgCompassPlateBlack = loadImage("compassPlateBlack.png");
|
||||
compassWidth = imgCompass.width;
|
||||
compassHeight = imgCompass.height;
|
||||
}
|
||||
|
||||
void drawCompass(int x, int y, float[] head, PImage plate)
|
||||
{
|
||||
pgCompassPlate = createGraphics(compassWidth, compassWidth);
|
||||
|
||||
float heading = head[actualSample-1];
|
||||
float north = 180 + heading;
|
||||
|
||||
pgCompassPlate.beginDraw();
|
||||
pgCompassPlate.clear();
|
||||
pgCompassPlate.translate(100,100);
|
||||
pgCompassPlate.rotate(-radians(heading));
|
||||
pgCompassPlate.image(plate, -100, -100);
|
||||
pgCompassPlate.endDraw();
|
||||
|
||||
image(pgCompassPlate, x+30, y+30);
|
||||
image(imgCompass, x, y);
|
||||
image(imgCompassRing, x, y);
|
||||
|
||||
textAlign(CENTER);
|
||||
text((int)heading+" deg", x+130, y+265);
|
||||
textAlign(LEFT);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
if (!hasData) return;
|
||||
|
||||
background(0);
|
||||
|
||||
drawChart("Heading [deg]", headingSeries, headingValues, 10, 280, 200, true, true, 0, 360, 30);
|
||||
drawCompass(10, 5, headingValues[0], imgCompassPlateWhite);
|
||||
drawCompass(295, 5, headingValues[1], imgCompassPlateWhite);
|
||||
}
|
||||
|
||||
float getMin(float[][] chart)
|
||||
{
|
||||
float minValue = 0;
|
||||
float[] testValues = new float[chart.length];
|
||||
float testMin = 0;
|
||||
|
||||
for (int i = 0; i < actualSample; i++)
|
||||
{
|
||||
for (int j = 0; j < testValues.length; j++)
|
||||
{
|
||||
testValues[j] = chart[j][i];
|
||||
}
|
||||
|
||||
testMin = min(testValues);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
minValue = testMin;
|
||||
} else
|
||||
{
|
||||
if (minValue > testMin) minValue = testMin;
|
||||
}
|
||||
}
|
||||
|
||||
return ceil(minValue)-1;
|
||||
}
|
||||
|
||||
float getMax(float[][] chart)
|
||||
{
|
||||
float maxValue = 0;
|
||||
float[] testValues = new float[chart.length];
|
||||
float testMax = 0;
|
||||
|
||||
for (int i = 0; i < actualSample; i++)
|
||||
{
|
||||
for (int j = 0; j < testValues.length; j++)
|
||||
{
|
||||
testValues[j] = chart[j][i];
|
||||
}
|
||||
|
||||
testMax = max(testValues);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
maxValue = testMax;
|
||||
} else
|
||||
{
|
||||
if (maxValue < testMax) maxValue = testMax;
|
||||
}
|
||||
}
|
||||
|
||||
return ceil(maxValue);
|
||||
}
|
||||
|
||||
void nextSample(float[][] chart)
|
||||
{
|
||||
for (int j = 0; j < chart.length; j++)
|
||||
{
|
||||
float last = chart[j][maxSamples-1];
|
||||
|
||||
for (int i = 1; i < maxSamples; i++)
|
||||
{
|
||||
chart[j][i-1] = chart[j][i];
|
||||
}
|
||||
|
||||
chart[j][(maxSamples-1)] = last;
|
||||
}
|
||||
}
|
||||
|
||||
void serialEvent (Serial myPort)
|
||||
{
|
||||
String inString = myPort.readStringUntil(10);
|
||||
|
||||
if (inString != null)
|
||||
{
|
||||
inString = trim(inString);
|
||||
String[] list = split(inString, ':');
|
||||
String testString = trim(list[0]);
|
||||
|
||||
if (list.length != 2) return;
|
||||
|
||||
// Headings
|
||||
headingValues[0][actualSample] = (float(list[0]));
|
||||
headingValues[1][actualSample] = (float(list[1]));
|
||||
|
||||
if (actualSample > 1)
|
||||
{
|
||||
hasData = true;
|
||||
}
|
||||
|
||||
if (actualSample == (maxSamples-1))
|
||||
{
|
||||
nextSample(headingValues);
|
||||
} else
|
||||
{
|
||||
actualSample++;
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 34 KiB |
@ -0,0 +1,341 @@
|
||||
/*
|
||||
HMC5883L Triple Axis Digital Compass.
|
||||
Processing for HMC5883L_processing.ino
|
||||
Processing for HMC5883L_processing_MPU6050.ino
|
||||
Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
GIT: https://github.com/jarzebski/Arduino-HMC5883L
|
||||
Web: http://www.jarzebski.pl
|
||||
(c) 2014 by Korneliusz Jarzebski
|
||||
*/
|
||||
|
||||
import processing.serial.*;
|
||||
|
||||
Serial myPort;
|
||||
|
||||
// Data samples
|
||||
int actualSample = 0;
|
||||
int maxSamples = 400;
|
||||
int sampleStep = 1;
|
||||
boolean hasData = false;
|
||||
|
||||
// Charts
|
||||
PGraphics pgChart;
|
||||
int[] colors = { #ff4444, #33ff99, #5588ff };
|
||||
String[] magneticSeries = { "XAxis", "YAxis", "ZAxis" };
|
||||
String[] headingSeries = { "Normal", "Fixed", "Smooth" };
|
||||
|
||||
// Data for compare
|
||||
float[][] magneticValues = new float[3][maxSamples];
|
||||
float[][] headingValues = new float[3][maxSamples];
|
||||
|
||||
// Artificial Horizon
|
||||
PGraphics pgCompassPlate;
|
||||
PImage imgCompass;
|
||||
PImage imgCompassRing;
|
||||
PImage imgCompassPlateWhite;
|
||||
PImage imgCompassPlateBlack;
|
||||
int compassWidth;
|
||||
int compassHeight;
|
||||
|
||||
void setup ()
|
||||
{
|
||||
size(755, 550, P2D);
|
||||
background(0);
|
||||
|
||||
// Init
|
||||
initCompass();
|
||||
|
||||
// Serial
|
||||
myPort = new Serial(this, Serial.list()[0], 9600);
|
||||
myPort.bufferUntil(10);
|
||||
}
|
||||
|
||||
void drawChart(String title, String[] series, float[][] chart, int x, int y, int h, boolean symmetric, boolean fixed, int fixedMin, int fixedMax, int hlines)
|
||||
{
|
||||
int actualColor = 0;
|
||||
|
||||
int maxA = 0;
|
||||
int maxB = 0;
|
||||
int maxAB = 0;
|
||||
|
||||
int min = 0;
|
||||
int max = 0;
|
||||
int step = 0;
|
||||
int divide = 0;
|
||||
|
||||
if (fixed)
|
||||
{
|
||||
min = fixedMin;
|
||||
max = fixedMax;
|
||||
step = hlines;
|
||||
} else
|
||||
{
|
||||
if (hlines > 2)
|
||||
{
|
||||
divide = (hlines - 2);
|
||||
} else
|
||||
{
|
||||
divide = 1;
|
||||
}
|
||||
|
||||
if (symmetric)
|
||||
{
|
||||
maxA = (int)abs(getMin(chart));
|
||||
maxB = (int)abs(getMax(chart));
|
||||
maxAB = max(maxA, maxB);
|
||||
step = (maxAB * 2) / divide;
|
||||
min = -maxAB-step;
|
||||
max = maxAB+step;
|
||||
} else
|
||||
{
|
||||
min = (int)(getMin(chart));
|
||||
max = (int)(getMax(chart));
|
||||
|
||||
if ((max >= 0) && (min <= 0)) step = (abs(min) + abs(max)) / divide;
|
||||
if ((max < 0) && (min < 0)) step = abs(min - max) / divide;
|
||||
if ((max > 0) && (min > 0)) step = (max - min) / divide;
|
||||
|
||||
if (divide > 1)
|
||||
{
|
||||
min -= step;
|
||||
max += step;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pgChart = createGraphics((maxSamples*sampleStep)+50, h+60);
|
||||
|
||||
pgChart.beginDraw();
|
||||
|
||||
// Draw chart area and title
|
||||
pgChart.background(0);
|
||||
pgChart.strokeWeight(1);
|
||||
pgChart.noFill();
|
||||
pgChart.stroke(50);
|
||||
pgChart.rect(0, 0, (maxSamples*sampleStep)+49, h+59);
|
||||
pgChart.text(title, ((maxSamples*sampleStep)/2)-(textWidth(title)/2)+40, 20);
|
||||
|
||||
// Draw chart description
|
||||
String Description[] = new String[chart.length];
|
||||
int DescriptionWidth[] = new int[chart.length];
|
||||
int DesctiptionTotalWidth = 0;
|
||||
int DescriptionOffset = 0;
|
||||
|
||||
for (int j = 0; j < chart.length; j++)
|
||||
{
|
||||
Description[j] = " "+series[j]+" = ";
|
||||
DescriptionWidth[j] += textWidth(Description[j]+"+0000.00");
|
||||
Description[j] += nf(chart[j][actualSample-1], 0, 2)+" ";
|
||||
DesctiptionTotalWidth += DescriptionWidth[j];
|
||||
}
|
||||
|
||||
actualColor = 0;
|
||||
|
||||
for (int j = 0; j < chart.length; j++)
|
||||
{
|
||||
pgChart.fill(colors[actualColor]);
|
||||
pgChart.text(Description[j], ((maxSamples*sampleStep)/2)-(DesctiptionTotalWidth/2)+DescriptionOffset+40, h+50);
|
||||
DescriptionOffset += DescriptionWidth[j];
|
||||
actualColor++;
|
||||
if (actualColor >= colors.length) actualColor = 0;
|
||||
}
|
||||
|
||||
// Draw H-Lines
|
||||
pgChart.stroke(100);
|
||||
|
||||
for (float t = min; t <= max; t=t+step)
|
||||
{
|
||||
float line = map(t, min, max, 0, h);
|
||||
pgChart.line(40, h-line+30, (maxSamples*sampleStep)+40, h-line+30);
|
||||
pgChart.fill(200, 200, 200);
|
||||
pgChart.textSize(12);
|
||||
pgChart.text(int(t), 5, h-line+34);
|
||||
}
|
||||
|
||||
// Draw data series
|
||||
pgChart.strokeWeight(2);
|
||||
|
||||
for (int i = 1; i < actualSample; i++)
|
||||
{
|
||||
actualColor = 0;
|
||||
|
||||
for (int j = 0; j < chart.length; j++)
|
||||
{
|
||||
pgChart.stroke(colors[actualColor]);
|
||||
|
||||
float d0 = chart[j][i-1];
|
||||
float d1 = chart[j][i];
|
||||
|
||||
if (d0 < min) d0 = min;
|
||||
if (d0 > max) d0 = max;
|
||||
if (d1 < min) d1 = min;
|
||||
if (d1 > max) d1 = max;
|
||||
|
||||
float v0 = map(d0, min, max, 0, h);
|
||||
float v1 = map(d1, min, max, 0, h);
|
||||
|
||||
pgChart.line(((i-1)*sampleStep)+40, h-v0+30, (i*sampleStep)+40, h-v1+30);
|
||||
|
||||
actualColor++;
|
||||
|
||||
if (actualColor >= colors.length) actualColor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pgChart.endDraw();
|
||||
|
||||
image(pgChart, x, y);
|
||||
}
|
||||
|
||||
void initCompass()
|
||||
{
|
||||
imgCompass = loadImage("compass.png");
|
||||
imgCompassRing = loadImage("compassRing.png");
|
||||
imgCompassPlateWhite = loadImage("compassPlateWhite.png");
|
||||
imgCompassPlateBlack = loadImage("compassPlateBlack.png");
|
||||
compassWidth = imgCompass.width;
|
||||
compassHeight = imgCompass.height;
|
||||
}
|
||||
|
||||
void drawCompass(int x, int y, float[][] head, PImage plate)
|
||||
{
|
||||
pgCompassPlate = createGraphics(compassWidth, compassWidth);
|
||||
|
||||
float heading = head[2][actualSample-1];
|
||||
float north = 180 + heading;
|
||||
|
||||
pgCompassPlate.beginDraw();
|
||||
pgCompassPlate.clear();
|
||||
pgCompassPlate.translate(100,100);
|
||||
pgCompassPlate.rotate(-radians(heading));
|
||||
pgCompassPlate.image(plate, -100, -100);
|
||||
pgCompassPlate.endDraw();
|
||||
|
||||
image(pgCompassPlate, x+30, y+30);
|
||||
image(imgCompass, x, y);
|
||||
image(imgCompassRing, x, y);
|
||||
|
||||
textAlign(CENTER);
|
||||
text((int)heading+" deg", x+130, y+265);
|
||||
textAlign(LEFT);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
if (!hasData) return;
|
||||
|
||||
background(0);
|
||||
|
||||
drawChart("Magnetic field [mG]", magneticSeries, magneticValues, 10, 10, 200, false, false, 0, 0, 10);
|
||||
drawChart("Heading [deg]", headingSeries, headingValues, 10, 280, 200, true, true, 0, 360, 30);
|
||||
drawCompass(480, 5, headingValues, imgCompassPlateWhite);
|
||||
drawCompass(480, 275, headingValues, imgCompassPlateBlack);
|
||||
|
||||
}
|
||||
|
||||
float getMin(float[][] chart)
|
||||
{
|
||||
float minValue = 0;
|
||||
float[] testValues = new float[chart.length];
|
||||
float testMin = 0;
|
||||
|
||||
for (int i = 0; i < actualSample; i++)
|
||||
{
|
||||
for (int j = 0; j < testValues.length; j++)
|
||||
{
|
||||
testValues[j] = chart[j][i];
|
||||
}
|
||||
|
||||
testMin = min(testValues);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
minValue = testMin;
|
||||
} else
|
||||
{
|
||||
if (minValue > testMin) minValue = testMin;
|
||||
}
|
||||
}
|
||||
|
||||
return ceil(minValue)-1;
|
||||
}
|
||||
|
||||
float getMax(float[][] chart)
|
||||
{
|
||||
float maxValue = 0;
|
||||
float[] testValues = new float[chart.length];
|
||||
float testMax = 0;
|
||||
|
||||
for (int i = 0; i < actualSample; i++)
|
||||
{
|
||||
for (int j = 0; j < testValues.length; j++)
|
||||
{
|
||||
testValues[j] = chart[j][i];
|
||||
}
|
||||
|
||||
testMax = max(testValues);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
maxValue = testMax;
|
||||
} else
|
||||
{
|
||||
if (maxValue < testMax) maxValue = testMax;
|
||||
}
|
||||
}
|
||||
|
||||
return ceil(maxValue);
|
||||
}
|
||||
|
||||
void nextSample(float[][] chart)
|
||||
{
|
||||
for (int j = 0; j < chart.length; j++)
|
||||
{
|
||||
float last = chart[j][maxSamples-1];
|
||||
|
||||
for (int i = 1; i < maxSamples; i++)
|
||||
{
|
||||
chart[j][i-1] = chart[j][i];
|
||||
}
|
||||
|
||||
chart[j][(maxSamples-1)] = last;
|
||||
}
|
||||
}
|
||||
|
||||
void serialEvent (Serial myPort)
|
||||
{
|
||||
String inString = myPort.readStringUntil(10);
|
||||
|
||||
if (inString != null)
|
||||
{
|
||||
inString = trim(inString);
|
||||
String[] list = split(inString, ':');
|
||||
String testString = trim(list[0]);
|
||||
|
||||
if (list.length != 6) return;
|
||||
|
||||
// Magnetic field
|
||||
magneticValues[0][actualSample] = (float(list[0]));
|
||||
magneticValues[1][actualSample] = (float(list[1]));
|
||||
magneticValues[2][actualSample] = (float(list[2]));
|
||||
|
||||
// Headings
|
||||
headingValues[0][actualSample] = (float(list[3]));
|
||||
headingValues[1][actualSample] = (float(list[4]));
|
||||
headingValues[2][actualSample] = (float(list[5]));
|
||||
|
||||
if (actualSample > 1)
|
||||
{
|
||||
hasData = true;
|
||||
}
|
||||
|
||||
if (actualSample == (maxSamples-1))
|
||||
{
|
||||
nextSample(magneticValues);
|
||||
nextSample(headingValues);
|
||||
} else
|
||||
{
|
||||
actualSample++;
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 34 KiB |
27
libraries/Arduino-HMC5883L-master/README.md
Normal file
@ -0,0 +1,27 @@
|
||||
Arduino-HMC5883L
|
||||
================
|
||||
|
||||
HMC5883L Triple Axis Digital Compass Arduino Library
|
||||
|
||||

|
||||
|
||||
Tutorials: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
|
||||
|
||||
YouTube: http://www.youtube.com/watch?v=zG3uzQW3wc0
|
||||
|
||||
This library use I2C to communicate, 2 pins are required to interface.
|
||||
|
||||
I need your help
|
||||
----------------
|
||||
|
||||
July 31, 2017
|
||||
|
||||
In the near future I plan to refactoring the libraries. The main goal is to improve code quality, new features and add support for different versions of Arduino boards like Uno, Mega and Zero.
|
||||
|
||||
For this purpose I need to buy modules, Arduino Boards and lot of beer.
|
||||
|
||||
If you want to support the further and long-term development of libraries, please help.
|
||||
|
||||
You can do this by transferring any amount to my PayPal account: paypal@jarzebski.pl
|
||||
|
||||
Thanks!
|
@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#define _GPRMC_TERM "GPRMC"
|
||||
#define _GPGGA_TERM "GPGGA"
|
||||
#define _GNRMC_TERM "GNRMC"
|
||||
#define _GNGGA_TERM "GNGGA"
|
||||
|
||||
TinyGPS::TinyGPS()
|
||||
: _time(GPS_INVALID_TIME)
|
||||
@ -212,9 +214,9 @@ bool TinyGPS::term_complete()
|
||||
// the first term determines the sentence type
|
||||
if (_term_number == 0)
|
||||
{
|
||||
if (!gpsstrcmp(_term, _GPRMC_TERM))
|
||||
if (!gpsstrcmp(_term, _GPRMC_TERM) || !gpsstrcmp(_term, _GNRMC_TERM))
|
||||
_sentence_type = _GPS_SENTENCE_GPRMC;
|
||||
else if (!gpsstrcmp(_term, _GPGGA_TERM))
|
||||
else if (!gpsstrcmp(_term, _GPGGA_TERM) || !gpsstrcmp(_term, _GNRMC_TERM))
|
||||
_sentence_type = _GPS_SENTENCE_GPGGA;
|
||||
else
|
||||
_sentence_type = _GPS_SENTENCE_OTHER;
|
||||
|