Format code with standard clang-format style
Some checks failed
Arduino Library CI / build (push) Has been cancelled

- Added .clang-format file with standard Google style settings
- Formatted source files to comply with CI formatting standards
- Fixed Doxygen parameter documentation warnings

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ladyada 2025-05-13 12:56:46 -04:00
parent e20b6b1ebd
commit c2239f97f6
3 changed files with 107 additions and 85 deletions

13
.clang-format Normal file
View file

@ -0,0 +1,13 @@
Language: Cpp
BasedOnStyle: Google
IndentWidth: 2
ColumnLimit: 80
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBraces: Attach
DerivePointerAlignment: false
PointerAlignment: Left
SpacesBeforeTrailingComments: 1

View file

@ -27,7 +27,9 @@
/** /**
* @brief Construct a new Adafruit_OPT4048 object. * @brief Construct a new Adafruit_OPT4048 object.
*/ */
Adafruit_OPT4048::Adafruit_OPT4048() { i2c_dev = nullptr; } Adafruit_OPT4048::Adafruit_OPT4048() {
i2c_dev = nullptr;
}
/** /**
* @brief Destroy the Adafruit_OPT4048 object, frees I2C device. * @brief Destroy the Adafruit_OPT4048 object, frees I2C device.

View file

@ -1,7 +1,8 @@
/*! /*!
* @file Adafruit_OPT4048.h * @file Adafruit_OPT4048.h
* *
* Arduino library for the OPT4048 High Speed High Precision Tristimulus XYZ Color Sensor. * Arduino library for the OPT4048 High Speed High Precision Tristimulus XYZ
* Color Sensor.
* *
* This is a library for the Adafruit OPT4048 breakout * This is a library for the Adafruit OPT4048 breakout
* ----> https://www.adafruit.com/products/6334 * ----> https://www.adafruit.com/products/6334
@ -19,13 +20,14 @@
#ifndef ADAFRUIT_OPT4048_H #ifndef ADAFRUIT_OPT4048_H
#define ADAFRUIT_OPT4048_H #define ADAFRUIT_OPT4048_H
#include "Arduino.h"
#include <Wire.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_BusIO_Register.h> #include <Adafruit_BusIO_Register.h>
#include <Adafruit_I2CDevice.h>
#include <Wire.h>
// Default I2C address (ADDR pin connected to GND) #include "Arduino.h"
#define OPT4048_DEFAULT_ADDR 0x44
#define OPT4048_DEFAULT_ADDR \
0x44 //!< Default I2C address (ADDR pin connected to GND)
/** /**
* @brief Available range settings for the OPT4048 sensor * @brief Available range settings for the OPT4048 sensor
@ -46,7 +48,8 @@ typedef enum {
/** /**
* @brief Available conversion time settings for the OPT4048 sensor * @brief Available conversion time settings for the OPT4048 sensor
* *
* These control the device conversion time per channel as described in datasheet page 29. * These control the device conversion time per channel as described in
* datasheet page 29.
*/ */
typedef enum { typedef enum {
OPT4048_CONVERSION_TIME_600US = 0, ///< 600 microseconds OPT4048_CONVERSION_TIME_600US = 0, ///< 600 microseconds
@ -78,7 +81,8 @@ typedef enum {
/** /**
* @brief Available fault count settings for the OPT4048 sensor * @brief Available fault count settings for the OPT4048 sensor
* *
* Controls how many consecutive fault events are needed to trigger an interrupt. * Controls how many consecutive fault events are needed to trigger an
* interrupt.
*/ */
typedef enum { typedef enum {
OPT4048_FAULT_COUNT_1 = 0, ///< 1 fault count (default) OPT4048_FAULT_COUNT_1 = 0, ///< 1 fault count (default)
@ -99,29 +103,30 @@ typedef enum {
} opt4048_int_cfg_t; } opt4048_int_cfg_t;
// Register addresses // Register addresses
#define OPT4048_REG_CH0_MSB 0x00 // X channel MSB #define OPT4048_REG_CH0_MSB 0x00 //!< X channel MSB register
#define OPT4048_REG_CH0_LSB 0x01 // X channel LSB #define OPT4048_REG_CH0_LSB 0x01 //!< X channel LSB register
#define OPT4048_REG_CH1_MSB 0x02 // Y channel MSB #define OPT4048_REG_CH1_MSB 0x02 //!< Y channel MSB register
#define OPT4048_REG_CH1_LSB 0x03 // Y channel LSB #define OPT4048_REG_CH1_LSB 0x03 //!< Y channel LSB register
#define OPT4048_REG_CH2_MSB 0x04 // Z channel MSB #define OPT4048_REG_CH2_MSB 0x04 //!< Z channel MSB register
#define OPT4048_REG_CH2_LSB 0x05 // Z channel LSB #define OPT4048_REG_CH2_LSB 0x05 //!< Z channel LSB register
#define OPT4048_REG_CH3_MSB 0x06 // W channel MSB #define OPT4048_REG_CH3_MSB 0x06 //!< W channel MSB register
#define OPT4048_REG_CH3_LSB 0x07 // W channel LSB #define OPT4048_REG_CH3_LSB 0x07 //!< W channel LSB register
#define OPT4048_REG_THRESHOLD_LOW 0x08 // Low threshold register #define OPT4048_REG_THRESHOLD_LOW 0x08 //!< Low threshold register
#define OPT4048_REG_THRESHOLD_HIGH 0x09 // High threshold register #define OPT4048_REG_THRESHOLD_HIGH 0x09 //!< High threshold register
#define OPT4048_REG_CONFIG 0x0A // Configuration register #define OPT4048_REG_CONFIG 0x0A //!< Configuration register
#define OPT4048_REG_THRESHOLD_CFG 0x0B // Threshold configuration register #define OPT4048_REG_THRESHOLD_CFG 0x0B //!< Threshold configuration register
#define OPT4048_REG_STATUS 0x0C // Status register #define OPT4048_REG_STATUS 0x0C //!< Status register
#define OPT4048_REG_DEVICE_ID 0x11 // Device ID register #define OPT4048_REG_DEVICE_ID 0x11 //!< Device ID register
// Status register (0x0C) bit flags // Status register (0x0C) bit flags
#define OPT4048_FLAG_L 0x01 // Flag low - measurement smaller than threshold #define OPT4048_FLAG_L 0x01 //!< Flag low - measurement smaller than threshold
#define OPT4048_FLAG_H 0x02 // Flag high - measurement larger than threshold #define OPT4048_FLAG_H 0x02 //!< Flag high - measurement larger than threshold
#define OPT4048_FLAG_CONVERSION_READY 0x04 // Conversion ready #define OPT4048_FLAG_CONVERSION_READY 0x04 //!< Conversion ready
#define OPT4048_FLAG_OVERLOAD 0x08 // Overflow condition #define OPT4048_FLAG_OVERLOAD 0x08 //!< Overflow condition
/** /**
@brief Class that stores state and functions for interacting with the OPT4048 sensor. @brief Class that stores state and functions for interacting with the OPT4048
sensor.
*/ */
class Adafruit_OPT4048 { class Adafruit_OPT4048 {
public: public:
@ -146,7 +151,8 @@ public:
* @param ch3 Pointer to store channel 3 (W) value * @param ch3 Pointer to store channel 3 (W) value
* @return true if successful, false otherwise * @return true if successful, false otherwise
*/ */
bool getChannelsRaw(uint32_t *ch0, uint32_t *ch1, uint32_t *ch2, uint32_t *ch3); bool getChannelsRaw(uint32_t* ch0, uint32_t* ch1, uint32_t* ch2,
uint32_t* ch3);
bool setThresholdLow(uint32_t thl); bool setThresholdLow(uint32_t thl);
uint32_t getThresholdLow(void); uint32_t getThresholdLow(void);
@ -178,8 +184,9 @@ public:
/** /**
* @brief Calculate the correlated color temperature (CCT) in Kelvin * @brief Calculate the correlated color temperature (CCT) in Kelvin
* *
* Uses the McCamy's approximation formula to calculate CCT from CIE 1931 x,y coordinates. * Uses the McCamy's approximation formula to calculate CCT from CIE 1931 x,y
* This is accurate for color temperatures between 2000K and 30000K. * coordinates. This is accurate for color temperatures between 2000K and
* 30000K.
* *
* @param CIEx The CIE x chromaticity coordinate * @param CIEx The CIE x chromaticity coordinate
* @param CIEy The CIE y chromaticity coordinate * @param CIEy The CIE y chromaticity coordinate