Giter Site home page Giter Site logo

adafruit / adafruit-gfx-library Goto Github PK

View Code? Open in Web Editor NEW
2.3K 159.0 1.5K 2.42 MB

Adafruit GFX graphics core Arduino library, this is the 'core' class that all our other graphics libraries derive from

Home Page: https://learn.adafruit.com/adafruit-gfx-graphics-library

License: Other

C++ 15.03% C 84.59% Makefile 0.02% Shell 0.07% Python 0.27% CMake 0.02%
arduino-library

adafruit-gfx-library's Introduction

Adafruit GFX Library Build Status

This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions).

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, check license.txt for more information. All text above must be included in any redistribution.

Recent Arduino IDE releases include the Library Manager for easy installation. Otherwise, to download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h. Place the Adafruit_GFX library folder your ArduinoSketchFolder/Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE.

You will also need to install the latest Adafruit BusIO library. Search for "Adafruit BusIO" in the library manager, or install by hand from https://github.com/adafruit/Adafruit_BusIO

Useful Resources

  • Image2Code: This is a handy Java GUI utility to convert a BMP file into the array code necessary to display the image with the drawBitmap function. Check out the code at ehubin's GitHub repository: https://github.com/ehubin/Adafruit-GFX-Library/tree/master/Img2Code

  • drawXBitmap function: You can use the GIMP photo editor to save a .xbm file and use the array saved in the file to draw a bitmap with the drawXBitmap function. See the pull request here for more details: #31

  • 'Fonts' folder contains bitmap fonts for use with recent (1.1 and later) Adafruit_GFX. To use a font in your Arduino sketch, #include the corresponding .h file and pass address of GFXfont struct to setFont(). Pass NULL to revert to 'classic' fixed-space bitmap font.

  • 'fontconvert' folder contains a command-line tool for converting TTF fonts to Adafruit_GFX header format.

  • You can also use this GFX Font Customiser tool (web version here) to customize or correct the output from fontconvert, and create fonts with only a subset of characters to optimize size.


Roadmap

The PRIME DIRECTIVE is to maintain backward compatibility with existing Arduino sketches -- many are hosted elsewhere and don't track changes here, some are in print and can never be changed! This "little" library has grown organically over time and sometimes we paint ourselves into a design corner and just have to live with it or add progressively more ungainly workarounds.

We are grateful for everyone's contributions, but pull requests for the following will NOT be merged:

  • Additional or incompatible font formats (see Prime Directive above). There are already two formats and the code is quite bloaty there as it is. This also creates liabilities for tools and documentation. What's there isn't perfect but it does the job.

  • Additional or incompatible bitmap formats, for similar reasons. It's getting messy.

  • Adding background color to custom fonts to erase prior screen contents. The ONLY acceptable methods are to clear the area with a filled rect, or (to avoid flicker) draw text into a GFXcanvas1 and copy to screen with drawBitmap() w/background color. This is on purpose and by design. We've discussed this. Glyphs can overlap.

  • Scrolling, whether hardware- or software-based. Such implementations tend to rely on hardware-specific features (not universally available), read access to the screen's framebuffer (ditto) and/or the addition of virtual functions in GFX which them must be added in every subclass, of which there are many. The GFX API is largely "set" at this point and this is just a limitation we live with now.

  • Please don't reformat code for the sake of reformatting code. The resulting large "visual diff" makes it impossible to untangle actual bug fixes from merely rearranged lines. clang-format will be the final arbiter.

  • Please no more pentagram-drawing PRs. Any oddly-specific drawing functions can go in your own code and aren't helpful in a library context.

If you must have one of these features, consider creating a fork with the features required for your project...it's easy to keep synced with the upstream code.

adafruit-gfx-library's People

Contributors

billydonahue avatar bitbank2 avatar blueandi avatar caternuson avatar daft-freak avatar evaherrada avatar grafalex82 avatar hathach avatar homeodor avatar johnbacas avatar jonniezg avatar jrcutler avatar kurte avatar ladyada avatar makermelissa avatar marcmerlin avatar markwal avatar michaelkamprath avatar paintyourdragon avatar prenticedavid avatar rbultman avatar rgiese avatar roddi avatar schlammbad avatar siddacious avatar subsonicpulse avatar tdicola avatar tyeth avatar vortigont avatar waynepiekarski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit-gfx-library's Issues

can you add raspberry pi support?

I want to use the library with ssd1306 library on raspberry pi ,but unfortunalty there's no raspberry pi version,i have to port it to raspberry pi with wiringpi ,but there's many many errors while compiling...
can you add raspberry pi support?

Println off-by-one wrapping error

Moving this bug adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library#16 from the PCD8544 library over to the GFX library since the GFX library handles the text rendering. The issue is that println for a string of text that is exactly the width of characters as the display will print two newlines, one for hitting the edge of the display and another because of the explicit newline in the function. This makes it difficult to display variable strings without carefully keeping track of the length of strings being printed.

I assume to resolve this we need to handle the case where the printed string is the same width as the display and suppress the end of display newline. I haven't looked into the GFX library yet to see if how Arduino's Print class is implemented might complicate catching this state. Opening this bug for now to come back to later though.

Error in char map

Today I wanted to write a ยฐC ("degree Celsius"). So I looked up code page 437 and found it should be character number 248. But it did not work.

After some investigation I learned that the characters starting from 177 are shifted due to a missing character in the 176 to 178 range.

For easy reference have a look at the code page in Wikipedia http://en.wikipedia.org/wiki/Code_page_437 and compare it to this photo: http://forum.arduino.cc/index.php/topic,173537.0.html

0xb0/0xb1/0xb2 should have "gray" blocks but 0xb2 is missing.

Solution: in glcdfont.c add a line

    0x08, 0x14, 0x2A, 0x14, 0x22,
    0x22, 0x14, 0x2A, 0x14, 0x08,
190 0x95, 0x00, 0x22, 0x00, 0x95,  // <-----------
    0xAA, 0x00, 0x55, 0x00, 0xAA,
    0xAA, 0x55, 0xAA, 0x55, 0xAA,

and remove the five bytes at the end.

fontconvert errors

Greetings,
I attempted to execute fontconvert but am running into problems. When I run 'sh makefonts.sh', the following error is received:

$ sh makefonts.sh
makefonts.sh: 18: makefonts.sh: Syntax error: "(" unexpected

Please advise.
*
Linux Mint17 x64

Text wrap change in version 1.1.x

display.clearDisplay();
display.setTextSize(1);
display.setTextColor(BLACK);
display.print("12345678901234");

On a PCD8544 display with GFX 1.0.2 the above code results in the following

Line 1: 12345678901234

After upgrading to GFX 1.1.5, the same code results in the following

Line 1: 1234567890123
Line 2: 4

There is a report that this is a PCD8544 problem but it is caused by the GFX library.

adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library#36

pausePlaying function has issue with else statement - Wrong library, meant VS1053

The pausePlaying function has an issue where the else statement would set playingMusic to true despite the currentTrack has finished if you call pausePlaying with false.
This causes the call to the function stopped to return false despite the fact that the currentTrack has
stopped because playingMusic was flipped to true despite that not being true.

This is my fix. I tried to commit to the git but I don't have the permissions:

void Adafruit_VS1053_FilePlayer::pausePlaying(boolean pause) {
if (pause)
playingMusic = false;
else {
// Added this because
// calling pausePlaying with false would
// caused the call to stopped to return
// false despite the fact that the track
// has indeed stopped playing.
// Could add else{ playingMusic = false; }
// but it seems unnecessary.
if (currentTrack)
{
playingMusic = true;
}
feedBuffer();
}
}

How do people most commonly use/bundle Adafruit-GFX in projects?

Do they install it as a library from the Arduino IDE? And then when you distribute your source do you list in the README everything they need to install the library or do you vendor it locally with your own code?

I'm struggling with this since the libraries I write are often tons of little files to separate everything nicely... and that's much harder to vendor than one big library in two files (since the IDE provides no good way to put things in subdirectories that I've found).

Plus if Arduboy was to decide to use Adafruit-GFX we'd then had to deal with this exact problem. Tell people to add the library vs vendor in our own source tree...

Thoughts?

Create a class that doesn't subclass Print

Could we please get a class to use that doesn't subclass Print.

class Adafruit_GFXWithoutPrint
{
// all the graphics stuff
}

class Adafruit_GFX: public Print, public Adafruit_GFXWithoutPrint 
{
// printing stuff
}

Obviously the names could change. Just subclassing Print gets you a whole dependency chain that most people don't realize:

  • write() - it's virtual, so it always gets linked via the vtable, even if you never print a single thing
  • drawChar() - called from write
  • font - used by drawChar
  • drawRect - used by drawChar (for x2+ size fonts)
  • drawFastHLine - used by drawRect
  • drawFastVLine - used by drawRect
  • drawLine - used by drawFast*Line
  • swap - used by drawLine
  • drawPixel - used by drawLine

A program that is only moving sprites around the screen might not ever be calling ANY of those methods (assuming a hardware optimized drawImage) - yet they are now linked in and easily taking up 2kb or more. Even if using the built in drawImage for most of your graphics the only thing from above you really need is drawPixel, but instead you get everything plus the kitchen sink.

I don't think most people understand or expect this behavior - even those that already understand the compiler doesn't link in what your program never calls. I had to get help from someone who knew a lot more C++ than me to find out that the virtual function table of the subclass is what is holding a pointer to write() and that's why the compiler can't remove it like it can for most functions that aren't used.

Thoughts?

dr

I didn't find any documentation on this but If I didn't make my bitmap a multiple of 8 it would render incorrectly. Is this by design or a bug?

For example I had a bitmap of 31x28

Accelerates text output.

If you replace this function in the project, the text is displayed in the 2-3 times faster. Depending on whether there is a back color.

// Draw a character
void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
uint16_t color, uint16_t bg, uint8_t size)
{
if((x >= _width) || // Clip right
(y >= _height) || // Clip bottom
((x + 6 * size - 1) < 0) || // Clip left
((y + 8 * size - 1) < 0)) // Clip top
return;

if(!_cp437 && (c >= 176)) c++; // Handle 'classic' charset behavior
uint8_t line;
bool Fill; uint8_t SF;
for (int8_t i=0; i<6; i++, x+=size)
{
if (i == 5) line = 0x0;
else line = pgm_read_byte(font+(c*5)+i);
Fill = line & 0x1; SF = 0;
for (int8_t j = 1, jy=size; j<9; j++, jy+=size)
{
line >>= 1;
if ((Fill == (line & 0x1)) && j!=8) continue;
if (Fill) fillRect(x, y+SF, size, jy-SF, color);
else if (bg != color) fillRect(x, y+SF, size, jy-SF, bg);
Fill = line & 0x1; SF = jy;
}
}
}

