Git Product home page Git Product logo

u8g2-rpi-demo's Introduction

Introduction

ST7920 using U8G2 on Raspberry Pi Demo

This project serves as an example of how to build and compile a C++ project using U8G2 and Wiring Pi library on the Raspberry Pi. CMake is used as the primary build tool with support for cross-compilation.

The display used for this demo is ST7920. If you would like to use a different display, you could easily modify the source and replace the setup/constructor definitions.

This project uses a custom SPI library for communication with the display, if you are wondering why that is considering Wiring Pi already provides such methods, please read the issue here.

Project Dependencies

Build Instructions

The project comes with a utility script for compiling on the Raspberry Pi or for cross-compiling from a Linux operating system. Cross-compilation will automatically take place if the script has detected it is not running on the target platform.

To compile on the Raspberry Pi, simply run the compile script.

./compile.sh

CMake will automatically download the required libraries (wiring pi and u8g2) if it is not found on the target system.

If you are compiling from the Linux platform, you need the Raspberry Pi toolchain (See Project Dependencies). If this is not yet installed in your system then CMake will try and download them for you. If you happen to have the toolchain already installed, then you can pass the existing path to the compile script.

./compile.sh -t <path-of-the-rpi-toolchain>

By default, the cmake builds the binaries with debug information. If you need to compile without debug information then you can specify the build type it in the compile script (release or debug)

./compile.sh -b<release/debug>

The binary output can be found in the following path:

<project_dir>/build/arm/<debug|release>/bin

Supported Features

  • SPI Hardware/Software implementations
  • I2C

Sample Usage

u8g2_t u8g2;

int main() {
    //1) Initialize the Struct containing SPI PIN details
    u8g2_rpi_hal_t u8g2_rpi_hal = {14 /*CLOCK/EN*/, 12 /*MOSI/RW*/, 10 /*CS/RS*/};
    u8g2_rpi_hal_init(u8g2_rpi_hal);

    //2) Pass the byte and gpio callbacks to the display setup procedure
    u8g2_Setup_st7920_s_128x64_f(&u8g2, U8G2_R2, cb_byte_spi_hw, cb_gpio_delay_rpi);

    //3) Initialize the display
    u8g2_InitDisplay(&u8g2);
    u8g2_SetPowerSave(&u8g2, 0);
    u8g2_ClearDisplay(&u8g2);


    //4) Do whatever you want
    u8g2_DrawStr(u8g2, 10, 32, "Hello");

    //Flush the buffer
    u8g2_SendBuffer(u8g2);

    return 0;
}

u8g2-rpi-demo's People

Contributors

ribasco 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

Watchers

 avatar  avatar  avatar  avatar

u8g2-rpi-demo's Issues

Blank screen

Hi

I'm running the code on a Pi 0 with an SSD1322 256x64 screen. I've changed the line that defines which screen we're using and SPI is enabled and shows in dev. I've tried 2 different screens but nothing appears on the screen.

Am I doing something stoopid?

Thanks
Mase

Large size executable

Hello,

Why does this create a executable that is 13MB large? Is there some linker-error or whats happening?

Licence

Hi, thanks for this port โ€“ most useful and working great!
Iโ€™d like to reuse your code in a project of mine, could you tell me what licence your code is published under?

Compile error on Raspberry Pi

I suspect this project isn't being actively maintained, but I was hoping to install it on an old Raspberry Pi I had lying around.
The compile.sh script obtained the u8g2 library code and seems to compile most of it no problem, but the linking stage errored out and I've no clue how to work around or fix this:

Host system is ARM
===================================================
Compile Info
===================================================
Machine Type = armv6l
Operating System = GNU/Linux
Target Build Directory = build/arm/debug
Tools Path = 
Build Type = Debug
CMake Bin Path = /usr/bin/cmake
Cmake Command = /usr/bin/cmake -DCMAKE_BUILD_TYPE=Debug  -H. -Bbuild/arm/debug
===================================================
Running CMake command
-- System Processor = armv6l
-- [U8G2] U8G2_HEADER_FILES = /home/pi/u8g2-rpi-demo/lib/u8g2/csrc/mui.h;/home/pi/u8g2-rpi-demo/lib/u8g2/csrc/mui_u8g2.h;/home/pi/u8g2-rpi-demo/lib/u8g2/csrc/u8g2.h;/home/pi/u8g2-rpi-demo/lib/u8g2/csrc/u8x8.h
-- [U8G2] U8G2_INCLUDE_DIR = /home/pi/u8g2-rpi-demo/build/arm/debug/install/u8g2/include
-- [U8G2] U8G2_LIBRARIES = 
-- [WIRING-PI] WIRINGPI_LIBRARIES = /usr/lib/libwiringPi.so
-- [WIRING-PI] WIRINGPI_INCLUDE_DIR = /usr/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/u8g2-rpi-demo/build/arm/debug
===================================================
Building Project Binaries
===================================================
[  1%] Linking CXX executable bin/u8g2demo
/usr/bin/ld: CMakeFiles/u8g2demo.dir/lib/u8g2/csrc/u8g2_d_setup.c.o: in function `u8g2_Setup_uc1609_slg19264_1':
/home/pi/u8g2-rpi-demo/lib/u8g2/csrc/u8g2_d_setup.c:3195: undefined reference to `u8x8_d_uc1609_slg19264'
/usr/bin/ld: CMakeFiles/u8g2demo.dir/lib/u8g2/csrc/u8g2_d_setup.c.o: in function `u8g2_Setup_uc1609_slg19264_2':
/home/pi/u8g2-rpi-demo/lib/u8g2/csrc/u8g2_d_setup.c:3204: undefined reference to `u8x8_d_uc1609_slg19264'
/usr/bin/ld: CMakeFiles/u8g2demo.dir/lib/u8g2/csrc/u8g2_d_setup.c.o: in function `u8g2_Setup_uc1609_slg19264_f':
/home/pi/u8g2-rpi-demo/lib/u8g2/csrc/u8g2_d_setup.c:3213: undefined reference to `u8x8_d_uc1609_slg19264'
/usr/bin/ld: CMakeFiles/u8g2demo.dir/lib/u8g2/csrc/u8g2_d_setup.c.o: in function `u8g2_Setup_uc1609_i2c_slg19264_1':
/home/pi/u8g2-rpi-demo/lib/u8g2/csrc/u8g2_d_setup.c:3223: undefined reference to `u8x8_d_uc1609_slg19264'
/usr/bin/ld: CMakeFiles/u8g2demo.dir/lib/u8g2/csrc/u8g2_d_setup.c.o: in function `u8g2_Setup_uc1609_i2c_slg19264_2':
/home/pi/u8g2-rpi-demo/lib/u8g2/csrc/u8g2_d_setup.c:3232: undefined reference to `u8x8_d_uc1609_slg19264'
/usr/bin/ld: CMakeFiles/u8g2demo.dir/lib/u8g2/csrc/u8g2_d_setup.c.o:/home/pi/u8g2-rpi-demo/lib/u8g2/csrc/u8g2_d_setup.c:3241: more undefined references to `u8x8_d_uc1609_slg19264' follow
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/u8g2demo.dir/build.make:1720: bin/u8g2demo] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/u8g2demo.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
ERROR: Build Failed```

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.