Open FFBoard
Open source force feedback firmware
Loading...
Searching...
No Matches
EncoderLocal.h
Go to the documentation of this file.
1/*
2 * EncoderLocal.h
3 *
4 * Created on: 02.02.2020
5 * Author: Yannick
6 */
7
8#ifndef ENCODERLOCAL_H_
9#define ENCODERLOCAL_H_
10
11#include "cppmain.h"
12#include <Encoder.h>
13#include "constants.h"
14#include "ExtiHandler.h"
15#include "TimerHandler.h"
16#include "CommandHandler.h"
17#include "PersistentStorage.h"
18
19#ifdef LOCALENCODER
20extern TIM_HandleTypeDef TIM_ENC;
21
22
23
25 enum class EncoderLocal_commands : uint32_t{
27 };
28public:
29 static bool inUse;
30 static ClassIdentifier info;
32 static bool isCreatable() {return !inUse;};
33
35 virtual ~EncoderLocal();
36
38
39 void registerCommands();
40
41 int32_t getPos();
42 void setPos(int32_t pos);
43 //void setOffset(int32_t offset);
44 void setPeriod(uint32_t period);
45 void overflowCallback();
46 void exti(uint16_t GPIO_Pin) override;
47 void timerElapsed(TIM_HandleTypeDef* htim);
48
49 int32_t getTimerCount();
50
51 void setCpr(uint32_t cpr); // Encoder counts per rotation
52
53 CommandStatus command(const ParsedCommand& cmd,std::vector<CommandReply>& replies);
54 std::string getHelpstring(){return "Local ABN encoder\n";}
55 void saveFlash(); // Write to flash here
56 void restoreFlash(); // Load from flash
57
58 //const ClassType getClassType() override {return ClassType::Encoder;};
59private:
60 TIM_HandleTypeDef* htim;
61 int16_t offset = 0;
62 int32_t pos = 0; // Extra position counter for overflows
63 uint32_t indexpos = 0;
64
65 bool indexHit = false;
66 bool useIndex = false;
67};
68#endif
69#endif /* ENCODERLOCAL_H_ */
CommandStatus
EncoderType
Definition Encoder.h:27
TIM_HandleTypeDef TIM_ENC
CommandHandler(const char *clsname, uint16_t clsid, uint8_t instance=0)
Encoder()
Definition Encoder.cpp:18
int32_t getTimerCount()
int32_t getPos()
void setPos(int32_t pos)
static bool isCreatable()
virtual ~EncoderLocal()
void exti(uint16_t GPIO_Pin) override
void timerElapsed(TIM_HandleTypeDef *htim)
void setPeriod(uint32_t period)
static bool inUse
const ClassIdentifier getInfo()
void registerCommands()
static ClassIdentifier info
void restoreFlash()
int16_t offset
TIM_HandleTypeDef * htim
void overflowCallback()
EncoderType getEncoderType()
CommandStatus command(const ParsedCommand &cmd, std::vector< CommandReply > &replies)
uint32_t indexpos
void setCpr(uint32_t cpr)
std::string getHelpstring()