Font AVR error for ESP32 Thing Plus and HyperDisplay

I was using arduino’s library manager to install all the Hyperdisplay libraries for use with the new Transparent Oled. I found a compilation error due to the ESP32 not having a default font.

I noticed that the library only included <avr/pgmspace.h> which was causing my compilation errors.

I rewrote some of the Font.h file to the following:

#if (defined(AVR))

#include <avr\pgmspace.h>

#else

#include <pgmspace.h>

#endif

The sketch compiled for the ESP32 Thing Plus and the Transparent OLED jumped to life!

-Nate Damen

Hi Nate and thanks for posting,

That’s a good catch! I will reach out to the engineer who wrote that library with this issue and we will see if we can update the library to fix the problem.

Thanks again for bringing this to our attention!

Hey, thanks for posting about this! The default font support is definitely a chink in the armor of HyperDisplay, so to speak. The goal for HyperDisplay is to be very portable and extendable. Sadly as you know ESP32 does not support <avr/pgmspace.h> (and who would put in the effort, given the big advances in uC memory these days?) Here’s how HyperDisplay is supposed to handle the case where <avr/pgmspace.h> is not available:

#if HYPERDISPLAY_USE_PRINT                  // 
    #if HYPERDISPLAY_INCLUDE_DEFAULT_FONT   
        #if __has_include ( <avr/pgmspace.h> )
            #include "util/font5x7.h"
            #define HYPERDISPLAY_DEFAULT_FONT_WIDTH 5
            #define HYPERDISPLAY_DEFAULT_FONT_HEIGHT 8
        #endif /* __has_include( "util/font5x7.h" ) */
    #endif
#endif

This is matched in the hyperdisplay.cpp file in lines [803 to 868], and when the program space header is not available there is a default implementation that shows nothing.

Can you tell me more about your compilation error? I’d certainly like to fix it but I’m not sure yet why the current method failed. Can you post the error message? Or, perhaps, do you mean that it just didn’t print? (Not printing text is currently the expected behavior when pgmspace is not available)

So, it seems apparent that we should include a default portable font. I’ll try to set up some configuration that allows you to opt-in to a RAM font if pgmspace doesn’t exist.

The exact error I am getting is as follows:

In file included from C:\Users\nated\Documents\Arduino\libraries\SparkFun_HyperDisplay_Library\src/hyperdisplay.h:39:0,

from C:\Users\nated\Documents\Arduino\libraries\SparkFun_HyperDisplay_SSD1309_Arduino_Library\src/HyperDisplay_SSD1309.h:19,

from C:\Users\nated\Documents\Arduino\libraries\SparkFun_HyperDisplay_Transparent_Grahical_OLED_Library\src/HyperDisplay_UG2856KLBAG01.h:19,

from C:\Users\nated\Documents\Arduino\Test_AR_Twitch_Chat\Test_AR_Twitch_Chat.ino:36:

C:\Users\nated\Documents\Arduino\libraries\SparkFun_HyperDisplay_Library\src/util/font5x7.h:23:26: fatal error: avr\pgmspace.h: No such file or directory

compilation terminated.

exit status 1

Error compiling for board Adafruit ESP32 Feather.