I’m using the technique used in FadeCandy now. It rounds a 16bit value to 8bit and adds the “rounding” error to the 16bit value the next frame. Before doing all this, the value is passed through a gamma lookup table.
Here below two links because my own code is a mess:
Another one I’ve used it a table that alternates (technique from HexaWS2811):
I’m curious how it combines with the 5bit value. I’ve read some where that it’s logarithmic already, so probably it has some build in correction.
@kasper it took me about a week longer to get back to this than I expected. I did see the stepping, and after adding some debug printfs to your sketch, I could tell the stepping coincides with GBC value changes. Turns out there was a bug, and I pushed a commit to GitHub. I see smooth changes with no stepping now. You should be able to refresh the library in Web Build to pull the latest changes from GitHub, or just download a new copy if compiling on your machine.
Re: backgroundLayer.swapBuffers(false);
For any sketches that fill the buffer completely every time, you can save some CPU cycles by setting swapBuffers to false, so there’s no copying of the refresh buffer to the new drawing buffer in the background.
I thought through the power supply scenarios, and I think there’s a very simple solution to handle both cases, without needing an additional power supply jack on the board:
Power supplied through USB to both Photon and strip
USB power (supplied through a diode to the Vin pin on the Photon), needs to be brought out to the strip connector
Power suppled through external power supply
External power will be supplied to the strip directly. All the strips/matrices I’ve seen that come with a connector have separate wires for easily connecting to a power supply. If the strips don’t come with wires, they can be easily added.
External power brought to the board through the strip connector needs to power the Photon through the Vin pin
External power can’t interfere with USB power (by drawing too much current or feeding current back to the USB host)
Connecting Vin directly to the strip connector handles both cases. The diode built into the Photon prevents current from the external power supply from flowing back to the USB host, and diode should lower the voltage of the USB power so the Photon and strip will draw from the external power supply and not from USB power.
Here’s a simple schematic showing the power connections, buffers, and microSD card.
@Pixelmatix, that looks good except that Vin at the Photon has no reverse voltage protection. Should one be added from the JP1 Vin feed? Also, I suggest adding a 10uF (or two) ceramic low ESR cap on Vin from the strip connector to remove any ringing caused by LED switching. The Photon regulator has been known to oscillate to death on low power conditions. I so look forward to seeing this completed!
Good question, that would make the board more robust to improper connections, but would prevent Vusb from powering the strip, or at least make it more difficult.
JP1 is likely going to be a pre-soldered JST-SM connector, which is polarized, and will have color coded wires and the pinout common to APA102 strips. It should be difficult to reverse polarity on the power lines. If the lines are reversed, it would likely mean that the strip or matrix (which has no reverse polarity protection) was connected backwards and was also fried.
I'm not sure if breaking the USB power feature is worth the marginal benefit of protecting against reverse polarity on the strip connector. If it were easy to support both scenarios by just adding another diode, it would be a no-brainer.
What do you think?
Also, I suggest adding a 10uF (or two) ceramic low ESR cap on Vin from the strip connector to remove any ringing caused by LED switching
The Photon already has a 22uF cap on Vin. Do you think another cap or two is necessary on the shield? I can always add them to the circuit and make them DNP after doing some testing if they're not necessary.
Adding the reverse protection diode between the strip connector and Vin would help prevent large dips on the power supply, but again, at the expense of easily supporting USB power.
@Pixelmatix, I was also thinking about the polarized connector and it is the better option IMO. Proving a pre-wired connector with a 6-8" pigtail would also help prevent someone from incorrectly wiring their own connector.
The cap was a byproduct of my own (bit banged) RGB Matrix panel board which has a prototyping area on it. For that, having the cap is useful, otherwise not so much as you point out.
Speaking of which, the design you show does not include the row latches for an RGB panel. Is the design ONLY for APA102 panels at this stage?
Maybe control of sharing USB current with the strip should be handled with a current-limiting power distribution switch, e.g. this one. It would add more cost to the shield, but better protect against drawing too much current from USB, and I think it could be used in parallel with the reverse protection diode on Vext (strip connector power connector).
It would be even better if the current limit could be adjustable on the fly (I’m sure there’s a part out there that handles this), so the limit could be changed from a 500mA default, up to 2A if the USB supply can handle it.
@Pixelmatix, interesting. The part you link to is adjustable with a resistor so a jumper could be added to the board to select 500ma or 2A operation. A larger output capacitor (120uF) may be necessary for the higher current mode.
I can’t help but think that adding this part is overkill. Will users tend to use an external supply for most applications (larger strings/panels) and only few users will use the USB option. Once you go external supply, the whole USB-as-a-supply issue goes away.
I’m starting to think about mechanical part placement. Here are the parts with fixed location:
2x12 female SMT headers on either side of Photon
MicroSD card socket under Photon’s USB connector (like in SmartMatrix Shield)
Keepout area under Photon’s antenna
There’s plenty of room for the buffers, diode, etc under the Photon. The big question is what connector to use for connecting to the APA102 strip, and where to put it.
The two options seem to be: put pads on the board so a JST-SM cable can be soldered to the board, or put pads on the board for a terminal block. The same pads can work for both options.
This style of terminal block is small, but can handle the 20AWG wire I’ve seen on APA102 strips/matrices, and can handle 5A per pin. It’s small enough to fit between the female SMT connectors. Here’s some photos using a SparkFun shield as a PCB for now.
I think I’ll want the cable to point away from the keep-out zone to keep a high speed signal away from the WiFi antenna, but it’s easy to double the cable back if you really want it to point that way, or if you’re soldering the cable or terminal block yourself, you can make the choice of direction.
I’d love to get some feedback on this before continuing with the layout.
Sorry, I missed the last few posts in this thread. Looks great so far! I voted in the poll. I think I would use an external power supply most often, but the power through USB option would be really nice for small projects. I would probably also prefer the JST-SM cable over the terminal block, but again, both options are great.
One more mechanical consideration: mounting holes. I don’t like the SparkFun Photon shield’s mounting holes because they interfere with the expansion connectors. You can’t use right-angle headers for expansion as they interfere with the mounting holes, and have to be careful with the screw you select as a large head can risk shorting out a pin.
Moving the holes further out in both X and Y directions would fix both problems, but increase the size (and cost) of the board. This is a useful option if we want to add prototyping space, but I want to focus on making a small/cheap board first.
The screws could be placed at the end of the Photon headers, leaving the sides free for use with right-angle headers and the board space still stays relatively small. This isn’t great for Electron compatibility, as the screws on the bottom would interfere with the longer headers on the Electron.
This layout is about the same surface area, but moves the mounting holes out of the way of the Electron.
I think this is OK, but could be better. I don’t like that the board got larger without adding any useful prototyping area. Perhaps the mounting holes could be an option that could be snapped off if not needed, using drill perforations like SparkFun does with their ProtoSnap boards.
I found one project that is using breakaway mounting holes, and the author commented that the “breakable mounting holes do break off very easy. One did break of during assembling”. I think the breakaway holes are spaced a little too close together, there’s not much PCB material between the holes.
This wouldn’t reduce the cost of the board, it still requires the same amount of PCB material before routing around the edges, but it would keep the board outline small for projects that are space constrained and don’t need some/all of the mounting holes.
I like the last layout (without the breakaways), except that it pushes the Photon’s micro USB connector (and the micro SD card) in from the edge of the board. If you were mounting inside a small enclosure, project box, etc, it’d be nice to have the connector flush. I wouldn’t mind only having mounting holes on the antenna end, or like the SparkFun shield and making sure to get small screws that don’t interfere with the headers.
Good idea, but the space under the Photon is pretty tight right now with the MicroSD socket, SMT components, and the pads for the the cable/terminal blocks
Good point, I agree with you, the shield shouldn't extend past the front edge of the Photon.
Despite not liking the SparkFun Photon Proto Shield's mounting holes, it might be worth making the SmartMatrix APA102 Shield match the form factor, to easily allow people to add prototyping space using a Proto Shield or more functionality to their project using one of SparkFun's other shields.
Most of the shields conveniently (or inconveniently) include tall 1x12 stacking headers pre-soldered to the board. The stack-up height isn't ideal, but you could use the shields as is with the SmartMatrix APA102 Shield by putting the Photon in the tall sockets, and putting the long headers through the SmartMatrix Shield. The height is 29.5mm with screw terminals, 26mm with just wires. Example using a SparkFun Battery Shield:
If you don't mind modifying the SparkFun shield, you can remove the tall female headers - no need to desolder, just flex them until they fall off - and add a second row of sockets to the outside pins on the shield. Add male pins to the outside row on the SmartMatrix Shield, and the stack-up height is better (22.65mm):
There's a tradeoff here, the board will be much wider than is needed for a project that doesn't need expansion or mounting holes. You can fairly easily break off the excess board at the outside expansion holes with some pliers, though I'm not sure if this would risk breaking SMT solder joints on a populated board.
I like it. It provides mounting holes, and allows for expansion, while still maintaining a fairly compact form.
Now someone just needs to create a compatible shield with an MSGEQ7, headphone input jack, and IR receiver. Oh, and while I’m wishing: someone should get an IR receiver library working for the Photon. That’s one reason I have to keep using Teensy or ESP8266 boards in my projects instead of Photons.
My understanding (please correct me if I’m wrong) is @AnalysIR requires a connection to a PC to perform the actual decoding. I’m just looking for a port of Arduino IRremote, ESP8266 IRremote, or a similar library for receiving and decoding. It doesn’t seem to have been ported it to the Photon. I’ve tried, but could not get it working. It’d be amazing if someone from Particle or the community could port it.