Adds support for inverting trigger logic. #featureadd

- Addresses #61
This commit is contained in:
pyr0ball 2019-11-12 18:25:14 -08:00
parent 407c9834d1
commit 5b8c409c10
4 changed files with 22 additions and 6 deletions

View file

@ -7,6 +7,7 @@ int compThrs = COMP_THRESHOLD_DEFAULT;
int LOOP_DUR = LOOP_DUR_DEFAULT; // duration of time between ADC checks and other loop functions
int TRG_DUR = TRG_DUR_DEFAULT; // duration of the Z-axis pulse sent, in ms
int Hyst = HYST_DEFAULT; // Hysteresis value for ADC measurements
bool LOGIC = LOGIC_DEFAULT; // Trigger output logic (active low or active high)
int Debug = 0;
long voltMeterConstant = VM_CONST_DEFAULT;
uint8_t pP_i2c_address = 0xa0;
@ -21,6 +22,7 @@ void eraseEEPROM() {
EEPROM.put(LOOP_DUR_ADDRESS, LOOP_DUR);
EEPROM.put(TRG_DUR_ADDRESS, TRG_DUR);
EEPROM.put(HYST_ADDRESS, Hyst);
EEPROM.put(LOGIC_ADDRESS, LOGIC);
EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant);
}
@ -72,6 +74,13 @@ void restoreConfig() {
Hyst = temp;
}
EEPROM.get(LOGIC_ADDRESS, temp);
if (temp < 0 || temp > 1) {
reset = true;
} else {
LOGIC = temp;
}
long longTemp;
EEPROM.get(VM_CONST_ADDRESS, longTemp);
if (longTemp < 1000000L || longTemp > 1200000L) {
@ -92,5 +101,6 @@ void setDefaultConfig() {
LOOP_DUR = LOOP_DUR_DEFAULT;
TRG_DUR = TRG_DUR_DEFAULT;
Hyst = HYST_DEFAULT;
LOGIC = LOGIC_DEFAULT;
voltMeterConstant = VM_CONST_DEFAULT;
}

View file

@ -43,6 +43,12 @@
extern int Hyst; // Hysteresis value for ADC measurements
#endif
#define LOGIC_DEFAULT 0
#define LOGIC_ADDRESS 24
#if !(defined(LOGIC))
extern bool LOGIC; // Trigger logic scheme, Active LOW is default
#endif
#if !(defined(Debug))
extern int Debug;
#endif
@ -58,10 +64,10 @@
#if !(defined(pP_i2c_address))
extern uint8_t pP_i2c_address; // I2C Bus Address
#endif
#endif
#endif // I2C_INPUT
void eraseEEPROM();
void setDefaultConfig();
void restoreConfig();
#endif
#endif // PP_CONFIG_H

View file

@ -23,10 +23,10 @@ int inline analogReadFast(byte ADCpin)
/*------------------------------------------------*/
void pulse() {
digitalWriteFast(TRG_OUT, LOW);
digitalWriteFast(TRG_OUT, LOGIC);
sensorHReading = 1;
delay(TRG_DUR);
digitalWriteFast(TRG_OUT, HIGH);
digitalWriteFast(TRG_OUT, !LOGIC);
Serial.println("Trig'd!");
}

View file

@ -23,7 +23,7 @@ int VFol = 0;
// Error blink parameters
int BlinkState = LOW;
int BlinkState = 0;
int BlinkCount = (InitCount * 2) + 1; // Multiply Blink count by 2 to handle toggle state, add one extra to make sure light is on after
// Serial Input Parsing Variables