mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
OpticalFlow - bug fix - highest resolution was incorrectly set as 1200 instead of 1600
This commit is contained in:
parent
7877a872d3
commit
bcd63a9807
@ -237,17 +237,17 @@ AP_OpticalFlow_ADNS3080::set_led_always_on( bool alwaysOn )
|
|||||||
write_register(ADNS3080_CONFIGURATION_BITS, regVal);
|
write_register(ADNS3080_CONFIGURATION_BITS, regVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns resolution (either 400 or 1200 counts per inch)
|
// returns resolution (either 400 or 1600 counts per inch)
|
||||||
int
|
int
|
||||||
AP_OpticalFlow_ADNS3080::get_resolution()
|
AP_OpticalFlow_ADNS3080::get_resolution()
|
||||||
{
|
{
|
||||||
if( (read_register(ADNS3080_CONFIGURATION_BITS) & 0x10) == 0 )
|
if( (read_register(ADNS3080_CONFIGURATION_BITS) & 0x10) == 0 )
|
||||||
return 400;
|
return 400;
|
||||||
else
|
else
|
||||||
return 1200;
|
return 1600;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set parameter to 400 or 1200 counts per inch
|
// set parameter to 400 or 1600 counts per inch
|
||||||
void
|
void
|
||||||
AP_OpticalFlow_ADNS3080::set_resolution(int resolution)
|
AP_OpticalFlow_ADNS3080::set_resolution(int resolution)
|
||||||
{
|
{
|
||||||
@ -255,12 +255,17 @@ AP_OpticalFlow_ADNS3080::set_resolution(int resolution)
|
|||||||
|
|
||||||
if( resolution == ADNS3080_RESOLUTION_400 ) {
|
if( resolution == ADNS3080_RESOLUTION_400 ) {
|
||||||
regVal &= ~0x10;
|
regVal &= ~0x10;
|
||||||
}else if( resolution == ADNS3080_RESOLUTION_1200) {
|
scaler = AP_OPTICALFLOW_ADNS3080_SCALER;
|
||||||
|
}else if( resolution == ADNS3080_RESOLUTION_1600) {
|
||||||
regVal |= 0x10;
|
regVal |= 0x10;
|
||||||
|
scaler = AP_OPTICALFLOW_ADNS3080_SCALER * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
delayMicroseconds(50); // small delay
|
delayMicroseconds(50); // small delay
|
||||||
write_register(ADNS3080_CONFIGURATION_BITS, regVal);
|
write_register(ADNS3080_CONFIGURATION_BITS, regVal);
|
||||||
|
|
||||||
|
// this will affect conversion factors so update them
|
||||||
|
update_conversion_factors();
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_frame_rate_auto - return whether frame rate is set to "auto" or manual
|
// get_frame_rate_auto - return whether frame rate is set to "auto" or manual
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
#define ADNS3080_LED_MODE_WHEN_REQUIRED 0x01
|
#define ADNS3080_LED_MODE_WHEN_REQUIRED 0x01
|
||||||
|
|
||||||
#define ADNS3080_RESOLUTION_400 400
|
#define ADNS3080_RESOLUTION_400 400
|
||||||
#define ADNS3080_RESOLUTION_1200 1200
|
#define ADNS3080_RESOLUTION_1600 1600
|
||||||
|
|
||||||
// Extended Configuration bits
|
// Extended Configuration bits
|
||||||
#define ADNS3080_SERIALNPU_OFF 0x02
|
#define ADNS3080_SERIALNPU_OFF 0x02
|
||||||
@ -118,8 +118,8 @@ class AP_OpticalFlow_ADNS3080 : public AP_OpticalFlow
|
|||||||
bool get_led_always_on(); // returns true if LED is always on, false if only on when required
|
bool get_led_always_on(); // returns true if LED is always on, false if only on when required
|
||||||
void set_led_always_on( bool alwaysOn ); // set parameter to true if you want LED always on, otherwise false for only when required
|
void set_led_always_on( bool alwaysOn ); // set parameter to true if you want LED always on, otherwise false for only when required
|
||||||
|
|
||||||
int get_resolution(); // returns resolution (either 400 or 1200 counts per inch)
|
int get_resolution(); // returns resolution (either 400 or 1600 counts per inch)
|
||||||
void set_resolution(int resolution); // set parameter to 400 or 1200 counts per inch
|
void set_resolution(int resolution); // set parameter to 400 or 1600 counts per inch
|
||||||
|
|
||||||
bool get_frame_rate_auto(); // get_frame_rate_auto - return true if frame rate is set to "auto", false if manual
|
bool get_frame_rate_auto(); // get_frame_rate_auto - return true if frame rate is set to "auto", false if manual
|
||||||
void set_frame_rate_auto(bool auto_frame_rate); // set_frame_rate_auto(bool) - set frame rate to auto (true), or manual (false)
|
void set_frame_rate_auto(bool auto_frame_rate); // set_frame_rate_auto(bool) - set frame rate to auto (true), or manual (false)
|
||||||
|
@ -201,7 +201,7 @@ void set_resolution()
|
|||||||
Serial.print("resolution: ");
|
Serial.print("resolution: ");
|
||||||
Serial.println(resolution);
|
Serial.println(resolution);
|
||||||
Serial.println("Choose new value:");
|
Serial.println("Choose new value:");
|
||||||
Serial.println(" 1) 1200");
|
Serial.println(" 1) 1600");
|
||||||
Serial.println(" 4) 400");
|
Serial.println(" 4) 400");
|
||||||
Serial.println(" x) exit");
|
Serial.println(" x) exit");
|
||||||
Serial.println();
|
Serial.println();
|
||||||
@ -215,10 +215,9 @@ void set_resolution()
|
|||||||
|
|
||||||
// update resolution
|
// update resolution
|
||||||
if( value == '1' ) {
|
if( value == '1' ) {
|
||||||
flowSensor.set_resolution(ADNS3080_RESOLUTION_1200);
|
flowSensor.set_resolution(ADNS3080_RESOLUTION_1600);
|
||||||
}
|
}
|
||||||
if( value == '4' ) {
|
if( value == '4' ) {
|
||||||
Serial.println("you want 1200!");
|
|
||||||
flowSensor.set_resolution(ADNS3080_RESOLUTION_400);
|
flowSensor.set_resolution(ADNS3080_RESOLUTION_400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user