Inclination - bellinux/pcode GitHub Wiki

The Inclination component provides a simple interface for accessing and handling inclination data from a device's sensors. It allows setting a callback function to handle inclination data.

JavaScript

Import the Component

To use the Inclination object, you need to include it in your project:

import Inclination from './js/inclination.js';

Starting the Inclination component

To start receiving inclination data, call the start method, with optional frequency in ms.

Inclination.start(300); //generate events each 300 ms

Handling Inclination Data

To handle the inclination data, set a callback function using the onData method. This callback function will be called with the inclination data whenever it changes.


Inclination.onData((data) => {
    console.log("X: " + data.x + "; Y: " + data.y + "; Z: " + data.z);
});

Python

Import the Component

To use the Inclination object, you need to include it in your project:

from inclination import Inclination

Starting the Inclination component

To start receiving inclination data, call the start method, with optional frequency in ms.

Inclination.start(300) #generate events each 300 ms

Handling Inclination Data

To handle the inclination data, set a callback function using the onData method. This callback function will be called with the inclination data whenever it changes.


def handle_data(data):
    print("X: " + str(data.x) + "; Y: " + str(data.y) + "; Z: " + str(data.z))

Inclination.onData(handle_data)