wip:
This commit is contained in:
21
zh_encoder.c
21
zh_encoder.c
@@ -17,22 +17,13 @@
|
|||||||
#define ZH_ENCODER_DIRECTION_CW 0x10
|
#define ZH_ENCODER_DIRECTION_CW 0x10
|
||||||
#define ZH_ENCODER_DIRECTION_CCW 0x20
|
#define ZH_ENCODER_DIRECTION_CCW 0x20
|
||||||
|
|
||||||
// Create the half-step state table (emits a code at 00 and 11)
|
|
||||||
#define R_START 0x0
|
|
||||||
#define H_CCW_BEGIN 0x1
|
|
||||||
#define H_CW_BEGIN 0x2
|
|
||||||
#define H_START_M 0x3
|
|
||||||
#define H_CW_BEGIN_M 0x4
|
|
||||||
#define H_CCW_BEGIN_M 0x5
|
|
||||||
|
|
||||||
static const uint8_t _encoder_matrix[7][4] = {
|
static const uint8_t _encoder_matrix[7][4] = {
|
||||||
// 00 01 10 11 // BA
|
{0x03, 0x02, 0x01, 0x00},
|
||||||
{H_START_M, H_CW_BEGIN, H_CCW_BEGIN, R_START}, // R_START (00)
|
{0x03 | 0x20, 0x00, 0x01, 0x00},
|
||||||
{H_START_M | DIR_CCW, R_START, H_CCW_BEGIN, R_START}, // H_CCW_BEGIN
|
{0x03 | 0x10, 0x02, 0x00, 0x00},
|
||||||
{H_START_M | DIR_CW, H_CW_BEGIN, R_START, R_START}, // H_CW_BEGIN
|
{0x03, 0x05, 0x04, 0x00},
|
||||||
{H_START_M, H_CCW_BEGIN_M, H_CW_BEGIN_M, R_START}, // H_START_M (11)
|
{0x03, 0x03, 0x04, 0x00 | 0x10},
|
||||||
{H_START_M, H_START_M, H_CW_BEGIN_M, R_START | DIR_CW}, // H_CW_BEGIN_M
|
{0x03, 0x05, 0x03, 0x00 | 0x20},
|
||||||
{H_START_M, H_CCW_BEGIN_M, H_START_M, R_START | DIR_CCW}, // H_CCW_BEGIN_M
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static QueueHandle_t _queue_handle = NULL;
|
static QueueHandle_t _queue_handle = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user