I2C THTIC is working on a patched EaserCAT-4000., EaserCAT-7000 tested, STM32 and LAN9252 works.
This commit is contained in:
285
Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/MyMCP3221/MyMCP3221.cpp
Executable file
285
Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/MyMCP3221/MyMCP3221.cpp
Executable file
@@ -0,0 +1,285 @@
|
||||
/*==============================================================================================================*
|
||||
|
||||
@file MyMCP3221.cpp
|
||||
@author Nadav Matalon
|
||||
@license MIT (c) 2016 Nadav Matalon
|
||||
|
||||
MCP3221 Driver (12-BIT Single Channel ADC with I2C Interface)
|
||||
|
||||
Ver. 1.0.0 - First release (16.10.16)
|
||||
|
||||
*==============================================================================================================*
|
||||
LICENSE
|
||||
*==============================================================================================================*
|
||||
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2016 Nadav Matalon
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*==============================================================================================================*/
|
||||
|
||||
#include "MyMCP3221.h"
|
||||
|
||||
/*==============================================================================================================*
|
||||
CONSTRUCTOR
|
||||
*==============================================================================================================*/
|
||||
|
||||
MyMCP3221::MyMCP3221(
|
||||
byte devAddr,
|
||||
TwoWire *Wire,
|
||||
unsigned int vRef,
|
||||
unsigned int res1,
|
||||
unsigned int res2,
|
||||
unsigned int alpha,
|
||||
voltage_input_t voltageInput,
|
||||
smoothing_t smoothingMethod,
|
||||
byte numSamples) :
|
||||
_Wire(Wire),
|
||||
_devAddr(devAddr),
|
||||
_vRef(vRef),
|
||||
_alpha(alpha),
|
||||
_voltageInput(voltageInput),
|
||||
_smoothing(smoothingMethod),
|
||||
_numSamples(numSamples)
|
||||
{
|
||||
memset(_samples, 0, sizeof(_samples));
|
||||
if (((res1 != 0) && (res2 != 0)) && (_voltageInput == VOLTAGE_INPUT_12V)) {
|
||||
_res1 = res1;
|
||||
_res2 = res2;
|
||||
} else if (_voltageInput == VOLTAGE_INPUT_5V) {
|
||||
_res1 = 0;
|
||||
_res2 = 0;
|
||||
} else {
|
||||
_res1 = DEFAULT_RES_1;
|
||||
_res2 = DEFAULT_RES_2;
|
||||
}
|
||||
_comBuffer = COM_SUCCESS;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
DESTRUCTOR
|
||||
*==============================================================================================================*/
|
||||
|
||||
MyMCP3221::~MyMCP3221() {}
|
||||
|
||||
/*==============================================================================================================*
|
||||
PING (0 = SUCCESS / 1, 2, ... = ERROR CODE)
|
||||
*==============================================================================================================*/
|
||||
|
||||
// See meaning of I2C Error Code values in README
|
||||
|
||||
byte MyMCP3221::ping() {
|
||||
_Wire->beginTransmission(_devAddr);
|
||||
return _comBuffer = _Wire->endTransmission();
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
GET VOLTAGE REFERENCE (2700mV - 5500mV)
|
||||
*==============================================================================================================*/
|
||||
|
||||
unsigned int MyMCP3221::getVref() {
|
||||
return _vRef;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
GET VOLTAGE DIVIDER RESISTOR 1 (Ω)
|
||||
*==============================================================================================================*/
|
||||
|
||||
unsigned int MyMCP3221::getRes1() {
|
||||
return _res1;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
GET VOLTAGE DIVIDER RESISTOR 2 (Ω)
|
||||
*==============================================================================================================*/
|
||||
|
||||
unsigned int MyMCP3221::getRes2() {
|
||||
return _res2;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
GET ALPHA (RELEVANT ONLY FOR EMAVG SMOOTHING METHOD, RANGE: 1 - 256)
|
||||
*==============================================================================================================*/
|
||||
|
||||
unsigned int MyMCP3221::getAlpha() {
|
||||
return _alpha;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
GET NUMBER OF SAMPLES (RELEVANT ONLY FOR ROLLING-AVAREGE SMOOTHING METHOD, RANGE: 1-20 SAMPLES)
|
||||
*==============================================================================================================*/
|
||||
|
||||
byte MyMCP3221::getNumSamples() {
|
||||
return _numSamples;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
GET VOLTAGE INPUT (0 = VOLTAGE_INPUT_5V / 1 = VOLTAGE_INPUT_12V)
|
||||
*==============================================================================================================*/
|
||||
|
||||
byte MyMCP3221::getVinput() {
|
||||
return _voltageInput;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
GET SMOOTHING METHOD (0 = NONE / 1 = ROLLING-AVAREGE / 2 = EMAVG)
|
||||
*==============================================================================================================*/
|
||||
|
||||
byte MyMCP3221::getSmoothing() {
|
||||
return _smoothing;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
GET DATA
|
||||
*==============================================================================================================*/
|
||||
|
||||
unsigned int MyMCP3221::getData() {
|
||||
return (_smoothing == NO_SMOOTHING) ? getRawData() : smoothData(getRawData());
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
GET VOLTAGE (Vref 4.096V: 2700 - 4096mV)
|
||||
*==============================================================================================================*/
|
||||
|
||||
unsigned int MyMCP3221::getVoltage() {
|
||||
if (_voltageInput == VOLTAGE_INPUT_5V) return round((_vRef / (float)DEFAULT_VREF) * getData());
|
||||
else return round(getData() * ((float)(_res1 + _res2) / _res2));
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
GET LATEST I2C COMMUNICATION RESULT (0 = OK / 1, 2, ... = ERROR)
|
||||
*==============================================================================================================*/
|
||||
|
||||
byte MyMCP3221::getComResult() {
|
||||
return _comBuffer;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
SET REFERENCE VOLTAGE (2700mV - 5500mV)
|
||||
*==============================================================================================================*/
|
||||
|
||||
void MyMCP3221::setVref(unsigned int newVref) { // PARAM RANGE: 2700-5500
|
||||
newVref = constrain(newVref, MIN_VREF, MAX_VREF);
|
||||
_vRef = newVref;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
SET VOLTAGE DIVIDER RESISTOR 1 (Ω)
|
||||
*==============================================================================================================*/
|
||||
|
||||
void MyMCP3221::setRes1(unsigned int newRes1) {
|
||||
_res1 = newRes1;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
SET VOLTAGE DIVIDER RESISTOR 2 (Ω)
|
||||
*==============================================================================================================*/
|
||||
|
||||
void MyMCP3221::setRes2(unsigned int newRes2) {
|
||||
_res2 = newRes2;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
SET ALPHA (RELEVANT ONLY FOR EMAVG SMOOTHING METHOD)
|
||||
*==============================================================================================================*/
|
||||
|
||||
void MyMCP3221::setAlpha(unsigned int newAlpha) { // PARAM RANGE: 1-256
|
||||
newAlpha = constrain(newAlpha, MIN_ALPHA, MAX_ALPHA);
|
||||
_alpha = newAlpha;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
SET NUMBER OF SAMPLES (RELEVANT ONLY FOR ROLLING-AVAREGE SMOOTHING METHOD)
|
||||
*==============================================================================================================*/
|
||||
|
||||
void MyMCP3221::setNumSamples(byte newNumSamples) { // PARAM RANGE: 1-20
|
||||
newNumSamples = constrain(newNumSamples, MIN_NUM_SAMPLES, MAX_NUM_SAMPLES);
|
||||
_numSamples = newNumSamples;
|
||||
for (byte i=0; i<MAX_NUM_SAMPLES; i++) _samples[i] = 0;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
SET VOLTAGE INPUT (NOTE: 12V INPUT READINGS REQUIRE A HARDWARE VOLTAGE DIVIDER)
|
||||
*==============================================================================================================*/
|
||||
|
||||
void MyMCP3221::setVinput(voltage_input_t newVoltageInput) { // PARAMS: VOLTAGE_INPUT_5V / VOLTAGE_INPUT_12V
|
||||
_voltageInput = newVoltageInput;
|
||||
if (newVoltageInput == VOLTAGE_INPUT_12V) {
|
||||
if (!_res1) _res1 = DEFAULT_RES_1;
|
||||
if (!_res2) _res2 = DEFAULT_RES_2;
|
||||
}
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
SET SMOOTHING METHOD
|
||||
*==============================================================================================================*/
|
||||
|
||||
void MyMCP3221::setSmoothing(smoothing_t newSmoothing) { // PARAMS: NO_SMOOTHING / ROLLING / EMAVG
|
||||
_smoothing = newSmoothing;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
RESET
|
||||
*==============================================================================================================*/
|
||||
|
||||
void MyMCP3221::reset() {
|
||||
setVref(DEFAULT_VREF);
|
||||
setAlpha(DEFAULT_ALPHA);
|
||||
setVinput(VOLTAGE_INPUT_5V);
|
||||
setSmoothing(EMAVG);
|
||||
setRes1(0);
|
||||
setRes2(0);
|
||||
setNumSamples(DEFAULT_NUM_SAMPLES);
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
GET RAW DATA
|
||||
*==============================================================================================================*/
|
||||
|
||||
unsigned int MyMCP3221::getRawData() {
|
||||
unsigned int rawData = 0;
|
||||
_Wire->requestFrom(_devAddr, DATA_BYTES);
|
||||
if (_Wire->available() == DATA_BYTES) rawData = (_Wire->read() << 8) | (_Wire->read());
|
||||
else ping();
|
||||
return rawData;
|
||||
}
|
||||
|
||||
/*==============================================================================================================*
|
||||
SMOOTH DATA
|
||||
*==============================================================================================================*/
|
||||
|
||||
unsigned int MyMCP3221::smoothData(unsigned int rawData) {
|
||||
unsigned int smoothedData;
|
||||
if (_smoothing == EMAVG) { // Exmponential Moving Average
|
||||
unsigned int emAvg = rawData;
|
||||
emAvg = (_alpha * (unsigned long)rawData + (MAX_ALPHA - _alpha) * (unsigned long)emAvg) / MAX_ALPHA;
|
||||
smoothedData = emAvg;
|
||||
} else { // Rolling-Average
|
||||
unsigned long sum = 0;
|
||||
if (_samples[_numSamples - 1] != 0) {
|
||||
for (byte i = 1; i<_numSamples; i++) _samples[i - 1] = _samples[i]; // drop last reading & rearrange array
|
||||
_samples[_numSamples - 1] = rawData; // add a new sample at the end of array
|
||||
for (byte j=0; j<_numSamples; j++) sum += _samples[j]; // aggregate all samples
|
||||
smoothedData = sum / _numSamples; // calculate average
|
||||
} else {
|
||||
for (byte i = 0; i<_numSamples; i++) _samples[i] = rawData;
|
||||
smoothedData = rawData;
|
||||
}
|
||||
}
|
||||
return smoothedData;
|
||||
}
|
||||
|
||||
207
Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/MyMCP3221/MyMCP3221.h
Executable file
207
Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/MyMCP3221/MyMCP3221.h
Executable file
@@ -0,0 +1,207 @@
|
||||
/*==============================================================================================================*
|
||||
|
||||
@file MyMCP3221.h
|
||||
@author Nadav Matalon
|
||||
@license MIT (c) 2016 Nadav Matalon
|
||||
|
||||
MCP3221 Driver (12-BIT Single Channel ADC with I2C Interface)
|
||||
|
||||
Ver. 1.0.0 - First release (16.10.16)
|
||||
|
||||
*===============================================================================================================*
|
||||
INTRODUCTION
|
||||
*===============================================================================================================*
|
||||
|
||||
The MCP3221 is a 12-Bit Single Channel ADC with hardware I2C interface.
|
||||
|
||||
This library contains a complete driver for the MCP3221 allowing the user to get raw conversion data,
|
||||
smoothed conversion data (Rollong-Average or EMAVG), or voltage readings ranging 0-5V or 0-12V (the latter
|
||||
requires a voltage divider setup).
|
||||
|
||||
*===============================================================================================================*
|
||||
DEVICE HOOKUP
|
||||
*===============================================================================================================*
|
||||
|
||||
MCP3221
|
||||
-------
|
||||
VCC --| • |-- SCL
|
||||
| |
|
||||
GND --| |
|
||||
| |
|
||||
AIN --| |-- SDA
|
||||
-------
|
||||
|
||||
PIN 1 (VCC/VREF) - Serves as both Power Supply input and Voltage Reference for the ADC. Connect to the Arduino
|
||||
5V Output or any other equivalent power source (5.5V max). If using an external power source,
|
||||
remember to connect all GND's together
|
||||
PIN 2 (GND) - connect to Arduino GND
|
||||
PIN 3 (AIN) - Connect to Arduino's 3.3V Output or the middle pin of a 10K potentiometer (other two pins go to 5V & GND)
|
||||
PIN 4 (SDA) - Connect to Arduino's PIN A4 with a 2K2 (400MHz I2C Bus speed) or 10K (100MHz I2C Bus speed) pull-up resistor
|
||||
PIN 5 (SCL) - Connect to Arduino's PIN A5 with a 2K2 (400MHz I2C Bus speed) or 10K (100MHz I2C Bus speed) pull-up resistor
|
||||
DECOUPING: Minimal decoupling consists of a 0.1uF Ceramic Capacitor between the VCC & GND PINS. For improved
|
||||
performance, add a 1uF and a 10uF Ceramic Capacitors as well across these pins
|
||||
|
||||
*===============================================================================================================*
|
||||
VOLTAGE DIVIDER HOOKUP (OPTIONAL: FOR 12V READINGS)
|
||||
*===============================================================================================================*
|
||||
|
||||
12V
|
||||
| MCP3221
|
||||
| -------
|
||||
R1 | | | |
|
||||
| | | |
|
||||
| AIN | |
|
||||
|-----------| |
|
||||
| | |
|
||||
| | -------
|
||||
R2 | |
|
||||
|
|
||||
|
|
||||
GND
|
||||
|
||||
R1 - 10K Resistor
|
||||
R2 - 4K7 Resistor
|
||||
|
||||
*===============================================================================================================*
|
||||
I2C ADDRESSES
|
||||
*===============================================================================================================*
|
||||
|
||||
Each MCP3221 has 1 of 8 possible I2C addresses (factory hardwired & recognized by its specific
|
||||
part number & top marking on the package itself):
|
||||
|
||||
PART DEVICE I2C ADDRESS PART
|
||||
NUMBER (BIN) (HEX) (DEC) MARKING
|
||||
MCP3221A0T-E/OT 01001000 0x48 72 GE
|
||||
MCP3221A1T-E/OT 01001001 0x49 73 GH
|
||||
MCP3221A2T-E/OT 01001010 0x4A 74 GB
|
||||
MCP3221A3T-E/OT 01001000 0x4B 75 GC
|
||||
MCP3221A4T-E/OT 01001100 0x4C 76 GD
|
||||
MCP3221A5T-E/OT 01001101 0x4D 77 GA
|
||||
MCP3221A6T-E/OT 01001110 0x4E 78 GF
|
||||
MCP3221A7T-E/OT 01001111 0x4F 79 GG
|
||||
|
||||
*===============================================================================================================*
|
||||
DEVICE SETTING DEFAULTS
|
||||
*===============================================================================================================*
|
||||
|
||||
VOLTAGE REFERENCE: 4096mV // this value is equal to the voltage fed to VCC
|
||||
VOLTAGE INPUT: 5V // direct measurment of voltage at AIN pin (hw setup without voltage divider)
|
||||
VOLTAGE DIVIDER RESISTOR 1: 0R // value used when measuring voltage of up to 12V at AIN pin
|
||||
VOLTAGE DIVIDER RESISTOR 2: 0R // value used when measuring voltage of up to 12V at AIN pin
|
||||
NUMBER OF SAMPLES: 10 // used by Rolling-Average smoothing method (range: 1-20 Samples)
|
||||
ALPHA 178 // factor used by EMAVG smoothing method (range: 1-256)
|
||||
|
||||
*===============================================================================================================*
|
||||
BUG REPORTS
|
||||
*===============================================================================================================*
|
||||
|
||||
Please report any bugs/issues/suggestions at the Github Repo of this library at:
|
||||
https://github.com/nadavmatalon/MCP3221
|
||||
|
||||
*===============================================================================================================*
|
||||
LICENSE
|
||||
*===============================================================================================================*
|
||||
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2016 Nadav Matalon
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*==============================================================================================================*/
|
||||
|
||||
#ifndef MyMCP3221_h
|
||||
#define MyMCP3221_h
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
//#include "utility/MCP3221_PString.h"
|
||||
|
||||
namespace Mymcp3221 {
|
||||
|
||||
const byte DATA_BYTES = 2; // number of data bytes requested from the device
|
||||
const byte MIN_CON_TIME = 15; // single conversion time with a small overhead (in uS)
|
||||
const byte COM_SUCCESS = 0; // I2C communication success Code (No Error)
|
||||
const unsigned int MIN_VREF = 2700; // minimum Voltage Reference value in mV (same as VCC)
|
||||
const unsigned int MAX_VREF = 5500; // minimum Voltage Reference value in mV (same as VCC)
|
||||
const unsigned int DEFAULT_VREF = 4096; // default Voltage Reference value in mV (same as VCC)
|
||||
const unsigned int DEFAULT_RES_1 = 10000; // default Resistor 1 value (in Ω) of voltage divider for 12V readings
|
||||
const unsigned int DEFAULT_RES_2 = 4700; // default Resistor 2 value (in Ω) of voltage divider for 12V readings
|
||||
const unsigned int MIN_ALPHA = 1; // minimum value of alpha (slowest change) (for EMAVG)
|
||||
const unsigned int MAX_ALPHA = 256; // maximum value of alpha (raw change/no filter) (for EMAVG)
|
||||
const unsigned int DEFAULT_ALPHA = 178; // default value of alpha (for EMAVG)
|
||||
const byte MIN_NUM_SAMPLES = 1; // minimum number of samples (for Rolling-Average smoothing)
|
||||
const byte MAX_NUM_SAMPLES = 20; // maximum number of samples (for Rolling-Average smoothing)
|
||||
const byte DEFAULT_NUM_SAMPLES = 10; // default number of samples (for Rolling-Average smoothing)
|
||||
|
||||
typedef enum:byte {
|
||||
VOLTAGE_INPUT_5V = 0, // default
|
||||
VOLTAGE_INPUT_12V = 1
|
||||
} voltage_input_t;
|
||||
|
||||
typedef enum:byte {
|
||||
NO_SMOOTHING = 0,
|
||||
ROLLING_AVG = 1,
|
||||
EMAVG = 2 // Default
|
||||
} smoothing_t;
|
||||
|
||||
class MyMCP3221 {
|
||||
public:
|
||||
MyMCP3221(
|
||||
byte devAddr,
|
||||
TwoWire *Wire,
|
||||
unsigned int vRef = DEFAULT_VREF,
|
||||
unsigned int res1 = DEFAULT_RES_1,
|
||||
unsigned int res2 = DEFAULT_RES_2,
|
||||
unsigned int alpha = DEFAULT_ALPHA,
|
||||
voltage_input_t voltageInput = VOLTAGE_INPUT_5V,
|
||||
smoothing_t smoothingMethod = EMAVG,
|
||||
byte numSamples = DEFAULT_NUM_SAMPLES
|
||||
);
|
||||
~MyMCP3221();
|
||||
byte ping();
|
||||
unsigned int getVref();
|
||||
unsigned int getRes1();
|
||||
unsigned int getRes2();
|
||||
unsigned int getAlpha();
|
||||
byte getNumSamples();
|
||||
byte getVinput();
|
||||
byte getSmoothing();
|
||||
unsigned int getData();
|
||||
unsigned int getVoltage();
|
||||
byte getComResult();
|
||||
void setVref(unsigned int newVref);
|
||||
void setRes1(unsigned int newRes1);
|
||||
void setRes2(unsigned int newRes2);
|
||||
void setAlpha(unsigned int newAlpha);
|
||||
void setNumSamples(byte newNumSamples);
|
||||
void setVinput(voltage_input_t newVinput);
|
||||
void setSmoothing(smoothing_t newSmoothing);
|
||||
void reset();
|
||||
private:
|
||||
TwoWire *_Wire;
|
||||
byte _devAddr, _voltageInput, _smoothing, _numSamples, _comBuffer;
|
||||
unsigned int _vRef, _res1, _res2, _alpha;
|
||||
unsigned int _samples[MAX_NUM_SAMPLES];
|
||||
unsigned int getRawData();
|
||||
unsigned int smoothData(unsigned int rawData);
|
||||
// friend MyMCP3221_PString MyMCP3221ComStr(const MyMCP3221&);
|
||||
// friend MyMCP3221_PString MyMCP3221InfoStr(const MyMCP3221&);
|
||||
};
|
||||
}
|
||||
|
||||
using namespace Mymcp3221;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user