11#include " TpagerEncoder.h"
22
3- #include < Tactility/Log .h>
3+ #include < Tactility/Logger .h>
44#include < driver/gpio.h>
55
6- constexpr auto * TAG = " TpagerEncoder" ;
6+ static const auto LOGGER = tt::Logger(" TpagerEncoder" );
7+
78constexpr auto ENCODER_A = GPIO_NUM_40 ;
89constexpr auto ENCODER_B = GPIO_NUM_41 ;
910constexpr auto ENCODER_ENTER = GPIO_NUM_7 ;
@@ -52,15 +53,15 @@ void TpagerEncoder::initEncoder() {
5253 };
5354
5455 if (pcnt_new_unit (&unit_config, &encPcntUnit) != ESP_OK ) {
55- TT_LOG_E ( TAG , " Pulsecounter intialization failed" );
56+ LOGGER . error ( " Pulsecounter intialization failed" );
5657 }
5758
5859 pcnt_glitch_filter_config_t filter_config = {
5960 .max_glitch_ns = 1000 ,
6061 };
6162
6263 if (pcnt_unit_set_glitch_filter (encPcntUnit, &filter_config) != ESP_OK ) {
63- TT_LOG_E ( TAG , " Pulsecounter glitch filter config failed" );
64+ LOGGER . error ( " Pulsecounter glitch filter config failed" );
6465 }
6566
6667 pcnt_chan_config_t chan_1_config = {
@@ -78,36 +79,36 @@ void TpagerEncoder::initEncoder() {
7879
7980 if ((pcnt_new_channel (encPcntUnit, &chan_1_config, &pcnt_chan_1) != ESP_OK ) ||
8081 (pcnt_new_channel (encPcntUnit, &chan_2_config, &pcnt_chan_2) != ESP_OK )) {
81- TT_LOG_E ( TAG , " Pulsecounter channel config failed" );
82+ LOGGER . error ( " Pulsecounter channel config failed" );
8283 }
8384
8485 // Second argument is rising edge, third argument is falling edge
8586 if ((pcnt_channel_set_edge_action (pcnt_chan_1, PCNT_CHANNEL_EDGE_ACTION_DECREASE , PCNT_CHANNEL_EDGE_ACTION_INCREASE ) != ESP_OK ) ||
8687 (pcnt_channel_set_edge_action (pcnt_chan_2, PCNT_CHANNEL_EDGE_ACTION_INCREASE , PCNT_CHANNEL_EDGE_ACTION_DECREASE ) != ESP_OK )) {
87- TT_LOG_E ( TAG , " Pulsecounter edge action config failed" );
88+ LOGGER . error ( " Pulsecounter edge action config failed" );
8889 }
8990
9091 // Second argument is low level, third argument is high level
9192 if ((pcnt_channel_set_level_action (pcnt_chan_1, PCNT_CHANNEL_LEVEL_ACTION_KEEP , PCNT_CHANNEL_LEVEL_ACTION_INVERSE ) != ESP_OK ) ||
9293 (pcnt_channel_set_level_action (pcnt_chan_2, PCNT_CHANNEL_LEVEL_ACTION_KEEP , PCNT_CHANNEL_LEVEL_ACTION_INVERSE ) != ESP_OK )) {
93- TT_LOG_E ( TAG , " Pulsecounter level action config failed" );
94+ LOGGER . error ( " Pulsecounter level action config failed" );
9495 }
9596
9697 if ((pcnt_unit_add_watch_point (encPcntUnit, LOW_LIMIT ) != ESP_OK ) ||
9798 (pcnt_unit_add_watch_point (encPcntUnit, HIGH_LIMIT ) != ESP_OK )) {
98- TT_LOG_E ( TAG , " Pulsecounter watch point config failed" );
99+ LOGGER . error ( " Pulsecounter watch point config failed" );
99100 }
100101
101102 if (pcnt_unit_enable (encPcntUnit) != ESP_OK ) {
102- TT_LOG_E ( TAG , " Pulsecounter could not be enabled" );
103+ LOGGER . error ( " Pulsecounter could not be enabled" );
103104 }
104105
105106 if (pcnt_unit_clear_count (encPcntUnit) != ESP_OK ) {
106- TT_LOG_E ( TAG , " Pulsecounter could not be cleared" );
107+ LOGGER . error ( " Pulsecounter could not be cleared" );
107108 }
108109
109110 if (pcnt_unit_start (encPcntUnit) != ESP_OK ) {
110- TT_LOG_E ( TAG , " Pulsecounter could not be started" );
111+ LOGGER . error ( " Pulsecounter could not be started" );
111112 }
112113}
113114
0 commit comments