close-circle
Close
0%
0%

PewPew FeatherWing

A shield for Adafruit Feather boards with buttons and a LED matrix display, for simple games.

Similar projects worth following

Game programming is hard. Sure, you can easily throw together something in RPGMaker, RenPy or Unity3D, and it's great -- but you don't actually know how it works inside. There is a certain skill required to go from scratch, write your own main loop, handle events, push the pixels, etc. Incidentally, the same exact skills are required when programming any other interactive system, such as a graphical user interface, an automatic appliance, a mobile art installation or... a robot! Those are going to be much more common in our lives soon. If we want to stay in control, we need to be able to program them ourselves, and for that we need those skills. They empower us and give us back the control over the technology.

One great tool for teaching it is PyGame -- which is a library, and not a game engine, so it forces you to attend to all those pesky details of game engine internals yourself. Which is a bit difficult, of course, but ultimately very useful. But even if you play with PyGame on the Raspberry Pi, it's still a very complicated and difficult to understand system. The learning curve is steep, and debugging is hell.

Enter MicroPython, and one of its flavors, CircuitPython. It's written by the people at Adafruit with the education in mind, but it runs on infinitely simpler devices than your average computer. Devices which you can't break easily, because reflashing the program will reset them to a known good state. Devices which run on batteries for hours, and which you can carry in your pocket. Devices, for which there is a plethora of add-ons and sensors that you could make use of in your game.

However, as of yet, there is no game library and/or add-on that would allow to easily create games in CircuitPython. This project is an attempt to fix this.

