Commit 9fe899db authored by Eric Duminil's avatar Eric Duminil
Browse files

Merge branch 'refactor/src_folder' into develop

parents e48ddf50 79e8d26b
...@@ -38,16 +38,6 @@ namespace ntp { ...@@ -38,16 +38,6 @@ namespace ntp {
} }
} }
void resetAmpel() {
Serial.print(F("Resetting"));
#ifdef AMPEL_CSV
FS_LIB.end();
#endif
LedEffects::LEDsOff();
delay(1000);
ESP.restart();
}
uint32_t max_loop_duration = 0; uint32_t max_loop_duration = 0;
//FIXME: Remove every instance of Strings, to avoid heap fragmentation problems. (Start: "Free heap space : 17104 bytes") //FIXME: Remove every instance of Strings, to avoid heap fragmentation problems. (Start: "Free heap space : 17104 bytes")
......
...@@ -2,19 +2,17 @@ ...@@ -2,19 +2,17 @@
#define AMPEL_UTIL_H_INCLUDED #define AMPEL_UTIL_H_INCLUDED
#include <Arduino.h> #include <Arduino.h>
#include "config.h" #include "config.h"
#include "wifi_util.h" // To get MAC
#ifdef AMPEL_CSV
# include "csv_writer.h" // To close filesystem before reset
#endif
#include <WiFiUdp.h> //required for NTP #include <WiFiUdp.h> // required for NTP
#include "src/lib/NTPClient-master/NTPClient.h" // NTP #include "src/lib/NTPClient-master/NTPClient.h" // NTP
#if defined(ESP8266) #if defined(ESP8266)
# define BOARD "ESP8266" # define BOARD "ESP8266"
# include <ESP8266WiFi.h> // required to get MAC address
# define get_free_heap_size() system_get_free_heap_size() # define get_free_heap_size() system_get_free_heap_size()
#elif defined(ESP32) #elif defined(ESP32)
# define BOARD "ESP32" # define BOARD "ESP32"
# include <WiFi.h> // required to get MAC address
# define get_free_heap_size() esp_get_free_heap_size() # define get_free_heap_size() esp_get_free_heap_size()
#else #else
# define BOARD "Unknown" # define BOARD "Unknown"
...@@ -42,6 +40,4 @@ namespace util { ...@@ -42,6 +40,4 @@ namespace util {
extern uint32_t max_loop_duration; extern uint32_t max_loop_duration;
const extern String SENSOR_ID; const extern String SENSOR_ID;
void resetAmpel();
#endif #endif
...@@ -16,7 +16,7 @@ namespace config { ...@@ -16,7 +16,7 @@ namespace config {
void WiFiConnect(const String &hostname) { void WiFiConnect(const String &hostname) {
//NOTE: WiFi Multi could allow multiple SSID and passwords. //NOTE: WiFi Multi could allow multiple SSID and passwords.
WiFi.persistent(false); // Don't write user & password to Flash. WiFi.persistent(false); // Don't write user & password to Flash.
WiFi.mode(WIFI_STA); // Set ESP8266 to be a WiFi-client only WiFi.mode(WIFI_STA); // Set ESP to be a WiFi-client only
#if defined(ESP8266) #if defined(ESP8266)
WiFi.hostname(hostname); WiFi.hostname(hostname);
#elif defined(ESP32) #elif defined(ESP32)
...@@ -29,16 +29,16 @@ void WiFiConnect(const String &hostname) { ...@@ -29,16 +29,16 @@ void WiFiConnect(const String &hostname) {
// Wait for connection, at most wifi_timeout seconds // Wait for connection, at most wifi_timeout seconds
for (int i = 0; i <= config::wifi_timeout && (WiFi.status() != WL_CONNECTED); i++) { for (int i = 0; i <= config::wifi_timeout && (WiFi.status() != WL_CONNECTED); i++) {
LedEffects::showRainbowWheel(); led_effects::showRainbowWheel();
Serial.print("."); Serial.print(".");
} }
if (WiFi.status() == WL_CONNECTED) { if (WiFi.status() == WL_CONNECTED) {
LedEffects::showKITTWheel(color::green); led_effects::showKITTWheel(color::green);
Serial.println(); Serial.println();
Serial.print("\nWiFi connected, IP address: "); Serial.print("\nWiFi connected, IP address: ");
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
} else { } else {
LedEffects::showKITTWheel(color::red); led_effects::showKITTWheel(color::red);
Serial.println("\nConnection to WiFi failed"); Serial.println("\nConnection to WiFi failed");
} }
} }
#ifndef WIFI_UTIL_H_INCLUDED #ifndef WIFI_UTIL_H_INCLUDED
# define WIFI_UTIL_H_INCLUDED #define WIFI_UTIL_H_INCLUDED
# if defined(ESP8266)
# include <ESP8266WiFi.h>
# elif defined(ESP32)
# include <WiFi.h>
# endif
#include "led_effects.h"
#include "config.h" #include "config.h"
#include "util.h"
#include "led_effects.h"
void WiFiConnect(const String &hostname); void WiFiConnect(const String &hostname);
#endif #endif
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
; http://docs.platformio.org/page/projectconf.html ; http://docs.platformio.org/page/projectconf.html
[platformio] [platformio]
src_dir = ./ src_dir = ampel-firmware
[env:esp8266] [env:esp8266]
platform = espressif8266 platform = espressif8266
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment