Browse Source

Make compilation more flexible (#1816)

* Make compilation more flexible allowing to define in custom.h your own variation to devices and define four wifi networks

* Implement suggestion from Max Prokhorov, it's simpler and cleaner

* Change a #elif by #else

* Move ESPurna Core comment
master
Rui Caridade 5 years ago
committed by Max Prokhorov
parent
commit
3bb5cc879f
3 changed files with 105 additions and 31 deletions
  1. +48
    -0
      code/espurna/config/general.h
  2. +35
    -30
      code/espurna/config/hardware.h
  3. +22
    -1
      code/espurna/wifi.ino

+ 48
- 0
code/espurna/config/general.h View File

@ -489,6 +489,54 @@
#define WIFI2_DNS "" #define WIFI2_DNS ""
#endif #endif
#ifndef WIFI3_SSID
#define WIFI3_SSID ""
#endif
#ifndef WIFI3_PASS
#define WIFI3_PASS ""
#endif
#ifndef WIFI3_IP
#define WIFI3_IP ""
#endif
#ifndef WIFI3_GW
#define WIFI3_GW ""
#endif
#ifndef WIFI3_MASK
#define WIFI3_MASK ""
#endif
#ifndef WIFI3_DNS
#define WIFI3_DNS ""
#endif
#ifndef WIFI4_SSID
#define WIFI4_SSID ""
#endif
#ifndef WIFI4_PASS
#define WIFI4_PASS ""
#endif
#ifndef WIFI4_IP
#define WIFI4_IP ""
#endif
#ifndef WIFI4_GW
#define WIFI4_GW ""
#endif
#ifndef WIFI4_MASK
#define WIFI4_MASK ""
#endif
#ifndef WIFI4_DNS
#define WIFI4_DNS ""
#endif
#ifndef WIFI_RSSI_1M #ifndef WIFI_RSSI_1M
#define WIFI_RSSI_1M -30 // Calibrate it with your router reading the RSSI at 1m #define WIFI_RSSI_1M -30 // Calibrate it with your router reading the RSSI at 1m
#endif #endif


+ 35
- 30
code/espurna/config/hardware.h View File

@ -20,11 +20,19 @@
// //
// Besides, other hardware specific information should be stated here // Besides, other hardware specific information should be stated here
// -----------------------------------------------------------------------------
// Custom hardware
// -----------------------------------------------------------------------------
#if defined(MANUFACTURER) and defined(DEVICE)
// user has defined custom hardware, no need to check anything else
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ESPurna Core // ESPurna Core
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#if defined(ESPURNA_CORE)
#elif defined(ESPURNA_CORE)
// This is a special device targeted to generate a light-weight binary image // This is a special device targeted to generate a light-weight binary image
// meant to be able to do two-step-updates: // meant to be able to do two-step-updates:
@ -3326,7 +3334,7 @@
// Relays // Relays
#define RELAY1_PIN 15 #define RELAY1_PIN 15
#define RELAY1_TYPE RELAY_TYPE_NORMAL #define RELAY1_TYPE RELAY_TYPE_NORMAL
// Light RGBW // Light RGBW
#define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
#define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER
@ -3491,20 +3499,20 @@
#elif defined(TECKIN_SP20) #elif defined(TECKIN_SP20)
// Info
// Info
#define MANUFACTURER "TECKIN" #define MANUFACTURER "TECKIN"
#define DEVICE "SP20" #define DEVICE "SP20"
// Buttons
// Buttons
#define BUTTON1_PIN 13 #define BUTTON1_PIN 13
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1 #define BUTTON1_RELAY 1
// Relays
// Relays
#define RELAY1_PIN 4 #define RELAY1_PIN 4
#define RELAY1_TYPE RELAY_TYPE_NORMAL #define RELAY1_TYPE RELAY_TYPE_NORMAL
// LEDs
// LEDs
#define LED1_PIN 2 #define LED1_PIN 2
#define LED1_PIN_INVERSE 1 #define LED1_PIN_INVERSE 1
#define LED2_PIN 0 #define LED2_PIN 0
@ -3512,7 +3520,7 @@
#define LED2_MODE LED_MODE_FINDME #define LED2_MODE LED_MODE_FINDME
#define LED2_RELAY 0 #define LED2_RELAY 0
// HJL01 / BL0937
// HJL01 / BL0937
#ifndef HLW8012_SUPPORT #ifndef HLW8012_SUPPORT
#define HLW8012_SUPPORT 1 #define HLW8012_SUPPORT 1
#endif #endif
@ -3520,7 +3528,7 @@
#define HLW8012_CF1_PIN 14 #define HLW8012_CF1_PIN 14
#define HLW8012_CF_PIN 5 #define HLW8012_CF_PIN 5
#define HLW8012_SEL_CURRENT LOW
#define HLW8012_SEL_CURRENT LOW
#define HLW8012_CURRENT_RATIO 25740 #define HLW8012_CURRENT_RATIO 25740
#define HLW8012_VOLTAGE_RATIO 313400 #define HLW8012_VOLTAGE_RATIO 313400
#define HLW8012_POWER_RATIO 3414290 #define HLW8012_POWER_RATIO 3414290
@ -3559,32 +3567,32 @@
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#elif defined(PSH_WIFI_PLUG) #elif defined(PSH_WIFI_PLUG)
// Info // Info
#define MANUFACTURER "PSH" #define MANUFACTURER "PSH"
#define DEVICE "WIFI_PLUG" #define DEVICE "WIFI_PLUG"
// Relays // Relays
#define RELAY1_PIN 2 #define RELAY1_PIN 2
#define RELAY1_TYPE RELAY_TYPE_NORMAL #define RELAY1_TYPE RELAY_TYPE_NORMAL
// LEDs // LEDs
#define LED1_PIN 0 #define LED1_PIN 0
#define LED1_PIN_INVERSE 0 #define LED1_PIN_INVERSE 0
#elif defined(PSH_RGBW_CONTROLLER) #elif defined(PSH_RGBW_CONTROLLER)
// Info // Info
#define MANUFACTURER "PSH" #define MANUFACTURER "PSH"
#define DEVICE "RGBW_CONTROLLER" #define DEVICE "RGBW_CONTROLLER"
#define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
#define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER
#define DUMMY_RELAY_COUNT 1 #define DUMMY_RELAY_COUNT 1
// LEDs // LEDs
#define LED1_PIN 13 #define LED1_PIN 13
#define LED1_PIN_INVERSE 1 #define LED1_PIN_INVERSE 1
// Light // Light
#define LIGHT_CHANNELS 4 #define LIGHT_CHANNELS 4
#define LIGHT_CH1_PIN 5 // RED #define LIGHT_CH1_PIN 5 // RED
@ -3595,9 +3603,9 @@
#define LIGHT_CH2_INVERSE 0 #define LIGHT_CH2_INVERSE 0
#define LIGHT_CH3_INVERSE 0 #define LIGHT_CH3_INVERSE 0
#define LIGHT_CH4_INVERSE 0 #define LIGHT_CH4_INVERSE 0
#elif defined(PSH_WIFI_SENSOR) #elif defined(PSH_WIFI_SENSOR)
// Info // Info
#define MANUFACTURER "PSH" #define MANUFACTURER "PSH"
#define DEVICE "WIFI_SENSOR" #define DEVICE "WIFI_SENSOR"
@ -3726,13 +3734,13 @@
#define MICS2710_SUPPORT 1 #define MICS2710_SUPPORT 1
#define MICS5525_SUPPORT 1 #define MICS5525_SUPPORT 1
// MAX6675 14 11 10
#ifndef MAX6675_SUPPORT
#define MAX6675_SUPPORT 1
#endif
#define MAX6675_CS_PIN 14
#define MAX6675_SO_PIN 11
#define MAX6675_SCK_PIN 10
// MAX6675 14 11 10
#ifndef MAX6675_SUPPORT
#define MAX6675_SUPPORT 1
#endif
#define MAX6675_CS_PIN 14
#define MAX6675_SO_PIN 11
#define MAX6675_SCK_PIN 10
#elif defined(TRAVIS02) #elif defined(TRAVIS02)
@ -3848,12 +3856,9 @@
#define SSDP_SUPPORT 1 #define SSDP_SUPPORT 1
#define RF_SUPPORT 1 #define RF_SUPPORT 1
#endif
#else
// -----------------------------------------------------------------------------
// Check definitions
// -----------------------------------------------------------------------------
#if not defined(MANUFACTURER) || not defined(DEVICE)
#error "UNSUPPORTED HARDWARE!!" #error "UNSUPPORTED HARDWARE!!"
#endif #endif

+ 22
- 1
code/espurna/wifi.ino View File

@ -217,8 +217,29 @@ void _wifiInject() {
setSetting("mask", 1, WIFI2_MASK); setSetting("mask", 1, WIFI2_MASK);
setSetting("dns", 1, WIFI2_DNS); setSetting("dns", 1, WIFI2_DNS);
} }
}
if (strlen(WIFI3_SSID)) {
if (!hasSetting("ssid", 2)) {
setSetting("ssid", 2, WIFI3_SSID);
setSetting("pass", 2, WIFI3_PASS);
setSetting("ip", 2, WIFI3_IP);
setSetting("gw", 2, WIFI3_GW);
setSetting("mask", 2, WIFI3_MASK);
setSetting("dns", 2, WIFI3_DNS);
}
if (strlen(WIFI4_SSID)) {
if (!hasSetting("ssid", 3)) {
setSetting("ssid", 3, WIFI4_SSID);
setSetting("pass", 3, WIFI4_PASS);
setSetting("ip", 3, WIFI4_IP);
setSetting("gw", 3, WIFI4_GW);
setSetting("mask", 3, WIFI4_MASK);
setSetting("dns", 3, WIFI4_DNS);
}
}
}
}
} }
} }


Loading…
Cancel
Save