Package-level declarations

Types

Link copied to clipboard
data class ChannelLabelContent(val title: String, val radio: String, val action: String)

What a channel label says beside its QR.

Link copied to clipboard
class FittedQr(val payload: String, val modules: QrModules, val dotsPerModule: Int)

A QR code that fits the head at a whole number of dots per module.

Link copied to clipboard
data class LabelLayout(val width: Int, val height: Int, val ops: List<LabelOp>)

A label in reading orientation: width dots along the feed, height across the head.

Link copied to clipboard
sealed interface LabelOp

One drawing step of a label, in printer dots with the origin at the top left of the reading orientation.

Link copied to clipboard
sealed interface LabelPrintError

Why the sheet could not find, reach or finish a print on the printer.

Link copied to clipboard
Link copied to clipboard
data class LabelPrintState(val status: LabelPrinterStatus = LabelPrinterStatus.IDLE, val printerName: String? = null, val found: List<BleDevice> = emptyList(), val error: LabelPrintError? = null, val printed: Boolean = false)
Link copied to clipboard

Finds a Niimbot printer, reconnects to the one used last as soon as it is seen, and prints. The printer has its own Bluetooth connection, so the radio's is not involved.

Link copied to clipboard
class LabelRasterizer(textMeasurer: TextMeasurer, emojiFont: FontFamily, textFont: FontFamily = FontFamily.Default, bandFont: FontFamily = textFont) : LabelTextMeasurer

Draws a LabelLayout at one pixel per printer dot and thresholds it to one bit. Text is bold in textFont; emoji come from emojiFont, a one-color face, because color emoji threshold to blobs. Band words are bold in bandFont.

Link copied to clipboard
sealed interface LabelSpec

A label the print sheet can draw: what it says, what its QR encodes, and the words in its band.

Link copied to clipboard
fun interface LabelTextMeasurer

Measures one run of label text in printer dots; sizes are font pixel sizes.

Link copied to clipboard
data class NameTagContent(val shortName: String, val longName: String, val nodeId: String)

What a name tag shows for a node.

Link copied to clipboard
fun interface QrEncoder
Link copied to clipboard
class QrModules(val size: Int, dark: BooleanArray)

A QR code's modules, without a quiet zone.

Link copied to clipboard
class RenderedLabel(val preview: ImageBitmap, val bitmap: LabelBitmap)

A label ready to show and to print.

Properties

Link copied to clipboard
const val LABEL_HEAD_DOTS: Int = 96

Dots across the D110's head, which is also the height of 12 mm stock.

Link copied to clipboard

Error correction L, as labeltastic prints: the label has no room to spend on redundancy.

Functions

Link copied to clipboard
fun channelLabelSpec(channelSet: ChannelSet, url: String, shouldAdd: Boolean, modemPresetName: String): LabelSpec

The channel label for channelSet, whose QR encodes url, the link Share Channels shows. shouldAdd is whether scanning adds the channels or replaces the scanner's.

Link copied to clipboard

Whether to offer Print label here: only where the app can reach the printer and the device has Bluetooth LE.

Link copied to clipboard
fun labelLengthDots(millimeters: Int): Int

The feed length of a die-cut label millimeters long, as labeltastic's with_label_length sizes it.

Link copied to clipboard
fun LabelPrintSheet(spec: LabelSpec, onDismiss: () -> Unit, viewModel: LabelPrintViewModel = metroViewModel(), permission: PermissionUiState = rememberBluetoothPermissionState(), bluetoothOff: Boolean = isBluetoothDisabled())

Prints spec on a Niimbot D110: a preview, the label length, the printer, and Print. The length and the printer are remembered, and the printer used last reconnects when it is seen.

Link copied to clipboard
fun LabelSpec.layout(lengthDots: Int, measurer: LabelTextMeasurer, encoder: QrEncoder = LabelQrEncoder): LabelLayout?

Lays this out for a label lengthDots long, or returns null when its QR does not fit the head at 2 dots per module. A contact's long name is cut in the QR payload first; a channel or connect link has nothing to cut.

Link copied to clipboard
fun nameTagSpec(node: Node, contact: SharedContact): LabelSpec

The name tag for node, whose QR encodes contact, the contact Share Contact shows.