fixing serial input not taking effect immediately #bugfix

Not a complete fix, still needs work
This commit is contained in:
pyr0ball 2019-12-18 16:12:44 -08:00
parent d30c60639c
commit 4076423e1b
2 changed files with 17 additions and 1 deletions

View file

@ -1,3 +1,5 @@
//#pragma once
//#include "pP_function.h"
#include "pP_config.h" #include "pP_config.h"
#include <EEPROM.h> #include <EEPROM.h>
@ -76,7 +78,7 @@ void restoreConfig() {
EEPROM.get(LOGIC_ADDRESS, temp); EEPROM.get(LOGIC_ADDRESS, temp);
if (temp < 0 || temp > 1) { if (temp < 0 || temp > 1) {
reset = true; erase = true;
} else { } else {
LOGIC = temp; LOGIC = temp;
} }
@ -92,6 +94,9 @@ void restoreConfig() {
if (erase) { if (erase) {
eraseEEPROM(); eraseEEPROM();
} }
adjustFollow();
adjustComp();
} }
void setDefaultConfig() { void setDefaultConfig() {
@ -103,4 +108,6 @@ void setDefaultConfig() {
Hyst = HYST_DEFAULT; Hyst = HYST_DEFAULT;
LOGIC = LOGIC_DEFAULT; LOGIC = LOGIC_DEFAULT;
voltMeterConstant = VM_CONST_DEFAULT; voltMeterConstant = VM_CONST_DEFAULT;
adjustFollow();
adjustComp();
} }

View file

@ -3,6 +3,9 @@
Created by Alan "pyr0ball" Weinstock 6/26/2019 Created by Alan "pyr0ball" Weinstock 6/26/2019
*/ */
//#pragma once
//#include "pP_function.h"
void digitalWriteFast(uint8_t pin, uint8_t x) { void digitalWriteFast(uint8_t pin, uint8_t x) {
if (pin / 8) { // pin >= 8 if (pin / 8) { // pin >= 8
PORTB ^= (-x ^ PORTB) & (1 << (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 /* Compares diffs of threshold vs read value
if positive, adjusts the follower to within if positive, adjusts the follower to within
the range set above*/ the range set above*/
followerLong = followerThrs * 1023L;
followerInt = (long long) followerLong / Vin;
followerInt = (int) followerInt;
ADJ_FOLLOW = (followerInt / 4); ADJ_FOLLOW = (followerInt / 4);
// Analog output (PWM) of duty cycle // Analog output (PWM) of duty cycle
@ -104,6 +110,9 @@ update the voltMeterConstant variable in pP_config.h with the correct value
/*------------------------------------------------*/ /*------------------------------------------------*/
void adjustComp() { void adjustComp() {
compLong = compThrs * 1023L;
compInt = (long long) compLong / Vin;
compInt = (int) compInt;
OCR1A = compInt; OCR1A = compInt;
} }