Player APIs (BrightScript & Ja...
JavaScript APIs
pointercalibration
8min
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(); }; 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); }