Skip to content

Commit

Permalink
Doxygen
Browse files Browse the repository at this point in the history
  • Loading branch information
tyeth committed Mar 5, 2025
1 parent 337560b commit 09763a2
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Adafruit_PM25AQI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Adafruit_PM25AQI::~Adafruit_PM25AQI() {
* @brief Setups the hardware and detects a valid PMSA003I. Initializes I2C.
* @param theWire
* Optional pointer to I2C interface, otherwise use Wire
* @param addr
* Optional I2C address, default is PMSA003I_I2CADDR_DEFAULT (0x12)
* @return True if PMSA003I found on I2C, False if something went wrong!
*/
bool Adafruit_PM25AQI::begin_I2C(TwoWire *theWire, uint8_t addr) {
Expand All @@ -64,7 +66,7 @@ bool Adafruit_PM25AQI::begin_I2C(TwoWire *theWire, uint8_t addr) {

/*!
* @brief Setups the hardware and detects a valid UART PM2.5 sensor
* @param theSerial
* @param theStream
* Pointer to Stream (HardwareSerial/SoftwareSerial) interface
* @return True
*/
Expand Down
1 change: 0 additions & 1 deletion Adafruit_PM25AQI.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Adafruit_PM25AQI {
Adafruit_PM25AQI();
~Adafruit_PM25AQI();

// Add deprecation warnings
[[deprecated("Please use Adafruit_PM25AQI_PMSA003I directly")]]
bool begin_I2C(TwoWire *theWire = &Wire,
uint8_t addr = PMSA003I_I2CADDR_DEFAULT);
Expand Down
27 changes: 27 additions & 0 deletions Adafruit_PM25AQI_Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,37 @@ Adafruit_PM25AQI_Base::~Adafruit_PM25AQI_Base() {
_buffer = nullptr;
}

/*!
* @brief Read the sensor data into the data struct
* @param data
* The data struct to fill
* @return True if the data was read successfully, false if there was an error
*/
bool Adafruit_PM25AQI_Base::read(PM25_AQI_Data *data) {
PM25AQI_DEBUG_PRINTLN("[ERROR] Messed up classes! Base read");
return false;
}

/*!
* @brief Verify the starting bytes of the data packet
* @param buffer
* The buffer with the data from the sensor
* @return True if the starting bytes are correct, false if they are incorrect
*/
bool Adafruit_PM25AQI_Base::verify_starting_bytes(uint8_t *buffer) {
PM25AQI_DEBUG_PRINTLN("Base verify_starting_bytes");
// PMSA003I uses same protocol as PMS5003: 0x42 0x4D
return (buffer[0] == 0x42 && buffer[1] == 0x4D);
}

/*!
* @brief Verify the checksum of the data packet
* @param buffer
* The buffer with the data from the sensor
* @param bufLen
* The length of the buffer
* @return True if the checksum is correct, false if it is incorrect
*/
bool Adafruit_PM25AQI_Base::verify_checksum(uint8_t *buffer, size_t bufLen) {
PM25AQI_DEBUG_PRINTLN("Base verify_checksum");
uint16_t sum = 0;
Expand All @@ -35,6 +55,13 @@ bool Adafruit_PM25AQI_Base::verify_checksum(uint8_t *buffer, size_t bufLen) {
return check == sum;
}

/*!
* @brief Decode the data from the sensor into the data struct
* @param buffer
* The buffer with the data from the sensor
* @param data
* The data struct to fill
*/
void Adafruit_PM25AQI_Base::decode_data(uint8_t *buffer, PM25_AQI_Data *data) {
PM25AQI_DEBUG_PRINTLN("Base decode_data");
// The data comes in endian'd, this solves it so it works on all platforms
Expand Down
3 changes: 3 additions & 0 deletions Adafruit_PM25AQI_Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ typedef struct PMSAQIdata {

} PM25_AQI_Data;

/*!
* Base class with state/helpers for interacting with PM2.5 Air Quality Sensor
*/
class Adafruit_PM25AQI_Base {
public:
Adafruit_PM25AQI_Base();
Expand Down
8 changes: 8 additions & 0 deletions Adafruit_PM25AQI_I2C_Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ Adafruit_PM25AQI_I2C_Base::~Adafruit_PM25AQI_I2C_Base() {
}
}

/*!
* @brief Setups the hardware and detects a valid PMSA003I. Initializes I2C.
* @param theWire
* Optional pointer to I2C interface, otherwise use Wire
* @param addr
* Optional I2C address, default is PMSA003I_I2CADDR_DEFAULT (0x12)
* @return True if PMSA003I found on I2C, False if something went wrong!
*/
bool Adafruit_PM25AQI_I2C_Base::begin_I2C(TwoWire *theWire, uint8_t addr) {
if (i2c_dev) {
delete i2c_dev;
Expand Down
3 changes: 3 additions & 0 deletions Adafruit_PM25AQI_I2C_Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include "Adafruit_PM25AQI_Base.h"
#include <Adafruit_I2CDevice.h>

/*!
* @brief Base class for PM2.5 sensor driver for I2C
*/
class Adafruit_PM25AQI_I2C_Base : public Adafruit_PM25AQI_Base {
public:
virtual ~Adafruit_PM25AQI_I2C_Base() override;
Expand Down
3 changes: 3 additions & 0 deletions Adafruit_PM25AQI_PMSA003I.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

#define PMSA003I_I2CADDR_DEFAULT 0x12

/*!
* @brief PM2.5 sensor driver for Plantower PMSA003I
*/
class Adafruit_PM25AQI_PMSA003I : public Adafruit_PM25AQI_I2C_Base {
public:
// Adafruit_PM25AQI_PMSA003I();
Expand Down
14 changes: 14 additions & 0 deletions Adafruit_PM25AQI_UART_Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Adafruit_PM25AQI_UART_Base::~Adafruit_PM25AQI_UART_Base() {
}
}

/*!
* @brief Setups the hardware and detects a valid UART PM2.5 sensor
* @param theStream
* Pointer to Stream (HardwareSerial/SoftwareSerial) interface
* @return True
*/
bool Adafruit_PM25AQI_UART_Base::begin_UART(Stream *theStream) {
if (serial_dev) {
delete serial_dev;
Expand All @@ -16,6 +22,14 @@ bool Adafruit_PM25AQI_UART_Base::begin_UART(Stream *theStream) {
return serial_dev != nullptr;
}

/*!
* @brief Read data from the UART stream
* @param buffer
* The buffer to read data into
* @param bufLen
* The length of the buffer
* @return True if the data was read successfully, false if there was an error
*/
bool Adafruit_PM25AQI_UART_Base::read_uart_data(uint8_t *buffer,
size_t bufLen) {
if (!serial_dev) {
Expand Down
3 changes: 3 additions & 0 deletions Adafruit_PM25AQI_UART_Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

#include "Adafruit_PM25AQI.h"

/*!
* @brief Base class for PM2.5 sensor driver for UART
*/
class Adafruit_PM25AQI_UART_Base : public Adafruit_PM25AQI_Base {
public:
~Adafruit_PM25AQI_UART_Base() override; // Need this for serial_dev cleanup
Expand Down
3 changes: 3 additions & 0 deletions Adafruit_PM25AQI_UART_PMS5003.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

#include "Adafruit_PM25AQI_UART_Base.h"

/*!
* @brief PM2.5 sensor driver for Plantower PMS5003
*/
class Adafruit_PM25AQI_UART_PMS5003 : public Adafruit_PM25AQI_UART_Base {
// public:
// Adafruit_PM25AQI_UART_PMS5003();
Expand Down

0 comments on commit 09763a2

Please sign in to comment.