Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proof of concept > OOP based approach #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
688 changes: 205 additions & 483 deletions BrauHelferlein.ino

Large diffs are not rendered by default.

Binary file added Brauhelferlein.aps
Binary file not shown.
22 changes: 22 additions & 0 deletions Brauhelferlein.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Brauhelferlein", "Brauhelferlein.vcxproj", "{C5F80730-F44F-4478-BDAE-6634EFC2CA88}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C5F80730-F44F-4478-BDAE-6634EFC2CA88}.Debug|x86.ActiveCfg = Debug|Win32
{C5F80730-F44F-4478-BDAE-6634EFC2CA88}.Debug|x86.Build.0 = Debug|Win32
{C5F80730-F44F-4478-BDAE-6634EFC2CA88}.Release|x86.ActiveCfg = Release|Win32
{C5F80730-F44F-4478-BDAE-6634EFC2CA88}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
103 changes: 103 additions & 0 deletions Brauhelferlein.vcxproj

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions Brauhelferlein.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="Brauhelferlein.ino" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="__vm\.Brauhelferlein.vsarduino.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="VisualizerClass.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="WiFiManagerClass.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ConfigClass.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FileStorageClass.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="WebserverManagerClass.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StringHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PID_Handler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Stirrer_Handler.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
55 changes: 55 additions & 0 deletions ConfigClass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#pragma once

#ifndef CONFIG_H
#define CONFIG_H



#include <EEPROM.h>
#include "VisualizerClass.h"
#include "Arduino.h"

#define CONFIG_VERSION 1
#define CONFIG_START 10

struct StoreStruct {
uint8_t version;
double solltemp, consKp, consKi, consKd;
} configStore;

bool shouldReboot = false;


class Config {
public:
Config(Visualizer* aVisualizer) {
this->visualizer = aVisualizer;
EEPROM.begin(512);
}

void save() {
if(visualizer) visualizer->show("EE save: ",mtSerial_LCD);
EEPROM.put(CONFIG_START, configStore);
EEPROM.commit();
if (visualizer) visualizer->showSecondary("OK");
}

void load() {
if (visualizer) visualizer->show("EE load: ", mtSerial_LCD);
EEPROM.get(CONFIG_START, configStore);

if (configStore.version != CONFIG_VERSION)
{
configStore.version = CONFIG_VERSION;
configStore.solltemp = 24;
configStore.consKp = 5000;
configStore.consKi = 0;
configStore.consKd = 0;
save();
}
}
private:
Visualizer* visualizer;
};

#endif // !CONFIG_H
58 changes: 58 additions & 0 deletions FileStorageClass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#pragma once

#ifndef FILESTORAGECLASS_H
#define FILESTORAGECLASS_H


#include <FS.h>
#include "Arduino.h"

class FileStorage {
public:
inline FileStorage(Visualizer* aVisualizer)
{
this->visualizer = aVisualizer;
}

inline void Initialize()
{
visualizer->show("Init SPIFFS", mtSerial_LCD);
if (!SPIFFS.begin()) visualizer->showSecondary("begin() failed!");
if (!SPIFFS.format()) visualizer->showSecondary("format() failed!");
this->visualizer->showSecondary("SPIFFS initialized");
isInitialized = true;
}

inline String getHtmlContentFromFile(String aFileName)
{
return this->getTextfileContent(aFileName,"/html/");
}

private:
Visualizer* visualizer;
bool isInitialized;

inline String getTextfileContent(String aFileName, String aPath)
{
if (!isInitialized)
this->Initialize();
String result = "";
String file = aPath + aFileName;

File fileHandle = fileHandle = SPIFFS.open(file, "r");
if (!fileHandle)
{
visualizer->show("File.open() failed for file: " + aFileName);
return "";
}
while (fileHandle.available())
{
result += fileHandle.readStringUntil('\n');
}
fileHandle.close();
return result;
}

};

#endif // !FILESTORAGECLASS_H
Loading