[WIP] Simon Merrett's Arduboy Clone


(Simon Merrett) #1

Hi everyone, I’m a little nervous of posting here as I have never really been into games but I see this as a great area to try and do something that may be rewarding. I was recently looking at getting (making) an arduino-based game handheld console for a long trip (sadly failed to read from SD card). I looked around a few platforms and the gamebuino/makerbuino suited what I had in my parts drawer. I really like the library aspect of their bootloader/SD combination but I get the feeling that the classic is not an active community at the moment (especially for hackers) and the META is getting into game territory that is a bit too jazzy and serious - especially for the best part of £100. I wonder if they will manage to keep people making games with those screens.

I love the Arduboy 2/ Arduboy Zero discussion. Surprised there’s not been much talk of ESP32 alongside the clamouring for connectivity and memory! I was thinking about doing a PCB for a SAMD based arduboy. Probably a SAMD21g, rather than the 51 series. I was mulling over all the discussion about screens and this one popped into mind. It’s 128x64, daylight readable with its own backlighting and is driven by the UC1701X chip, which is at least supported by u8g2lib so can’t be too hard to make work in the Arduino IDE. I made a breakout for its 1.27mm pitch pins to demo to a friend and I think it is lovely - the pixel size almost adds to the feeling of quality! With the LED backlights it does come in around 5mm thick but I think you could suspend it in a PCB cutout and lose most of that thickness.

So my main questions on this forum are:

  1. would anyone like to contribute by making pinout suggestions for the SAMD21 (I’m aware there are giant shoulders to stand on here @MLXXXp), including perhaps FFBNW (fitted for but not with) SD card slot and EEPROM chip, headphone jack (well, if the LCD is going to blow the original thickness…), IR LED and receiver, USB C connector. Missed anything major?
  2. would anyone be interested in working on SW side to a) get it working (probably easy) and b) looking into ways of adding a library for games to be loaded from SD card or EEPROM IC, like gamebuino?

Thanks for reading, here are some pictures of the screen I have (micro SD for scale - it’s out of focus and the screen looks sharper for real; it’s a dark image, not a negative display; the backlight looks much whiter than the photo; the missing pixel is missing in the image file, so not an LCD error).


My Arduino Zero based system - The next generation Arduboy?
(Simon Merrett) #2


#3

…there’s some work happening on ESP8266 over here:

The screen you show shouldn’t be too difficult to get working - looks like the controller uses the same DDRAM page layout as a SSD1306 / SH1106, so would just be a matter of swapping out the initialisation function, and manually incrementing the page address if necessary (like when using a SH1106) if that controller doesn’t auto-increment the way that the SSD1306 does?

You might be on your own with SAMD21 though, unless @bateske releases the SAMD ‘Arduboy Developer Kit’ that has been teased… I know @Pharap was working on an implementation of the Arduboy2 library for the Pokitto (which is also Cortex-M0+ based, like SAMD21 is):

…so maybe that could be generalised into Cortex-M0+ port?


(Simon Merrett) #4

@uXe thanks - both interesting links and I’m grateful for your post joining things together for me. WRT the “Arduboy Dev Kit”, is that expected as a HW or SW thing? I’m up for doing the HW bits but I lack the kind of coding skills (e.g. of @Pharap shown in that pokitto Arduboy 2 lib overhaul thread) to port/update the library. I’ll probably get started on the PCB soon but wanted to get the input of all those people who have thought about this before. Likely to make a batch and send some to those willing to work on the SW side.

For starters:

  • The screen will be on SPI (thanks for your vote of confidence about that model)
  • Headphones on the DAC, I presume
  • Not sure whether a PWM to control the backlight or just a rotary wheel potentiometer
  • Micro SD holder and EEPROM on SPI (may need a couple of footprints to accomodate different EEPROM ICs?)
  • What USB/Serial do I (we) want? CH340, CP2102…?
  • Are buttons a contentious/sentitive issue for gamers? If so, what are acceptable ones? I happen to like the idea of the “joystick” style 5 way switches like this one and many vendors have a similar one.
  • SWD and debugging pads/through holes
  • Any preferences on battery management? I’m happy with TP4056 and DW01 combo but we don’t have to use a pre-made module (although it would save assembly time to start with).
  • Any strong preferences on battery (dimensions/capacity/duration?)?

(Pharap) #5

I got it to the point where screen rendering and eeprom saving work, but haven’t got round to implementing the LED or sound (I’m dreading trying to get sound working).

I took a break from it because there seemed to be a bit of a lack of interest and I accumulated more projects.
(It’s hard to be motivated when everyone seems more excited about the other projects going on.)

I didn’t have to worry about page addressing etc because the Pokitto has a larger screen capable of RGB565.
I implemented the screen by just drawing the Arduboy’s screen buffer onto the Pokitto’s screen buffer.

Some of my changes require access to an implementation of the C++ standard library rather than just an Arduino environment,
but otherwise I’m bound by the MIT and GPL licences, so anyone is free to copy/fork and edit the code.

The only differences between the Arduboy and the DevKit are the pinouts and the fact the DevKit’s LED was wired up incorrectly.
There’s notes about how it behaves in the Arduboy2 library’s documentation.

The only downside is that you can’t press up and down or left and right at the same time.
As far as I’m aware there aren’t any games that require that, but there’s over 200 games and I’ve only played a handful.

Most of the effort spent on getting the Arduboy2 library up and running was planning, changing the code style to something more comfortable and porting the Arduino and avr-libc code.
I don’t think you’ll have that issue with a SAMD chip.
Although I think the SAMD chips dont implement random (as I’ve learnt from working on FixedPoints), so you might have to implement that yourself.

