Close
0%
0%

Micro:Gamer

Portable game console based on the Micro:Bit

Similar projects worth following

Micro:Gamer is a portable game console based on the micro:bit board. It features a 128x64 monochrome OLED screen, six buttons (plus the two buttons of the micro:bit), a buzzer for sound and a 2xAAA battery holder. The micro:bit is inserted in the back of the board, like a game cartridge on the GameBoy. The specs being similar to the Arduboy, it is quite easy to port existing games to the Micro:Gamer.

Let me know in the comments section if you are interested by this project, what would you add/remove and if you would like to get one.

  • I'm giving away 4 Micro:Gamer boards!

    Fabien-Chouteau05/16/2018 at 21:43 5 comments

    I just received the first batch of Micro:Gamer rev-B from SeeedStudio. It is the first time I have a design made in series, a very small series but a series nonetheless :)

    There's a few changes in the design, the first one being the SMD version of the micro:bit connector which allows for a better looking board. I also added a power slide switch and slightly moved some components.

    As stated in the title of this post I'm giving away 4 of the boards. I have no use for 5 so if you have a cool idea for a game or feature that you want to try, I will be happy to send one to you (depending on the how much it costs, I might ask you to pay for shipping). Contact me using the private messages if you are interested.

  • TODO list update

    Fabien-Chouteau04/22/2018 at 19:41 0 comments

    I think it is time to do an update on the DODO list:

    • [DONE] Try audio support with the buzzer
    • [DONE: board in production] Some improvements to the PCB (on/off switch, button position)
    • [DONE] Add an API for persistent storage (highscores, player data)
    • Add an API to read the accelerometer and magnetometer of the micro:bit
    • [DONE] Improve performance of screen data transfer
    • Design a case for 3D printing

    New item:

    • Create an example game/project that demonstrate all the features

  • synchronous frame buffer transfer and double buffering

    Fabien-Chouteau04/18/2018 at 20:59 0 comments

    On the Micro:Gamer, the OLED screen is controlled via an I2C bus.

    The screen resolution is 128x64, that is 8192 pixels. Since the screen is monochrome, there is only one bit per pixel so the frame buffer size 1024 bytes. We have to transfer all those 1024 bytes over I2C to refresh the screen. Lets calculate how much time it takes.

    I2C transfer time

    First we have to count the number of bits in an I2C transfer.

     - 1 start bit
     - 8 address bits
     - 1 address ack bit
     - 1 stop bit
     - 8 bits + 1 ack bit for each byte of data we transfer

    So the total number of bits for a transfer of N data bytes is:

    bits (N) = 1 + 8 + 1 + N * (8 + 1) + 1 

    or

    bits (N) = 11 + (9 * N)

    Then we can calculate the speed of the transfer by dividing the number of bits by the speed of the bus in bits per second.

    The micro:bit is fitted with an nRF51 microcontroller. On the nRF51 the maximum speed of the I2C controller is 400k bits per second, so the transfer time is:

    transfer_time (N) = bits (N) / 400000
    

    For examples, transferring 10 bytes will take

    transfer_time (10) = (11 + (9 * 10)) / 400000 = 0.00025 seconds
    

    or

    0.25 milliseconds 

    There are more things to take into account for an accurate estimate of the transfer time, but this is a good approximation.

    Arduino library I2C transfer

    Now that we have the formula, let's see how much time it takes to transfer the 1024 bytes of our frame buffer.

    The Arduino library limits the number of bytes per I2C transfers so the frame buffer has to be sent in multiple transfers. The driver I used, from Adafruit, sends 16 bytes of frame buffer per transfer with an extra byte to specify that we are sending data for the frame buffer, which means 64 transfers of 17 bytes.

    So the total time it takes to send the full frame buffer is:

    64 * transfer_time (16 + 1) = 26.2 milliseconds 

    The Arduino library driver is implemented using the polling technique. The CPU just continuously waits in a loop until it can send the next byte. So during the transfer time, the CPU is doing almost nothing.

    If we want to run a game at 30 frames per seconds - one frame every 33 milliseconds - a transfer time of 26.2 milliseconds means that 80% of the CPU time will be wasted in I2C transfer. This is not ideal...

    Asynchronous frame buffer transfer

    The solution to this it to let the CPU do something else during the frame buffer transfer, and it can be done with interrupts. So I implemented an interrupt based I2C driver.

    The CPU sends the first byte on the I2C bus and then continues its work, typically it will start to compute the new state of the game and render the next frame.

    When the I2C controller is ready to send the next byte, an interrupt is triggered and the CPU will temporarily stop its normal operation to send the byte.

    As a result, there's more CPU time available to execute the game code, allowing more complex games to run on the Micro:Gamer.

    Double buffering

    One potential problem with asynchronous frame buffer transfer is that, as the CPU continues to execute the game code, it can override the frame buffer in the middle of the transfer. This can cause glitches on the display, similar to the rolling shutter effect of digital cameras.

    Again there is a solution for that, double buffering! Using two frame buffer instead of one, the CPU can edit frame buffer A while sending frame buffer B, and then it is the opposite, CPU edits frame buffer B while sending frame buffer A. Of course this means that we have to allocate one more frame buffer so it has a significant impact on memory usage.

  • Playing sounds

    Fabien-Chouteau03/15/2018 at 16:59 1 comment

    After the persistent data storage, the next important feature for me was sound.

    There is a small buzzer on the Micro:Gamer board which means it can play a single note at a time. It is enough to play little tunes and some sounds effect as shown here:


    This time again, I re-use the Arduboy libraries to provide compatibility with the existing games.

  • "Memory Card" (Non-volatile memory)

    Fabien-Chouteau03/14/2018 at 01:28 0 comments

    Most of the games I ported from Arduboy to the Micro:Gamer use EEPROM to save high score or game state when the console is powered off. I think this is must have feature for a game console so I implemented it for the Micro:Gamer.

    There is no EEPROM on the micro:bit board and I don't want to add it as an extra component on my hardware design, so I had to use the flash memory inside the micro-controller.

    The interface to use the flash as persistent storage is provided by the MicroGamerMemoryCard class. This class uses two different memory areas:

    • The first one is a 1k bytes page in the flash memory, this is where the data will be stored permanently. The reason for a fixed size of 1k bytes is because flash memory have to be erased/written by pages of 1k.
    • The second memory area is the temporary RAM buffer. This is where the program will read/write the data before saving it permanently in the flash page. Since there is not a lot of RAM available, the program can decide to have a temporary RAM buffer that is smaller than 1k.

    Here is an example of how it looks like in the code:

    // Create a memory card of one 32bit word
    MicroGamerMemoryCard mem(1);
    
    // Load the content of the flash page to the temporary RAM buffer
    mem.load();
    
    // Read a value from the temporary RAM buffer
    if (mem.read(0) != 42) {
    
      // Write a value to the temporary RAM buffer
      mem.write(0, 42);
    
      // Permanently save the RAM buffer into flash memory
      mem.save();
    }
    
    

    And here is a demo with the game Micro City:

  • The idea and the first prototype

    Fabien-Chouteau02/25/2018 at 18:37 1 comment

    Like most of you I suppose, I love the micro:bit. It is very affordable, available everywhere, quite powerful and it even has an integrated programming/debugging probe. However, one “disappointing” aspect in my opinion is the 5x5 LED matrix. It can barely display text and cannot be used for anything beyond very very simple “games”. A couple months ago I saw the Adafruit OLED Bonnet for Raspberry Pi and I thought it would be cool to have something similar for the micro:bit, so I decided to give it a try.

    One of the design choices for the Micro:Gamer is to embrace the micro:bit edge connector. There are a good number of disadvantages with this connector, it’s big, there is no SMD version (at least I couldn’t find one). But for this project in particular I think it is great because it mimics the cartridge of a retro console like the GameBoy. If you have more than one micro:bit you can program different games and swap between them.

    For the batteries, my first idea was to not include any on the board (keep it simple), but then it’s not really a portable device anymore… The next choice was between a coin cell battery and 2xAAA. I decided to use the AAAs because - even if they are bigger - it is easy to find rechargeable ones.

    For the software I use the Arduino IDE and a modified Arduboy2 library. Since the Arduboy and Micro:Gamer have the same screen and buttons, it is very easy to port games from the Arduboy to the Micro:Gamer (I already did 6). I will maybe experiment with Python support and probably Ada as well.

    The next steps for me are:

    • Try audio support with the buzzer
    • Some improvements to the PCB (on/off switch, button position)
    • Add an API for persistent storage (highscores, player data)
    • Add an API to read the accelerometer and magnetometer of the micro:bit
    • Improve performance of screen data transfer
    • Design a case for 3D printing

    That’s it for the first project log. Let me know in the comments what you think about this project.

