BUS PIRATE: 2bit anti aliased font for small color LCDs

Bus Pirate prototype “Ultra” v1b has an IPS LCD to show pinout labels, voltage levels, and other useful info. The background image was done in Photoshop and is stored in the 32Mbit flash chip on the board. Pin labels and voltage readings are drawn on top of the background image with a fixed-width font.

1bit font generator by maxpromer

Most LCD fonts represent each pixel with a single bit (on or off). This is an efficient way to store a font, but the results look jagged and unprofessional. To get a better look, we anti aliased an open source font and then extracted two bits per pixel of color data. The results, shown above, use a four color lookup table to represent the background, text color, and two intermediate colors for anti aliased pixels.

Anti aliasing smooths the edges of each letter with a few pixels in intermediate colors. The bottom line of text is not processed at all, angular and circular edges look jagged and stepped. The top four lines of text use various styles of anti aliasing and the edges appear smoother on a small display.

Real-time anti aliasing on the MCU will take too many resources, so we made a pre-anti aliased font. Instead of storing each pixel as a single bit, we use 2bits of data per pixel and a four color lookup table to draw the characters. The resulting font takes twice as much space as a one bit font, but the extra bit (two extra colors) are used for those nice fuzzy edges.

The background image is designed for characters 14 pixels tall. It’s important to choose a fixed-width monospaced font so that each character has even spacing. We used DejaVu Mono, an open source fixed-width font that is used in Linux. At 14 pixels tall the characters are 10 pixels wide. Our characters will be 10×14 at 2 bits per pixel, that’s 35 bytes each.

In Photoshop we used View->New Guide Layout to create a 10×14 pixel grid, then added the typical range of ASCII characters. We skipped a box between each character so that any stray anti aliased pixels that fall outside the box don’t get included in a neighboring character. We tried several types of anti aliasing, and decided “Windows LCD” looks best on our small display.

At this point we have a grid of nicely anti aliased characters, but Photoshop is using dozens of different colored pixels to make those smooth edges. Before we process the character set we need to reduce that to something manageable. The simplest enhancement to a 1 bit font is to add an extra bit. 2 bits per pixel provides a four color pallet: text, background, and two shades of grey for the anti aliased pixels. We converted the characters to a four color pallet in Photoshop with Image->Mode->Indexed color, then assigned a four color custom pallet and saved the result as a 8bit color bitmap.

Bus Terminal has become a dumping ground for our utility scripts. A small addition loads the font image, crops each character, and outputs the font variables as HEX numbers. The font output goes into a font.h file to include in the Bus Pirate firmware.

lcd.c demonstrates how to use the 2 bit font. Our display uses 16 bits per pixel in 565RGB mode. font_lut16RGB contains our pallet of 4 16 bit color codes. We prefer to start with 24 bit color codes because they’re ubiquitous, so we enter our colors into font_lut24 and pre-calculate the 16 bit color values during initialization. Our color pallet includes the background image color, a white shade for the character, and two grey tones for the anti aliased pixels.

To write a character we loop through the 35 bytes of data, pulling out 2 bits at a time. Each two bit set is used to lookup a color code in the lookup table. The color code is sent to the display via SPI. A lot of data has to be moved to write a single character, 280 bytes each for this font.

This is an example of different anti aliasing methods (sharp/crisp/strong/smooth) using 2 bits/pixel. The line on the bottom has no anti aliasing. Without anti aliasing the bottom line is jagged and rough. The other lines add one bit (two indexed colors) for anti aliasing and look remarkably better, even without tweaking.

Taking it further

The 2 bit font looks much better than a 1 bit font. This same technique could be used to extract 3 or more bits of color data per pixel, but that eventually feels like reinventing the PNG.

This is very much a hack in progress. A few tweaks the pallet during conversion to indexed color that will probably make it look much nicer. Some of the characters in the set hang below the outline, so g, q and p are cut off. While Photoshop is good for extensive tweaking, it’s going to take a lot of effort to make font in different sizes.

