hi,
I have a problem. My c++ level very very low. I am c# developer. I need to help.
This is my Storage.h
#include <EEPROM/EEPROM.h>
#define CONFIG_START 32
#define CONFIG_VERSION "mkb"
class Storage
{
public:
Storage();
static void LoadConfig();
static void SaveConfig();
};
and this my Storage.cpp
#include "storage.h"
#include <EEPROM.h>
// ESP Eeprom Ayarlar Bilgisi
struct Settings {
char version[4];
// Motor 1 : Sırt Motoru
int MOTOR1_UP_PIN;
int MOTOR1_DOWN_PIN;
int MOTOR1_UP_LIMIT;
int MOTOR1_DOWN_LIMIT;
// Motor 2 : Bel Motoru
int MOTOR2_PIN;
int MOTOR2_DOWN_PIN;
int MOTOR2_UP_LIMIT;
int MOTOR2_DOWN_LIMIT;
// Motor 3 : Ayak Motoru
int MOTOR3_PIN;
int MOTOR3_DOWN_PIN;
int MOTOR3_UP_LIMIT;
int MOTOR3_DOWN_LIMIT;
// Motor 4 : Ayak Motoru
int MOTOR4_PIN;
int MOTOR4_DOWN_PIN;
int MOTOR4_UP_LIMIT;
int MOTOR4_DOWN_LIMIT;
// Okuma Lambası
int LIGHT_PIN;
int LIGHT_SENSIVITY;
bool HAS_CALIBRATED;
bool HAS_CONFIGURED;
} settings;
Storage::Storage() {
}
void Storage::LoadConfig() {
// To make sure there are settings, and they are YOURS!
// If nothing is found it will use the default settings.
if (EEPROM.read(CONFIG_START + 0) == CONFIG_VERSION[0] &&
EEPROM.read(CONFIG_START + 1) == CONFIG_VERSION[1] &&
EEPROM.read(CONFIG_START + 2) == CONFIG_VERSION[2])
for (unsigned int t = 0; t < sizeof(settings); t++)
((char)&settings + t) = EEPROM.read(CONFIG_START + t);
else
SaveConfig();
}
void Storage::SaveConfig() {
for (unsigned int t = 0; t < sizeof(settings); t++)
EEPROM.write(CONFIG_START + t, ((char)&settings + t));
EEPROM.commit();
}
and this is "Esp8266App.ino"
#pragma region Imports
#include <ESP8266WiFi.h>
#include <WebSocketsServer.h>
#include <Hash.h>
#include <Ticker/Ticker.h>
#include "Storage.h"
#pragma endregion
DeviceState deviceState = NotReady;
void setup() {
USE_SERIAL.begin(9600);
// Hafızadaki ayarları yükle
Storage::LoadConfig();
// Aygıt ayarları yapılmamışsa durumu Ayar Gerekiyor yap
if (!settings.HAS_CONFIGURED)
{
deviceState = NeedConfig;
return;
}
// Motor kalibrasyon ayarları yapılmamışsa durumu Kalibrasyon Gerekiyor yap
if (!settings.HAS_CALIBRATED)
{
deviceState = NeedCalibrate;
return;
}
}
this code throwing error.
Error :
Esp8266App.ino: 24:7: error: 'settings' was not declared in this scope
** if (!settings.HAS_CONFIGURED)**