Once I had a pseudo-Arduino environment, the Arduboy2 library was pretty easy to get working.
The only parts that you have to change are the bits that touch the hardware, everything else pretty much just works.

Oh, there is one thing I had an issue with in Sprites.
On the Arduboy int is 16 bits and on the Pokitto int is 32 bits.
There was one very hard to spot case where the author was relying on int being 16 bits.
It was hard to spot because it was the result of an arithmetic expression - the int wasn’t explicitly specified.
According to the laws of C++, the result of an arithmetic expression on basic types is an int - if I hadn’t known that I could have been head scratching for another day or two.
(You can read the full story here.)

One of the other issues I encountered I raised an issue to fix.
I mention in the thread how I fixed it.

I’d be happy to lend a hand, but my programming knowledge is much better than my hardware knowledge,
so I probably have the opposite problem to you.


(Simon Merrett) #6

That is perfect for collaboration. I won’t over commit now but I will start having a go at a schematic over the next couple of weeks. And share progress for comment here. Should I start a new thread or would an admin be able to extract the previous posts into one for me?


(Scott) #7

I believe the Dev Kit @uXe is referring to is a shield for the official Arduino Zero containing all the proposed peripherals (display, buttons, speaker, SD card slot, etc.). At one point, @bateske indicated intent to produce this for the purposes of quickly and easily getting something out there that early developers could use for producing and testing software for a next generation SAMD21 based Arduboy. This would facilitate easier software development, since the Arduino Zero has an on-board debugger chip and existing Arduino environment.

I haven’t heard anything from @bateske about this for quite some time.

I can provide information on the pins I used for my prototype. I put a fair amount of thought into mapping of the pins to the peripherals, based on their required functions and capabilities.

The SAMD21 has built in USB. Why do you want a separate converter?

With production in mind:
My intent was to be able to re-use the exiting Arduboy case with a very minimal amount of modifications, such as adding an opening for an SD card slot. Also to try to use as many of the current components as possible (battery, display, buttons, speaker, charge circuitry …) for economical production alongside the current Arduboy. Unless something like another Kickstarter campaign is used to guarantee numbers and funds up front, it’s very risky to produce a new case mold, and source and buy different components, without knowing what sales numbers would be.


(Pharap) #8

It would be better to have a separate thread (in the homemade section).
However…

I think it would be better to move the existing discussion.
We don’t need the admin, a moderator can do that.
Fortunately I happen to be a moderator, so I’ll do that for you.
(Moderators have a shield icon next to their name.)

You should be able to edit the title of the thread because you’ll technically own it, but if you can’t just let one of the moderators know and we’ll edit it for you.


(Simon Merrett) #9

That makes sense.

Yes please!

Of course, was mentally ticking off what most AVRs would have needed, not SAMDs.

I can definitely understand this and I am unlikely to pursue a new custom enclosure. I’d like to be slightly less constrained for space than the original so will probably look at a layered pcb / sheet plastic enclosure. I also have a 3D printer so can cover most things up!

Thank you.


(Simon Merrett) #10

Thanks for sorting @Pharap!


(Simon) #11

A couple of games (including mine) use combinations like up and Down to reset high-scores. Not a big issue obviously.


(Simon Merrett) #12

Good example. I wonder if you could put the PCB pads there such that either discrete buttons or the joystick option could be soldered…
@MLXXXp @bateske forgive me if this is obvious but is there a BoM for Arduboy and in particular the dome buttons used? The ones in the KS edition look nice and gold-finish but was there a special extra-thick ENIG finish on the PCB to handle the number of presses without failure or are they “sealed” units?


(Scott) #13

I should make it clear, for those who aren’t aware, that I don’t work for, or am officially associated with, the Arduboy company/organisation. I’m just a relatively active user.

I’ve never seen a BoM published. There are schematics available. I’m not sure but there may also be Eagle files for the PCB.


(Scott) #14

I’ve documented the pin mappings in my original topic:


(Simon Merrett) #15

Button debouncing. I see that this has been implemented in SW in an alternative arduboy library. Seems like a 15mS delay is used which should keep up with the frame rate of ~60Hz but does the need to use an alternative library suit most developers and users (in terms of perceived responsiveness of the default SW or the alt library)?

I’m keen to hear from those who have experience with the original / current arduboy hardware if there’s much appetite for hardware debouncing in any new clone design…


(Pharap) #16

I’ve never had a problem with the buttons.
Most of the time they’re only updated once per frame.

But then I spend more time writing code than playing games, so I might not be the best person to answer that.


(Scott) #17

Button handling functions from the ArduboyExtra library have been incorporated into the Arduboy2 library (with due credit as per the licence agreement).


(Simon Merrett) #18

Here’s a first draft schematic. Please could people comment so I can get a better revision before sending to the PCB house?

Ardugirl_01.pdf (116.8 KB)


(Scott) #19

Something many people have asked for is the ability to (accurately) monitor the battery voltage, to be able to indicate a low battery condition. A good way to do this is with a resistor divider between the raw battery output and ground, connected to an ADC capable input. (I didn’t do this on my prototype because I just wanted to get something going quickly and a spare analog input wasn’t available on the SparkFun SAMD21 board I used.)

You could use PA05, PB02 or PB03 for this. Here is a description of this technique:


(Simon Merrett) #20


Now with battery monitor, battery charging and infrared transmitter and receiver. Plus a SWD header, LCD backlight power and dimmer. Still needs flash chip.:grinning: