From 54ab121e89df6c204bd390432cfc662fbfd3b688 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Fri, 22 Feb 2019 16:31:53 -0500 Subject: [PATCH] Feeble first attempt at documenting code --- app/lib/arduino/Readme.md | 82 ++++++++++++++++++++++++++++++++++++++ app/lib/arduino/index.js | 37 +++++++++++++++++ app/lib/capture/Readme.md | 0 app/lib/database/Readme.md | 0 app/lib/delay/Readme.md | 0 app/lib/display/Readme.md | 0 app/lib/exit/Readme.md | 0 app/lib/ffmpeg/Readme.md | 0 app/lib/ffprobe/Readme.md | 0 app/lib/intval/Readme.md | 0 app/lib/mscript/Readme.md | 37 ++++++++++------- app/lib/server/Readme.md | 0 app/lib/settings/Readme.md | 0 app/lib/spawn/Readme.md | 0 app/lib/system/Readme.md | 0 app/lib/ui/Readme.md | 0 16 files changed, 141 insertions(+), 15 deletions(-) create mode 100644 app/lib/arduino/Readme.md create mode 100644 app/lib/capture/Readme.md create mode 100644 app/lib/database/Readme.md create mode 100644 app/lib/delay/Readme.md create mode 100644 app/lib/display/Readme.md create mode 100644 app/lib/exit/Readme.md create mode 100644 app/lib/ffmpeg/Readme.md create mode 100644 app/lib/ffprobe/Readme.md create mode 100644 app/lib/intval/Readme.md create mode 100644 app/lib/server/Readme.md create mode 100644 app/lib/settings/Readme.md create mode 100644 app/lib/spawn/Readme.md create mode 100644 app/lib/system/Readme.md create mode 100644 app/lib/ui/Readme.md diff --git a/app/lib/arduino/Readme.md b/app/lib/arduino/Readme.md new file mode 100644 index 0000000..498f041 --- /dev/null +++ b/app/lib/arduino/Readme.md @@ -0,0 +1,82 @@ +## Functions + +
+
delay(ms)Promise
+

Pause the process for X milliseconds in async/await functions

+
+
send(device, cmd)Promise
+

Send a command to an Arduino using async/await

+
+
write(device, str)Promise
+

Send a string to an Arduino using async/await

+
+
open(device)Promise
+

Connect to an Arduino using async/await

+
+
close(device)Promise
+

Close a connection to an Arduino using async/await

