TM1637TinyDisplay icon indicating copy to clipboard operation
TM1637TinyDisplay copied to clipboard

compile issue on raspberry pi pico

Open goephs opened this issue 2 years ago • 5 comments

  • I have been using your library with arduino, STM32 Nucleo 64 F103rb without issues for several years and I love the library!! I was transferring code to raspberry pi Pico and got these compile errors. I'm using visual studio with visual micro extension. Any suggestions to modify the .h file is welcome.

tm1637tinydisplay.cpp:29: In file included from
tm1637tinydisplay.h: 34:6: error: expected unqualified-id before 'const
   34 |   (*(const unsigned char *)(addr)) \\ workaround for non-AVR
   |      ^~~~~
pgmspace.h:116: note  in expansion of macro pgm_read_byte
   116 | static inline unsigned char pgm_read_byte(const void *addr) {
   |                             ^~~~~~~~~~~~~

goephs avatar Nov 30 '23 22:11 goephs

This is the header definition:

https://github.com/jasonacox/TM1637TinyDisplay/blob/f13913e803ccfbe56f9ac924371738d19d66a597/TM1637TinyDisplay.h#L26-L35

Ah, this may be a bug. I don't know that I have a device that would really test that last else case (not AVR and not ESP). Here are some suggestions to try:

  • Try to removing lines 32 to 34. The pgmspace.h you have seems to define pgm_read_byte().
  • Line 33 is doing a \ to push the definition to the next line. That may not be supported. Try moving the contents of line 34 to line 33 (remove the \).

If either of these work, we can update the project to fix that.

jasonacox avatar Dec 01 '23 03:12 jasonacox

Hello Jason,

  • Commenting out lines 32-34 in both .h files compiles successfully.

//#else//#define pgm_read_byte(addr)                                                    //  (*(const unsigned char *)(addr)) // workaround for non-AVR

  • Your second suggestion looks like the code below starting at line 32:

#else#define pgm_read_byte(addr)  (*(const unsigned char *)(addr)) // workaround for non-AVR// (moved contents to line above and removed )#endif

The compiler is unhappy with the expansion:

tm1637tinydisplay.cpp:29: In file included from tm1637tinydisplay.h: 33:32: error: expected unqualified-id before 'const   33 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) \ workaround for non-AVR   |                                ^~~~~pgmspace.h:116: note  in expansion of macro pgm_read_byte   116 | static inline unsigned char pgm_read_byte(const void addr) {   |                             ^~~~~~~~~~~~~ tm1637tinydisplay.h: 33:32: error: expected ')' before 'const   33 | #define pgm_read_byte(addr) ((const unsigned char *)(addr)) \ workaround for non-AVR   |                               ~^~~~~pgmspace.h:116: note  in expansion of macro pgm_read_byte   116 | static inline unsigned char pgm_read_byte(const void *addr) {   |                             ^~~~~~~~

In a few days, I'll test with a tm1637 display on the pico and let you know.  My functionality needs are only to display integers and float numbers.  Occasionally a degree sign (little o shifted up). Kind regards,Gavin Watson (goephs)

On Thursday, November 30, 2023 at 10:48:32 PM EST, Jason Cox ***@***.***> wrote:  

This is the header definition:

https://github.com/jasonacox/TM1637TinyDisplay/blob/f13913e803ccfbe56f9ac924371738d19d66a597/TM1637TinyDisplay.h#L26-L35

Ah, this may be a bug. I don't know that I have a device that would really test that last else case (not AVR and not ESP). Here are some suggestions to try:

  • Try to removing lines 32 to 34. The pgmspace.h you have seems to define pgm_read_byte().
  • Line 33 is doing a \ to push the definition to the next line. That may not be supported. Try moving the contents of line 34 to line 33 (remove the ).

If either of these work, we can update the project to fix that.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

goephs avatar Dec 01 '23 22:12 goephs

Thanks @goephs ! I suspect you just needed to remove that #else condition. The formatting in your email didn't come through very well but I think I get the gist.

Let us know if it work on the device.

jasonacox avatar Dec 02 '23 03:12 jasonacox

Hello Jason,I tested the tm1637 display on the PICO with the #else condition removed and it worked perfectly with both your demo script and test script.  I'm good to go now.  Thank you for your help!

On Friday, December 1, 2023 at 10:42:03 PM EST, Jason Cox ***@***.***> wrote:  

Thanks @goephs ! I suspect you just needed to remove that #else condition. The formatting in your email didn't come through very well but I think I get the gist.

Let us know if it work on the device.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

goephs avatar Dec 03 '23 20:12 goephs

Thanks @goephs !

jasonacox avatar Dec 04 '23 02:12 jasonacox