Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg: u8glib: add initial support for graphics library #5126

Closed
wants to merge 2 commits into from

Conversation

basilfx
Copy link
Member

@basilfx basilfx commented Mar 21, 2016

This PR adds initial support for U8glib graphics library as an external package. While targeted for Arduino MCUs, it works fine on 32-bit MCUs. The license should be compatible (new-style BSD).

I've tested this with a cheap SSD1306 OLED display via SPI, but it also has a stdout (for native) and I2C backend (untested). The included test application cycles through three pages, each second. Several other displays are also supported.

u8glib

The code size for the test application only (EFM32, STK3600, SPI) is approximately 4.0 kb.

@OlegHahm
Copy link
Member

nice!

cd "$(PKG_DIR)" && git am --ignore-whitespace "$(CURDIR)"/*.patch

$(PKG_DIR)/.git/config:
test -d "$(PKG_DIR)" || git clone "$(PKG_URL)" "$(PKG_DIR)"; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this Makefile to use "git cache" from #5112, please?

@OlegHahm OlegHahm added Type: new feature The issue requests / The PR implemements a new feature for RIOT Area: pkg Area: External package ports Area: drivers Area: Device drivers labels Mar 21, 2016
@basilfx basilfx force-pushed the feature/pkg_u8glib branch 3 times, most recently from 990caf3 to 4de6cb6 Compare March 22, 2016 12:09
@basilfx
Copy link
Member Author

basilfx commented Mar 22, 2016

Added git-cache support and fixed some gcc errors (I normally use clang).

@aabadie
Copy link
Contributor

aabadie commented Mar 23, 2016

Thanks for the PR ! That was something I was also thinking about.
I tested it yesterday with a samr21-xpro and the OLED1 Xplained extension. The extension uses SPI so, according to the datasheet, I adapted the test application using this SPI initialization call:

#define SPI_INTERFACE SPI_1
#define SS_PIN GPIO_PIN(PB,03)
#define A0_PIN GPIO_PIN(PA,13)
#define RS_PIN GPIO_PIN(PA,23)

int main(void)
{
    uint32_t screen = 0;
    u8g_t u8g; 
    u8g_spi_t dev;

    if (u8g_init_spi(&dev, SPI_INTERFACE, SS_PIN, A0_PIN, RS_PIN, &u8g, &u8g_dev_ssd1306_128x32_hw_spi)) {
        puts("Failed to initialize U8glib to SPI device.");
        return -1;
    }

/* draw text */
...

Unfortunately, nothing is displayed. I plan to test with another board asap (arduino-due for instance).

@basilfx
Copy link
Member Author

basilfx commented Mar 23, 2016

Unfortunately, nothing is displayed. I plan to test with another board asap (arduino-due for instance).

Hmm, not sure what is wrong. You can try to swap SS/A0/RS pins and see if that makes a difference. This is because my cheap OLED display uses vague names, so I basically guessed and tried until it worked :-)

You can also try to set breakpoints in the u8g_com_riotos_hw_spi_fn method and see if the correct pins toggle.

Does the native/stdout backend work for you?

@OlegHahm
Copy link
Member

I tested the native/stdout and it worked for me. Don't have any other hardware to test right now.

@miri64 miri64 modified the milestone: Release 2016.07 Mar 29, 2016
@basilfx basilfx force-pushed the feature/pkg_u8glib branch from 4de6cb6 to 7099981 Compare April 4, 2016 19:47
@basilfx
Copy link
Member Author

basilfx commented Apr 4, 2016

Adapted to new pkg structure and rebased.

@basilfx basilfx force-pushed the feature/pkg_u8glib branch from 7099981 to 65c49fd Compare April 17, 2016 09:40
@basilfx basilfx force-pushed the feature/pkg_u8glib branch 2 times, most recently from 6ad41d8 to cd31852 Compare May 2, 2016 20:22
@basilfx
Copy link
Member Author

basilfx commented May 2, 2016

I bought the same SSD1306 OLED display, but this time with an I2C interface. I have updated this PR so that both interfaces work.

bestand 02-05-16 22 25 43

(The test application only supports one display at a time, but the graphics memory survives a reboot/flash.)

@kaspar030 kaspar030 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 3, 2016
@basilfx basilfx force-pushed the feature/pkg_u8glib branch 2 times, most recently from 26c77ed to d6f88ad Compare May 5, 2016 23:32
@basilfx
Copy link
Member Author

basilfx commented May 5, 2016

Fixed couple of things to make Murdock happy:

  • Removed interface drivers from U8glib because of conflicts with the Arduino and MSP430 builds. These builds have their own defines (e.g. ARDUINO, __MSP430__) which would compile different code that would circumvent the RIOT-OS interface.
  • Unified file names for RIOT-OS interface

Now Murdock is happy.

@@ -0,0 +1,123 @@
/*
* Copyright (C) 2015 Freie Universität Berlin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the copyright you want to add? It's 2016. ;)

@kaspar030
Copy link
Contributor

Please address copyright if needed, then squash.
We usually squash into one commit for the package, one for the test.

Very nice, I wish I had such a display!

@basilfx basilfx force-pushed the feature/pkg_u8glib branch from d6f88ad to c6278cf Compare May 6, 2016 22:33
@basilfx
Copy link
Member Author

basilfx commented May 6, 2016

Changed the copyright and squashed into two separate commits.

@basilfx basilfx force-pushed the feature/pkg_u8glib branch from c6278cf to 206c3c9 Compare May 11, 2016 22:33
@PeterKietzmann PeterKietzmann added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels May 12, 2016
@basilfx
Copy link
Member Author

basilfx commented May 12, 2016

After #5435, this PR should build again.

@basilfx
Copy link
Member Author

basilfx commented May 21, 2016

Don't merge this PR yet. I'm improving the interface to RIOT-OS, which depends on a PR I have submitted to U8glib. I hope that gets merged, otherwise I will point it to my own branch.

In the mean time, enjoy this picture of this PR running on a low-power memory display :-)

result

@basilfx
Copy link
Member Author

basilfx commented May 24, 2016

I will close this PR as I am working on porting the successor of U8glib to RIOT-OS. The successor is (IMHO) much easier to use, includes the fixes I originally PR'd for U8glib and is less coupled to Arduino. It also need less patches.

I'll open a new PR once it is ready.

@basilfx basilfx closed this May 24, 2016
@miri64
Copy link
Member

miri64 commented May 24, 2016

It would have been perfectly fine to just rework this PR, but no problem. Looking forward for the new PR :-).

@basilfx basilfx deleted the feature/pkg_u8glib branch July 30, 2016 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers Area: pkg Area: External package ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants