-
PyWeek Failure
10/22/2017 at 17:11 • 0 commentsThe week has ended and the contest is now closed. I didn't manage to finish my game, even though I was very careful to set the scope small. There were simply too many distractions during the week.
I still plan to finish that game one day, it's a top-down shooter similar to the Alien Breed series or the classic "Into the Eagle's Nest". I feel it can be really fun to play on PewPew.
-
PyWeek, Here I Come
10/15/2017 at 10:15 • 0 commentsThere is this challenge, where you have to write a game in Python in one week. I never really had the time for it (I preferred Ludum Dare, where you only have one weekend, so it's easier), but I decided to try and enter this time. Of course CircuitPython is Python too, so I'm going to develop a new game for PewPew. But since others wouldn't be able to play it without making their own PewPew, I will also write an emulator for it.
Here's my entry: https://pyweek.org/e/pewpew/
The topic is "They're behind everything". Wish me luck.
-
PewPew 4.1
10/15/2017 at 00:33 • 7 commentsI assembled one of the boards for the PewPew 4.1 and got it to work. It's really close to what I want ultimately, at least feature-wise.
It has the IS31FL3733 chip for handling the LED matrix, an ATSAMD21E18A-AU microcontroller for running CircuitPython, and extra S25FL216K0PMFI011 flash memory for more disk space, a battery charging circuit, and a piezo speaker. I should have an amplifier for the speaker in there too, but I didn't get it to work yet — I have parts for it on order. Oh, and I'm using a rectifier diode in place of a shottky diode, because I'm waiting for those too.
I have made a custom board definition for CircuitPython, and built custom firmware for it — so that I can make use of all the pins I need and the extra flash memory. Once I finalize the hardware, I will submit the board definition to the CircuitPython upstream.
I'm still not happy with three things: the position of the speaker, the connectors for the battery and the fact that the board is pretty difficult to assemble manually. I would definitely not want to have to assemble 10 of them. So now it's time for optimization of the layout, possibly moving a few parts around. I also considered replacing the piezo speaker with a headphone jack — we will see about that.
-
Boards from Aisler
10/14/2017 at 10:29 • 8 commentsRecently I found a board maker similar to OSHPark, but based in Germany, Europe. Could it be that my wish came true? As soon as I had a new version of PewPew's PCBs designed, I decided to try them.
The prices seem similar to what OSHPark offers: at OSHPark I paid $8.95 for three 2.00x0.90 inch PCBs, here it's €8.43. However, OSHPark has free shipping (which constitutes the bulk of the waiting time for me), while Aisler charged me additional €4.96 for shipping. But that's totally fine by my if the boards land in my mailbox faster this way.
There is a bit of disappointment here, though. I made my order on 28th of September, and for nearly two weeks nothing happened. I finally went to check the order's status two days ago, and it said on the website that they will be fabricating it within 1 hour. I assumed that it's just a fancy message, but indeed one hour later the message changed to information that they are shipping it within minutes, and later that day that it shipped. The boards arrived two days later.
So in theory, it could be much faster than OSHPark, which usually makes my boards within a few days, and then they take two weeks to get here. However, in practice waiting for fabrication made it about the same. Perhaps it will get better as they get more orders and the panels will fill up faster?
Now about the boards themselves. Here's a photo:
First of all, as you can see, the boards are green. As with OSHPark there are no color options, which is fine, but green is a bit boring. Their website is all orange, it would be super-awesome to get some orange boards! Oh well, green is fine.
There is ENIG finish, just like with the OSHPark boards.
Both the solder mask and the silkscreen are much lower resolution than what you get with OSHPark. If you look at the chip footprint on the left, you will see that every pin pad is different width — that's the effect of low-res solder mask. You can also see that the head of the sheep logo bled into the outline — that's the effect of low-res silkscreen. For comparison, boards from OSHPark and SeeedStudio:
Finally, the board outline. I'm really shocked about that: it looks like it was cut out with a hatchet by a drunk worker. I guess I shouldn't have ordered during the Octoberfest.
I still need to assemble the board and see if it works, but all the traces look fine visually. We will see how that goes.
-
Contest Video
10/13/2017 at 00:53 • 0 commentsI have the video, which is required for the prize finals, finally done, at least the first version of it. I don't really have any video editing tools, so this all has been done by gluing together bits and pieces with ffmpeg.
-
GamePad module and Trinket M0 Haxpress
10/03/2017 at 21:16 • 0 commentsMy pull requests just got merged into CircuitPython. One is the for the Trinket M0 with a hacked on flash chip — it's now called Trinket M0 Haxpress, and the other one is adding a gamepad module with functions for scanning and de-bouncing button presses.
I'm now waiting for the version 4.1 prototype PCB and parts, and once that works, I can make the custom firmware for it and start working on the sound support in the library.
-
Struggling with BOM
10/03/2017 at 16:04 • 0 commentsThe PewPew Lite was simple enough to solder by hand. The self-contained PewPew is not going to be so easy. Of course, I can solder a prototype or two — I even explicitly shied away from QFN parts — but just thinking about making a 20 pieces for a workshop makes me shudder. So I need a PCB assembly service.
I have been looking at the different services, and what they need as the input, and not very surprisingly, the main input they need is the bill of materials, also known ass the parts list. Unfortunately, it's not enough to just say "a 10kΩ resistor" — you have to specify the size, tolerance, and most importantly, the product number. Actually, forget everything else, they just want the product number, and if the part is exotic, a link for where to buy it.
So I've spent the last couple of evenings trying to use the #FindChipsPro service, and it has been a bumpy ride. I started with the pick-and-place file that Fritzing generated for me — it's a CSV file that lists all the parts, together with their exact positions on the board. So I just removed the irrelevant position information, and got a list of parts in a format that could be imported into FindChips. Then FindChips started sugeesting parts. Oh boy.
It couldn't find any tact switches at all. Apparently the best alternative to a USB micro socket is a HDMI socket. There is only one power switch with the pinout I need, and it's a super-expensive ALPS. 0402 20kΩ resistors simply don't exist. Forget about any LED matrices at all, not to mention bi-color ones. And so on and so forth.
With much struggling and some cheating, I finally put together a BOM list that only has 3 parts missing. I have simply added the URLs for those in the comments. The list is at https://www.findchips.com/org/10-open-hardware/list/48895-pewpew-41-bomcsv
The good news is that the total cost of all parts seems to be around $15 at quantity 1. That means that together with the PCBs and the assembly service, there is a chance that the whole thing won't be more expensive than a Feather board.
-
Replicating the Trinket M0 Express Hack
10/02/2017 at 21:47 • 4 commentsIt would be great to have more memory on PewPew, so I decided to try and replicate the Trinket M0 Express hack, only with my bare chip. To do that, I need a flash chip. The original hack used a S25FL116K0XMFI043 chip, but of course I don't have that. But they should all be pretty much the same, no? So I tried with a W25Q32FVSSIG instead:
The connections are pretty much what you would expect:
And the board definition is in this branch: https://github.com/pewpew-game/circuitpython/tree/trinket-m0-express
After compiling and flashing the firmware, it... doesn't work. I mean, the CircuitPython itself works and shows me the REPL console, but there is no USB disk. And it's easy to see why — there is a number of files in the boards directory that contain flash chip definitions, and that you include in your board definition files. And guess what, the chip I'm using is not there. So I have two options now: dive into the datasheets and prepare my own flash definition file, which would be the "correct" choice, or order a flash chip that is compatible with what is there already, then wait a few weeks for it to arrive and try again, which is the "lazy" choice. Guess which one I've chosen.
Since I'm waiting for the PCBs and parts for the next version of PewPew anyways...
Update: So I overcame by inherent laziness and created a flash file for the W25Q32BV family. And what do you know, it works!
-
Custom CircuitPython
09/28/2017 at 22:37 • 0 commentsHaving played a little bit with the prototype of the standalone version, I realized that I really need better button handling. The PewPew Lite did handling on the LED driver chip — the chip would scan the whole matrix every 25ms, and if a button came up as pressed in at least two consecutive scans, would set the corresponding bit in its registers. Reading the registers resets them, so you get a simple "what buttons has been pressed since the last time I checked" behavior, which works quite well for most games.
But the IS31FL3733 chip I'm using the PewPew can't do that, so I had to connect the buttons to the GPIO pins of the microcontroller, and poll them myself from CircuitPython. But since the games have pretty slow frame rate (about 6FPS), and they only poll once per frame, it's very easy to skip a fast key press. So I need a better way to read them.
An immediate answer that comes to mind is external interrupts. Problem is, CircuitPython doesn't support them — they are an advanced feature, and since the callback code has its own limitations, they were skipped in the current implementation. But I can always add my own C code there, and implement a button-handling module. Since I need to compile my own CircuitPython firmware anyways (because I'm using more pins than the Trinket M0 has), this should be doable. So I started reading about the interrupts on the SAMD21 and looking at the CircuitPython code for the best place to fit it.
But then I thought about de-bouncing. Remember that "two consecutive scans" part in the PewPew Lite? That's the de-bouncing. I should really do it too here, or the users will get too many key presses. To do that, I will need a timer. Timers are also an advanced feature that CircuitPython doesn't yet implement. So I started reading about timers and looking at CircuitPython code to see which timers are already used and where I could plug in my own code...
And then I realized that if I have a timer that is firing relatively fast (say, every 16ms), I don't need the interrupts — I can do the same thing that the chip on PewPew Lite did. And I also found a function that CircuitPython calls every millisecond, where I can plug my own code that would poll the keys once every 16 ticks. Then I just need a function to get the current button status, and I'm done.
Now all that is left is to just write the code...
-
License
09/26/2017 at 08:31 • 0 commentsI just realized that the license in the PewPew repository was wrong. It was CC BY-NC-SA, while I wanted to use BY-SA and allow commercial use. This is now fixed, and all released PewPew code and designs are under Creative Commons BY-SA 4.0 license.