Migrated configs to separate header file, made adjustment to definition

This commit is contained in:
pyr0ball 2019-07-19 15:04:01 -07:00
parent 95ea534381
commit 56c06008d4
3 changed files with 50 additions and 16 deletions

View file

@ -54,16 +54,6 @@ The gain STATE is representative of these values:
4 = 11x 4 = 11x
*/ */
// Configurable settings:
int GAIN_FACTOR = 2; // Gain adjustment factor. 0=3x, 1=3.5x, 2=4.33x, 3=6x, 4=11x
#define InitCount 6 // Number of times to blink the LED on start
int LOOP_DUR = 50; // duration of time between ADC checks and other loop functions
int TRG_DUR = 20; // duration of the Z-axis pulse sent, in ms
#define senseThrs 1450
#define compThrs 2850
int Hyst = 20; // Hysteresis value for ADC measurements
long voltMeterConstant = 1125300L; // For fine tuning input voltage sense
/*------------------------------------------------------------*/ /*------------------------------------------------------------*/
// Debug output toggle. Uncomment to enable // Debug output toggle. Uncomment to enable
@ -76,12 +66,13 @@ long voltMeterConstant = 1125300L; // For fine tuning input voltage sense
// Headers, variables, and functions // Headers, variables, and functions
#include "LightChrono.h" #include "LightChrono.h"
#include "pP_pins.h" #include "pP_pins.h"
#include "pP_config.h"
#include "pP_volatile.h" #include "pP_volatile.h"
#include "pP_function.h" #include "pP_function.h"
#include "pP_serial.h" #include "pP_serial.h"
// i2c input toggle. Uncomment to enable // i2c input toggle. Uncomment to enable
#define I2C true //#define I2C_INPUT true
void setup() { void setup() {
pinMode(TRG_OUT, OUTPUT); // declare the Trigger as as OUTPUT pinMode(TRG_OUT, OUTPUT); // declare the Trigger as as OUTPUT
@ -103,7 +94,7 @@ void setup() {
/*------------------------------------------------*/ /*------------------------------------------------*/
void loop() { void loop() {
if (mainLoop.haspassed(LOOP_DUR)) { if (mainLoop.hasPassed(LOOP_DUR)) {
mainLoop.restart(); mainLoop.restart();
// Blink LED's on init // Blink LED's on init
if (BlinkCount > 0) { if (BlinkCount > 0) {

View file

@ -0,0 +1,41 @@
// Configurable settings:
#if !(defined(GAIN_FACTOR))
int GAIN_FACTOR = 2; // Gain adjustment factor. 0=3x, 1=3.5x, 2=4.33x, 3=6x, 4=11x
#endif
#ifndef senseThrs
#define senseThrs 1450
#endif
#ifndef compThrs
#define compThrs 2850
#endif
#ifndef InitCount
#define InitCount 6 // Number of times to blink the LED on start
#endif
#if !(defined(LOOP_DUR))
int LOOP_DUR = 50; // duration of time between ADC checks and other loop functions
#endif
#if !(defined(TRG_DUR))
int TRG_DUR = 20; // duration of the Z-axis pulse sent, in ms
#endif
#if !(defined(Hyst))
int Hyst = 20; // Hysteresis value for ADC measurements
#endif
#if !(defined(voldMeterConstant))
long voltMeterConstant = 1125300L; // For fine tuning input voltage sense
#endif
#ifdef I2C
#if !(defined(pP_i2c_address))
byte pP_i2c_address = 0xa0; // I2C Bus Address
#endif
#endif

View file

@ -9,10 +9,11 @@ int VOld = 5000; // Variable to store previous cycle's Vin
int VLast = 0; int VLast = 0;
// Convert threshold values based on the input voltage // Convert threshold values based on the input voltage
long senseLong = senseThrs * 1024L; long senseLong = senseThrs * 1024L;
long compLong = compThrs * 1024L; long compLong = compThrs * 1024L;
long senseInt = senseLong / Vin; long senseInt;
long compInt = compLong / Vin; long compInt;
// Voltage Comparator Adjustment parameters // Voltage Comparator Adjustment parameters
int VComp = 0; int VComp = 0;
@ -25,6 +26,7 @@ int diffAdjL = VAdj - senseInt;
int diffAdjH = senseInt - VAdj; int diffAdjH = senseInt - VAdj;
// Error blink parameters // Error blink parameters
int BlinkState = LOW; int BlinkState = LOW;
int BlinkCount = InitCount * 2; // Multiply Blink count by 2 to handle toggle state int BlinkCount = InitCount * 2; // Multiply Blink count by 2 to handle toggle state
@ -39,8 +41,8 @@ bool serialIncoming = false;
char serialMessageIn[buffSize] = {0}; char serialMessageIn[buffSize] = {0};
int serialInt = 0; int serialInt = 0;
#define LOW 0 //#define LOW 0
#define HIGH 1 //#define HIGH 1
// Task scheduler instances // Task scheduler instances
LightChrono mainLoop; LightChrono mainLoop;