Big wheaterstation update #2

Closed
klaute wants to merge 19 commits from master into feature/http_call_send_json
3 changed files with 44 additions and 3 deletions
Showing only changes of commit 76d8416a41 - Show all commits

20
firmware/datastore.ino Normal file
View file

@ -0,0 +1,20 @@
#include <EEPROM.h>
#define EEPROM_SIZE 512
int eeprom_read(int addr) {
int ret = -255;
EEPROM.begin(EEPROM_SIZE);
EEPROM.get(addr, ret);
EEPROM.commit();
EEPROM.end();
return ret;
}
void eeprom_write(int addr, int data) {
EEPROM.begin(EEPROM_SIZE);
EEPROM.put(addr, data);
EEPROM.commit();
EEPROM.end();
}

View file

@ -4,7 +4,7 @@
#include <ESP8266WiFiType.h>
#include <esp.h>
#include <user_interface.h>
#include <WiFiClient.h> // WiFiClient
// Project includes
@ -84,10 +84,14 @@ void setup() {
//wdt_disable();
#endif
#if defined(DEBUG) || defined(SERIAL_FEATURE)
#if defined(DEBUG) || defined(SERIAL_FEATURE) || defined(DEBUG_RESET_REASON)
Serial.begin(SERIAL_BAUD_RATE);
#endif
#ifdef DEBUG_RESET_REASON
debugResetReason();
#endif
// Pin settings
pinMode(BAT_CHARGED_PIN, INPUT);
pinMode(BAT_CHARGING_PIN, INPUT);
@ -783,3 +787,20 @@ void http_call_send_json_data()
}
#endif
#ifdef DEBUG_RESET_REASON
void debugResetReason() {
rst_info *resetInfo;
// 1. read eeprom reset reason
//int eep_reset_reason = eeprom_read(0);
//debug("EEPROM reset reason " + String(eep_reset_reason));
// 2. read real reset reason
int reset_reason = resetInfo->reason;
debug("New reset reason " + String(reset_reason));
//eeprom_write(0, reset_reason);
}
#endif