SidSilver's GBZ

Show off your completed Game Boy Zero, or post your build logs here!
SidSilver
Posts: 263
Joined: Sun May 22, 2016 6:22 am
Location: France
Has thanked: 137 times
Been thanked: 37 times

SidSilver's GBZ

Post by SidSilver » Sat Jun 04, 2016 8:13 am

Hello everyone !

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
SpoilerShow
I've bought this brand new housing shell from EBay => Link
Image
Raspberry Pi Zero
SpoilerShow
I've bought my Pi Zero from Pimoroni => Link
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"
Don't forget to modify "/recalbox/share/system/recalbox.conf to set "global.videomode=default"
LCD Screen (320x240)
SpoilerShow
I've bought the screen from GearBest => Link

Hack to make it 5V (see wiki)
Image

Test with power from USB power supply and a camcorder as video input.
Image
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.
Image
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.
Buttons
SpoilerShow
Power Supply
SpoilerShow
I've bought the PowerBoost 1000C from Pimoroni => Link
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()
Then create a script "S92gbzpower" in "/etc/init.d" to launch the python script on startup

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
To do that you will need to make the folder writable, run the command

Code: Select all

mount -o remount,rw /
Recalbox reset the folder rights to make it read only on restart.
Don't forget to make this new file executable. (chmod +x /etc/init.d/S06gbzpower)
@Popcorn & @Camble: Thanks again for this great feature
Battery
SpoilerShow
I've bought an Adafruit LiPo 3.7V 2500mah from Robotics 4 Geek => Link
Audio
SpoilerShow
I'm waiting to see if I can get one integrated in my custom buttons PCB from Helder
Usb Hub
SpoilerShow
I'm waiting to see if I can get one integrated in my custom buttons PCB from Helder
Game Cartridge
SpoilerShow
I've bought a cartridge PCB from Prerunnerseth => Link
Image
Image
Cartridge Reader
SpoilerShow
I've bought a Super GameBoy from EBay
Image
I've desoldered the GameBoy Cartridge connector
Image
I've cut a piece of the metalic cartridge shield and done a little tuning of the cartridge reader to make it fit
Image
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.
Image
Wire soldered on the cartridge reader before I hot-glue the soldered pins. I've used an old ethernet cable.
Image
Wire soldered on the Pi Zero (I've used PP8 for 3,3V and PP5 for GND)
Image
After having hot-glued the soldered wires, a little test and everything works pretty well ;)
Image
Finally, I've decided to rewire it because the ethernet cable were too rigid and cumbersome.
I've used a flat cable.
Image
Miscellaneous
Game Cartridge LabelShow
Image

Image

Image
Last edited by SidSilver on Tue Mar 20, 2018 11:48 am, edited 23 times in total.

User avatar
DirtyBullets
Posts: 137
Joined: Tue May 17, 2016 4:05 pm
Location: Lowestoft, UK
Has thanked: 5 times
Been thanked: 42 times
Contact:

Re: SidSilver's GBZ

Post by DirtyBullets » Sat Jun 04, 2016 1:32 pm

Liking the game card reader idea because it has the ejector on it cos then you can have a smaller cleaner finish as i had to cut more cos you have to pick the card out with your fingernails.

would be interesting how it goes, Good luck :)

SidSilver
Posts: 263
Joined: Sun May 22, 2016 6:22 am
Location: France
Has thanked: 137 times
Been thanked: 37 times

Re: SidSilver's GBZ

Post by SidSilver » Sat Jun 18, 2016 11:07 am

Added the cartridge reader part. (to be completed when wired)

SidSilver
Posts: 263
Joined: Sun May 22, 2016 6:22 am
Location: France
Has thanked: 137 times
Been thanked: 37 times

Re: SidSilver's GBZ

Post by SidSilver » Sun Jun 19, 2016 11:48 am

Cartridge reader wiring complete. Everything is working nice :)
Waiting my Polulu switch to wire the power and the screen.

(for the pictures, see the first post. I update it)

User avatar
Rod2D2
Posts: 131
Joined: Thu May 05, 2016 5:08 am
Location: USA
Has thanked: 80 times
Been thanked: 17 times

Re: SidSilver's GBZ

Post by Rod2D2 » Mon Jun 20, 2016 10:31 pm

Have you tried to fire up the pi zero with the new SD card cartridge yet?

SidSilver
Posts: 263
Joined: Sun May 22, 2016 6:22 am
Location: France
Has thanked: 137 times
Been thanked: 37 times

Re: SidSilver's GBZ

Post by SidSilver » Tue Jun 21, 2016 12:12 am

