sabas1080 / pypboy

Python/Pygame interface, emulating that of the Pipboy-3000. Uses OSM for map data and has been partially tailored to respond to physical switches over Raspberry Pi's GPIO and TFT 2.8" Capacitive Adadfruit
https://learn.adafruit.com/raspberry-pi-pipboy-3000/overview
84 stars 54 forks source link

Raspberry-Pi Implementation Problem #2

Open SharpworksGames opened 7 years ago

SharpworksGames commented 7 years ago

I recently began trying Adafruit's Raspberry Pi Pipboy project which involves attaching several computer chips to the raspberry pi for the sound and a rechargeable battery. I also had to attach a 12 position rotary switch (the tutorial says 10 position but I could only find a 12 position, and I just used 5 positions instead of 6) and I believe this might be part of the problem I'm having. When I start the program, it boots up normally, but when the actual pipboy part comes up it starts to bug out. The program tries to switch between the different screens multiple times per second, or at least I assume that it does because all I can hear is the sound effect for switching modes. I know it is not frozen, however, because when I press the keyboard controls on a USB keyboard fast enough, the screen sometimes switches to the map for a split second.

I'm pretty new to coding in general and only know Java and C#, so if I need to change the program then I will need help knowing what to do.

Also worth noting that I'm using a 3.5" PiTFT touchscreen and a Raspberry Pi 3.

TheOneTheDave commented 7 years ago

Did you ever get it working? I'm having the same problem.

SharpworksGames commented 7 years ago

No, I don't know Python yet, so I couldn't fix it.

SharpworksGames commented 7 years ago

If you get it to work though, let me know what you did

CraigHissett commented 7 years ago

If you have a look in the config.py file there's the two following arrays of actions and GPIO pin actions. As far as I can see the ACTIONS array ties functions to keyboard presses, and the GPIO_ACTIONS ties activity on the GPIO pins to the same functions. Are your rotary switches connected to the same pins as listed in the config?

ACTIONS = { pygame.K_F1: "module_stats", pygame.K_F2: "module_items", pygame.K_F3: "module_data", pygame.K_1: "knob_1", pygame.K_2: "knob_2", pygame.K_3: "knob_3", pygame.K_4: "knob_4", pygame.K_5: "knob_5", pygame.K_UP: "dial_up", pygame.K_DOWN: "dial_down" }

Using GPIO.BCM as mode

GPIO_ACTIONS = { 4: "module_stats", #GPIO 4 14: "module_items", #GPIO 14 15: "module_data", #GPIO 15 17: "knob_1", #GPIO 17 18: "knob_2", #GPIO 18 7: "knob_3", #GPIO 7 22: "knob_4", #GPIO 22 23: "knob_5", #GPIO 27

31: "dial_up", #GPIO 23

27: "dial_down" #GPIO 7

}

SharpworksGames commented 7 years ago

I'll try that out later today and post if it worked

boiler02 commented 7 years ago

I assume no one has been able to resolve this yet?

NelsonPJ commented 6 years ago

I've been struggling with this too - but finally figured it out today! When the GPIO pins are setup as inputs, they are not specified to use the built in pullup resistors.

In the module /pypboy/pypboy/core.py, in the line starting with GPIO.setup, add “pull_up_down=GPIO.PUD_UP” at the end of the statement like this:

    def init_gpio_controls(self):
            for pin in config.GPIO_ACTIONS.keys():
                print "Intialising pin %s as action '%s'" % (pin, config.GPIO_ACTIONS[pin])
                GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
                self.gpio_actions[pin] = config.GPIO_ACTIONS[pin]

I also had to change my GPIO pin assignments because with my Adafruit TFT installation, GPIO pin 23 is set to shutdown the system. I used these assignments in /pypboy/config.py (I haven't wired up hardware for the other inputs yet - only the rotary switch)

# Using GPIO.BCM as mode
GPIO_ACTIONS = {
#    4: "module_stats", 
#       14: "module_items",
#       15: "module_data", 
       4:  "knob_1",
       17: "knob_2",
       27: "knob_3",
       22: "knob_4",
       7: "knob_5",
#       31: "dial_up",
#       27: "dial_down" 
}

Another thing I noticed by watching error messages in the terminal window is that there some sort of "status LED" setup to use GPIO pin 28 (as defined in GPIO_LED_ID)

I commented out the definition of GPIO_LED_ID in module pypboy/pypboy/modules/data/init.py

GPIO_LED_ID = 28 #GPIO 23 #23

And GPIO_LED_ID is also used in pypboy/pypboy/init.py in a few places that I also commented out (you will get error messages showing where they are if you comment out the GPIO_LED_ID definition above)

Charhea commented 6 years ago

hey there, sry for that question, but how did i get start the pipboy installation?? i dont knowe anything about linux / python. can anyone help me? what should i doo with these code above? thanks for a fast reply