-
Notifications
You must be signed in to change notification settings - Fork 1
Home
You can find the retired functions here.
Sets up the pins. If the value goes up for the wrong direction of rotation then flip the pins:
//value goes up for CW
Encoder encoder(4, 5);//value goes up for CCW
Encoder encoder(5, 4);-
CLK_pin- CLK pin of the encoder -
DT_pin- DT pin of the encoder
//Set the pins of the encoder
Encoder encoder(4, 5);Initializes the library.
- none
//initialize the library
encoder.begin();Returns an long integer that can be changed by the rotary encoder. If the NeoPixel ring functionality is being used and the board runs an OS in the background, like freeRTOS on the ESP-32, it also updates the ring pattern currently displayed.
- none
//Returns the value
encoder.read();Returns an integer that can be changed by the rotary encoder but can be given a lower and an upper limit.
-
long Minval- lower stop -
long Maxval- upper stop
//Constrains the encoder output value between 0 and 10
//affects the read() function
encoder.setLimits(0, 10);Sets the value of the encoder to the pos parameter and returns HIGH if successful else it returns LOW.
-
int pos- the position to set the encoder value to
//sets the position of the encoder to zero
encoder.setPosition(0);//if succesful at setting the value to zero it will print "1"
Serial.println(encoder.setPosition(0));Sets the direction of the encoder used for incrementing/decrementing the output.
-
bool direction- can flip the direction of the encoder from the software side. Default value isfalse.
//flips the input direction
encoder.setDirection(true);//flips input direction back
encoder.setDirection(false);returns the current software direction of the encoder instance.
none
//print the current software direction
Serial.println(encoder.getDirection());//flips encoder software direction
encoder.setDirection(!encoder.getDirection());Sets increments of the output
-
int scale- the amount thepositionchanges per click
//sets the scaling to 10
encoder.scale(10);Returns true when the encoder was moved and keeps its value until it gets called, after that it goes back to false
- none
//checks for motion
if(encoder.motion()) { //only print the value of the encoder if it was moved
Serial.println(encoder.read());
}returns true if the encoder has not had any motion for more than the amount of time you set.
-
int noMotionTime- the time of no motion required to return true
//sets the position of the encoder to zero
encoder.setPosition(0);//if succesful at setting the value to zero it will print "1"
Serial.println(encoder.setPosition(0));Sets the time waiting between checking the encoder's pins
int debounce_time
//sets the debounce time to 2 milliseconds
encoder.setDebounceTime(2)
}Initializes the NeoPixel ring.
int ledPinuint16_t ledCount
//initialize the ring
encoder.LEDRing(3, 20); //init on pin 3 with 20 LEDs in totalupdates the pattern displayed on the NeoPixel ring. This function is only needed for boards running an OS like the ESP-32 with freeRTOS. for all other bare-metal boards this is managed automatically.
- none
//update the pattern
encoder.updatePattern();For testing and development of this library I'm using my custom board manufactured by PCBWay
You can find and download all design and manufacturing files + schematics here.
Special thanks to PCBWay for sponsoring the production of the prototype boards used in this project. Make sure to check out their services at www.pcbway.com.