Skip to content
Aleksei Dynda edited this page Aug 28, 2019 · 1 revision

FAQ

There is garbage on the display

There can be several root causes for the garbage observed:

  • Check max i2c or spi interface freqyency, supported by your display
  • Check if correct lcdgfx library mode is used with specific API functions

Frequency can be changed inside of lcdgfx library. You need to find the code, which works for your platform. In general lcdgfx library sets the frequency, supported by your display. But there are a lot of hardware solutions from reach amount of lcd display manufactures. We assume that frequency tuning may be necessary in lcdgfx library code.

How to reduce code size

The main rule here is "the less different functions you use from lcdgfx library, the less flash space it requires".

For atmega328p ssd1331 display initialization code needs 392 bytes, but you also need to initialize SPI interface to communicate with display module. Arduino SPI library for atmega328p eats another 892 bytes. Adding single display.clear() to your program need another 88 bytes of flash (calling display.clear() twice from the sketch needs 88 bytes for first call + 4 bytes for second call). Thus, the idea is clear: it is ok to call specific function several times from source code, but number of different used functions should be reduced.

There is very helpful script for AVR controllers in lcdgfx/tools directory: avrparse.bat for Windows and avrparse.sh for Linux, it provides detailed information on functions and data variables space consumption.

Not to use Arduino IDE for compilation, or use workaround in lcdgfx library

Arduino IDE is specific IDE, limiting compiling capabilities too heavy. Lcdgfx library supports many interfaces, and compile all supported interfaces for your chosen platform. It is deal of the linker to remove not used code. But some Arduino IDE core libraries do not allow linker to throw out unused code due to their implementation (Serial.h, Wire.h, etc.). So, if you do not use Wire interface to reduce binary size, you need to tell lcdgfx library to not compile Wire support at all. This can be done in two ways:

  1. Not to use Arduino IDE (arduino builder), and pass SSD1306_DISABLE_WIRE_SUPPORT (for example) definition when compiling library
  2. Use workaround way and edit ssd1306_hal/UserSettings.h file and comment CONFIG_ARDUINO_WIRE_LIBRARY_ENABLE and/or CONFIG_ARDUINO_SPI_LIBRARY_ENABLE.

How to debug application

When working with micro controllers debugging application takes much time. It is big deal to get logs from the program running on micro controller. There are several ways to solve the problem:

  1. use hardware jtag debugger (not always available by hand)
  2. use serial port communication to get run-time logs (log places of interest to Serial port, and collect logs on PC).
  3. use SDL emulation mode, embedded to lcdgfx library, and run your code on PC.

The third-way greatly speeds up code development, since you use all standard PC debugging tools, but requires some accuracy from developer when working with hardware. All lcdgfx examples can be run on PC (both in Linux and Windows OS), you can use them as start point for your project.

How to add new font

Refer to How to create new font instructions.

How to use my own i2c/spi instead of built-in ones

TODO

How to run demos on raspberry pi

You need to through several simple steps prior to running demo code on raspberry:

I2C

  1. Enable i2c in raspi-config (please, refer to official instructions)
  2. reboot your raspberry
  3. run sudo modprobe i2c-dev to make i2c-1 interface available in /dev/.

SPI

  1. Enable SPI in raspi-config (please, refer to official instructions)
  2. reboot your raspberry

Now compile the demo, you want, and run it like in this example:

cd lcdgfx/tools
./build_and_run.sh -p linux demos/ssd1306_demo
sudo ../bld/demos/ssd1306_demo.out

Note: sudo is required only for SPI-based demo, because demo needs to export gpio to control RST, D/C pins.

How to port library to new platform

TODO