UNPKG

jvsveml6070

Version:

Node.js package for the Vishay VEML6070 UVA Light Sensor, written in TypeScript.

69 lines (68 loc) 2.25 kB
/// <reference types="node" /> export declare class Byte { /** * The internal `Buffer` instance. */ protected _buffer: Buffer; /** * Creates a new `Byte` instance. * * @param buffer - An optional `Buffer` instance to use. */ constructor(buffer?: Buffer); /** * Creates a new `Byte` instance from the values of one or more bits. * * @param bits - A map of bit values keyed by the bit index (in binary order, right to left). * * @returns The created `Byte` instance. */ static fromBits(bits: Map<number, number>): Byte; /** * Creates a new `Byte` instance from a hexadecimal value. * * @param hex - A hexadecimal value, e.g. `0x01` (binary `00000001`). * * @returns The created `Byte` instance. */ static fromHex(hex: number): Byte; /** * Reads the value of a specific bit. * * @param index - The index of the bit to read (in binary order, right to left). Should be a value from 0 to 7. * * @returns The value of the bit. */ readBit(index: number): number; /** * Reads the values of all eight bits. * * @returns A map of bit values keyed by the bit index (in binary order, right to left). */ readBits(): Map<number, number>; /** * Writes the value of a specific bit. * * @param index - The index of the bit to write (in binary order, right to left). Should be a value from 0 to 7. * @param value - The value of the bit. * * @throws {@link LogicError} * Thrown if an invalid bit index and/or value is provided. */ writeBit(index: number, value: number): void; /** * Writes the values of one or more bits. * * @param bits - A map of bit values keyed by the bit index (in binary order, right to left). * * @throws {@link LogicError} * Thrown if too many bits values are provided, or if invalid bit indexes and/or values are provided. */ writeBits(bits: Map<number, number>): void; /** * Returns a `Buffer` instance representing the `Byte` instance. * * @returns The `Buffer` instance representing the `Byte` instance. */ toBuffer(): Buffer; }