diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2679a37..728592b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,8 +15,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p Please ensure to specify the following: * Arduino IDE version (e.g. 1.8.19) or Platform.io version -* Board type -* Arduino `mbed` Core Version (e.g. Arduino `mbed` core v1.3.2 or Arduino `mbed_nano` core v2.7.2 ) +* `nRF52840 mbed` Core Version (e.g. Arduino mbed_nano core v3.4.1, Seeeduino mbed core v2.7.2) +* `nRF52840-based Nano_33_BLE` Board type (e.g. Nano_33_BLE, Nano_33_BLE_Sense, SEEED_XIAO_NRF52840 and SEEED_XIAO_NRF52840_SENSE, etc.) * Contextual information (e.g. what you were trying to achieve) * Simplest possible steps to reproduce * Anything that might be relevant in your opinion, such as: @@ -28,13 +28,13 @@ Please ensure to specify the following: ``` Arduino IDE version: 1.8.19 +Arduino mbed_nano core v3.4.1 Nano_33_BLE board -Arduino mbed_nano` core v2.7.2 OS: Ubuntu 20.04 LTS -Linux xy-Inspiron-3593 5.4.0-99-generic #112-Ubuntu SMP Thu Feb 3 13:50:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux +Linux xy-Inspiron-3593 5.15.0-52-generic #58~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Context: -I encountered a crash while using PWM. +I encountered a crash while using this library Steps to reproduce: 1. ... @@ -43,13 +43,33 @@ Steps to reproduce: 4. ... ``` +--- + ### Sending Feature Requests Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful. There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/nRF52_MBED_PWM/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them. +--- + ### Sending Pull Requests Pull Requests with changes and fixes are also welcome! +Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux) + +1. Change directory to the library GitHub + +``` +xy@xy-Inspiron-3593:~$ cd Arduino/xy/nRF52_MBED_PWM_GitHub/ +xy@xy-Inspiron-3593:~/Arduino/xy/nRF52_MBED_PWM_GitHub$ +``` + +2. Issue astyle command + +``` +xy@xy-Inspiron-3593:~/Arduino/xy/nRF52_MBED_PWM_GitHub$ bash utils/restyle.sh +``` + + diff --git a/changelog.md b/changelog.md index 2e13cc9..0abd5d9 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ ## Table of Contents * [Changelog](#changelog) + * [Releases v1.0.2](#Releases-v102) * [Releases v1.0.1](#Releases-v101) * [Initial Releases v1.0.0](#Initial-Releases-v100) @@ -20,12 +21,16 @@ ## Changelog +### Releases v1.0.2 + +1. Add support to Seeeduino nRF52840-based boards such as **SEEED_XIAO_NRF52840 and SEEED_XIAO_NRF52840_SENSE**, etc. using Seeeduino `mbed` core +2. Add astyle using `allman` style. Restyle the library + ### Releases v1.0.1 1. Add functions to read PWM parameters 2. Update examples - ### Initial Releases v1.0.0 1. Initial coding to support **Nano_33_BLE boards**, using [**ArduinoCore-mbed mbed_nano** core](https://github.com/arduino/ArduinoCore-mbed) diff --git a/examples/PWM_Multi/PWM_Multi.ino b/examples/PWM_Multi/PWM_Multi.ino index 2b4cd68..65f2433 100644 --- a/examples/PWM_Multi/PWM_Multi.ino +++ b/examples/PWM_Multi/PWM_Multi.ino @@ -39,11 +39,12 @@ void startAllPWM() digitalWrite(LEDG, LED_ON); digitalWrite(LEDB, LED_OFF); digitalWrite(LEDR, LED_OFF); - + for (uint8_t index = 0; index < NUM_OF_PINS; index++) { - PWM_LOGERROR7("Freq = ", freq[index], ", \tDutyCycle % = ", dutyCycle[index], ", \tDutyCycle = ", dutyCycle[index] / 100, ", \tPin = ", pins[index]); - + PWM_LOGERROR7("Freq = ", freq[index], ", \tDutyCycle % = ", dutyCycle[index], ", \tDutyCycle = ", + dutyCycle[index] / 100, ", \tPin = ", pins[index]); + // setPWM(mbed::PwmOut* &pwm, pin_size_t pin, float frequency, float dutyCycle) setPWM(pwm[index], pins[index], freq[index], dutyCycle[index]); } @@ -54,12 +55,12 @@ void restoreAllPWM() digitalWrite(LEDG, LED_ON); digitalWrite(LEDB, LED_OFF); digitalWrite(LEDR, LED_OFF); - + for (uint8_t index = 0; index < NUM_OF_PINS; index++) { curFreq[index] = freq[index]; curDutyCycle[index] = dutyCycle[index]; - + // setPWM(mbed::PwmOut* &pwm, pin_size_t pin, float frequency, float dutyCycle) setPWM(pwm[index], pins[index], freq[index], dutyCycle[index]); } @@ -70,12 +71,12 @@ void changeAllPWM() digitalWrite(LEDG, LED_OFF); digitalWrite(LEDB, LED_ON); digitalWrite(LEDR, LED_OFF); - + for (uint8_t index = 0; index < NUM_OF_PINS; index++) { curFreq[index] = freq[index] * 2; curDutyCycle[index] = dutyCycle[index] / 2; - + // setPWM(mbed::PwmOut* &pwm, pin_size_t pin, float frequency, float dutyCycle) setPWM(pwm[index], pins[index], curFreq[index], curDutyCycle[index]); } @@ -86,12 +87,12 @@ void stopAllPWM() digitalWrite(LEDG, LED_OFF); digitalWrite(LEDB, LED_OFF); digitalWrite(LEDR, LED_ON); - + for (uint8_t index = 0; index < NUM_OF_PINS; index++) { curFreq[index] = 1000.0f; curDutyCycle[index] = 0.0f; - + //stopPWM(mbed::PwmOut* &pwm, pin_size_t pin) stopPWM(pwm[index], pins[index]); } @@ -109,22 +110,25 @@ void printPulseWidth() if (num++ % 50 == 0) { printLine(); - + for (uint8_t index = 0; index < NUM_OF_PINS; index++) { - Serial.print(F("PW (us) ")); Serial.print(index); Serial.print(F("\t")); + Serial.print(F("PW (us) ")); + Serial.print(index); + Serial.print(F("\t")); } printLine(); } - + if (num > 1) { for (uint8_t index = 0; index < NUM_OF_PINS; index++) { if (pwm[index]) { - Serial.print(getPulseWidth_uS(pwm[index])); Serial.print(F("\t\t")); + Serial.print(getPulseWidth_uS(pwm[index])); + Serial.print(F("\t\t")); } } @@ -152,10 +156,10 @@ void check_status() if ( (millis() > changePWM_timeout) && (millis() > CHANGE_INTERVAL) ) { - + if (PWM_orig) { - if (count++ %2 == 0) + if (count++ % 2 == 0) { Serial.println("Stop all PWM"); stopAllPWM(); @@ -163,7 +167,7 @@ void check_status() else { Serial.println("Change all PWM"); - + changeAllPWM(); PWM_orig = !PWM_orig; @@ -172,12 +176,12 @@ void check_status() else { Serial.println("Restore all PWM"); - + restoreAllPWM(); PWM_orig = !PWM_orig; } - + changePWM_timeout = millis() + CHANGE_INTERVAL; } } @@ -199,11 +203,13 @@ void setup() } Serial.begin(115200); - while (!Serial); + + while (!Serial && millis() < 5000); delay(100); - Serial.print(F("\nStarting PWM_Multi on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStarting PWM_Multi on ")); + Serial.println(BOARD_NAME); Serial.println(nRF52_MBED_PWM_VERSION); startAllPWM(); diff --git a/examples/PWM_Single/PWM_Single.ino b/examples/PWM_Single/PWM_Single.ino index 373481c..16f5eb2 100644 --- a/examples/PWM_Single/PWM_Single.ino +++ b/examples/PWM_Single/PWM_Single.ino @@ -47,10 +47,10 @@ void restorePWM() digitalWrite(LEDG, LED_ON); digitalWrite(LEDB, LED_OFF); digitalWrite(LEDR, LED_OFF); - + curFreq = freq; curDutyCycle = dutyCycle; - + // setPWM(mbed::PwmOut* &pwm, pin_size_t pin, float frequency, float dutyCycle) setPWM(pwm, myPin, freq, dutyCycle); } @@ -60,10 +60,10 @@ void changePWM() digitalWrite(LEDG, LED_OFF); digitalWrite(LEDB, LED_ON); digitalWrite(LEDR, LED_OFF); - + curFreq = freq * 2; curDutyCycle = dutyCycle / 2; - + // setPWM(mbed::PwmOut* &pwm, pin_size_t pin, float frequency, float dutyCycle) setPWM(pwm, myPin, curFreq, curDutyCycle); } @@ -73,10 +73,10 @@ void stopMyPWM() digitalWrite(LEDG, LED_OFF); digitalWrite(LEDB, LED_OFF); digitalWrite(LEDR, LED_ON); - + curFreq = 1000.0f; curDutyCycle = 0.0f; - + //stopPWM(mbed::PwmOut* &pwm, pin_size_t pin) stopPWM(pwm, myPin); } @@ -93,18 +93,20 @@ void printPulseWidth() if (num++ % 50 == 0) { printLine(); - + Serial.print(F("PW (us)\t\tDutyCycle\tPeriod (uS)")); printLine(); } - + if (num > 1) { if (pwm) { - Serial.print(getPulseWidth_uS(pwm)); Serial.print(F("\t\t")); - Serial.print(getDutyCycle(pwm)); Serial.print(F("\t\t")); + Serial.print(getPulseWidth_uS(pwm)); + Serial.print(F("\t\t")); + Serial.print(getDutyCycle(pwm)); + Serial.print(F("\t\t")); Serial.print(getPeriod_uS(pwm)); } @@ -132,10 +134,10 @@ void check_status() if ( (millis() > changePWM_timeout) && (millis() > CHANGE_INTERVAL) ) { - + if (PWM_orig) { - if (count++ %2 == 0) + if (count++ % 2 == 0) { Serial.println("Stop PWM"); stopMyPWM(); @@ -143,7 +145,7 @@ void check_status() else { Serial.println("Change PWM"); - + changePWM(); PWM_orig = !PWM_orig; @@ -152,12 +154,12 @@ void check_status() else { Serial.println("Restore PWM"); - + restorePWM(); PWM_orig = !PWM_orig; } - + changePWM_timeout = millis() + CHANGE_INTERVAL; } } @@ -176,11 +178,13 @@ void setup() digitalWrite(myPin, LOW); Serial.begin(115200); - while (!Serial); + + while (!Serial && millis() < 5000); delay(100); - Serial.print(F("\nStarting PWM_Single on ")); Serial.println(BOARD_NAME); + Serial.print(F("\nStarting PWM_Single on ")); + Serial.println(BOARD_NAME); Serial.println(nRF52_MBED_PWM_VERSION); startPWM(); diff --git a/examples/multiFileProject/multiFileProject.cpp b/examples/multiFileProject/multiFileProject.cpp index 3b352ce..5e3d3ce 100644 --- a/examples/multiFileProject/multiFileProject.cpp +++ b/examples/multiFileProject/multiFileProject.cpp @@ -1,6 +1,6 @@ /**************************************************************************************************************************** multiFileProject.cpp - + For Nano_33_BLE or Nano_33_BLE_Sense boards Written by Khoi Hoang diff --git a/examples/multiFileProject/multiFileProject.h b/examples/multiFileProject/multiFileProject.h index 6bdcbc4..08147ac 100644 --- a/examples/multiFileProject/multiFileProject.h +++ b/examples/multiFileProject/multiFileProject.h @@ -1,6 +1,6 @@ /**************************************************************************************************************************** multiFileProject.h - + For Nano_33_BLE or Nano_33_BLE_Sense boards Written by Khoi Hoang diff --git a/examples/multiFileProject/multiFileProject.ino b/examples/multiFileProject/multiFileProject.ino index 4fe7a21..8950b76 100644 --- a/examples/multiFileProject/multiFileProject.ino +++ b/examples/multiFileProject/multiFileProject.ino @@ -1,6 +1,6 @@ /**************************************************************************************************************************** multiFileProject.ino - + For Nano_33_BLE or Nano_33_BLE_Sense boards Written by Khoi Hoang @@ -14,32 +14,36 @@ #error This code is designed to run on nRF52-based Nano-33-BLE boards using mbed-RTOS platform! Please check your Tools->Board setting. #endif -#define nRF52_MBED_PWM_VERSION_MIN_TARGET "nRF52_MBED_PWM v1.0.1" -#define nRF52_MBED_PWM_VERSION_MIN 1000001 +#define nRF52_MBED_PWM_VERSION_MIN_TARGET "nRF52_MBED_PWM v1.0.2" +#define nRF52_MBED_PWM_VERSION_MIN 1000002 #include "multiFileProject.h" // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include "nRF52_MBED_PWM.h" -void setup() +void setup() { Serial.begin(115200); - while (!Serial); - - Serial.println("\nStart multiFileProject"); + + while (!Serial && millis() < 5000); + + Serial.println("\nStart multiFileProject on "); + Serial.println(BOARD_NAME); Serial.println(nRF52_MBED_PWM_VERSION); #if defined(nRF52_MBED_PWM_VERSION_MIN) + if (nRF52_MBED_PWM_VERSION_INT < nRF52_MBED_PWM_VERSION_MIN) { Serial.print("Warning. Must use this example on Version equal or later than : "); Serial.println(nRF52_MBED_PWM_VERSION_MIN_TARGET); } + #endif } -void loop() +void loop() { // put your main code here, to run repeatedly: } diff --git a/library.json b/library.json index 190578e..e1d2983 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "nRF52_MBED_PWM", - "version": "1.0.1", + "version": "1.0.2", "keywords": "timing, device, control, timer, pwm, interrupt, isr, isr-based, hardware-timer, mission-critical, accuracy, non-blocking, mbed, mbed-nano, nrf52840, nano-33-ble, nano-33-ble-sense, precise, hardware", "description": "This library enables you to use Hardware-based PWM to create and output PWM to pins on an nRF52840-based Nano_33_BLE board. These PWM channels, using nRF52840 Hardware PWM, still work even if other functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software ir ISR-based PWM, using millis(), micros() or Timer Interrupt. This important feature is absolutely necessary for mission-critical tasks. You can start, stop, change and restore the settings of any PWM channel on-the-fly.", "authors": diff --git a/library.properties b/library.properties index 20cd3c2..b99b485 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=nRF52_MBED_PWM -version=1.0.1 +version=1.0.2 author=Khoi Hoang maintainer=Khoi Hoang sentence=This library enables you to use Hardware-based PWM to create and output PWM to pins on an nRF52840-based Nano_33_BLE board. diff --git a/src/PWM_Generic_Debug.h b/src/PWM_Generic_Debug.h index 19e352f..115c390 100644 --- a/src/PWM_Generic_Debug.h +++ b/src/PWM_Generic_Debug.h @@ -6,12 +6,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/nRF52_MBED_PWM Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K.Hoang 09/02/2022 Initial coding for Nano_33_BLE / Nano_33_BLE_Sense using ArduinoCore-mbed mbed_nano core 1.0.1 K.Hoang 09/02/2022 Add functions to read PWM parameters + 1.0.2 K.Hoang 26/10/2022 Add support to SEEED_XIAO_NRF52840 and SEEED_XIAO_NRF52840_SENSE using mbed *****************************************************************************************************************************/ #pragma once diff --git a/src/nRF52_MBED_PWM.h b/src/nRF52_MBED_PWM.h index 8aa5c2d..6bed619 100644 --- a/src/nRF52_MBED_PWM.h +++ b/src/nRF52_MBED_PWM.h @@ -6,12 +6,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/nRF52_MBED_PWM Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K.Hoang 09/02/2022 Initial coding for Nano_33_BLE / Nano_33_BLE_Sense using ArduinoCore-mbed mbed_nano core 1.0.1 K.Hoang 09/02/2022 Add functions to read PWM parameters + 1.0.2 K.Hoang 26/10/2022 Add support to SEEED_XIAO_NRF52840 and SEEED_XIAO_NRF52840_SENSE using mbed *****************************************************************************************************************************/ #pragma once diff --git a/src/nRF52_MBED_PWM.hpp b/src/nRF52_MBED_PWM.hpp index 6d67175..955eb18 100644 --- a/src/nRF52_MBED_PWM.hpp +++ b/src/nRF52_MBED_PWM.hpp @@ -6,12 +6,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/nRF52_MBED_PWM Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K.Hoang 09/02/2022 Initial coding for Nano_33_BLE / Nano_33_BLE_Sense using ArduinoCore-mbed mbed_nano core 1.0.1 K.Hoang 09/02/2022 Add functions to read PWM parameters + 1.0.2 K.Hoang 26/10/2022 Add support to SEEED_XIAO_NRF52840 and SEEED_XIAO_NRF52840_SENSE using mbed *****************************************************************************************************************************/ #pragma once @@ -24,13 +25,13 @@ #endif #ifndef nRF52_MBED_PWM_VERSION - #define nRF52_MBED_PWM_VERSION "nRF52_MBED_PWM v1.0.1" + #define nRF52_MBED_PWM_VERSION "nRF52_MBED_PWM v1.0.2" #define nRF52_MBED_PWM_VERSION_MAJOR 1 #define nRF52_MBED_PWM_VERSION_MINOR 0 - #define nRF52_MBED_PWM_VERSION_PATCH 1 + #define nRF52_MBED_PWM_VERSION_PATCH 2 - #define nRF52_MBED_PWM_VERSION_INT 1000001 + #define nRF52_MBED_PWM_VERSION_INT 1000002 #endif diff --git a/src/nRF52_MBED_PWM_Impl.h b/src/nRF52_MBED_PWM_Impl.h index 033f80b..8902c56 100644 --- a/src/nRF52_MBED_PWM_Impl.h +++ b/src/nRF52_MBED_PWM_Impl.h @@ -6,12 +6,13 @@ Built by Khoi Hoang https://github.com/khoih-prog/nRF52_MBED_PWM Licensed under MIT license - Version: 1.0.1 + Version: 1.0.2 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K.Hoang 09/02/2022 Initial coding for Nano_33_BLE / Nano_33_BLE_Sense using ArduinoCore-mbed mbed_nano core 1.0.1 K.Hoang 09/02/2022 Add functions to read PWM parameters + 1.0.2 K.Hoang 26/10/2022 Add support to SEEED_XIAO_NRF52840 and SEEED_XIAO_NRF52840_SENSE using mbed *****************************************************************************************************************************/ #ifndef nRF52_MBED_PWM_IMPL_H @@ -30,14 +31,20 @@ // https://www.etechnophiles.com/arduino-nano-33-ble-sense-pinout-introduction-specifications/ bool isValidPWMPin(const pin_size_t& pin) { +#if defined(ARDUINO_ARDUINO_NANO33BLE) + if ( (pin == D0) || (pin == D1) || (pin == D2) || (pin == D3) || (pin == D4) || (pin == D5) || (pin == D6) || \ (pin == D7) || (pin == D8) || (pin == D9) || (pin == D10) || (pin == D11) || (pin == D12) || (pin == D13) ) +#elif ( defined(ARDUINO_SEEED_XIAO_NRF52840) || defined(ARDUINO_SEEED_XIAO_NRF52840_SENSE) ) + if ( (pin == D0) || (pin == D1) || (pin == D2) || (pin == D3) || (pin == D4) || (pin == D5) || (pin == D6) || \ + (pin == D7) || (pin == D8) || (pin == D9) || (pin == D10) ) +#endif { return true; } - + PWM_LOGERROR1("Not PWM pin = ", pin); - + return false; } @@ -46,7 +53,7 @@ bool isValidPWMDutyCycle(const pin_size_t& pin, const float& dutyCycle) if ( (dutyCycle < 0.0f) || (dutyCycle > 100.0f) ) { PWM_LOGERROR3("Bad dutyCycle = ", dutyCycle, ", pin = ", pin); - + return false; } @@ -62,53 +69,54 @@ bool isValidPWMFreq(const pin_size_t& pin, const float& frequency) return false; } - + return true; } bool isValidPWMSettings(const pin_size_t& pin, const float& frequency, const float& dutyCycle) { if ( !isValidPWMPin(pin) || !isValidPWMFreq(pin, frequency) || !isValidPWMDutyCycle(pin, dutyCycle) ) - { + { return false; - } - + } + return true; } // dutyCycle from 0.0f to 100.0f mbed::PwmOut* setPWM(mbed::PwmOut* &pwm, const pin_size_t& pin, const float& frequency, const float& dutyCycle) { - PWM_LOGDEBUG7("Freq = ", frequency, ", \tDutyCycle = ", dutyCycle, ", \tDutyCycle % = ", dutyCycle / 100, ", \tPin = ", pin); - + PWM_LOGDEBUG7("Freq = ", frequency, ", \tDutyCycle = ", dutyCycle, ", \tDutyCycle % = ", dutyCycle / 100, ", \tPin = ", + pin); + if ( !isValidPWMSettings(pin, frequency, dutyCycle) ) - { + { return NULL; } float percent = dutyCycle / 100.0f; - + if (digitalPinToPwm(pin) == NULL) { PWM_LOGDEBUG("New pwm"); - + pwm = new mbed::PwmOut(digitalPinToPinName(pin)); - + digitalPinToPwm(pin) = pwm; - pwm->period_us( 1000000.0f/frequency ); + pwm->period_us( 1000000.0f / frequency ); pwm->write(percent); } else if (pwm && (digitalPinToPwm(pin) == pwm) ) { PWM_LOGDEBUG("Use existing pwm"); - - pwm->period_us( 1000000.0f/frequency ); + + pwm->period_us( 1000000.0f / frequency ); pwm->write(percent); } - + return pwm; } diff --git a/utils/astyle_library.conf b/utils/astyle_library.conf new file mode 100644 index 0000000..8a73bc2 --- /dev/null +++ b/utils/astyle_library.conf @@ -0,0 +1,70 @@ +# Code formatting rules for Arduino libraries, modified from for KH libraries: +# +# https://github.com/arduino/Arduino/blob/master/build/shared/examples_formatter.conf +# + +# astyle --style=allman -s2 -t2 -C -S -xW -Y -M120 -f -p -xg -H -xb -c --xC120 -xL *.h *.cpp *.ino + +--mode=c +--lineend=linux +--style=allman + +# -r or -R +#--recursive + +# -c => Converts tabs into spaces +convert-tabs + +# -s2 => 2 spaces indentation +--indent=spaces=2 + +# -t2 => tab =2 spaces +#--indent=tab=2 + +# -C +--indent-classes + +# -S +--indent-switches + +# -xW +--indent-preproc-block + +# -Y => indent classes, switches (and cases), comments starting at column 1 +--indent-col1-comments + +# -M120 => maximum of 120 spaces to indent a continuation line +--max-continuation-indent=120 + +# -xC120 => max‑code‑length will break a line if the code exceeds # characters +--max-code-length=120 + +# -f => +--break-blocks + +# -p => put a space around operators +--pad-oper + +# -xg => Insert space padding after commas +--pad-comma + +# -H => put a space after if/for/while +pad-header + +# -xb => Break one line headers (e.g. if/for/while) +--break-one-line-headers + +# -c => Converts tabs into spaces +#--convert-tabs + +# if you like one-liners, keep them +#keep-one-line-statements + +# -xV +--attach-closing-while + +#unpad-paren + +# -xp +remove-comment-prefix + diff --git a/utils/restyle.sh b/utils/restyle.sh new file mode 100644 index 0000000..bcd846f --- /dev/null +++ b/utils/restyle.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +for dir in . ; do + find $dir -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.ino" \) -exec astyle --suffix=none --options=./utils/astyle_library.conf \{\} \; +done +