clean up INA238 since its software compat

This commit is contained in:
ladyada 2025-05-14 09:53:36 -04:00
parent 6180255cb3
commit a93107554e
6 changed files with 35 additions and 15 deletions

View file

@ -3,9 +3,12 @@
*
* @section ina237_intro Introduction
*
* I2C Driver for the INA237 I2C Current and Power sensor
* I2C Driver for the INA237/INA238 I2C Current and Power sensor
*
* Note: INA237 and INA238 are functionally identical devices with different
* part numbers. This class implements all functionality for both chips.
*
* This is a library for the Adafruit INA237 breakout:
* This is a library for the Adafruit INA237/INA238 breakouts:
* http://www.adafruit.com/products/xxxx
*
* Adafruit invests time and resources providing this open source code,

View file

@ -2,6 +2,9 @@
* @file Adafruit_INA237.h
*
* I2C Driver for INA237/INA238 Current and Power sensors
*
* Note: INA237 and INA238 are functionally identical devices with different
* part numbers. This class implements all functionality for both chips.
*
* This is a library for the Adafruit INA237/INA238 breakouts:
* http://www.adafruit.com/products/xxxx
@ -20,9 +23,8 @@
#include <Adafruit_INA2xx.h>
#define INA237_I2CADDR_DEFAULT 0x40 ///< INA237/INA238 default i2c address
#define INA237_DEVICE_ID \
0x238 ///< INA237 device ID (technically doesnt have one)
#define INA238_DEVICE_ID 0x238 ///< INA238 device ID
#define INA237_DEVICE_ID 0x238 ///< INA237 device ID
#define INA238_DEVICE_ID 0x238 ///< INA238 device ID (identical to INA237)
/**
* @brief Alert trigger options specific to INA237/INA238.

View file

@ -31,10 +31,6 @@
#include "Adafruit_INA238.h"
#include <Wire.h>
#include "Arduino.h"
/*!
* @brief Instantiates a new INA238 class
*/

View file

@ -24,7 +24,7 @@
/*!
* @brief Class that stores state and functions for interacting with
* INA238 Current and Power Sensor (subclass of INA237)
* INA238 Current and Power Sensor (identical to INA237)
*/
class Adafruit_INA238 : public Adafruit_INA237 {
public:

View file

@ -4,11 +4,29 @@ Arduino library for the INA237 and INA238 power monitors
[![Build Status](https://github.com/adafruit/Adafruit_INA237_INA238/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_INA237_INA238/actions)
[![Documentation](https://raw.githubusercontent.com/adafruit/ci-arduino/master/assets/doxygen_badge.svg)](https://adafruit.github.io/Adafruit_INA237_INA238/html/index.html)
This is the Adafruit INA237 and INA238 Current and Power sensor library
This is the Adafruit INA237 and INA238 Current and Power sensor library.
Tested and works great with the Adafruit INA237 and INA238 Breakout Boards
## Device Information
These chips use I2C to communicate, 2 pins are required to interface
The INA237 and INA238 are functionally identical devices with different part numbers. They share:
- Same register map
- Same device ID (0x238)
- Same measurement capabilities and accuracy
- Same configuration options
This library provides separate classes for each part number for clarity:
- `Adafruit_INA237` - For INA237 devices
- `Adafruit_INA238` - For INA238 devices (a thin wrapper around the INA237 implementation)
Tested and works great with the Adafruit INA237 and INA238 Breakout Boards.
These chips use I2C to communicate, 2 pins are required to interface.
## Installation
To install, use the Arduino Library Manager and search for "Adafruit INA237" and install the library.
## License Information
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
@ -17,5 +35,3 @@ products from Adafruit!
Written by Limor "Ladyada" Fried for Adafruit Industries.
MIT license, check license.txt for more information
All text above must be included in any redistribution
To install, use the Arduino Library Manager and search for "Adafruit INA237" and install the library.

View file

@ -1,5 +1,8 @@
#include <Adafruit_INA238.h>
// Note: The INA238 is functionally identical to the INA237.
// This example demonstrates the INA238-specific class, but
// all functionality is identical to the INA237 example.
Adafruit_INA238 ina238 = Adafruit_INA238();
void setup() {