View all 6 components

  • Prototypes

    Radomir Dopieralskia day ago 0 comments

    A gathered all my attempts at a microcontroller-based simple game console, and took a photo:

    On the far right you can see #Frowney, then there is a bunch of different versions of the #PewPew FeatherWing, in the far left corner there is #D1 Mini X-Pad Shield, and below it there are two other shields for D1 Mini with buttons. The D1 Mini shields are too small to hold comfortably, and the small joystick is pretty hard to use, at least without anything on top of it. The feather boards are just the right size, provided the whole assembly is not too thick, like the one in the center with a battery shield. 

  • BOM Updated for PewPew Lite

    Radomir Dopieralski3 days ago 0 comments

    Since I'm starting with PewPew Lite, I updated the bill of materials to reflect that. the non-lite version will be done if the Lite version catches on — otherwise I will switch to D1 Mini as the development board.

    I also added a link to the project's repository, and added a license (it's CC by-nc-sa for now). The work on the tutorials is coming slowly.

  • Business Plan

    Radomir Dopieralski4 days ago 0 comments

    The first step is to get the PewPew Lite featherwing to work properly, write the example games for it, and write the tutorial explaining how each one of them works. This part only requires time on my part, no special funding or resources are necessary. This should be done until the end of the year.

    Once that is done, the next step is to start producing the boards and selling them on Tindie, at the same time reaching out to potential distributors. This is also the time to start running workshops, improving the documentation based on the feedback from the early users, and finding ways to outsource the assembly of the boards.

    If that is successful, use the funds and experience gained from that to finish the PewPew (not Lite) board and to keep growing the community (at this point probably hired help will be necessary). Cooperate with teachers and writers to prepare lesson plans and other materials, record video tutorials, etc. With larger number of PewPew board, it should be possible to keep their price similar to the PewPew Lite.

    If PewPew Lite featherwing is not successful, stop its production, and work on a PewPew D1 Mini version, which would work with much cheaper Chinese boards. Again, start selling those on Tindie, but this time the goal is to get other manufacturers to clone them, and not the distributors to sell them. Instead of preparing lessons, work on making the documentation appeal to the maker community, encourage modding and emphasize the use of those boards outside of education and games, as controllers for robots and IoT devices.

    If any of those two plans works, start working on a third version of the PewPew board, this time with a TFT screen and an STM32 processor for handling it, with a tile and sprite engine and built-in example assets. Keep it compatible with the previous platforms, making all the old games work on it, but provide additional functions. Write an emulator on a PC that will allow easier debugging, and will let people try the games even without the device. Maintain a repository of games, including both the example games and 3rd party contributions (require open licenses on those). The games for older platform can use graphics based on popular themes (maybe get licenses from movies etc.).

  • Scrolling and Text

    Radomir Dopieralski4 days ago 1 comment

    While most games will be simple enough to just use the individual pixels on the matrix, we still need a way to display text to the player — to show errors, to list the available games, to show the "game over" text, etc. So today I worked on that.

    I designed my own 4×6 4-color font specially for this. The effect of using the 4 available colors for shading when they actually have very different hues is a bit strange, but you get used to it and I think it's actually quite readable:

    I might add an option of displaying the text in just a single color — the font is designed so that it's still readable if you "round" the half tones.

    The scrolling is actually quite slow on the SAMD feathers (the maximum speed is about twice as on the gif above), but I think it's quite sufficient for text.

  • The Challenge

    Radomir Dopieralski6 days ago 0 comments

    I'm in a ranty mood today, so I will write a little bit about why I decided to make this and how I hope it will work.

    You have probably heard about the Raspberry Pi and the Micro:bit. Those projects are both parts of a larger effort to liberate people and give them back the control of their own devices. The modern computers, tablets, smartphones, game consoles and even toys are black boxes today. They are supposed to make you enjoy consuming carefully designed user experiences, without much thinking. Oh sure, they cater to your creative side too, letting you write comments with lots of emoji, upload user-generated content that you no longer own, or write a product review. In the mean time, as the population ages, we are running out of technically skilled people that are able to maintain and build those devices.

    You might think that the obvious solution is to simply educate more people to do the technical jobs. But that doesn't work. The school doesn't teach you the important skills of an engineer. Schools are designed to kill the passions, not to make them grow. The best engineers out there are the ones who spent their lives tinkering with things, who were curious and fascinated with them, who needed to know how they work, needed to see for themselves, and then needed to modify the devices and make them their own. But you can't understand how a computer works today — it's much too complex a beast. And tinkering with game consoles can get you in the jail in no time. There are simply no stepping stones between a bright kid and an officially recognized engineer.

    Raspberry Pi helps, because it gives a cheap computer that you can actually play with, that you can break and fix and break again, and nobody will lose their jobs because of that, like they might if you broke the family's computer. A computer that you can connect things to, and make it behave like a retro game console.

    However, once you do all the soldering and connect the screen and joystick and put it in a cute box and so on, you simply load an emulator for one of the many old game systems, download the ROMs for the retro games, and continue consuming content as if nothing changed. Sure, you learned something about connecting wires and configuring Linux kernel hardware overlays, but you still have no idea how those games actually work, and you still wouldn't be able to make your own.

    The Micro:bit is much better in that regard, as it is infinitely simpler and easier to understand, and you program it at a much lower level. You can program it at school and then take home and play with it even if you don't have a computer at home. You can show it to your friends and parents. You can make it do amazing things.

    But you can only make very simple games on it.

    There are only two buttons, and while you can use the accelerometer and compass as inputs, this is very limiting. Even worse, the 5x5 display is not very good for most games either. Sure, you can connect additional buttons and LED matrices or screens, but that requires much more experience, and you probably have to leave it all at school, as it's too unwieldy to carry around in your pocket.

    So we need something simpler. Something that is as simple and easy to program as the Micro:bit, but more colorful, more convenient, closer to the "real" games out there. Something that doesn't require amazing graphical skills and hundreds of hours of work of artists, but still looks good. Something that you can program and take with you in your pocket. Something that plugs into an existing ecosystem of modules, extensions and tutorials, so that you are not left alone on your own. Something that is sturdy and rugged, so that it will survive being carried around in the pocket while you climb trees and fight pirates.

    Physically, the device doesn't need to be complex. It should be small, it should have the familiar d-pad and fire keys, and a display capable of displaying colors. It should be low-resolution, so that you don't need to be a pixel-art...

    Read more »

  • First CircuitPython Program

    Radomir Dopieralski07/19/2017 at 21:58 0 comments

    Today I found one more bi-color matrix that I have left (more of them are ordered for the next version), and used it to assemble a second PewPew Lite. I'm really happy with how it works, and I'm considering switching entirely to the Lite version — four colors are enough for most games, and really simplify things.

    However, this time I decided to make it as flat as possible, so I used the 3mm female pin headers on the Feather board, and shortened the male headers. The effect:

    Unfortunately it can't get any flatter, because of the battery plug and the chip on the underside of the shield. But one centimeter is still quite good. I wonder if I can find a LiPo battery that would fit in the space between the boards -- but more likely I will just stick the battery on the bottom.

    I also wrote the driver for the CircuitPython (used MicroPython before that), and a simple drawing program:

    import pewpew
    import time
    pewpew.brightness(0)
    pewpew.show()
    x = 3
    y = 3
    color = 1
    hold = 0
    blink = False
    hold_keys = (pewpew.K_UP | pewpew.K_DOWN | pewpew.K_LEFT | pewpew.K_RIGHT |
                 pewpew.K_X)
    while True:
        keys = pewpew.keys()
        if not keys & hold_keys:
            hold = 0
        if keys & pewpew.K_UP:
            y = max(0, y - 1)
        elif keys & pewpew.K_DOWN:
            y = min(7, y + 1)
        if keys & pewpew.K_LEFT:
            x = max(0, x - 1)
        elif keys & pewpew.K_RIGHT:
            x = min(7, x + 1)
        back = pewpew.pixel(x, y)
        if keys & pewpew.K_O:
            back = color
        if keys & pewpew.K_X:
            color = (color + 1) % 4
        if blink:
            pewpew.pixel(x, y, color)
        elif back == color:
            pewpew.pixel(x, y, (color + 1) % 4)
        else:
            pewpew.pixel(x, y, back)
        blink = not blink
        pewpew.show()
        pewpew.pixel(x, y, back)
        while pewpew.keys() & hold_keys and hold < 15:
            time.sleep(0.025)
            hold += 1
        time.sleep(0.125)

    As you can see, most of the code is dedicated to handling keys, including the repeating when a key is held down. The library is very bare bones for now, but I like the simplicity. I will probably need to add a function to display text, and some functions for scrolling around.

  • PewPew Lite Assembled

    Radomir Dopieralski07/17/2017 at 16:40 0 comments

    The PCBs for the PewPew Lite arrived from @oshpark, so I assembled one and I'm really happy with it:

    I didn't have an SMD diode at hand, so I just put a THT one there, and connected it to the correct pin (there was a mistake in the PCB, if you remember the previous log). I also quickly extended my HT16K33 drivers with a class for this board:

    class PewPewLite(Matrix8x8x2):
        def _copy_buf(self):
            pixel = self.framebuffer.pixel
            _buffer = self._buffer
            for y in range(8):
                b = 0
                for x in range(8):
                    color = pixel(y, x)
                    if color & 0x01:
                        b |= 0x01 << x
                    if color & 0x02:
                        b |= 0x01 << (15 - x)
                _buffer[14 - y * 2] = b & 0xff
                _buffer[15 - y * 2] = (b >> 8) & 0xff
    
        def keys(self):
            return int.from_bytes(self.i2c.readfrom_mem(self.address, 0x40, 2),
                                  'little') >> 5

    Nothing too fancy, just had to adjust the rotation and add a method for reading the keys.

    I also received the PCB for #Ye Olde Nowt with the THT buttons, and now I'm thinking about how to use those buttons also with this project, as they are much more compact. Probably won't work, since I really need stuff on both sides of the PCB. There is one more type of buttons that I might try -- they are SMD, but use pads under the buttons, and not legs, like the ones here.

    And of course I *really* need to start writing the games for this. I already have ideas of a dozen of them.

  • PewPew Lite Schematic

    Radomir Dopieralski07/05/2017 at 21:53 0 comments

    I decided to make a proper schematic for that PewPew Lite board I ordered recently. You know, so that it's more complete and also so it's easier to figure out what is what when I will be programming it. Most PCB programs force you to start with the schematic, and only do the PCB design later, but I'm using Fritzing specifically because it lets me do it in any order – and I get much better PCB layout this way, because many times it doesn't really matter which pin I use for a particular function, so I can as well just pick the one that is easiest to route.

    Once I did that, I brought up the datasheet for the HT16K33 chip to see whether I will need a common cathode or a common anode LED matrix, and I noticed a grave error: the buttons are connected to the address select pin (COM0) and not to the buttons pins (COM1-COM3). Oops. (The schematic above has that already fixed.)

    Of course I quickly corrected that. Fortunately, the two pins are close together and close the the diode, so it should be relatively easy to cut the trace and connect it to the other pin with a piece of wire. Still very embarrassing. I guess next time I should make the schematic before ordering the PCB.

  • PewPew Lite

    Radomir Dopieralski07/02/2017 at 22:42 0 comments

    I decided to try and make a more minimalist version of this board, replacing the IS31FL3733 LED matrix driver chip and the microcontroller with a HT16K33 chip, which can do both LED matrix control and key scanning at the same time. It will have no sound. Why didn't I use HT16K33 in the first place? Well, the main reason is because it can only switch the LEDs on or off, and doesn't have brightness control for individual pixels. That means that there will be only 4 colors available for each pixel: black, green, red and yellow. On the other hand, this chip is cheaper, easier to source and much easier to solder by hand.

    The plan is to write the libraries in such a way, that most games will work on both kinds of the boards -- as long as they don't require too many subtle shades of colors. It should still be possible to make Flappy Bird, Pong, Snake, Arkanoid, Space Invaders, Rogue, Boulder Dash or similar clones, and even have some board games like Checkers or Go. Chess would require much more colors, and it would be probably hard to remember which shade is which piece.

    As usual, I will see how it all works when the boards arrive.

  • Version 1.5

    Radomir Dopieralski06/18/2017 at 19:20 0 comments

    The boards for version 1.5 arrived yesterday, and today I had some time to assemble one. It didn't work initially, but after touching each solder joint with the soldering iron again, it started to work. Go figure.

    Programming of the ATmega8 went smoothly, and it does appear as an I²C device together with the display controller, so everything seems fine. I will test the key scanning and the display library later. The sound code requires some more work before it's usable -- hopefully I will be able to beat it into shape soon.

    I already have a version 1.6 PCB designed -- the only difference is that it has pads for an SMD speaker, and that the speaker is driven from two GPIO pins, not one and ground -- giving me one more bit of resolution and louder volume. I'm not ordering that yet, though, because I'm sure I will have some ideas for improvements while working with the version 1.5.

View all 18 project logs

Enjoy this project?

Share

Discussions

oshpark wrote 05/10/2017 at 23:43 point

great project!

  Are you sure? yes | no

Radomir Dopieralski wrote 05/10/2017 at 23:46 point

Thank you, hopefully the new PCBs arrive before PyCon.US, so I can show them off there. They just got shipped, and if they arrive within 7 days, I'm good. Otherwise we will miss each other going opposite directions.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates