From 93ce6e542a71ab8c4f2dd27da00e5c88910f3b0b Mon Sep 17 00:00:00 2001 From: jflyper Date: Mon, 5 Feb 2018 00:35:51 +0900 Subject: [PATCH] Separate pg related to pg directory --- make/source.mk | 1 + src/main/drivers/display_ug2864hsweg01.c | 8 ------ src/main/interface/settings.c | 1 + src/main/io/dashboard.c | 9 +----- src/main/io/dashboard.h | 15 ++++------ src/main/pg/dashboard.c | 35 ++++++++++++++++++++++++ src/main/pg/dashboard.h | 23 ++++++++++++++++ 7 files changed, 66 insertions(+), 26 deletions(-) create mode 100644 src/main/pg/dashboard.c create mode 100644 src/main/pg/dashboard.h diff --git a/make/source.mk b/make/source.mk index e0750cbe44..649c35742b 100644 --- a/make/source.mk +++ b/make/source.mk @@ -66,6 +66,7 @@ COMMON_SRC = \ pg/bus_i2c.c \ pg/bus_spi.c \ pg/camera_control.c \ + pg/dashboard.c \ pg/max7456.c \ pg/pg.c \ pg/rx_pwm.c \ diff --git a/src/main/drivers/display_ug2864hsweg01.c b/src/main/drivers/display_ug2864hsweg01.c index c157bfa662..454b657daa 100644 --- a/src/main/drivers/display_ug2864hsweg01.c +++ b/src/main/drivers/display_ug2864hsweg01.c @@ -28,14 +28,6 @@ #ifdef USE_I2C_OLED_DISPLAY -#if !defined(OLED_I2C_INSTANCE) -#if defined(I2C_DEVICE) -#define OLED_I2C_INSTANCE I2C_DEVICE -#else -#define OLED_I2C_INSTANCE I2C_NONE -#endif -#endif - #define INVERSE_CHAR_FORMAT 0x7f // 0b01111111 #define NORMAL_CHAR_FORMAT 0x00 // 0b00000000 diff --git a/src/main/interface/settings.c b/src/main/interface/settings.c index 197a1dd8bf..605712ebe4 100644 --- a/src/main/interface/settings.c +++ b/src/main/interface/settings.c @@ -64,6 +64,7 @@ #include "pg/adc.h" #include "pg/beeper.h" #include "pg/beeper_dev.h" +#include "pg/dashboard.h" #include "pg/max7456.h" #include "pg/pg.h" #include "pg/pg_ids.h" diff --git a/src/main/io/dashboard.c b/src/main/io/dashboard.c index 07572023de..f968d64f11 100644 --- a/src/main/io/dashboard.c +++ b/src/main/io/dashboard.c @@ -46,6 +46,7 @@ #include "config/feature.h" #include "pg/pg.h" #include "pg/pg_ids.h" +#include "pg/dashboard.h" #include "fc/config.h" #include "fc/controlrate_profile.h" @@ -71,14 +72,6 @@ #include "sensors/gyro.h" #include "sensors/sensors.h" - -PG_REGISTER_WITH_RESET_TEMPLATE(dashboardConfig_t, dashboardConfig, PG_DASHBOARD_CONFIG, 0); - -PG_RESET_TEMPLATE(dashboardConfig_t, dashboardConfig, - .device = I2C_DEV_TO_CFG(DASHBOARD_I2C_INSTANCE), - .address = DASHBOARD_I2C_ADDRESS, -); - #define MICROSECONDS_IN_A_SECOND (1000 * 1000) #define DISPLAY_UPDATE_FREQUENCY (MICROSECONDS_IN_A_SECOND / 5) diff --git a/src/main/io/dashboard.h b/src/main/io/dashboard.h index 136939d21e..e1ef660c02 100644 --- a/src/main/io/dashboard.h +++ b/src/main/io/dashboard.h @@ -23,21 +23,16 @@ #define ENABLE_DEBUG_DASHBOARD_PAGE -#ifdef OLED_I2C_INSTANCE -#define DASHBOARD_I2C_INSTANCE OLED_I2C_INSTANCE +#if !defined(DASHBOARD_I2C_INSTANCE) +#if defined(I2C_DEVICE) +#define DASHBOARD_I2C_INSTANCE I2C_DEVICE #else -#define DASHBOARD_I2C_INSTANCE I2CDEV_1 +#define DASHBOARD_I2C_INSTANCE I2C_NONE +#endif #endif #define DASHBOARD_I2C_ADDRESS 0x3C // OLED at address 0x3C in 7bit -typedef struct dashboardConfig_s { - I2CDevice device; - uint8_t address; -} dashboardConfig_t; - -PG_DECLARE(dashboardConfig_t, dashboardConfig); - typedef enum { PAGE_WELCOME, PAGE_ARMED, diff --git a/src/main/pg/dashboard.c b/src/main/pg/dashboard.c new file mode 100644 index 0000000000..8b63ad4d7d --- /dev/null +++ b/src/main/pg/dashboard.c @@ -0,0 +1,35 @@ +/* + * This file is part of Cleanflight. + * + * Cleanflight is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Cleanflight is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Cleanflight. If not, see . + */ + +#include "platform.h" + +#ifdef USE_DASHBOARD + +#include "pg/pg.h" +#include "pg/pg_ids.h" + +#include "io/dashboard.h" + +#include "dashboard.h" + +PG_REGISTER_WITH_RESET_TEMPLATE(dashboardConfig_t, dashboardConfig, PG_DASHBOARD_CONFIG, 0); + +PG_RESET_TEMPLATE(dashboardConfig_t, dashboardConfig, + .device = I2C_DEV_TO_CFG(DASHBOARD_I2C_INSTANCE), + .address = DASHBOARD_I2C_ADDRESS, +); +#endif diff --git a/src/main/pg/dashboard.h b/src/main/pg/dashboard.h new file mode 100644 index 0000000000..0d3e8c49ef --- /dev/null +++ b/src/main/pg/dashboard.h @@ -0,0 +1,23 @@ +/* + * This file is part of Cleanflight. + * + * Cleanflight is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Cleanflight is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Cleanflight. If not, see . + */ + +typedef struct dashboardConfig_s { + I2CDevice device; + uint8_t address; +} dashboardConfig_t; + +PG_DECLARE(dashboardConfig_t, dashboardConfig);