Giter Club home page Giter Club logo

pxt-data-streamer's Introduction

Data Streamer

Support for Hacking STEM activities in micro:bit. For Hacking Stem activities you will need to enable the Data Streamer Add-in in Excel. For information on enabling Data Streamer, click here. 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. 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.

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

A simple write number.

dataStreamer.writeNumber(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 as decimal with 4 digit precision.

let mv = 0
basic.forever(() => {
    mv = pins.analogReadPin(AnalogPin.P0) * 3.3 / 1023
    dataStreamer.writeNumber(mv,4)
    dataStreamer.writeLine()
})

writeLine

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

dataStreamer.writeLine();

Example: Writing values in a loop

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

basic.forever(function () {
    dataStreamer.writeNumber(input.acceleration(Dimension.X))
    dataStreamer.writeLine()
})

writeString

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

dataStreamer.writeString(",");

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.

basic.forever(function () {
    dataStreamer.writeNumber(input.acceleration(Dimension.X))
    dataStreamer.writeString(",")
    dataStreamer.writeNumber(input.acceleration(Dimension.Y))
    dataStreamer.writeString(",")
    dataStreamer.writeNumber(input.acceleration(Dimension.Z))
    dataStreamer.writeLine()
})

writeNumberArray

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

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.

let acc: number[] = []
basic.forever(function () {
    acc[0] = input.acceleration(Dimension.X)
    acc[1] = input.acceleration(Dimension.Y)
    acc[2] = input.acceleration(Dimension.Z)
    dataStreamer.writeNumberArray(acc)
    dataStreamer.writeLine()
})

setBaudRate

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

dataStreamer.setBaudRate(9600);

Parameters

  • rate is the number for the baud rate

License

MIT

Supported targets

  • for PXT/microbit (The metadata above is needed for package search.)

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

pxt-data-streamer's People

Contributors

abchatra avatar ganicke avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar pelikhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pxt-data-streamer's Issues

No license file.

The repository has no MIT License file. It should be added for easier categorization and identification.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.