Fix clang-format CI: add .clang-format, update workflow, format code

This commit is contained in:
piclaw
2026-02-05 09:32:02 -05:00
parent 2295fe471c
commit 99e90c2698
6 changed files with 231 additions and 180 deletions
+13
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
+20
View File
@@ -3,8 +3,28 @@ name: Arduino Library CI
on: [pull_request, push, repository_dispatch]
jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: adafruit/ci-arduino
path: ci
- name: pre-install
run: bash ci/actions_install.sh
- name: clang
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
build:
runs-on: ubuntu-latest
needs: clang-format
steps:
- uses: actions/setup-python@v4
+6 -2
View File
@@ -129,7 +129,9 @@ float DHT::readTemperature(bool S, bool force) {
* value in Celcius
* @return float value in Fahrenheit
*/
float DHT::convertCtoF(float c) { return c * 1.8 + 32; }
float DHT::convertCtoF(float c) {
return c * 1.8 + 32;
}
/*!
* @brief Converts Fahrenheit to Celcius
@@ -137,7 +139,9 @@ float DHT::convertCtoF(float c) { return c * 1.8 + 32; }
* value in Fahrenheit
* @return float value in Celcius
*/
float DHT::convertFtoC(float f) { return (f - 32) * 0.55555; }
float DHT::convertFtoC(float f) {
return (f - 32) * 0.55555;
}
/*!
* @brief Read Humidity
+10 -4
View File
@@ -30,14 +30,20 @@
/* Setup debug printing macros. */
#ifdef DHT_DEBUG
#define DEBUG_PRINT(...) \
{ DEBUG_PRINTER.print(__VA_ARGS__); }
{ \
DEBUG_PRINTER.print(__VA_ARGS__); \
}
#define DEBUG_PRINTLN(...) \
{ DEBUG_PRINTER.println(__VA_ARGS__); }
{ \
DEBUG_PRINTER.println(__VA_ARGS__); \
}
#else
#define DEBUG_PRINT(...) \
{} /**< Debug Print Placeholder if Debug is disabled */
{ \
} /**< Debug Print Placeholder if Debug is disabled */
#define DEBUG_PRINTLN(...) \
{} /**< Debug Print Line Placeholder if Debug is disabled */
{ \
} /**< Debug Print Line Placeholder if Debug is disabled */
#endif
/* Define types of sensors. */
+9 -5
View File
@@ -29,13 +29,17 @@
*/
DHT_Unified::DHT_Unified(uint8_t pin, uint8_t type, uint8_t count,
int32_t tempSensorId, int32_t humiditySensorId)
: _dht(pin, type, count), _type(type), _temp(this, tempSensorId),
: _dht(pin, type, count),
_type(type),
_temp(this, tempSensorId),
_humidity(this, humiditySensorId) {}
/*!
* @brief Setup sensor (calls begin on It)
*/
void DHT_Unified::begin() { _dht.begin(); }
void DHT_Unified::begin() {
_dht.begin();
}
/*!
* @brief Sets sensor name
@@ -57,9 +61,9 @@ void DHT_Unified::setName(sensor_t *sensor) {
strncpy(sensor->name, "DHT22", sizeof(sensor->name) - 1);
break;
default:
// TODO: Perhaps this should be an error? However main DHT library doesn't
// enforce restrictions on the sensor type value. Pick a generic name for
// now.
// TODO: Perhaps this should be an error? However main DHT library
// doesn't enforce restrictions on the sensor type value. Pick a generic
// name for now.
strncpy(sensor->name, "DHT?", sizeof(sensor->name) - 1);
break;
}
+6 -2
View File
@@ -80,13 +80,17 @@ public:
* @brief Returns temperature stored in _temp
* @return Temperature value
*/
Temperature temperature() { return _temp; }
Temperature temperature() {
return _temp;
}
/*!
* @brief Returns humidity stored in _humidity
* @return Humidity value
*/
Humidity humidity() { return _humidity; }
Humidity humidity() {
return _humidity;
}
private:
DHT _dht;