eventhandler: #6 add basic members
This commit is contained in:
parent
595243f41a
commit
e8f3593704
26
EventHandler/inc/Counter.h
Normal file
26
EventHandler/inc/Counter.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Counter.h
|
||||||
|
*
|
||||||
|
* Created on: Sep 1, 2022
|
||||||
|
* Author: tylen
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COUNTER_H_
|
||||||
|
#define COUNTER_H_
|
||||||
|
|
||||||
|
class Counter {
|
||||||
|
|
||||||
|
public:
|
||||||
|
Counter(int i, int up);
|
||||||
|
void inc();
|
||||||
|
void dec();
|
||||||
|
int getInit();
|
||||||
|
void setInit(int i);
|
||||||
|
~Counter() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int init;
|
||||||
|
int up_lim;
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif /* COUNTER_H_ */
|
||||||
@ -9,6 +9,7 @@
|
|||||||
#define EVENTHANDLER_H_
|
#define EVENTHANDLER_H_
|
||||||
|
|
||||||
#include "DigitalIoPin.h"
|
#include "DigitalIoPin.h"
|
||||||
|
#include "Counter.h"
|
||||||
|
|
||||||
typedef struct _EVENT_HANDL{
|
typedef struct _EVENT_HANDL{
|
||||||
DigitalIoPin * _button_control_up;
|
DigitalIoPin * _button_control_up;
|
||||||
@ -19,10 +20,15 @@ typedef struct _EVENT_HANDL{
|
|||||||
|
|
||||||
class EventHandler {
|
class EventHandler {
|
||||||
public:
|
public:
|
||||||
EventHandler(EVENT_HANDL * btns);
|
EventHandler(EVENT_HANDL btns);
|
||||||
virtual ~EventHandler();
|
virtual ~EventHandler();
|
||||||
|
int getSetPresuure();
|
||||||
|
int getSetSpeed();
|
||||||
private:
|
private:
|
||||||
EVENT_HANDL = {0,0,0,0};
|
EVENT_HANDL internal = {0,0,0,0};
|
||||||
|
bool mode;
|
||||||
|
Counter * bar_pressure;
|
||||||
|
Counter * bar_speed;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
47
EventHandler/src/Counter.cpp
Normal file
47
EventHandler/src/Counter.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Counter.cpp
|
||||||
|
*
|
||||||
|
* Created on: Sep 1, 2022
|
||||||
|
* Author: tylen
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Counter.h"
|
||||||
|
|
||||||
|
#include "Counter.h"
|
||||||
|
|
||||||
|
void Counter::inc() {
|
||||||
|
if(init >= up_lim){
|
||||||
|
init = 0;
|
||||||
|
} else{
|
||||||
|
++init;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Counter::dec() {
|
||||||
|
if(init <= 0){
|
||||||
|
init = up_lim;
|
||||||
|
} else{
|
||||||
|
--init;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Counter::getInit(){
|
||||||
|
return this->init;
|
||||||
|
}
|
||||||
|
|
||||||
|
Counter::Counter(int i, int up) {
|
||||||
|
up_lim = up;
|
||||||
|
if(i > up){
|
||||||
|
init = up;
|
||||||
|
}else if(i < 0){
|
||||||
|
init = 0;
|
||||||
|
}else{
|
||||||
|
init = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Counter::setInit(int i){
|
||||||
|
init = i;
|
||||||
|
}
|
||||||
@ -16,3 +16,12 @@ EventHandler::~EventHandler() {
|
|||||||
// TODO Auto-generated destructor stub
|
// TODO Auto-generated destructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int EventHandler::getSetPresuure(){
|
||||||
|
//TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int EventHandler::getSetSpeed(){
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user