0.1.3 rotaryDecoder

This commit is contained in:
rob tillaart 2022-11-23 15:19:55 +01:00
parent e01bd30402
commit f2bf989d84
7 changed files with 81 additions and 29 deletions

View File

@ -1,11 +1,29 @@
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:
packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
compile:
# Choosing to run compilation tests on 2 different Arduino platforms
# selected only those that work
platforms:
- uno
- due
- zero
- leonardo
# - due
# - zero
# - leonardo
- m4
- esp32
- esp8266
- mega2560
# - mega2560
- rpipico

View File

@ -0,0 +1,29 @@
# Change Log rotaryDecoder
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.1.3] - 2022-11-23
- add changelog.md
- add RP2040 to build-CI
- fix version number .cpp
- minor edits
## [0.1.2] - 2021-12-27
- update library.json
- update readme.md
- update license
- minor edits
## [0.1.1] - 2021-11-15
- update build-CI, readme.md
- improve readability of code
## [0.1.0] - 2021-05-08
- initial version

View File

@ -95,7 +95,14 @@ See examples..
## Future
- test with a high speed drill like a Dremel-tool.
#### must
- update documentation
- picture how to connect e.g 2 RE's which pins to used
#### should
- test with a high speed drill like a Dremel-tool.
#### could
- invert flag to adjust to RE that give their pulse just the other way around?
- setInvert(bool); getInvert();
- per channel / all?

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/rotaryDecoder.git"
},
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=rotaryDecoder
version=0.1.2
version=0.1.3
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library to rotary decoder with a PCF8574

View File

@ -1,16 +1,10 @@
//
// FILE: rotaryDecoder.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.1
// VERSION: 0.1.3
// DATE: 2021-05-08
// PURPOSE: rotary decoder library for Arduino
// URL: https://github.com/RobTillaart/rotaryDecoder
//
// HISTORY:
// 0.1.0 2021-05-08 initial version
// 0.1.1 2021-11-15 update build-CI, readme.md
// improve readability of code
// 0.1.2 2021-12-27 update library.json, license, minor edits
#include "rotaryDecoder.h"
@ -18,7 +12,7 @@
/////////////////////////////////////////////////////
//
// CONSTRUCTORS
// CONSTRUCTORS
//
rotaryDecoder::rotaryDecoder(const int8_t address, TwoWire *wire)
{
@ -91,7 +85,7 @@ bool rotaryDecoder::update()
uint8_t change = (_lastPos[i] << 2) | currentpos;
switch (change)
{
case 0b0001: // fall through..
case 0b0001: // fall through..
case 0b0111:
case 0b1110:
case 0b1000:
@ -125,7 +119,7 @@ bool rotaryDecoder::updateSingle()
uint8_t change = (_lastPos[i] << 2) | currentpos;
switch (change)
{
case 0b0001: // fall through..
case 0b0001: // fall through..
case 0b0111:
case 0b1110:
case 0b1000:
@ -150,6 +144,10 @@ bool rotaryDecoder::updateSingle()
}
/////////////////////////////////////////////////////
//
// PRIVATE
//
uint8_t rotaryDecoder::_read8()
{
_wire->requestFrom(_address, (uint8_t)1);
@ -157,5 +155,5 @@ uint8_t rotaryDecoder::_read8()
}
// -- END OF FILE --
// -- END OF FILE --

View File

@ -2,7 +2,7 @@
//
// FILE: rotaryDecoder.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.2
// VERSION: 0.1.3
// DATE: 2021-05-08
// PURPOSE: rotary decoder library for Arduino
// URL: https://github.com/RobTillaart/rotaryDecoder
@ -11,7 +11,7 @@
#include "Arduino.h"
#include "Wire.h"
#define ROTARY_DECODER_LIB_VERSION (F("0.1.2"))
#define ROTARY_DECODER_LIB_VERSION (F("0.1.3"))
class rotaryDecoder
@ -28,20 +28,20 @@ public:
void readInitialState();
// for polling version,
// checkChange is bit faster than a call to update
// so useful if there are only a few updates
// for polling version,
// checkChange is bit faster than a call to update
// so useful if there are only a few updates
bool checkChange();
// read and update the counters
bool update(); // assumes two directions => +1 and -1
bool updateSingle(); // assumes single direction => + ++ +++
// read and update the counters
bool update(); // assumes two directions => +1 and -1
bool updateSingle(); // assumes single direction => + ++ +++
// re = rotary encoder
// re = rotary encoder
int32_t getValue(uint8_t re) { return _encoder[re]; };
void setValue(uint8_t re, int32_t value = 0) { _encoder[re] = value; };
// DEBUG
// DEBUG
uint8_t getLastPosition(uint8_t re) { return _lastPos[re]; };
@ -57,5 +57,5 @@ private:
};
// -- END OF FILE --
// -- END OF FILE --