Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Current »

The pointercalibration object allows you to calibrate a touchscreen connected to the player.

pointercalibration IDL
interface PointerCalibration {
    Promise<void> startCalibration();
    Promise<int> getCalibrationStatus();
    Promise<void> setCalibrationRanges(int XMin, int XMax, int YMin, int YMax);
    Promise<bool> clearStoredCalibration();
    Promise<bool> isCalibrated();

    Promise<String> getDiagnosticInfoHTML(bool deviceInfo = true, bool events = true);
    Promise<void> startEventLogging();
    Promise<void> stopEventLogging();
};

ON THIS PAGE

Object Creation

To create a pointcalibration object, first load the brightsign/pointercalibration module using the require() method. Then create an instance of the pointcalibration class.

var pointerCalibrationClass = require("@brightsign/pointercalibration");
var pointerCalibration = new pointerCalibrationClass();

PointerCalibration

startCalibration()
Promise<void> startCalibration()

Begins touchscreen calibration. This method may fail if no suitable devices are present.

getCalibrationStatus()
Promise<int> getCalibrationStatus()

Returns the current touchscreen calibration status as an integer. This method may fail if no suitable devices are present. The following are possible return values:

  • 0: Calibrating the top-left point
  • 1: Calibrating the top-right point
  • 2: Calibrating the bottom-right point
  • 100: Calibration complete
setCalibrationRanges()
Promise<void> setCalibrationRanges(int XMin, int XMax, int YMin, int YMax)

Overrides the screen range values provided by the touchscreen. This method is useful when the entirety of the video output is not being displayed on the touch surface. Practical use of this method usually requires a custom calibration script, appropriate images, and a calibration setting matched to a particular setup.

clearStoredCalibration()
Promise<bool> clearStoredCalibration()

Clears the stored calibration setting for a touch screen. This method may fail if no suitable devices are present. 

isCalibrated()
Promise<bool> isCalibrated()

Returns true if calbration data is present in system software.

getDiagnosticInfoHTML()
Promise<DOMString> getDiagnosticInfoHTML(bool deviceInfo, bool events)

Returns touch-screen diagnostics. If deviceInfo is true, this method will return hardware and kernel-configuration information; if events is true, this method will return a log of events (the event log is then deleted up to that point).

startEventLogging()
Promise<void> startEventLogging()

Begins logging for touchscreen events.

stopEventLogging()
Promise<void> stopEventLogging()

Stops logging for touchscreen events.

Example

const pointerClass = require("@brightsign/pointer");
var pointer = new pointerClass();
const pointerCalibClass = require("@brightsign/pointercalibration");
var pointerCalib = new pointerCalibClass();
var bsMessage = new BSMessagePort();
var present = {
    mouse: undefined,
    TouchScreen: undefined
}

