move wifi and sd init functions to cpp file
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
#include <IRremote.hpp>
|
#include <IRremote.hpp>
|
||||||
#include "secrets.h"
|
#include "secrets.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
#include "initfunctions.h"
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
|
|
||||||
@@ -144,7 +145,6 @@ bool wasNumber = false;
|
|||||||
|
|
||||||
// Create AsyncWebServer object on port 80
|
// Create AsyncWebServer object on port 80
|
||||||
AsyncWebServer server(80);
|
AsyncWebServer server(80);
|
||||||
// WiFiServer server(80);
|
|
||||||
|
|
||||||
const char *PARAM_MESSAGE = "message";
|
const char *PARAM_MESSAGE = "message";
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ void notFound(AsyncWebServerRequest *request)
|
|||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
//-------------- SD-Card Functions ---------------
|
//-------------- SD-Card Functions ---------------
|
||||||
void initSDCard()
|
/* void initSDCard()
|
||||||
{
|
{
|
||||||
if (!SD.begin())
|
if (!SD.begin())
|
||||||
{
|
{
|
||||||
@@ -188,9 +188,9 @@ void initSDCard()
|
|||||||
}
|
}
|
||||||
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
|
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||||
Serial.printf("SD Card Size: %lluMB\n", cardSize);
|
Serial.printf("SD Card Size: %lluMB\n", cardSize);
|
||||||
}
|
} */
|
||||||
|
|
||||||
void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
|
/* void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
|
||||||
{
|
{
|
||||||
Serial.printf("Listing directory: %s\n", dirname);
|
Serial.printf("Listing directory: %s\n", dirname);
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
|
|||||||
}
|
}
|
||||||
file = root.openNextFile();
|
file = root.openNextFile();
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
//--------------- IR Functions -------------------
|
//--------------- IR Functions -------------------
|
||||||
@@ -342,7 +342,7 @@ void nameAllTracks(String message)
|
|||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
//------------- Webserver Functions --------------
|
//------------- Webserver Functions --------------
|
||||||
|
|
||||||
void initWiFi()
|
/* void initWiFi()
|
||||||
{
|
{
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.begin(SSID, PASSWORD);
|
WiFi.begin(SSID, PASSWORD);
|
||||||
@@ -353,7 +353,7 @@ void initWiFi()
|
|||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
}
|
} */
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
//-------------------- Setup ---------------------
|
//-------------------- Setup ---------------------
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
#include "initfunctions.h"
|
||||||
|
|
||||||
|
//------------------------------------------------
|
||||||
|
//-------------- SD-Card Functions ---------------
|
||||||
|
void initSDCard()
|
||||||
|
{
|
||||||
|
if (!SD.begin())
|
||||||
|
{
|
||||||
|
Serial.println("Card Mount Failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint8_t cardType = SD.cardType();
|
||||||
|
|
||||||
|
if (cardType == CARD_NONE)
|
||||||
|
{
|
||||||
|
Serial.println("No SD card attached");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Serial.print("SD Card Type: ");
|
||||||
|
if (cardType == CARD_MMC)
|
||||||
|
{
|
||||||
|
Serial.println("MMC");
|
||||||
|
}
|
||||||
|
else if (cardType == CARD_SD)
|
||||||
|
{
|
||||||
|
Serial.println("SDSC");
|
||||||
|
}
|
||||||
|
else if (cardType == CARD_SDHC)
|
||||||
|
{
|
||||||
|
Serial.println("SDHC");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println("UNKNOWN");
|
||||||
|
}
|
||||||
|
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||||
|
Serial.printf("SD Card Size: %lluMB\n", cardSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------
|
||||||
|
//--------------- IR Functions -------------------
|
||||||
|
/* void initIR()
|
||||||
|
{
|
||||||
|
IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN); // Specify send pin and enable feedback LED at default feedback LED pin
|
||||||
|
Serial.println();
|
||||||
|
Serial.print(F("Send IR signals at pin "));
|
||||||
|
Serial.println(IR_SEND_PIN);
|
||||||
|
} */
|
||||||
|
|
||||||
|
//------------------------------------------------
|
||||||
|
//------------- Webserver Functions --------------
|
||||||
|
void initWiFi()
|
||||||
|
{
|
||||||
|
WiFi.mode(WIFI_STA);
|
||||||
|
WiFi.begin(SSID, PASSWORD);
|
||||||
|
Serial.print("Connecting to WiFi ..");
|
||||||
|
while (WiFi.status() != WL_CONNECTED)
|
||||||
|
{
|
||||||
|
Serial.print('.');
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef INITFUNCTIONS_H
|
||||||
|
#define INITFUNCTIONS_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <WiFi.h>
|
||||||
|
#include "FS.h"
|
||||||
|
#include "SD.h"
|
||||||
|
#include "SPI.h"
|
||||||
|
//#include <IRremote.hpp>
|
||||||
|
#include "defines.h"
|
||||||
|
#include "secrets.h"
|
||||||
|
|
||||||
|
void initSDCard();
|
||||||
|
//void initIR();
|
||||||
|
void initWiFi();
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user