Utility class for various common operations.

Constructors

Methods

  • Converts a DataView, Uint8Array, or number array to a hexadecimal string with byte separator.

    Parameters

    • buf: DataView | Uint8Array | number[]
    • separator: string = " "

    Returns string

  • Converts a Uint8Array of length 2 to a 16-bit signed integer (big endian).

    Parameters

    • arr: Uint8Array

    Returns number

  • Count non-zero bits in the byte array.

    Not efficient, but readable.

    The algorithm is obtained by reverse engineering and I don't understand what's going on here.

    Sometimes these values match original packets, sometimes not.

    Parameters

    • arr: Uint8Array
    • printheadSize: number

    Returns {
        a: number;
        b: number;
        c: number;
        total: number;
    }

    • a: number
    • b: number
    • c: number
    • total: number
  • Converts a DataView object to an array of numbers.

    Parameters

    • dw: DataView

    Returns number[]

  • Converts a DataView object to a Uint8Array

    Parameters

    • dw: DataView

    Returns Uint8Array

  • Converts a hexadecimal string to a Uint8Array buffer.

    Parameters

    • str: string

    Returns Uint8Array

  • Checks if the browser supports Bluetooth functionality.

    Returns boolean

  • Checks if the browser supports the Web Serial API for serial communication.

    Returns boolean

  • Converts a given number to its hexadecimal representation.

    Parameters

    • n: number

    Returns string

  • Asynchronously pauses the execution for the specified amount of time.

    Parameters

    • ms: number

    Returns Promise<undefined>

  • Converts a 16-bit unsigned integer to an array of two bytes (big endian).

    Parameters

    • n: number

    Returns [number, number]

  • Compares two Uint8Arrays to check if they are equal.

    Parameters

    • a: Uint8Array
    • b: Uint8Array

    Returns boolean

  • Converts a Uint8Array to a string using TextDecoder.

    Parameters

    • arr: Uint8Array

    Returns string