raspi-io-server-utils
Version:
Utilities for interacting with Raspberry IOs and Raspbian
59 lines (58 loc) • 1.6 kB
TypeScript
declare const EventEmitter: any;
export declare enum InputMode {
PULLUP = "PULLUP",
PULLDOWN = "PULLDOWN",
OFF = "OFF"
}
/**
* Digital input which listens to rising edges.
* Keeps the state until reset.
*
* ## Events
*
* ### `enable`
*
* Emitted when the input changes to logical HIGH (depending on the `highIsOff` settings)
*
* ### `disable`
*
* Emitted when the input changes to logical LOW
*/
export declare class DigitalInput extends EventEmitter {
private readonly _pin;
private readonly _highIsOff;
private readonly _inputMode;
private readonly _ON;
private _tEnabled;
private _currentStatus;
/**
* Creates a new digital input which is polled for changes. When the pin changes,
* an `enable` or `disable` event is emitted.
*
* @param pin Physical pin to read
* @param highIsOff Invert the input: low = on, high = off
* @param inputMode Defines which input resistors (pullup, pulldown, or none) are used.
*/
constructor(pin: number, highIsOff?: boolean, inputMode?: InputMode);
readonly pin: number;
readonly status: {
pin: number;
status: boolean;
tEnabled: number;
highIsOff: boolean;
inputMode: InputMode;
};
/**
* @returns Timestamp when the input was activated the last time
*/
readonly tEnabled: number;
/**
* @returns true, if the input is currently HIGH
*/
readonly currentStatus: boolean;
reset(): void;
setActivated(): void;
setDeactivated(): void;
_stateChanged(): void;
}
export {};