+
+
+ + + +## delay(ms) ⇒ Promise +Pause the process for X milliseconds in async/await functions + +**Kind**: global function +**Returns**: Promise - Resolves after wait + +| Param | Type | Description | +| --- | --- | --- | +| ms | integer | milliseconds | + + + +## send(device, cmd) ⇒ Promise +Send a command to an Arduino using async/await + +**Kind**: global function +**Returns**: Promise - Resolves after sending + +| Param | Type | Description | +| --- | --- | --- | +| device | string | Arduino identifier | +| cmd | string | Single character command to send | + + + +## write(device, str) ⇒ Promise +Send a string to an Arduino using async/await + +**Kind**: global function +**Returns**: Promise - Resolves after sending + +| Param | Type | Description | +| --- | --- | --- | +| device | string | Arduino identifier | +| str | string | String to send | + + + +## open(device) ⇒ Promise +Connect to an Arduino using async/await + +**Kind**: global function +**Returns**: Promise - Resolves after opening + +| Param | Type | Description | +| --- | --- | --- | +| device | string | Arduino identifier | + + + +## close(device) ⇒ Promise +Close a connection to an Arduino using async/await + +**Kind**: global function +**Returns**: Promise - Resolves after closing + +| Param | Type | Description | +| --- | --- | --- | +| device | string | Arduino identifier | + diff --git a/app/lib/arduino/index.js b/app/lib/arduino/index.js index b6c6a06..d2a27b3 100644 --- a/app/lib/arduino/index.js +++ b/app/lib/arduino/index.js @@ -10,12 +10,27 @@ let eventEmitter const mcopy = {} +/** + * Pause the process for X milliseconds in async/await functions + * + * @param {integer} ms milliseconds + * + * @returns {Promise} Resolves after wait + **/ async function delay (ms) { return new Promise(resolve => { return setTimeout(resolve, ms) }) } +/** + * Send a command to an Arduino using async/await + * + * @param {string} device Arduino identifier + * @param {string} cmd Single character command to send + * + * @returns {Promise} Resolves after sending + **/ async function send (device, cmd) { return new Promise ((resolve, reject) => { mcopy.arduino.queue[cmd] = (ms) => { @@ -31,6 +46,14 @@ async function send (device, cmd) { }) } +/** + * Send a string to an Arduino using async/await + * + * @param {string} device Arduino identifier + * @param {string} str String to send + * + * @returns {Promise} Resolves after sending + **/ async function write (device, str) { return new Promise ((resolve, reject) => { mcopy.arduino.serial[device].write(str, function (err, results) { @@ -43,6 +66,13 @@ async function write (device, str) { }) } +/** + * Connect to an Arduino using async/await + * + * @param {string} device Arduino identifier + * + * @returns {Promise} Resolves after opening + **/ async function open (device) { return new Promise((resolve, reject) => { return mcopy.arduino.serial[device].open(error => { @@ -54,6 +84,13 @@ async function open (device) { }) } +/** + * Close a connection to an Arduino using async/await + * + * @param {string} device Arduino identifier + * + * @returns {Promise} Resolves after closing + **/ async function close (device) { return new Promise((resolve, reject) => { return mcopy.arduino.serial[device].close((err) => { diff --git a/app/lib/capture/Readme.md b/app/lib/capture/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/app/lib/database/Readme.md b/app/lib/database/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/app/lib/delay/Readme.md b/app/lib/delay/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/app/lib/display/Readme.md b/app/lib/display/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/app/lib/exit/Readme.md b/app/lib/exit/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/app/lib/ffmpeg/Readme.md b/app/lib/ffmpeg/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/app/lib/ffprobe/Readme.md b/app/lib/ffprobe/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/app/lib/intval/Readme.md b/app/lib/intval/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/app/lib/mscript/Readme.md b/app/lib/mscript/Readme.md index cfb7fdb..3112f09 100644 --- a/app/lib/mscript/Readme.md +++ b/app/lib/mscript/Readme.md @@ -24,6 +24,7 @@ * [.light_to_arr()](#module_lib/mscript..Mscript+light_to_arr) * [.light_state()](#module_lib/mscript..Mscript+light_state) * [.fail()](#module_lib/mscript..Mscript+fail) + * [~startsWith()](#module_lib/mscript..startsWith) @@ -70,55 +71,55 @@ of steps to be fed into the mcopy. **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.basic_cmd() +#### mscript.basic\_cmd() Apply a basic two character command **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.new_loop() +#### mscript.new\_loop() Start a new loop **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.end_loop() +#### mscript.end\_loop() Close the most recent loop **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.move_cam() +#### mscript.move\_cam() Move camera to explicitly-defined frame **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.move_proj() +#### mscript.move\_proj() Move projector to explicitly-defined frame **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.set_state() +#### mscript.set\_state() Set the state of either the cam or projector **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.last_loop() +#### mscript.last\_loop() Return the last loop **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.parent_loop() +#### mscript.parent\_loop() Return the second-last loop **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.loop_count() +#### mscript.loop\_count() Extract the loop count integer from a LOOP cmd **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) @@ -130,19 +131,19 @@ Execute a fade of frame length, from color to another color **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.fade_count() +#### mscript.fade\_count() Extract the fade length integer from a FADE cmd **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.fade_start() +#### mscript.fade\_start() Extract the start color from a string **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.fade_end() +#### mscript.fade\_end() Extract the end color from a string **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) @@ -155,19 +156,19 @@ by the value defined in val **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.str_to_arr() +#### mscript.str\_to\_arr() Split string on command, extract any integers from string **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.light_to_arr() +#### mscript.light\_to\_arr() Split a string on a command to extract data for light array **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) -#### mscript.light_state() +#### mscript.light\_state() Split a string to extract an rgb color value **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) @@ -177,3 +178,9 @@ Split a string to extract an rgb color value Throw an error with specific message **Kind**: instance method of [Mscript](#module_lib/mscript..Mscript) + + +### lib/mscript~startsWith() +startswith function from lodash, do not want the entire lib for this + +**Kind**: inner method of [lib/mscript](#module_lib/mscript) diff --git a/app/lib/server/Readme.md b/app/lib/server/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/app/lib/settings/Readme.md b/app/lib/settings/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/app/lib/spawn/Readme.md b/app/lib/spawn/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/app/lib/system/Readme.md b/app/lib/system/Readme.md new file mode 100644 index 0000000..e69de29 diff --git a/app/lib/ui/Readme.md b/app/lib/ui/Readme.md new file mode 100644 index 0000000..e69de29