It seems possible to render each character, anti alias it, and reduce it to indexed color using Qt libraries like QPaint and QPixelmap. The Photoshop side could be automated in Qt to export any system font in any size with minimal hassle.

from Dangerous Prototypes https://ift.tt/2OUZIf2

Sequence controller

Eric Gunnerson has been working on a sequence controller project:

Yeah. Those pins are beautifully aligned a very precise 0.1” from where they are supposed to be…
Pro tip: Print out your design and put your components on it so that you can check the design.
Meta pro tip: Follow your pro tips.
Anyway, that’s not the only problem; it turns out that the power and LED parts of the connector are right underneath the end of the board, so you can’t use a normal header on them (you could use a right-angle one if you wanted), so I did a new revision of the board with 1.0” rather than 1.1” for the ESP and extended the board so the connectors are out on the end. That’s on the slow ship from China right now.

See the full post on Eric’s Arcana and RiderX blog.

from Dangerous Prototypes https://ift.tt/33ydCaM

Chinese cable and connector vocabulary

Bus Pirate prototype “Ultra” v1c will use a 0.5mm flex cable (FFC/FPC) to connect the display board. Of course we could just order the standard parts from Mouser or SZLCSC, but rooting around on Taobao is fun and gives a better idea of the range of stuff out there. Here’s some Chinese vocabulary that helped us order parts.

Cables that are connected 1:1, pin one of one connector is wired to pin 1 of the other connector, are called 反向. Cables that are connected 1:N, pin one of one connector is wired to the highest number pin of the other connector, are called 同向. We ordered the wrong version of the 1.25mm display cable for v1b, but fortunately the crimps can be carefully removed and replaced in reverse order. This won’t be an option with the flex connector.

Most FPC/FFC connectors are available in two types. Metal contacts on the bottom of the connector slot are called 下接. Metal contacts along the top of the connector slot are called 上接.

Orientation is really important because FPC/FFC cables generally only have contacts exposed on one side of each end. FPC/FFC cables are also available in 反向 / 同向 (1:1/1:N), meaning the exposed contacts are on the same side or opposite side of the ends. We’ll post some photos of these cables when they arrive.

from Dangerous Prototypes https://ift.tt/2nS8zTF

DIY AD9833 signal generator

Daumemo has been working on a DIY signal generator based on an AD9833 IC:

In this post I am going to continue with the DIY signal generator based on the AD9833 IC where I have left in the previous part. Earlier, I have talked how I had built my first analog signal generator’s stage – variable gain amplification circuit. Usually, a generator needs to have an ability to change not only the signal’s amplitude, but also its offset. So, today I will walk you through a circuit which adds an offset to the DIY generator’s output signal.

More details on his blog. See part 1 of this series for the analog signal generator’s stage.

from Dangerous Prototypes https://ift.tt/33D9xCy

BUS PIRATE: LCD with pinout labels and live info

The Bus Pirate prototype “Ultra” v1b has a 10 pin 1.25mm connector for a display daughterboard. We wanted a more dynamic way to keep track of the pinout and other handy information like pin states and voltage levels.

There are various reference stickers and labeled probe cables for the Bus Pirate v3 and v4, but a display frees us from strict pinout conventions and makes setup a lot easier for new hackers. More on the display below.

We wanted to use ePaper!

At first we really wanted to use ePaper. A static, easily readable display is reminiscent of the stickers it replaces, and makes reference to its primary purpose as a label. The slow update speeds also dampen expectations of flashy graphics and interaction.

The three color ePaper shown above was a top candidate, but it requires 180 seconds of rest between updates to stay in spec. Slow updates are acceptable, but we need to be able to change the display more frequently than once every three minutes.

While the two color version of this display doesn’t have this limitation, we ultimately decided that the Dots Per Inch is just too low to look really good. ePaper is also quite expensive compared to IPS LCDs with much higher pixel density.

IPS LCDs

Our attention turned to inexpensive LCDs. These are not the dodgy panels with limited color and ever-changing driver chips you may have used in the past. About $3 buys a 240×320 pixel 2 inch IPS (view from every angle) display supporting 250K colors, with a simple SPI interface and well known driver chip. We bought samples from two manufacturers, a QT020HLCG00 and a HT020SQV003NS.

