From 8cfba6fefb4d7b899d52584fd0f7778e7d921691 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Mon, 28 Aug 2017 20:34:30 -0500 Subject: [PATCH] Update binary and docs --- README.md | 66 ++++++++++++++++++++++++++++++++++++++++++++-- bin/sorting_hat.js | 18 +++++++++++++ doc/README.md | 54 +++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 bin/sorting_hat.js create mode 100644 doc/README.md diff --git a/README.md b/README.md index a0aff3a..75b6b80 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,64 @@ -# sorting-hat -A sorting hat, sorts you to a variety of sets of 4 +# Sorting Hat + +A sorting hat, sorts you to a variety of sets based on the assignment of +mind waves. + +## Usage + +This package can be used as a standalone executable or as a library +inside other node applications + +### As an executable + +It can be used as a local or global installation + +#### Local Install + +``` +$ npm install sorting-hat +$ npx sorting-hat +``` + +#### Global Install + +``` +$ npm install -g sorting-hat +$ sorting-hat +``` + +#### Overriding configuration in the binary + +The binary uses environment variables to override the defaults + +* `SORTING_HAT_DEVICE_LOCATION`: The path from where we'll listen to the + mindwave, defaults to `/dev/tty.MindWaveMobile-SerialPo` +* `SORTING_HAT_MAPPING_STRATEGY`: The strategy used to sort the waves, + it defaults to `tmnt`. That is also the only supported value as of + right now +* `SORTING_HAT_PORT`: The port on which we'll start the websocket server + to send state updates to the frontends + +### As a Library + +You can include it in other libraries by requiring the file. For more +information on the public API and the used data structures, please check +`doc/README.md` + +``` +'use strict'; + +const sortingHat = new SortingHat({ + deviceLocation: '/dev/tty.MindWaveMobile-SerialPo', + mappingStrategy: 'tmnt', + port: 1987 +}); +sortingHat.start(); +``` + +At the moment it's not built right, so you can't really do much with +this mode. But you can do it. + +## Further Improvements + +* Give independent weights to each wave and category so we can balance +* Allow actual use as a library diff --git a/bin/sorting_hat.js b/bin/sorting_hat.js new file mode 100644 index 0000000..bcd1225 --- /dev/null +++ b/bin/sorting_hat.js @@ -0,0 +1,18 @@ +'use strict'; + +const Config = require('../config/config'); +const SortingHat = require('..'); + +const internals = { + + // Main entry point of the application + + run() { + + const sortingHat = new SortingHat(Config); + + sortingHat.start(); + } +}; + +internals.run(); diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 0000000..67eb065 --- /dev/null +++ b/doc/README.md @@ -0,0 +1,54 @@ +## Classes + +
+
SortingHat
+
+
+ +## Typedefs + +
+
tSortingHatConfig : object
+

The configuration used to extend the SortingHat class

+
+
+ + + +## SortingHat +**Kind**: global class + +* [SortingHat](#SortingHat) + * [new SortingHat(config)](#new_SortingHat_new) + * [.deviceLocation](#SortingHat+deviceLocation) : string + + + +### new SortingHat(config) +The main server for the sorting hat, it is in charge of connecting to the +device and emitting events for the GUI via a socket + + +| Param | Type | Description | +| --- | --- | --- | +| config | [tSortingHatConfig](#tSortingHatConfig) | the configuration to extend the object | + + + +### sortingHat.deviceLocation : string +The location of the mindwae device we'll be listening to + +**Kind**: instance property of [SortingHat](#SortingHat) +**Default**: "/dev/cu.Bluetooth-Incoming-Port" + + +## tSortingHatConfig : object +The configuration used to extend the SortingHat class + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| deviceLocation | string | the location of the mindwave device | + -- 2.45.2