Skip to content

Commit

Permalink
update readme.md COMP_POLARITY (#77)
Browse files Browse the repository at this point in the history
- Fix #76, update readme.md Comparator Polarity
- added defines to replace magic numbers (not used in code yet)
- minor edits
  • Loading branch information
RobTillaart authored Jun 30, 2024
1 parent 50dbd26 commit 6c86d80
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 45 deletions.
20 changes: 10 additions & 10 deletions ADS1X15.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: ADS1X15.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.4.3
// VERSION: 0.4.4
// DATE: 2013-03-24
// PURPOSE: Arduino library for ADS1015 and ADS1115
// URL: https://github.com/RobTillaart/ADS1X15
Expand All @@ -24,7 +24,7 @@

// CONFIG REGISTER

// BIT 15 Operational Status // 1 << 15
// BIT 15 Operational Status // 1 << 15
#define ADS1X15_OS_BUSY 0x0000
#define ADS1X15_OS_NOT_BUSY 0x8000
#define ADS1X15_OS_START_SINGLE 0x8000
Expand Down Expand Up @@ -53,7 +53,7 @@
#define ADS1X15_MODE_CONTINUE 0x0000
#define ADS1X15_MODE_SINGLE 0x0100

// BIT 5-7 data rate sample per second // (0..7) << 5
// BIT 5-7 data rate sample per second // (0..7) << 5
/*
differs for different devices, check datasheet or readme.md
Expand All @@ -69,26 +69,26 @@ differs for different devices, check datasheet or readme.md
| 7 | 3300 | 860 | fastest |
*/

// BIT 4 comparator modi // 1 << 4
// BIT 4 comparator modi // 1 << 4
#define ADS1X15_COMP_MODE_TRADITIONAL 0x0000
#define ADS1X15_COMP_MODE_WINDOW 0x0010

// BIT 3 ALERT active value // 1 << 3
// BIT 3 ALERT active value // 1 << 3
#define ADS1X15_COMP_POL_ACTIV_LOW 0x0000
#define ADS1X15_COMP_POL_ACTIV_HIGH 0x0008

// BIT 2 ALERT latching // 1 << 2
// BIT 2 ALERT latching // 1 << 2
#define ADS1X15_COMP_NON_LATCH 0x0000
#define ADS1X15_COMP_LATCH 0x0004

// BIT 0-1 ALERT mode // (0..3)
// BIT 0-1 ALERT mode // (0..3)
#define ADS1X15_COMP_QUE_1_CONV 0x0000 // trigger alert after 1 convert
#define ADS1X15_COMP_QUE_2_CONV 0x0001 // trigger alert after 2 converts
#define ADS1X15_COMP_QUE_4_CONV 0x0002 // trigger alert after 4 converts
#define ADS1X15_COMP_QUE_NONE 0x0003 // disable comparator


// _CONFIG masks
// _CONFIG masks
//
// | bit | description |
// |:-----:|:-----------------------|
Expand Down Expand Up @@ -131,7 +131,7 @@ void ADS1X15::reset()
setMode(1); // _mode = ADS1X15_MODE_SINGLE;
setDataRate(4); // middle speed, depends on device.

// COMPARATOR variables # see notes .h
// COMPARATOR variables # see notes .h
_compMode = 0;
_compPol = 1;
_compLatch = 0;
Expand Down Expand Up @@ -423,7 +423,7 @@ void ADS1X15::setWireClock(uint32_t clockSpeed)
// TODO: get the real clock speed from the I2C interface if possible.
uint32_t ADS1X15::getWireClock()
{
// UNO 328 and
// UNO 328 and
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)
uint32_t speed = F_CPU / ((TWBR * 2) + 16);
return speed;
Expand Down
26 changes: 23 additions & 3 deletions ADS1X15.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: ADS1X15.h
// AUTHOR: Rob Tillaart
// VERSION: 0.4.3
// VERSION: 0.4.4
// DATE: 2013-03-24
// PURPOSE: Arduino library for ADS1015 and ADS1115
// URL: https://github.com/RobTillaart/ADS1X15
Expand All @@ -12,7 +12,7 @@
#include "Arduino.h"
#include "Wire.h"

#define ADS1X15_LIB_VERSION (F("0.4.3"))
#define ADS1X15_LIB_VERSION (F("0.4.4"))

// allow compile time default address
// address in { 0x48, 0x49, 0x4A, 0x4B }, no test...
Expand All @@ -31,6 +31,26 @@
#define ADS1X15_INVALID_MODE 0xFE


// PARAMETER CONSTANTS NOT USED IN CODE YET
// enum ?
#define ADS1X15_GAIN_6144MV 0x00
#define ADS1X15_GAIN_4096MV 0x01
#define ADS1X15_GAIN_2048MV 0x02
#define ADS1X15_GAIN_1024MV 0x04
#define ADS1X15_GAIN_0512MV 0x08
#define ADS1X15_GAIN_0256MV 0x10

#define ADS1x15_COMP_MODE_TRADITIONAL 0x00
#define ADS1x15_COMP_MODE_WINDOW 0x01

#define ADS1x15_COMP_POL_FALLING_EDGE 0x00
#define ADS1x15_COMP_POL_RISING_EDGE 0x01

#define ADS1x15_COMP_POL_LATCH 0x00
#define ADS1x15_COMP_POL_NOLATCH 0x01



class ADS1X15
{
public:
Expand All @@ -56,7 +76,7 @@ class ADS1X15


// 0 = CONTINUOUS
// 1 = SINGLE default
// 1 = SINGLE default
void setMode(uint8_t mode = 1); // invalid values are mapped to 1 (default)
uint8_t getMode(); // 0xFE == invalid mode error.

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.4.4] - 2024-06-28
- Fix #76, update readme.md Comparator Polarity
- added defines to replace magic numbers (not used in code yet)
- minor edits

## [0.4.3] - 2024-06-25
- Fix #74, ALERT/RDY pin documentation
- update readme.md
Expand Down
Loading

0 comments on commit 6c86d80

Please sign in to comment.