diff --git a/ChangeLog.md b/ChangeLog.md index f13ad22..4ee12f3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,12 @@ # Yatuli Changelog File # +================================================== +## Release v0.5 (May 29, 2017) (Public Release) ## + +### Improvements ### + +* Feature: now you has a lock var, when lock is true the code will refuse to update any values coming from the ADC; this is to avoid any form of FM modulation due to voltage variations due to high currents or RF when in use in real transceivers. + ================================================== ## Release v0.4 (May 22, 2017) (First Public Release) ## diff --git a/README.md b/README.md index 9907fe2..40214f0 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ This is a kind of linear tuning and in the center with big steps on the edges: * You can dynamically reset the range and start value while running (useful in setups). * Negative values are supported in all the range (start, end & value) * Range is handled by 32 bit signed values, so it will work from -/+ 2.4G values. +* Lock feature, you can lock in the lib when in TX (or wherever you case it). See the examples bundled with the lib for use cases. diff --git a/library.properties b/library.properties index 54bac17..45dabcc 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Yatuli (Yet Another Tune Library) -version=0.4 +version=0.5 author=Pavel Milanes maintainer=Pavel Milanes sentence=Tune your hardware with a linear potentiometer instead a rotary encoder: be cheap, have Fun! diff --git a/src/yatuli.cpp b/src/yatuli.cpp index 21f6192..19a4ac7 100644 --- a/src/yatuli.cpp +++ b/src/yatuli.cpp @@ -17,7 +17,7 @@ * You can get the latest code in this Github repository: * * https://github.com/pavelmc/yatuli - * + * * 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 @@ -56,6 +56,9 @@ void Yatuli::init(uint8_t _pin, int32_t _start, int32_t _end, uint16_t _step, ui // some defaults base = start; value = start; + + // defaults to unlock state + lock = false; } @@ -86,11 +89,14 @@ void Yatuli::set(int32_t init_value) { * This is the one you NEED to run in every loop cycle to update value ****************************************************************************/ void Yatuli::check(void) { + // lock flag + if (lock) return; + // internal vars, statics as they are used repeatedly in this. static int16_t lastAdc = adc; static uint32_t newTime = millis(); static boolean adcDir; - + // update adc values _osadc(); @@ -109,18 +115,18 @@ void Yatuli::check(void) { // move value += (edgeStep * t); base += (edgeStep * t); - + // reset pace timer newTime = millis() + PACE; } } else { // we are in the operative range // flutter fix, from bitx amunters raduino code, author Jerry KE7ER - + // direction detectors... (re-using vars) up = (adc > lastAdc) && (adcDir == 1 || (adc - lastAdc) > 5); down = (adc < lastAdc) && (adcDir == 0 || (lastAdc - adc) > 5); - + // check it now if (up || down) { // flag about the direction of the movement @@ -132,7 +138,7 @@ void Yatuli::check(void) { // force an update value = base + (int32_t)(adc / 10) * step; - + // force a consistent step interval value /= step; value *= step; @@ -149,6 +155,9 @@ void Yatuli::check(void) { * convenient range of -5115 to +5115 ****************************************************************************/ void Yatuli::_osadc(void) { + // lock flag + if (lock) return; + // internal var int32_t t = 0; @@ -170,9 +179,12 @@ void Yatuli::_osadc(void) { * See OptionSelect example ****************************************************************************/ int8_t Yatuli::dir(void) { + // lock flag + if (lock) return; + // internal var static int16_t lastAdcDir = adc; - + // calc the difference and scale to 20 tick per dial rotation int16_t result = (adc - lastAdcDir)/DIRTICKS; diff --git a/src/yatuli.h b/src/yatuli.h index a7622e2..993427b 100644 --- a/src/yatuli.h +++ b/src/yatuli.h @@ -17,7 +17,7 @@ * You can get the latest code in this Github repository: * * https://github.com/pavelmc/yatuli - * + * * 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 @@ -66,13 +66,18 @@ class Yatuli { // Return a relative vector from the last position: -1/0/+1 // it will emit about ~50 steps in one rotation - // WATCH OUT!: int8_t is char in arduino + // WATCH OUT!: int8_t is char in arduino int8_t dir(void); // public value int16_t adc; // oversampled ADC in the range -5115/+5115 int32_t value; // real value in the range + // lock feature, when lock is true, we refuse to update the value/dir + // as in a real TX high currents or RF can disturb the ADC and add FMing + // to the real freq. + bool lock; + private: int32_t start; // start of the range int32_t end; // stop of the range diff --git a/version b/version index 1811f96..83b4ac5 100644 --- a/version +++ b/version @@ -1 +1 @@ -v0.4 +v0.5