Encoder fyrir position í int32, stöðuvél án null-pointera, nefndir fastar, LED gegnum context
This commit is contained in:
@@ -4,37 +4,36 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "digital_in.h"
|
||||
//#include "digital_out.h"
|
||||
#include "timer_usec.h"
|
||||
|
||||
class RotaryEncoderDriver {
|
||||
static const uint8_t HIST_LEN = 4; // 4 x 4 ms = 16 ms gluggi fyrir rpm-utreikning
|
||||
public:
|
||||
static constexpr uint16_t SAMPLE_PERIOD_US = 4000; // Ts = 4 ms
|
||||
static constexpr float COUNTS_PER_REV = 1050.0f;
|
||||
|
||||
volatile uint8_t cycle;
|
||||
volatile int16_t count;
|
||||
volatile int16_t prev_count;
|
||||
private:
|
||||
static const uint8_t HIST_LEN = 4; // 4 x Ts = 16 ms gluggi fyrir rpm-utreikning
|
||||
|
||||
volatile int32_t count;
|
||||
volatile int16_t delta;
|
||||
volatile bool speed_ready;
|
||||
|
||||
volatile int16_t history[HIST_LEN];
|
||||
volatile int32_t history[HIST_LEN];
|
||||
volatile uint8_t hist_idx;
|
||||
|
||||
//Digital_out led;
|
||||
|
||||
Digital_in eA;
|
||||
Digital_in eB;
|
||||
|
||||
Timer_usec timer;
|
||||
|
||||
public:
|
||||
volatile int16_t delta;
|
||||
|
||||
RotaryEncoderDriver();
|
||||
|
||||
void begin();
|
||||
|
||||
void update();
|
||||
|
||||
int position();
|
||||
int32_t position();
|
||||
|
||||
void update_delta();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user