Nýtt branch og kóðar/files fyrir part 1
This commit is contained in:
@@ -4,11 +4,11 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "digital_in.h"
|
||||
#include "digital_out.h"
|
||||
//#include "digital_out.h"
|
||||
#include "timer_usec.h"
|
||||
|
||||
class RotaryEncoderDriver {
|
||||
static const uint8_t HIST_LEN = 4; // 8 x 5 ms = 40 ms gluggi fyrir rpm-utreikning
|
||||
static const uint8_t HIST_LEN = 4; // 4 x 4 ms = 16 ms gluggi fyrir rpm-utreikning
|
||||
|
||||
volatile uint8_t cycle;
|
||||
volatile int16_t count;
|
||||
@@ -18,7 +18,7 @@ class RotaryEncoderDriver {
|
||||
volatile int16_t history[HIST_LEN];
|
||||
volatile uint8_t hist_idx;
|
||||
|
||||
Digital_out led;
|
||||
//Digital_out led;
|
||||
|
||||
Digital_in eA;
|
||||
Digital_in eB;
|
||||
@@ -29,14 +29,21 @@ public:
|
||||
volatile int16_t delta;
|
||||
|
||||
RotaryEncoderDriver();
|
||||
|
||||
void begin();
|
||||
|
||||
void update();
|
||||
|
||||
int position();
|
||||
|
||||
void update_delta();
|
||||
|
||||
float count_per_sec();
|
||||
|
||||
float rpm();
|
||||
|
||||
bool new_speed_available();
|
||||
|
||||
void reset_speed_measurement();
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef STATE_H
|
||||
#define STATE_H
|
||||
|
||||
class MotorController;
|
||||
|
||||
class State
|
||||
{
|
||||
protected:
|
||||
MotorController* context;
|
||||
|
||||
public:
|
||||
virtual ~State()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void set_context(MotorController* context)
|
||||
{
|
||||
this->context = context;
|
||||
}
|
||||
|
||||
virtual void enter() = 0; // LED ON
|
||||
|
||||
virtual void update() = 0; // run motor controller
|
||||
|
||||
virtual void command(char c) = 0; // Listen for reset
|
||||
|
||||
virtual void exit() = 0; // Stop motor
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user