View all 6 project logs

Enjoy this project?

Share

Discussions

lavazza.damien wrote 9 hours ago point

Super project! I am an Arduboy fan and also love the micro bit. Would be great to see an old multiplayer classic like maze war / maze wars+ running on this which could use the micro bits radio feature to send messages to other micro bits. 

  Are you sure? yes | no

Dan O'Shea wrote 05/11/2018 at 12:24 point

Love this project! I am a regular on the Arduboy community, and you have inspired me to order a micro:bit!

Would you be able to share the pinout for how you have everything hooked up to the micro:bit's edge connector? I could dig through your fork of the library to figure it out, but thought it would be easier to just ask... 😃

  Are you sure? yes | no

Fabien-Chouteau wrote 05/12/2018 at 13:35 point

Well the sources actually hold the most reliable information right now :)

Here are the locations of the different pins:

 - I2C : https://github.com/MicroGamerConsole/MicroGamer-Arduino/blob/master/src/Arduboy2Core.cpp#L86

- Screen Reset: https://github.com/MicroGamerConsole/MicroGamer-Arduino/blob/master/src/Arduboy2Core.h#L42

- Buttons : https://github.com/MicroGamerConsole/MicroGamer-Arduino/blob/master/src/Arduboy2Core.h#L52

 - Buzzer: https://github.com/MicroGamerConsole/MicroGamer-Arduino/blob/master/src/ArduboyTones.cpp#L59

