PAW3902: align mode change logic with the spec

1. The spec specifies that the mode change condition should be met for 10
   consecutive frames before changing to the next mode.
2. The spec (and comment) says that "PAW3902JF should not operate with Shutter < 0x01F4 in Mode 2" -
   however the if condition checked the reverse condition

Signed-off-by: Koby Aizer <koby.aizer@tg-17.com>
This commit is contained in:
pengl-aee09
2020-06-05 14:43:15 +08:00
committed by Daniel Agar
parent 8a3a71caed
commit 18eccb0cbd
2 changed files with 42 additions and 15 deletions
+38 -15
View File
@@ -155,6 +155,10 @@ PAW3902::changeMode(Mode newMode)
_mode = newMode; _mode = newMode;
} }
_bright_to_low_counter = 0;
_low_to_superlow_counter = 0;
_low_to_bright_counter = 0;
_superlow_to_low_counter = 0;
// Approximate Resolution = (Register Value + 1) * (50 / 8450) ≈ 0.6% of data point in Figure 19 // Approximate Resolution = (Register Value + 1) * (50 / 8450) ≈ 0.6% of data point in Figure 19
// The maximum register value is 0xA8. The minimum register value is 0. // The maximum register value is 0xA8. The minimum register value is 0.
uint8_t resolution = registerRead(Register::Resolution); uint8_t resolution = registerRead(Register::Resolution);
@@ -589,21 +593,38 @@ PAW3902::RunImpl()
switch (_mode) { switch (_mode) {
case Mode::Bright: case Mode::Bright:
if ((shutter >= 0x1FFE) && (buf.data.RawData_Sum < 0x3C)) { // AND valid for 10 consecutive frames? if ((shutter >= 0x1FFE) && (buf.data.RawData_Sum < 0x3C)) {
// Bright -> LowLight _bright_to_low_counter++;
changeMode(Mode::LowLight);
if (_bright_to_low_counter >= 10) { // AND valid for 10 consecutive frames
// Bright -> LowLight
changeMode(Mode::LowLight);
}
} else {
_bright_to_low_counter = 0;
} }
break; break;
case Mode::LowLight: case Mode::LowLight:
if ((shutter >= 0x1FFE) && (buf.data.RawData_Sum < 0x5A)) { // AND valid for 10 consecutive frames? if ((shutter >= 0x1FFE) && (buf.data.RawData_Sum < 0x5A)) {
// LowLight -> SuperLowLight _low_to_bright_counter = 0;
changeMode(Mode::SuperLowLight); _low_to_superlow_counter++;
} else if ((shutter < 0x0BB8)) { // AND valid for 10 consecutive frames? if (_low_to_superlow_counter >= 10) { // AND valid for 10 consecutive frames
// LowLight -> Bright // LowLight -> SuperLowLight
changeMode(Mode::Bright); changeMode(Mode::SuperLowLight);
}
} else if ((shutter < 0x0BB8)) {
_low_to_superlow_counter = 0;
_low_to_bright_counter++;
if (_low_to_bright_counter >= 10) { // AND valid for 10 consecutive frames
// LowLight -> Bright
changeMode(Mode::Bright);
}
} }
break; break;
@@ -611,13 +632,15 @@ PAW3902::RunImpl()
case Mode::SuperLowLight: case Mode::SuperLowLight:
// SuperLowLight -> LowLight // SuperLowLight -> LowLight
if ((shutter < 0x03E8)) { // AND valid for 10 consecutive frames? if ((shutter < 0x03E8)) {
changeMode(Mode::LowLight); _superlow_to_low_counter++;
}
// PAW3902JF should not operate with Shutter < 0x01F4 in Mode 2 if (_superlow_to_low_counter >= 10) { // AND valid for 10 consecutive frames
if (shutter >= 0x01F4) { changeMode(Mode::LowLight);
changeMode(Mode::LowLight); }
} else {
_superlow_to_low_counter = 0;
} }
break; break;
@@ -119,5 +119,9 @@ private:
int _flow_sum_y{0}; int _flow_sum_y{0};
Mode _mode{Mode::LowLight}; Mode _mode{Mode::LowLight};
uint8_t _bright_to_low_counter{0};
uint8_t _low_to_superlow_counter{0};
uint8_t _low_to_bright_counter{0};
uint8_t _superlow_to_low_counter{0};
}; };