With a bunch of colors and the ability to constantly update, we can show a lot of useful info. Each pin has a proper name corresponding to the active mode, along with input/output direction indication. Color caps on each pin match the probe cable wires, the terminal interface and the logic analyzer client.

Starting with v1b we can measure voltage on all 8 IO pins, so we’ll show that on the display. We’re particularly excited about this feature because we always end up jugging multimeter probes to verify levels during a rough hack. Now we can just look at the display!

Both LCDs are approximately the same dimensions, but the solderable flex connector is a slightly different length. The LCD daughterboard has extra long pads that fit both displays. The files for the display board are in the git repo.

The image on this LCD is just a static mock-up exported from Photoshop. Next we’ll need to create a font and write actual values to the display. This is will be tricky because LCD fonts typically look jagged and ugly, and we don’t really have enough power to do anti aliasing on the fly. Follow our latest progress in the forum.

from Dangerous Prototypes https://ift.tt/31c9wUk

Arduboy with removable flash cart

A homebrew Arduboy with removale flash cart from Facelesstech:

I’ll start with the Arduboy its self. I wanted to make a small Arduboy that anyone with basic soldering skills could make. I don’t think its the easies of boards to solder but its the only way I could make it small enough and have all the features I wanted. I just went with the standard SSH1106 0.96″ screen that most people use in their homemade builds. The buttons I went with are the ones I’ve been using on my other RetroPie builds in the past. They are soft touch but they are not mushy like some are and have a small foot print.

More details on Facelesstech homepage.

Check out the video after the break.

from Dangerous Prototypes https://ift.tt/2ISvo0F

BUS PIRATE: Love the USB C connector!

Bus Pirate prototype Ultra v1b uses a common, cheap USB C connector and we are in love!

Micro B connectors are a nightmare. Very inconsistent footprints, poor materials and build quality, and very weak mounting supports. Often the leads are hidden under the housing and conceal pesky shorts. Almost every Micro B connector we hand soldered eventually broke off the board and usually took some traces with it.

USB C solved all these issues! Soldering it is an absolute breeze. Leads are easily accessible and friendly to solder. It’s made of decent materials, and the footprint seems to be pretty standardized across the market. The mounting posts are solid and strong, this connector isn’t going anywhere.

Here’s how we connected it on the v1b hardware. The footprint was made by Sjaak at SMDprutser and is in our git repo.

from Dangerous Prototypes https://ift.tt/32e8dFz

App note: FPGA power supply considerations

App note from Vishay Siliconix, giving us tips on powering FPGAs. Link here (PDF)

An FPGA is a device that offers many logic elements – up to 1 million gates in a single device at this writing – as well as other functionality such as transceivers, PLLs, and MAC units for complex processing. FPGAs are becoming very powerful, and the need to power the devices effectively is a key, if often underestimated, part of the design. A straightforward power supply design process can significantly reduce the number of required design iterations for the OEM designer.

from Dangerous Prototypes https://ift.tt/2VAIK6Y

PROTOTYPE: Bus Pirate “Ultra” v1b

Today we finished stuffing the first Bus Pirate “Ultra” v1b board. This includes the updates we posted this week, and a few other improvements from v1a:

The new power supply and voltage measurement concept are both tested and working on the new hardware. The new USB C connector is extremely solid and is a dream to solder, we’ll never look back.

Next we’ll work on getting the display going. So far it powers up and no smoke escapes.

Eagle files for v1b are in the git repo. Follow development of v1c in the forum.

from Dangerous Prototypes https://ift.tt/2q5jt9j

Bus Pirate: Reclaiming the Vpullup pin

The Bus Pirate Vpullup pin supplies a voltage to the on-board pull-up resistors. In the “Ultra” hardware it also powers the external half of the bi-directional IO buffer.

  1. MOSI
  2. CLOCK
  3. MISO
  4. CS
  5. AUX
  6. AUX2 (formerly ADC)
  7. Vpullup
  8. AUX4 (formerly 3.3Volts)
  9. 0.8-5.0Vout (formerly 5.0Volts)
  10. GND

