Browse Source

Platformio *.ino preprocessor does not find function names not starting in the first row of a line

fastled
Xose Pérez 8 years ago
parent
commit
7b0fbfd898
2 changed files with 138 additions and 138 deletions
  1. +57
    -57
      code/src/nofuss.ino
  2. +81
    -81
      code/src/rf.ino

+ 57
- 57
code/src/nofuss.ino View File

@ -9,81 +9,81 @@ Copyright (C) 2016 by Xose Pérez <xose dot perez at gmail dot com>
#if ENABLE_NOFUSS #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 #endif

+ 81
- 81
code/src/rf.ino View File

@ -9,86 +9,86 @@ Copyright (C) 2016 by Xose Pérez <xose dot perez at gmail dot com>
#if ENABLE_RF #if ENABLE_RF
#include <RemoteReceiver.h>
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 <RemoteReceiver.h>
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 #endif

Loading…
Cancel
Save