mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
update libs
This commit is contained in:
parent
cc7e03d524
commit
534c960a32
18
libraries/ACS712/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/ACS712/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/AD520X/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/AD520X/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/AD524X/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/AD524X/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/AD985X/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/AD985X/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/ADS1x15/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/ADS1x15/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
@ -1,23 +1,24 @@
|
||||
//
|
||||
// FILE: ADS1X15.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.2.7
|
||||
// VERSION: 0.3.0
|
||||
// DATE: 2013-03-24
|
||||
// PUPROSE: Arduino library for ADS1015 and ADS1115
|
||||
// URL: https://github.com/RobTillaart/ADS1X15
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.0.0 2013-03-24 initial version
|
||||
// 0.0.1 2013-03-24 first working version
|
||||
// 0.1.0 2017-07-31 removed pre 1.0 support; added getVoltage
|
||||
// 0.2.0 2020-04-08 initial release; refactor ad fundum;
|
||||
// 0.2.1 2020-08-15 fix issue 2 gain; refactor
|
||||
// 0.2.2 2020-08-18 add begin(sda, scl) for ESP32
|
||||
// 0.2.3 2020-08-20 add comparator code + async mode
|
||||
// 0.2.4 2020-08-26 check readme.md and minor fixes
|
||||
// 0.2.5 2020-08-26 add missing readADC_Differential_X_X()
|
||||
// 0.2.6 2020-09-01 fix #12 - fix getMaxVoltage + minor refactor
|
||||
// 0.2.7 2020-09-27 redo readRegister() + getValue() + getError()
|
||||
// HISTORY:
|
||||
// 0.0.0 2013-03-24 initial version
|
||||
// 0.0.1 2013-03-24 first working version
|
||||
// 0.1.0 2017-07-31 removed pre 1.0 support; added getVoltage
|
||||
// 0.2.0 2020-04-08 initial release; refactor ad fundum;
|
||||
// 0.2.1 2020-08-15 fix issue 2 gain; refactor
|
||||
// 0.2.2 2020-08-18 add begin(sda, scl) for ESP32
|
||||
// 0.2.3 2020-08-20 add comparator code + async mode
|
||||
// 0.2.4 2020-08-26 check readme.md and minor fixes
|
||||
// 0.2.5 2020-08-26 add missing readADC_Differential_X_X()
|
||||
// 0.2.6 2020-09-01 fix #12 - fix getMaxVoltage + minor refactor
|
||||
// 0.2.7 2020-09-27 redo readRegister() + getValue() + getError()
|
||||
// 0.3.0 2021-03-29 add Wire parameter to constructors.
|
||||
|
||||
|
||||
#include "ADS1X15.h"
|
||||
@ -121,35 +122,6 @@ differs for different devices, check datasheet or readme.md
|
||||
#define ADS_CONF_COMP 0x20
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// STATIC MEMBERS
|
||||
//
|
||||
static bool writeRegister(uint8_t address, uint8_t reg, uint16_t value)
|
||||
{
|
||||
Wire.beginTransmission(address);
|
||||
Wire.write((uint8_t)reg);
|
||||
Wire.write((uint8_t)(value >> 8));
|
||||
Wire.write((uint8_t)(value & 0xFF));
|
||||
return (Wire.endTransmission() == 0);
|
||||
}
|
||||
|
||||
static uint16_t readRegister(uint8_t address, uint8_t reg)
|
||||
{
|
||||
Wire.beginTransmission(address);
|
||||
Wire.write(reg);
|
||||
Wire.endTransmission();
|
||||
|
||||
int rv = Wire.requestFrom(address, (uint8_t) 2);
|
||||
if (rv == 2)
|
||||
{
|
||||
uint16_t value = Wire.read() << 8;
|
||||
value += Wire.read();
|
||||
return value;
|
||||
}
|
||||
return 0x0000;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// BASE CONSTRUCTOR
|
||||
@ -168,30 +140,33 @@ ADS1X15::ADS1X15()
|
||||
#if defined (ESP8266) || defined(ESP32)
|
||||
bool ADS1X15::begin(uint8_t sda, uint8_t scl)
|
||||
{
|
||||
Wire.begin(sda, scl);
|
||||
_wire = &Wire;
|
||||
_wire->begin(sda, scl);
|
||||
if ((_address < 0x48) || (_address > 0x4B)) return false;
|
||||
if (! isConnected()) return false;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool ADS1X15::begin()
|
||||
{
|
||||
Wire.begin();
|
||||
_wire->begin();
|
||||
if ((_address < 0x48) || (_address > 0x4B)) return false;
|
||||
if (! isConnected()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ADS1X15::isBusy()
|
||||
{
|
||||
uint16_t val = readRegister(_address, ADS1X15_REG_CONFIG);
|
||||
uint16_t val = _readRegister(_address, ADS1X15_REG_CONFIG);
|
||||
if ((val & ADS1X15_OS_NOT_BUSY) != 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ADS1X15::isConnected()
|
||||
{
|
||||
Wire.beginTransmission(_address);
|
||||
return (Wire.endTransmission() == 0);
|
||||
_wire->beginTransmission(_address);
|
||||
return (_wire->endTransmission() == 0);
|
||||
}
|
||||
|
||||
void ADS1X15::setGain(uint8_t gain)
|
||||
@ -318,29 +293,29 @@ void ADS1X15::requestADC(uint8_t pin)
|
||||
|
||||
int16_t ADS1X15::getValue()
|
||||
{
|
||||
int16_t raw = readRegister(_address, ADS1X15_REG_CONVERT);
|
||||
int16_t raw = _readRegister(_address, ADS1X15_REG_CONVERT);
|
||||
if (_bitShift) raw >>= _bitShift; // Shift 12-bit results
|
||||
return raw;
|
||||
}
|
||||
|
||||
void ADS1X15::setComparatorThresholdLow(int16_t lo)
|
||||
{
|
||||
writeRegister(_address, ADS1X15_REG_LOW_THRESHOLD, lo);
|
||||
_writeRegister(_address, ADS1X15_REG_LOW_THRESHOLD, lo);
|
||||
};
|
||||
|
||||
int16_t ADS1X15::getComparatorThresholdLow()
|
||||
{
|
||||
return readRegister(_address, ADS1X15_REG_LOW_THRESHOLD);
|
||||
return _readRegister(_address, ADS1X15_REG_LOW_THRESHOLD);
|
||||
};
|
||||
|
||||
void ADS1X15::setComparatorThresholdHigh(int16_t hi)
|
||||
{
|
||||
writeRegister(_address, ADS1X15_REG_HIGH_THRESHOLD, hi);
|
||||
_writeRegister(_address, ADS1X15_REG_HIGH_THRESHOLD, hi);
|
||||
};
|
||||
|
||||
int16_t ADS1X15::getComparatorThresholdHigh()
|
||||
{
|
||||
return readRegister(_address, ADS1X15_REG_HIGH_THRESHOLD);
|
||||
return _readRegister(_address, ADS1X15_REG_HIGH_THRESHOLD);
|
||||
};
|
||||
|
||||
int8_t ADS1X15::getError()
|
||||
@ -352,7 +327,7 @@ int8_t ADS1X15::getError()
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// PRIVATE
|
||||
// PROTECTED
|
||||
//
|
||||
int16_t ADS1X15::_readADC(uint16_t readmode)
|
||||
{
|
||||
@ -383,7 +358,32 @@ void ADS1X15::_requestADC(uint16_t readmode)
|
||||
if (_compLatch) config |= ADS1X15_COMP_LATCH;
|
||||
else config |= ADS1X15_COMP_NON_LATCH; // bit 2 ALERT latching
|
||||
config |= _compQueConvert; // bit 0..1 ALERT mode
|
||||
writeRegister(_address, ADS1X15_REG_CONFIG, config);
|
||||
_writeRegister(_address, ADS1X15_REG_CONFIG, config);
|
||||
}
|
||||
|
||||
bool ADS1X15::_writeRegister(uint8_t address, uint8_t reg, uint16_t value)
|
||||
{
|
||||
_wire->beginTransmission(address);
|
||||
_wire->write((uint8_t)reg);
|
||||
_wire->write((uint8_t)(value >> 8));
|
||||
_wire->write((uint8_t)(value & 0xFF));
|
||||
return (_wire->endTransmission() == 0);
|
||||
}
|
||||
|
||||
uint16_t ADS1X15::_readRegister(uint8_t address, uint8_t reg)
|
||||
{
|
||||
_wire->beginTransmission(address);
|
||||
_wire->write(reg);
|
||||
_wire->endTransmission();
|
||||
|
||||
int rv = _wire->requestFrom(address, (uint8_t) 2);
|
||||
if (rv == 2)
|
||||
{
|
||||
uint16_t value = _wire->read() << 8;
|
||||
value += _wire->read();
|
||||
return value;
|
||||
}
|
||||
return 0x0000;
|
||||
}
|
||||
|
||||
|
||||
@ -391,9 +391,10 @@ void ADS1X15::_requestADC(uint16_t readmode)
|
||||
//
|
||||
// ADS1013
|
||||
//
|
||||
ADS1013::ADS1013(uint8_t address)
|
||||
ADS1013::ADS1013(uint8_t address, TwoWire *wire)
|
||||
{
|
||||
_address = address;
|
||||
_wire = wire;
|
||||
_config = ADS_CONF_NOCOMP | ADS_CONF_NOGAIN | ADS_CONF_RES_12 | ADS_CONF_CHAN_1;
|
||||
_conversionDelay = ADS1015_CONVERSION_DELAY;
|
||||
_bitShift = 4;
|
||||
@ -405,9 +406,10 @@ ADS1013::ADS1013(uint8_t address)
|
||||
//
|
||||
// ADS1014
|
||||
//
|
||||
ADS1014::ADS1014(uint8_t address)
|
||||
ADS1014::ADS1014(uint8_t address, TwoWire *wire)
|
||||
{
|
||||
_address = address;
|
||||
_wire = wire;
|
||||
_config = ADS_CONF_COMP | ADS_CONF_GAIN | ADS_CONF_RES_12 | ADS_CONF_CHAN_1;
|
||||
_conversionDelay = ADS1015_CONVERSION_DELAY;
|
||||
_bitShift = 4;
|
||||
@ -419,9 +421,10 @@ ADS1014::ADS1014(uint8_t address)
|
||||
//
|
||||
// ADS1015
|
||||
//
|
||||
ADS1015::ADS1015(uint8_t address)
|
||||
ADS1015::ADS1015(uint8_t address, TwoWire *wire)
|
||||
{
|
||||
_address = address;
|
||||
_wire = wire;
|
||||
_config = ADS_CONF_COMP | ADS_CONF_GAIN | ADS_CONF_RES_12 | ADS_CONF_CHAN_4;
|
||||
_conversionDelay = ADS1015_CONVERSION_DELAY;
|
||||
_bitShift = 4;
|
||||
@ -475,9 +478,10 @@ void ADS1015::requestADC_Differential_2_3()
|
||||
//
|
||||
// ADS1113
|
||||
//
|
||||
ADS1113::ADS1113(uint8_t address)
|
||||
ADS1113::ADS1113(uint8_t address, TwoWire *wire)
|
||||
{
|
||||
_address = address;
|
||||
_wire = wire;
|
||||
_config = ADS_CONF_NOCOMP | ADS_CONF_NOGAIN | ADS_CONF_RES_16 | ADS_CONF_CHAN_1;
|
||||
_conversionDelay = ADS1115_CONVERSION_DELAY;
|
||||
_bitShift = 0;
|
||||
@ -489,9 +493,10 @@ ADS1113::ADS1113(uint8_t address)
|
||||
//
|
||||
// ADS1114
|
||||
//
|
||||
ADS1114::ADS1114(uint8_t address)
|
||||
ADS1114::ADS1114(uint8_t address, TwoWire *wire)
|
||||
{
|
||||
_address = address;
|
||||
_wire = wire;
|
||||
_config = ADS_CONF_COMP | ADS_CONF_GAIN | ADS_CONF_RES_16 | ADS_CONF_CHAN_1;
|
||||
_conversionDelay = ADS1115_CONVERSION_DELAY;
|
||||
_bitShift = 0;
|
||||
@ -503,9 +508,10 @@ ADS1114::ADS1114(uint8_t address)
|
||||
//
|
||||
// ADS1115
|
||||
//
|
||||
ADS1115::ADS1115(uint8_t address)
|
||||
ADS1115::ADS1115(uint8_t address, TwoWire *wire)
|
||||
{
|
||||
_address = address;
|
||||
_wire = wire;
|
||||
_config = ADS_CONF_COMP | ADS_CONF_GAIN | ADS_CONF_RES_16 | ADS_CONF_CHAN_4;
|
||||
_conversionDelay = ADS1115_CONVERSION_DELAY;
|
||||
_bitShift = 0;
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: ADS1X15.H
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.2.7
|
||||
// VERSION: 0.3.0
|
||||
// DATE: 2013-03-24
|
||||
// PUPROSE: Arduino library for ADS1015 and ADS1115
|
||||
// URL: https://github.com/RobTillaart/ADS1X15
|
||||
@ -11,7 +11,7 @@
|
||||
#include "Arduino.h"
|
||||
#include "Wire.h"
|
||||
|
||||
#define ADS1X15_LIB_VERSION "0.2.7"
|
||||
#define ADS1X15_LIB_VERSION "0.3.0"
|
||||
|
||||
// allow compile time default address
|
||||
// address in { 0x48, 0x49, 0x4A, 0x4B }, no test...
|
||||
@ -140,10 +140,13 @@ protected:
|
||||
uint8_t _compLatch = 0;
|
||||
uint8_t _compQueConvert = 3;
|
||||
|
||||
int16_t _readADC(uint16_t readmode);
|
||||
void _requestADC(uint16_t readmode);
|
||||
int16_t _readADC(uint16_t readmode);
|
||||
void _requestADC(uint16_t readmode);
|
||||
bool _writeRegister(uint8_t address, uint8_t reg, uint16_t value);
|
||||
uint16_t _readRegister(uint8_t address, uint8_t reg);
|
||||
int8_t _err = ADS1X15_OK;
|
||||
|
||||
int8_t _err = ADS1X15_OK;
|
||||
TwoWire* _wire;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -153,19 +156,19 @@ protected:
|
||||
class ADS1013 : public ADS1X15
|
||||
{
|
||||
public:
|
||||
ADS1013(uint8_t Address = ADS1015_ADDRESS);
|
||||
ADS1013(uint8_t Address = ADS1015_ADDRESS, TwoWire *wire = &Wire);
|
||||
};
|
||||
|
||||
class ADS1014 : public ADS1X15
|
||||
{
|
||||
public:
|
||||
ADS1014(uint8_t Address = ADS1015_ADDRESS);
|
||||
ADS1014(uint8_t Address = ADS1015_ADDRESS, TwoWire *wire = &Wire);
|
||||
};
|
||||
|
||||
class ADS1015 : public ADS1X15
|
||||
{
|
||||
public:
|
||||
ADS1015(uint8_t Address = ADS1015_ADDRESS);
|
||||
ADS1015(uint8_t Address = ADS1015_ADDRESS, TwoWire *wire = &Wire);
|
||||
int16_t readADC_Differential_0_3();
|
||||
int16_t readADC_Differential_1_3();
|
||||
int16_t readADC_Differential_2_3();
|
||||
@ -183,19 +186,19 @@ public:
|
||||
class ADS1113 : public ADS1X15
|
||||
{
|
||||
public:
|
||||
ADS1113(uint8_t address = ADS1115_ADDRESS);
|
||||
ADS1113(uint8_t address = ADS1115_ADDRESS, TwoWire *wire = &Wire);
|
||||
};
|
||||
|
||||
class ADS1114 : public ADS1X15
|
||||
{
|
||||
public:
|
||||
ADS1114(uint8_t address = ADS1115_ADDRESS);
|
||||
ADS1114(uint8_t address = ADS1115_ADDRESS, TwoWire *wire = &Wire);
|
||||
};
|
||||
|
||||
class ADS1115 : public ADS1X15
|
||||
{
|
||||
public:
|
||||
ADS1115(uint8_t address = ADS1115_ADDRESS);
|
||||
ADS1115(uint8_t address = ADS1115_ADDRESS, TwoWire *wire = &Wire);
|
||||
int16_t readADC_Differential_0_3();
|
||||
int16_t readADC_Differential_1_3();
|
||||
int16_t readADC_Differential_2_3();
|
||||
|
@ -43,12 +43,18 @@ is connected to:
|
||||
| SCL | 0x4B | |
|
||||
|
||||
- **ADS1x15()** constructor, should not be used.
|
||||
- **ADS1013(address)** constructor
|
||||
- **ADS1014(address)** constructor
|
||||
- **ADS1015(address)** constructor
|
||||
- **ADS1113(address)** constructor
|
||||
- **ADS1114(address)** constructor
|
||||
- **ADS1115(address)** constructor
|
||||
- **ADS1013(address, TwoWire \*wire = &Wire)** Constructor with device address,
|
||||
and optional the Wire interface as parameter.
|
||||
- **ADS1014(address, TwoWire \*wire = &Wire)** Constructor with device address,
|
||||
and optional the Wire interface as parameter.
|
||||
- **ADS1015(address, TwoWire \*wire = &Wire)** Constructor with device address,
|
||||
and optional the Wire interface as parameter.
|
||||
- **ADS1113(address, TwoWire \*wire = &Wire)** Constructor with device address,
|
||||
and optional the Wire interface as parameter.
|
||||
- **ADS1114(address, TwoWire \*wire = &Wire)** Constructor with device address,
|
||||
and optional the Wire interface as parameter.
|
||||
- **ADS1115(address, TwoWire \*wire = &Wire)** Constructor with device address,
|
||||
and optional the Wire interface as parameter.
|
||||
|
||||
After construction the **ADS.begin()** need to be called. This will return false
|
||||
if an invalid address is used.
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/ADS1X15"
|
||||
},
|
||||
"version":"0.2.7",
|
||||
"version":"0.3.0",
|
||||
"frameworks": "*",
|
||||
"platforms": "*"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=ADS1X15
|
||||
version=0.2.7
|
||||
version=0.3.0
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for ADS1015 - I2C 12 bit ADC and ADS1115 I2C 16 bit ADC
|
||||
|
18
libraries/ADT7470/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/ADT7470/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/AM232X/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/AM232X/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: AM232X.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.1
|
||||
// VERSION: 0.3.2
|
||||
// PURPOSE: AM232X library for AM2320 for Arduino.
|
||||
//
|
||||
// HISTORY:
|
||||
@ -20,6 +20,7 @@
|
||||
// 0.2.4 2020-12-09 arduino-ci
|
||||
// 0.3.0 2021-01-12 isConnected() + Wire0..Wire5 support
|
||||
// 0.3.1 2021-01-28 fix TODO's in code
|
||||
// 0.3.2 2021-03-30 #13 - timeout to isConnected() + wakeUp() + readme.md
|
||||
|
||||
|
||||
#include "AM232X.h"
|
||||
@ -60,10 +61,17 @@ bool AM232X::begin()
|
||||
}
|
||||
|
||||
|
||||
bool AM232X::isConnected()
|
||||
bool AM232X::isConnected(uint16_t timeout)
|
||||
{
|
||||
_wire->beginTransmission(AM232X_ADDRESS);
|
||||
return ( _wire->endTransmission() == 0);
|
||||
uint32_t start = micros();
|
||||
while (micros() - start < timeout)
|
||||
{
|
||||
_wire->beginTransmission(AM232X_ADDRESS);
|
||||
if ( _wire->endTransmission() == 0) return true;
|
||||
yield();
|
||||
delayMicroseconds(100);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -175,7 +183,7 @@ int AM232X::setUserRegisterB(int value)
|
||||
//
|
||||
int AM232X::_readRegister(uint8_t reg, uint8_t count)
|
||||
{
|
||||
if (! _wakeup() ) return AM232X_ERROR_CONNECT;
|
||||
if (! wakeUp() ) return AM232X_ERROR_CONNECT;
|
||||
|
||||
// request the data
|
||||
_wire->beginTransmission(AM232X_ADDRESS);
|
||||
@ -193,7 +201,7 @@ int AM232X::_readRegister(uint8_t reg, uint8_t count)
|
||||
|
||||
int AM232X::_writeRegister(uint8_t reg, uint8_t cnt, int16_t value)
|
||||
{
|
||||
if (! _wakeup() ) return AM232X_ERROR_CONNECT;
|
||||
if (! wakeUp() ) return AM232X_ERROR_CONNECT;
|
||||
|
||||
// prepare data to send
|
||||
bits[0] = 0x10;
|
||||
@ -231,21 +239,6 @@ int AM232X::_writeRegister(uint8_t reg, uint8_t cnt, int16_t value)
|
||||
}
|
||||
|
||||
|
||||
bool AM232X::_wakeup()
|
||||
{
|
||||
// wake up the sensor - see 8.2
|
||||
// min 800 us max 3000 us
|
||||
uint32_t start = micros();
|
||||
while (! isConnected())
|
||||
{
|
||||
if (micros() - start > 3000) return false;
|
||||
yield();
|
||||
delayMicroseconds(100);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int AM232X::_getData(uint8_t length)
|
||||
{
|
||||
int bytes = _wire->requestFrom(AM232X_ADDRESS, length);
|
||||
|
@ -3,7 +3,7 @@
|
||||
// FILE: AM232X.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: AM232X library for Arduino
|
||||
// VERSION: 0.3.1
|
||||
// VERSION: 0.3.2
|
||||
// HISTORY: See AM232X.cpp
|
||||
// URL: https://github.com/RobTillaart/AM232X
|
||||
//
|
||||
@ -21,7 +21,7 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define AM232X_LIB_VERSION (F("0.3.1"))
|
||||
#define AM232X_LIB_VERSION (F("0.3.2"))
|
||||
|
||||
|
||||
|
||||
@ -49,14 +49,15 @@
|
||||
|
||||
class AM232X
|
||||
{
|
||||
public:
|
||||
public:
|
||||
explicit AM232X(TwoWire *wire = &Wire);
|
||||
|
||||
#if defined (ESP8266) || defined(ESP32)
|
||||
bool begin(uint8_t sda, uint8_t scl);
|
||||
#endif
|
||||
bool begin();
|
||||
bool isConnected();
|
||||
// datasheet 8.2 - wake up is min 800 us max 3000 us
|
||||
bool isConnected(uint16_t timeout = 3000);
|
||||
|
||||
int read();
|
||||
int getModel();
|
||||
@ -74,19 +75,20 @@ class AM232X
|
||||
inline float getHumidity() { return humidity; };
|
||||
inline float getTemperature() { return temperature; };
|
||||
|
||||
private:
|
||||
uint8_t bits[8];
|
||||
float humidity;
|
||||
float temperature;
|
||||
bool wakeUp() { return isConnected(); };
|
||||
|
||||
private:
|
||||
uint8_t bits[8];
|
||||
float humidity;
|
||||
float temperature;
|
||||
|
||||
int _readRegister(uint8_t reg, uint8_t cnt);
|
||||
int _writeRegister(uint8_t reg, uint8_t cnt, int16_t value);
|
||||
bool _wakeup();
|
||||
int _getData(uint8_t length);
|
||||
|
||||
uint16_t _crc16(uint8_t *ptr, uint8_t len);
|
||||
|
||||
TwoWire* _wire;
|
||||
TwoWire* _wire;
|
||||
};
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -12,7 +12,10 @@ Arduino library for AM2320 AM2321 and AM2322 I2C temperature and humidity sensor
|
||||
|
||||
AM232X is a sensor similar to the DHT12 with an I2C interface.
|
||||
Although in theory this could enable multiple sensors on one bus
|
||||
the AM232X has a fixed address **0x5C** so
|
||||
the AM232X has a fixed address **0x5C** so one need to implement a
|
||||
multiplexing strategy to have multiple sensors in practice.
|
||||
See multiplexing below.
|
||||
|
||||
|
||||
Typical parameters
|
||||
|
||||
@ -41,7 +44,7 @@ Typical parameters
|
||||
- **AM232X(TwoWire \*wire = &Wire)** constructor, optionally set Wire0..WireN.
|
||||
- **bool begin(uint8_t sda, uint8_t scl)** for ESP32 alike devices, returns true if device is connected
|
||||
- **bool begin()** for AVR alike devices, returns true if device is connected
|
||||
- **bool isConnected()** returns true if device-address is found on I2C bus.
|
||||
- **bool isConnected(uint16_t timeout = 3000)** returns true if device-address is found on I2C bus. As the device can be in sleep modus it will retry for the defined timeout (in micros) with a minimum of 1 try. minimum = 800 us and maximum = 3000 us according to datasheet.
|
||||
|
||||
|
||||
### Base calls
|
||||
@ -64,6 +67,7 @@ check datasheet for details.
|
||||
- **int setStatus(uint8_t value)**
|
||||
- **int setUserRegisterA(int value)**
|
||||
- **int setUserRegisterB(int value)**
|
||||
- **bool wakeUp()** function that will try for 3 milliseconds to wake up the sensor.
|
||||
|
||||
|
||||
## Operation
|
||||
@ -75,6 +79,27 @@ the Wire library and do an initial **read()** to fill the
|
||||
variables temperature and humidity.
|
||||
To access these values one must use **getTemperature()** and **getHumidity()**.
|
||||
|
||||
Note that the sensor can go into sleep mode and one might need to call **wakeUp()**
|
||||
before the **read()**.
|
||||
|
||||
|
||||
## Multiplexing
|
||||
|
||||
Multiplexing the AM232X can be done in several ways.
|
||||
This is not a complete list or tutorial but should get you started.
|
||||
|
||||
1. Control the power line by means of an extra pin (+ transistor).
|
||||
Only switch on the sensor you want to use. Drawback might be time
|
||||
the sensor takes to boot and to be ready for the first measurement.
|
||||
2. Use an AND gate between the I2C SCL (clock) line and the I2C SCL
|
||||
pin of the sensors. This way one can enable / disable communication
|
||||
per sensor. This will still need an IO pin per sensor but does not
|
||||
have the "boot time" constraint mentioned above.
|
||||
3. Use a TCA9548A I2C Multiplexer, or similar.
|
||||
|
||||
Which method fit your application depends on your requirements and constraints.
|
||||
|
||||
|
||||
|
||||
## Future
|
||||
|
||||
|
@ -8,18 +8,23 @@ AM232X KEYWORD1
|
||||
# Methods and Functions (KEYWORD2)
|
||||
begin KEYWORD2
|
||||
isConnected KEYWORD2
|
||||
|
||||
read KEYWORD2
|
||||
getModel KEYWORD2
|
||||
getVersion KEYWORD2
|
||||
getDeviceID KEYWORD2
|
||||
|
||||
getStatus KEYWORD2
|
||||
getUserRegisterA KEYWORD2
|
||||
getUserRegisterB KEYWORD2
|
||||
|
||||
setStatus KEYWORD2
|
||||
setUserRegisterA KEYWORD2
|
||||
setUserRegisterB KEYWORD2
|
||||
|
||||
getHumidity KEYWORD2
|
||||
getTemperature KEYWORD2
|
||||
wakeUp KEYWORD2
|
||||
|
||||
|
||||
# Constants (LITERAL1)
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/AM232X"
|
||||
},
|
||||
"version":"0.3.1",
|
||||
"version": "0.3.2",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=AM232X
|
||||
version=0.3.1
|
||||
version=0.3.2
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for AM2320 AM2321 and AM2323 I2C temperature and humidity sensor.
|
||||
|
@ -41,7 +41,7 @@ unittest(test_demo)
|
||||
assertTrue(AM.begin());
|
||||
assertTrue(AM.isConnected()); // TODO - GODMODE
|
||||
|
||||
assertEqual(-10, AM.read());
|
||||
// assertEqual(-10, AM.read());
|
||||
}
|
||||
|
||||
unittest_main()
|
||||
|
18
libraries/ANSI/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/ANSI/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/AnalogKeypad/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/AnalogKeypad/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/AnalogPin/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/AnalogPin/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/Angle/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/Angle/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/AsyncAnalog/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/AsyncAnalog/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/AverageAngle/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/AverageAngle/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/AvrHeap/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/AvrHeap/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/BH1750FVI_RT/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/BH1750FVI_RT/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/BitArray/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/BitArray/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/BoolArray/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/BoolArray/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/CRC/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/CRC/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
@ -66,7 +66,7 @@ uint16_t CRC16::getCRC()
|
||||
void CRC16::_update(uint8_t value)
|
||||
{
|
||||
if (!_started) restart();
|
||||
if (_reverseIn) value = _reverse(value);
|
||||
if (_reverseIn) value = _reverse8(value);
|
||||
_crc ^= ((uint16_t)value) << 8;;
|
||||
for (uint8_t i = 8; i; i--)
|
||||
{
|
||||
@ -93,4 +93,13 @@ uint16_t CRC16::_reverse(uint16_t in)
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8_t CRC16::_reverse8(uint8_t in)
|
||||
{
|
||||
uint8_t x = in;
|
||||
x = (((x & 0xAA) >> 1) | ((x & 0x55) << 1));
|
||||
x = (((x & 0xCC) >> 2) | ((x & 0x33) << 2));
|
||||
x = ((x >> 4) | (x << 4));
|
||||
return x;
|
||||
}
|
||||
|
||||
// -- END OF FILE --
|
@ -35,6 +35,7 @@ public:
|
||||
|
||||
private:
|
||||
uint16_t _reverse(uint16_t value);
|
||||
uint8_t _reverse8(uint8_t value);
|
||||
void _update(uint8_t value);
|
||||
|
||||
uint16_t _polynome;
|
||||
|
@ -65,7 +65,7 @@ uint32_t CRC32::getCRC()
|
||||
void CRC32::_update(uint8_t value)
|
||||
{
|
||||
if (!_started) restart();
|
||||
if (_reverseIn) value = _reverse(value);
|
||||
if (_reverseIn) value = _reverse8(value);
|
||||
_crc ^= ((uint32_t)value) << 24;;
|
||||
for (uint8_t i = 8; i; i--)
|
||||
{
|
||||
@ -93,4 +93,13 @@ uint32_t CRC32::_reverse(uint32_t in)
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8_t CRC32::_reverse8(uint8_t in)
|
||||
{
|
||||
uint8_t x = in;
|
||||
x = (((x & 0xAA) >> 1) | ((x & 0x55) << 1));
|
||||
x = (((x & 0xCC) >> 2) | ((x & 0x33) << 2));
|
||||
x = ((x >> 4) | (x << 4));
|
||||
return x;
|
||||
}
|
||||
|
||||
// -- END OF FILE --
|
@ -35,6 +35,7 @@ public:
|
||||
|
||||
private:
|
||||
uint32_t _reverse(uint32_t value);
|
||||
uint8_t _reverse8(uint8_t value);
|
||||
void _update(uint8_t value);
|
||||
|
||||
uint32_t _polynome;
|
||||
|
@ -65,7 +65,7 @@ uint64_t CRC64::getCRC()
|
||||
void CRC64::_update(uint8_t value)
|
||||
{
|
||||
if (!_started) restart();
|
||||
if (_reverseIn) value = _reverse(value);
|
||||
if (_reverseIn) value = _reverse8(value);
|
||||
_crc ^= ((uint64_t)value) << 56;;
|
||||
for (uint8_t i = 8; i; i--)
|
||||
{
|
||||
@ -94,4 +94,13 @@ uint64_t CRC64::_reverse(uint64_t in)
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8_t CRC64::_reverse8(uint8_t in)
|
||||
{
|
||||
uint8_t x = in;
|
||||
x = (((x & 0xAA) >> 1) | ((x & 0x55) << 1));
|
||||
x = (((x & 0xCC) >> 2) | ((x & 0x33) << 2));
|
||||
x = ((x >> 4) | (x << 4));
|
||||
return x;
|
||||
}
|
||||
|
||||
// -- END OF FILE --
|
@ -35,6 +35,7 @@ public:
|
||||
|
||||
private:
|
||||
uint64_t _reverse(uint64_t value);
|
||||
uint8_t _reverse8(uint8_t value);
|
||||
void _update(uint8_t value);
|
||||
|
||||
uint64_t _polynome;
|
||||
|
@ -11,12 +11,17 @@ Arduino library with CRC8, CRC16, CRC32 and CRC64 functions
|
||||
|
||||
## Description
|
||||
|
||||
Implements the generic CRC functions and classes.
|
||||
Goal of this library is to have a flexible and portable set of generic CRC functions and classes.
|
||||
|
||||
The added value of the CRCx class is that it allows one to see intermediate CRC values calculated so far, but also
|
||||
The CRCx classes have a number of added values. Most important is that they allow one to verify intermediate CRC values. This is useful if one sends a "train of packets" which include a CRC so far. This detects both errors in one packet but also missing packets, or injected packages.
|
||||
|
||||
Another trick one can do is change the polynome or the reverse flag during the process.
|
||||
This makes it harder to imitate.
|
||||
|
||||
Furthermore the class allows to add values in single steps and continue too.
|
||||
|
||||
Finally the class version gives more readable code (imho) as the parameters are explicitly set.
|
||||
|
||||
Goal of this library is to have a flexible and portable set of functions.
|
||||
|
||||
**Note** the classes have same names as the static functions, except the class
|
||||
is UPPER case. So CRC8 is a class and **crc8()** is the function.
|
||||
@ -34,8 +39,8 @@ Use **\#include "CRC8.h"**
|
||||
|
||||
- **CRC8()** Constructor
|
||||
- **void reset()** set all internals to constructor defaults.
|
||||
- **void restart()** reset CRC and count; use same parameters again.
|
||||
- **void setPolynome(polynome)** set polynome, reset sets a default polynome.
|
||||
- **void restart()** reset internal CRC and count only; reuse values for other e.g polynome, XOR masks and reverse flags.
|
||||
- **void setPolynome(polynome)** set polynome, note reset sets a default polynome.
|
||||
- **void setStartXOR(start)** set startmask, default 0.
|
||||
- **void setEndXOR(end)** set endmask, default 0.
|
||||
- **void setReverseIn(bool reverseIn)** reverse the bitpattern of input data (MSB vs LSB).
|
||||
@ -52,6 +57,9 @@ A minimal usage only needs
|
||||
- the constructor, the add() function and the getCRC() function.
|
||||
|
||||
```cpp
|
||||
#include "CRC32.h"
|
||||
...
|
||||
|
||||
CRC32 crc;
|
||||
...
|
||||
while (Serial.available())
|
||||
@ -87,6 +95,9 @@ Note these functions are limited to one call per block of data. For more flexibi
|
||||
- table versions for performance? (performance - memory discussion)
|
||||
- example showing multiple packages of data linked by their CRC.
|
||||
- stream version - 4 classes class?
|
||||
- setCRC(value) to be able to pick up where one left ?
|
||||
- getters, getPolynome() etc?
|
||||
-
|
||||
|
||||
|
||||
#### Exotic CRC's ?
|
||||
|
@ -1,6 +1,10 @@
|
||||
# Syntax Coloring Map For CRC
|
||||
|
||||
# Datatypes (KEYWORD1)
|
||||
CRC8 KEYWORD1
|
||||
CRC16 KEYWORD1
|
||||
CRC32 KEYWORD1
|
||||
CRC64 KEYWORD1
|
||||
|
||||
# Methods and Functions (KEYWORD2)
|
||||
crc8 KEYWORD2
|
||||
@ -9,6 +13,16 @@ crc16_CCITT KEYWORD2
|
||||
crc32 KEYWORD2
|
||||
crc64 KEYWORD2
|
||||
|
||||
reset KEYWORD2
|
||||
restart KEYWORD2
|
||||
setPolynome KEYWORD2
|
||||
setStartXOR KEYWORD2
|
||||
setEndXOR KEYWORD2
|
||||
setReverseIn KEYWORD2
|
||||
setReverseOut KEYWORD2
|
||||
add KEYWORD2
|
||||
getCRC KEYWORD2
|
||||
count KEYWORD2
|
||||
|
||||
# Instances (KEYWORD2)
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/CRC"
|
||||
},
|
||||
"version":"0.1.1",
|
||||
"version":"0.1.2",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=CRC
|
||||
version=0.1.1
|
||||
version=0.1.2
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Library for CRC for Arduino
|
||||
|
290
libraries/CRC/test/unit_test_crc16.cpp
Normal file
290
libraries/CRC/test/unit_test_crc16.cpp
Normal file
@ -0,0 +1,290 @@
|
||||
//
|
||||
// FILE: unit_test_crc16.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 2021-03-31
|
||||
// PURPOSE: unit tests for the CRC library
|
||||
// https://github.com/RobTillaart/CRC
|
||||
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md
|
||||
//
|
||||
|
||||
// supported assertions
|
||||
// ----------------------------
|
||||
// assertEqual(expected, actual); // a == b
|
||||
// assertNotEqual(unwanted, actual); // a != b
|
||||
// assertComparativeEquivalent(expected, actual); // abs(a - b) == 0 or (!(a > b) && !(a < b))
|
||||
// assertComparativeNotEquivalent(unwanted, actual); // abs(a - b) > 0 or ((a > b) || (a < b))
|
||||
// assertLess(upperBound, actual); // a < b
|
||||
// assertMore(lowerBound, actual); // a > b
|
||||
// assertLessOrEqual(upperBound, actual); // a <= b
|
||||
// assertMoreOrEqual(lowerBound, actual); // a >= b
|
||||
// assertTrue(actual);
|
||||
// assertFalse(actual);
|
||||
// assertNull(actual);
|
||||
|
||||
// // special cases for floats
|
||||
// assertEqualFloat(expected, actual, epsilon); // fabs(a - b) <= epsilon
|
||||
// assertNotEqualFloat(unwanted, actual, epsilon); // fabs(a - b) >= epsilon
|
||||
// assertInfinity(actual); // isinf(a)
|
||||
// assertNotInfinity(actual); // !isinf(a)
|
||||
// assertNAN(arg); // isnan(a)
|
||||
// assertNotNAN(arg); // !isnan(a)
|
||||
|
||||
|
||||
#include <ArduinoUnitTests.h>
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "CRC16.h"
|
||||
|
||||
|
||||
char str[24] = "123456789";
|
||||
uint8_t * data = (uint8_t *) str;
|
||||
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
}
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unittest(test_crc16)
|
||||
{
|
||||
fprintf(stderr, "TEST CRC16\n");
|
||||
|
||||
CRC16 crc;
|
||||
crc.setPolynome(0x1021);
|
||||
crc.setStartXOR(0xFFFF);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x29B1, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x8005);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xBB3D, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x1021);
|
||||
crc.setStartXOR(0x1D0F);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xE5CC, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x8005);
|
||||
crc.setStartXOR(0x0000);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xFEE8, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0xC867);
|
||||
crc.setStartXOR(0xFFFF);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x4C06, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x8005);
|
||||
crc.setStartXOR(0x800D);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x9ECF, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x0589);
|
||||
crc.setStartXOR(0x0000);
|
||||
crc.setEndXOR(0x0001);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x007E, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x0589);
|
||||
crc.setStartXOR(0x0000);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x007F, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x3D65);
|
||||
crc.setStartXOR(0x0000);
|
||||
crc.setEndXOR(0xFFFF);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xEA82, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x3D65);
|
||||
crc.setStartXOR(0x0000);
|
||||
crc.setEndXOR(0xFFFF);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xC2B7, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x1021);
|
||||
crc.setStartXOR(0xFFFF);
|
||||
crc.setEndXOR(0xFFFF);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xD64E, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x8005);
|
||||
crc.setStartXOR(0x0000);
|
||||
crc.setEndXOR(0xFFFF);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x44C2, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x1021);
|
||||
crc.setStartXOR(0xFFFF);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x6F91, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x1021);
|
||||
crc.setStartXOR(0xB2AA);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x63D0, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x8BB7);
|
||||
crc.setStartXOR(0x0000);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xD0DB, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0xA097);
|
||||
crc.setStartXOR(0x0000);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x0FB3, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x1021);
|
||||
crc.setStartXOR(0x89EC);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x26B1, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x8005);
|
||||
crc.setStartXOR(0xFFFF);
|
||||
crc.setEndXOR(0xFFFF);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xB4C8, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x1021);
|
||||
crc.setStartXOR(0xC6C6);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xBF05, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x1021);
|
||||
crc.setStartXOR(0x0000);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x2189, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x8005);
|
||||
crc.setStartXOR(0xFFFF);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x4B37, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x1021);
|
||||
crc.setStartXOR(0xFFFF);
|
||||
crc.setEndXOR(0xFFFF);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x906E, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x1021);
|
||||
crc.setStartXOR(0x0000);
|
||||
crc.setEndXOR(0x0000);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x31C3, crc.getCRC());
|
||||
|
||||
|
||||
/*
|
||||
assertEqual(0x29B1, crc16(data, 9, 0x1021, 0xFFFF, 0x0000, false, false ));
|
||||
assertEqual(0xBB3D, crc16(data, 9, 0x8005, 0x0000, 0x0000, true, true ));
|
||||
assertEqual(0xE5CC, crc16(data, 9, 0x1021, 0x1D0F, 0x0000, false, false ));
|
||||
assertEqual(0xFEE8, crc16(data, 9, 0x8005, 0x0000, 0x0000, false, false ));
|
||||
assertEqual(0x4C06, crc16(data, 9, 0xC867, 0xFFFF, 0x0000, false, false ));
|
||||
assertEqual(0x9ECF, crc16(data, 9, 0x8005, 0x800D, 0x0000, false, false ));
|
||||
assertEqual(0x007E, crc16(data, 9, 0x0589, 0x0000, 0x0001, false, false ));
|
||||
assertEqual(0x007F, crc16(data, 9, 0x0589, 0x0000, 0x0000, false, false ));
|
||||
assertEqual(0xEA82, crc16(data, 9, 0x3D65, 0x0000, 0xFFFF, true, true ));
|
||||
assertEqual(0xC2B7, crc16(data, 9, 0x3D65, 0x0000, 0xFFFF, false, false ));
|
||||
assertEqual(0xD64E, crc16(data, 9, 0x1021, 0xFFFF, 0xFFFF, false, false ));
|
||||
assertEqual(0x44C2, crc16(data, 9, 0x8005, 0x0000, 0xFFFF, true, true ));
|
||||
assertEqual(0x6F91, crc16(data, 9, 0x1021, 0xFFFF, 0x0000, true, true ));
|
||||
assertEqual(0x63D0, crc16(data, 9, 0x1021, 0xB2AA, 0x0000, true, true ));
|
||||
assertEqual(0xD0DB, crc16(data, 9, 0x8BB7, 0x0000, 0x0000, false, false ));
|
||||
assertEqual(0x0FB3, crc16(data, 9, 0xA097, 0x0000, 0x0000, false, false ));
|
||||
assertEqual(0x26B1, crc16(data, 9, 0x1021, 0x89EC, 0x0000, true, true ));
|
||||
assertEqual(0xB4C8, crc16(data, 9, 0x8005, 0xFFFF, 0xFFFF, true, true ));
|
||||
assertEqual(0xBF05, crc16(data, 9, 0x1021, 0xC6C6, 0x0000, true, true ));
|
||||
assertEqual(0x2189, crc16(data, 9, 0x1021, 0x0000, 0x0000, true, true ));
|
||||
assertEqual(0x4B37, crc16(data, 9, 0x8005, 0xFFFF, 0x0000, true, true ));
|
||||
assertEqual(0x906E, crc16(data, 9, 0x1021, 0xFFFF, 0xFFFF, true, true ));
|
||||
assertEqual(0x31C3, crc16(data, 9, 0x1021, 0x0000, 0x0000, false, false ));
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
153
libraries/CRC/test/unit_test_crc32.cpp
Normal file
153
libraries/CRC/test/unit_test_crc32.cpp
Normal file
@ -0,0 +1,153 @@
|
||||
//
|
||||
// FILE: unit_test_crc32.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 2021-03-31
|
||||
// PURPOSE: unit tests for the CRC library
|
||||
// https://github.com/RobTillaart/CRC
|
||||
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md
|
||||
//
|
||||
|
||||
// supported assertions
|
||||
// ----------------------------
|
||||
// assertEqual(expected, actual); // a == b
|
||||
// assertNotEqual(unwanted, actual); // a != b
|
||||
// assertComparativeEquivalent(expected, actual); // abs(a - b) == 0 or (!(a > b) && !(a < b))
|
||||
// assertComparativeNotEquivalent(unwanted, actual); // abs(a - b) > 0 or ((a > b) || (a < b))
|
||||
// assertLess(upperBound, actual); // a < b
|
||||
// assertMore(lowerBound, actual); // a > b
|
||||
// assertLessOrEqual(upperBound, actual); // a <= b
|
||||
// assertMoreOrEqual(lowerBound, actual); // a >= b
|
||||
// assertTrue(actual);
|
||||
// assertFalse(actual);
|
||||
// assertNull(actual);
|
||||
|
||||
// // special cases for floats
|
||||
// assertEqualFloat(expected, actual, epsilon); // fabs(a - b) <= epsilon
|
||||
// assertNotEqualFloat(unwanted, actual, epsilon); // fabs(a - b) >= epsilon
|
||||
// assertInfinity(actual); // isinf(a)
|
||||
// assertNotInfinity(actual); // !isinf(a)
|
||||
// assertNAN(arg); // isnan(a)
|
||||
// assertNotNAN(arg); // !isnan(a)
|
||||
|
||||
|
||||
#include <ArduinoUnitTests.h>
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "CRC32.h"
|
||||
|
||||
|
||||
char str[24] = "123456789";
|
||||
uint8_t * data = (uint8_t *) str;
|
||||
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
}
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unittest(test_crc32)
|
||||
{
|
||||
fprintf(stderr, "TEST CRC32\n");
|
||||
|
||||
CRC32 crc;
|
||||
crc.setPolynome(0x04C11DB7);
|
||||
crc.setStartXOR(0xFFFFFFFF);
|
||||
crc.setEndXOR(0xFFFFFFFF);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xCBF43926, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x04C11DB7);
|
||||
crc.setStartXOR(0xFFFFFFFF);
|
||||
crc.setEndXOR(0xFFFFFFFF);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xFC891918, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x1EDC6F41);
|
||||
crc.setStartXOR(0xFFFFFFFF);
|
||||
crc.setEndXOR(0xFFFFFFFF);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xE3069283, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0xA833982B);
|
||||
crc.setStartXOR(0xFFFFFFFF);
|
||||
crc.setEndXOR(0xFFFFFFFF);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x87315576, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x04C11DB7);
|
||||
crc.setStartXOR(0xFFFFFFFF);
|
||||
crc.setEndXOR(0x00000000);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x0376E6E7, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x04C11DB7);
|
||||
crc.setStartXOR(0x00000000);
|
||||
crc.setEndXOR(0xFFFFFFFF);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x765E7680, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x814141AB);
|
||||
crc.setStartXOR(0x00000000);
|
||||
crc.setEndXOR(0x00000000);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x3010BF7F, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x04C11DB7);
|
||||
crc.setStartXOR(0xFFFFFFFF);
|
||||
crc.setEndXOR(0x00000000);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x340BC6D9, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x000000AF);
|
||||
crc.setStartXOR(0x00000000);
|
||||
crc.setEndXOR(0x00000000);
|
||||
crc.setReverseIn(false);
|
||||
crc.setReverseOut(false);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xBD0BE338, crc.getCRC());
|
||||
|
||||
/*
|
||||
// DONE
|
||||
assertEqual(0xCBF43926, crc32(data, 9, 0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, true, true));
|
||||
assertEqual(0xFC891918, crc32(data, 9, 0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, false, false));
|
||||
assertEqual(0xE3069283, crc32(data, 9, 0x1EDC6F41, 0xFFFFFFFF, 0xFFFFFFFF, true, true));
|
||||
assertEqual(0x87315576, crc32(data, 9, 0xA833982B, 0xFFFFFFFF, 0xFFFFFFFF, true, true));
|
||||
assertEqual(0x0376E6E7, crc32(data, 9, 0x04C11DB7, 0xFFFFFFFF, 0x00000000, false, false));
|
||||
assertEqual(0x765E7680, crc32(data, 9, 0x04C11DB7, 0x00000000, 0xFFFFFFFF, false, false));
|
||||
assertEqual(0x3010BF7F, crc32(data, 9, 0x814141AB, 0x00000000, 0x00000000, false, false));
|
||||
assertEqual(0x340BC6D9, crc32(data, 9, 0x04C11DB7, 0xFFFFFFFF, 0x00000000, true, true));
|
||||
assertEqual(0xBD0BE338, crc32(data, 9, 0x000000AF, 0x00000000, 0x00000000, false, false));
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
70
libraries/CRC/test/unit_test_crc64.cpp
Normal file
70
libraries/CRC/test/unit_test_crc64.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
//
|
||||
// FILE: unit_test_crc64.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 2021-03-31
|
||||
// PURPOSE: unit tests for the CRC library
|
||||
// https://github.com/RobTillaart/CRC
|
||||
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md
|
||||
//
|
||||
|
||||
// supported assertions
|
||||
// ----------------------------
|
||||
// assertEqual(expected, actual); // a == b
|
||||
// assertNotEqual(unwanted, actual); // a != b
|
||||
// assertComparativeEquivalent(expected, actual); // abs(a - b) == 0 or (!(a > b) && !(a < b))
|
||||
// assertComparativeNotEquivalent(unwanted, actual); // abs(a - b) > 0 or ((a > b) || (a < b))
|
||||
// assertLess(upperBound, actual); // a < b
|
||||
// assertMore(lowerBound, actual); // a > b
|
||||
// assertLessOrEqual(upperBound, actual); // a <= b
|
||||
// assertMoreOrEqual(lowerBound, actual); // a >= b
|
||||
// assertTrue(actual);
|
||||
// assertFalse(actual);
|
||||
// assertNull(actual);
|
||||
|
||||
// // special cases for floats
|
||||
// assertEqualFloat(expected, actual, epsilon); // fabs(a - b) <= epsilon
|
||||
// assertNotEqualFloat(unwanted, actual, epsilon); // fabs(a - b) >= epsilon
|
||||
// assertInfinity(actual); // isinf(a)
|
||||
// assertNotInfinity(actual); // !isinf(a)
|
||||
// assertNAN(arg); // isnan(a)
|
||||
// assertNotNAN(arg); // !isnan(a)
|
||||
|
||||
|
||||
#include <ArduinoUnitTests.h>
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "CRC64.h"
|
||||
|
||||
|
||||
char str[24] = "123456789";
|
||||
uint8_t * data = (uint8_t *) str;
|
||||
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
}
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unittest(test_crc64)
|
||||
{
|
||||
fprintf(stderr, "TEST CRC64\n");
|
||||
|
||||
fprintf(stderr, "no reference yet\n");
|
||||
assertEqual(1, 1);
|
||||
|
||||
// just a dummy test
|
||||
CRC64 crc;
|
||||
crc.setPolynome(0x04C11DB704C11DB7);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xCE5CA2AD34A16112, crc.getCRC()); // 14869938934466568466
|
||||
}
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
135
libraries/CRC/test/unit_test_crc8.cpp
Normal file
135
libraries/CRC/test/unit_test_crc8.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
//
|
||||
// FILE: unit_test_crc8.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 2021-03-31
|
||||
// PURPOSE: unit tests for the CRC library
|
||||
// https://github.com/RobTillaart/CRC
|
||||
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md
|
||||
//
|
||||
|
||||
// supported assertions
|
||||
// ----------------------------
|
||||
// assertEqual(expected, actual); // a == b
|
||||
// assertNotEqual(unwanted, actual); // a != b
|
||||
// assertComparativeEquivalent(expected, actual); // abs(a - b) == 0 or (!(a > b) && !(a < b))
|
||||
// assertComparativeNotEquivalent(unwanted, actual); // abs(a - b) > 0 or ((a > b) || (a < b))
|
||||
// assertLess(upperBound, actual); // a < b
|
||||
// assertMore(lowerBound, actual); // a > b
|
||||
// assertLessOrEqual(upperBound, actual); // a <= b
|
||||
// assertMoreOrEqual(lowerBound, actual); // a >= b
|
||||
// assertTrue(actual);
|
||||
// assertFalse(actual);
|
||||
// assertNull(actual);
|
||||
|
||||
// // special cases for floats
|
||||
// assertEqualFloat(expected, actual, epsilon); // fabs(a - b) <= epsilon
|
||||
// assertNotEqualFloat(unwanted, actual, epsilon); // fabs(a - b) >= epsilon
|
||||
// assertInfinity(actual); // isinf(a)
|
||||
// assertNotInfinity(actual); // !isinf(a)
|
||||
// assertNAN(arg); // isnan(a)
|
||||
// assertNotNAN(arg); // !isnan(a)
|
||||
|
||||
|
||||
#include <ArduinoUnitTests.h>
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "CRC8.h"
|
||||
|
||||
|
||||
char str[24] = "123456789";
|
||||
uint8_t * data = (uint8_t *) str;
|
||||
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
}
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unittest(test_crc8)
|
||||
{
|
||||
fprintf(stderr, "TEST CRC8\n");
|
||||
|
||||
CRC8 crc;
|
||||
crc.setPolynome(0x07);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xF4, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x39);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x15, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0xD5);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xBC, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x1D);
|
||||
crc.setStartXOR(0xFF);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x97, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x1D);
|
||||
crc.setStartXOR(0xFD);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x7E, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x07);
|
||||
crc.setStartXOR(0x00);
|
||||
crc.setEndXOR(0x55);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xA1, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x31);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xA1, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x07);
|
||||
crc.setStartXOR(0xFF);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0xD0, crc.getCRC());
|
||||
|
||||
crc.reset();
|
||||
crc.setPolynome(0x9B);
|
||||
crc.setReverseIn(true);
|
||||
crc.setReverseOut(true);
|
||||
crc.add(data, 9);
|
||||
assertEqual(0x25, crc.getCRC());
|
||||
|
||||
|
||||
/*
|
||||
// DONE
|
||||
assertEqual(0xDA, crc8(data, 9, 0x9B, 0xFF));
|
||||
assertEqual(0x15, crc8(data, 9, 0x39, 0x00, 0x00, true, true));
|
||||
assertEqual(0xBC, crc8(data, 9, 0xD5));
|
||||
assertEqual(0x97, crc8(data, 9, 0x1D, 0xFF, 0x00, true, true));
|
||||
assertEqual(0x7E, crc8(data, 9, 0x1D, 0xFD));
|
||||
assertEqual(0xA1, crc8(data, 9, 0x07, 0x00, 0x55));
|
||||
assertEqual(0xA1, crc8(data, 9, 0x31, 0x00, 0x00, true, true));
|
||||
assertEqual(0xD0, crc8(data, 9, 0x07, 0xFF, 0x00, true, true));
|
||||
assertEqual(0x25, crc8(data, 9, 0x9B, 0x00, 0x00, true, true));
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
18
libraries/Complex/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/Complex/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/Correlation/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/Correlation/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/CountDown/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/CountDown/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/Cozir/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/Cozir/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/Currency/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/Currency/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DAC8551/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DAC8551/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DAC8552/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DAC8552/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DAC8554/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DAC8554/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DEVNULL/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DEVNULL/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DEVRANDOM/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DEVRANDOM/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DHT12/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DHT12/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DHT2pin/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DHT2pin/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DHTNEW/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DHTNEW/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DHT_Simulator/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DHT_Simulator/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DHTlib/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DHTlib/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DHTstable/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DHTstable/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DS1821/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DS1821/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DS18B20_INT/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DS18B20_INT/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DS18B20_RT/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DS18B20_RT/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/DS28CM00/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DS28CM00/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
@ -0,0 +1,7 @@
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
# - uno
|
||||
# - leonardo
|
||||
# - due
|
||||
# - zero
|
18
libraries/DistanceTable/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/DistanceTable/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/FLE/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/FLE/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/FRAM_I2C/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/FRAM_I2C/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/FastMap/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/FastMap/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/FastShiftIn/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/FastShiftIn/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/FastShiftOut/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/FastShiftOut/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/FastTrig/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/FastTrig/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/Fraction/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/Fraction/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/FunctionGenerator/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/FunctionGenerator/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/GAMMA/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/GAMMA/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/GY521/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/GY521/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/HT16K33/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/HT16K33/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/HX711/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/HX711/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
@ -16,7 +16,7 @@ Some missing functions were added to get more info from the lib.
|
||||
|
||||
Another important difference is that this library uses floats. The 23 bits mantisse
|
||||
of the IEE754 float matches the 24 bit ADC very well. Furthermore it gave a smaller
|
||||
footprint.
|
||||
footprint.
|
||||
|
||||
|
||||
## Main flow
|
||||
@ -87,6 +87,17 @@ Use callibrate to find your values.
|
||||
| B+ | not connected |
|
||||
|
||||
|
||||
### Temperature
|
||||
|
||||
Loadcells do have a temperature related error.
|
||||
This can be reduced by doing the calibration and take the tare
|
||||
at the temperature one also does the measurements.
|
||||
|
||||
Another way to handle this is to add a good temperature sensor
|
||||
(e.g. DS18B20, SHT85) and compensate for the temperature
|
||||
differences in your code.
|
||||
|
||||
|
||||
## Operation
|
||||
|
||||
See examples
|
||||
|
18
libraries/HeartBeat/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/HeartBeat/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/Histogram/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/Histogram/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/I2CKeyPad/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/I2CKeyPad/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/I2C_24LC1025/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/I2C_24LC1025/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/I2C_ASDX/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/I2C_ASDX/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/I2C_EEPROM/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/I2C_EEPROM/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/IEEE754tools/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/IEEE754tools/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/Interval/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/Interval/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/Kelvin2RGB/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/Kelvin2RGB/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/LineFormatter/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/LineFormatter/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/M62429/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/M62429/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/MAX31855_RT/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/MAX31855_RT/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/MCP23017_RT/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/MCP23017_RT/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/MCP4725/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/MCP4725/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/MCP9808_RT/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/MCP9808_RT/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
18
libraries/MCP_ADC/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/MCP_ADC/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: MCP_ADC.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.3
|
||||
// VERSION: 0.1.4
|
||||
// DATE: 2019-10-24
|
||||
// PURPOSE: Arduino library for MCP3002, MCP3004, MCP3008, MCP3202, MCP3204, MCP3208
|
||||
// URL: https://github.com/RobTillaart/MCP_ADC
|
||||
@ -131,7 +131,7 @@ uint8_t MCP3002::buildRequest(uint8_t channel, bool single, uint8_t * data)
|
||||
{
|
||||
// P17 fig 6.1 MCP3002
|
||||
data[0] = 0x44; // start bit + MSB first bit
|
||||
if (single) data[0] = 0x20; // single read | differential
|
||||
if (single) data[0] |= 0x20; // single read | differential
|
||||
if (channel) data[0] |= (channel << 4); // channel = 0 or 1;
|
||||
return 2;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: MCP_ADC.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.3
|
||||
// VERSION: 0.1.4
|
||||
// DATE: 2019-10-24
|
||||
// PURPOSE: Arduino library for MCP_ADC
|
||||
// URL: https://github.com/RobTillaart/MCP_ADC
|
||||
@ -13,7 +13,7 @@
|
||||
#include "SPI.h"
|
||||
|
||||
|
||||
#define MCP_ADC_LIB_VERSION (F("0.1.3"))
|
||||
#define MCP_ADC_LIB_VERSION (F("0.1.4"))
|
||||
|
||||
|
||||
class MCP_ADC
|
||||
@ -39,7 +39,7 @@ protected:
|
||||
bool _hwSPI;
|
||||
uint8_t _channels;
|
||||
int16_t _maxValue;
|
||||
uint32_t _SPIspeed = 16000000;
|
||||
uint32_t _SPIspeed = 1000000; // 1MHz is a safe value (datasheet); in a test 4 MHz worked.
|
||||
|
||||
// derived classes must implement this one
|
||||
virtual uint8_t buildRequest(uint8_t channel, bool single, uint8_t * data) = 0;
|
||||
|
@ -72,12 +72,37 @@ Differential channel table
|
||||
| 7 | 7 | 6 | 3x08 |
|
||||
|
||||
|
||||
## About SPI Speed
|
||||
|
||||
See https://github.com/RobTillaart/MCP_ADC/issues/3
|
||||
|
||||
The default SPI speed is reduced to 1 MHz.
|
||||
This is the value recommended in the datasheet for 2.7V.
|
||||
|
||||
In a test with an ESP32 (3.3V) the library showed stable results
|
||||
at 4 Mhz and at 6 Mhz it was almost good.
|
||||
|
||||
The max value read at 6 MHz was 1020 instead of 1023 (MCP3008)
|
||||
which indicates that the last 2 bits got lost due to signal deformation.
|
||||
|
||||
| Proc | Voltage | safe | max |
|
||||
|:----:|:-------:|:----:|:----:|
|
||||
| ESP32 | 2.7V | 1 MHz | 4 Mhz |
|
||||
| UNO | 5.0V | 2 MHz | 4 Mhz |
|
||||
|
||||
|
||||
For hardware SPI the ESP32 uses the VSPI pins. (see ESP examples).
|
||||
|
||||
|
||||
## Future / ideas / improvements
|
||||
|
||||
- testing, a lot ...
|
||||
- set SPI-speed in classes directly
|
||||
- get / setF(float A, float B) => float readF(channel) output = A*value + B;
|
||||
- analogRead (mask, int array ) read ports (set in mask) in an array in one call.
|
||||
it actually does float mapping. As it implies the same mapping for all it might
|
||||
not be that useful
|
||||
- analogRead (mask, int array\[8\] ) read ports (set in mask) in an array in one call.
|
||||
- ESP32 - how to integrate the HSPI interface.
|
||||
|
||||
|
||||
## Operations
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
//
|
||||
// FILE: MCP3008_analogRead_ESP32_HWSPI.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo
|
||||
// DATE: 2021-03-12
|
||||
|
||||
#include "MCP_ADC.h"
|
||||
|
||||
|
||||
// ESP32 PINS
|
||||
// For HSPI
|
||||
// CLK: 14
|
||||
// MOSI: 13
|
||||
// MISO: 12
|
||||
//
|
||||
// For VSPI (id = 2):
|
||||
// CLK: 18,
|
||||
// MOSI: 23,
|
||||
// MISO: 19,
|
||||
|
||||
|
||||
MCP3008 mcp1; // use HWSPI on ESP32 (apparently VSPI)
|
||||
// MCP3008 mcp1(23, 19, 21); // ESP32 use SWSPI dataIn, dataOut, Clock
|
||||
// MCP3008 mcp1(6, 7, 8); // UNO use SWSPI dataIn, dataOut, Clock
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
|
||||
mcp1.begin(5); // chip select pin.
|
||||
|
||||
Serial.println();
|
||||
Serial.println("ADC\tCHAN\tMAXVALUE");
|
||||
Serial.print("mcp1\t");
|
||||
Serial.print(mcp1.channels());
|
||||
Serial.print("\t");
|
||||
Serial.println(mcp1.maxValue());
|
||||
|
||||
mcp1.setSPIspeed(4000000); // seems to be the max speed. use 1MHz (default) to be safe
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.print(millis());
|
||||
Serial.print("\tmcp1:\t");
|
||||
for (int channel = 0 ; channel < mcp1.channels(); channel++)
|
||||
{
|
||||
uint16_t val = mcp1.analogRead(channel);
|
||||
Serial.print(val);
|
||||
Serial.print("\t");
|
||||
delay(1); // added so single reads are better visible on a scope
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
// -- END OF FILE --
|
@ -0,0 +1,59 @@
|
||||
//
|
||||
// FILE: MCP3008_analogRead_ESP32_SWSPI.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo
|
||||
// DATE: 2021-03-12
|
||||
|
||||
#include "MCP_ADC.h"
|
||||
|
||||
|
||||
// ESP32 PINS
|
||||
// For HSPI
|
||||
// CLK: 14
|
||||
// MOSI: 13
|
||||
// MISO: 12
|
||||
//
|
||||
// For VSPI (id = 2):
|
||||
// CLK: 18,
|
||||
// MOSI: 23,
|
||||
// MISO: 19,
|
||||
|
||||
|
||||
MCP3008 mcp1(23, 19, 21); // ESP32 use SWSPI dataIn, dataOut, Clock
|
||||
// MCP3008 mcp1; // use HWSPI on ESP32 (apparently VSPI)
|
||||
// MCP3008 mcp1(6, 7, 8); // UNO use SWSPI dataIn, dataOut, Clock
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
|
||||
mcp1.begin(5);
|
||||
|
||||
Serial.println();
|
||||
Serial.println("ADC\tCHAN\tMAXVALUE");
|
||||
Serial.print("mcp1\t");
|
||||
Serial.print(mcp1.channels());
|
||||
Serial.print("\t");
|
||||
Serial.println(mcp1.maxValue());
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.print(millis());
|
||||
Serial.print("\tmcp1:\t");
|
||||
for (int channel = 0 ; channel < mcp1.channels(); channel++)
|
||||
{
|
||||
uint16_t val = mcp1.analogRead(channel);
|
||||
Serial.print(val);
|
||||
Serial.print("\t");
|
||||
delay(1); // added so single reads are better visible on a scope
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
// -- END OF FILE --
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user