Good luck!

Should cursor_x and cursor_y be public?

Hi,
Im using the library together with the 0.96" 16-bit Color OLED with the SSD1331 driver chip. I looked for a way to get the current cursor position and couldn't find one. So should these two be public or should there be a get Method?
Or am I missing something?

No definitiong for pgm_read_word

If we look in Adafruit_GFX.cpp we find reference to a function called pgm_read_word, However, it appears that if we are not compiling on an AVR, this function is not defined.

2.2" tft LCD display

we need a wiring diagram and code that does not give errors every time we load it. I cannot get it to work without it giving me errors so right now after spending 25 dollars it is a pretty paper weight.

ft2build.h file is missing

Hi,
I'm giving a try to a simple Arduino-based Oscilloscope project, the " fontconvert.c " file refers to a " ft2build.h " file to be included. (see line 23: #include <ft2build.h>)

Where can we find this file if Not present amongst the already present libraries on the computer ?

Thanks in advance.

Best regards,
HP_

Dynamic Display

The ADAFRUIT_GFX/RGBPanelMatrix Library uses the PROGMEM to display the text.
Now how a char/string be displayed dynamically say how the input from keyboard be displayed in the LED matrix panel when being typed??

Please help with some coding logic

Remove use of virtual functions

Pasting my comment from the other issue. It was a bit off topic there.

Please read:
http://www.learncpp.com/cpp-tutorial/122-virtual-functions/

We could also just remove the "virtual". This isn't really the intended use for virtual - since there is no polymorphism happening here. Someone is going to subclass GFX and then all the calls are going to be against that class. You aren't going to have multiple AdaFruitGFX subclasses being passed around where the function dispatch needs to happen at runtime. The function dispatch can all be resolved statically at compile time, the unused functions can be discarded, and the virtual dispatch table is also wasted space that will be saved.


I just did a test now with the Arduboy lib (in my branch). I have core class that the main class builds on... very low-level hardware stuff is in core (not even drawPixel), graphics stuff is in the subclass (including drawPixel). The Ardubreakout sketch compiled (before any changes) is 17,498.

I modified core to add this single line:

# subclass must implement this virtual function
virtual void drawPixel(int x, int y, uint8_t color) = 0;

That's the only change. The compile size quickly jumps to 17,592. 94 bytes larger just for dynamic dispatch of a single function. That's not even counting the increased overhead of virtual function dispatch.

Thoughts?

drawBitmap PROGMEM constraint

I'm trying to define a class that has a draw method which draws a bitmap to the matrix. But when I run that function, I get very odd, though consistent results. Upon reviewing the code, it's indicated

[drawBitmap] ... Draw a 1-bit color bitmap at the specified x, y position from the provided bitmap buffer (must be PROGMEM memory)...

Why does it only work with data in PROGMEM?

font must be const to be static

exist some problens with only "static unsigned char font[] PROGMEM"
It need to be const static to the compiler work.
const static unsigned char font[] PROGMEM

Issue with arduino 1.0.5

If I follow the instructions for naming and placing the Adafruit_GFX library found in the README file then the command:

include <Adafruit_GFX.h>

Compiles fine on Arduino version 1.0.4 but breaks on Arduino version 1.0.5

I get a list of error messages originating from:

arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp

