adding files

This commit is contained in:
2026-03-21 23:51:53 +01:00
commit 8cb0240ca2
19 changed files with 2162 additions and 0 deletions

28
i2c_encoder/encoder.cpp Normal file
View File

@@ -0,0 +1,28 @@
#include "encoder.h"
// public:
// constructor : sets pins as inputs and turns on pullup resistors
RotaryEncoder::RotaryEncoder( const String& argName, int argClkPin, int argDtPin, int argPinMode) : name(argName), clkPin ( argClkPin), dtPin( argDtPin )
{
// set pin a and b to be input with pull up enabled
pinMode(clkPin, argPinMode);
pinMode(dtPin, argPinMode);
position = 0;
}
void RotaryEncoder::update(void)
{
digitalRead(dtPin) ? position++ : position--;
}
int RotaryEncoder::getPosition ()
{
return position;
}
void RotaryEncoder::clearPosition()
{
position = 0;
}