Modifications

Sauter à la navigation Sauter à la recherche
aucun résumé de modification
Ligne 1 : Ligne 1 :  
{{Rasp-Hack-Afficheur-LCD-NAV}}
 
{{Rasp-Hack-Afficheur-LCD-NAV}}
   −
xx
+
It's all fine and dandy to have a script like ''Adafruit_CharLCD_IPclock_example.py''  which we can manually run, but wouldn't it be nice to have the time and ip address pop up on the display when the raspberry pi boots up? This is done using a init script which runs the ''Adafruit_CharLCD_IPclock_example.py'' code on boot and kills it during system shut down.
 +
 
 +
Paste this code into '''/etc/init.d/lcd'''
 +
 
 +
(you will need to use sudo to write to this directory)
 +
 
 +
<nowiki>### BEGIN INIT INFO
 +
# Provides: LCD - date / time / ip address
 +
# Required-Start: $remote_fs $syslog
 +
# Required-Stop: $remote_fs $syslog
 +
# Default-Start: 2 3 4 5
 +
# Default-Stop: 0 1 6
 +
# Short-Description: Liquid Crystal Display
 +
# Description: date / time / ip address
 +
### END INIT INFO
 +
 
 +
 
 +
#! /bin/sh
 +
# /etc/init.d/lcd
 +
 
 +
 
 +
export HOME
 +
case "$1" in
 +
    start)
 +
        echo "Starting LCD"
 +
        /home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCD/Adafruit_CharLCD_IPclock_example.py  2>&1 &
 +
    ;;
 +
    stop)
 +
        echo "Stopping LCD"
 +
LCD_PID=`ps auxwww | grep Adafruit_CharLCD_IPclock_example.py | head -1 | awk '{print $2}'`
 +
kill -9 $LCD_PID
 +
    ;;
 +
    *)
 +
        echo "Usage: /etc/init.d/lcd {start|stop}"
 +
        exit 1
 +
    ;;
 +
esac
 +
exit 0
 +
</nowiki>
 +
 
 +
You should change
 +
'''/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCD/Adafruit_CharLCD_IPclock_example.py''' to where-ever you are actually keeping the IPclock python script
 +
 
 +
Make the init script executable.
 +
 
 +
$ sudo chmod +x /etc/init.d/lcd
 +
 
 +
Make the lcd init script known to the system by using the update-rc.d command.
 +
 
 +
$ sudo update-rc.d lcd defaults
 +
 
 +
[[Fichier:Rasp-Hack-Afficheur-LCD-init.jpg]]
 +
 
 +
Now on each boot the lcd will automatically show the date/time/ip address on startup. This means you will know when the pi is reachable and what the ip address is without having to plug a monitor in.
    
{{Rasp-Hack-Afficheur-LCD-TRAILER}}
 
{{Rasp-Hack-Afficheur-LCD-TRAILER}}
29 917

modifications

Menu de navigation