diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.cpp b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.cpp index d5a67d4..0fd5167 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.cpp +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_config.cpp @@ -1,3 +1,5 @@ +//#pragma once +//#include "pP_function.h" #include "pP_config.h" #include @@ -76,7 +78,7 @@ void restoreConfig() { EEPROM.get(LOGIC_ADDRESS, temp); if (temp < 0 || temp > 1) { - reset = true; + erase = true; } else { LOGIC = temp; } @@ -92,6 +94,9 @@ void restoreConfig() { if (erase) { eraseEEPROM(); } + + adjustFollow(); + adjustComp(); } void setDefaultConfig() { @@ -103,4 +108,6 @@ void setDefaultConfig() { Hyst = HYST_DEFAULT; LOGIC = LOGIC_DEFAULT; voltMeterConstant = VM_CONST_DEFAULT; + adjustFollow(); + adjustComp(); } diff --git a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h index 0b5391f..aea4a1b 100644 --- a/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h +++ b/firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.h @@ -3,6 +3,9 @@ Created by Alan "pyr0ball" Weinstock 6/26/2019 */ +//#pragma once +//#include "pP_function.h" + void digitalWriteFast(uint8_t pin, uint8_t x) { if (pin / 8) { // pin >= 8 PORTB ^= (-x ^ PORTB) & (1 << (pin % 8)); @@ -95,6 +98,9 @@ update the voltMeterConstant variable in pP_config.h with the correct value /* Compares diffs of threshold vs read value if positive, adjusts the follower to within the range set above*/ + followerLong = followerThrs * 1023L; + followerInt = (long long) followerLong / Vin; + followerInt = (int) followerInt; ADJ_FOLLOW = (followerInt / 4); // Analog output (PWM) of duty cycle @@ -104,6 +110,9 @@ update the voltMeterConstant variable in pP_config.h with the correct value /*------------------------------------------------*/ void adjustComp() { + compLong = compThrs * 1023L; + compInt = (long long) compLong / Vin; + compInt = (int) compInt; OCR1A = compInt; }