I believe that this trouble is related to 1.0.5 including a version of the Adafruit_GFX library. I spent most of the today trying to figure out how to make your library work on 1.0.5 but I have been unable to.

missing character in glcdfont.c

The glcdfont.c file appears to be missing character number (decimal) 178. This causes all characters after that spot to be off by one. For example, the degree character is supposed to be at decimal 248, but it is decimal 247. Based on other characters in the font, I'm assuming that the character set is supposed to be close to "Code Page 437" standard (see: http://en.wikipedia.org/wiki/Code_page_437 ) This issue can be easily fixed by adding a line after line 191 (which is character 177). The new line can be something like: 0xFF, 0x55, 0xFF, 0x55, 0xFF, I wasted a lot of time tracking down this bug and hopefully the fix can save others the same frustration.

underscores?

If I clone this repo directly and try to compile using the Arduino Makefile, I get this:

make: *** No rule to make target '/home/thoth/sketchbook/libraries/Adafruit_GFX_Library/Adafruit_GFX.h', needed by 'build-uno/userlibs/Adafruit_SSD1306/Adafruit_SSD1306.o'.  Stop.

But if I swap out the dashes for underscores mv Adafruit-GFX-Library Adafruit_GFX_Library and change the makefile that is calling it:

ARDUINO_LIBS = Average Arduino-PID-Library SPI Wire Time Adafruit_SSD1306 Adafruit_GFX_Library

now my compiles are fine?

getTextBounds returns no width

For default font:
If no text wrap occurrs, then only lineWith is incremented by textsize * 6.
But when the string ends, *w is returned with maxWith -1, which is still at the initial 0.

international character sets

happy to see you adapted some of my code from ftGFX!
I'll have a look at the new code in Adafruit_GFX and, if you don't mind, might start contributing to this codebase (no use to have multiple forks that do the same thing).
My first priority (and the actual reason I forked from Paul's mfGFX fork) was latin-1 characters, and while working on the code, I figured, it was quite a bit of effort to support more than just this one character set.
My approach was to create an i18n library that would provide the mapping functions.
The initial intention was to leave all the print / writeChar etc. routines the same (that is: not enable them for UTF-8) in order not to create a comaptibility hell but instead frontend them with a UTF8toISO() call that would translate UTF8 to a predefined 256 character table. I chose this way since it allows me to still use a contiguous block of memory as my character bitmap and adress it using a linear mapping table (the GFXglyph table in this version).
The alternative would be a full blown UTF-8 implementation, but that would a) mean potentially huge fonts with thousands of glyphs (not very useful on uControllers) and b) searching through a sparsly populated glyph table for the matching UFT-8 code cell. I still believe that ISO8859-x translation is the better way to go.

So, I'm most happy to start working on this, but woud appreciate if you could let me know if you have any larger scheme that you would i18n to fit into.

missing initializations

cppcheck suggested to add these initializations.

// Constructor when using software SPI.  All output pins are configurable.
Adafruit_ST7735::Adafruit_ST7735(uint8_t cs, uint8_t rs, uint8_t sid,
 uint8_t sclk, uint8_t rst) : Adafruit_GFX(ST7735_TFTWIDTH, ST7735_TFTHEIGHT) {
  csport=0; 
  clkport=0;
  dataport=0;
  rsport=0;

  _cs   = cs;
  _rs   = rs;
  _sid  = sid;
  _sclk = sclk;
  _rst  = rst;
  hwSPI = false;
}


// Constructor when using hardware SPI.  Faster, but must use SPI pins
// specific to each board type (e.g. 11,13 for Uno, 51,52 for Mega, etc.)
Adafruit_ST7735::Adafruit_ST7735(uint8_t cs, uint8_t rs, uint8_t rst) :
    Adafruit_GFX(ST7735_TFTWIDTH, ST7735_TFTHEIGHT) {
  csport=0; 
  clkport=0;
  dataport=0;
  rsport=0;

  _cs   = cs;
  _rs   = rs;
  _rst  = rst;
  hwSPI = true;
  _sid  = _sclk = 0;
}

Font implmentation suggestions

Hi, Great to see fonts are being built in with focus on keeping the library slim for an UNO.

Here are some suggestions:

  1. Render the font characters as a raster scan from left to right (instead of the current top down). Rationale:
    • Rendering fonts will not be quick when using generic functions, so a string drawn from left to right is less visually intrusive (looks like a string is "wiped" smoothly onto the screen).
    • Rendering italic characters that overlap in cartesian coordinate rectangles can be handled easier, especially when drawing background (important!) since it is possible to look ahead and render parts of the next character.
    • A character draw subclass override in a library for a specific controller (such as the ILI9241) can then make good use of the TFT SGRAM orientation features to window and fast render the font.
  2. Edit: getBounds() problem removed from list.
  3. At the moment (without background being rendered) it is necessary to store the bounds of every string printed to screen permit it to be efficiently overwritten by for example a new value from a sensor, to store the old string and overprint in background colour, then swap to foreground and overprint with the new value.

Hope this helps.

Have print() clear existing text

While I was writing the code for my display as it monitors a measurement bench, I learned I needed to manually blank the existing text in a given location. I made a function in my program for this which would fillRect() in the area the text needs to go. In order to do this, I could pass to it the X,Y, but then I have to maintain the cursor coordinates. The Adafruit_GFX class already does this so I added int16_t Adafruit_GFX::getCursor(boolean x) just beneath setCursor(). It returns cursor_x if x is 1 or cursor_y if it isn't.

Very simple:
int16_t Adafruit_GFX::getCursor(boolean x) {
if( x )
return cursor_x;
return cursor_y;
}

That or expand print() to include an option for clearing the space where it's about to print?

Font dimensions

Please make functions for current font char dimensions (char width and height for currently selected font and it's size).
Also be good to have width and height functions for string.

Polymorphism issue with setRotation

Hi there,

Minor issue in Adafruit_GFX.h with the setRotation function.
I think it should be declared virtual to be able to use the polymorphism mecanism correctly with this function (which is overrided in the subclasses ...).

Regards,

Paul

signed char in Adafruit_GFX::drawChar()

I'm not sure if this was by design or by some other reason but Adafruit_GFX::drawChar() uses a signed char instead of a unsigned char:

void Adafruit_GFX::drawChar(int16_t x, int16_t y, char c,
uint16_t color, uint16_t bg, uint8_t size)

Adafruit_GFX::write() which calls Adafruit_GFX::drawChar() takes an unsigned int8 and the code in Adafruit_GFX::drawChar() to calculate (jump) to the right font mapping does not do kindly with "negatives" and thus outputs gibberish for when the character being written's unsigned value is > 127

I've gone ahead and modified my local copy of Adafruit_GFX.h and Adafruit_GFX.cpp to use "unsigned char" and voila, I get more ASCII goodness:

void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
uint16_t color, uint16_t bg, uint8_t size) {

Font size description in glcdfont.c file is incorrect

glcdfont.c claims the described font is 5x7. Looking at the bitmaps, it is 5x8. There are used pixels on both the top and bottom rows, so the full byte width is used at different times.

You can easily tell by looking for any bytes with size >= 80h (msb used) and bytes that are odd (lsb used).

Filled Circle Render Error

Filled circles do not render properly when part of the circle's area lies above the top of a screen. Only the columns that would be fully visible on the screen are filled.

ESP8266 compatibility

For the Adafruit_GFX library to work with the ESP8266 board I have inserted the line "#elif defined ESP8266" in the Adafruit_GFX.cpp file. Otherwise also works commenting the line //#define pgm_read_byte(addr)...

Code in Adafruit_GFX.cpp should look like this:

ifdef AVR

#include <avr/pgmspace.h>

elif defined ESP8266 //Added for compatibility with ESP8266 BOARD

else

#define pgm_read_byte(addr) (*(const unsigned char *)(addr))

endif

I've created the ESP_SSD1306 library which is a copy of the Adafruit_SSD1306 library with some modifications in order to work with the ESP8266 board.

See more details at https://github.com/somhi/ESP_SSD1306

Why are methods such as drawChar() not virtual?

Is it to reduce the memory footprint on memory-starved cores? I have several good reasons to override some of them, in particular, if I'm using a monospaced font, it makes sense to be able to override drawChar() so it first clears the off-pixels of the bounding box of the largest character in the font, rather than blink the entire string.

Shall I send a pull request?

Compiler warnings on ESP8266

It looks like there are some warnings about PROGMEM and flash memory functions being redefined:

C:\Users\Mike\AppData\Local\Temp\build8213996557431336517.tmp\Adafruit_GFX\Adafruit_GFX.cpp.o 
In file included from F:\Code\ArduinoCode\libraries\Adafruit_GFX\Adafruit_GFX.cpp:35:0:
F:\Code\ArduinoCode\libraries\Adafruit_GFX\glcdfont.c:8:0: warning: "PROGMEM" redefined [enabled by default]
  #define PROGMEM
 ^
In file included from C:\Users\Mike\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.4-673-g8cd3697\cores\esp8266/Arduino.h:38:0,
                 from F:\Code\ArduinoCode\libraries\Adafruit_GFX\Adafruit_GFX.h:5,
                 from F:\Code\ArduinoCode\libraries\Adafruit_GFX\Adafruit_GFX.cpp:34:
C:\Users\Mike\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.4-673-g8cd3697\cores\esp8266/pgmspace.h:15:0: note: this is the location of the previous definition
 #define PROGMEM     ICACHE_RODATA_ATTR
 ^
F:\Code\ArduinoCode\libraries\Adafruit_GFX\Adafruit_GFX.cpp:39:0: warning: "pgm_read_byte" redefined [enabled by default]
  #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
 ^
In file included from C:\Users\Mike\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.4-673-g8cd3697\cores\esp8266/Arduino.h:38:0,
                 from F:\Code\ArduinoCode\libraries\Adafruit_GFX\Adafruit_GFX.h:5,
                 from F:\Code\ArduinoCode\libraries\Adafruit_GFX\Adafruit_GFX.cpp:34:
C:\Users\Mike\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.4-673-g8cd3697\cores\esp8266/pgmspace.h:63:0: note: this is the location of the previous definition
 #define pgm_read_byte(addr)                               

Looks like we need to slightly tweak the AVR architecture checks to also handle the ESP8266. Opening this as an issue so we don't lose track of it.

Using fonts on the ESP8266

I'm running adafruit gfx just fine with the standard font. However when i include fonts, and try to use one i get a stack trace.

Exception (28):
epc1=0x4021131d epc2=0x00000000 epc3=0x00000000 excvaddr=0x000046fc depc=0x00000000

ctx: cont 
sp: 3fff3470 end: 3fff3750 offset: 01a0

>>>stack>>>
3fff3610:  4000050c 00000030 00000010 ffffffff  
3fff3620:  3fff61e0 00000000 3ffead13 40202764  
3fff3630:  3fff3660 00000000 3fff4580 4023b45c  
3fff3640:  3d96cd03 00000000 3b020821 ffffff82  
3fff3650:  3fff14f4 3fff4580 3fff56e0 40202141  
3fff3660:  3fff4580 00000000 00000000 40216ae1  
3fff3670:  3fff56e0 3fff4580 3fff56e0 4023b4e8  
3fff3680:  00000013 3fdf9f9f 3fff56e0 402189dc  
3fff3690:  3fff5ba0 3f800000 40216aa0 402172d0  
3fff36a0:  00000012 00000000 00000000 00000012  
3fff36b0:  000003fc 00000001 3ffead12 3fff2724  
3fff36c0:  3fff4580 000000aa 3fff14f4 40218ad1  
3fff36d0:  3f000012 00000013 3ffffc00 40202141  
3fff36e0:  3fffdad0 00000000 3fff62c0 4021a2c8  
3fff36f0:  4021d3c7 00000000 3fff1700 40218b36  
3fff3700:  3fff3e68 00000000 3fff62c0 40218b7b  
3fff3710:  00000000 00000000 3fff14f4 402101a8  
3fff3720:  3fffdad0 00000000 3fff271d 40217ced  
3fff3730:  3fffdad0 00000000 3fff271d 40202954  
3fff3740:  feefeffe feefeffe 3fff2730 402049bc  
<<<stack<<<

The causative function

40211178 <_ZN12Adafruit_GFX5writeEh>:
40211178:   e0c112          addi    a1, a1, -32
4021117b:   61c9        s32i.n  a12, a1, 24
4021117d:   02cd        mov.n   a12, a2
4021117f:   7228        l32i.n  a2, a2, 28
40211181:   7109        s32i.n  a0, a1, 28
40211183:   51d9        s32i.n  a13, a1, 20
40211185:   745030          extui   a5, a3, 0, 8
40211188:   062256          bnez    a2, 402111ee <_ZN12Adafruit_GFX5writeEh+0x76>
4021118b:   0e9566          bnei    a5, 10, 4021119d <_ZN12Adafruit_GFX5writeEh+0x25>
4021118e:   091c32          l16ui   a3, a12, 18
40211191:   180c42          l8ui    a4, a12, 24
40211194:   b03430          addx8   a3, a4, a3
40211197:   095c32          s16i    a3, a12, 18
4021119a:   001286          j   402111e8 <_ZN12Adafruit_GFX5writeEh+0x70>
4021119d:   d30c        movi.n  a3, 13
4021119f:   029537          bne a5, a3, 402111a5 <_ZN12Adafruit_GFX5writeEh+0x2d>
402111a2:   006906          j   4021134a <_ZN12Adafruit_GFX5writeEh+0x1d2>
402111a5:   1a0c32          l8ui    a3, a12, 26
402111a8:   180c82          l8ui    a8, a12, 24
402111ab:   939c        beqz.n  a3, 402111c8 <_ZN12Adafruit_GFX5writeEh+0x50>
402111ad:   089c32          l16si   a3, a12, 16
402111b0:   904880          addx2   a4, a8, a8
402111b3:   904430          addx2   a4, a4, a3
402111b6:   069c32          l16si   a3, a12, 12
402111b9:   0b2437          blt a4, a3, 402111c8 <_ZN12Adafruit_GFX5writeEh+0x50>
402111bc:   085c22          s16i    a2, a12, 16
402111bf:   091c22          l16ui   a2, a12, 18
402111c2:   b02820          addx8   a2, a8, a2
402111c5:   095c22          s16i    a2, a12, 18
402111c8:   089c32          l16si   a3, a12, 16
402111cb:   099c42          l16si   a4, a12, 18
402111ce:   0a1c62          l16ui   a6, a12, 20
402111d1:   0b1c72          l16ui   a7, a12, 22
402111d4:   0c2d        mov.n   a2, a12
402111d6:   006182          s32i    a8, a1, 0
402111d9:   ffc305          call0   40210e0c <_ZN12Adafruit_GFX8drawCharEsshtth>
402111dc:   180c22          l8ui    a2, a12, 24
402111df:   081c32          l16ui   a3, a12, 16
402111e2:   902220          addx2   a2, a2, a2
402111e5:   902230          addx2   a2, a2, a3
402111e8:   085c22          s16i    a2, a12, 16
402111eb:   0056c6          j   4021134a <_ZN12Adafruit_GFX5writeEh+0x1d2>
402111ee:   2b9566          bnei    a5, 10, 4021121d <_ZN12Adafruit_GFX5writeEh+0xa5>
402111f1:   030c        movi.n  a3, 0
402111f3:   22ab        addi.n  a2, a2, 10
402111f5:   085c32          s16i    a3, a12, 16
402111f8:   143020          extui   a3, a2, 0, 2
402111fb:   c02230          sub a2, a2, a3
402111fe:   0228        l32i.n  a2, a2, 0
40211200:   1133d0          slli    a3, a3, 3
40211203:   180c52          l8ui    a5, a12, 24
40211206:   400300          ssr a3
40211209:   912020          srl a2, a2
4021120c:   742020          extui   a2, a2, 0, 8
4021120f:   099c42          l16si   a4, a12, 18
40211212:   822520          mull    a2, a5, a2
40211215:   242a        add.n   a2, a4, a2
40211217:   095c22          s16i    a2, a12, 18
4021121a:   004b06          j   4021134a <_ZN12Adafruit_GFX5writeEh+0x1d2>
4021121d:   d30c        movi.n  a3, 13
4021121f:   029537          bne a5, a3, 40211225 <_ZN12Adafruit_GFX5writeEh+0xad>
40211222:   004906          j   4021134a <_ZN12Adafruit_GFX5writeEh+0x1d2>
40211225:   328b        addi.n  a3, a2, 8
40211227:   14d030          extui   a13, a3, 0, 2
4021122a:   c033d0          sub a3, a3, a13
4021122d:   0338        l32i.n  a3, a3, 0
4021122f:   11ddd0          slli    a13, a13, 3
40211232:   400d00          ssr a13
40211235:   91d030          srl a13, a3
40211238:   74d0d0          extui   a13, a13, 0, 8
4021123b:   02b5d7          bgeu    a5, a13, 40211241 <_ZN12Adafruit_GFX5writeEh+0xc9>
4021123e:   004206          j   4021134a <_ZN12Adafruit_GFX5writeEh+0x1d2>
40211241:   429b        addi.n  a4, a2, 9
40211243:   143040          extui   a3, a4, 0, 2
40211246:   c04430          sub a4, a4, a3
40211249:   0448        l32i.n  a4, a4, 0
4021124b:   1133d0          slli    a3, a3, 3
4021124e:   400300          ssr a3
40211251:   913040          srl a3, a4
40211254:   743030          extui   a3, a3, 0, 8
40211257:   023357          bltu    a3, a5, 4021125d <_ZN12Adafruit_GFX5writeEh+0xe5>
4021125a:   002586          j   402112f4 <_ZN12Adafruit_GFX5writeEh+0x17c>
4021125d:   003a46          j   4021134a <_ZN12Adafruit_GFX5writeEh+0x1d2>
40211260:   5b0000          excw
40211263:   606d        excw
40211265:   401440          excw
40211268:   78c066          bnei    a0, 32, 402112e4 <_ZN12Adafruit_GFX5writeEh+0x16c>
4021126b:   0c6206          j   402143f7 <_ZN15ArduinoOTAClass10_runUpdateEv+0x63>
4021126e:   821a        add.n   a8, a2, a1
40211270:   180c        movi.n  a8, 1
40211272:   047616          beqz    a6, 402112bd <_ZN12Adafruit_GFX5writeEh+0x145>
40211275:   1144d0          slli    a4, a4, 3
40211278:   400400          ssr a4
4021127b:   914070          srl a4, a7
4021127e:   014480          slli    a4, a4, 24
40211281:   314840          srai    a4, a4, 24
40211284:   743030          extui   a3, a3, 0, 8
40211287:   343a        add.n   a3, a4, a3
40211289:   089c62          l16si   a6, a12, 16
4021128c:   823830          mull    a3, a8, a3
4021128f:   069c42          l16si   a4, a12, 12
40211292:   363a        add.n   a3, a6, a3
40211294:   252347          blt a3, a4, 402112bd <_ZN12Adafruit_GFX5writeEh+0x145>
40211297:   030c        movi.n  a3, 0
40211299:   22ab        addi.n  a2, a2, 10
4021129b:   085c32          s16i    a3, a12, 16
4021129e:   143020          extui   a3, a2, 0, 2
402112a1:   c02230          sub a2, a2, a3
402112a4:   0228        l32i.n  a2, a2, 0
402112a6:   1133d0          slli    a3, a3, 3
402112a9:   400300          ssr a3
402112ac:   912020          srl a2, a2
402112af:   742020          extui   a2, a2, 0, 8
402112b2:   099c42          l16si   a4, a12, 18
402112b5:   822820          mull    a2, a8, a2
402112b8:   242a        add.n   a2, a4, a2
402112ba:   095c22          s16i    a2, a12, 18
402112bd:   089c32          l16si   a3, a12, 16
402112c0:   099c42          l16si   a4, a12, 18
402112c3:   0a1c62          l16ui   a6, a12, 20
402112c6:   0b1c72          l16ui   a7, a12, 22
402112c9:   0189        s32i.n  a8, a1, 0
402112cb:   0c2d        mov.n   a2, a12
402112cd:   ffb3c5          call0   40210e0c <_ZN12Adafruit_GFX8drawCharEsshtth>
402112d0:   dd4b        addi.n  a13, a13, 4
402112d2:   1420d0          extui   a2, a13, 0, 2
402112d5:   c0dd20          sub a13, a13, a2
402112d8:   0d48        l32i.n  a4, a13, 0
402112da:   1122d0          slli    a2, a2, 3
402112dd:   400200          ssr a2
402112e0:   912040          srl a2, a4
402112e3:   180c42          l8ui    a4, a12, 24
402112e6:   742020          extui   a2, a2, 0, 8
402112e9:   089c32          l16si   a3, a12, 16
402112ec:   822240          mull    a2, a2, a4
402112ef:   232a        add.n   a2, a3, a2
402112f1:   ffbcc6          j   402111e8 <_ZN12Adafruit_GFX5writeEh+0x70>
402112f4:   424b        addi.n  a4, a2, 4
402112f6:   230c        movi.n  a3, 2
402112f8:   103430          and a3, a4, a3
402112fb:   c04430          sub a4, a4, a3
402112fe:   0448        l32i.n  a4, a4, 0
40211300:   1133d0          slli    a3, a3, 3
40211303:   400300          ssr a3
40211306:   913040          srl a3, a4
40211309:   c0d5d0          sub a13, a5, a13
4021130c:   f43030          extui   a3, a3, 0, 16
4021130f:   74d0d0          extui   a13, a13, 0, 8
40211312:   b0dd30          addx8   a13, a13, a3
40211315:   4d2b        addi.n  a4, a13, 2
40211317:   143040          extui   a3, a4, 0, 2
4021131a:   c04430          sub a4, a4, a3
4021131d:   0448        l32i.n  a4, a4, 0
4021131f:   6d3b        addi.n  a6, a13, 3
40211321:   1133d0          slli    a3, a3, 3
40211324:   400300          ssr a3
40211327:   913040          srl a3, a4
4021132a:   144060          extui   a4, a6, 0, 2
4021132d:   c06640          sub a6, a6, a4
40211330:   0668        l32i.n  a6, a6, 0
40211332:   1144d0          slli    a4, a4, 3
40211335:   400400          ssr a4
40211338:   914060          srl a4, a6
4021133b:   744040          extui   a4, a4, 0, 8
4021133e:   f8e416          beqz    a4, 402112d0 <_ZN12Adafruit_GFX5writeEh+0x158>
40211341:   744030          extui   a4, a3, 0, 8
40211344:   f1a456          bnez    a4, 40211262 <_ZN12Adafruit_GFX5writeEh+0xea>
40211347:   ffe146          j   402112d0 <_ZN12Adafruit_GFX5writeEh+0x158>
4021134a:   7108        l32i.n  a0, a1, 28
4021134c:   120c        movi.n  a2, 1
4021134e:   61c8        l32i.n  a12, a1, 24
40211350:   51d8        l32i.n  a13, a1, 20
40211352:   20c112          addi    a1, a1, 32
40211355:   f00d        ret.n
40211357:   71dc00          excw
4021135a:   124010          excw

all fonts seem to cause it...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.