Rod2D2 wrote:Have you tried to fire up the pi zero with the new SD card cartridge yet?
Yup, it works very well.

User avatar
joe7dust
Posts: 218
Joined: Mon Jun 06, 2016 4:13 am
Has thanked: 23 times
Been thanked: 7 times

Re: SidSilver's GBZ

Post by joe7dust » Thu Jun 23, 2016 3:58 am

SidSilver wrote:Hello everyone !

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
[spoiler=" "]I've bought this brand new housing shell from EBay => Link[/spoiler]
Raspberry Pi Zero
[spoiler=" "]I've bought my Pi Zero from Pimoroni => Link[/spoiler]
LCD Screen (320x240)
[spoiler=" "]I've bought the screen from GearBest => Link

Hack to make it 5V (see wiki)
Image

Test with power from USB power supply and a camcorder as video input.
Image[/spoiler]
Buttons
[spoiler=" "][/spoiler]
Power Supply
[spoiler=" "]I've bought the PowerBoost 1000C from Pimoroni => Link
and the Pololu Mini MOSFET Slide Switch, LV from Gotronic => Link[/spoiler]
Battery
[spoiler=" "]I've bought an Adafruit LiPo 3.7V 2500mah from Robotics 4 Geek => Link[/spoiler]
Audio
[spoiler=" "]I'm waiting to see if I can get one integrated in my custom buttons PCB from Helder[/spoiler]
Usb Hub
[spoiler=" "]I've bought a Hama 4 ports from Amazon => Link[/spoiler]
Game Cartridge
[spoiler=" "]I've bought a cartridge PCB from Prerunnerseth => Link
Image
Image[/spoiler]
Cartridge Reader
[spoiler=" "]I've bought a Super GameBoy from EBay
Image
I've desoldered the GameBoy Cartridge connector
Image
I've cut a piece of the metalic cartridge shield and done a little tuning of the cartridge reader to make it fit
Image
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.
Image
Wire soldered on the cartridge reader before I hot-glue the soldered pins. I've used an old ethernet cable.
Image
Wire soldered on the Pi Zero (I've used PP8 for 3,3V and PP5 for GND)
Image
After having hot-glued the soldered wires, a little test and everything works pretty well ;)
Image[/spoiler]
Miscellaneous
[spoiler=" "][/spoiler]
How did you know to run that small cable to make it work on 5v? I'm afraid to even solder it with the pins on that chip being 1mm apart. I definitely never would have known to run a cable there. O_o

SidSilver
Posts: 263
Joined: Sun May 22, 2016 6:22 am
Location: France
Has thanked: 137 times
Been thanked: 37 times

Re: SidSilver's GBZ

Post by SidSilver » Thu Jun 23, 2016 4:02 am

joe7dust wrote: How did you know to run that small cable to make it work on 5v? I'm afraid to even solder it with the pins on that chip being 1mm apart. I definitely never would have known to run a cable there. O_o
I've just read the wiki :)

User avatar
joe7dust
Posts: 218
Joined: Mon Jun 06, 2016 4:13 am
Has thanked: 23 times
Been thanked: 7 times

Re: SidSilver's GBZ

Post by joe7dust » Thu Jun 23, 2016 4:05 am

SidSilver wrote:
joe7dust wrote: How did you know to run that small cable to make it work on 5v? I'm afraid to even solder it with the pins on that chip being 1mm apart. I definitely never would have known to run a cable there. O_o
I've just read the wiki :)
It just shows a picture of the cable soldered on and gives this post as a reference so I thought it was your original hack.
Last edited by joe7dust on Thu Jun 23, 2016 4:42 am, edited 1 time in total.

SidSilver
Posts: 263
Joined: Sun May 22, 2016 6:22 am
Location: France
Has thanked: 137 times
Been thanked: 37 times

Re: SidSilver's GBZ

Post by SidSilver » Thu Jun 23, 2016 4:40 am

joe7dust wrote:
SidSilver wrote:
joe7dust wrote: How did you know to run that small cable to make it work on 5v? I'm afraid to even solder it with the pins on that chip being 1mm apart. I definitely never would have known to run a cable there. O_o
I've just read the wiki :)
It just shows a picture of the cable soldered on and gives this post as a reference so I thought it was your original hack.
Actually, I added a ref to my project because it uses the same screen. But if you look carrefully, you'll see that the color of the wire is not the same ;) I've used a red wire, in the wiki its yellow.

To mod those boards, you need electronics knowledge and analysis of the board design to figure out how it works.

I think there is a chip to make 12V to 5V, so if you put 5V , you should bypass the chip. That's my understanding.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest