You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Does not compile for RP2040 (SREG was not declared) #7
Arduino: 1.8.19 (Linux), Board: "Raspberry Pi Pico, 2MB (no FS), 120 MHz, Small (-Os) (standard), Disabled, Disabled, Disabled, Disabled, Disabled, None, Adafruit TinyUSB, IPv4 Only, Default (UF2)"
In file included from /home/rena/projects/micros/arduino/ToneGen/ToneGen.ino:4:
/home/rena/Arduino/libraries/BasicEncoder/BasicEncoder.h: In member function 'int8_t BasicEncoder::get_change()':
/home/rena/Arduino/libraries/BasicEncoder/BasicEncoder.h:91:20: error: 'SREG' was not declared in this scope
91 | uint8_t sreg = SREG; // save the current interrupt enable flag
| ^~~~
/home/rena/Arduino/libraries/BasicEncoder/BasicEncoder.h: In member function 'int BasicEncoder::get_count()':
/home/rena/Arduino/libraries/BasicEncoder/BasicEncoder.h:114:20: error: 'SREG' was not declared in this scope
114 | uint8_t sreg = SREG; // save the current interrupt enable flag
| ^~~~
/home/rena/Arduino/libraries/BasicEncoder/BasicEncoder.h: In member function 'void BasicEncoder::reset()':
/home/rena/Arduino/libraries/BasicEncoder/BasicEncoder.h:122:20: error: 'SREG' was not declared in this scope
122 | uint8_t sreg = SREG; // save the current interrupt enable flag
| ^~~~
It may appear to work but is likely fail at some point because you would not then be preventing an interrupt while you read the pins. Reading encoders is very time sensitive.
I would suggest you searcgh for an encoder library that specifically supports the RP2040. This one does not.
Activity
micromouseonline commentedon Dec 24, 2024
Sorry. The library was only written for the ATmega328 processor to fulfil a particular need.
I have added a note to the readme. which should probably always have been there.
RenaKunisaki commentedon Dec 26, 2024
It looks like all you need to make it work on any Arduino board is:
micromouseonline commentedon Dec 26, 2024
SREG is a hardware register on the ATmega328. Here it is used to control the interrupt enable status.
RenaKunisaki commentedon Jan 7, 2025
Just making that change lets it work for me.
micromouseonline commentedon Jan 7, 2025
It may appear to work but is likely fail at some point because you would not then be preventing an interrupt while you read the pins. Reading encoders is very time sensitive.
I would suggest you searcgh for an encoder library that specifically supports the RP2040. This one does not.