24-06-2014, 01:07:29
Ici sera déposé tout ce qui concerne le Projet "M-Pi-3 Player".
J’alimenterai au fur et à mesure de l'avancement du projet.
L'idée est de créer un lecteur MP3 avec un Raspberry Pi.
Le projet une fois terminé sera distribué sous licence libre.
Mes conditions :
Le MP3 sera dirigé uniquement à l'aide des input/output GPIO du Pi. (Bouton poussoir ?)
Il doit disposer :
D'un afficheur basic. (exit le port HDMI)
Des fonctions "suivant", "pause/reprise", "Volume Up/Down".
D'un menu "Setting" dans lequel... ---> (Fonction encore à définir) <---
D'une Fonction "shutdown" (genre 'sudo shutdown -h now')
Les fichiers audio seront accessible via /media/~usb_stick
Compatible mp3,ogg et wma
===========================
1. - Installer un OS sur le Raspberry Pi
Le choix naturel se porte sur Raspbian. Il met tout à disposition pour coder son Raspberry Pi moyennant quelque connaissance basique Linux.
Pour ce faire il vous faudra :
Télécharger l'image Raspbian via http://www.raspberrypi.org/downloads/ et la déziper.
Linux :
Utiliser le créateur de clé USB (installé par défaut sur la plus par des distributions)
![[Image: 1404060912.png]](http://pix.toile-libre.org/upload/img/1404060912.png)
Sélectionner l'image Raspbian [1] précédemment téléchargé puis sélectionner votre Carte SD [2].
Enfin cliquer sur Écrire [3].
![[Image: 1404061494.png]](http://pix.toile-libre.org/upload/img/1404061494.png)
Votre Carte SD prête, introduisez la dans le slot de votre Raspberry Pi.
Votre Raspberry Pi est maintenant prêt, il faut maintenant l'habiller d'un afficheur et de quelque bouton.
Windows :
Votre Carte SD prête, introduisez la dans le slot de votre Raspberry Pi.
Votre Raspberry Pi est maintenant prêt, il faut maintenant l'habiller d'un afficheur et de quelque bouton.
1.1 - Premier lancement de Raspbian
2. - Ajouter un afficheur LCD + Bouton
Après quelque recherche, j'ai choisi d'utiliser le kit LCD + Keypad de Adafruit. ( https://www.adafruit.com/products/1109 )
Ce kit met à disposition tout ce don j'ai besoin sur un unique support.
2.1 - Monter le kit Adafruit
3. Coder sur Raspbian en mode terminal
/home/pi/M-Pi-3.py
J’alimenterai au fur et à mesure de l'avancement du projet.
L'idée est de créer un lecteur MP3 avec un Raspberry Pi.
Le projet une fois terminé sera distribué sous licence libre.
Mes conditions :
Le MP3 sera dirigé uniquement à l'aide des input/output GPIO du Pi. (Bouton poussoir ?)
Il doit disposer :
D'un afficheur basic. (exit le port HDMI)
Des fonctions "suivant", "pause/reprise", "Volume Up/Down".
D'un menu "Setting" dans lequel... ---> (Fonction encore à définir) <---
D'une Fonction "shutdown" (genre 'sudo shutdown -h now')
Les fichiers audio seront accessible via /media/~usb_stick
Compatible mp3,ogg et wma
===========================
1. - Installer un OS sur le Raspberry Pi
Le choix naturel se porte sur Raspbian. Il met tout à disposition pour coder son Raspberry Pi moyennant quelque connaissance basique Linux.
Pour ce faire il vous faudra :
Citation :1x Ordinateur avec lecteur carte SD
1x Carte SD 4Go ou +
1x Image Raspbian
Télécharger l'image Raspbian via http://www.raspberrypi.org/downloads/ et la déziper.
Linux :
Utiliser le créateur de clé USB (installé par défaut sur la plus par des distributions)
![[Image: 1404060912.png]](http://pix.toile-libre.org/upload/img/1404060912.png)
Sélectionner l'image Raspbian [1] précédemment téléchargé puis sélectionner votre Carte SD [2].
Enfin cliquer sur Écrire [3].
![[Image: 1404061494.png]](http://pix.toile-libre.org/upload/img/1404061494.png)
Votre Carte SD prête, introduisez la dans le slot de votre Raspberry Pi.
Votre Raspberry Pi est maintenant prêt, il faut maintenant l'habiller d'un afficheur et de quelque bouton.
Windows :
Citation :Je ne dispose pas de système Windows, un volontaire pour faire cette partie ?
Votre Carte SD prête, introduisez la dans le slot de votre Raspberry Pi.
Votre Raspberry Pi est maintenant prêt, il faut maintenant l'habiller d'un afficheur et de quelque bouton.
1.1 - Premier lancement de Raspbian
Citation :---> A suivre
2. - Ajouter un afficheur LCD + Bouton
Après quelque recherche, j'ai choisi d'utiliser le kit LCD + Keypad de Adafruit. ( https://www.adafruit.com/products/1109 )
Ce kit met à disposition tout ce don j'ai besoin sur un unique support.
2.1 - Monter le kit Adafruit
Citation :---> A suivre2.2 - Configurer Raspbian pour I2C
Citation :---> A suivre2.3 - Installation des drivers du kit Adafruit (.py)
Citation :---> A suivre2.4 - Test du kit Adafruit
Citation :---> A suivreLe kit fonctionnel, il nous faut maintenant coder notre M-Pi-3 Player
3. Coder sur Raspbian en mode terminal
Citation :---> A suivre3.1 Créer un nouveau fichier .py
Citation :---> A suivre3.2 Éditer un fichier .py avec nano
Citation :---> A suivre4. Le code M-Pi-3.py
/home/pi/M-Pi-3.py
Code :
[== Python ==]
#!/usr/bin/python
###################################################
### This is a python programme for Raspberry Pi ###
### He transforme your Pi in to a MP3 Player ###
### You will need the Adafruit LCD Kit ###
###################################################
from time import sleep
from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
import random, sys, time, pygame, os
from pygame.locals import *
# Initialize the LCD plate. Should auto-detect correct I2C bus. If not,
# pass '0' for early 256 MB Model B boards or '1' for all later versions
lcd = Adafruit_CharLCDPlate()
# Clear display and show greeting, pause 2 sec
lcd.clear()
lcd.message(" M-Pi-3 Player\n v.a01 ")
os.system("clear")
print(" M-Pi-3 Player\n v.a01 ")
sleep(2)
# LCD variable
shuting_down = 1 # 0n/Off fonction
refresh_lcd = 0 # for printing juste one time on LCD
menu = 10 # 0 to 40 Menu existing
color = 2 # backlight colors (lcd.RED, lcd.YELLOW, lcd.GREEN, lcd.TEAL, lcd.BLUE, lcd.VIOLET, lcd.ON, lcd.OFF)
# Audio variable
pygame.mixer.init()
global btnBEEP
btnBEEP = pygame.mixer.Sound("btnBEEP.ogg")
### M-Pi-3 Player Main
while (shuting_down):
########################
#
#WORK IN PROGRESSE !
#
########################
### Shuting_down function
lcd.clear()
lcd.message("M-Pi-3 Player\nis shuting down")
os.system("clear")
print("M-Pi-3 Player\nis shuting down")
sleep(3)
lcd.clear()
lcd.backlight(lcd.OFF)
os.system("sudo shutdown -h now") ### Will shutdown the Raspberry Ri