Skip to content

Commit

Permalink
#22 increasing the overflow even more
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Jun 23, 2020
1 parent 2e5adb5 commit e48eb40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/ESP32Encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void IRAM_ATTR pcnt_example_intr_handler(void *arg) {
/* Save the PCNT event type that caused an interrupt
to pass it to the main program */

int status=0;
int64_t status=0;
if(PCNT.status_unit[i].h_lim_lat){
status=ptr->r_enc_config.counter_h_lim;
}
Expand Down Expand Up @@ -189,28 +189,28 @@ void ESP32Encoder::attachFullQuad(int aPintNumber, int bPinNumber) {
attach(aPintNumber, bPinNumber, full);
}

void ESP32Encoder::setCount(int32_t value) {
void ESP32Encoder::setCount(int64_t value) {
count = value - getCountRaw();
}
int32_t ESP32Encoder::getCountRaw() {
int64_t ESP32Encoder::getCountRaw() {
int16_t c;
pcnt_get_counter_value(unit, &c);
return c;
}
int32_t ESP32Encoder::getCount() {
int64_t ESP32Encoder::getCount() {
return getCountRaw() + count;
}

int32_t ESP32Encoder::clearCount() {
int64_t ESP32Encoder::clearCount() {
count = 0;
return pcnt_counter_clear(unit);
}

int32_t ESP32Encoder::pauseCount() {
int64_t ESP32Encoder::pauseCount() {
return pcnt_counter_pause(unit);
}

int32_t ESP32Encoder::resumeCount() {
int64_t ESP32Encoder::resumeCount() {
return pcnt_counter_resume(unit);
}

12 changes: 6 additions & 6 deletions src/ESP32Encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class ESP32Encoder {
void attachFullQuad(int aPintNumber, int bPinNumber);
void attachSingleEdge(int aPintNumber, int bPinNumber);
//void attachHalfQuad(int aPintNumber, int bPinNumber);
int32_t getCount();
int32_t getCountRaw();
int32_t clearCount();
int32_t pauseCount();
int32_t resumeCount();
int64_t getCount();
int64_t getCountRaw();
int64_t clearCount();
int64_t pauseCount();
int64_t resumeCount();

boolean isAttached(){return attached;}
void setCount(int32_t value);
void setCount(int64_t value);
static ESP32Encoder *encoders[MAX_ESP32_ENCODERS];
static bool attachedInterrupt;
gpio_num_t aPinNumber;
Expand Down

0 comments on commit e48eb40

Please sign in to comment.