NEQTO Docs
  • Languages iconEnglish
    • 日本語
  • Docs
  • API
  • FAQ

›neqto.js

Getting Started

  • NEQTO Hello World!
  • Tutorial Step 1. NEQTO Console Setting
  • Tutorial Step 2. Device Settings & Launching Service (NEQTO Bridge)
  • Tutorial Step 2. Device Settings & Launching Service (STM32 Discovery)
  • Tutorial Step 2. Device Settings & Launching Service (SPRESENSE)
  • Tutorial Step 3. Application development using scripts

NEQTO

  • NEQTO Account Registration
  • Sub-accounts
  • API Usage
  • NEQTO CloudSync for GCP
  • NEQTO Engine Firmware List
  • Support Guidelines

NEQTO Console

  • Introduction
  • Fundamentals
  • Administrative Actions
  • Device Management
  • Linux-based Device Management
  • Batch Registration
  • Scripts
  • Actions and Contacts
  • View Data from the Console
  • NEQTO Apps

    • About NEQTO Apps
    • NEQTO Infinitypool
    • NEQTO Insights
    • NEQTO Custodia
    • NEQTO Flow
  • Machine Driver
  • Recommended Browsers
  • Billing Information

SPRESENSE

    Hardware Specifications

    • 01. About Spresense

    Software Specifications

    • 01. Operational Flow
    • 02. Initial Installation
    • 03. Spresense Wi-Fi Initial Setup
    • 04. Spresense LTE-M Initial Setup
    • 05. Debug Log Acquisition
    • 06. System LED Indications
    • 07. Event Messages
    • 08. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. GPIO
    • 12. UART
    • 13. SPI
    • 14. I2C
    • 15. ADC
    • 16. GNSS
    • 17. Camera
    • 18. Utils
    • 19. nqSpresense
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi
    • 24. nqLte

STM32 Discovery

    Hardware Specifications

    • 01. About STM32 Discovery Kit (B-L4S5I-IOT01A)

    Software Specifications

    • 01. Operational Flow
    • 02. Initial Installation
    • 03. STM32 Discovery Wi-Fi Initial Setup
    • 04. Debug Log Acquisition
    • 05. System LED Indications
    • 06. Event Messages
    • 07. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. UserSW
    • 12. GPIO
    • 13. UART
    • 14. SPI
    • 15. I2C
    • 16. ADC
    • 18. Utils
    • 19. nqDiscovery
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi

NEQTO Bridge

    Hardware Specifications

    • 01. NEQTO Bridge Module
    • 02. NEQTO Bridge Wi-Fi Module
    • 03. NEQTO Bridge LTE-1 Module
    • 04. NEQTO Bridge LTE-M/NB Module
    • 05. NEQTO Bridge IO Board
    • 06. NEQTO Bridge Digital IO Board
    • 07. NEQTO Bridge Connector Board

    Software Specifications

    • 01. Operational Flow
    • 02. NEQTO Bridge Wi-Fi Module Initial Setup
    • 03. NEQTO Bridge LTE Module Initial Setup
    • 04. Debug Log Acquisition
    • 05. System LED Indications
    • 06. Event Messages
    • 07. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. UserSW
    • 12. GPIO
    • 13. UART
    • 14. SPI
    • 15. I2C
    • 16. ADC
    • 17. BLE
    • 18. Utils
    • 19. nqBridge
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi
    • 24. nqLte
    • 25. nqLAN
    • 26. nqEx

Linux-based device

    Software Specifications

    • 01. System Requirements
    • 02. Installation
    • 03. Software Configurations
    • 04. Operational Flow
    • 05. Debug Log Acquisition
    • 06. Event Messages
    • 07. Updating Software

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. RTC
    • 10. UNIXSocket
    • 11. FileSystem
    • 12. SubProcess
    • 13. Utils
    • 14. nqLinux
    • 15. nqService
    • 16. nqMqtt
    • 17. nqFOTA
    • 18. nqLAN

neqto.js Libraries

  • About neqto.js Libraries
  • UART

    • GM65 Barcode Reader
    • SRF Ultrasonic Range Finder - Serial Mode

    I2C

    • HTS221 v2 Temperature and Humidity Sensor
    • LIS2DW12 v2 Accelerometer
    • SRF Ultrasonic Range Finder - I2C Mode
    • [Archive] HTS221 Temperature and Humidity Sensor
    • [Archive] LIS2DW12 Accelerometer

    Utils

    • RTC Alarm Synchronized Scheduler

    Integration

    • AWS S3 v2
    • AWS IoT Core v2
    • Azure IoT v2
    • GCP IoT Core
    • [Archive] AWS S3
    • [Archive] AWS IoT Core

