Browse Source

Move hardware code in main file to its own module

i18n
Xose Pérez 6 years ago
parent
commit
b605cd43cd
3 changed files with 48 additions and 41 deletions
  1. +1
    -0
      code/espurna/debug.ino
  2. +0
    -41
      code/espurna/espurna.ino
  3. +47
    -0
      code/espurna/hardware.ino

+ 1
- 0
code/espurna/debug.ino View File

@ -10,6 +10,7 @@ Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
#include <stdio.h>
#include <stdarg.h>
#include <EEPROM.h>
extern "C" {
#include "user_interface.h"


+ 0
- 41
code/espurna/espurna.ino View File

@ -20,52 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config/all.h"
#include <EEPROM.h>
// -----------------------------------------------------------------------------
// METHODS
// -----------------------------------------------------------------------------
unsigned long _loopDelay = 0;
void hardwareSetup() {
EEPROM.begin(EEPROM_SIZE);
#if DEBUG_SERIAL_SUPPORT
DEBUG_PORT.begin(SERIAL_BAUDRATE);
#if DEBUG_ESP_WIFI
DEBUG_PORT.setDebugOutput(true);
#endif
#elif defined(SERIAL_BAUDRATE)
Serial.begin(SERIAL_BAUDRATE);
#endif
#if SPIFFS_SUPPORT
SPIFFS.begin();
#endif
#if defined(ESPLIVE)
//The ESPLive has an ADC MUX which needs to be configured.
pinMode(16, OUTPUT);
digitalWrite(16, HIGH); //Defualt CT input (pin B, solder jumper B)
#endif
}
void hardwareLoop() {
// Heartbeat
#if HEARTBEAT_ENABLED
static unsigned long last = 0;
if ((last == 0) || (millis() - last > HEARTBEAT_INTERVAL)) {
last = millis();
heartbeat();
}
#endif // HEARTBEAT_ENABLED
}
// -----------------------------------------------------------------------------
// BOOTING
// -----------------------------------------------------------------------------


+ 47
- 0
code/espurna/hardware.ino View File

@ -0,0 +1,47 @@
/*
HARDWARE MODULE
Copyright (C) 2018 by Xose Pérez <xose dot perez at gmail dot com>
*/
#include <EEPROM.h>
void hardwareSetup() {
EEPROM.begin(EEPROM_SIZE);
#if DEBUG_SERIAL_SUPPORT
DEBUG_PORT.begin(SERIAL_BAUDRATE);
#if DEBUG_ESP_WIFI
DEBUG_PORT.setDebugOutput(true);
#endif
#elif defined(SERIAL_BAUDRATE)
Serial.begin(SERIAL_BAUDRATE);
#endif
#if SPIFFS_SUPPORT
SPIFFS.begin();
#endif
#if defined(ESPLIVE)
//The ESPLive has an ADC MUX which needs to be configured.
pinMode(16, OUTPUT);
digitalWrite(16, HIGH); //Defualt CT input (pin B, solder jumper B)
#endif
}
void hardwareLoop() {
// Heartbeat
#if HEARTBEAT_ENABLED
static unsigned long last = 0;
if ((last == 0) || (millis() - last > HEARTBEAT_INTERVAL)) {
last = millis();
heartbeat();
}
#endif // HEARTBEAT_ENABLED
}

Loading…
Cancel
Save