Merge branch 'main' into pressure-wrapper

This commit is contained in:
Vasily Davydov 2022-10-10 14:28:35 +03:00
commit 40a0f080b2
9 changed files with 236 additions and 59 deletions

5
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"C_Cpp.autocompleteAddParentheses": true,
"files.autoSave": "onFocusChange",
"C_Cpp.codeAnalysis.clangTidy.enabled": true
}

View File

@ -48,6 +48,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
</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="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
</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="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
</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="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
</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="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
</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="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
</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"/>

View File

@ -5,6 +5,7 @@
<projects>
<project>lpc_chip_15xx</project>
<project>DigitalIoPin</project>
<project>LiquidCrystal</project>
</projects>
<buildSpec>
<buildCommand>

View File

@ -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

View File

@ -14,7 +14,7 @@ public:
Counter(int i, int up);
void inc();
void dec();
int getInit();
int getCurrent();
void setInit(int i);
~Counter() = default;

View File

@ -15,43 +15,115 @@
#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
*
* Current switch state is being passed
* from main to StateHandler through
*
* Current switch state is being passed
* from main to StateHandler through
* a keyEvent. Enumeration determines the state
* of the particular button.
* of the particular button.
* */
enum _buttons {
/** Raises the bar up */
BUTTON_CONTROL_UP,
/** Raises the bar down */
BUTTON_CONTROL_DOWN,
/** Toggles the mode between auto and
* manual, which changes the state */
BUTTON_CONTROL_TOG_MODE,
/** Optional button to toggle the
* activation of the current setting.
* Not compulsory to be used. */
BUTTON_CONTROL_TOG_ACTIVE
enum _buttons
{
/** Raises the bar up */
BUTTON_CONTROL_UP,
/** Raises the bar down */
BUTTON_CONTROL_DOWN,
/** Toggles the mode between auto and
* manual, which changes the state */
BUTTON_CONTROL_TOG_MODE,
/** Optional button to toggle the
* activation of the current setting.
* Not compulsory to be used. */
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_ */

View File

@ -24,7 +24,7 @@ void Counter::dec() {
}
int Counter::getInit(){
int Counter::getCurrent(){
return this->init;
}

View File

@ -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() {
// TODO Auto-generated destructor stub
StateHandler::~StateHandler ()
{
// TODO Auto-generated destructor stub
}
int StateHandler::getSetPresuure(){
//TODO
return 0;
void
StateHandler::displaySet (unsigned int value1, unsigned int value2)
{
// TODO
/**
* 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;
}
}

View File

@ -1,14 +1,14 @@
/*
===============================================================================
Name : main.c
Author : Vasily, Evgenii, Jaakko, Miisa
Author : Vasily, Evgenii, Jaakko, Miisa
Version :
Copyright : $(copyright)
Description : main definition
===============================================================================
*/
#if defined (__USE_LPCOPEN)
#if defined(__USE_LPCOPEN)
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
@ -22,21 +22,25 @@
// TODO: insert other definitions and declarations here
int main(void) {
int
main (void)
{
#if defined (__USE_LPCOPEN)
// Read clock settings and update SystemCoreClock variable
SystemCoreClockUpdate();
#if defined(__USE_LPCOPEN)
// Read clock settings and update SystemCoreClock variable
SystemCoreClockUpdate ();
#if !defined(NO_BOARD_LIB)
// Set up and initialize all required blocks and
// functions related to the board hardware
Board_Init();
// Set the LED to the state of "On"
Board_LED_Set(0, true);
// Set up and initialize all required blocks and
// functions related to the board hardware
Board_Init ();
// Set the LED to the state of "On"
Board_LED_Set (0, true);
#endif
#endif
while(1) {}
return 0 ;
while (1)
{
}
return 0;
}