Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@
.vscode/extensions.json
.vscode/launch.json
.DS_Store

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
*.egg-info/
dist/
build/
38 changes: 38 additions & 0 deletions include/ADS1232_ADC.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,29 @@ Note: ADS1232_ADC configuration values has been moved to file config.h

#define SIGNAL_TIMEOUT 100

// Debug info structure
struct ADS1232DebugInfo {
unsigned long timestamp; // millis() when debug info was captured
long rawValue; // Latest raw 24-bit value read
long smoothedValue; // Smoothed value after filtering
long tareOffset; // Current tare offset
float conversionTime; // Latest conversion time in ms
float sps; // Samples per second
int readIndex; // Current read index in dataset
int samplesInUse; // Number of samples being averaged
bool dataOutOfRange; // If data exceeded valid range
bool signalTimeout; // If DOUT signal timed out
bool tareInProgress; // If tare operation is running
int tareTimes; // Tare sample counter
long dataMin; // Min value in current dataset
long dataMax; // Max value in current dataset
long dataAvg; // Average of dataset
float dataStdDev; // Standard deviation (noise indicator)
};

// Debug callback function type
typedef void (*DebugCallback)(const ADS1232DebugInfo& info);

class ADS1232_ADC {

public:
Expand Down Expand Up @@ -90,13 +113,23 @@ class ADS1232_ADC {
bool getDataSetStatus(); //returns 'true' when the whole dataset has been filled up with conversions, i.e. after a reset/restart
float getNewCalibration(float known_mass); //returns and sets a new calibration value (calFactor) based on a known mass input
bool getSignalTimeoutFlag(); //returns 'true' if it takes longer time then 'SIGNAL_TIMEOUT' for the dout pin to go low after a new conversion is started
uint8_t getDoutPin(); //returns the DOUT pin number
void setReverseOutput(); //reverse the output value
void setChannelInUse(int channel); //select channel from 0 or 1, channel 0 is default
int getChannelInUse(); //returns current channel number

// Debug functions
void setDebugCallback(DebugCallback callback); //set callback function for debug output
void setDebugEnabled(bool enabled); //enable/disable debug mode
bool getDebugEnabled(); //check if debug is enabled
void captureDebugInfo(); //manually trigger debug info capture
ADS1232DebugInfo getDebugInfo(); //get current debug info without callback

protected:
void conversion24bit(); //if conversion is ready: returns 24 bit data and starts the next conversion
long smoothedData(); //returns the smoothed data value calculated from the dataset
void calculateDebugStats(ADS1232DebugInfo& info); //calculate statistics for debug info

uint8_t sckPin; //ADS1232 pd_sck pin
uint8_t doutPin; //ADS1232 dout pin
uint8_t GAIN; //ADS1232 GAIN
Expand Down Expand Up @@ -130,6 +163,11 @@ class ADS1232_ADC {
bool signalTimeoutFlag = 0;
bool reverseVal = 0;
bool dataWaiting = 0;

// Debug members
bool debugEnabled = false;
DebugCallback debugCallback = nullptr;
long lastRawValue = 0; //store last raw value for debug
};

#endif
2 changes: 1 addition & 1 deletion include/ADS1232_ADC_CONFIG.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Note that you can also overide (reducing) the number of samples in use at any ti
#define ADS1232_ADC_config_h

//number of samples in moving average dataset, value must be 1, 2, 4, 8, 16, 32, 64 or 128.
#define SAMPLES 1 //default value: 16
#define SAMPLES 4 //default value: 16

//adds extra sample(s) to the dataset and ignore peak high/low sample, value must be 0 or 1.
#define IGN_HIGH_SAMPLE 0 //default value: 1
Expand Down
1 change: 1 addition & 0 deletions include/ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class MyServerCallbacks : public BLEServerCallbacks {
Serial.print("BLE connID is: ");
Serial.println(connId);
t_firstConnect = millis();
t_heartBeat = millis();
bleState = CONNECTED;
deviceConnected = true;
#ifdef BUZZER
Expand Down
2 changes: 1 addition & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
//#define CHECKBATTERY

//SCALE CONFIG
#define LINE1 (char*)"FW: 3.0.6"
#define LINE1 (char*)"FW: 3.0.7"
#define LINE2 (char*)"Built-date "
#define LINE3 __DATE__ //Serial number
#define VERSION /*version*/ LINE1, /*compile date*/ LINE2, /*sn*/ LINE3
Expand Down
Loading
Loading