So far we’ve added voltage measurement to every IO pin and removed the dedicated ADC pin. We also replaced the fixed 3.3volt and 5volt power supplies with a single programmable output power supply (Vout) capable of 0.8-5.0volts output at 300mA. Today we’re going to reclaim the Vpullup pin and dig into the on-board pull-up resistor system.

On-board pull-up resistors

Many common buses like I2C and 1-Wire won’t work at all without pull-up resistors. Pull-up resistors are also commonly used in voltage level translation. The Bus Pirate can only directly interface at 3.3volts, but using open drain outputs with pull-up resistors it can interface with devices running at 2-5.5volts.

The Bus Pirate has on-board pull-up resistors on the four main bus pins (MOSI, CLOCK, MISO, CS) of the IO header. The pull-ups are toggled in the terminal with the P/p commands.

MOSI is used in the 1-Wire protocol. Several 1-Wire devices are parasitically powered from the pull-up resistor and require no additional power supply. These devices typically require a lower value pull-up resistor than other buses. The Bus Pirate has a 2K pull-up resistor on MOSI to properly power 1-Wire devices, while the other pins have 10K pull-up resistors.

74HCT4066 analog switch applies Vpullup voltage to a resistor attached to MISO pin.

The Vpullup voltage is switched onto the pull-up resistors through a 74HCT4066 analog switch. This is an effective solution, but there’s an annoying waste of pins when the 4066 is used this way.

Merge the Vpullup functions into the Vout pin

Pull-up source select on v5 prototype.

In the past it made sense to have a dedicated Vpullup pin so the user can connect it to one of the two on-board power supplies (3.3volts, 5volts), or the supply of an external circuit. We tried to automate this from the terminal in various prototypes using FETs, analog switches and other methods.

Since we’ve combined the on-board supplies into a single Vout pin, let’s also power the pull-up resistors and bi-directional IO buffer the Vout pin. The Vout/Vref pin now has two uses:

  1. Programmable power supply output from 0.8-5.0volts that powers the IO buffers and pull-up resistors (when enabled)
  2. Voltage reference input that powers the IO buffers and pull-up resistors (when enabled) from an external supply (e.g. self-powered breakout board)

We lose the ability to run the pull-up resistors and the programmable output power supply at different voltages. This could matter when Vout is used as the external supply for a board with its own voltage regulator.

Adjustable pull-up/down resistors?

MCP44X2 I2C digital quad rheostat. Source: MCP44X2 datasheet page 1.

This is definitely overkill, but let’s go “Ultra” for a moment. MCP4442-10K is an I2C controlled digital rheostat with 4 10K resistors. Each resistor can be disabled or connected to 127 taps between 10K and 0R.

Unfortunately we run into pesky bandwidth issues again, the same reason we couldn’t use this chip in the programmable output power supply. The 10K version of the MCP4442 only has 1MHz of bandwidth, which means the maximum speed the internal circuit can adjust to changes in signals. A lot of common buses support speeds above 1MHz. Linear Devices has several precision digital pots with much higher bandwidth, but they’re far too expensive to justify replacing the current cheap and dirty setup.

Updated pinout

  1. MOSI
  2. CLOCK
  3. MISO
  4. CS
  5. AUX
  6. AUX2 (formerly ADC)
  7. AUX3 (formerly Vpullup)
  8. AUX4 (formerly 3.3Volts)
  9. 0.8-5.0Vout/Vref (formerly 5.0Volts)
  10. GND

With the Vpullup pin features safely tucked into the Vout pin, we can add an eighth general purpose IO pin to the header (AUX3). Vout is renamed Vout/Vref to identify its dual power output and reference input functions.

The final thing to do is add a second 4066 so all 8 IO pins have a pull-up resistor.

Next time we’ll try to find a better way to label the IO header pinout. If you want to skip the wait, our latest work is in the forum.

from Dangerous Prototypes https://ift.tt/2AZTdPQ