rpi-io 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/esm/dev.mjs +6 -6
- package/esm/rio.mjs +12 -2
- package/history.md +5 -0
- package/package.json +1 -1
- package/scr/test.js +3 -3
package/README.md
CHANGED
|
@@ -406,7 +406,7 @@ console.log(Rio.os())
|
|
|
406
406
|
|
|
407
407
|
To check if device is supported by **rpi-io** (device, model, os, middleware). It returns *true/false* and displays details in console.
|
|
408
408
|
|
|
409
|
-
#### Rio.
|
|
409
|
+
#### Rio.logCfg(level)
|
|
410
410
|
To set the level of console used in the module:
|
|
411
411
|
|
|
412
412
|
- 0: no console
|
|
@@ -417,9 +417,9 @@ To set the level of console used in the module:
|
|
|
417
417
|
|
|
418
418
|
```javascript
|
|
419
419
|
import {Rio} from "rpi-io";
|
|
420
|
-
Rio.
|
|
420
|
+
Rio.logCfg(0)
|
|
421
421
|
Rio.isSystemSupported() // Nothing displayed in console
|
|
422
|
-
Rio.
|
|
422
|
+
Rio.logCfg(2)
|
|
423
423
|
Rio.isSystemSupported() // See console below
|
|
424
424
|
// 08:15:16.506 🔎 👍 Hardware is Raspberry Pi
|
|
425
425
|
// 08:15:16.539 🔎 👍 Raspberry Pi 5 Model B Rev 1.0 is supported
|
package/esm/dev.mjs
CHANGED
|
@@ -9,11 +9,11 @@ let debug = {
|
|
|
9
9
|
// -------------------------------------------------------------------
|
|
10
10
|
// FUNCTIONS
|
|
11
11
|
/** ------------------------------------------------------------------
|
|
12
|
-
* @function
|
|
12
|
+
* @function nowStr
|
|
13
13
|
* @description Return timestamp as formatted string
|
|
14
14
|
* @return {String}
|
|
15
15
|
*/
|
|
16
|
-
export const
|
|
16
|
+
export const nowStr = () => {
|
|
17
17
|
const date = new Date()
|
|
18
18
|
return date.toLocaleTimeString() + "." + date.getMilliseconds().toLocaleString('en', {
|
|
19
19
|
minimumIntegerDigits: 3,
|
|
@@ -29,7 +29,7 @@ export const now = () => {
|
|
|
29
29
|
*/
|
|
30
30
|
export const log = function () {
|
|
31
31
|
if (debug.log)
|
|
32
|
-
console.log.apply(console, Array.prototype.concat.apply([
|
|
32
|
+
console.log.apply(console, Array.prototype.concat.apply([nowStr(), "🔎 "], arguments))
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/** ------------------------------------------------------------------
|
|
@@ -38,15 +38,15 @@ export const log = function () {
|
|
|
38
38
|
*/
|
|
39
39
|
export const trap = function () {
|
|
40
40
|
if (debug.trap)
|
|
41
|
-
console.log.apply(console, Array.prototype.concat.apply([
|
|
41
|
+
console.log.apply(console, Array.prototype.concat.apply([nowStr(), "⚠️", "\x1b[38;2;255;80;0m", ...arguments, "\x1b[0m"]))
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/** ------------------------------------------------------------------
|
|
45
|
-
* @function
|
|
45
|
+
* @function logCfg
|
|
46
46
|
* @description Set log configuration
|
|
47
47
|
* @param {Number} level 0: no log, 1: trap only, 2: trap and log
|
|
48
48
|
*/
|
|
49
|
-
export const
|
|
49
|
+
export const logCfg = level => {
|
|
50
50
|
debug = {
|
|
51
51
|
log: false,
|
|
52
52
|
trap: false
|
package/esm/rio.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import {spawn} from "child_process";
|
|
7
7
|
import {writeFileSync, readFileSync} from "fs"
|
|
8
8
|
import {exeFile, exeShell, wait} from "./utl.mjs"
|
|
9
|
-
import {
|
|
9
|
+
import {logCfg, log, trap} from "./dev.mjs"
|
|
10
10
|
|
|
11
11
|
// -------------------------------------------------------------------
|
|
12
12
|
// CLASS RIO AND FURTHER
|
|
@@ -628,10 +628,20 @@ Rio.isSystemSupported = () => {
|
|
|
628
628
|
log("👍 Systems requirements for rpi-io are met")
|
|
629
629
|
return true
|
|
630
630
|
}
|
|
631
|
+
/** ------------------------------------------------------------------
|
|
632
|
+
* @function Rio.logCfg
|
|
633
|
+
*/
|
|
634
|
+
Rio.logCfg = logCfg
|
|
635
|
+
|
|
631
636
|
/** ------------------------------------------------------------------
|
|
632
637
|
* @function Rio.log
|
|
633
638
|
*/
|
|
634
|
-
Rio.log =
|
|
639
|
+
Rio.log = log
|
|
640
|
+
|
|
641
|
+
/** ------------------------------------------------------------------
|
|
642
|
+
* @function Rio.trap
|
|
643
|
+
*/
|
|
644
|
+
Rio.log = trap
|
|
635
645
|
// -------------------------------------------------------------------
|
|
636
646
|
// EoF
|
|
637
647
|
// -------------------------------------------------------------------
|
package/history.md
CHANGED
package/package.json
CHANGED
package/scr/test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// -------------------------------------------------------------------
|
|
2
2
|
// RPi GPIO CONTROL TEST SCRIPT
|
|
3
3
|
// -------------------------------------------------------------------
|
|
4
|
-
import {log, trap,
|
|
4
|
+
import {log, trap, nowStr} from "../esm/dev.mjs"
|
|
5
5
|
import {ctrlC} from "../esm/utl.mjs"
|
|
6
6
|
import {Rio} from "../esm/rio.mjs"
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ import {Rio} from "../esm/rio.mjs"
|
|
|
12
12
|
* @param {String} txt
|
|
13
13
|
*/
|
|
14
14
|
function info(cmd, txt) {
|
|
15
|
-
console.log(
|
|
15
|
+
console.log(nowStr(), "🔎", "\x1b[38;2;0;160;16m", cmd, "\x1b[0m", txt)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/** ------------------------------------------------------------------
|
|
@@ -35,7 +35,7 @@ function isNumber(str) {
|
|
|
35
35
|
// TOP LEVEL TEST
|
|
36
36
|
// -------------------------------------------------------------------
|
|
37
37
|
(function () {
|
|
38
|
-
Rio.
|
|
38
|
+
Rio.logCfg(2)
|
|
39
39
|
ctrlC(Rio.stopMonitoring)
|
|
40
40
|
|
|
41
41
|
if (process.argv.length < 3) {
|