PetRockBlock https://blog.petrockblock.com Fun Stuff for Technics Enthusiasts Mon, 25 Jun 2018 01:55:13 +0000 en-US hourly 1 Design Patterns with PlantUML: Decorator Pattern https://blog.petrockblock.com/2018/06/24/design-patterns-plantuml-decorator-pattern/ https://blog.petrockblock.com/2018/06/24/design-patterns-plantuml-decorator-pattern/#respond Sun, 24 Jun 2018 18:35:04 +0000 https://blog.petrockblock.com/?p=125257 This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML …

The post Design Patterns with PlantUML: Decorator Pattern appeared first on PetRockBlock.

]]>
This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The article aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML diagram. Then, the second part provides the PlantUML code for the diagram so that these posts can also be used as a source of design patterns in PlantUML syntax.

What is the Decorator Pattern?

According to Wikipedia, the decorator pattern is a design pattern that allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class. The decorator pattern is often useful for adhering to the Single Responsibility Principle, as it allows functionality to be divided between classes with unique areas of concern.

UML Diagram

The following diagram shows the Decorator Pattern in UML notation. It is based on the corresponding chapter in the book “Head First Design Patterns“:

PlantUML Syntax:
<p>@startuml<br />
skinparam componentStyle uml2</p>
<p>class Component<br />
class ConcreteComponent<br />
class Decorator<br />
class ConcreteDecoratorA<br />
class ConcreteDecoratorB</p>
<p>Component : methodA()<br />
Component : methodB()<br />
Component : // otherMethods()</p>
<p>ConcreteComponent : methodA()<br />
ConcreteComponent : methodB()<br />
ConcreteComponent : // otherMethods()</p>
<p>Decorator : methodA()<br />
Decorator : methodB()<br />
Decorator : // otherMethods()</p>
<p>ConcreteDecoratorA : Component wrappedObject<br />
ConcreteDecoratorA : methodA()<br />
ConcreteDecoratorA : methodB()<br />
ConcreteDecoratorA : newBehavior()<br />
ConcreteDecoratorA : // otherMethods()</p>
<p>ConcreteDecoratorB : Component wrappedObject<br />
ConcreteDecoratorB : Object newState<br />
ConcreteDecoratorB : methodA()<br />
ConcreteDecoratorB : methodB()<br />
ConcreteDecoratorB : // otherMethods()</p>
<p>Component <|– ConcreteComponent<br />
Component <|– Decorator<br />
Decorator <|– ConcreteDecoratorA<br />
Decorator <|– ConcreteDecoratorB<br />
Decorator –> Component : component<br />
note right on link<br />
Each component can be used on its<br />
own, or wrapped by a decorator<br />
component<br />
end note</p>
<p>note bottom of ConcreteComponent<br />
The ConreteComponent<br />
is the object we are going<br />
to dynamically add new<br />
behavior to it. It extends<br />
Component.<br />
end note</p>
<p>note bottom of Decorator<br />
Decorators implement the<br />
same interface or abstract<br />
class as the component they<br />
are going to decorate.<br />
end note</p>
<p>note bottom of ConcreteDecoratorB<br />
Decorators can extend the<br />
state of the component<br />
end note</p>
<p>note bottom of ConcreteDecoratorB<br />
Decorators can add new methods;<br />
however, new behavior is typically<br />
added by doing computation<br />
before or after an existing method<br />
in the component.<br />
end note</p>
<p>note bottom of ConcreteDecoratorA<br />
The ConcreteDecorator has an<br />
instance variable for the thing<br />
it decorates (the Component the<br />
Decorator wraps).<br />
end note<br />
@enduml</p>

PlantUML Sources

PlantUML is a tool allowing users to create UML diagrams from a plain text language. Here are the PlantUML sources for the above software pattern:


@startuml
skinparam componentStyle uml2

class Component
class ConcreteComponent
class Decorator
class ConcreteDecoratorA
class ConcreteDecoratorB

Component : methodA()
Component : methodB()
Component : // otherMethods()

ConcreteComponent : methodA()
ConcreteComponent : methodB()
ConcreteComponent : // otherMethods()

Decorator : methodA()
Decorator : methodB()
Decorator : // otherMethods()

ConcreteDecoratorA : Component wrappedObject
ConcreteDecoratorA : methodA()
ConcreteDecoratorA : methodB()
ConcreteDecoratorA : newBehavior()
ConcreteDecoratorA : // otherMethods()