function runThis() {
    pointerCalib.startEventLogging().then(() => {
        console.log("Started Event Logger.");
        bsMessage.PostBSMessage({
            startLogger: "Success"
        });
    }).catch((err) => {
        console.log("ERROR: " + err);
        bsMessage.PostBSMessage({
            startLogger: "Failed"
        });
    });
    function eventInfo() {
        pointerCalib.getDiagnosticInfoHTML(false, true).then((val) => {
            console.log("----------------------------Events Info-----------------------------")
            console.log(val);
        }).catch((err) => {
            console.log("ERROR: " + err);
        });
    }

    function checkPeripherals() {
        pointer.isMousePresent().then((val) => {
            console.log("Checking to see if a mouse if present.");
            present.Mouse = val;
            if (val === false) {
                console.log("No mouse attached.");
                console.log("value: " + val);
                bsMessage.PostBSMessage({
                    mouse: "Success"
                });
            } else if (val === true) {
                console.log("Mouse Detected.");
                console.log("value: " + val);
                bsMessage.PostBSMessage({
                    mouse: "Success"
                });
            } else {
                console.log("Recieved unexpected return value.");
                console.log("value: " + val);
                bsMessage.PostBSMessage({
                    mouse: "Failed"
                });
            }
        }).catch((err) => {
            console.log("ERROR: " + err);
            bsMessage.PostBSMessage({
                mouse: "Failed"
            });
        });
        pointer.isMultiTouchPresent().then((val) => {
            present.TouchScreen = val;
            if (val === true) {
                console.log("TouchScreen found.");
                console.log(val);
                bsMessage.PostBSMessage({
                    touch: "Success"
                });
            } else {
                console.log("TouchScreen not found.");
                console.log(val);
                bsMessage.PostBSMessage({
                    touch: "Success"
                });
            }
        }).catch((err) => {
            console.log("ERROR: " + err);
            console.log("isMultiTouchPresent failed.");
            bsMessage.PostBSMessage({
                touch: "Failed"
            });
        });
    }

    function Calibrate() {
        pointerCalib.setCalibrationRanges(0, 1920, 0, 1080).then((val) => {
            console.log("Range has been set.");
            bsMessage.PostBSMessage({
                CalibRange: "Success"
            });
        }).catch((err) => {
            console.log("ERROR: " + err);
            console.log("SetCalibrationRanges Failed.");
            bsMessage.PostBSMessage({
                CalibRange: "Failed"
            });
        });
        pointerCalib.startCalibration().then((value) => {
            console.log("Starting Calibration:");
            bsMessage.PostBSMessage({
                Calib: "Success"
            });
            pointerCalib.getCalibrationStatus().then((val) => {
                console.log("Calibration Status: " + val);
                bsMessage.PostBSMessage({
                    CalibStat: "Success"
                });
            }).catch((err) => {
                console.log("ERROR: " + err);
                console.log("getCalibrationStatus Failed.");
                bsMessage.PostBSMessage({
                    CalibStat: "Failed"
                });
            });
        }).catch((err) => {
            console.log("ERROR: " + err);
            console.log("startCalibration Failed.");
            bsMessage.PostBSMessage({
                Calib: "Failed"
            });
        });
    }

    function CheckandClear() {
        pointerCalib.isCalibrated().then((value) => {
            console.log("Checking for calibration.");
            if (value === true) {
                console.log("Calibrated: " + value);
                bsMessage.PostBSMessage({
                    isCalib: "Success"
                });
                pointerCalib.clearStoredCalibration().then((val) => {
                    console.log("Attempting to clear calibration.");
                    if (value === true) {
                        console.log("Calibration Cleared: " + val);
                        bsMessage.PostBSMessage({
                            clearCalib: "Success"
                        });
                    } else {
                        console.log("Calibration Cleared: " + val);
                        bsMessage.PostBSMessage({
                            clearCallib: "Success"
                        });
                    }
                }).catch((err) => {
                    console.log("ERROR: " + err);
                    console.log("Failed to clear calibration.");
                    bsMessage.PostBSMessage({
                        clearCalib: "Failed"
                    });
                });
            } else {
                console.log("Calibrated: " + value);
                bsMessage.PostBSMessage({
                    isCalib: "Success"
                });
            }
        }).catch((err) => {
            console.log("ERROR: " + err);
            console.log("Calibration Check Failed.");
            bsMessage.PostBSMessage({
                isCalib: "Failed"
            });
        });
    }

    function diagInfHTML() {
        pointerCalib.getDiagnosticInfoHTML(true, true).then((value) => {
            console.log("Success in getting diagnostics info. Printing below.");
            console.log("Info: " + value);
            bsMessage.PostBSMessage({
                getDiagInf: "Success"
            });
        }).catch((err) => {
            console.log("ERROR: " + err);
            console.log("Failed to get diagnostics information.");
            bsMessage.PostBSMessage({
                getDiagInf: "Failed"
            });
        });
    }

    bsMessage.PostBSMessage({
        BSMessagePort: "CREATED"
    });
    setTimeout(checkPeripherals, 1000);
    setTimeout(() => {
        if (present.TouchScreen === true) {
            setTimeout(Calibrate, 4000);
            setTimeout(CheckandClear, 8000);
        } else {
            console.log("TouchScreen Not Found. Calibration Tests Skipped.");
            console.log("TouchScreen Value: " + present.TouchScreen);
            console.log("Mouse Value: " + present.Mouse);
            bsMessage.PostBSMessage({
                CalibTest: "Skipped"
            });
        }
    }, 3000);
    setTimeout(diagInfHTML, 10000);
    setTimeout(eventInfo, 11500);
    setTimeout(() => {
        console.log("Ending Test.");
        pointerCalib.stopEventLogging().then(() => {
            console.log("Stopped Event Logger.");
            bsMessage.PostBSMessage({
                stopLogger: "Success"
            });
        }).catch((err) => {
            console.log("ERROR STOPPING EVENT LOGGER: " + err);
            bsMessage.PostBSMessage({
                stopLogger: "Failed"
            });
        });
    }, 12000);
    setTimeout(() => {
        bsMessage.PostBSMessage({
            BSMessagePort: "COMPLETE"
        });
    }, 16000);
}







  • No labels