I2C rotary encoder

Placed on

I2C Rotary Encoder Library

The library has the following methods:

The library has the following setters:

SetterReturnsParmesDescription
setRotVal()boolint16_tset the value of the Rotary Encoder (-5000 .. + 5000)
setRotStep()boolint16_tset the rotary Step (1 .. 50)
setRotMin()boolint16_tset the Minimum rotary value (-5000 .. +5000)
setRotMax()boolint16_tset the Maximum rotary value (-5000 .. +5000)
setRotSpinTime()booluint8_tset the Rotary Spin thime value (2 .. 100 milliseconds)
setRGBcolor()booluint8_t, uint8_t, uint8_tset the color of all 3 leds Red, Green, Blue (0 .. 255, 0 .. 255, 0 .. 255)
setRGBcolor()booluint32_tset the RGB color of all 3 leds (0x000000 .. 0xFFFFFF)
setLedRed()booluint8_tset the PWM value of the Red led (0 .. 255)
setLedGreen()booluint8_tset the PWM value of the Green led (0 .. 255)
setLedBlue()booluint8_tset the PWM value of the Blue led (0 .. 255)
setDebounceTime()booluint8_tset the Debounce Time of the switch (5 .. 250 microseconds)
setMidPressTime()booluint16_tset the Mid Press Time of the switch (100 .. 5000 milli seconds)
setLongPressTime()booluint16_tset the Long Press Time of the switch (300 .. 10000 milliseconds)
setModeSetBit()booluint8_tset the Mode Bit (STNG_HWROTDIR | STNG_FLIPMODE | STNG_TURNMODE)
setModeClearBit()booluint8_tclears the Mode Bit (STNG_HWROTDIR | STNG_FLIPMODE | STNG_TURNMODE)
setI²Caddress()booluint8_tset a new I²C address for this Slave (1 .. 127)
writeCommand()booluint8_twrite a command to the Slave (CMD_READCONF | CMD_WRITECONF | CMD_REBOOT)

The library has the following getters:

GetterReturnsParmesDescription
getStatus()uint8_tnonereads the status byte
getRotVal()int16_tnoneread the value of the rotary (-5000 .. +5000)
getRotStep()int16_tnoneread the rotary Step (1 .. 50)
getRotMin()int16_tnoneread the minimum rotary value (-5000 .. +5000)
getRotMax()int16_tnoneread the maximum rotary value (-5000 .. +5000)
getRotSpinTime()uint8_tnoneread the rotary spin time (2 .. 100 milliseconds)
getWhoAmI()int8_tnoneread the Address Register
getLedRed()uint8_tnoneread the current Red led PWM value (0 .. 255)
getLedGreen()uint8_tnoneread the current Green led PWM value (0 .. 255)
getLedBlue()uint8_tnoneread the current Blue led PWM value (0 .. 255)
getDebounceTime()uint8_tnoneread the Debounce Time of the switch (5 .. 250 microseconds)
getMidPressTime()uint16_tnoneread the Mid Press Time of the switch (100 .. 5000 milliseconds)
getLongPressTime()uint16_tnoneread the Long Press Time of the switch (300 .. 10000 milli seconds)
getMajorRelease()uint8_tnoneread the Major Firmware Release byte (0 .. 255)
getMinorRelease()uint8_tnoneread the Minor Firmware Release byte (0 .. 255)
getModeSettings()uint8_tnoneread the Mode register byte (0 .. 255)
getModeSettings()booluint8_tread the Mode register byte and test against (STNG_HWROTDIR | STNG_FLIPMODE | STNG_TURNMODE)

The library has the following helpers:

HelperReturnsParmesDescription
isRotValChanged()boolnonetrue if the Rotary Value has changed
isRotValChangedUp()boolnonetrue if the Rotary Value > previous value
isRotValChangedDown()boolnonetrue if the Rotary Value < previous value
isButtonPressed()boolnonetrue if the Button is pressed
isButtonQuickReleased()boolnonetrue if the Button is released before midPressTime
isButtonMidReleased()boolnonetrue if the Button is released between midPressTime and longPressTime
isButtonLongReleased()boolnonetrue if the Button is released after longPressTime

Current Page 2. I2C Rotary Encoder Library 1. Introduction 2. I2C Rotary Encoder Library 3. Schematic I2C Rotary Encoder Posted by Website Willem Aandewiel (1955) has a background in electronics and digital techniques. However, most of his working life he has worked in automation where he has worked in just about all disciplines from programmer to project leader and project manager. Willem was one of the first Dutchmen with a micro-computer (KIM-1, 1976) at a time when the PC had yet to be invented. Nowadays he is mainly concerned with the design and production of small electronic circuits with microprocessors. His 'mission in life' is to make people enthusiastic about making their own electronic circuits, microcomputers and programming.

Comments

Webwinkelkeur Kiyoh Trustpilot Opencircuit