Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PeripheralAD<EventTypes>

Type parameters

  • EventTypes: string

Hierarchy

Index

Constructors

constructor

Properties

Obniz

Obniz: Obniz

obniz to be used

id

id: number

Optional onchange

onchange: undefined | ((value: number) => void)

called when voltage gets changed.

timeout

timeout: number = 30 * 1000

Rsponse waiting timeout in milliseconds

value

value: number

The value will be stored in the value variable.

Note: This property stores the last received value. NOT the value when you read this property.

obniz.ad0.start();
while(true) {
console.log("changed to "+obniz.ad0.value+" v")
 await obniz.wait(10); // 10ms wait
}

Static prefixed

prefixed: string | boolean

Methods

addListener

  • addListener(event: EventTypes, fn: ListenerFn, context?: any): this
  • Parameters

    • event: EventTypes
    • fn: ListenerFn
    • Optional context: any

    Returns this

emit

  • emit(event: EventTypes, ...args: Array<any>): boolean
  • Calls each of the listeners registered for a given event.

    Parameters

    • event: EventTypes
    • Rest ...args: Array<any>

    Returns boolean

end

  • end(): void
  • This stops measuring voltage on ioX.

    obniz.ad0.start();
    obniz.ad0.end();

    Returns void

eventNames

  • eventNames(): Array<EventTypes>
  • Return an array listing the events for which the emitter has registered listeners.

    Returns Array<EventTypes>

getWait

  • getWait(): Promise<number>
  • This measures the voltage just once and returns its value. This function will pause until ad result arrives to your js.

    obniz.io0.output(true)
    var voltage = await obniz.ad0.getWait();
    obniz.io0.output(false)
    console.log(""+voltage+" should be closed to 5.00");

    Returns Promise<number>

    measured voltage

listenerCount

  • listenerCount(event: EventTypes): number
  • Return the number of listeners listening to a given event.

    Parameters

    • event: EventTypes

    Returns number

listeners

  • listeners(event: EventTypes): Array<ListenerFn>
  • Return the listeners registered for a given event.

    Parameters

    • event: EventTypes

    Returns Array<ListenerFn>

notifyFromObniz

  • notifyFromObniz(json: any): void

off

  • off(event: EventTypes, fn?: EventEmitter.ListenerFn, context?: any, once?: undefined | false | true): this
  • Parameters

    • event: EventTypes
    • Optional fn: EventEmitter.ListenerFn
    • Optional context: any
    • Optional once: undefined | false | true

    Returns this

on

  • on(event: EventTypes, fn: ListenerFn, context?: any): this
  • Add a listener for a given event.

    Parameters

    • event: EventTypes
    • fn: ListenerFn
    • Optional context: any

    Returns this

once

  • once(event: EventTypes, fn: ListenerFn, context?: any): this
  • Add a one-time listener for a given event.

    Parameters

    • event: EventTypes
    • fn: ListenerFn
    • Optional context: any

    Returns this

removeAllListeners

  • Remove all listeners, or those of the specified event.

    Parameters

    Returns this

removeListener

  • removeListener(event: EventTypes, fn?: EventEmitter.ListenerFn, context?: any, once?: undefined | false | true): this
  • Remove the listeners of a given event.

    Parameters

    • event: EventTypes
    • Optional fn: EventEmitter.ListenerFn
    • Optional context: any
    • Optional once: undefined | false | true

    Returns this

start

  • start(callback?: undefined | ((voltage: number) => void)): number
  • This starts measuring voltage on ioX until end() is called.

    obniz.ad0.start(function(voltage){
     console.log("changed to "+voltage+" v")
    });

    Parameters

    • Optional callback: undefined | ((voltage: number) => void)

      called when voltage gets changed.

    Returns number

validate

  • validate(commandUri: any, json: any): WSSchema.MultiResult
  • Parameters

    • commandUri: any
    • json: any

    Returns WSSchema.MultiResult

Generated using TypeDoc