View on GitHub

microbit-2of5-font

2of5 number screen in makecode microbit

microbit-2of5-font

README | TH-README

A MakeCode extension for the micro:bit that displays numbers on the 5×5 LED matrix in 2 of 5 style.
Inspired by the 2 of 5 barcode family, especially Interleaved 2 of 5 (ITF).

Demo:

Project page: https://quarequin.github.io/microbit-2of5-font/


Features


Install as Extension

  1. Open https://makecode.microbit.org/
  2. Create a New Project
  3. Click the gear icon → Extensions
  4. Paste this URL and import:
https://github.com/Quarequin/microbit-2of5-font

(The previous URL https://github.com/phatisena/microbit-2of5-font still works.)


Main Blocks / Functions

Function Description
write2of5(a, b) Map two bit positions (0–4) to a 2of5 digit (returns -1 if invalid)
show2of5Number(n, guard, transpose?, brightness?) Show a full number (up to 5 or 6 digits)
show2of5SingleNumber(n, col, inv, transpose?, brightness?) Show a single digit at a specific column
show2of5DualNumber(a, b, align, transpose?, brightness?) Show two numbers side-by-side (Left / Center / Right)

Important Parameters


2 of 5 Pattern Encoding

Each digit is encoded with 5 bits (exactly two bits set to 1):

0 → 11000
1 → 10100
2 → 10010
3 → 10001
4 → 01100
5 → 01010
6 → 01001
7 → 00110
8 → 00101
9 → 00011

Stored as a compact descending Buffer (the “2of5 magic buffer”):

const pin2of5: Buffer = hex`181412110C0A09060503`

write2of5 uses binary search on this buffer to convert two bit positions back into a digit.


Edit this Project

  1. Open https://makecode.microbit.org/
  2. Click ImportImport URL
  3. Paste:
https://github.com/Quarequin/microbit-2of5-font

Technical Info


Metadata (used for search, rendering)