Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Update WebIDL and modify documentation to fit new "node.js-like" style, Part 2 #1893

Merged
merged 30 commits into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6b7e6c6
jfjfjf
Jan 24, 2018
b2e4ff7
Reinserted WebIDL for buffer.md; changed the WebIDL in aio and ble to
Jan 28, 2018
073a9a5
Merge branch 'working'
Jan 28, 2018
3dce399
Made changes based on the first round of pull request 1800
Feb 2, 2018
5ee32ce
Merge branch 'working'
Feb 2, 2018
74d43a1
Merge branch 'master' of https://github.com/intel/zephyr.js
May 9, 2018
6e2ab61
jfjfjf
Jun 6, 2018
123533a
Modified format and fixed WebIDL
Jun 29, 2018
b5c0e2f
Merge branch 'master' of https://github.com/intel/zephyr.js
Jun 29, 2018
48ff0a8
Fixed a problem with too many newlines
Jun 29, 2018
81134a2
Merge branch 'working' into upstream/modify_docs2
Jun 29, 2018
f601baf
Modified format and fixed WebIDL
Jun 6, 2018
759a697
[net] Increase multicast addresses so neighbor solicitation will work…
grgustaf May 18, 2018
c5b0176
[debugger] Added debugger support for Zephyr
jimmy-huang Feb 1, 2018
f64722f
[build] Enable LTO to further shrink ROM size
jimmy-huang May 18, 2018
7a15158
[jerryscript] Rebase to latest JerryScript (#1883)
Jun 6, 2018
65323ee
Fixed a problem with too many newlines
Jun 29, 2018
6fe497e
Fixed some node.js-style syntax...
Jul 3, 2018
b394cec
Merge remote-tracking branch 'remotes/origin/master'
Jul 3, 2018
7a2b5ce
Merge branch 'working'
Jul 3, 2018
215bba2
Merge branch 'working'
Jul 3, 2018
a2f14e3
Simplified the External* attribute
Jul 6, 2018
c7d135e
Simplified the External* attribute
Jul 6, 2018
74841c7
Merge branch 'modify_docs2' of https://github.com/t-harvey/zephyr.js …
Jul 6, 2018
70ad3d8
Merge branch 'modify_docs2' of https://github.com/t-harvey/zephyr.js …
Jul 6, 2018
108aedc
Merge branch 'modify_docs2' of https://github.com/t-harvey/zephyr.js
Jul 6, 2018
549aeec
Fixed a few minor anoyances impeding clean compilation.
Jul 6, 2018
620b41a
Experiment to see what surrounding "details" with the "pre" looks like.
Jul 9, 2018
56d12fb
Fixed vertical whitespace to make all of the WebIDL files consistent.
Jul 10, 2018
17059cf
Merge branch 'modify_docs2' of https://github.com/t-harvey/zephyr.js …
Jul 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions docs/Notes_on_WebIDL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Notes on WebIDL for zephyr.js documentation:

The WebIDL fragments are for reference only; the description of the
API should be considered correct -- please report discrepancies as
soon as possible.

Although both WebIDL and JavaScript are aimed at web applications,
numerous incompatibilities exist between the two. In general, we try
to use basic (as opposed to "advanced") WebIDL to describe each
API; below, we list some of our conventions.

We map WebIDL definitions to JavaScript objects as follows:

1. dictionaries -- these map to JavaScript objects that simply don't
have methods attached to them.
2. interfaces -- like definitions, these correspond to JavaScript
objects, except that they may also include methods.
3. callbacks -- these are type definitions for functions used as
parameters or object fields.
4. enumerations -- these are largely the same in both languages.

Unless a constructor is explicitly defined/denied (*e.g.*, see the
note about "require", below), we assume the JavaScript model that the
object can be constructed with "new" -- WebIDL specifies that the
external attribute "constructor" be applied to a definition that can
be new'd, but putting the attribute on every object would be
cumbersome.

The node.js notion of "require" is subtly different from constructing
an object with JavaScript's "new", but it has appealing semantics. We
annotate WebIDL definitions that should be implemented with node.js's
"require" semantics with the external attribute "ReturnFromRequire".

Similarly, many people's general model is one of separate compilation,
which WebIDL does not support. WebIDL's model is to assume that all
of the required files will be concatenated together and then compiled
-- thus, one file can reference types that are found in another file,
and there is no annotation to alert the reader that the definition of
some type is to be found elsewhere. We use WebIDL attributes to
specify and call attention to types that are defined in other files.
95 changes: 47 additions & 48 deletions docs/aio.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ ZJS API for Analog I/O (AIO)

* [Introduction](#introduction)
* [Web IDL](#web-idl)
* [API Documentation](#api-documentation)
* [Class: AIO](#aio-api)
* [aio.open(AIOInit)](#aioopenaioinit)
* [Class: AIOPin](#aiopin-api)
* [pin.read()](#pinread)
* [pin.readAsync(ReadCallback)](#pinreadasyncreadcallback)
* [pin.on(eventType, ReadCallback)](#pinoneventtype-readcallback)
* [pin.close()](#pinclose)
* [Sample Apps](#sample-apps)

Introduction
Expand All @@ -23,84 +29,77 @@ not have support for this.

Web IDL
-------
This IDL provides an overview of the interface; see below for documentation of
specific API functions.

```javascript
// require returns an AIO object
// var aio = require('aio');
This IDL provides an overview of the interface; see below for
documentation of specific API functions. We have a short document
explaining [ZJS WebIDL conventions](Notes_on_WebIDL.md).

[NoInterfaceObject]
<details>
<summary>Click to show WebIDL</summary>
<pre>
// require returns an AIO object
// var aio = require('aio');<p>[ReturnFromRequire]
interface AIO {
AIOPin open(AIOInit init);
};

dictionary AIOInit {
unsigned long pin;
};

[NoInterfaceObject]
interface AIOPin {
};<p>dictionary AIOInit {
(unsigned long or string) pin;
};<p>interface AIOPin {
unsigned long read();
void readAsync(ReadCallback callback); // TODO: change to return a promise
void on(string eventType, ReadCallback callback);
void close();
};
};<p>callback ReadCallback = void (unsigned long value);
</pre> </details>

callback ReadCallback = void (unsigned long value);
```

API Documentation
-----------------
### AIO.open

`AIOPin open(AIOInit init);`
AIO API
-------
### aio.open(init)
* 'init' *AIOInit object* The AIOInit object has a single field called "pin"
that represents the name of the pin (either an integer or a string,
depending on the board).
* Returns: an AIOPin object that may be used to read values from the pin.

The `init` object lets you set the pin number. You can either use a raw
When setting the pin number, you can either use a raw
number for your device or use the board support module such as
[Arduino 101](./boards/arduino_101.md) or [K64F](./boards/frdm_k64f.md) to
specify a named pin.

Use the AIOPin object returned to read values from the pin.
AIOPin API
----------
### pin.read()
* Returns: the latest reading from the pin (an unsigned integer). Blocks until it gets the result.

### AIOPin.read
### pin.readAsync(callback)
* 'callback' *ReadCallback* User-provided callback function that takes
a single unsigned integer and has no return value.

`unsigned long read();`

Returns the latest reading from the pin. Blocks until it gets the result.

### AIOPin.readAsync

`void readAsync(ReadCallback callback);`

Pass a function for `callback` that will be called later when the result is
Pass a function for `ReadCallback` that will be called later when the result is
obtained.

*WARNING: Making an async call like this allocates some memory while the call
is pending, so if you issue them faster than they are fulfilled, you will
is pending; if async calls are issued faster than they are fulfilled,
the system will
eventually run out of memory - pretty soon on these small devices. So the best
practice would be to make sure you only have a small, fixed number pending at
practice would be to have only a small, fixed number pending at
any given time.*

*NOTE: This function will probably be replaced with a version that instead
returns a promise.*

### AIOPin.on

`void on(string eventType, ReadCallback callback);`
### pin.on(eventType, callback)
* 'eventType' *string* Type of event; currently, the only supported
type is "change".
* 'callback' *ReadCallback* User-provided callback function that takes
a single, unsigned integer and has no return value; can be null.

Currently, the only supported `eventType` is 'change', and `callback` should
be either a function or null. When a function is passed for the change event,
the function will be called any time the analog voltage changes. (At the moment,
The callback function is called any time the analog voltage changes. (At the moment,
it actually gets called periodically even when it hasn't changed.) When null is
passed for the change event, the previously registered callback will be
discarded and no longer called.

### AIOPin.close

`void close();`
### pin.close()

Closes the AIOPin. Once it is closed, all event handlers registered will no
Closes the AIOPin. Once it is closed, all registered event handlers will no
longer be called.

Sample Apps
Expand Down
Loading