From 7b0fbfd8983d933336fc3b004c9b0246b42edbae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 21 Oct 2016 06:12:00 +0200 Subject: [PATCH] Platformio *.ino preprocessor does not find function names not starting in the first row of a line --- code/src/nofuss.ino | 114 +++++++++++++++---------------- code/src/rf.ino | 162 ++++++++++++++++++++++---------------------- 2 files changed, 138 insertions(+), 138 deletions(-) diff --git a/code/src/nofuss.ino b/code/src/nofuss.ino index 02aa67b9..31c4ac97 100644 --- a/code/src/nofuss.ino +++ b/code/src/nofuss.ino @@ -9,81 +9,81 @@ Copyright (C) 2016 by Xose Pérez #if ENABLE_NOFUSS - #include "NoFUSSClient.h" +#include "NoFUSSClient.h" - // ----------------------------------------------------------------------------- - // NOFUSS - // ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// NOFUSS +// ----------------------------------------------------------------------------- - void nofussSetup() { +void nofussSetup() { - NoFUSSClient.setServer(getSetting("nofussServer", NOFUSS_SERVER)); - NoFUSSClient.setDevice(DEVICE); - NoFUSSClient.setVersion(APP_VERSION); +NoFUSSClient.setServer(getSetting("nofussServer", NOFUSS_SERVER)); +NoFUSSClient.setDevice(DEVICE); +NoFUSSClient.setVersion(APP_VERSION); - NoFUSSClient.onMessage([](nofuss_t code) { +NoFUSSClient.onMessage([](nofuss_t code) { - if (code == NOFUSS_START) { - Serial.println(F("[NoFUSS] Start")); - } + if (code == NOFUSS_START) { + Serial.println(F("[NoFUSS] Start")); + } - if (code == NOFUSS_UPTODATE) { - Serial.println(F("[NoFUSS] Already in the last version")); - } + if (code == NOFUSS_UPTODATE) { + Serial.println(F("[NoFUSS] Already in the last version")); + } - if (code == NOFUSS_PARSE_ERROR) { - Serial.println(F("[NoFUSS] Error parsing server response")); - } + if (code == NOFUSS_PARSE_ERROR) { + Serial.println(F("[NoFUSS] Error parsing server response")); + } - if (code == NOFUSS_UPDATING) { - Serial.println(F("[NoFUSS] Updating")); - Serial.print( F(" New version: ")); - Serial.println(NoFUSSClient.getNewVersion()); - Serial.print( F(" Firmware: ")); - Serial.println(NoFUSSClient.getNewFirmware()); - Serial.print( F(" File System: ")); - Serial.println(NoFUSSClient.getNewFileSystem()); - } + if (code == NOFUSS_UPDATING) { + Serial.println(F("[NoFUSS] Updating")); + Serial.print( F(" New version: ")); + Serial.println(NoFUSSClient.getNewVersion()); + Serial.print( F(" Firmware: ")); + Serial.println(NoFUSSClient.getNewFirmware()); + Serial.print( F(" File System: ")); + Serial.println(NoFUSSClient.getNewFileSystem()); + } - if (code == NOFUSS_FILESYSTEM_UPDATE_ERROR) { - Serial.print(F("[NoFUSS] File System Update Error: ")); - Serial.println(NoFUSSClient.getErrorString()); - } + if (code == NOFUSS_FILESYSTEM_UPDATE_ERROR) { + Serial.print(F("[NoFUSS] File System Update Error: ")); + Serial.println(NoFUSSClient.getErrorString()); + } - if (code == NOFUSS_FILESYSTEM_UPDATED) { - Serial.println(F("[NoFUSS] File System Updated")); - } + if (code == NOFUSS_FILESYSTEM_UPDATED) { + Serial.println(F("[NoFUSS] File System Updated")); + } - if (code == NOFUSS_FIRMWARE_UPDATE_ERROR) { - Serial.print(F("[NoFUSS] Firmware Update Error: ")); - Serial.println(NoFUSSClient.getErrorString()); - } + if (code == NOFUSS_FIRMWARE_UPDATE_ERROR) { + Serial.print(F("[NoFUSS] Firmware Update Error: ")); + Serial.println(NoFUSSClient.getErrorString()); + } - if (code == NOFUSS_FIRMWARE_UPDATED) { - Serial.println(F("[NoFUSS] Firmware Updated")); - } + if (code == NOFUSS_FIRMWARE_UPDATED) { + Serial.println(F("[NoFUSS] Firmware Updated")); + } - if (code == NOFUSS_RESET) { - Serial.println(F("[NoFUSS] Resetting board")); - } + if (code == NOFUSS_RESET) { + Serial.println(F("[NoFUSS] Resetting board")); + } - if (code == NOFUSS_END) { - Serial.println(F("[NoFUSS] End")); - } + if (code == NOFUSS_END) { + Serial.println(F("[NoFUSS] End")); + } - }); +}); - } +} - void nofussLoop() { +void nofussLoop() { - static unsigned long last_check = 0; - if (!wifiConnected()) return; - unsigned long interval = getSetting("nofussInterval", String(NOFUSS_INTERVAL)).toInt(); - if ((last_check > 0) && ((millis() - last_check) < interval)) return; - last_check = millis(); - NoFUSSClient.handle(); +static unsigned long last_check = 0; +if (!wifiConnected()) return; +unsigned long interval = getSetting("nofussInterval", String(NOFUSS_INTERVAL)).toInt(); +if ((last_check > 0) && ((millis() - last_check) < interval)) return; +last_check = millis(); +NoFUSSClient.handle(); - } +} #endif diff --git a/code/src/rf.ino b/code/src/rf.ino index 569e8bb4..f28907dc 100644 --- a/code/src/rf.ino +++ b/code/src/rf.ino @@ -9,86 +9,86 @@ Copyright (C) 2016 by Xose Pérez #if ENABLE_RF - #include - - unsigned long rfCode = 0; - unsigned long rfCodeON = 0; - unsigned long rfCodeOFF = 0; - - // ----------------------------------------------------------------------------- - // RF - // ----------------------------------------------------------------------------- - - void rfLoop() { - return; - if (rfCode == 0) return; - DEBUG_MSG("[RF] Received code: %lu\n", rfCode); - if (rfCode == rfCodeON) switchRelayOn(); - if (rfCode == rfCodeOFF) switchRelayOff(); - rfCode = 0; - } - - void rfBuildCodes() { - - unsigned long code = 0; - - // channel - unsigned int channel = getSetting("rfChannel", String(RF_CHANNEL)).toInt(); - for (byte i = 0; i < 5; i++) { - code *= 3; - if (channel & 1) code += 1; - channel >>= 1; - } - - // device - unsigned int device = getSetting("rfDevice", String(RF_DEVICE)).toInt(); - for (byte i = 0; i < 5; i++) { - code *= 3; - if (device != i) code += 2; - } - - // status - code *= 9; - rfCodeOFF = code + 2; - rfCodeON = code + 6; - - DEBUG_MSG("[RF] Code ON : %lu\n", rfCodeON); - DEBUG_MSG("[RF] Code OFF: %lu\n", rfCodeOFF); - - } - - void rfCallback(unsigned long code, unsigned int period) { - rfCode = code; - } - - void rfSetup() { - - pinMode(RF_PIN, INPUT_PULLUP); - rfBuildCodes(); - RemoteReceiver::init(RF_PIN, 3, rfCallback); - RemoteReceiver::disable(); - DEBUG_MSG("[RF] Disabled\n"); - - static WiFiEventHandler e1 = WiFi.onStationModeDisconnected([](const WiFiEventStationModeDisconnected& event) { - RemoteReceiver::disable(); - DEBUG_MSG("[RF] Disabled\n"); - }); - - static WiFiEventHandler e2 = WiFi.onSoftAPModeStationDisconnected([](const WiFiEventSoftAPModeStationDisconnected& event) { - RemoteReceiver::disable(); - DEBUG_MSG("[RF] Disabled\n"); - }); - - static WiFiEventHandler e3 = WiFi.onStationModeConnected([](const WiFiEventStationModeConnected& event) { - RemoteReceiver::enable(); - DEBUG_MSG("[RF] Enabled\n"); - }); - - static WiFiEventHandler e4 = WiFi.onSoftAPModeStationConnected([](const WiFiEventSoftAPModeStationConnected& event) { - RemoteReceiver::enable(); - DEBUG_MSG("[RF] Enabled\n"); - }); - - } +#include + +unsigned long rfCode = 0; +unsigned long rfCodeON = 0; +unsigned long rfCodeOFF = 0; + +// ----------------------------------------------------------------------------- +// RF +// ----------------------------------------------------------------------------- + +void rfLoop() { +return; +if (rfCode == 0) return; +DEBUG_MSG("[RF] Received code: %lu\n", rfCode); +if (rfCode == rfCodeON) switchRelayOn(); +if (rfCode == rfCodeOFF) switchRelayOff(); +rfCode = 0; +} + +void rfBuildCodes() { + +unsigned long code = 0; + +// channel +unsigned int channel = getSetting("rfChannel", String(RF_CHANNEL)).toInt(); +for (byte i = 0; i < 5; i++) { + code *= 3; + if (channel & 1) code += 1; + channel >>= 1; +} + +// device +unsigned int device = getSetting("rfDevice", String(RF_DEVICE)).toInt(); +for (byte i = 0; i < 5; i++) { + code *= 3; + if (device != i) code += 2; +} + +// status +code *= 9; +rfCodeOFF = code + 2; +rfCodeON = code + 6; + +DEBUG_MSG("[RF] Code ON : %lu\n", rfCodeON); +DEBUG_MSG("[RF] Code OFF: %lu\n", rfCodeOFF); + +} + +void rfCallback(unsigned long code, unsigned int period) { +rfCode = code; +} + +void rfSetup() { + +pinMode(RF_PIN, INPUT_PULLUP); +rfBuildCodes(); +RemoteReceiver::init(RF_PIN, 3, rfCallback); +RemoteReceiver::disable(); +DEBUG_MSG("[RF] Disabled\n"); + +static WiFiEventHandler e1 = WiFi.onStationModeDisconnected([](const WiFiEventStationModeDisconnected& event) { + RemoteReceiver::disable(); + DEBUG_MSG("[RF] Disabled\n"); +}); + +static WiFiEventHandler e2 = WiFi.onSoftAPModeStationDisconnected([](const WiFiEventSoftAPModeStationDisconnected& event) { + RemoteReceiver::disable(); + DEBUG_MSG("[RF] Disabled\n"); + }); + +static WiFiEventHandler e3 = WiFi.onStationModeConnected([](const WiFiEventStationModeConnected& event) { + RemoteReceiver::enable(); + DEBUG_MSG("[RF] Enabled\n"); +}); + +static WiFiEventHandler e4 = WiFi.onSoftAPModeStationConnected([](const WiFiEventSoftAPModeStationConnected& event) { + RemoteReceiver::enable(); + DEBUG_MSG("[RF] Enabled\n"); +}); + +} #endif