Encoder Library

I use the Encoder Library on a Project that uses a Photon.
I would like to write the project for a Argon, but I get a error when Compiling for a Argon…

Encoder.h:35:63: 'NRF5x_Pin_Info {aka struct NRF5x_Pin_Info}' has no member named 'gpio_peripheral'
error
Encoder.h:35:63: 'NRF5x_Pin_Info {aka struct NRF5x_Pin_Info}' has no member named 'gpio_peripheral'

I’m not sure where to start looking for a fix for this.
thanks in advance for any help.

You could check with @jvanier who ported the library to Particle

He did ask me :slight_smile: I don’t have time at the moment to look into porting the encoder library to the Nordic microcontroller but I will gladly merge a pull request with changes and release a new version.

I’ll give it a shot this afternoon. It doesn’t look too hard to fix.

4 Likes

Have you had a chance to look at this @rickkas7 ?
I’d like to work on this project during thanksgiving, but I need this library.
Could you point me in the right direction, maybe I can fix it?

Since the Encoder library is really just the header file Encoder.h, I’d grab the file from the library and add it into your project directly and remove the Encoder library. Then change this little block of code at the top of the file:

#define IO_REG_TYPE                     uint32_t

#if defined(HAL_PLATFORM_NRF52840) && HAL_PLATFORM_NRF52840
# define PIN_TO_BASEREG(pin)             (0)
# define PIN_TO_BITMASK(pin)             (pin)
# define DIRECT_PIN_READ(base, mask)     pinReadFast(mask)
#else
# define PIN_TO_BASEREG(pin)             (&(HAL_Pin_Map()[pin].gpio_peripheral->IDR))
# define PIN_TO_BITMASK(pin)             (HAL_Pin_Map()[pin].gpio_pin)
# define DIRECT_PIN_READ(base, mask)     (((*(base)) & (mask)) ? 1 : 0)
#endif
2 Likes

I added the Code, but now I get a error…

../wiring/inc/spark_wiring.h:57:13: error: 'DAC1' was not declared in this scope
 #define DAC DAC1

Ignore the above error, I was getting that because I had DAC in Argon code. forgot that Argon doesn’t have hardware DAC, but Now I’m getting

expression must be a pointer to a complete object type

on line 57, 58, 59, 60 on the Encoder Library.

Seems like I may not have the correct pins assigned to the Encoder Object. Where Can I find which pins can be used as interrupt pins? the Documentation for attachInterrupt() only lists the non-mesh hardware’s Interrupt pins.

Per @rickkas7 advice above, I have submitted a pull request to @jvanier on Github. Hopefully others will be able to use the library soon without having to dig.

Thanks! I merged the PR and published a version 2.0.0 of the library with Gen 3 support. Thanks @rickkas7 and @Leo_G for the porting and testing work!