hallard / arduipi_oled Goto Github PK
View Code? Open in Web Editor NEWCommon used OLED driver for Raspberry PI
Home Page: http://hallard.me/adafruit-oled-display-driver-for-pi/
Common used OLED driver for Raspberry PI
Home Page: http://hallard.me/adafruit-oled-display-driver-for-pi/
hello,
how is it possible to run oled programs without sudo rights?
I can't install the lib on my Raspberry Pi (OS Raspbian Stretch), downloading and then typing "make" or even "sudo make" does not work at all, e.g.,
pi@PiStr:~/ArduiPi_OLED $ sudo make
g++ -Wall -fPIC -fno-rtti -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c ArduiPi_OLED.cpp
ArduiPi_OLED.cpp: In member function ‘void ArduiPi_OLED::putSeedChar(char)’:
ArduiPi_OLED.cpp:635:41: warning: array subscript has type ‘char’ [-Wchar-subscripts]
char bit1=( seedfont[C-32][i] >> j) & 0x01;
^
In file included from ArduiPi_OLED.cpp:36:0:
./ArduiPi_OLED_lib.h: At global scope:
./ArduiPi_OLED_lib.h:58:21: warning: ‘oled_type_str’ defined but not used [-Wunused-variable]
static const char * oled_type_str[] = {
^~~~~~~~~~~~~
g++ -Wall -fPIC -fno-rtti -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c Adafruit_GFX.cpp
In file included from Adafruit_GFX.cpp:26:0:
./ArduiPi_OLED_lib.h:58:21: warning: ‘oled_type_str’ defined but not used [-Wunused-variable]
static const char * oled_type_str[] = {
^~~~~~~~~~~~~
gcc -Wall -fPIC -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c bcm2835.c
gcc -Wall -fPIC -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c Wrapper.cpp
Wrapper.cpp: In function ‘int16_t Wrapper_DisplayWidth()’:
Wrapper.cpp:233:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
Wrapper.cpp: In function ‘int16_t Wrapper_DisplayHeight()’:
Wrapper.cpp:238:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
In file included from Wrapper.cpp:39:0:
./ArduiPi_OLED_lib.h: At global scope:
./ArduiPi_OLED_lib.h:58:21: warning: ‘oled_type_str’ defined but not used [-Wunused-variable]
static const char * oled_type_str[] = {
^~~~~~~~~~~~~
g++ -shared -Wl,-soname,libArduiPi_OLED.so.1 -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -o libArduiPi_OLED.so.1.0 ArduiPi_OLED.o Adafruit_GFX.o bcm2835.o Wrapper.o -li2c
/usr/bin/ld: cannot find -li2c
collect2: error: ld returned 1 exit status
Makefile:54: die Regel für Ziel „ArduiPi_OLED“ scheiterte
make: *** [ArduiPi_OLED] Fehler 1
how to fix that?
hello,
can you please provide compile/build parameter settings and examples how to use this lib with Geany, providing system-wide paths to #include the libs from each proprietary source code program located in any different directory?
solved:
#24 (comment)
Hallo,
can some one help me with that issue?? Where do i get the lib´s, or how can i install the missing lib´s?
Running Debian 9 on Raspi3.
pi@raspberrypi:/ArduiPi_OLED $ sudo make/ArduiPi_OLED $
g++ -Wall -fPIC -fno-rtti -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c ArduiPi_OLED.cpp
ArduiPi_OLED.cpp: In member function ‘void ArduiPi_OLED::putSeedChar(char)’:
ArduiPi_OLED.cpp:635:41: warning: array subscript has type ‘char’ [-Wchar-subscripts]
char bit1=( seedfont[C-32][i] >> j) & 0x01;
^
In file included from ArduiPi_OLED.cpp:36:0:
./ArduiPi_OLED_lib.h: At global scope:
./ArduiPi_OLED_lib.h:58:21: warning: ‘oled_type_str’ defined but not used [-Wunused-variable]
static const char * oled_type_str[] = {
^
g++ -Wall -fPIC -fno-rtti -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c Adafruit_GFX.cpp
In file included from Adafruit_GFX.cpp:26:0:
./ArduiPi_OLED_lib.h:58:21: warning: ‘oled_type_str’ defined but not used [-Wunused-variable]
static const char * oled_type_str[] = {
^
gcc -Wall -fPIC -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c bcm2835.c
gcc -Wall -fPIC -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c Wrapper.cpp
Wrapper.cpp: In function ‘int16_t Wrapper_DisplayWidth()’:
Wrapper.cpp:233:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
Wrapper.cpp: In function ‘int16_t Wrapper_DisplayHeight()’:
Wrapper.cpp:238:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
In file included from Wrapper.cpp:39:0:
./ArduiPi_OLED_lib.h: At global scope:
./ArduiPi_OLED_lib.h:58:21: warning: ‘oled_type_str’ defined but not used [-Wunused-variable]
static const char * oled_type_str[] = {
^
g++ -shared -Wl,-soname,libArduiPi_OLED.so.1 -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -o libArduiPi_OLED.so.1.0 ArduiPi_OLED.o Adafruit_GFX.o bcm2835.o Wrapper.o -li2c
/usr/bin/ld: cannot find -li2c
collect2: error: ld returned 1 exit status
Makefile:54: recipe for target 'ArduiPi_OLED' failed
make: *** [ArduiPi_OLED] Error 1
pi@raspberrypi:
into which directory is the file
ArduiPi_OLED.h
installed by make?
I can't find it on my Pi (need to edit it for a patch!)
The i2c_smbus_write functions seem to not exist on my system.
gcc -Wall -fPIC -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c bcm2835.c
bcm2835.c: In function ‘bcm2835_i2c_write’:
bcm2835.c:877:12: warning: implicit declaration of function ‘i2c_smbus_write_byte_data’ [-Wimplicit-function-declaration]
reason = i2c_smbus_write_byte_data(i2c_fd, buf[0], buf[1]);
^~~~~~~~~~~~~~~~~~~~~~~~~
bcm2835.c:880:12: warning: implicit declaration of function ‘i2c_smbus_write_word_data’ [-Wimplicit-function-declaration]
reason = i2c_smbus_write_word_data(i2c_fd, buf[0], (buf[2]<<8) | buf[1] );
^~~~~~~~~~~~~~~~~~~~~~~~~
bcm2835.c:883:12: warning: implicit declaration of function ‘i2c_smbus_write_i2c_block_data’ [-Wimplicit-function-declaration]
reason = i2c_smbus_write_i2c_block_data(i2c_fd, buf[0], len-1, (const __u8 *) &buf[1]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The compilation work, but when linking the examples we get undefined symbol errors.
g++ -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -Wall -lArduiPi_OLED oled_demo.cpp -o oled_demo
/usr/local/lib/libArduiPi_OLED.so: undefined reference to `i2c_smbus_write_i2c_block_data'
/usr/local/lib/libArduiPi_OLED.so: undefined reference to `i2c_smbus_write_word_data'
/usr/local/lib/libArduiPi_OLED.so: undefined reference to `i2c_smbus_write_byte_data'
Hello,
Thank a lot for your work specilly for RadioHead and Oled.
I am novie but I could make working both libraries
Actually, I compiled this
https://github.com/hallard/RadioHead/blob/master/examples/raspi/rf95/rf95_server.cpp
and I can read the radio package from the sender.
I also connected a OLED LCD and I can not find how I can display the received radio package on the LCD.
I suggest, I should link the LOED library in the RadioHead Makefile?
I am novice and I do not how can I do it.
Would not be a good idea to include the possibility to use ArduiPi_OLED into RadioHead in order to have the possibility to display?
May I have your help for this?
Secondely, could you tell me the difference between
https://github.com/hallard/RadioHead/tree/master/examples/raspi/rf95
and
https://github.com/hallard/RadioHead/tree/master/examples/rf95
Thank a lot for your help and clarfication
Pierre
It seems theres no include guards in the ArduiPi_OLED.h header file, thus causing compile issues when using the header in multiple source files.
Hi,
first, my C++ know-how is not good. I will edit the oled_demo.cpp for setting Title and Subtitle Parameters. Why the Script runs in a Seqfault ?
/*********************************************************************
This is an example for our Monochrome OLEDs based on SSD1306 drivers
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/category/63_98
This example is for a 128x32|64 size display using SPI or I2C to communicate
4 or 5 pins are required to interface
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, and the splash screen must be included in any redistribution
02/18/2013 Charles-Henri Hallard (http://hallard.me)
Modified for compiling and use on Raspberry ArduiPi Board
LCD size and connection are now passed as arguments on
the command line (no more #define on compilation needed)
ArduiPi project documentation http://hallard.me/arduipi
*********************************************************************/
#include "ArduiPi_OLED_lib.h"
#include "Adafruit_GFX.h"
#include "ArduiPi_OLED.h"
#include <getopt.h>
//#include <string>
#define PRG_NAME "oled_demo"
#define PRG_VERSION "1.1"
//using namespace std;
// Instantiate the display
ArduiPi_OLED display;
// Config Option
struct s_opts
{
int oled;
int verbose;
char title[64];
char subtitle[64];
} ;
int sleep_divisor = 1 ;
// default options values
s_opts opts = {
OLED_ADAFRUIT_I2C_128x64, // Default oled
false // Not verbose
};
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
static unsigned char logo16_glcd_bmp[] =
{ 0b00000000, 0b11000000,
0b00000001, 0b11000000,
0b00000001, 0b11000000,
0b00000011, 0b11100000,
0b11110011, 0b11100000,
0b11111110, 0b11111000,
0b01111110, 0b11111111,
0b00110011, 0b10011111,
0b00011111, 0b11111100,
0b00001101, 0b01110000,
0b00011011, 0b10100000,
0b00111111, 0b11100000,
0b00111111, 0b11110000,
0b01111100, 0b11110000,
0b01110000, 0b01110000,
0b00000000, 0b00110000 };
/* ======================================================================
Function: usage
Purpose : display usage
Input : program name
Output : -
Comments:
====================================================================== */
void usage( char * name)
{
printf("%s\n", name );
printf("Usage is: %s --oled type [options]\n", name);
printf(" --<o>led type\nOLED type are:\n");
for (int i=0; i<OLED_LAST_OLED;i++)
printf(" %1d %s\n", i, oled_type_str[i]);
printf("Options are:\n");
printf(" --<v>erbose : speak more to user\n");
printf(" --<h>elp\n");
printf("<?> indicates the equivalent short option.\n");
printf("Short options are prefixed by \"-\" instead of by \"--\".\n");
printf("Example :\n");
printf( "%s -o 1 use a %s OLED\n\n", name, oled_type_str[1]);
printf( "%s -o 4 -v use a %s OLED being verbose\n", name, oled_type_str[4]);
}
/* ======================================================================
Function: parse_args
Purpose : parse argument passed to the program
Input : -
Output : -
Comments:
====================================================================== */
void parse_args(int argc, char *argv[])
{
int c;
while (1) {
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_Options[] =
{
{"oled", required_argument, 0, 'o'},
{"verbose", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"title", required_argument, 0, 't'},
{"subtitle", required_argument, 0, 's'},
{0, 0, 0, 0}
};
c = getopt_long(argc, argv, "vhots:", long_Options, &option_index);
if (c < 0)
break;
switch (c)
{
case 'v': opts.verbose = true ; break;
case 'o':
opts.oled = (int) atoi(ostarg);
if (opts.oled < 0 || opts.oled >= OLED_LAST_OLED )
{
fprintf(stderr, "--oled %d ignored must be 0 to %d.\n", opts.oled, OLED_LAST_OLED-1);
fprintf(stderr, "--oled set to 0 now\n");
opts.oled = 0;
}
break;
case 'h':
usage(argv[0]);
exit(EXIT_SUCCESS);
break;
case 't': strcpy(opts.title, optarg); break;
case 's': strcpy(opts.subtitle, optarg); break;
case '?':
default:
fprintf(stderr, "Unrecognized option.\n");
fprintf(stderr, "Run with '--help'.\n");
exit(EXIT_FAILURE);
}
} /* while */
// exit(EXIT_SUCCESS);
}
/* ======================================================================
Function: main
Purpose : Main entry Point
Input : -
Output : -
Comments:
====================================================================== */
int main(int argc, char **argv)
{
int i;
// Oled supported display in ArduiPi_SSD1306.h
// Get OLED type
parse_args(argc, argue)
// I2C change parameters to fit to your LCD
if ( !display.init(OLED_I2C_RESET,opts.oled) )
exit(EXIT_FAILURE);
display.begin();
// init done
display.clearDisplay(); // clears the screen buffer
display.display(); // display it (clear display)
display.clearDisplay();
// Title
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.printf("%s\n", opts.title);
printf("%s\n", opts.title);
// Subtitle
display.setTextColor(BLACK, WHITE); // 'inverted' text
display.setTextSize(2);
display.setTextColor(WHITE);
display.printf("%s\n", opts.subtitle);
printf("%s\n", opts.subtitle);
display.clearDisplay(); // clears the screen buffer
display.display();
sleep(2);
// Free PI GPIO ports
display.close();
}
;
I started by playing on a Pi Zero w with a MMDVM hat for ham radio DMR, Basically I want to build my own hotspot and not use Pi-Star, as I have a few other things I would like o install and run also. Everything worked great on the PI Zero, I was able to download and compile this project, and get my OLED screen on the MMDVM to work. So I moved up in the world, and bought a PI4 I believe it is a B. Installed Bookworm lite 64 bit, and could not compile the OLED drivers anymore. I assume that this is a 32 bit project? Is it possible to compile on 64 bit OS? Thanks for any thoughts or help.
pi@raspberrypi:~/ArduiPi_OLED $ sudo make
g++ -shared -Wl,-soname,libArduiPi_OLED.so.1 -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -o libArduiPi_OLED.so.1.0 ArduiPi_OLED.o Adafruit_GFX.o bcm2835.o Wrapper.o -li2c
[Install Library]
[Install Headers]
pi@raspberrypi:~/ArduiPi_OLED $./oled_demo --help
-bash: ./oled_demo: No such file or directory
in ArduiPi_OLED_lib.h there are some defines which perhaps conflict with general or arbitrary programs:
// Arduino Compatible type
typedef uint8_t boolean;
typedef uint8_t byte;
//...
// GCC Missing
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
especially the max/min #defines are ambiguous and possibly conflicting because this ArduiPi_OLED lib is used by gcc on the Pi, and for gcc both max and min are perhaps already defined in other libs (e.g., max / min (namespace std) or in different optional/proprietary libs)
solutions:
(a) drop all completely, they make no sense in a OLED lib for the Pi
(b) enable them only when a global MAKRO is not defined, like e.g. (how it's done fo millis() etc):
#ifndef ARDUIPIOLED_NO_ARDUINISH_COMPATIBILITY
I try to get the library to work with the 128x32 SPI version from Adafruit but none of the examples seem to work, I also don't get any error which makes it really hard to trace down the cause of the issue.
I'm using the latest Raspbian as of this day and tried a RPi 2 & 3. Could maybe a system update have broken something?
what are the RESET pins for? especially OLED_I2C_RESET ?
OLED SSD1306 boards normally don't have a breakout pin for reset GPIOs,
and on the RPi GPIO pin bcm 25 (physical pin 22) is probably used for arbitrary purposes (conflicting!)
and why does the init() method require then to get passed the parameter OLED_I2C_RESET at all?
Why can't the parameter OLED_I2C_RESET in init() be dropped?
Or can one pass -1 for reset instead of OLED_I2C_RESET if there is no reset pin connected?
e.g.,
display.init(-1, opts.oled)
:?:
(edit: I tested passing -1, seems to work at first view, but not sure if failsafe though)
// Configuration Pin for ArduiPi board
#define OLED_SPI_RESET RPI_V2_GPIO_P1_22 /* GPIO 25 pin 22 */
//
#define OLED_I2C_RESET RPI_V2_GPIO_P1_22 /* GPIO 25 pin 12 */ //<<<<<<<< pin 22 ?! typo ?!
(just to mention, the latest comment
/* GPIO 25 pin 12 */
is probably faulty, should be "pin 22" instead, probably)
Hey,
I try to run the demo ( with sudo ./oled_demo --verbose --oled 1
) on a SH1106 connected via SPI to my Raspi 3 B+ with Raspian but get no output on the display at all.
There is no error in the terminal, and the pins should be right as the display is functioning (with python and luma.oled).
I also tried the SH1106 fix from @alex-graf but as there is no output at all right now, I have the feeling there is something else wrong.
My C++ skills are on beginner level, so if you have any tip, where to read further I would be very happy, as I got stuck here for a few days now.
best, Janos
Hi,
first of all thank you for this library! It saved me a lot of coding time.
In my project, I am using the std::vector class and some things from the chrono header. But the swap macro in Adafruit_GFX.h and the min/max macros in the ArduiPi_SSD1306.h have name conflicts with these stl classes/functions.
I have changed the swap macro to an inline function and I have changed the name of the min/max macros to MIN/MAX. Seems it solved my issues but please, could you check this issue as well?
Thank you, Istvan
I am using the sh1106 and would like to dim the screen.
Does the sh1106 support such a feature or would the software need to flicker the screen so fast that it looks dimmed?
Followed Issue #16 as it wasn't possible to compile the project! So I also changed the -march to -march=native 2x in the Makefile in examples. But when I write "sudo make" I get lots of reference errors:
oled_demo:cpp:(.text.startup+0x39e): undefined reference to 'ArduiPi_OLED::ArduiPi_OLED()'
...
is just one of these messages..
In ArduiPi_OLED.cpp starting at line 152.
// Low level I2C and SPI Write function
inline void ArduiPi_OLED::fastSPIwrite(uint8_t d) {
bcm2835_spi_transfer(d);
}
inline void ArduiPi_OLED::fastI2Cwrite(uint8_t d) {
bcm2835_spi_transfer(d);
}
Both the SPI and I2C functions call the same bcm spi function?
I think we are saved because this form of the fastI2Cwrite function is never used, phew!
Thanks for publishing this project, it is of great value to me and I am sure others too.
I had a issue to compile the library on a Raspberry Pi 3 with Ubuntu Mate 16.04, with this error:
g++ -Wall -fPIC -fno-rtti -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -c ArduiPi_OLED.cpp
In file included from /usr/include/stdio.h:933:0,
from ./ArduiPi_OLED_lib.h:21,
from ArduiPi_OLED.cpp:36:
/usr/include/arm-linux-gnueabihf/bits/stdio.h: In function ‘int getchar()’:
/usr/include/arm-linux-gnueabihf/bits/stdio.h:44:14: sorry, unimplemented: Thumb-1 hard-float VFP ABI
getchar (void)
^
I just updated the Makefile to change the CCFLAGS to "-march-native" and it works.
I installed this library on Slackware ARM linux on the Raspberry Pi 3. It worked fine, with some minor adjustments:
Thanks for publishing this library as open source.
I'm trying to port this to work with beaglebone.
Could you tell me the steps that i have to follow.
I supose that i have to write low level functions to beaglebone spi like your bcm2835.c frrom pi and pin mapping of gpios.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.