Merge branch 'main' into pressure-wrapper
This commit is contained in:
commit
40a0f080b2
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"C_Cpp.autocompleteAddParentheses": true,
|
||||
"files.autoSave": "onFocusChange",
|
||||
"C_Cpp.codeAnalysis.clangTidy.enabled": true
|
||||
}
|
||||
@ -48,6 +48,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_chip_15xx/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.cpp.misc.dialect.1047276372" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
|
||||
<inputType id="com.crt.advproject.compiler.cpp.input.1472075573" superClass="com.crt.advproject.compiler.cpp.input"/>
|
||||
@ -71,6 +72,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_chip_15xx/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.c.misc.dialect.1367957643" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
|
||||
<option id="com.crt.advproject.gcc.hdrlib.1476293714" name="Library headers" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
|
||||
@ -87,6 +89,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_chip_15xx/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.gas.hdrlib.925707249" name="Library headers" superClass="com.crt.advproject.gas.hdrlib" value="Newlib" valueType="enumerated"/>
|
||||
<option id="com.crt.advproject.gas.specs.1146689581" name="Specs" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.newlib" valueType="enumerated"/>
|
||||
@ -149,6 +152,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_chip_15xx/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.cpp.misc.dialect.2103564035" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
|
||||
<option id="com.crt.advproject.cpp.hdrlib.1905759872" name="Library headers" superClass="com.crt.advproject.cpp.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
|
||||
@ -173,6 +177,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_chip_15xx/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.c.misc.dialect.1578394517" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
|
||||
<option id="com.crt.advproject.gcc.hdrlib.339012185" name="Library headers" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
|
||||
@ -189,6 +194,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_chip_15xx/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.gas.hdrlib.1849085416" name="Library headers" superClass="com.crt.advproject.gas.hdrlib" value="Newlib" valueType="enumerated"/>
|
||||
<option id="com.crt.advproject.gas.specs.451573115" name="Specs" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.newlib" valueType="enumerated"/>
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
<projects>
|
||||
<project>lpc_chip_15xx</project>
|
||||
<project>DigitalIoPin</project>
|
||||
<project>LiquidCrystal</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
../src/StateHandler.cpp:10:1:StateHandler::StateHandler(EVENT_HANDL) 16 static
|
||||
../src/StateHandler.cpp:15:1:StateHandler::~StateHandler() 16 static
|
||||
../src/StateHandler.cpp:15:1:virtual StateHandler::~StateHandler() 16 static
|
||||
../src/StateHandler.cpp:19:5:int StateHandler::getSetPresuure() 16 static
|
||||
../src/StateHandler.cpp:24:5:int StateHandler::getSetSpeed() 16 static
|
||||
/home/tylen/Desktop/Programming/Projects_Metropolia/ESP-Ventilation/StateHandler/inc/Event.h:13:11:Event::~Event() 16 static
|
||||
/home/tylen/Desktop/Programming/Projects_Metropolia/ESP-Ventilation/StateHandler/inc/Event.h:13:11:virtual Event::~Event() 16 static
|
||||
/home/tylen/Desktop/Programming/Projects_Metropolia/ESP-Ventilation/StateHandler/inc/Event.h:26:3:Event::Event(Event::eventType, int, int) 24 static
|
||||
../src/StateHandler.cpp:10:1:StateHandler::StateHandler() 16 static
|
||||
../src/StateHandler.cpp:14:1:StateHandler::~StateHandler() 16 static
|
||||
../src/StateHandler.cpp:14:1:virtual StateHandler::~StateHandler() 16 static
|
||||
../src/StateHandler.cpp:18:14:unsigned int StateHandler::getSetPressure() 16 static
|
||||
../src/StateHandler.cpp:22:14:unsigned int StateHandler::getSetSpeed() 16 static
|
||||
../src/StateHandler.cpp:26:6:void StateHandler::HandleState(const Event&) 16 static
|
||||
../src/StateHandler.cpp:30:6:void StateHandler::SetState(state_pointer) 64 static
|
||||
|
||||
@ -14,7 +14,7 @@ public:
|
||||
Counter(int i, int up);
|
||||
void inc();
|
||||
void dec();
|
||||
int getInit();
|
||||
int getCurrent();
|
||||
void setInit(int i);
|
||||
~Counter() = default;
|
||||
|
||||
|
||||
@ -15,9 +15,10 @@
|
||||
#ifndef STATE_HANDLER_H_
|
||||
#define STATE_HANDLER_H_
|
||||
|
||||
#include "DigitalIoPin.h"
|
||||
#include "Counter.h"
|
||||
#include "DigitalIoPin.h"
|
||||
#include "Event.h"
|
||||
#include "LiquidCrystal.h"
|
||||
|
||||
/** Buttons enumeration
|
||||
*
|
||||
@ -27,7 +28,8 @@
|
||||
* of the particular button.
|
||||
* */
|
||||
|
||||
enum _buttons {
|
||||
enum _buttons
|
||||
{
|
||||
/** Raises the bar up */
|
||||
BUTTON_CONTROL_UP,
|
||||
/** Raises the bar down */
|
||||
@ -41,17 +43,87 @@ enum _buttons {
|
||||
BUTTON_CONTROL_TOG_ACTIVE
|
||||
};
|
||||
|
||||
class StateHandler {
|
||||
public:
|
||||
StateHandler();
|
||||
virtual ~StateHandler();
|
||||
int getSetPresuure(); // Get currently set pressure 0-100%
|
||||
int getSetSpeed(); //Get currently set FanSpeed 0-100%
|
||||
private:
|
||||
bool mode;
|
||||
Counter * bar_pressure;
|
||||
Counter * bar_speed;
|
||||
enum _bars
|
||||
{
|
||||
/** 0-100 % */
|
||||
FAN_SPEED,
|
||||
/** 0-120 Pa */
|
||||
PRESSURE
|
||||
};
|
||||
|
||||
enum _mode
|
||||
{
|
||||
MANUAL,
|
||||
AUTO
|
||||
};
|
||||
|
||||
class StateHandler;
|
||||
typedef void (StateHandler::*state_pointer) (const Event &);
|
||||
|
||||
class StateHandler
|
||||
{
|
||||
public:
|
||||
StateHandler (LiquidCrystal *lcd);
|
||||
virtual ~StateHandler ();
|
||||
|
||||
/** Get currently set pressure
|
||||
*
|
||||
* @return pressure in range of 0-120
|
||||
*/
|
||||
unsigned int getSetPressure ();
|
||||
|
||||
/** Get currently set FanSpeed
|
||||
*
|
||||
* @return speed in range of 0-100
|
||||
*/
|
||||
unsigned int getSetSpeed ();
|
||||
|
||||
/** Display values on LCD depending on current mode
|
||||
*
|
||||
* @param value1 value to be displayed on LCD line 0
|
||||
* @param value2 value to be displayed on LCD line 1
|
||||
*/
|
||||
void displaySet (unsigned int value1, unsigned int value2);
|
||||
|
||||
/** Handle the given event of the current state
|
||||
* @param event event to be handled in the current state
|
||||
*/
|
||||
void HandleState (const Event &event);
|
||||
|
||||
private:
|
||||
state_pointer current;
|
||||
/** Set a new curremt state
|
||||
* @param newstate new state to be set to current
|
||||
*/
|
||||
void SetState (state_pointer newstate);
|
||||
bool current_mode;
|
||||
Counter value[2] = { { 0, 100 }, { 0, 120 } };
|
||||
LiquidCrystal *_lcd;
|
||||
|
||||
/** Initialization state
|
||||
*
|
||||
* @param event event of the state
|
||||
*/
|
||||
void stateInit (const Event &event);
|
||||
|
||||
/** Manual state
|
||||
*
|
||||
* - set current speed
|
||||
* - print current pressure
|
||||
*
|
||||
* @param event event of the state
|
||||
*/
|
||||
void stateManual (const Event &event);
|
||||
|
||||
/** Automated state
|
||||
*
|
||||
* - print current pressure
|
||||
* - print set pressure
|
||||
* - inc/dec fan speed
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
void stateAuto (const Event &event);
|
||||
};
|
||||
|
||||
#endif /* STATE_HANDLER_H_ */
|
||||
|
||||
@ -24,7 +24,7 @@ void Counter::dec() {
|
||||
}
|
||||
|
||||
|
||||
int Counter::getInit(){
|
||||
int Counter::getCurrent(){
|
||||
return this->init;
|
||||
}
|
||||
|
||||
|
||||
@ -7,21 +7,105 @@
|
||||
|
||||
#include <StateHandler.h>
|
||||
|
||||
StateHandler::StateHandler(EVENT_HANDL btns) {
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
StateHandler::StateHandler (LiquidCrystal *lcd)
|
||||
{
|
||||
this->_lcd = lcd;
|
||||
// TODO
|
||||
}
|
||||
|
||||
StateHandler::~StateHandler() {
|
||||
StateHandler::~StateHandler ()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
int StateHandler::getSetPresuure(){
|
||||
void
|
||||
StateHandler::displaySet (unsigned int value1, unsigned int value2)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
/**
|
||||
* MANUAL MODE:
|
||||
* ----------------
|
||||
* SPEED: 20%
|
||||
* PRESSURE: XXPa
|
||||
* ----------------
|
||||
* AUTO MODE:
|
||||
* ----------------
|
||||
* PRESSURE SET: 35Pa
|
||||
* PRESSURE CUR: XXPa
|
||||
* ----------------
|
||||
*/
|
||||
}
|
||||
|
||||
int StateHandler::getSetSpeed(){
|
||||
// TODO
|
||||
return 0;
|
||||
unsigned int
|
||||
StateHandler::getSetPressure ()
|
||||
{
|
||||
return (unsigned int)this->value[PRESSURE].getCurrent ();
|
||||
}
|
||||
|
||||
unsigned int
|
||||
StateHandler::getSetSpeed ()
|
||||
{
|
||||
return (unsigned int)this->value[FAN_SPEED].getCurrent ();
|
||||
}
|
||||
|
||||
void
|
||||
StateHandler::HandleState (const Event &event)
|
||||
{
|
||||
(this->*current) (event);
|
||||
}
|
||||
|
||||
void
|
||||
StateHandler::SetState (state_pointer newstate)
|
||||
{
|
||||
(this->*current) (Event (Event::eExit));
|
||||
current = newstate;
|
||||
(this->*current) (Event (Event::eEnter));
|
||||
}
|
||||
|
||||
void
|
||||
stateInit (const Event &event)
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case Event::eEnter:
|
||||
break;
|
||||
case Event::eExit:
|
||||
break;
|
||||
case Event::eKey:
|
||||
break;
|
||||
case Event::eTick:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
stateManual (const Event &event)
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case Event::eEnter:
|
||||
break;
|
||||
case Event::eExit:
|
||||
break;
|
||||
case Event::eKey:
|
||||
break;
|
||||
case Event::eTick:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
stateAuto (const Event &event)
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case Event::eEnter:
|
||||
break;
|
||||
case Event::eExit:
|
||||
break;
|
||||
case Event::eKey:
|
||||
break;
|
||||
case Event::eTick:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -22,7 +22,9 @@
|
||||
|
||||
// TODO: insert other definitions and declarations here
|
||||
|
||||
int main(void) {
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
|
||||
#if defined(__USE_LPCOPEN)
|
||||
// Read clock settings and update SystemCoreClock variable
|
||||
@ -36,7 +38,9 @@ int main(void) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
while(1) {}
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user