======Raspberry Pi OpenFrameworks====== ===== OpenFrameworks ===== Ce tutoriel présente l'installation d'OpenFrameworks sur une RaspberryPi. Il se base sur celui fourni sur [[http://openframeworks.cc/setup/raspberrypi/Raspberry-Pi-Getting-Started.html|OpenFrameworks]]. Avant de commencer, il est nécessaire d'installer et de [[Raspberry_Pi_Installation|configurer sa Raspberry Pi]]. ==== Configurations supplémentaires ==== Pour la compilation il est nécessaire d'allouer de la mémoire supplémentaire, éditer le fichier de configuration : sudo nano /boot/config.txt ==== Télécharger OpenFrameworks ==== Ces commandes vont télécharger et décompresser l'archive dans le répertoire /home/pi/openFrameworks cd wget http://openframeworks.cc/versions/v0.9.8/of_v0.9.8_linuxarmv6l_release.tar.gz mkdir openFrameworks tar vxfz of_v0.9.8_linuxarmv6l_release.tar.gz -C openFrameworks --strip-components 1 ==== Compilation d'OpenFrameworks ==== Des librairies supplémentaires sont nécessaires pour pouvoir compiler correctement OpenFrameworks. Ces opérations durent à peu près une heure. cd /home/pi/openFrameworks/scripts/linux/debian sudo ./install_dependencies.sh make Release -C /home/pi/openFrameworks/libs/openFrameworksCompiled/project ==== Compilation du premier projet ==== Pour commencer un projet, il faut copier la structure d'un projet vide dans un nouveau répertoire. cp -R /home/pi/openFrameworks/apps/myApps/emptyExample /home/pi/openFrameworks/apps/myApps/premierProjet cd /home/pi/openFrameworks/apps/myApps/premierProjet make make run Il faut garder en mémoire que le répertoire de l'application doit être un sous-réperoire d'un sous-répertoire du répertoire openFramworks. ==== Compiler OpenFrameworks en attendant 0.10 ==== La dernière version raspbian change beaucoup de chose pour les compilations. Il faut télécharger la dernière unightly build : cd wget http://ci.openframeworks.cc/versions/nightly/of_v20170714_linuxarmv6l_nightly.tar.gz mkdir openFrameworks tar vxfz of_v20170714_linuxarmv6l_nightly.tar.gz -C openFrameworks --strip-components 1 sudo nano  openFrameworks/libs/openFrameworksCompiled/project/linuxarmv6l/config.linuxarmv6l.default.mk # raspberry pi specific stetch !!!!!!!!!! PLATFORM_LIBRARIES += GLESv2_static PLATFORM_LIBRARIES += EGL_static PLATFORM_LIBRARIES += mmal PLATFORM_LIBRARIES += mmal_components PLATFORM_LIBRARIES += mmal_core PLATFORM_LIBRARIES += mmal_util PLATFORM_LIBRARIES += mmal_vc_client PLATFORM_LIBRARIES += brcmOpenVG PLATFORM_LIBRARIES += brcmWFC PLATFORM_LIBRARIES += brcmEGL PLATFORM_LIBRARIES += brcmGLESv2 #PLATFORM_LIBRARIES += GLESv2 PLATFORM_LIBRARIES += GLESv1_CM #PLATFORM_LIBRARIES += EGL PLATFORM_LIBRARIES += openmaxil PLATFORM_LIBRARIES += bcm_host PLATFORM_LIBRARIES += vcos PLATFORM_LIBRARIES += vchiq_arm PLATFORM_LIBRARIES += pcre PLATFORM_LIBRARIES += rt PLATFORM_LIBRARIES += X11 PLATFORM_LIBRARIES += dl et # Broadcom hardware interface library PLATFORM_HEADER_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/include PLATFORM_HEADER_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/include/IL PLATFORM_HEADER_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/include/EGL PLATFORM_HEADER_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/include/GLES PLATFORM_HEADER_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/include/GLES2 PLATFORM_HEADER_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/include/VG PLATFORM_HEADER_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/include/WF PLATFORM_HEADER_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/include/vcinclude PLATFORM_HEADER_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/include/interface/mmal PLATFORM_HEADER_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/include/interface/vcos/pthreads PLATFORM_HEADER_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/include/interface/vmcs_host/linux ===== Utilisation des addons ===== Si vous utilisez des addons, il faut indiquer au compilateur lesquels. Pour cela il faut modifier le fichier addons.make. S'il n'existe pas il sera créé. Il faut le placer dans le répertoire de votre projet au même niveau que config.make : cd /home/pi/openFrameworks/apps/myApps/premierProjet sudo nano addons.make Ajoutez le nom des addons que vous souhaitez utiliser par exemple : ofxXmlSettings ofxOsc Puis ctrl-O pour sauvegarder en validant, puis ctrl-x pour quitter. ===== Gestion du GPIO ===== La bibliothèque wiringPi est idéale pour gérer le GPIO avec OpenFrameworks. ==== Téléchargement et installation de la librairie ==== Afin d'obtenir la librairie, taper : cd git clone git://git.drogon.net/wiringPi Ensuite un script s'occupe d'installer et de compiler la librairie : cd wiringPi ./build Vous pouvez mettre à jour la librairie avec : cd ~/wiringPi git pull origin ./build Pour tester que tout fonctionne bien : gpio -v gpio readall La liste des fonctionnalités est disponible sur le [[http://wiringpi.com|site]] du dévellopeur. ==== Compilation ==== Il est nécessaire d'indiquer au compilateur la présence de la librairie wiringPi. Pour cela, il faut éditer le fichier config.make de l'application en cours de développement : sudo nano config.make et modifier les lignes suivantes en gras : ################################################################################ # PROJECT LINKER FLAGS #       These flags will be sent to the linker when compiling the executable. # #               (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs # #   Note: Leave a leading space when adding list items with the += operator # # Currently, shared libraries that are needed are copied to the # $(PROJECT_ROOT)/bin/libs directory.  The following LDFLAGS tell the linker to # add a runtime path to search for those shared libraries, since they aren't # incorporated directly into the final executable application binary. ################################################################################ '''PROJECT_LDFLAGS=-Wl,-rpath=./libs '''PROJECT_LDFLAGS += -lwiringPi Ctrl-o pour sauvegarder et Ctrl-x pour quitter ==== Configuration de la Raspberry ==== Pour utiliser le port série du GPIO il est nécessaire de désactiver la console série. Un petit script fait cela pour nous : sudo wget https://raw.github.com/lurch/rpi-serial-console/master/rpi-serial-console Pour désactiver la console série : sudo rpi-serial-console disable Pour la réactiver si nécessaire : sudo rpi-serial-console enable [[https://github.com/lurch/rpi-serial-console|Console série RPI]] {{tag>sylvain openFrameworks raspberry_pi}}