(The pins might change with next revisions)

If you have an Idea for the Micro:Gamer let me know here or in private message. I will receive 5 new boards soon and I plan to give away 2 or 3 for some motivated contributors.

  Are you sure? yes | no

Harry Cartwright wrote 03/25/2018 at 22:50 point

Are you planning on selling this? If so, do you have an estimate of how much it would cost?

  Are you sure? yes | no

Fabien-Chouteau wrote 03/26/2018 at 22:42 point

I would love to make a product from this project. I'm working on it, I will let you know when I make progress.

  Are you sure? yes | no

mark gunderson wrote 03/23/2018 at 16:19 point

Do you think you could get the wireless working? It seems to me the most interesting games would involve large numbers of Micro:Bits and wireless interaction. Maybe not real time gameplay, but some sort of social aspect.

  Are you sure? yes | no

Fabien-Chouteau wrote 03/24/2018 at 00:11 point

It's definitely possible to use the wireless feature of the micro:bit but I didn't try that yet. Right now I'm focusing on core features and hardware design.

As for the kind of games that could be done, I want to try real-time 1v1 games at least, for the rest I count on your  imagination ;)

  Are you sure? yes | no

greenaum wrote 03/01/2018 at 06:55 point

At first this seemed a bit pointless, since Arduboy already exists. But then I noticed you're using the Micro Bit. That changes it! There's probably a lot of kids who'd be much more interested in the MB if it had features like these.

