Skip to content

Commit 074e578

Browse files
authored
Merge pull request #5 from TcMenu/main-sync-with-libsdk
#4 merge with the code base in the libsdk, this is now the primary so…
2 parents feb4a67 + 1a653ac commit 074e578

22 files changed

+342
-1116
lines changed

Adafruit_SSD1306_I2c.h

Lines changed: 0 additions & 80 deletions
This file was deleted.

Adafruit_SSD1306_Spi.h

Lines changed: 0 additions & 86 deletions
This file was deleted.

README.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,49 @@ Although many newer mbed RTOS chipsets have inbuilt hardware LCD drivers, there'
2020
* You can use the regular [Adafruit_GFX introductory guide](https://learn.adafruit.com/adafruit-gfx-graphics-library/overview) as this fork has high compatibility.
2121
* It also integrates well with tcMenu, IoAbstraction and TaskManagerIO.
2222

23-
## Issues
23+
## Different construction between version
2424

25-
Unless you are absolutely sure that the issue is a core Adafruit_GFX issue, please raise the issue here first for us to triage it.
25+
If you prefer to stay temporarily with the old version here is the link, we do recommend you move forward, and the work to do so should be trivial for most, but here is the old link: https://github.com/TcMenu/Adafruit-GFX-mbed-fork/releases/tag/mb0.1.1
2626

27-
## Usage
27+
## Constructing and using a display object
2828

29-
This library can work with SSD1306 and SH1106 displays over I2C or SPI. There's a couple of really simple examples packaged that show basic usage. However, you can look at almost any Adafruit example, as this library is completely compatible, especially wit the IoAbstraction extensions.
29+
For SPI, we recommend that you create the object using `new` once the system is initialised, sometimes trying to use SPI in any way before this results in board crashes. This is as simple as deferring the creation.
30+
31+
// Global variable
32+
AdafruitSSD1306Spi* gfx;
3033

31-
Although not required, this library has the ability to integrate with IoAbstraction by defining USE_IOABSTRACTION_TCMENU, this provides a complete Print interface that is nearly compatible with Arduino's print functions. I'll be honest, we all but assume this flag is set because all our development uses it. To completely remove IoAbstraction, remove the flag in the config header.
34+
// then somewhere during setup
35+
gfx = new AdafruitSSD1306Spi(SPIWithSettings(&spi, PF_13, 10000000), PD_15, PF_12, 64, 128, ENCMODE_UTF8, SSD_1306);
36+
gfx->begin();
3237

33-
Performance, at the moment the SSD1306 class could be significantly optimised. However, our first aim is to get it stable on mbed 5/6, we'll look at performance later.
38+
For I2C you can use either the above method or just use a global variable providing it an I2C pointer and the address of the device:
3439

35-
## What is the purpose of this fork:
40+
AdafruitSSD1306I2c gfx(&i2c, NC, SSD_I2C_ADDRESS, 64, 132, ENCMODE_UTF8, SH_1106);
3641

37-
Every fork should state what it's purpose is. This fork is purely to provide mbed support for a few popular displays, we do not intend to change the core libraries in any way. It allows mbed V6 users to take advantage of the excellent Adafruit_GFX library. We have set it up to work with platformIO, but it should also work with any other build system.
42+
The above assume you want to use UTF-8 encoding.
3843

39-
Important note about bug fixes: do not put in PRs for the core graphics class here, only mbed and display specific fixes will be applied. Instead apply any changes to the core and then we'll re-pull the change here.
44+
Once created usage is almost exactly the same as regular Adafruit_GFX with tcUnicode also available (even down to the print interface).
4045

41-
# Useful Resources
46+
## Issues
4247

43-
- 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
48+
Never raise issues in the core Adafruit_GFX repository as this fork is now very different, please raise the issue here first for us to triage it.
4449

45-
- 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: https://github.com/adafruit/Adafruit-GFX-Library/pull/31
50+
## Usage
51+
52+
This library can work with SSD1306 and SH1106 displays over I2C or SPI. There's a couple of really simple examples packaged that show basic usage. However, you can look at almost any Adafruit example, as this library is completely compatible.
4653

47-
- '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.
54+
This library integrates with IoAbstraction to provide a complete Print interface that is nearly compatible with Arduino's print functions. You also need `IoAbstraction` to use this library.
4855

49-
- 'fontconvert' folder contains a command-line tool for converting TTF fonts to Adafruit_GFX header format.
56+
Performance, at the moment the SSD1306 class could be significantly optimised. However, our first aim is to get it stable on mbed 5/6, we'll look at performance later.
5057

51-
---
58+
## What is the purpose of this fork:
5259

53-
### Roadmap
60+
Every fork should state what it's purpose is. This fork is purely to provide mbed support for a few popular displays, we do not intend to change the core libraries in any way. It allows mbed V6 users to take advantage of the excellent Adafruit_GFX library. We have set it up to work with platformIO, but it should also work with any other build system.
5461

55-
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 ungainly workarounds.
62+
Important note about bug fixes: do not put in PRs for the core graphics class here, only mbed and display specific fixes will be applied. Instead apply any changes to the core and then we'll re-pull the change here.
5663

57-
Highly unlikely to merge any changes for 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). If you *must* have a more sophisticated font format, consider creating a fork with the features required for your project. For similar reasons, also unlikely to add any more bitmap formats, it's getting messy.
64+
# Bitmaps and fonts with the library
5865

59-
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.
66+
- With TcMenu Designer you can now export and even create bitmaps suitable for use with this library. 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 main tcMenu repo to download.
67+
- '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(). As of 2024 you must choose a font, either TcUnicode or Ada Gfx. This fork now always uses the tcUnicode library for text.
68+
- You can use TcMenu Designer to export custom fonts, it has a font export utility.

cmake/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
add_library(AdafruitGFXNativePort
3+
../src/Adafruit_SSD1306.cpp
4+
../src/Adafruit_GFX.cpp
5+
../src/oled/AdafruitSSD1306I2c.cpp
6+
../src/oled/AdafruitSSD1306Spi.cpp
7+
)
8+
9+
target_compile_definitions(AdafruitGFXNativePort
10+
PUBLIC BUILD_FOR_PICO_CMAKE=1 BUILD_PICO_FORCE_UART=1 IO_LOGGING_DEBUG=1
11+
)
12+
13+
target_include_directories(AdafruitGFXNativePort PUBLIC
14+
${PROJECT_SOURCE_DIR}/mbed_lib/Adafruit-GFX-mbed-fork/src
15+
)
16+
17+
target_link_libraries(AdafruitGFXNativePort PUBLIC pico_stdlib pico_sync IoAbstraction TaskManagerIO tcUnicodeHelper)

examples/GFXcanvas/GFXcanvas.ino

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)