Skip to content

Commit

Permalink
Update info on enabling Data Streamer (#4)
Browse files Browse the repository at this point in the history
* Update info on enabling Data Streamer

* Fix 'click here' link

* Do some edits
  • Loading branch information
ganicke authored and abchatra committed Apr 11, 2019
1 parent 685cc37 commit c08e322
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
# Hacking STEM [![Build Status](https://travis-ci.org/Microsoft/pxt-hacking-stem.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-hacking-stem)

Support for [Hacking STEM](https://www.microsoft.com/en-us/education/education-workshop/activity-library.aspx) activities in [micro:bit](https://makecode.microbit.org). For Hacking Stem activities you will need excel add-on Data Streamer as well. To download Data Streamer [click here](https://www.microsoft.com/en-us/download/details.aspx?id=56976). This extension helps build the code for emitting serial data in the format required by Data Streamer excel addon.
Support for [Hacking STEM](https://www.microsoft.com/en-us/education/education-workshop/activity-library.aspx) activities in [micro:bit](https://makecode.microbit.org). For Hacking Stem activities you will need to enable the Data Streamer Add-in in Excel. For information on enabling Data Streamer, [click here](https://aka.ms/data-streamer). This extension helps build the code to emit serial data in the format required by Data Streamer.

## Usage

Go to https://makecode.microbit.org, click on the gearwheel menu and select ``Extensions``, search for ``hacking stem`` and select this extension. Once you load the extension you should see a new category named DataStreamer. Hacking Stem extension sets the baud rate of serial output to 9600 as required by data streamer add-on in excel.
Go to https://makecode.microbit.org, click on the gearwheel menu and select ``Extensions``, search for ``hacking stem`` and select this extension. Once you load the extension you should see a new category named **DataStreamer**. THe Hacking Stem extension sets the baud rate for the serial output to 9600 as required by data streamer add-on in excel.

Following are the API reference:

## writeNumber

The ``||dataStreamer.writeNumber||`` block writes a number to the serial port as a floating point number.

```sig
dataStreamer.writeNumber(1.52, 2);
```

### Parameters

* `value` is the floating point number to write to the serial port
* `decimal digits` is the number of decimal digits to write. Default is 2.

### Example 1
For example,

A simple write number.

```blocks
dataStreamer.writeNumber(1.52);
```

writes the following number to serial
1.52
writes the number `1.52` to serial.

### Example 2
This example reads the analog signal on pin ``P0``, scales it to 3.3v and writes it to serial with 4 decimal digits precision.

This example reads the analog signal on pin ``P0``, scales it to 3.3v and writes it to serial as decimal with 4 digit precision.

```blocks
let mv = 0
Expand All @@ -41,13 +44,15 @@ basic.forever(() => {
```

## writeLine

The ``||dataStreamer.writeString||`` block writes a new line to the serial port.

```sig
dataStreamer.writeLine();
```

### Example: Writing values in a loop

This program writes a series of accererlation values to the serial port repeatedly.

```blocks
Expand All @@ -58,6 +63,7 @@ basic.forever(function () {
```

## writeString

The ``||dataStreamer.writeString||`` block writes a string to the serial port, without starting a new line afterward.

```sig
Expand All @@ -68,7 +74,8 @@ dataStreamer.writeString(",");
* `text` is the string to write to the serial port

### Example: Writing comma seperated values in a loop
This program writes a comma `,` seperated x,y,z acceleration values to the serial port repeatedly..

This program writes a comma `,` seperated x,y,z acceleration values to the serial port repeatedly.

```blocks
basic.forever(function () {
Expand All @@ -82,16 +89,19 @@ basic.forever(function () {
```

## writeNumberArray
The ``||dataStreamer.writeNumberArray||`` block writes a array of numbers to the serial port as a comma seperated values, without starting a new line afterward.

The ``||dataStreamer.writeNumberArray||`` block writes an array of numbers to the serial port as a comma seperated values, without starting a new line afterward.

```sig
dataStreamer.writeNumberArray([0,1,2]);
```

### Parameters

* `text` is the string to write to the serial port

### Example: Writing comma seperated values in a loop

This program writes a comma `,` seperated x,y,z acceleration values to the serial port repeatedly.

```blocks
Expand All @@ -106,13 +116,15 @@ basic.forever(function () {
```

## setBaudRate
The ``||dataStreamer.setBaudRate||`` sets the baud rate. Default is 9600 for datastreamer

The ``||dataStreamer.setBaudRate||`` sets the baud rate. Default is 9600 (this is the baud rate used by Excel Data Streamer).

```sig
dataStreamer.setBaudRate(9600);
```

### Parameters

* `rate` is the number for the baud rate

## License
Expand Down

0 comments on commit c08e322

Please sign in to comment.