something that i want to see : programmable rollover and lookup tables.
for example :
---------------
limit_low = 22 ,
limit_high = 33,
rollover = false
int_on_click= true
int_on_change_only = true
the encoder now goes between 22 and 33 , does not roll over , does not underflow. for each 'change' an interrupt is generated. so 32 to 33 generates and int. 33 to 33 does NOT generate an interrupt
turn right : 22<int>,23<int> ... 31<int>,32<int>,33<int>,33<NO INT! no change>,33<NO INT! no change>,33<NO INT! no change>
-----------------------
limit_low = 22 ,
limit_high = 33,
rollover = false
int_on_click= true
int_on_change_only = false
the encoder now goes between 22 and 33 , does not roll over , does not underflow. for each 'click' an interrupt is generated. so 32 to 33 generates an int. 33 to 33 does also generate an interrupt
turn right : 22<int>,23<int> ... 31<int>,32<int>,33<int>,33<int>,33<int>,33<int>
-----------------------
limit_low = 22 ,
limit_high = 33,
rollover = true
int_on_click= true
int_on_change_only = false
turn right : 22<int>,23<int> ... 31<int>,32<int>,33<int>,22<int>,23<int> .... : the encoder now rolls over properly.
other settings
limit_low (16 bit) : lower value of the encoder <nonvolatile>
limit_up (16 bit) : upper value of the encoder <nonvolatile>
rollover : boolean : stops at limit or rolls over <nonvolatile>
int_on_click : boolean : interrupt for every click. <nonvolatile>
int_on_change_only : boolean : only interrupts if a change in value is detected works together with int_on_click <nonvolatile>
power_on_value : nonvolatile value. this is the value applied at power-up. this allows for example to default an encoder to midpoint. <nonvolatile>
use_lookup : boolean : use a lookup table ( max 1 byte ) <nonvolatile>
table <bytes> : lookup table <nonvolatile>
current_value : current pointer value <volatile, restore from power_on_value>
current_data : current data in the table returns table<current_pointer>
read_pointer : a byte telling me what the next data byte will be. <volatile, starts at 0 after power_on>
auto_increment_read_pointer = boolean : this allows me to stop the readpointer. <nonvolatile>
so , for example if i want to make a encoder that can cycle the letter and numbers i can give it a table containing only those ascii codes.
0 = 65 ( capital a )
1 = 66 ...
25 = 90 (Z)
26 = 48 (0)
36 = 57 (9)
table 65,66,67,68,69,70,41,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,48,49,50,51,52,53,54,55,56,57
rollover= true
limit_low = 0
limit_high=36
int_on_change=true
int_on_click=true
power_up = 26
if i now turn the scrollwheel i get an interrupt on every change. i can directly read the pointer , or the table.
i would change the memory map.
current_value should be stored at 0x00
current_data should be stored at 0x04
and use little endian format. ( least significant byte first)
this limits the amount of data i need to stream over i2c.
for example : i am only interested in the table lookup, and i know i only use 1 byte , not all 4):
i set current_read_pointer to 0x04
i set _auto_increment to false
i2c_read always returns me the data pointed at. i don't need to stream all subdata.
if i only use 1 byte of the word i dont need to perform 3 useless data transfers.