Add "Auto" mode to FrequencyField (#959)

* Add "Auto" mode to FrequencyField
* Use exponential function instead of hyperbolic
* Fix tabs
* Back to hyperbolic, better feel
This commit is contained in:
Kyle Reed 2023-05-07 13:01:43 -07:00 committed by GitHub
parent dfadd38e32
commit f22046eccc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 2 deletions

1
.gitignore vendored
View File

@ -13,6 +13,7 @@
/sdcard/FREQMAN/BHT* /sdcard/FREQMAN/BHT*
/sdcard/FREQMAN/R.TXT /sdcard/FREQMAN/R.TXT
/sdcard/FREQMAN/XXX.TXT /sdcard/FREQMAN/XXX.TXT
/armbin
# Compiled Object files # Compiled Object files
*.slo *.slo

View File

@ -40,7 +40,7 @@ public:
void focus() override; void focus() override;
std::string title() const override { return "Flash Utility"; }; std::string title() const override { return "SD over USB"; };
private: private:
NavigationView& nav_; NavigationView& nav_;

View File

@ -87,7 +87,22 @@ bool FrequencyField::on_key(const ui::KeyEvent event) {
} }
bool FrequencyField::on_encoder(const EncoderEvent delta) { bool FrequencyField::on_encoder(const EncoderEvent delta) {
set_value(value() + (delta * step)); if (step == 0) { // 'Auto' mode.'
auto ms = RTT2MS(halGetCounterValue());
auto delta_ms = last_ms_ <= ms ? ms - last_ms_ : ms;
last_ms_ = ms;
// The goal is to map 'scale' to a range of about 10 to 10M.
// The faster the encoder is rotated, the larger the step.
// Linear doesn't feel right. Hyperbolic felt better.
// To get these magic numbers, I graphed the function until the
// curve shape seemed about right then tested on device.
delta_ms = std::min(145ull, delta_ms) + 5; // Prevent DIV/0
int64_t scale = 200'000'000 / (0.001'55 * pow(delta_ms, 5.45)) + 8;
set_value(value() + (delta * scale));
} else {
set_value(value() + (delta * step));
}
return true; return true;
} }

View File

@ -63,6 +63,7 @@ private:
const range_t range; const range_t range;
rf::Frequency value_ { 0 }; rf::Frequency value_ { 0 };
rf::Frequency step { 25000 }; rf::Frequency step { 25000 };
uint64_t last_ms_ { 0 };
rf::Frequency clamp_value(rf::Frequency value); rf::Frequency clamp_value(rf::Frequency value);
}; };
@ -247,6 +248,7 @@ public:
parent_pos, parent_pos,
5, 5,
{ {
{ " Auto", 0 }, /* Faster == larger step. */
{ " 10", 10 }, /* Fine tuning SSB voice pitch,in HF and QO-100 sat #669 */ { " 10", 10 }, /* Fine tuning SSB voice pitch,in HF and QO-100 sat #669 */
{ " 50", 50 }, /* added 50Hz/10Hz,but we do not increase GUI digit decimal */ { " 50", 50 }, /* added 50Hz/10Hz,but we do not increase GUI digit decimal */
{ " 100", 100 }, { " 100", 100 },