From 3fcdcc4746e8881eada87d9e60a929cf5bacd319 Mon Sep 17 00:00:00 2001 From: Paul D'Angio Date: Fri, 25 Aug 2023 23:51:31 -0400 Subject: [PATCH 1/2] package: wrote readme file --- README.md | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d8937e..bc13a77 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,116 @@ # ads101x -A cross-platform driver for the TI ADS101x family of analog-to-digital converters. + +A C++ driver for the Texas Instruments [ADS101x](https://www.ti.com/lit/ds/symlink/ads1015.pdf) family of analog-to-digital converters. + +## Overview + +The ads101x library provides a driver that allows you to easily interface with the Texas Instruments ADS101x (ADS1013, ADS1014, ADS1015) series of analog-to-digital (ADC) converters. It offers a flexible and extensible way to communicate with the ADS101x devices, abstracting away the low-level details of I2C communication and providing a clean API for your applications. Features include: + +- Abstracts I2C communication with the ADS101x devices. +- Provides a consistent API for configuration, conversion, thresholds, and alerts. +- Supports different platform-specific variants to suit your needs. + +**License:** [MIT Open Source](LICENSE) + +## Table of Contents + +1. [Multi-Platform Support](#1-multi-platform-support) +2. [Getting Started](#2-getting-started) +3. [Usage](#3-usage) +4. [API Documentation](#4-api-documentation) +5. [Contributing](#5-contributing) + +## 1: Multi-Platform Support + +The ADS101x library provides multi-platform support, allowing you to use the driver on different hardware platforms with ease. The library includes multiple variants for platforms such as the Raspberry Pi, and includes a base driver class that can be overidden to support other platforms. + +### 1.1: Base Driver: + +The base driver offers a platform-agnostic implementation of the ADS101x driver. It serves as the foundation for the other variants and can be used with any I2C library or environment. Create a class derived from the base driver, and override the necessary platform-specific functions. If you need to do so in a separate project, compile the ads101x library using the ```-DADS101X_BASE=ON``` option when configuring with cmake to generate a static library containing the base driver functionality. + +### 1.2: Raspberry Pi Drivers: + +1. **pigpio**: This platform variant is based on the [pigpio](http://abyz.me.uk/rpi/pigpio/index.html) library, and uses the standard single-process implementation of pigpio. To build the library for this platform, use the ```-DADS101X_PIGPIO=ON``` option when configuring with cmake. Make sure to install pigpio beforehand as it is a dependency. + +2. **pigpiod**: This platform variant is based on the [pigpio](http://abyz.me.uk/rpi/pigpio/index.html) library, and uses the daemon implementation of pigpio. To build the library for this platform, use the ```-DADS101X_PIGPIOD=ON``` option when configuring with cmake. Make sure to install pigpio beforehand as it is a dependency. + +## 2: Getting Started + +To use the ads101x library in your project, clone the repository and follow these steps: + +```bash +# Create a build directory and change into it. +mkdir build && cd build +# Configure the project using cmake (see build options below). +cmake .. +# Build the project. +make +``` + +### 2.1: Build Options + +The following options can be used with cmake to configure which libraries and functionalities are built: + +- ```-DADS101X_BASE=ON```: Builds the base driver library. +- ```-DADS101X_PIGPIO=ON```: Builds the [pigpio](#12-raspberry-pi-drivers) platform library. +- ```-DADS101X_PIGPIOD=ON```: Builds the [pigpiod](#12-raspberry-pi-drivers) platform library. +- ```-DADS101X_TESTS=ON```: Builds unit test executables for all enabled platforms. + +## 3: Usage + +To use the library in your code, include the necessary headers and link against the appropriate ads101x static library. See the [API Documentation](#4-api-documentation) section for instructions on how to generate and view the library's API documentation files. + +**Code Example:** + +```cpp +#include + +// Create a driver instance +ads101x::pigpio::driver driver; + +// Initialize the pigpio library if not done elsewhere. +driver.pigpio_initialize(); + +// Start the driver using default I2C bus and slave address. +driver.start(); + +// Create a configuration to write to the ADS101x. +ads101x::configuration config; +config.set_operation(ads101x::configuration::operation::CONVERT); +config.set_multiplexer(ads101x::configuration::multiplexer::AIN0_GND); +config.set_data_rate(ads101x::configuration::data_rate::SPS_3300); +config.set_fsr(ads101x::configuration::fsr::FSR_6_114); + +// Write configuration to begin conversion. +driver.write_config(config); + +// Wait for conversion to complete. +usleep(10000); + +// Read a conversion value. +uint16_t conversion = driver.read_conversion(); + +// Stop the driver +driver.stop(); + +// Terminate the pigpio library if not done elsewhere. +driver.pigpio_terminate(); +``` + +## 4: API Documentation + +The library uses ```doxygen``` for API documentation. To generate and view the documentation: + +```bash +# Start from the repository root directory. + +# Generate the documentation files. +doxygen doxyfile + +# Open the documentation using your default html application. +xdg-open doc/html/index.html +``` + +## 5: Contributing + +Contributions to the ads101x library are welcome! If you encounter issues, have suggestions, or want to contribute enhancements, feel free to open an issue or submit a pull request. \ No newline at end of file From 744b2b69d57f8aed946432bcfd065d53730f4d9c Mon Sep 17 00:00:00 2001 From: Paul D'Angio Date: Sat, 26 Aug 2023 00:02:42 -0400 Subject: [PATCH 2/2] cmake: updated project version to v0.6 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 753cd69..f41d0de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.2) # Set up project. project(ads101x - VERSION 0.6 + VERSION 0.7 DESCRIPTION "A driver for the TI ADS101X family of analog-to-digital converters.") # OPTIONS