52 lines
996 B
C
52 lines
996 B
C
//
|
|
// Created by villuton on 06.02.25.
|
|
//
|
|
#ifndef ENCODER_H
|
|
#define ENCODER_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint-gcc.h>
|
|
|
|
typedef enum {
|
|
ENC_NON = 0,
|
|
ENC_FWD = 0b1<<0,
|
|
ENC_BACK=0b1<<1,
|
|
ENC_KEY=0b1<<2,
|
|
ENC_FWD_KEY = ENC_FWD|ENC_KEY,
|
|
ENC_BACK_KEY = ENC_BACK|ENC_KEY,
|
|
ENC_NOT_DEF=0b1<<3,
|
|
}eEncoderEvent;
|
|
|
|
#define ENCODER_WITHOUT_KEY 0b1<<0
|
|
#define ENCODER_PIN_REWERT 0b1<<1
|
|
|
|
typedef bool (*pinGetProvider)(void *pinEnv);
|
|
|
|
typedef struct {
|
|
void *pinA;
|
|
void *pinB;
|
|
void *pinKey;
|
|
|
|
pinGetProvider pinGet;
|
|
|
|
|
|
bool undefState;
|
|
int countValue;
|
|
uint8_t encoderState;
|
|
uint8_t newValue;
|
|
uint8_t fullState;
|
|
|
|
uint16_t flags;
|
|
}tEncoder;
|
|
|
|
void Encoder_Init(tEncoder *env,
|
|
void *pinA,
|
|
void *pinB,
|
|
void *pinKey,
|
|
pinGetProvider pinGet,
|
|
uint16_t flags);
|
|
eEncoderEvent Encoder_Check(tEncoder *env);
|
|
int Encoder_GetCounter(tEncoder *env);
|
|
|
|
#endif //ENCODER_H
|