This commit is contained in:
2025-06-14 10:51:45 +03:00
parent f4ec446606
commit fab461f771

View File

@@ -17,22 +17,13 @@
#define ZH_ENCODER_DIRECTION_CW 0x10
#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] = {
// 00 01 10 11 // BA
{H_START_M, H_CW_BEGIN, H_CCW_BEGIN, R_START}, // R_START (00)
{H_START_M | DIR_CCW, R_START, H_CCW_BEGIN, R_START}, // H_CCW_BEGIN
{H_START_M | DIR_CW, H_CW_BEGIN, R_START, R_START}, // H_CW_BEGIN
{H_START_M, H_CCW_BEGIN_M, H_CW_BEGIN_M, R_START}, // H_START_M (11)
{H_START_M, H_START_M, H_CW_BEGIN_M, R_START | DIR_CW}, // H_CW_BEGIN_M
{H_START_M, H_CCW_BEGIN_M, H_START_M, R_START | DIR_CCW}, // H_CCW_BEGIN_M
{0x03, 0x02, 0x01, 0x00},
{0x03 | 0x20, 0x00, 0x01, 0x00},
{0x03 | 0x10, 0x02, 0x00, 0x00},
{0x03, 0x05, 0x04, 0x00},
{0x03, 0x03, 0x04, 0x00 | 0x10},
{0x03, 0x05, 0x03, 0x00 | 0x20},
};
static QueueHandle_t _queue_handle = NULL;