more notes for a bad memory - - -
Setting up the Raspberry Pi with a 3.5 inch colour LCD and Epiphany browser in Kiosk mode
Objective
Show a web page in full screen (Kiosk mode) that is controlled by CGI scripts to show solar water heater performance etc.
Method
I bought a 3.5 inch 320x400 display for a Pi for under £9 from eBay
It is pin sharp and colorful - I thought that 1 or 2 pixels were dead (hence the price?)
but their location is random - perhaps a data comms problem?
I loaded the img file -
raspberry_35_inch_ts.rar
from -
http://osoyoo.com/wp-content/uploads/sample code/
Load the image with Apple Pi-Baker
Set a fixed IP address in /etc/interfaces/network
# The loopback network interface - always needed here # this one for dhcp # this one for WIFI D-Link DWL-G122 # The primary network interface - use this for ethernet cable if WIFI above not used # set these for the LAN address # set this for the Internet modem gateway to the LAN # my gateway acts as a local dns-nameserver (not needed?) |
Do not change the bootloader during the update
sudo apt-mark hold raspberrypi-bootloader
Update/upgrade the PI image
sudo apt-get update && sudo apt-get upgrade -y
Create a webserver that will be used to create the local web page at 127.0.0.1 for the Kiosk mode
sudo apt-get install apache2 -y
Note - I tried to load PHP at various point in this procedure. After all seeming to work I backed up the image with PiBake (Mac).
On the next boot I could not see the GUI screen - just a black screen tha accepted typing from the keyboard.
This happend several times.
Epiphany browser - Boot to a web page and set Kiosk mode,
Create full screen as if key F11 pressed
sudo aptitude install xautomation
At
/home/pi/fullscreen.sh
create -
#! /bin/sh # launch the web page of choice (this one is the default that Apache creates in /var/www # this does the same job as pressing the F11 key to force Kiosk mode |
then do -
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
@lxpanel --profile LXDE-pi # kill the screen saver @/home/pi/fullscreen.sh |
sudo reboot
and the Pi will show the normal GUI followed by the Apache default web page in full screen mode at /var/www/index.html
It works!This is the default web page for this server. The web server software is running but no content has been added, yet. |
There are no borders and no way to poweroff cleanly other than hitting the "Windows" key on the keyboard.
I aim to create the page from a script and add a poweroff button.
First prepare the Raspberry Pi
I need a ramdisk for changing data so as to not burn out the flash memory
Place this with 755 permissions into
/etc/init.d/graham_startup.sh
Every time the Raspberry Pi is booted the temporary RAM disk will be created - 2M means 2 Mega Bytes
it could be much larger - I use it for the output of bash scripts and the input of Blassic basic programs.
(Blassic basic acts as great glue to hold together other software including C, bash etc and can save and read files as needed.
It handles and manipulates text string in ways I can understand and remember
- (unlike C !!!!).
Learn Python and C++ if you can but if you only program a couple of times a year consider Blassic as a tool to get the job done.
See a few notes at pull down menu item 12 at -> http://www.sunspot.co.uk/Projects/sweexproject.htm )
#! /bin/sh # Now carry out specific functions when asked to by the system # make a ramdisk to save the flash ;; exit 0 |
Setting up the Pi as a webserver
Get the latest software and links
apt-get update
install Apache
apt-get install apache2
There should be a simple webpage index.html in /var/www/
see it at http://192.168.0.82
CGI scripting in bash
in :-
/usr/lib/cgi-bin/hello.cgi
put :-
#!/bin/bash
echo -e "Content-type: text/html\n\n"
echo "<h1>Hello World</h1>"
then create a link to cgi-bin in the www folder :-
ln -s /usr/lib/cgi.bin /var/www/cgi-bin
see it at http://192.168.0.82/cgi-bin/hello.cgi
Add PHP - works - but it was not stable. . . .
sudo apt-get install php5 libapache2-mod-php5 -y
To test PHP put into /var/www/php_test.php
<html>
<head>
<title>PHP test</title>
</head>
<body>
<?php
echo "<b>Hello World!</b><BR><BR>The date is ";
echo date('Y-m-d'), "<BR>and the time is ", date('H:i:s');
echo "<BR><BR>Now for some information about PHP :-<BR><BR>", phpinfo();
?>
</body>
</html>
see it at http://192.168.0.xxx/php_test.php
If there are several Raspis on the network change their host names
sudo nano /etc/hosts
sudo nano /etc/hostname
sudo /etc/init.d/hostname.sh
sudo reboot
Please email
me if you want to swap notes
- especially if you do a better job !!!!
and/or
add i2c port expanders, thermometers, displays etc
(my next learning exercise)
more to come . . .