Separating declaration and definition - volatile

This commit is contained in:
Vsevolod Merenkov 2020-02-19 03:32:22 +03:00
parent 36b6402b2e
commit bf800e9940
3 changed files with 56 additions and 19 deletions

View file

@ -89,7 +89,7 @@ update the voltMeterConstant variable in pP_config.h with the correct value
#include <EEPROM.h> #include <EEPROM.h>
#include "LightChrono.h" #include "LightChrono.h"
#include "pP_pins.h" #include "pP_pins.h"
#include "pP_config.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"

View file

@ -0,0 +1,36 @@
#include "pP_volatile.h"
#include "pP_config.h"
#include "stdint.h"
// these variables will change on their own. Do not edit ANYTHING below this line
volatile int sensorHReading = 0; // variable to store the value read from the sensor pin
volatile int ADJ_FOLLOW = 0; // Variable for Follower adjustment
volatile int ADJ_COMP = 0; // Variable for Comparator adjustment
volatile int ERR_STATE = 0;
volatile int PZ_STATE = 0;
int Vin = 5000; // input reference voltage in millivolts (multiply V by 1000)
int VOld = 5000; // Variable to store previous cycle's Vin
int VLast = 0;
// Convert threshold values based on the input voltage
long followerLong = followerThrs * 1023L;
long compLong = compThrs * 1023L;
// Voltage Comparator Adjustment parameters
int VComp = 0;
// Voltage Follower Adjustment parameters
int VFol = 0;
// Error blink parameters
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
uint8_t bytesRecvd = 0;
bool serialIncoming = false;
char serialMessageIn[buffSize] = {0};
long serialLong = 0;

View file

@ -2,44 +2,45 @@
#define PP_VOLATILE_H #define PP_VOLATILE_H
#include "LightChrono.h" #include "LightChrono.h"
#include "stdint.h"
// these variables will change on their own. Do not edit ANYTHING below this line // these variables will change on their own. Do not edit ANYTHING below this line
volatile int sensorHReading = 0; // variable to store the value read from the sensor pin extern volatile int sensorHReading; // variable to store the value read from the sensor pin
volatile int ADJ_FOLLOW = 0; // Variable for Follower adjustment extern volatile int ADJ_FOLLOW; // Variable for Follower adjustment
volatile int ADJ_COMP = 0; // Variable for Comparator adjustment extern volatile int ADJ_COMP; // Variable for Comparator adjustment
volatile int ERR_STATE = 0; extern volatile int ERR_STATE;
volatile int PZ_STATE = 0; extern volatile int PZ_STATE;
int Vin = 5000; // input reference voltage in millivolts (multiply V by 1000) extern int Vin; // input reference voltage in millivolts (multiply V by 1000)
int VOld = 5000; // Variable to store previous cycle's Vin extern int VOld; // Variable to store previous cycle's Vin
int VLast = 0; extern int VLast;
// Convert threshold values based on the input voltage // Convert threshold values based on the input voltage
long followerLong = followerThrs * 1023L; extern long followerLong;
long compLong = compThrs * 1023L; extern long compLong;
long followerInt; long followerInt;
long compInt; long compInt;
// Voltage Comparator Adjustment parameters // Voltage Comparator Adjustment parameters
int VComp = 0; extern int VComp;
// Voltage Follower Adjustment parameters // Voltage Follower Adjustment parameters
int VFol = 0; extern int VFol;
// Error blink parameters // Error blink parameters
int BlinkState = 0; extern int BlinkState;
int BlinkCount = (InitCount * 2) + 1; // Multiply Blink count by 2 to handle toggle state, add one extra to make sure light is on after extern int BlinkCount; // Multiply Blink count by 2 to handle toggle state, add one extra to make sure light is on after
// Serial Input Parsing Variables // Serial Input Parsing Variables
#define buffSize 40 #define buffSize 40
char inputBuffer[buffSize]; char inputBuffer[buffSize];
#define endMarker '\n' #define endMarker '\n'
byte bytesRecvd = 0; extern uint8_t bytesRecvd;
bool serialIncoming = false; extern bool serialIncoming;
char serialMessageIn[buffSize] = {0}; extern char serialMessageIn[buffSize];
long serialLong = 0; extern long serialLong;
//#define LOW 0 //#define LOW 0
//#define HIGH 1 //#define HIGH 1