mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-11 21:31:02 +01:00
Wifi active
This commit is contained in:
parent
34474cbf5c
commit
b048879eaa
@ -59,6 +59,7 @@ void setup()
|
|||||||
// Responsibility 1: Start the usb connection for diagnostics
|
// Responsibility 1: Start the usb connection for diagnostics
|
||||||
// This is normally Serial but uses SerialUSB on a SAMD processor
|
// This is normally Serial but uses SerialUSB on a SAMD processor
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
Serial.setDebugOutput(true);
|
||||||
|
|
||||||
DIAG(F("License GPLv3 fsf.org (c) dcc-ex.com"));
|
DIAG(F("License GPLv3 fsf.org (c) dcc-ex.com"));
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ void setup()
|
|||||||
#if WIFI_ON
|
#if WIFI_ON
|
||||||
WifiInterface::setup(WIFI_SERIAL_LINK_SPEED, F(WIFI_SSID), F(WIFI_PASSWORD), F(WIFI_HOSTNAME), IP_PORT, WIFI_CHANNEL);
|
WifiInterface::setup(WIFI_SERIAL_LINK_SPEED, F(WIFI_SSID), F(WIFI_PASSWORD), F(WIFI_HOSTNAME), IP_PORT, WIFI_CHANNEL);
|
||||||
#endif // WIFI_ON
|
#endif // WIFI_ON
|
||||||
|
WifiESP::setup(WIFI_SSID, WIFI_PASSWORD, WIFI_HOSTNAME, 2560, 1);
|
||||||
#if ETHERNET_ON
|
#if ETHERNET_ON
|
||||||
EthernetInterface::setup();
|
EthernetInterface::setup();
|
||||||
#endif // ETHERNET_ON
|
#endif // ETHERNET_ON
|
||||||
@ -118,6 +119,7 @@ void loop()
|
|||||||
#if WIFI_ON
|
#if WIFI_ON
|
||||||
WifiInterface::loop();
|
WifiInterface::loop();
|
||||||
#endif
|
#endif
|
||||||
|
WifiESP::loop();
|
||||||
#if ETHERNET_ON
|
#if ETHERNET_ON
|
||||||
EthernetInterface::loop();
|
EthernetInterface::loop();
|
||||||
#endif
|
#endif
|
||||||
@ -134,11 +136,12 @@ void loop()
|
|||||||
|
|
||||||
// Report any decrease in memory (will automatically trigger on first call)
|
// Report any decrease in memory (will automatically trigger on first call)
|
||||||
static int ramLowWatermark = __INT_MAX__; // replaced on first loop
|
static int ramLowWatermark = __INT_MAX__; // replaced on first loop
|
||||||
|
/*
|
||||||
int freeNow = minimumFreeMemory();
|
int freeNow = minimumFreeMemory();
|
||||||
if (freeNow < ramLowWatermark)
|
if (freeNow < ramLowWatermark)
|
||||||
{
|
{
|
||||||
ramLowWatermark = freeNow;
|
ramLowWatermark = freeNow;
|
||||||
LCD(2,F("Free RAM=%5db"), ramLowWatermark);
|
LCD(2,F("Free RAM=%5db"), ramLowWatermark);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
1
DCCEX.h
1
DCCEX.h
@ -31,6 +31,7 @@
|
|||||||
#include "DCCEXParser.h"
|
#include "DCCEXParser.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "WifiInterface.h"
|
#include "WifiInterface.h"
|
||||||
|
#include "WifiESP.h"
|
||||||
#if ETHERNET_ON == true
|
#if ETHERNET_ON == true
|
||||||
#include "EthernetInterface.h"
|
#include "EthernetInterface.h"
|
||||||
#endif
|
#endif
|
||||||
|
12
DCCTimer.cpp
12
DCCTimer.cpp
@ -150,16 +150,24 @@ void DCCTimer::read(uint8_t word, uint8_t *mac, uint8_t offset) {
|
|||||||
// ESP8266 !!!!!!!!!!!!!!!!!!!!!
|
// ESP8266 !!!!!!!!!!!!!!!!!!!!!
|
||||||
void DCCTimer::begin(INTERRUPT_CALLBACK callback) {
|
void DCCTimer::begin(INTERRUPT_CALLBACK callback) {
|
||||||
interruptHandler=callback;
|
interruptHandler=callback;
|
||||||
|
timer1_disable();
|
||||||
|
// ETS_FRC_TIMER1_INTR_ATTACH(NULL, NULL);
|
||||||
|
// ETS_FRC_TIMER1_NMI_INTR_ATTACH(interruptHandler);
|
||||||
|
timer1_attachInterrupt(interruptHandler);
|
||||||
|
timer1_enable(TIM_DIV1, TIM_EDGE, TIM_LOOP);
|
||||||
|
timer1_write(CLOCK_CYCLES);
|
||||||
|
/*
|
||||||
noInterrupts();
|
noInterrupts();
|
||||||
timer1_attachInterrupt(interruptHandler);
|
timer1_attachInterrupt(interruptHandler);
|
||||||
timer1_write(CLOCK_CYCLES);
|
timer1_write(CLOCK_CYCLES);
|
||||||
timer1_enable(TIM_DIV1, TIM_EDGE, TIM_LOOP);
|
timer1_enable(TIM_DIV1, TIM_EDGE, TIM_LOOP);
|
||||||
interrupts();
|
interrupts();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
bool DCCTimer::isPWMPin(byte pin) {
|
IRAM_ATTR bool DCCTimer::isPWMPin(byte pin) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void DCCTimer::setPWM(byte pin, bool high) {
|
void ICACHE_RAM_ATTR DCCTimer::setPWM(byte pin, bool high) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,31 +53,26 @@ void DCCWaveform::begin(MotorDriver * mainDriver, MotorDriver * progDriver) {
|
|||||||
DCCTimer::begin(DCCWaveform::interruptHandler);
|
DCCTimer::begin(DCCWaveform::interruptHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCCWaveform::loop(bool ackManagerActive) {
|
void IRAM_ATTR DCCWaveform::loop(bool ackManagerActive) {
|
||||||
mainTrack.checkPowerOverload(false);
|
mainTrack.checkPowerOverload(false);
|
||||||
progTrack.checkPowerOverload(ackManagerActive);
|
progTrack.checkPowerOverload(ackManagerActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCCWaveform::interruptHandler() {
|
void IRAM_ATTR DCCWaveform::interruptHandler() {
|
||||||
// call the timer edge sensitive actions for progtrack and maintrack
|
// call the timer edge sensitive actions for progtrack and maintrack
|
||||||
// member functions would be cleaner but have more overhead
|
// member functions would be cleaner but have more overhead
|
||||||
byte sigMain=signalTransform[mainTrack.state];
|
byte sigMain=signalTransform[mainTrack.state];
|
||||||
byte sigProg=progTrackSyncMain? sigMain : signalTransform[progTrack.state];
|
byte sigProg=progTrackSyncMain? sigMain : signalTransform[progTrack.state];
|
||||||
|
|
||||||
// Set the signal state for both tracks
|
// Set the signal state for both tracks
|
||||||
mainTrack.motorDriver->setSignal(sigMain);
|
mainTrack.motorDriver->setSignal(sigMain);
|
||||||
progTrack.motorDriver->setSignal(sigProg);
|
progTrack.motorDriver->setSignal(sigProg);
|
||||||
|
|
||||||
// Move on in the state engine
|
// Move on in the state engine
|
||||||
mainTrack.state=stateTransform[mainTrack.state];
|
mainTrack.state=stateTransform[mainTrack.state];
|
||||||
progTrack.state=stateTransform[progTrack.state];
|
progTrack.state=stateTransform[progTrack.state];
|
||||||
|
|
||||||
|
|
||||||
// WAVE_PENDING means we dont yet know what the next bit is
|
// WAVE_PENDING means we dont yet know what the next bit is
|
||||||
if (mainTrack.state==WAVE_PENDING) mainTrack.interrupt2();
|
if (mainTrack.state==WAVE_PENDING) mainTrack.interrupt2();
|
||||||
if (progTrack.state==WAVE_PENDING) progTrack.interrupt2();
|
if (progTrack.state==WAVE_PENDING) progTrack.interrupt2();
|
||||||
else if (progTrack.ackPending) progTrack.checkAck();
|
else if (progTrack.ackPending) progTrack.checkAck();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -197,7 +192,7 @@ const bool DCCWaveform::signalTransform[]={
|
|||||||
/* WAVE_LOW_0 -> */ LOW,
|
/* WAVE_LOW_0 -> */ LOW,
|
||||||
/* WAVE_PENDING (should not happen) -> */ LOW};
|
/* WAVE_PENDING (should not happen) -> */ LOW};
|
||||||
|
|
||||||
void DCCWaveform::interrupt2() {
|
void ICACHE_RAM_ATTR DCCWaveform::interrupt2() {
|
||||||
// calculate the next bit to be sent:
|
// calculate the next bit to be sent:
|
||||||
// set state WAVE_MID_1 for a 1=bit
|
// set state WAVE_MID_1 for a 1=bit
|
||||||
// or WAVE_HIGH_0 for a 0 bit.
|
// or WAVE_HIGH_0 for a 0 bit.
|
||||||
@ -207,7 +202,7 @@ void DCCWaveform::interrupt2() {
|
|||||||
remainingPreambles--;
|
remainingPreambles--;
|
||||||
// Update free memory diagnostic as we don't have anything else to do this time.
|
// Update free memory diagnostic as we don't have anything else to do this time.
|
||||||
// Allow for checkAck and its called functions using 22 bytes more.
|
// Allow for checkAck and its called functions using 22 bytes more.
|
||||||
updateMinimumFreeMemory(22);
|
// might break ESP8266 updateMinimumFreeMemory(22);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +301,7 @@ byte DCCWaveform::getAck() {
|
|||||||
return(0); // pending set off but not detected means no ACK.
|
return(0); // pending set off but not detected means no ACK.
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCCWaveform::checkAck() {
|
void ICACHE_RAM_ATTR DCCWaveform::checkAck() {
|
||||||
// This function operates in interrupt() time so must be fast and can't DIAG
|
// This function operates in interrupt() time so must be fast and can't DIAG
|
||||||
if (sentResetsSincePacket > 6) { //ACK timeout
|
if (sentResetsSincePacket > 6) { //ACK timeout
|
||||||
ackCheckDuration=millis()-ackCheckStart;
|
ackCheckDuration=millis()-ackCheckStart;
|
||||||
|
@ -21,11 +21,6 @@
|
|||||||
#include "DCCTimer.h"
|
#include "DCCTimer.h"
|
||||||
#include "DIAG.h"
|
#include "DIAG.h"
|
||||||
|
|
||||||
#define setHIGH(fastpin) *fastpin.inout |= fastpin.maskHIGH
|
|
||||||
#define setLOW(fastpin) *fastpin.inout &= fastpin.maskLOW
|
|
||||||
#define isHIGH(fastpin) (*fastpin.inout & fastpin.maskHIGH)
|
|
||||||
#define isLOW(fastpin) (!isHIGH(fastpin))
|
|
||||||
|
|
||||||
bool MotorDriver::usePWM=false;
|
bool MotorDriver::usePWM=false;
|
||||||
bool MotorDriver::commonFaultPin=false;
|
bool MotorDriver::commonFaultPin=false;
|
||||||
|
|
||||||
@ -109,8 +104,8 @@ void MotorDriver::setBrake(bool on) {
|
|||||||
if (on ^ invertBrake) setHIGH(fastBrakePin);
|
if (on ^ invertBrake) setHIGH(fastBrakePin);
|
||||||
else setLOW(fastBrakePin);
|
else setLOW(fastBrakePin);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
void MotorDriver::setSignal( bool high) {
|
IRAM_ATTR void MotorDriver::setSignal( bool high) {
|
||||||
if (usePWM) {
|
if (usePWM) {
|
||||||
DCCTimer::setPWM(signalPin,high);
|
DCCTimer::setPWM(signalPin,high);
|
||||||
}
|
}
|
||||||
@ -125,7 +120,7 @@ void MotorDriver::setSignal( bool high) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#if defined(ARDUINO_TEENSY32) || defined(ARDUINO_TEENSY35)|| defined(ARDUINO_TEENSY36)
|
#if defined(ARDUINO_TEENSY32) || defined(ARDUINO_TEENSY35)|| defined(ARDUINO_TEENSY36)
|
||||||
volatile unsigned int overflow_count=0;
|
volatile unsigned int overflow_count=0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,12 +42,27 @@ struct FASTPIN {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define setHIGH(fastpin) *fastpin.inout |= fastpin.maskHIGH
|
||||||
|
#define setLOW(fastpin) *fastpin.inout &= fastpin.maskLOW
|
||||||
|
#define isHIGH(fastpin) (*fastpin.inout & fastpin.maskHIGH)
|
||||||
|
#define isLOW(fastpin) (!isHIGH(fastpin))
|
||||||
|
|
||||||
class MotorDriver {
|
class MotorDriver {
|
||||||
public:
|
public:
|
||||||
MotorDriver(byte power_pin, byte signal_pin, byte signal_pin2, int8_t brake_pin,
|
MotorDriver(byte power_pin, byte signal_pin, byte signal_pin2, int8_t brake_pin,
|
||||||
byte current_pin, float senseFactor, unsigned int tripMilliamps, byte faultPin);
|
byte current_pin, float senseFactor, unsigned int tripMilliamps, byte faultPin);
|
||||||
virtual void setPower( bool on);
|
virtual void setPower( bool on);
|
||||||
virtual void setSignal( bool high);
|
virtual void setSignal( bool high) {
|
||||||
|
if (high) {
|
||||||
|
setHIGH(fastSignalPin);
|
||||||
|
if (dualSignal) setLOW(fastSignalPin2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setLOW(fastSignalPin);
|
||||||
|
if (dualSignal) setHIGH(fastSignalPin2);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
virtual void setBrake( bool on);
|
virtual void setBrake( bool on);
|
||||||
virtual int getCurrentRaw();
|
virtual int getCurrentRaw();
|
||||||
virtual unsigned int raw2mA( int raw);
|
virtual unsigned int raw2mA( int raw);
|
||||||
|
104
WifiESP.cpp
104
WifiESP.cpp
@ -17,15 +17,111 @@
|
|||||||
along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <ESPAsyncTCP.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "WifiESP.h"
|
#include "WifiESP.h"
|
||||||
#include "DIAG.h"
|
#include "DIAG.h"
|
||||||
|
#include "RingStream.h"
|
||||||
|
#include "CommandDistributor.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
bool WifiESP::setup(const FSH *wifiESSID,
|
static std::vector<AsyncClient*> clients; // a list to hold all clients
|
||||||
const FSH *wifiPassword,
|
static AsyncServer *server;
|
||||||
const FSH *hostname,
|
|
||||||
const int port,
|
static RingStream *outboundRing = new RingStream(2048);
|
||||||
|
|
||||||
|
static void handleError(void* arg, AsyncClient* client, int8_t error) {
|
||||||
|
DIAG(F("connection error %s from client %s"), client->errorToString(error), client->remoteIP().toString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handleData(void* arg, AsyncClient* client, void *data, size_t len) {
|
||||||
|
DIAG(F("data received from client %s"), client->remoteIP().toString().c_str());
|
||||||
|
uint8_t clientId;
|
||||||
|
for (clientId=0; clientId<clients.size(); clientId++){
|
||||||
|
if (clients[clientId] == client) break;
|
||||||
|
}
|
||||||
|
if (clientId < clients.size()) {
|
||||||
|
byte cmd[len+1];
|
||||||
|
memcpy(cmd,data,len);
|
||||||
|
cmd[len]=0;
|
||||||
|
CommandDistributor::parse(clientId,cmd,outboundRing);
|
||||||
|
}
|
||||||
|
// reply to client
|
||||||
|
int c;
|
||||||
|
if (client->space() >= (c=outboundRing->count()) && client->canSend()) {
|
||||||
|
char cmd[c+1];
|
||||||
|
int i;
|
||||||
|
for (i=0;i<c;i++) {
|
||||||
|
cmd[i]=outboundRing->read();
|
||||||
|
}
|
||||||
|
cmd[i]=0;
|
||||||
|
client->add(cmd, strlen(cmd));
|
||||||
|
client->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handleDisconnect(void* arg, AsyncClient* client) {
|
||||||
|
DIAG(F("client %s disconnected"), client->remoteIP().toString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handleTimeOut(void* arg, AsyncClient* client, uint32_t time) {
|
||||||
|
DIAG(F("client ACK timeout ip: %s"), client->remoteIP().toString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void handleNewClient(void* arg, AsyncClient* client) {
|
||||||
|
DIAG(F("New client has been connected to server, ip: %s"), client->remoteIP().toString().c_str());
|
||||||
|
|
||||||
|
// add to list
|
||||||
|
clients.push_back(client);
|
||||||
|
|
||||||
|
// register events
|
||||||
|
client->onData(&handleData, NULL);
|
||||||
|
client->onError(&handleError, NULL);
|
||||||
|
client->onDisconnect(&handleDisconnect, NULL);
|
||||||
|
client->onTimeout(&handleTimeOut, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WifiESP::setup(const char *wifiESSID,
|
||||||
|
const char *wifiPassword,
|
||||||
|
const char *hostname,
|
||||||
|
int port,
|
||||||
const byte channel) {
|
const byte channel) {
|
||||||
|
DIAG(F("START"));
|
||||||
|
// connects to access point
|
||||||
|
wifi_set_sleep_type(NONE_SLEEP_T);
|
||||||
|
WiFi.mode(WIFI_STA);
|
||||||
|
WiFi.setAutoReconnect(true);
|
||||||
|
DIAG(F("BEGIN"));
|
||||||
|
WiFi.begin(wifiESSID, wifiPassword);
|
||||||
|
DIAG(F("STATUS"));
|
||||||
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
Serial.print('.');
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
DIAG(F("SERVER"));
|
||||||
|
|
||||||
|
server = new AsyncServer(port); // start listening on tcp port
|
||||||
|
|
||||||
|
DIAG(F("CLIENT"));
|
||||||
|
server->onClient(&handleNewClient, server);
|
||||||
|
DIAG(F("SBEGIN"));
|
||||||
|
|
||||||
|
server->begin();
|
||||||
|
|
||||||
|
DIAG(F("ENDSETUP"));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
void WifiESP::loop() {
|
void WifiESP::loop() {
|
||||||
|
static unsigned long last = 0;
|
||||||
|
if (millis() - last > 60000) {
|
||||||
|
last = millis();
|
||||||
|
DIAG(F("+"));
|
||||||
|
}
|
||||||
|
ESP.wdtFeed();
|
||||||
}
|
}
|
||||||
|
@ -16,16 +16,19 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WifiESP_h
|
#ifndef WifiESP_h
|
||||||
#define WifiESP_h
|
#define WifiESP_h
|
||||||
|
|
||||||
|
#include "FSH.h"
|
||||||
|
|
||||||
class WifiESP
|
class WifiESP
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool setup(const FSH *wifiESSID,
|
static bool setup(const char *wifiESSID,
|
||||||
const FSH *wifiPassword,
|
const char *wifiPassword,
|
||||||
const FSH *hostname,
|
const char *hostname,
|
||||||
const int port,
|
const int port,
|
||||||
const byte channel);
|
const byte channel);
|
||||||
static void loop();
|
static void loop();
|
||||||
|
@ -41,7 +41,14 @@ The configuration file for DCC-EX Command Station
|
|||||||
// |
|
// |
|
||||||
// +-----------------------v
|
// +-----------------------v
|
||||||
//
|
//
|
||||||
#define MOTOR_SHIELD_TYPE STANDARD_MOTOR_SHIELD
|
//#define MOTOR_SHIELD_TYPE STANDARD_MOTOR_SHIELD
|
||||||
|
|
||||||
|
#define ESP_MOTOR_SHIELD F("ESP"), \
|
||||||
|
new MotorDriver(D3, D5, UNUSED_PIN, UNUSED_PIN, UNUSED_PIN, 2.99, 2000, UNUSED_PIN),\
|
||||||
|
new MotorDriver(D2, D6, UNUSED_PIN, UNUSED_PIN, UNUSED_PIN, 2.99, 2000, UNUSED_PIN)
|
||||||
|
|
||||||
|
#define MOTOR_SHIELD_TYPE ESP_MOTOR_SHIELD
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// The IP port to talk to a WIFI or Ethernet shield.
|
// The IP port to talk to a WIFI or Ethernet shield.
|
||||||
@ -53,7 +60,7 @@ The configuration file for DCC-EX Command Station
|
|||||||
// NOTE: Only supported on Arduino Mega
|
// NOTE: Only supported on Arduino Mega
|
||||||
// Set to false if you not even want it on the Arduino Mega
|
// Set to false if you not even want it on the Arduino Mega
|
||||||
//
|
//
|
||||||
#define ENABLE_WIFI true
|
//#define ENABLE_WIFI true
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -64,9 +64,7 @@ static inline int freeMemory() {
|
|||||||
}
|
}
|
||||||
// Return low memory value.
|
// Return low memory value.
|
||||||
int minimumFreeMemory() {
|
int minimumFreeMemory() {
|
||||||
noInterrupts(); // Disable interrupts
|
|
||||||
int retval = minimum_free_memory;
|
int retval = minimum_free_memory;
|
||||||
interrupts(); // interrupts
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -118,7 +116,7 @@ int minimumFreeMemory() {
|
|||||||
// So even if all of the heap is freed, the reported minimum free
|
// So even if all of the heap is freed, the reported minimum free
|
||||||
// memory will not increase.
|
// memory will not increase.
|
||||||
//
|
//
|
||||||
void updateMinimumFreeMemory(unsigned char extraBytes) {
|
void ICACHE_RAM_ATTR updateMinimumFreeMemory(unsigned char extraBytes) {
|
||||||
int spare = freeMemory()-extraBytes;
|
int spare = freeMemory()-extraBytes;
|
||||||
if (spare < 0) spare = 0;
|
if (spare < 0) spare = 0;
|
||||||
if (spare < minimum_free_memory) minimum_free_memory = spare;
|
if (spare < minimum_free_memory) minimum_free_memory = spare;
|
||||||
|
Loading…
Reference in New Issue
Block a user