I will update this post to follow my progress.
For the moment I've just bought some components and hack my screen to make it works on 5V.
Housing Shell
My "/boot/config.txt"
Code: Select all
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
disable_overscan=0
overscan_scale=1
overscan_left=10
overscan_right=0
overscan_top=10
overscan_bottom=0
# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=1
hdmi_mode=16
# Sound output. Set to 0 or comment for autodetect, 1 for DVI, 2 to force HDMI.
#hdmi_drive=2
# Using /etc/modules is deprecated and no longer supported on 4.4 kernel
# So manually enable audio
dtparam=audio=on
config_hdmi_boost=0
# force hdmi while the tv can take time before sending the signal on the hdmi output
#hdmi_force_hotplug=1
# uncomment for composite PAL
sdtv_mode=2
# uncomment for lirc-rpi
#dtoverlay=lirc-rpi
# if you plug your tv at the same time as your rpi and that the rpi switches from the hdmi or give a low resolution because tv had no enough time to initialize it
boot_delay=3
# uncomment if you don't want the rainbow at startup
disable_splash=1
# default CEC name
cec_osd_name=recalbox
# Overclock
gpu_mem_256=128
gpu_mem_512=256
gpu_mem_1024=512
avoid_safe_mode=1
kernel=zImage
arm_freq=950
core_freq=250
sdram_freq=450
force_turbo=0
over_voltage=6
over_voltage_sdram_p=0
over_voltage_sdram_i=0
over_voltage_sdram_c=0
gpu_freq=250
sdram_schmoo=0x02000020
max_usb_current = 1
dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4
dtoverlay=gpio-poweroff,gpiopin=22,active_low="y"
Hack to make it 5V (see wiki)
Test with power from USB power supply and a camcorder as video input.
I've wired it to my Pi : Yellow wire to TV round pin on the Pi, Red and Black wires to 5V and GND of my power supply.
Don't pay attention to the black tape and screen protector, they are temporary just here to protect the screen.
When i'll finish my GBZ i'll fix the @dominator screen surround glass I already have.
and the Camble's Safe Shutdown v1.2 for Adafruit Powerboost => Link
GBZ-Power-Monitor on the GBZ [RECALBOX 18.03]
I've managed to make the "GBZ-Power-Monitor" works on Recalbox v18.03
Here is how I've done that.
First of all Recalbox has no sudo command (user is root)
It doesn't have Git and it doesn't have crontab !
So, some little tricks are needed to make the Camble/GBZ-Power-Monitor_PB works :
Using WinSCP (or equivalent), create a folder "/recalbox/share/system/GBZ-Power-Monitor_PB" where you put the python script and the mp4 videos from Camble's Github.
I've done some little modifications in the python to make it works : remove all sudos and change the video paths
Code: Select all
#!/usr/bin/env python2.7
# date: 30/05/16
# author: Popcorn <abandonedemails@gmail.com> - Add "Sudomod" in the subject or your message will not be received
# version: 1.0a
# name: GBZ-Power-Monitor - a Power Management utility for the Gameboy Zero project
# description: a GPIO monitor that detects low battery and power switch status which provides a graceful shutdown facility
# source: https://github.com/Camble/GBZ-Power-Monitor_PB
import RPi.GPIO as GPIO
import os
import sys
import time
batteryGPIO = 17 # GPIO 17/pin 0
powerGPIO = 27 # GPIO 27/pin 2
sampleRate = 0.1 # tenth of a second
batteryTimeout = 10 # 10 seconds
powerTimeout = 1 # 1 second
shutdownVideo = "~/GBZ-Power-Monitor_PB/lowbattshutdown.mp4" # use no space or non-alphanum characters
lowalertVideo = "~/GBZ-Power-Monitor_PB/lowbattalert.mp4" # use no space or non-alphanum characters
playerFlag = 0
GPIO.setmode(GPIO.BCM)
GPIO.setup(batteryGPIO, GPIO.IN) # No pull_up_down for LBO with voltage clamped with diode
GPIO.setup(powerGPIO, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
def lowBattery(channel):
#Checking for LED bounce for the duration of the battery Timeout
for bounceSample in range(1, int(round(batteryTimeout / sampleRate))):
time.sleep(sampleRate)
if GPIO.input(batteryGPIO) is 1:
break
global playerFlag
while playerFlag is 1:
time.sleep(1)
#If the LED is a solid condition, there will be no bounce. Launch shutdown video and then gracefully shutdown
if bounceSample is int(round(batteryTimeout / sampleRate)) - 1:
playerFlag = 1
os.system("/usr/bin/omxplayer --no-osd --layer 999999 " + shutdownVideo + " --alpha 180;")
if GPIO.input(batteryGPIO) is 0:
os.system("sudo shutdown -h now")
playerFlag = 0
sys.exit(0)
#If the LED is a solid for more than 10% of the timeout, we know that the battery is getting low. Launch the Low Battery alert.
if bounceSample > int(round(batteryTimeout / sampleRate * 0.1)):
playerFlag = 1
os.system("/usr/bin/omxplayer --no-osd --layer 999999 " + lowalertVideo + " --alpha 160;")
playerFlag = 0
#Discovered a bug with the Python GPIO library and threaded events. Need to unbind and rebind after a System Call or the program will crash
GPIO.remove_event_detect(batteryGPIO)
GPIO.add_event_detect(batteryGPIO, GPIO.BOTH, callback=lowBattery, bouncetime=300)
#If we know the battery is low, we aggresively monitor the level to ensure we shutdown once the Power Timeout is exceeded.
lowBattery(batteryGPIO)
def powerSwitch(channel):
#Checking for LED bounce for the duration of the Power Timeout
for bounceSample in range(1, int(round(powerTimeout / sampleRate))):
time.sleep(sampleRate)
if GPIO.input(powerGPIO) is 1:
break
if bounceSample is int(round(powerTimeout / sampleRate)) - 1:
#When the Power Switch is placed in the off position with no bounce for the duration of the Power Timeout, we immediately shutdown
os.system("sudo shutdown -h now")
try:
sys.stdout.close()
except:
pass
try:
sys.stderr.close()
except:
pass
sys.exit(0)
def main():
#if the Low Battery LED is active when the program launches, handle it
if GPIO.input(batteryGPIO) is 0:
lowBattery(batteryGPIO)
#if the Power Switch is active when the program launches, handle it
if GPIO.input(powerGPIO) is 0:
powerSwitch(powerGPIO)
#Add threaded event listeners for the Low Battery and Power Switch
try:
GPIO.remove_event_detect(batteryGPIO)
GPIO.add_event_detect(batteryGPIO, GPIO.FALLING, callback=lowBattery, bouncetime=300)
GPIO.remove_event_detect(powerGPIO)
GPIO.add_event_detect(powerGPIO, GPIO.FALLING, callback=powerSwitch, bouncetime=300)
except KeyboardInterrupt:
GPIO.cleanup()
main()
#We make an endless loop so the threads running the GPIO events will always be listening, in the future we can add Battery Level monitoring here
while True:
time.sleep(1)
GPIO.cleanup()
Code: Select all
#!/bin/bash
NAME="S92gbzpower"
RUN="/recalbox/share/system/GBZ-Power-Monitor_PB/gbz_power_monitor.py"
BTD_PID=$(ps -eo pid,args | grep "/bin/bash $RUN" | grep -v grep | awk '{print $1}')
# Carry out specific functions when asked to by the system
case "$1" in
start)
recallog "Starting $NAME"
if [ -z "$BTD_PID" ]; then
nice -n 19 /usr/bin/python $RUN start&
if [ $? -eq 0 ]; then
recallog "script $RUN [ STARTED ]"
fi
else
recallog "script $RUN already started ["$BTD_PID"]!"
fi
;;
stop)
recallog "Stopping $NAME"
if [ ! -z "$BTD_PID" ]; then
kill $BTD_PID
if [ $? -eq 0 ]; then
recallog "script $RUN [ STOPPED ]"
fi
$RUN stop
else
recallog "script $RUN already stopped !"
fi
;;
status)
if [ ! -z "$BTD_PID" ]; then
echo "Service gbz_power_monitor.py ["$BTD_PID"] [ OK ]"
else
echo "Service gbz_power_monitor.py [ KO ]"
fi
;;
*)
echo "Usage: /etc/init.d/S92gbzpower {start | stop | status}"
exit 1
;;
esac
exit 0
Code: Select all
mount -o remount,rw /
Don't forget to make this new file executable. (chmod +x /etc/init.d/S06gbzpower)
@Popcorn & @Camble: Thanks again for this great feature
I've desoldered the GameBoy Cartridge connector
I've cut a piece of the metalic cartridge shield and done a little tuning of the cartridge reader to make it fit
Hot-glued the metalic part on the cartridge reader, then screw it in the origin holes.
And few gaffer so the metal part won't do short-cuts.
Wire soldered on the cartridge reader before I hot-glue the soldered pins. I've used an old ethernet cable.
Wire soldered on the Pi Zero (I've used PP8 for 3,3V and PP5 for GND)
After having hot-glued the soldered wires, a little test and everything works pretty well
Finally, I've decided to rewire it because the ethernet cable were too rigid and cumbersome.
I've used a flat cable.