ok, here my write up:
I got my raspberry Pi3B a couple of days ago along with the official 7" display and the case for both. Looks useful but when I install it in the car I was wondering why the screen is flipped upside down. Now that I read a bit, they do it intentionally to increase the viewing angle. So you have to mount the case upside down. This is ok and works as good.
I installed the standard rasbian OS with the Noobs installer. It is not just called this way: "noobs", it is really for people like me who never worked with any Pi.
Then I had to change some configurations. The first and most important one is the screensaver. I found 100 tutorials about how to turn it off, no success. Then I found the noob-way:
Type thin into your Terminal:
Then you get a nice config tool installed where you can turn all energy saving/screensaver stuff off.
The next thing was to enable a push-button for left/right key to flip the pages in the app. I did not want to hack a keyboard etc, I just wanted to use the GPIO on the Pi. So I needed a Deamon which runs in the background to emulate a keyboard. No problem if you know how to:
pikeyd is a c program which translates the GPIO HI/LOW to keyboard presses.
Code: Select all
sudo git clone https://github.com/mmoller2k/pikeyd.git
cd pikeyd
sudo nano joy_RPi.c
If you use a Pi3, you must change one #define before you continue. The line is called
#define GPIO_PERI_BASE 0x
20000000
change the number into 0x
3f000000
After saving the file, go on with:
Code: Select all
sudo make
sudo modprobe uinput
sudo cp pikeyd /usr/local/bin/pikeyd
pikeyd needs a config file to map the key presses to GPIO pins
and paste the following code and save
Code: Select all
# {all keycodes can be found in /usr/include/linux/input.h} {GPIO pin no}
# The numbers are the GPIO numbers. It is not the Pin on the header!! This drove me nuts!
KEY_LEFT 2 #Pin03 on Header
KEY_RIGHT 4 #Pin07 on Header
KEY_ESC 14 #not used in my setup.
Now, lets make sure pikeyd start when we boot up
Add the following line before exit 0
Save the file.
Now we want to launch the uinput module every time we boot up automatically:
Scroll to the bottom of the file and add:
Save the file.
The thing is, that every button requires a pull-up resistor on the Pi GPIO unless you switch on the internal pull-ups. I have done that and I will explain you how in the following description.
I wanted to run the Pi with an external power pack. To be able to turn it on and off, I needed to add a button on the GPIO which runs a script. The best one I found was this here.
Code: Select all
sudo git clone https://github.com/gilyes/pi-shutdown.git
nano pi-shutdown/pishutdown.py
Here I wanted to come back on the pull-up resistors. Now, in the file add below the line "shutdownPin =5"
Code: Select all
leftPin = 3 #GPIO2
rightPin = 7 #GPIO4
escPin = 8 #GPIO14
then go down in the file and find the line "GPIO.setup(shutdownPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)"
add below:
Code: Select all
GPIO.setup(shutdownPin, GPIO.IN, pull_up_down=GPIO.PUD_UP) #already existing
GPIO.setup(leftPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(rightPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(escPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
save the file and copy it to the opt location.
Code: Select all
sudo cp pi-shutdown/pishutdown.py /opt/pishutdown.py
Now we want to run the script as a service in the background. To do this create a file called pishutdown.service in /etc/systemd/system/:
Code: Select all
sudo nano /etc/systemd/system/pishutdown.service
fill the file with:
Code: Select all
[Service]
ExecStart=/usr/bin/python /opt/pishutdown.py
WorkingDirectory=/opt/
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=pishutdown
User=root
Group=root
[Install]
WantedBy=multi-user.target
Enable service:
Code: Select all
sudo systemctl enable pishutdown.service
Run service (will be automatically started on next reboot):
Code: Select all
sudo systemctl start pishutdown.service
I got an error message here but after the restart the script was running. You can now reboot by connecting pin 5 to ground for less than 3 seconds. if you push for longer than three seconds, the Pi will turn off. If you stay with pin 5 you can wake up th Pi by pressing the button again after shutdown. This will work on this pin only.
grounding Pin 3 will be as if you press keyboard left, Pin 7 is for keyboard right. This will be on my steering wheel to change pages. ESC is mapped to Pin 8 but I think I will not use it.
This is it for now.