Setti inn allar skrár frá Project 3 og bætti við overlay í samræmi við controlloerinn og pin out.

This commit is contained in:
2026-10-08 13:11:39 +00:00
parent 9194d71f10
commit 53091f68df
29 changed files with 1645 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
#ifndef ROTARY_ENCODER_DRIVER_H
#define ROTARY_ENCODER_DRIVER_H
#include <stdint.h>
#include "digital_in.h"
#include "timer_usec.h"
class RotaryEncoderDriver {
public:
static constexpr uint16_t SAMPLE_PERIOD_US = 4000; // Ts = 4 ms
static constexpr float COUNTS_PER_REV = 1050.0f;
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 int32_t history[HIST_LEN];
volatile uint8_t hist_idx;
Digital_in eA;
Digital_in eB;
Timer_usec timer;
public:
RotaryEncoderDriver();
void begin();
void update();
int32_t position();
void update_delta();
float count_per_sec();
float rpm();
bool new_speed_available();
void reset_speed_measurement();
};
#endif