From 5ba20b176327ae217b8678638706edc5df52f8aa Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Fri, 29 Jan 2016 02:38:21 -0200 Subject: [PATCH] AP_Notify: sanitize includes Due to the way the headers are organized changing a single change in an AP_Notify driver would trigger a rebuild for most of the files in the project. Time could be saved by using ccache (since most of the things didn't change) but we can do better, i.e. re-organize the headers so we don't have to re-build everything. --- libraries/AP_Notify/AP_BoardLED.cpp | 1 + libraries/AP_Notify/AP_BoardLED.h | 7 ++---- libraries/AP_Notify/AP_Notify.cpp | 14 +++++++++++ libraries/AP_Notify/AP_Notify.h | 24 ++++--------------- libraries/AP_Notify/Buzzer.cpp | 2 +- libraries/AP_Notify/Buzzer.h | 5 +--- libraries/AP_Notify/Display.cpp | 3 ++- libraries/AP_Notify/Display.h | 1 - libraries/AP_Notify/Display_SSD1306_I2C.cpp | 3 +-- libraries/AP_Notify/Display_SSD1306_I2C.h | 1 - libraries/AP_Notify/ExternalLED.cpp | 4 +++- libraries/AP_Notify/ExternalLED.h | 8 +++---- libraries/AP_Notify/NavioLED_I2C.cpp | 2 +- libraries/AP_Notify/NavioLED_I2C.h | 5 +--- libraries/AP_Notify/OreoLED_PX4.cpp | 3 ++- libraries/AP_Notify/OreoLED_PX4.h | 5 +--- libraries/AP_Notify/ToneAlarm_Linux.cpp | 11 +++++---- libraries/AP_Notify/ToneAlarm_Linux.h | 5 +--- libraries/AP_Notify/ToneAlarm_PX4.h | 5 +--- libraries/AP_Notify/ToshibaLED.h | 8 ++----- libraries/AP_Notify/ToshibaLED_I2C.cpp | 3 +-- libraries/AP_Notify/ToshibaLED_I2C.h | 7 +++--- libraries/AP_Notify/ToshibaLED_PX4.h | 8 +++---- libraries/AP_Notify/VRBoard_LED.cpp | 2 +- libraries/AP_Notify/VRBoard_LED.h | 8 ++----- .../ToshibaLED_test/ToshibaLED_test.cpp | 5 ++-- 26 files changed, 60 insertions(+), 90 deletions(-) diff --git a/libraries/AP_Notify/AP_BoardLED.cpp b/libraries/AP_Notify/AP_BoardLED.cpp index 4e388f2e78..2e9b931444 100644 --- a/libraries/AP_Notify/AP_BoardLED.cpp +++ b/libraries/AP_Notify/AP_BoardLED.cpp @@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "AP_BoardLED.h" #include "AP_Notify.h" diff --git a/libraries/AP_Notify/AP_BoardLED.h b/libraries/AP_Notify/AP_BoardLED.h index 2da0369f08..42843044ee 100644 --- a/libraries/AP_Notify/AP_BoardLED.h +++ b/libraries/AP_Notify/AP_BoardLED.h @@ -14,12 +14,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - -#ifndef __AP_HAL_BOARDLED_H__ -#define __AP_HAL_BOARDLED_H__ +#pragma once #include #include + #include "NotifyDevice.h" #define HIGH 1 @@ -38,5 +37,3 @@ private: // counter incremented at 50Hz uint8_t _counter; }; - -#endif // __AP_HAL_BOARDLED_H__ diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index be3c6b8dc7..0bd8ffd4c8 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -16,6 +16,20 @@ #include "AP_Notify.h" +#include "AP_BoardLED.h" +#include "Buzzer.h" +#include "Display_SSD1306_I2C.h" +#include "ExternalLED.h" +#include "NavioLED_I2C.h" +#include "OreoLED_PX4.h" +#include "RCOutputRGBLed.h" +#include "ToneAlarm_Linux.h" +#include "ToneAlarm_PX4.h" +#include "ToshibaLED.h" +#include "ToshibaLED_I2C.h" +#include "ToshibaLED_PX4.h" +#include "VRBoard_LED.h" + // table of user settable parameters const AP_Param::GroupInfo AP_Notify::var_info[] = { diff --git a/libraries/AP_Notify/AP_Notify.h b/libraries/AP_Notify/AP_Notify.h index 5be90dde0c..87935d63a0 100644 --- a/libraries/AP_Notify/AP_Notify.h +++ b/libraries/AP_Notify/AP_Notify.h @@ -14,27 +14,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - -#ifndef __AP_NOTIFY_H__ -#define __AP_NOTIFY_H__ +#pragma once #include -#include #include -#include "AP_BoardLED.h" -#include "ToshibaLED.h" -#include "ToshibaLED_I2C.h" -#include "ToshibaLED_PX4.h" -#include "ToneAlarm_PX4.h" -#include "ToneAlarm_Linux.h" -#include "NavioLED_I2C.h" -#include "ExternalLED.h" -#include "Buzzer.h" -#include "VRBoard_LED.h" -#include "OreoLED_PX4.h" -#include "RCOutputRGBLed.h" -#include "Display.h" -#include "Display_SSD1306_I2C.h" +#include + +#include "NotifyDevice.h" #ifndef OREOLED_ENABLED # define OREOLED_ENABLED 0 // set to 1 to enable OreoLEDs @@ -115,5 +101,3 @@ private: AP_Int8 _rgb_led_brightness; }; - -#endif // __AP_NOTIFY_H__ diff --git a/libraries/AP_Notify/Buzzer.cpp b/libraries/AP_Notify/Buzzer.cpp index 87acc0db35..a113801dfa 100644 --- a/libraries/AP_Notify/Buzzer.cpp +++ b/libraries/AP_Notify/Buzzer.cpp @@ -15,10 +15,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "Buzzer.h" #include -#include "Buzzer.h" #include "AP_Notify.h" extern const AP_HAL::HAL& hal; diff --git a/libraries/AP_Notify/Buzzer.h b/libraries/AP_Notify/Buzzer.h index a67f8f5901..0ccdacdc6f 100644 --- a/libraries/AP_Notify/Buzzer.h +++ b/libraries/AP_Notify/Buzzer.h @@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef __BUZZER_H__ -#define __BUZZER_H__ +#pragma once #if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN # define BUZZER_PIN 32 @@ -77,5 +76,3 @@ private: uint8_t _pattern_counter; // used to time on/off of current patter uint32_t _arming_buzz_start_ms; // arming_buzz start time in milliseconds }; - -#endif // __BUZZER_H__ diff --git a/libraries/AP_Notify/Display.cpp b/libraries/AP_Notify/Display.cpp index ec5bc1e510..9c208afdac 100644 --- a/libraries/AP_Notify/Display.cpp +++ b/libraries/AP_Notify/Display.cpp @@ -16,10 +16,11 @@ */ /* Notify display driver for 128 x 64 pixel displays */ +#include "Display.h" #include "AP_Notify.h" + #include -#include "Display.h" static const uint8_t _font[] = { 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/libraries/AP_Notify/Display.h b/libraries/AP_Notify/Display.h index 028cab107b..047b76af83 100644 --- a/libraries/AP_Notify/Display.h +++ b/libraries/AP_Notify/Display.h @@ -1,5 +1,4 @@ /// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- - #pragma once #include "NotifyDevice.h" diff --git a/libraries/AP_Notify/Display_SSD1306_I2C.cpp b/libraries/AP_Notify/Display_SSD1306_I2C.cpp index b6881a7f47..b68735a9e8 100644 --- a/libraries/AP_Notify/Display_SSD1306_I2C.cpp +++ b/libraries/AP_Notify/Display_SSD1306_I2C.cpp @@ -14,11 +14,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "Display_SSD1306_I2C.h" #include -#include "Display_SSD1306_I2C.h" - static const AP_HAL::HAL& hal = AP_HAL::get_HAL(); bool Display_SSD1306_I2C::hw_init() diff --git a/libraries/AP_Notify/Display_SSD1306_I2C.h b/libraries/AP_Notify/Display_SSD1306_I2C.h index 431d7f2e57..3d07fe91e8 100644 --- a/libraries/AP_Notify/Display_SSD1306_I2C.h +++ b/libraries/AP_Notify/Display_SSD1306_I2C.h @@ -1,5 +1,4 @@ /// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- - #pragma once #include "Display.h" diff --git a/libraries/AP_Notify/ExternalLED.cpp b/libraries/AP_Notify/ExternalLED.cpp index d2efeb2162..ec9efeabdf 100644 --- a/libraries/AP_Notify/ExternalLED.cpp +++ b/libraries/AP_Notify/ExternalLED.cpp @@ -14,10 +14,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "ExternalLED.h" -#include #include "AP_Notify.h" +#include + #if (defined(EXTERNAL_LED_ARMED) && defined(EXTERNAL_LED_GPS) && \ defined(EXTERNAL_LED_MOTOR1) && defined(EXTERNAL_LED_MOTOR2)) diff --git a/libraries/AP_Notify/ExternalLED.h b/libraries/AP_Notify/ExternalLED.h index dcd149a4d7..e4dbbf8037 100644 --- a/libraries/AP_Notify/ExternalLED.h +++ b/libraries/AP_Notify/ExternalLED.h @@ -15,12 +15,12 @@ along with this program. If not, see . */ -#ifndef __EXTERNALLED_H__ -#define __EXTERNALLED_H__ +#pragma once #include #include #include + #include "NotifyDevice.h" class ExternalLED: public NotifyDevice @@ -31,7 +31,7 @@ public: // initialise the LED driver bool init(void); - + // should be called at 50Hz void update(void); @@ -70,5 +70,3 @@ private: void motor_led1(bool on_off); void motor_led2(bool on_off); }; - -#endif // __EXTERNALLED_H__ diff --git a/libraries/AP_Notify/NavioLED_I2C.cpp b/libraries/AP_Notify/NavioLED_I2C.cpp index 4802c90e3b..2da5fd51c5 100644 --- a/libraries/AP_Notify/NavioLED_I2C.cpp +++ b/libraries/AP_Notify/NavioLED_I2C.cpp @@ -15,9 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "NavioLED_I2C.h" #include -#include "NavioLED_I2C.h" #define PCA9685_ADDRESS 0x40 #define PCA9685_PWM 0x6 diff --git a/libraries/AP_Notify/NavioLED_I2C.h b/libraries/AP_Notify/NavioLED_I2C.h index 59e7b1f695..52bd862034 100644 --- a/libraries/AP_Notify/NavioLED_I2C.h +++ b/libraries/AP_Notify/NavioLED_I2C.h @@ -14,8 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef __NAVIO_LED_I2C_H__ -#define __NAVIO_LED_I2C_H__ +#pragma once #include "NavioLED.h" @@ -25,5 +24,3 @@ protected: virtual bool hw_init(void); virtual bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b); }; - -#endif // __TOSHIBA_LED_I2C_H__ diff --git a/libraries/AP_Notify/OreoLED_PX4.cpp b/libraries/AP_Notify/OreoLED_PX4.cpp index 33db5976a0..9f90df7e2a 100644 --- a/libraries/AP_Notify/OreoLED_PX4.cpp +++ b/libraries/AP_Notify/OreoLED_PX4.cpp @@ -20,7 +20,6 @@ #if CONFIG_HAL_BOARD == HAL_BOARD_PX4 #include "OreoLED_PX4.h" -#include "AP_Notify.h" #include #include @@ -32,6 +31,8 @@ #include #include +#include "AP_Notify.h" + extern const AP_HAL::HAL& hal; #define OREOLED_BACKLEFT 0 // back left led instance number diff --git a/libraries/AP_Notify/OreoLED_PX4.h b/libraries/AP_Notify/OreoLED_PX4.h index 1a430fbf40..725a11c0d5 100644 --- a/libraries/AP_Notify/OreoLED_PX4.h +++ b/libraries/AP_Notify/OreoLED_PX4.h @@ -14,8 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef __OREOLED_PX4_H__ -#define __OREOLED_PX4_H__ +#pragma once #if CONFIG_HAL_BOARD == HAL_BOARD_PX4 @@ -93,5 +92,3 @@ private: }; #endif // CONFIG_HAL_BOARD == HAL_BOARD_PX4 - -#endif // __OREOLED_PX4_H__ diff --git a/libraries/AP_Notify/ToneAlarm_Linux.cpp b/libraries/AP_Notify/ToneAlarm_Linux.cpp index 85a1558305..e475d33014 100644 --- a/libraries/AP_Notify/ToneAlarm_Linux.cpp +++ b/libraries/AP_Notify/ToneAlarm_Linux.cpp @@ -20,16 +20,17 @@ #if CONFIG_HAL_BOARD == HAL_BOARD_LINUX #include "ToneAlarm_Linux.h" -#include "AP_Notify.h" -#include -#include +#include #include +#include +#include +#include #include #include -#include -#include + +#include "AP_Notify.h" extern const AP_HAL::HAL& hal; diff --git a/libraries/AP_Notify/ToneAlarm_Linux.h b/libraries/AP_Notify/ToneAlarm_Linux.h index a002375c0a..b3049c6796 100644 --- a/libraries/AP_Notify/ToneAlarm_Linux.h +++ b/libraries/AP_Notify/ToneAlarm_Linux.h @@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef __TONE_ALARM_Linux_H__ -#define __TONE_ALARM_Linux_H__ +#pragma once #include "NotifyDevice.h" @@ -42,5 +41,3 @@ private: bool parachute_release : 1; // true if parachute is being released } flags; }; - -#endif // __TONE_ALARM_Linux_H__ diff --git a/libraries/AP_Notify/ToneAlarm_PX4.h b/libraries/AP_Notify/ToneAlarm_PX4.h index 76e52310da..fa2357e12e 100644 --- a/libraries/AP_Notify/ToneAlarm_PX4.h +++ b/libraries/AP_Notify/ToneAlarm_PX4.h @@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef __TONE_ALARM_PX4_H__ -#define __TONE_ALARM_PX4_H__ +#pragma once #include "NotifyDevice.h" @@ -69,5 +68,3 @@ private: const static Tone _tones[]; }; - -#endif // __TONE_ALARM_PX4_H__ diff --git a/libraries/AP_Notify/ToshibaLED.h b/libraries/AP_Notify/ToshibaLED.h index 9758241ca1..6f182dbf19 100644 --- a/libraries/AP_Notify/ToshibaLED.h +++ b/libraries/AP_Notify/ToshibaLED.h @@ -1,5 +1,5 @@ /* - * AP_Notify Library. + * AP_Notify Library. * based upon a prototype library by David "Buzz" Bussenschutt. */ @@ -17,9 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - -#ifndef __TOSHIBA_LED_H__ -#define __TOSHIBA_LED_H__ +#pragma once #include "RGBLed.h" @@ -27,5 +25,3 @@ class ToshibaLED: public RGBLed { public: ToshibaLED(); }; - -#endif // __TOSHIBA_LED_H__ diff --git a/libraries/AP_Notify/ToshibaLED_I2C.cpp b/libraries/AP_Notify/ToshibaLED_I2C.cpp index a07d0889b7..4c0639cd94 100644 --- a/libraries/AP_Notify/ToshibaLED_I2C.cpp +++ b/libraries/AP_Notify/ToshibaLED_I2C.cpp @@ -15,10 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "ToshibaLED_I2C.h" #include -#include "ToshibaLED.h" -#include "ToshibaLED_I2C.h" extern const AP_HAL::HAL& hal; diff --git a/libraries/AP_Notify/ToshibaLED_I2C.h b/libraries/AP_Notify/ToshibaLED_I2C.h index 02f6793363..5f2d125073 100644 --- a/libraries/AP_Notify/ToshibaLED_I2C.h +++ b/libraries/AP_Notify/ToshibaLED_I2C.h @@ -14,8 +14,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef __TOSHIBA_LED_I2C_H__ -#define __TOSHIBA_LED_I2C_H__ +#pragma once + +#include "ToshibaLED.h" class ToshibaLED_I2C : public ToshibaLED { @@ -23,5 +24,3 @@ public: bool hw_init(void); bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b); }; - -#endif // __TOSHIBA_LED_I2C_H__ diff --git a/libraries/AP_Notify/ToshibaLED_PX4.h b/libraries/AP_Notify/ToshibaLED_PX4.h index 38ecc2aceb..d4caf263d0 100644 --- a/libraries/AP_Notify/ToshibaLED_PX4.h +++ b/libraries/AP_Notify/ToshibaLED_PX4.h @@ -15,13 +15,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef __TOSHIBA_LED_PX4_H__ -#define __TOSHIBA_LED_PX4_H__ +#pragma once -#include "ToshibaLED.h" #include #include +#include "ToshibaLED.h" + class ToshibaLED_PX4 : public ToshibaLED { public: @@ -44,5 +44,3 @@ private: union rgb_value last, next; }; - -#endif // __TOSHIBA_LED_PX4_H__ diff --git a/libraries/AP_Notify/VRBoard_LED.cpp b/libraries/AP_Notify/VRBoard_LED.cpp index a4a5ab2d17..d69e6c45c2 100644 --- a/libraries/AP_Notify/VRBoard_LED.cpp +++ b/libraries/AP_Notify/VRBoard_LED.cpp @@ -16,8 +16,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - #include "VRBoard_LED.h" + #include #if (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN) && \ diff --git a/libraries/AP_Notify/VRBoard_LED.h b/libraries/AP_Notify/VRBoard_LED.h index 1203883748..b45e94dc8b 100644 --- a/libraries/AP_Notify/VRBoard_LED.h +++ b/libraries/AP_Notify/VRBoard_LED.h @@ -1,5 +1,5 @@ /* - * AP_Notify Library. + * AP_Notify Library. * based upon a prototype library by David "Buzz" Bussenschutt. */ @@ -18,13 +18,11 @@ along with this program. If not, see . */ -#ifndef __VRBRAIN_LED_H__ -#define __VRBRAIN_LED_H__ +#pragma once #include "RGBLed.h" #include "AP_BoardLED.h" - class VRBoard_LED: public RGBLed { public: VRBoard_LED(); @@ -32,5 +30,3 @@ public: bool hw_init(void); bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b); }; - -#endif diff --git a/libraries/AP_Notify/examples/ToshibaLED_test/ToshibaLED_test.cpp b/libraries/AP_Notify/examples/ToshibaLED_test/ToshibaLED_test.cpp index ad37f3ef2c..0de3e4b0f1 100644 --- a/libraries/AP_Notify/examples/ToshibaLED_test/ToshibaLED_test.cpp +++ b/libraries/AP_Notify/examples/ToshibaLED_test/ToshibaLED_test.cpp @@ -1,14 +1,15 @@ // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*- #include -#include // Notify library -#include +#include const AP_HAL::HAL& hal = AP_HAL::get_HAL(); #if CONFIG_HAL_BOARD == HAL_BOARD_PX4 +#include static ToshibaLED_PX4 toshiba_led; #else +#include static ToshibaLED_I2C toshiba_led; #endif