ConcreteDecoratorB : Component wrappedObject
ConcreteDecoratorB : Object newState
ConcreteDecoratorB : methodA()
ConcreteDecoratorB : methodB()
ConcreteDecoratorB : // otherMethods()

Component <|-- ConcreteComponent
Component <|-- Decorator
Decorator <|-- ConcreteDecoratorA
Decorator <|-- ConcreteDecoratorB
Decorator --> Component : component

@enduml

Other Design Patterns

In another article you find information about how to put together a single-side web application using PlantUML.

Decorator Pattern Design Patterns with PlantUML: Decorator Pattern - This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design ... Read More
Observer Pattern Design Patterns with PlantUML: Observer Pattern - This post gives a brief overview about the Observer Pattern. The post is part of a series about software design ... Read More

The post Design Patterns with PlantUML: Decorator Pattern appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/06/24/design-patterns-plantuml-decorator-pattern/feed/ 0
Design Patterns with PlantUML: Observer Pattern https://blog.petrockblock.com/2018/06/24/design-patterns-plantuml-observer-pattern/ https://blog.petrockblock.com/2018/06/24/design-patterns-plantuml-observer-pattern/#respond Sun, 24 Jun 2018 18:25:35 +0000 https://blog.petrockblock.com/?p=125241 This post gives a brief overview about the Observer Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The post aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML …

The post Design Patterns with PlantUML: Observer Pattern appeared first on PetRockBlock.

]]>
This post gives a brief overview about the Observer Pattern. The post is part of a series about software design patterns and their UML representations with the help of PlantUML. The post aims at providing a very short description of the general idea of the pattern in the first part. This also involves a descriptive UML diagram. Then, the second part provides the PlantUML code for the diagram so that these posts can also be used as a source of design patterns in PlantUML syntax.

What is the Observer Pattern?

According to Wikipedia, the observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems, in “event driven” software.

The pattern addresses these problems:

  • A one-to-many dependency between objects should be defined without making the objects tightly coupled.
  • It should be ensured that when one object changes state an open-ended number of dependent objects are updated automatically.
  • It should be possible that one object can notify an open-ended number of other objects.

UML Diagram

The following diagram shows the Observer Pattern in UML notation. It is based on the corresponding chapter in the book “Head First Design Patterns“:

PlantUML Syntax:
<p>@startuml</p>
<p>title Observer Pattern</p>
<p>class Subject <<interface>><br />
class Observer <<interface>><br />
class ConcreteSubject<br />
class ConcreteObserver</p>
<p>Subject : registerObserver(Observer)<br />
Subject : removeObserver(Observer)<br />
Subject : notifyObservers()</p>
<p>Observer : update()<br />
ConcreteObserver : update()<br />
ConcreteObserver : // otherObserverMethods()</p>
<p>ConcreteSubject : registerObserver(Observer) {…}<br />
ConcreteSubject : removeObserver(Observer) {…}<br />
ConcreteSubject : notifyObservers() {…}</p>
<p>Subject “1” -right-> “*” Observer : “observers”</p>
<p>ConcreteSubject <-left- ConcreteObserver : “subject”<br />
Subject <|– ConcreteSubject<br />
Observer <|— ConcreteObserver</p>
<p>note left of Subject<br />
The Subject Interface<br />
Objects use this interface to register<br />
as observers and also to remove<br />
themselves from being observers.<br />
end note</p>
<p>note left of ConcreteSubject<br />
A concrete subject always<br />
implements the Subject<br />
interface. In addition to<br />
the register and remove<br />
methods, the concrete subject<br />
implements a notifyObservers()<br />
method that is used to update<br />
all the current observers<br />
whenever state changes.<br />
end note</p>
<p>note bottom of ConcreteSubject<br />
The conrete subject<br />
may also have methods for<br />
setting and getting its state.<br />
end note</p>
<p>note bottom of ConcreteObserver<br />
Concrete observers can be<br />
any class that implements the<br />
Observer interface. Each<br />
observer registers with a concrete<br />
subject to receive updates.<br />
end note</p>
<p>note top of Observer<br />
All potential observers need<br />
to implement the Observer<br />
interface. This interface<br />
just has one method, update(),<br />
that gets called when the<br />
Subject’s state changes.<br />
end note</p>
<p>@enduml</p>

PlantUML Sources

PlantUML is a tool allowing users to create UML diagrams from a plain text language. Here are the PlantUML sources for the above software pattern:

@startuml
title Observer Pattern

class Subject <<interface>>
class Observer <<interface>>
class ConcreteSubject
class ConcreteObserver

Subject : registerObserver(Observer)
Subject : removeObserver(Observer)
Subject : notifyObservers()

Observer : update()
ConcreteObserver : update()
ConcreteObserver : // otherObserverMethods()

ConcreteSubject : registerObserver(Observer) {...}
ConcreteSubject : removeObserver(Observer) {...}
ConcreteSubject : notifyObservers() {...}

Subject "1" -right-> "*" Observer : "observers"

ConcreteSubject <-left- ConcreteObserver : "subject"
Subject <|-- ConcreteSubject
Observer <|-- ConcreteObserver
@enduml 

Other Design Patterns

In another article you find information about how to put together a single-side web application using PlantUML.

Here is a list of posts with other Design Patterns:

Decorator Pattern Design Patterns with PlantUML: Decorator Pattern - This post gives a brief overview about the Decorator Pattern. The post is part of a series about software design ... Read More
Observer Pattern Design Patterns with PlantUML: Observer Pattern - This post gives a brief overview about the Observer Pattern. The post is part of a series about software design ... Read More

The post Design Patterns with PlantUML: Observer Pattern appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/06/24/design-patterns-plantuml-observer-pattern/feed/ 0
Tutorial: ControlBlock with RetroPie and SNES or NES Controllers https://blog.petrockblock.com/2018/04/15/controlblock-retropie-snes/ https://blog.petrockblock.com/2018/04/15/controlblock-retropie-snes/#respond Sun, 15 Apr 2018 12:12:37 +0000 https://blog.petrockblock.com/?p=125115 Introduction This is a post as part of a tutorial series about getting to start with the ControlBlock with various images for the Raspberry Pi. In this tutorial we will learn how to use the ControlBlock with RetroPie and SNES or NES Controllers. Preparation If you have not already done it, we need to download …

The post Tutorial: ControlBlock with RetroPie and SNES or NES Controllers appeared first on PetRockBlock.

]]>
Introduction

This is a post as part of a tutorial series about getting to start with the ControlBlock with various images for the Raspberry Pi. In this tutorial we will learn how to use the ControlBlock with RetroPie and SNES or NES Controllers.

Preparation

Tutorial: ControlBlock with SNES and NES Controllers
If you have not already done it, we need to download the RetroPie image first. You get the image on the official RetroPie downloads site. When you have downloaded the image you need to load it on your SD card. You can follow the Raspberry Pi Software guide for that, if you are unsure how to do that.

Installing the ControlBlock Hardware

Make sure that the Raspberry Pi is switched off before you do any hardware work on it. Attach the ControlBlockBlock with its female header to the GPIO pins of the Raspberry Pi as shown on the following image:

ControlBlock with attached Power Switch and Status LED
ControlBlock with attached Power Switch and Status LED

Attach your power switch to the two pins that are marked with “Switch”. Again, the above image shows that exemplarily.

Attach the micro USB connector of your power supply to the micro USB connector of the PowerBlock:

ControlBlock with attached micro USB power cable
ControlBlock with attached micro USB power cable
It is important that you connect your switch to the ControlBlock before you connect the micro USB cable of your power supply. Otherwise the Raspberry Pi will start with an endless loop of booting and shutting down.

Connecting SNES and NES Controllers

The ControlBlock can also be used to poll NES and SNES controllers. Here is a diagram that describes the pin out for using NES and SNES controllers with the ControlBlock:

ControlBlockLayoutSNESNES

Here is a pin out diagram for NES and SNES connectors:

If you want to use a SNES case, here is a diagram that shows the pin out of the original SNES controller front:

SNES Controller Front Pin Out
SNES Controller Front Pin Out

You can also connect a latching reset button to Player-1, Input B. If the button is pressed a virtual ESC-key press will be triggered.

In order to poll NES and SNES controllers the configuration in the file /etc/controlblockconfig.cfg must set “gamepadtype” to “snes”:

    "gamepadtype" : "snes"

You can start editing that file, for example, with the command

sudo nano /etc/controlblockconfig.cfg

After making the needed changes you can save and exit the editor with “Ctrl-X” and “y”.

 

Installing the ControlBlock Service

We install the ControlBlock driver from the console via SSH. In order to install the ControlBlock driver and service we can follow the quick installation instructions as given on the driver Github site. To install the driver and the service you just need to call this one command:

wget -O - https://raw.githubusercontent.com/petrockblog/ControlBlockService2/master/install.sh | sudo bash

That command will download the installation script of the ControlBlock service and start the script. It will compile and install the driver as well as install and start the service:

When the script is finished, you get a success or failure message in the console. In case of a success, you can also see that the optional status LED stopped to flash and, instead, is permanently switched on.

Configuring RetroPie

After the ControlBlock service is installed, you can start the input configuration within EmulationStation. If everything is wired and set up correctly, EmulationStation will recognise the button presses of the SNES/NES controllers correctly and configure everything with the input assistant accordingly.

Conclusion

As you can see, getting started with the ControlBlock involves very few steps. We hope you enjoy your ControlBlock and wish you good luck with your project!

The post Tutorial: ControlBlock with RetroPie and SNES or NES Controllers appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/04/15/controlblock-retropie-snes/feed/ 0
All gadgets fully compatible with Raspberry Pi 3 Model B+ https://blog.petrockblock.com/2018/04/14/compatibility-rpi-3-model-b-plus/ https://blog.petrockblock.com/2018/04/14/compatibility-rpi-3-model-b-plus/#respond Sat, 14 Apr 2018 10:53:41 +0000 https://blog.petrockblock.com/?p=125104 Hi everyone! This is a short post about the compatibility of our boards with the new Raspberry Pi model. As you probably already have heard the Raspberry Pi 3 Model B+ was recently released.  Compared to its predecessor it offers We checked all our gadgets – the PowerBlock, ControlBlock, and the GamepadBlock – and we …

The post All gadgets fully compatible with Raspberry Pi 3 Model B+ appeared first on PetRockBlock.

]]>
Raspberry Pi 3 Model B+ (TM) CompatibilityHi everyone! This is a short post about the compatibility of our boards with the new Raspberry Pi model.

As you probably already have heard the Raspberry Pi 3 Model B+ was recently released.  Compared to its predecessor it offers

  • a quad-core processor,
  • dual-band wireless LAN,
  • Bluetooth 4.2/BLE,
  • faster Ethernet,
  • and Power-over-Ethernet support.

We checked all our gadgets – the PowerBlock, ControlBlock, and the GamepadBlock – and we are happy to tell you all of them are fully compatible with this new Raspberry Pi model.

This already concludes our brief post.

Have fun and good luck with your projects!

The post All gadgets fully compatible with Raspberry Pi 3 Model B+ appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2018/04/14/compatibility-rpi-3-model-b-plus/feed/ 0
GamepadBlock: New Firmware V1.2.0 Now Supports Amiga, C64, and Equal Joysticks https://blog.petrockblock.com/2017/11/19/gamepadblock-firmware-supports-amiga-c64/ https://blog.petrockblock.com/2017/11/19/gamepadblock-firmware-supports-amiga-c64/#respond Sun, 19 Nov 2017 10:24:07 +0000 https://blog.petrockblock.com/?p=124683 The GamepadBlock is an Arcade and Original Game Controller USB Interface for your computer. It lets you connect your favourite arcade and original game controllers to your PC via USB. With the release of the GamepadBlock a few weeks ago we got asked to add support for further joystick. We are happy to announce today that we have …

The post GamepadBlock: New Firmware V1.2.0 Now Supports Amiga, C64, and Equal Joysticks appeared first on PetRockBlock.

]]>
The GamepadBlock is an Arcade and Original Game Controller USB Interface for your computer. It lets you connect your favourite arcade and original game controllers to your PC via USB.

With the release of the GamepadBlock a few weeks ago we got asked to add support for further joystick. We are happy to announce today that we have released a new firmware that adds support for joysticks from Amiga, C64, C128, VC20 and computers with equal D-SUB 9 joystick pinout.

Joystick Competition PRO GamepadBlock with D-SUB 9 Connector

The GamepadBlock Updater lets you update the firmware in just a few steps. If you have any questions or comments feel free to get in touch with us.

 

Have fun!

 

The post GamepadBlock: New Firmware V1.2.0 Now Supports Amiga, C64, and Equal Joysticks appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2017/11/19/gamepadblock-firmware-supports-amiga-c64/feed/ 0
GamepadBlock Updater: Updating the firmware of the GamepadBlock https://blog.petrockblock.com/2017/11/12/gamepadblock-updater-updating-firmware-gamepadblock/ https://blog.petrockblock.com/2017/11/12/gamepadblock-updater-updating-firmware-gamepadblock/#comments Sun, 12 Nov 2017 12:39:27 +0000 https://blog.petrockblock.com/?p=124629 The GamepadBlock is an Arcade and Original Game Controller USB Interface for your computer. It lets you connect your favourite arcade and original game controllers. The firmware of the GamepadBlock can be updated via USB with the tool “GamepadBlock Updater”. This tutorial describes in detail how to do a firmware update with it. GamepadBlock Updater – The Firmware …

The post GamepadBlock Updater: Updating the firmware of the GamepadBlock appeared first on PetRockBlock.

]]>
The GamepadBlock is an Arcade and Original Game Controller USB Interface for your computer. It lets you connect your favourite arcade and original game controllers. The firmware of the GamepadBlock can be updated via USB with the tool “GamepadBlock Updater”. This tutorial describes in detail how to do a firmware update with it.

Please note that there is a newer update tool for the GamepadBlock. It is a command line tool and should works more reliable than the first update tool on multiple platforms.

You can find the new update tool on the GamepadBlock Downloads page.

GamepadBlock Updater – The Firmware Update Tool

As mentioned above the firmware of the GamepadBlock can be updates via USB. This means that you do not need any additional tools or cables. Furthermore, a firmware update can be done without disconnecting the wires to the controllers. To make the update as easy as possible we provide an update tool that we creatively named “GamepadBlock Updater”:

GamepadBlock Updater

The sources of the tool can be found at Github. Technically, it is a self-executable Python-based TkInter application.

Download

The tool is available for various platforms and is about 10 MB large. You find the download links for the various platforms below:

 

After the download you just need to unpack the archive. This gives you a single executable that you can just start to get the GamepadBlock Updater running. Right after the start, the tool connects to Github and looks for the most recent firmware for the GamepadBlock. Depending on your internet connection this can take a few seconds, so do not worry, if the GUI is not immediately showing up. When the GUI appears everything is ready for the firmware update.

How To: Updating the Firmware

Now that you have downloaded, unpacked, and started the GamepadBlock Updater, what to do next? Follow the instructions on the GUI! Usually, the firmware update is a four steps procedure:

  • You start with step 1 at the top of the GUI: Connect the GamepadBlock to the machine where the update tool is running (if that is not already the case).
  • Then, in step 2, click the “Start Search” button to let the update tool connect with the GamepadBlock. When the update tool finds a GamepadBlock it reads out the currently installed firmware and shows it in the GUI.
  • In step 3 you are asked to press the “Reset” button on the GamepadBlock. Do that and confirm  that you actually have pressed “Reset” by pressing the button “Ok, I have pressed the reset button”.
    GamepadBlock Updater
    To set the GamepadBlock into update mode, you need to press the “Reset” button.
  • In the finishing step 4, you can start to download the new firmware with the “Start Download” button. You get an information message at the bottom of the GUI about the success of the download process.

That is all!

Conclusion

The GameapadBlock Updater lets you download new firmwares to the GamepadBlock. To do so, it automatically downloads the most recent firmware. We hope that the GamepadBlock Updater is easy to use. However, if you find any bugs or if you have any suggestion for further enhancing the tool, feel free to contact us!

The post GamepadBlock Updater: Updating the firmware of the GamepadBlock appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2017/11/12/gamepadblock-updater-updating-firmware-gamepadblock/feed/ 1
Tutorial: Using the virtual COM port of the GamepadBlock https://blog.petrockblock.com/2017/11/11/using-virtual-com-port-gamepadblock/ https://blog.petrockblock.com/2017/11/11/using-virtual-com-port-gamepadblock/#respond Sat, 11 Nov 2017 20:49:22 +0000 https://blog.petrockblock.com/?p=124612 This tutorial explains the virtual COM port of the GamepadBlock. It can be used, for example,  to switch the Controller Mode of the GamepadBlock. The Controller Mode itself is explained in more details and also an example for Python will be shown and  explained. The Controller Mode The controller mode determines how the GamepadBlock polls …

The post Tutorial: Using the virtual COM port of the GamepadBlock appeared first on PetRockBlock.

]]>
This tutorial explains the virtual COM port of the GamepadBlock. It can be used, for example,  to switch the Controller Mode of the GamepadBlock. The Controller Mode itself is explained in more details and also an example for Python will be shown and  explained.

The Controller Mode

GamepadBlock DIP Switch for Controller Mode
GamepadBlock DIP Switch for Controller Mode

The controller mode determines how the GamepadBlock polls the terminal inputs. You need to set the three DIP switches according to the controller that you want to attach to the GamepadBlock.

To activate the DIP switch configuration, you need to unplug and reattach the micro USB cable. You can find a table that shows all possible switch settings for the supported controller types on the GamepadBlock page.

The Virtual COM Port of the GamepadBlock

Besides the DIP switch you can also use the virtual COM port that is provided by the GamepadBlock. For example: Imagine you have SNES and NES controllers connected to a single GamepadBlock. Now, you want to activate SNES controllers for SNES emulators and NES controllers for NES emulators. You decide for your project to use a push button to toggle between these two modes.

Besides switching the Controller Mode, the virtual COM port can also be used to read out the currently installed firmware version and also to read out the currently active Controller Mode.

In order to connect to the COM port, you need to use these settings:

Baud rate: 115200
Data bits: 8
Parity: None
Stop Bits: 1

Any terminal program or scripting language that is capable of communicating with serial ports can be used.

Connecting to the COM port via Python

In the following we will use Python to connect for connecting to the COM port from a Linux system. In the example, we use a RetroPie image, which is based on Raspbian.

We will use the PySerial package in the following example. First of all, we need to make sure that we have that package installed. We achieve this with the following command:

sudo apt-get install -y python-pip
sudo pip install pyserial

We need to find the COM port of the GamepadBlock. To get a list of all possible ports you can use this command:

ls /dev/tty*

The output of that command lists all TTY ports available on the system. If not sure, which port belongs to the GamepadBlock, you can disconnect the GamepadBlock, list all TTY ports, reconnect the GamepadBlock and list all TTY ports again. The newly added TTY port is the GamepadBlock.

Here is a brief Python script that shows how to connect to the GamepadBlock, and read out the firmware version and currently active controller mode:

#!/usr/bin/env python

import serial

serialPort = serial.Serial("/dev/ttyACM0", baudrate=115200, bytesize=8, parity=serial.PARITY_NONE, stopbits=1, timeout=1)  # open serial port
serialPort.write("v".encode())  # send v character
readValue = serialPort.read(size=64)  # read up to 64 bytes. Timeout after 1 second as set above.
serialPort.write("c".encode())  # send c character
currentMode = serialPort.read(size=64)  # read up to 64 bytes. Timeout after 1 second as set above.
serialPort.close()  # close serial port
print("Firmware Version is " + str(readValue))  # print firmware version
print("Current controller mode is " + str(currentMode))  # print current controller mode

Assuming that the code above was put into the file comPortDemo.py the output of a call of that  file could look like this:

pi@retropie:~ $ ./comPortDemo.py
Firmware Version is 1.1.0

Current controller mode is 1

pi@retropie:~ $

Supported Commands

Once connected to the COM port, the GamepadBlock implements a very simple protocol: Receive one character, reply accordingly

These are the commands that the GamepadBlock supports:

Character Description
V Returns the number of the current firmware version
C Returns the number of the currently active controller mode
0 Switch to controller mode 0: Arcade
1 Switch to controller mode 1: SNES
2 Switch to controller mode 2: NES
3 Switch to controller mode 3: Genesis/Megadrive/Master System/Atari

Conclusion

We have explained the use cases for the virtual COM port of the GamepadBlock. The COM port can be accessed with a baud rate of 115200 and 8N1 configuration. Python can be used to write to and read from the serial port quite easily. The PySerial package makes the communication over a serial COM port easy. The communication protocol of the GamepadBlock was also described.

If you have any question, suggestion or comment feel free to contact us!

The post Tutorial: Using the virtual COM port of the GamepadBlock appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2017/11/11/using-virtual-com-port-gamepadblock/feed/ 0
GamepadBlock – Universal Game Controller USB Interface https://blog.petrockblock.com/2017/10/13/gamepadblock-game-controller-usb-interface/ https://blog.petrockblock.com/2017/10/13/gamepadblock-game-controller-usb-interface/#comments Fri, 13 Oct 2017 11:25:25 +0000 https://blog.petrockblock.com/?p=124483 Retro-Gaming is popular. And a lot of people are building their own arcade machines or gaming consoles as personal projects. Part of these projects is to decide which hardware to use for accessing the arcade controls or gamepads. If original gamepads should be used this decision becomes even harder. And what if you want to …

The post GamepadBlock – Universal Game Controller USB Interface appeared first on PetRockBlock.

]]>
Retro-Gaming is popular. And a lot of people are building their own arcade machines or gaming consoles as personal projects. Part of these projects is to decide which hardware to use for accessing the arcade controls or gamepads. If original gamepads should be used this decision becomes even harder. And what if you want to connect various types of game controllers? What about a multi-platform, universal game controller USB interface for that purpose?

What is special about the GamepadBlock?

There already exist USB interfaces that allow you to connect arcade controls. And there are also other USB interfaces that allow you to connect one type of original game controllers or another type of controllers. In some cases these interfaces also only allow to connect a controller for one player. The key feature of the GamepadBlock is that it supports a whole range of controller types at the same time. It, therefore, combines several of the individually available adapters within one device. And since the GamepadBlock is USB HID-compliant, it can be used on Windows, MacOS, and Linux including system-on-chip platforms like the Raspberry Pi™ or Odroid. For all gaming consoles that are supported two gamepads can be connected. And you can even switch between the controller types via a virtual COM port.

Starting with a Game Controller Interface for the Raspberry Pi

So far we have released the ControlBlock, which is an add-on board only for the Raspberry Pi. It provides ways for easily connecting arcade and original controllers to the Raspberry Pi™ (besides a power switch on-off functionality). However, people also asked for a game controller hardware interface like the ControlBlock that could be used on additional platforms other than the Raspberry Pi. Windows, MacOS, and, of course, other Linux-based systems.

Get Ready for the GamepadBlock

Today we are presenting the GamepadBlock: It is a Game Controller USB Interface for arcade and original game controllers.

GamepadBlock: A Universal Game Controller USB Interface
GamepadBlock: A Universal Game Controller USB Interface

It is a USB HID compatible device that works with Windows, MacOS, and Linux such that no drivers need to be installed. Besides arcade joystick and button controls also NES, SNES, Megadrive/Genesis, Master System, and Atari controllers are currently supported. In addition the GamepadBlock allows firmware updates via USB. Therefore, it is ready for future updates that, for example, extend the list of supported gamepads! And if you want to dynamically switch between various controller types on your gaming machine, it is even possible to do so via a virtual USB COM port.

More  Infos

Are you interested in more details about the development? We are preparing a development blog post, feel free to comment for any suggestions or questions!

The post GamepadBlock – Universal Game Controller USB Interface appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2017/10/13/gamepadblock-game-controller-usb-interface/feed/ 1
Tutorial: GamepadBlock with Debian / Ubuntu https://blog.petrockblock.com/2017/10/10/tutorial-gamepadblock-debian-ubuntu/ https://blog.petrockblock.com/2017/10/10/tutorial-gamepadblock-debian-ubuntu/#respond Tue, 10 Oct 2017 19:14:24 +0000 https://blog.petrockblock.com/?p=124464 This is a post as part of a tutorial series about getting to start with the GamepadBlock. In this tutorial we will learn how to use the GamepadBlock with Debian or Debian-based distributions like Ubuntu. Preparation If you have not already done it, we need to download the Raspbian image first. You get the image on …

The post Tutorial: GamepadBlock with Debian / Ubuntu appeared first on PetRockBlock.

]]>
This is a post as part of a tutorial series about getting to start with the GamepadBlock. In this tutorial we will learn how to use the GamepadBlock with Debian or Debian-based distributions like Ubuntu.

Preparation

If you have not already done it, we need to download the Raspbian image first. You get the image on the official Raspberry Pi downloads site. When you have downloaded the image you need to load it on your SD card. You can follow the Raspberry Pi Software guide for that, if you are unsure how to do that.

Setting the Controller Mode

The Controller Mode determines how the GamepadBlock polls the controllers that are attached to it. You find a detailed description for all modes on the Getting Started Page.