neqto.js Snippets

  • About neqto.js Snippets
  • DataDog
  • Dropbox
  • Google Sheets
  • InfluxDB
  • Oracle Cloud Object Storage
  • Salesforce
  • SAP Cloud Platform Internet of Things
  • Splunk
  • Niagara

Release Notes

  • NEQTO Console Updates
  • NEQTO Firmware (Bridge Wi-Fi/LTE Module) Releases
  • NEQTO Firmware (STM32 Discovery Wi-Fi) Releases
  • NEQTO Firmware (Spresense Wi-Fi/LTE-M) Releases
  • NEQTO Engine for Linux Releases

11. UserSW

The userSW object is a built-in object that provides a user switch port input function.



userSW Global Object

Methods()/PropertiesSummaryVersionNote
userSW.on()Registers the event handler.00.00.17+
userSW.stopEvent()Stops the event handler.00.00.17+
userSW.getStatus()Gets the current state of the user switch.00.00.17+



Details

userSW.on(event,callback[,opt1[,opt2]])

Registers the event handler.
The event names that can be used are assert and change.
Registering event handlers is performed exclusively, so if the event handler already exists, it will be stopped before the new event handler is registered.

event : ’assert’

NameTypeM/OSummaryNote
eventstringmandatoryHandles the event when the user switch is pressed.
'assert'
If you registered an event handler while the switch is pressed, it is determined that the switch has been pressed from that point.
callback(term)functionmandatoryExecutes callback processing when an event occurs.
term : {number}
Continuous pressing time measured internally [ms]
Start the measurement from after the switch press event occurs.
opt1numberoptionalSwitch press detection time [ms]
Specifies the minimum time required to detect a state in which the switch is pressed.
The default value is 0.
opt2numberoptionalSwitch release wait timer [ms]
This timer starts after the condition of opt1 is satisfied.
If switch is released before timeout, stop the timer and execute immediate callback.
If a timeout occurs, the callback executes at that point even if the switch is pressed.
The default value is 0.
opt2 is valid only when opt1 is specified.

If opt2 is 0, it will be immediately timeout state.
returnundefined--When an error occurs, an exception is raised.

event : ’change’

NameTypeM/OSummaryNote
eventstringmandatoryHandles the state change event of the user switch.
'change'
The initial state immediately after registration of the event handler is also regarded as changed.
callback(status)functionmandatoryExecutes callback processing when an event occurs.
status : {number}
Indicates the switch status.
0: Released state
1: Pressed state
The value at the moment when the event occurs and the current value may not be the same.
returnundefined--When an error occurs, an exception is raised.

userSW.stopEvent()

Stops the event handler.

NameTypeM/OSummaryNote
returnundefined--

userSW.getStatus()

Gets the current state of the user switch.

NameTypeM/OSummaryNote
returnnumber-Indicates the switch status.
0: Released state
1: Pressed state



Object Usage Examples

Sample 1

This sample handles long and short presses of the user switch.
In opt1, set the time until the pressed state becomes valid, In opt2, set the waiting time until a long press is determined.

var minTerm = 100; //ms
var maxTerm = 2000; //ms
userSW.on('assert' ,function(realTerm) {
  print('callback assertion time= ' + realTerm + 'ms');
  if (realTerm >= maxTerm){
    print('long');
  }else if (realTerm >= 300){
    print('short');
  }else{
    print('minimal');
  }
} ,minTerm ,maxTerm);

Sample 2

This is a sample that handles the change of user switch.

userSW.on('change' ,function(status) {
  print('callback SW status= ' + status);
  print('getStatus() SW status= ' + userSW.getStatus());
});



Updated: 2020-05-01
← 10. RTC12. GPIO →
  • userSW Global Object
  • Details
    • userSW.on(event,callback[,opt1[,opt2]])
    • event : ’assert’
    • event : ’change’
    • userSW.stopEvent()
    • userSW.getStatus()
  • Object Usage Examples
    • Sample 1
    • Sample 2
AboutNewsProductsFAQPrivacy Policy}
NEQTO Console
IntroductionFundamentalsAdministrative ActionsDevice Management NEQTO Apps
NEQTO Bridge
NEQTO Bridge ModuleNEQTO Bridge Wi-Fi ModuleNEQTO Bridge LTE-1 ModuleError Logging Event Messages
API Documentation
API UsageGlobal APIRegional APIAPI Terms of Service
Jigsaw, Inc.
© 2023 JIG-SAW INC.