From 52c0c6f35298583d6b49d1eda410908c8c331b48 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Tue, 19 Sep 2017 15:20:58 -0400 Subject: [PATCH] Add default optional values to documentation --- lib/intval/Readme.md | 37 ++++++++++++++++++++++++------------- lib/intval/index.js | 40 +++++++++++++++++++++++----------------- 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/lib/intval/Readme.md b/lib/intval/Readme.md index 549eda3..e893021 100644 --- a/lib/intval/Readme.md +++ b/lib/intval/Readme.md @@ -13,7 +13,7 @@ Class representing the intval3 features * [._stop()](#Intval+_stop) * [._watchMicro(err, val)](#Intval+_watchMicro) * [._watchRelease(err, val)](#Intval+_watchRelease) - * [.frame(dir, time, delay)](#Intval+frame) + * [.frame([dir], [time], [delay])](#Intval+frame) @@ -55,8 +55,14 @@ Stop motor by setting both motor pins to 0 (LOW) ### intval._watchMicro(err, val) Intval._watchMicro() - -Callback for watching microswitch state changes -Using GPIO 06 on raspberry pi zero w +Callback for watching relese switch state changes. +Using GPIO 06 on Raspberry Pi Zero W. +* If closed, start timer. +* If opened, check timer AND + +Microswitch + 10K ohm resistor +* 1 === open +* 0 === closed **Kind**: instance method of [Intval](#Intval) @@ -69,12 +75,17 @@ Using GPIO 06 on raspberry pi zero w ### intval._watchRelease(err, val) Intval._watchRelease() - -Callback for watching relese switch state changes -Using GPIO 05 on raspberry pi zero w -* If closed, start timer. -* If opened, check timer AND -* If time closed longer than minimum and less than `this._releaseSequence`, start frame -* If time closed longer than `this._releaseSequence`, start sequence +Callback for watching relese switch state changes. +Using GPIO 05 on Raspberry Pi Zero W. + +1) If closed, start timer. +2) If opened, check timer AND +3) If `press` (`NOW - this._state.release.time`) greater than minimum and less than `this._releaseSequence`, start frame +4) If `press` greater than `this._releaseSequence`, start sequence + +Button + 10K ohm resistor +* 1 === open +* 0 === closed **Kind**: instance method of [Intval](#Intval) @@ -85,7 +96,7 @@ Using GPIO 05 on raspberry pi zero w -### intval.frame(dir, time, delay) +### intval.frame([dir], [time], [delay]) Intval.frame() - Begin a single frame with set variables or defaults @@ -93,7 +104,7 @@ Begin a single frame with set variables or defaults | Param | Type | Default | Description | | --- | --- | --- | --- | -| dir | boolean | | (optional) Direction of the frame | -| time | integer | | (optional) Exposure time, 0 = minimum | -| delay | delay | | (optional) Delay after frame before another can be started | +| [dir] | boolean | "null" | (optional) Direction of the frame | +| [time] | integer | "null" | (optional) Exposure time, 0 = minimum | +| [delay] | integer | "null" | (optional) Delay after frame before another can be started | diff --git a/lib/intval/index.js b/lib/intval/index.js index 35481b6..c3f31e0 100644 --- a/lib/intval/index.js +++ b/lib/intval/index.js @@ -118,17 +118,21 @@ class Intval { } /** * Intval._watchMicro() - - * Callback for watching microswitch state changes - * Using GPIO 06 on raspberry pi zero w + * Callback for watching relese switch state changes. + * Using GPIO 06 on Raspberry Pi Zero W. + * * If closed, start timer. + * * If opened, check timer AND + * + * Microswitch + 10K ohm resistor + * * 1 === open + * * 0 === closed + * * * @param {object} err Error object present if problem reading pin * @param {integer} val Current value of the pin * */ _watchMicro (err, val) { - /* Microswitch + 10K ohm resistor */ - /* 1 = open */ - /* 0 = closed */ if (err) { console.error(err) } @@ -137,12 +141,17 @@ class Intval { } /** * Intval._watchRelease() - - * Callback for watching relese switch state changes - * Using GPIO 05 on raspberry pi zero w - * * If closed, start timer. - * * If opened, check timer AND - * * If time closed longer than minimum and less than `this._releaseSequence`, start frame - * * If time closed longer than `this._releaseSequence`, start sequence + * Callback for watching relese switch state changes. + * Using GPIO 05 on Raspberry Pi Zero W. + * + * 1) If closed, start timer. + * 2) If opened, check timer AND + * 3) If `press` (`NOW - this._state.release.time`) greater than minimum and less than `this._releaseSequence`, start frame + * 4) If `press` greater than `this._releaseSequence`, start sequence + * + * Button + 10K ohm resistor + * * 1 === open + * * 0 === closed * * @param {object} err Error object present if problem reading pin * @param {integer} val Current value of the pin @@ -151,9 +160,6 @@ class Intval { _watchRelease (err, val) { const NOW = +new Date() let press = 0 - /* Button + 10K ohm resistor */ - /* 1 = open */ - /* 0 = closed */ if (err) { return console.error(err) } @@ -188,9 +194,9 @@ class Intval { * Intval.frame() - * Begin a single frame with set variables or defaults * - * @param {boolean} dir (optional) Direction of the frame - * @param {integer} time (optional) Exposure time, 0 = minimum - * @param {delay} delay (optional) Delay after frame before another can be started + * @param {?boolean} [dir="null"] (optional) Direction of the frame + * @param {?integer} [time="null"] (optional) Exposure time, 0 = minimum + * @param {?integer} [delay="null"] (optional) Delay after frame before another can be started * */ frame (dir = null, time = null, delay = null) { //may be overloaded, delay is suspect