Attaching the GamepadBlock

Using the GamepadBlock with the Raspberry Pi is very easy: You connect the GamepadBlock to your computer with a micro USB cable just like any other USB device. You can use any free USB connector. Also, you can use multiple GamepadBlocks if you need want to have more players.

Installing USB HID Quirks for the GamepadBlock

Until the GamepadBlock patch for the Linux kernel is merged, the following description is important for you if you want to use the two-player functionality of the GamepadBlock on a Linux computer. When you connect the GamepadBlock to your Linux computer only one gamepad is listed under /dev/inputs/. For Linux-based computers we need to configure a so-called USB HID quirk for the GamepadBlock. We provide a Bash script that automates this at Github. You execute the script with the following command:

wget -O - https://raw.githubusercontent.com/petrockblog/GamepadBlockScripts/master/gamepadblockDebian.sh | sudo bash

That command will download the script and start it. The scripts checks if the file /etc/modprobe.d/usbhid.conf exists and creates it, if it does not already exist. Then it checks if the quirks have already been configured for the GamepadBlock. If these are not configured, the script adds the necessary command to the file and reloads the usbhid module.

Conclusion

As you can see, getting started with the GamepadBlock involves very few steps. We hope you enjoy your GamepadBlock and wish you good luck with your project!

The post Tutorial: GamepadBlock with Debian / Ubuntu appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2017/10/10/tutorial-gamepadblock-debian-ubuntu/feed/ 0
Tutorial: GamepadBlock with Raspbian https://blog.petrockblock.com/2017/10/10/tutorial-gamepadblock-raspbian/ https://blog.petrockblock.com/2017/10/10/tutorial-gamepadblock-raspbian/#respond Tue, 10 Oct 2017 19:13:33 +0000 https://blog.petrockblock.com/?p=124455 This is a post as part of a tutorial series about getting to start with the GamepadBlock with various images for the Raspberry Pi. In this tutorial we will learn how to use the GamepadBlock with Raspbian, the most common operating system for the Raspberry. Preparation If you have not already done it, we need …

The post Tutorial: GamepadBlock with Raspbian appeared first on PetRockBlock.

]]>
This is a post as part of a tutorial series about getting to start with the GamepadBlock with various images for the Raspberry Pi. In this tutorial we will learn how to use the GamepadBlock with Raspbian, the most common operating system for the Raspberry.

Preparation

If you have not already done it, we need to download the Raspbian image first. You get the image on the official Raspberry Pi downloads site. When you have downloaded the image you need to load it on your SD card. You can follow the Raspberry Pi Software guide for that, if you are unsure how to do that.

Setting the Controller Mode

The Controller Mode determines how the GamepadBlock polls the controllers that are attached to it. You find a detailed description for all modes on the Getting Started Page.

Attaching the GamepadBlock

Using the GamepadBlock with the Raspberry Pi is very easy: You connect the GamepadBlock to the Raspberry Pi with a micro USB cable just like any other USB device. You can use any free USB connector.

GamepadBlock attached to Raspberry Pi
GamepadBlock attached to Raspberry Pi

Installing USB HID Quirks for the GamepadBlock

Until the GamepadBlock patch for the Linux kernel is merged, the following description is important for you if you want to use the two-player functionality of the GamepadBlock on a Linux computer. When you connect the GamepadBlock to your Linux computer, for example the Raspberry Pi, only one gamepad is listed under /dev/inputs/. For Linux-based computers we need to configure a so-called USB HID quirk for the GamepadBlock. We provide a Bash script that automates this at Github. You execute the script with the following command:

wget -O - https://raw.githubusercontent.com/petrockblog/GamepadBlockScripts/master/gamepadblockRaspbian.sh | sudo bash

That command will download the script and start it. The scripts checks the file /boot/cmdline.txt if the quirks have already been configured. If these are not configured, the script adds the necessary command to the file.

Note that the Raspberry needs to be restarted, in order to take the changes into effect.

Conclusion

As you can see, getting started with the GamepadBlock involves very few steps. We hope you enjoy your GamepadBlock and wish you good luck with your project!

The post Tutorial: GamepadBlock with Raspbian appeared first on PetRockBlock.

]]>
https://blog.petrockblock.com/2017/10/10/tutorial-gamepadblock-raspbian/feed/ 0