summaryrefslogtreecommitdiffhomepage
path: root/tracker-trackhat/settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-trackhat/settings.cpp')
-rw-r--r--tracker-trackhat/settings.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/tracker-trackhat/settings.cpp b/tracker-trackhat/settings.cpp
index f9a866bf..0ecca16d 100644
--- a/tracker-trackhat/settings.cpp
+++ b/tracker-trackhat/settings.cpp
@@ -7,6 +7,14 @@ namespace trackhat_impl {
trackhat_settings::trackhat_settings() : opts{"tracker-trackhat"}
{
}
+int trackhat_settings::effective_exposure() const
+{
+ return std::clamp((int)*exposure, min_exposure, max_exposure);
+}
+int trackhat_settings::effective_gain() const
+{
+ return min_gain + std::clamp((int)*exposure - max_exposure, 0, max_gain - min_gain);
+}
void setting_receiver::settings_changed()
{
@@ -80,12 +88,12 @@ void trackhat_camera::set_pt_options()
bool trackhat_camera::init_regs()
{
- auto exp = (uint8_t)t.exposure;
+ auto exp = (uint8_t)t.effective_exposure();
auto exp2 = (uint8_t)(exp == 0xff ? 0xf0 : 0xff);
auto thres = (uint8_t)t.threshold;
auto thres2 = (uint8_t)3;
- auto gain = (uint8_t)((int)*t.gain);
+ auto gain = (uint8_t)t.effective_gain();
auto gain_c = (uint8_t)(gain/0x10);
gain %= 0x10; gain_c %= 4;