The fact there's games already available helps too. Particularly cos kids can play them, have fun, then, the crucial step, start modifying them and seeing what happens. That's always a good start.

Is it open source? I know the parts are fairly cheap. It'd be great if this takes off for schools. It probably won't, but that's more their failing than yours. Still parents might be interested. Or kids, and for the price it won't be hard to badger a parent into buying it.

Just one suggestion... might it be possible to leave the 5 big hole connectors available? I realise the connector blocks them. But if that can't be changed, maybe have breakout points on the board? You could even just do them as PCB pads, and let the owner drill through if they want to. Should do the trick I think. Don't think it'll need through-hole plating, especially if you connect both sides together.

Then a kid could have lights flash, or whatever else, when they score points. Or make their little robots more interactive.

  Are you sure? yes | no

Fabien-Chouteau wrote 03/01/2018 at 18:05 point

"Just one suggestion... might it be possible to leave the 5 big hole connectors available? I"

I'm using almost all the pins of the edge connector so the 5 big hole connector will not be available for the users.

  Are you sure? yes | no

nardev wrote 02/28/2018 at 14:39 point

Do you plan to share the schematics?

  Are you sure? yes | no

Fabien-Chouteau wrote 03/01/2018 at 18:07 point

I will probably post them but at least I need to clean it before :)

  Are you sure? yes | no

nardev wrote 03/01/2018 at 20:14 point

I have small group of kids in orphanage, teaching them programming since last year.. soon i'l introduce some basic electronics for their age.. and good thing we do all on micro:bit's so it would be cool if you share it, i would most likely add their names on PCB and teach them how to solder it,  some ideas how some product is born.. i see that it's quite simplified, so i would not bother them  with much caps, resistors and others parts.. would be interesting i think...
that is why i'm asking :D

  Are you sure? yes | no

Fabien-Chouteau wrote 03/05/2018 at 20:44 point

@nardev This project is not suitable for teaching soldering, especially for kids. It uses small SMD parts and the screen's flat flex is also quite difficult to solder.

  Are you sure? yes | no

nardev wrote 03/05/2018 at 22:08 point

don't worry, it will fit... it doesn't have many parts...good enough. It would definitely not be the only thing they do.

  Are you sure? yes | no

Stef64kb wrote 02/28/2018 at 11:00 point

Nice one. You might like my project too: #Bit:Boy I attempted the same a couple of months ago. Apart from Arduboy, I have Gamebuino emulation in place and I was experimenting with Bluetooth to play games on your phone and stuff.

  Are you sure? yes | no

Fabien-Chouteau wrote 03/01/2018 at 18:12 point

Awesome, I love how you use the micro:bit as a remote controller!

  Are you sure? yes | no

oshpark wrote 02/28/2018 at 00:29 point

Great project!

  Are you sure? yes | no

Fabien-Chouteau wrote 03/01/2018 at 18:08 point

Thanks!

  Are you sure? yes | no

ðeshipu wrote 02/25/2018 at 19:06 point

Very nice! Making the library fit an existing one and thus leveraging an existing community and their games makes a lot of sense when you just want to play games on it.

  Are you sure? yes | no

Fabien-Chouteau wrote 03/01/2018 at 18:11 point

The micro:bit is more capable than the Arduboy so this is just a quick solution to get started. There's a lot more to do with the on board accelerometer, magnetometer, the increased RAM size and CPU power.

  Are you sure? yes | no

ðeshipu wrote 02/08/2018 at 16:30 point

Hi, great to see you starting work on this! You might be interested in my recent attempt at the same: #Micro:Boy 

  Are you sure? yes | no

Fabien-Chouteau wrote 02/09/2018 at 10:11 point

Thanks! Actually my first prototype was called Micro:Boy until I saw your project this week :)

I will post project details when I get the next board and you will see that we took different approaches.

  Are you sure? yes | no

ðeshipu wrote 02/09/2018 at 10:16 point

Can't wait to see it!

  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