Compare commits

..

No commits in common. "master" and "v1" have entirely different histories.
master ... v1

1490 changed files with 26297 additions and 68470 deletions

View File

@ -1,6 +0,0 @@
BasedOnStyle: LLVM
IndentWidth: 4
UseTab: Never
ColumnLimit: 100
AllowShortFunctionsOnASingleLine: Inline
SortIncludes: false

View File

@ -1,35 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
Add screenshots to help explain your problem. You can copy paste the screenshot in the github report. The .gif screen recording is very useful as well.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

View File

@ -1,17 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

69
.github/lock.yml vendored
View File

@ -1,69 +0,0 @@
# Configuration for Lock Threads - https://github.com/dessant/lock-threads
# Number of days of inactivity before a closed issue or pull request is locked
daysUntilLock: 365
# Skip issues and pull requests created before a given timestamp. Timestamp must
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable
skipCreatedBefore: false
# Issues and pull requests with these labels will be ignored. Set to `[]` to disable
exemptLabels: []
# Label to add before locking, such as `outdated`. Set to `false` to disable
lockLabel: false
# Comment to post before locking. Set to `false` to disable
lockComment: false
# Assign `resolved` as the reason for locking. Set to `false` to disable
setLockReason: true
# Limit to only `issues` or `pulls`
# only: issues
# Optionally, specify configuration settings just for `issues` or `pulls`
# issues:
# exemptLabels:
# - help-wanted
# lockLabel: outdated
# pulls:
# daysUntilLock: 30
# Repository to extend settings from
# _extends: repo

View File

@ -1,51 +0,0 @@
name: "Code scanning - action"
on:
push:
pull_request:
schedule:
- cron: '0 19 * * 0'
jobs:
CodeQL-Build:
# CodeQL runs on ubuntu-latest and windows-latest
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: javascript
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

View File

@ -1,40 +0,0 @@
name: pxt-buildmain
on:
push:
branches:
- 'master'
- 'main'
create:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install
run: |
sudo apt-get install xvfb
sudo npm install -g pxt
npm install
- name: pxt ci
run: |
pxt ci
env:
CROWDIN_KEY: ${{ secrets.CROWDIN_KEY }}
PXT_ACCESS_TOKEN: ${{ secrets.PXT_ACCESS_TOKEN }}
PXT_RELEASE_REPO: ${{ secrets.PXT_RELEASE_REPO }}
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
CHROME_BIN: chromium-browser
DISPLAY: :99.0
CI: true

View File

@ -1,31 +0,0 @@
name: pxt-buildpr
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install
run: |
sudo apt-get install xvfb
sudo npm install -g pxt
npm install
- name: pxt ci
run: |
pxt ci
env:
CHROME_BIN: chromium-browser
DISPLAY: :99.0
CI: true

View File

@ -1,39 +0,0 @@
name: pxt-buildpush
on:
push:
# main/master has its own build that includes the crowdin key
branches-ignore:
- 'main'
- 'master'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install
run: |
sudo apt-get install xvfb
sudo npm install -g pxt
npm install
- name: pxt ci
run: |
pxt ci
env:
PXT_ACCESS_TOKEN: ${{ secrets.PXT_ACCESS_TOKEN }}
PXT_RELEASE_REPO: ${{ secrets.PXT_RELEASE_REPO }}
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
CHROME_BIN: chromium-browser
DISPLAY: :99.0
CI: true

View File

@ -1,52 +0,0 @@
name: pxt-testghpkgs
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x]
branch: [stable3.0]
steps:
- uses: actions/checkout@v2
with:
ref: ${{ matrix.branch }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install
run: |
sudo npm install -g pxt
npm install
- name: pxt buildtarget
run: pxt buildtarget
- name: cache build output
uses: actions/cache@v1
env:
cache-name: cache-testghpkgs
with:
path: temp/ghpkgs
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: pxt testghpkgs
run: pxt testghpkgs
env:
PXT_FORCE_GITHUB_PROXY: 1
PXT_ACCESS_TOKEN: ${{ secrets.PXT_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.TRAVIS_GITHUB_ACCESS_TOKEN }}
- name: upload build log
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: logs-${{ matrix.branch }}
path: temp/ghpkgs/*.txt

10
.gitignore vendored
View File

@ -15,10 +15,8 @@ clients/win10/app/bld
clients/win10/*.opendb clients/win10/*.opendb
clients/**/bin/** clients/**/bin/**
clients/**/obj/** clients/**/obj/**
electron-out clients/electron/projects
hexcache hexcache
build
crowdinstats.csv
*.user *.user
*.sw? *.sw?
@ -27,7 +25,9 @@ crowdinstats.csv
*.db *.db
*.suo *.suo
*.log *.log
.DS_Store
.idea
*.iml
.vscode/.BROWSE.VC.DB-shm .vscode/.BROWSE.VC.DB-shm
.vscode/.BROWSE.VC.DB-wal .vscode/.BROWSE.VC.DB-wal
package-lock.json
.DS_Store

16
.travis.yml Normal file
View File

@ -0,0 +1,16 @@
language: node_js
node_js:
- "5.7.0"
script:
- "node node_modules/pxt-core/built/pxt.js travis"
- "node node_modules/pxt-core/built/pxt.js testdir tests"
sudo: false
notifications:
email:
- kindscript@microsoft.com
cache:
directories:
- node_modules
- built/cache
- libs/hello/built/cache

46
.vscode/launch.json vendored
View File

@ -1,46 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/../pxt/built/pxt.js",
"stopOnEntry": false,
"args": ["serve"],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"console": "internalConsole",
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
},
{
"name": "Attach to Process",
"type": "node",
"request": "attach",
"processId": "${command.PickProcess}",
"port": 5858,
"sourceMaps": false,
"outDir": null
}
]
}

View File

@ -1,5 +1,6 @@
// Place your settings in this file to overwrite default and user settings. // Place your settings in this file to overwrite default and user settings.
{ {
"file.autoSave": "afterDelay",
"files.watcherExclude": { "files.watcherExclude": {
"**/.git/objects/**": true, "**/.git/objects/**": true,
"**/built/**": true, "**/built/**": true,

19
.vscode/tasks.json vendored
View File

@ -1,19 +1,20 @@
{ {
"version": "2.0.0", "version": "0.1.0",
// Task runner is jake // Task runner is jake
"command": "pxt", "command": "pxt",
// Need to be executed in shell / cmd
"isShellCommand": true,
"showOutput": "always",
"tasks": [ "tasks": [
{ {
"label": "serve", // TS build command is local.
"type": "shell", "taskName": "serve",
"command": "pxt", // Make this the default build command.
"args": [ "isBuildCommand": true,
"serve" // Use the redefined Typescript output problem matcher.
],
"problemMatcher": [ "problemMatcher": [
"$tsc" "$tsc"
], ]
"group": "build"
} }
] ]
} }

143
README.md
View File

@ -1,149 +1,82 @@
# calliope target for PXT # Calliope target for Microsoft MakeCode
This target is hosted at https://makecode.calliope.cc.
## Hosted editor and build
Jenkins build: https://ci2.dot.net/job/Private/job/pxt_project_teal/job/master/
### BUILD COMMENTS
pxt-calliope is a [Microsoft Programming Experience Toolkit (PXT)](https://github.com/Microsoft/pxt) target that allows you to program a [Calliope mini](https://calliope.cc/en). - build libs/core/dal.d.ts new requires some meddling, as the `#define` parser does not parse `#ifdef` and thus
has some conflicts with double defines constants
![](http://calliope.cc/content/1-ueber-mini/mini_board.png)
* [Try it live](https://makecode.calliope.cc/) ## Local server
## Issue tracking The local server allows to run the editor and the documentation from your computer.
Please add an issue if you discover an (unreported) bug. ### Setup
## Developing new extensions The following commands are a 1-time setup after synching the repo on your machine.
Authoring and testing of new extensions can be done directly from the web editor. See [our documentation](https://makecode.com/blog/github-packages) on how to get started. If you want to run the editor locally, keep reading. * See requirements for [pxt](https://github.com/Microsoft/pxt)
* [clone this repo](https://help.github.com/articles/cloning-a-repository/) to your computer and go in the project folder
## Local server setup
The local server lets you to run the editor and serve the documentation from your own computer. It is meant for a single developer used and not designed to serve the editor to a large amount of users.
1. Install [Node.js](https://nodejs.org/) 8.9.4 or higher.
2. Clone this repository.
``` ```
git clone https://github.com/microsoft/pxt-calliope git clone https://github.com/microsoft/pxt-calliope
cd pxt-calliope cd pxt-calliope
``` ```
3. Install the PXT command line (add `sudo` for Mac/Linux shells). * install the PXT command line (add ``sudo`` for Mac/Linux shells).
``` ```
npm install -g pxt npm install -g pxt
``` ```
4. Install the pxt-calliope dependencies. * install the dependencies
``` ```
npm install npm install
``` ```
Go to the **Running** section.
### Developer Setup
This is the typical setup used by the MakeCode team to work on the microbit.
1. Install [Node.js](https://nodejs.org/) 8.9.4 or higher.
2. Install [Docker](https://www.docker.com/get-started) if you plan to build ``.cpp`` files.
3. Clone the pxt repository.
```
git clone https://github.com/microsoft/pxt
cd pxt
```
4. Install the dependencies of pxt and build it
```
npm install
npm run build
cd ..
```
5. Clone the pxt-common-packages repository
```
git clone https://github.com/microsoft/pxt-common-packages
cd pxt-common-packages
npm install
cd ..
```
6. Clone this repository.
```
git clone https://github.com/microsoft/pxt-calliope
cd pxt-calliope
```
7. Install the PXT command line (add `sudo` for Mac/Linux shells).
```
npm install -g pxt
```
8. Install the pxt-calliope dependencies.
```
npm install
```
8. Link pxt-calliope back to base pxt repo (add `sudo` for Mac/Linux shells).
This step is only required if you intend to make changes to pxt and/or
pxt-common-packages repos. If all you want is serve a local Makecode, you can skip
this step.
```
pxt link ../pxt
pxt link ../pxt-common-packages
```
Note the above command assumes the folder structure of
```
makecode
|
----------------------------------
| | |
pxt pxt-common-packages pxt-calliope
```
### Running ### Running
Run this command from inside pxt-calliope to open a local web server Run this command to open a local web server (add ``sudo`` for Mac/Linux shells).
``` ```
pxt serve pxt serve
``` ```
If the local server opens in the wrong browser, make sure to copy the URL containing the local token. If the local server opens in the wrong browser, make sure to copy the URL containing the local token.
Otherwise, the editor will not be able to load the projects. Otherwise, the editor will not be able to load the projects.
If you need to modify the `.cpp` files (and have installed yotta), enable yotta compilation using the `--localbuild` flag: If you need modify the `.cpp` files, turn on yotta compilation with the ``-yt`` flag (add ``sudo`` for Mac/Linux shells). On Windows, you must be running
from the ``Run Yotta`` command prompt.
``` ```
pxt serve --local pxt serve -yt
``` ```
If you want to speed up the build, you can use the ``rebundle`` option, which skips building and simply refreshes the target information ## Updates
To update your PXT version and make sure you're running the latest tools, run (add ``sudo`` for Mac/Linux shells)
``` ```
pxt serve --rebundle pxt update
``` ```
### Cleaning More instructions at https://github.com/Microsoft/pxt#running-a-target-from-localhost
Sometimes, your built folder might be in a bad state, clean it and try again. ## Testing
```
pxt clean
```
### Updates The build automatically runs the following:
Make sure to pull changes from all repos regularly. More instructions are at https://github.com/Microsoft/pxt#running-a-target-from-localhost * make sure the built-in packages compile
* `pxt run` in `libs/lang-test*` - this will run the test in command line runner;
there is a number of asserts in both of these
* `pxt testdir` in `tests` - this makes sure all the files compile and generates .hex files
## Update playlists in markdown To test something on the device:
Get a Google API key and store it in the ``GOOGLE_API_KEY`` environment variables (turn on data from the app). * do a `pxt deploy` in `libs/lang-test*` - they should show `1` or `2` on the screen (and not unhappy face)
* run `pxt testdir` in `tests` and deploy some of the hex files from `tests/built`
``` The `lang-test0` source comes from the `pxt-core` package. It's also tested with `pxt run` there.
pxt downloadplaylists
```
## Repos
The pxt-calliope target depends on several other repos. The main ones are:
- https://github.com/Microsoft/pxt, the PXT framework
- https://github.com/Microsoft/pxt-common-packages, common APIs accross various MakeCode editors
- https://github.com/lancaster-university/microbit, basic wrapper around the DAL
- https://github.com/lancaster-university/microbit-dal
## History
See the [MakeCode blog](https://makecode.com/blog).
## Code of Conduct ## Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
## Trademarks
MICROSOFT, the Microsoft Logo, and MAKECODE are registered trademarks of Microsoft Corporation. They can only be used for the purposes described in and in accordance with Microsofts Trademark and Brand guidelines published at https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general.aspx. If the use is not covered in Microsofts published guidelines or you are not sure, please consult your legal counsel or MakeCode team (makecode@microsoft.com).

View File

@ -1,41 +0,0 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.7 BLOCK -->
## Security
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
## Reporting Security Issues
**Please do not report security vulnerabilities through public GitHub issues.**
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly.
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
## Preferred Languages
We prefer all communications to be in English.
## Policy
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
<!-- END MICROSOFT SECURITY.MD BLOCK -->

View File

@ -1,229 +0,0 @@
/*!----------------- PXT ThirdPartyNotices -------------------------------------------------------
PXT uses third party material from the projects listed below.
The original copyright notice and the license under which Microsoft
received such third party material are set forth below. Microsoft
reserves all other rights not expressly granted, whether by
implication, estoppel or otherwise.
In the event that we accidentally failed to list a required notice, please
bring it to our attention. Post an issue or email us:
abchatra@microsoft.com
---------------------------------------------
Third Party Code Components
---------------------------------------------
Some code derived (as noted) from
https://github.com/bbcmicrobit/micropython
The MIT License (MIT)
Copyright (c) 2013-2016 The MicroPython-on-micro:bit Developers, as listed
in the accompanying AUTHORS file
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
----------------- google/blockly -------------------
Sounds under sim/public/blockly/media from Google Blockly.
Copyright 2013 Google Inc
Apache License
Version 2.0, January 2011
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
---------------------------------------------

26
clients/chrome/README.md Normal file
View File

@ -0,0 +1,26 @@
# microbit-chrome
Prototype chrome addon that exposes the micro:bit's serial output to webpages.
* watch the [demo video](https://vimeo.com/146207766)
# Installation
See [developer.chrome.com](https://developer.chrome.com/extensions/getstarted#unpacked)
for instructions on how to install the local version into your chrome browser.
# Requirements
* Chrome 48 or later.
# Sample page
The `demo.html` webpage goes along with the
https://github.com/Microsoft/microbit-touchdevelop/blob/master/examples/tcs34725.cpp
program. Run `http-server` from this directory, then visit
http://localhost:8080/demo.html
(keep in mind that pages served from `file://` cannot open ports).
# Building
Open a command prompt and run the following commands.
````
npm install
typings update
````

View File

@ -0,0 +1,67 @@
var connections = [];
// A list of "ports", i.e. connected clients (such as web pages). Multiple web
// pages can connect to our service: they all receive the same data.
var ports = [];
function byPath(path) {
return connections.filter(function (x) { return x.path == path; });
}
function byId(id) {
return connections.filter(function (x) { return x.id == id; });
}
function onReceive(data, id) {
if (ports.length == 0)
return;
var view = new DataView(data);
var decoder = new TextDecoder("utf-8");
var decodedString = decoder.decode(view);
ports.forEach(function (port) { return port.postMessage({
type: "serial",
data: decodedString,
id: id
}); });
}
function findNewDevices() {
chrome.serial.getDevices(function (serialPorts) {
serialPorts.forEach(function (serialPort) {
if (byPath(serialPort.path).length == 0 &&
serialPort.displayName == "mbed Serial Port") {
chrome.serial.connect(serialPort.path, { bitrate: 115200 }, function (info) {
// In case the [connect] operation takes more than five seconds...
if (info && byPath(serialPort.path).length == 0)
connections.push({
id: info.connectionId,
path: serialPort.path
});
});
}
});
});
}
function main() {
// Register new clients in the [ports] global variable.
chrome.runtime.onConnectExternal.addListener(function (port) {
if (/^(micro:bit|touchdevelop|yelm|pxt|codemicrobit|codethemicrobit|pxt.microbit.org)$/.test(port.name)) {
ports.push(port);
port.onDisconnect.addListener(function () {
ports = ports.filter(function (x) { return x != port; });
});
}
});
// When receiving data for one of the connections that we're tracking, forward
// it to all connected clients.
chrome.serial.onReceive.addListener(function (info) {
if (byId(info.connectionId).length > 0)
onReceive(info.data, info.connectionId);
});
// When it looks like we've been disconnected, drop the corresponding
// connection object from the [connections] global variable.
chrome.serial.onReceiveError.addListener(function (info) {
if (info.error == "system_error" || info.error == "disconnected" || info.error == "device_lost")
connections = connections.filter(function (x) { return x.id != info.connectionId; });
});
// Probe serial connections at regular intervals. In case we find an mbed port
// we haven't yet connected to, connect to it.
setInterval(findNewDevices, 5000);
findNewDevices();
}
document.addEventListener("DOMContentLoaded", main);

View File

@ -0,0 +1,92 @@
// A list of: {
// id: number;
// path: string;
// } where [id] is the [connectionId] (internal to Chrome) and [path] is the
// OS' name for the device (e.g. "COM4").
interface Connection {
id: string;
path: string;
}
let connections: Connection[] = [];
// A list of "ports", i.e. connected clients (such as web pages). Multiple web
// pages can connect to our service: they all receive the same data.
let ports = [];
interface Message {
type: string;
data: string;
id: string;
}
function byPath(path: string): Connection[] {
return connections.filter((x) => x.path == path);
}
function byId(id: string): Connection[] {
return connections.filter((x) => x.id == id);
}
function onReceive(data, id: string) {
if (ports.length == 0) return;
let view = new DataView(data);
let decoder = new TextDecoder("utf-8");
let decodedString = decoder.decode(view);
ports.forEach(port => port.postMessage(<Message>{
type: "serial",
data: decodedString,
id: id,
}));
}
function findNewDevices() {
chrome.serial.getDevices(function (serialPorts) {
serialPorts.forEach(function (serialPort) {
if (byPath(serialPort.path).length == 0 &&
serialPort.displayName == "mbed Serial Port") {
chrome.serial.connect(serialPort.path, { bitrate: 115200 }, function (info) {
// In case the [connect] operation takes more than five seconds...
if (info && byPath(serialPort.path).length == 0)
connections.push({
id: info.connectionId,
path: serialPort.path
});
});
}
});
});
}
function main() {
// Register new clients in the [ports] global variable.
chrome.runtime.onConnectExternal.addListener(function (port) {
if (/^(micro:bit|touchdevelop|yelm|pxt|codemicrobit|codethemicrobit|pxt.microbit.org)$/.test(port.name)) {
ports.push(port);
port.onDisconnect.addListener(function () {
ports = ports.filter(function (x) { return x != port });
});
}
});
// When receiving data for one of the connections that we're tracking, forward
// it to all connected clients.
chrome.serial.onReceive.addListener(function (info) {
if (byId(info.connectionId).length > 0)
onReceive(info.data, info.connectionId);
});
// When it looks like we've been disconnected, drop the corresponding
// connection object from the [connections] global variable.
chrome.serial.onReceiveError.addListener(function (info) {
if (info.error == "system_error" || info.error == "disconnected" || info.error == "device_lost")
connections = connections.filter((x) => x.id != info.connectionId);
});
// Probe serial connections at regular intervals. In case we find an mbed port
// we haven't yet connected to, connect to it.
setInterval(findNewDevices, 5000);
findNewDevices();
}
document.addEventListener("DOMContentLoaded", main);

BIN
clients/chrome/logo128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
clients/chrome/logo48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,30 @@
{
"app": {
"background": {
"scripts": [ "background.js" ]
}
},
"manifest_version": 2,
"name": "pxt.microbit.org",
"version": "0.7.0",
"author": "Microsoft Corporation",
"short_name": "pxt.microbit.org",
"description": "Extension for https://pxt.microbit.org.",
"homepage_url": "https://pxt.microbit.org",
"offline_enabled": "true",
"icons": {
"48": "logo48.png",
"128": "logo128.png"
},
"permissions": [
"serial",
"usb"
],
"externally_connectable": {
"matches": [ "*://localhost/*", "https://pxt.microbit.org/*", "https://*.microbit.org/*" ]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

View File

@ -0,0 +1,7 @@
{
"compiler-options": {
"target": "ES5",
"module": "amd",
"sourceMap": false
}
}

2
clients/electron/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules
projects

View File

@ -0,0 +1,5 @@
# PXT micro:bit Electron app
A very basic wrapper around the web app. To install, copy the contents of this
directory to somewhere outside the main `pxt-microbit` repository. Then run `npm
install && npm start`.

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>code the micro:bit</title>
</head>
<body>
<webview id="webview" style="position:absolute; left:0; top:0; right:0; bottom:0"/>
<script>
const webview = document.getElementById("webview")
const url = `http://localhost:3232/${window.location.hash}`
webview.src = url
</script>
</body>
</html>

39
clients/electron/main.js Normal file
View File

@ -0,0 +1,39 @@
const {app, BrowserWindow, Menu} = require('electron')
const pxt = require('pxt-core')
const path = require('path')
let win
const cliPath = path.join(process.cwd(), "node_modules/pxt-microbit")
function startServerAndCreateWindow() {
pxt.mainCli(cliPath, ["serve", "-no-browser"])
createWindow()
}
function createWindow () {
win = new BrowserWindow({
width: 800,
height: 600,
title: "code the micro:bit"
})
Menu.setApplicationMenu(null)
win.loadURL(`file://${__dirname}/index.html#local_token=${pxt.globalConfig.localToken}`)
win.on('closed', () => {
win = null
})
}
app.on('ready', startServerAndCreateWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})

View File

@ -0,0 +1,14 @@
{
"name" : "code-the-microbit",
"version" : "1.0.0",
"description": "Blocks / Javascript editor",
"author": "Microsoft",
"main" : "main.js",
"scripts": {
"start": "node_modules/.bin/electron ."
},
"devDependencies": {
"electron": "*",
"pxt-microbit": "*"
}
}

View File

@ -124,7 +124,7 @@
} }
- (void)launchEditor:(id)sender { - (void)launchEditor:(id)sender {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://makecode.microbit.org/"]]; [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://pxt.microbit.org/"]];
} }
@end @end

View File

@ -1,12 +1,12 @@
# @boardname@ uploader for OS X # micro:bit uploader for OS X
![](Microbit Uploader/Assets.xcassets/AppIcon.appiconset/icon_256x256.png) ![](Microbit Uploader/Assets.xcassets/AppIcon.appiconset/icon_256x256.png)
This project is a clone of the [Windows This project is a clone of the [Windows
uploader](https://makecode.microbit.org/uploader), but for OS X. Once launched, uploader](https://pxt.microbit.org/uploader), but for OS X. Once launched,
the app runs in your menu bar and will automatically deploy any HEX files to the app runs in your menu bar and will automatically deploy any HEX files to
your `@boardname@`. Like the Windows version, it is compatible with any browser your `micro:bit`. Like the Windows version, it is compatible with any browser
that can run @homeurl@. that can run [pxt.microbit.org](http://pxt.microbit.org).
## Install the built version ## Install the built version

View File

@ -32,7 +32,7 @@ namespace Microsoft.MicroBit
private void openEditor() private void openEditor()
{ {
// lanch editor // lanch editor
try { Process.Start("https://makecode.microbit.org#uploader"); } catch (Exception) { } try { Process.Start("https://pxt.microbit.org#uploader"); } catch (Exception) { }
} }
private void initializeFileWatch() private void initializeFileWatch()
@ -236,7 +236,7 @@ namespace Microsoft.MicroBit
{ {
try try
{ {
Process.Start("https://makecode.microbit.org/uploader"); Process.Start("https://pxt.microbit.org/uploader");
} }
catch (IOException) { } catch (IOException) { }
} }

View File

@ -1,131 +0,0 @@
/// <reference path="../node_modules/pxt-core/built/pxtcompiler.d.ts"/>
namespace ts.pxtc.extension {
pxtc.compilerHooks.postBinary = (program: ts.Program, opts: CompileOptions, res: CompileResult) => {
if (!opts.target.isNative)
return
const mbdal = res.outfiles["mbdal-binary.hex"]
const mbcodal = res.outfiles["mbcodal-binary.hex"]
if (!mbdal || !mbcodal)
return
let outp = ""
wrapHex(mbdal, 0x00, [0x99, 0x01, 0xc0, 0xde])
wrapHex(mbcodal, 0x0D, [0x99, 0x03, 0xc0, 0xde], true)
outp += ":00000001FF\n"
res.outfiles["binary.hex"] = outp
function hex2str(bytes: number[]) {
return ts.pxtc.hexfile.hexBytes([bytes.length - 3].concat(bytes)) + "\n"
}
function paddingString(len: number) {
let r = ""
const len0 = len
while (len >= 44) {
r += hex2str([0x00, 0x00, 0x0C,
0x42, 0x42, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42])
len -= 44
}
if (len >= 12) {
const numBytes = (len - 11) >> 1
const bytes = [0x00, 0x00, 0x0C]
for (let i = 0; i < numBytes; ++i) bytes.push(0x42)
const add = hex2str(bytes)
r += add
len -= add.length
}
while (len--)
r += "\n"
U.assert(r.length == len0)
return r
}
function addBlock(blk: string) {
const leftoff = blk.length & 511
outp += blk + paddingString(512 - leftoff)
}
function wrapHex(inpHex: string, dataType: number, deviceType: number[], keepSrc = false) {
let blk =
hex2str([0x00, 0x00, 0x04, 0x00, 0x00])
+ hex2str([0x00, 0x00, 0x0A].concat(deviceType))
let upperAddr = 0
const lines = inpHex.split(/\r?\n/)
for (let i = 0; i < lines.length; ++i) {
const line = lines[i]
if (!line)
continue
const parsed = ts.pxtc.hexfile.parseHexRecord(line)
switch (parsed.type) {
case 0x00:
/*
const parsed2 = parsed.len <= 16 && lines[i + 1] ?
ts.pxtc.hexfile.parseHexRecord(lines[i + 1])
: null
// if this and next line can fit in 32 bytes, concat them
if (parsed2 && parsed2.type == 0x00 &&
parsed2.addr == parsed.addr + parsed.len &&
parsed.len + parsed2.len <= 32) {
parsed.data = parsed.data.concat(parsed2.data)
parsed.len += parsed2.len
i++
}
*/
addData([parsed.addr >> 8, parsed.addr & 0xff, dataType]
.concat(parsed.data))
break
case 0x01:
flush()
if (keepSrc) break
else return
case 0x04:
const newUpper = ((parsed.data[0] << 8) | parsed.data[1]) << 16
if (upperAddr != newUpper) {
upperAddr = newUpper
addData([0, 0, 0x04, parsed.data[0], parsed.data[1]])
}
break
case 0x03:
case 0x05:
// ignore
break
case 0x0E:
// src record
addData([parsed.addr >> 8, parsed.addr & 0xff, 0x0E]
.concat(parsed.data))
break
default:
U.oops(`unknown hex record type: ${line}`)
break
}
}
flush()
function addData(bytes: number[]) {
const newData = hex2str(bytes)
blk += newData
}
function flush() {
if (blk)
addBlock(blk)
blk = ""
}
}
}
}

View File

@ -1,23 +0,0 @@
{
"compilerOptions": {
"target": "es2017",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"declaration": true,
"moduleResolution": "node",
"isolatedModules": false,
"out": "../built/compiler.js",
"rootDir": ".",
"newLine": "LF",
"sourceMap": false,
"typeRoots": ["../node_modules/@types"],
"lib": [
"dom",
"dom.iterable",
"scripthost",
"es2017",
"ES2018.Promise"
]
}
}

View File

@ -1,29 +0,0 @@
<meta name="msvalidate.01" content="C458ADC671C51F222A0F655F66596649" />
<meta property="og:title" content="Microsoft MakeCode" />
<meta property="og:site_name" content="Microsoft MakeCode" />
<meta property="og:url" content="https://www.makecode.com">
<meta property="og:type" content="website" />
<meta property="og:description" content="Microsoft MakeCode is a free, open-source Block and JavaScript learn-to-code editor that promotes a more inclusive approach to computing education." />
<meta property="og:image" content="/static/logo/logo-card.png">
<meta property="fb:app_id" content=""/>
<meta name="msapplication-config" content="/static/logo/favicons/browserconfig.xml">
<meta name="msapplication-TileImage" content="/static/logo/favicons/mstile-310x310.png">
<meta name="msapplication-TileColor" content="#b4009e">
<meta name="application-name" content="MakeCode">
<link rel="shortcut icon" sizes="16x16 24x24 32x32 48x48" href="/static/logo/favicons/favicon.ico">
<link rel="icon" type="image/png" sizes="32x32" href="/static/logo/favicons/favicon-32x32.png">
<link rel="apple-touch-icon" sizes="180x180" href="/static/logo/favicons/apple-touch-icon.png">
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Microsoft MakeCode">
<meta name="twitter:description" content="Microsoft MakeCode is a free, open-source Block and JavaScript learn-to-code editor that promotes a more inclusive approach to computing education.">
<meta name="twitter:site" content="@MSMakeCode">
<meta name="twitter:creator" content="@MSMakeCode">
<meta name="twitter:image" content="/static/logo/logo-card.png"/>
<link rel="stylesheet" href="/doccdn/semantic.css" />
<link rel="stylesheet" href="/docfiles/index.css" />
<script src="/doccdn/jquery.js"></script>
<script src="/static/semantic/semantic.min.js"></script>
<script src="/docfiles/index.js"></script>

View File

@ -1,2 +0,0 @@
Micro:bit and micro:bit logo are trademarks and/ or copyrights of the Micro:bit
Educational Foundation. &copy; Micro:bit Educational Foundation. All rights reserved.

View File

@ -1,103 +1,5 @@
![](/static/mb/device/calliope_website.jpg) ![](/static/mb/device/pano.jpg)
# About # About
## @description A Blocks / Javascript code editor for the Calliope mini, a pocket-size computer with 5x5 display, sensors and Bluetooth. Read more at https://calliope.cc .
The [Calliope mini](https://calliope.cc) is a [pocket-size computer]([/device](https://calliope.cc/en/calliope-mini/tech-facts)) with a 5x5 display of 25 LEDs, Bluetooth and sensors that can be programmed by anyone.
The Calliope mini provides an easy and fun introduction to programming and making ??? switch on, program it to do something fun ??? wear it, customize it.
Just like Arduino, the Calliope mini can additionally be connected to and interact with sensors, displays, and other devices.
* [Read the docs](/docs)
## [Hardware: The Device](/device)
The Calliope mini is packaged with sensors, radio and other goodies. Learn about the [hardware components]([/device](https://calliope.cc/en/calliope-mini/tech-facts)) of the Calliope mini to make the most of it!
## ~ hint
**Looking to buy a Calliope mini?** See the [list of resellers](https://calliope.cc/en/shops).
## ~
## Programming: [Blocks](/blocks) or [JavaScript](/javascript)
You can program the Calliope mini using [Blocks](/blocks) or [JavaScript](/javascript) in your web browser via the [Calliope mini APIs](/reference):
```block
input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => {
basic.showString("Hi!");
})
```
```typescript
input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => {
basic.showString("Hi!");
})
```
The editor work in [most modern browsers](/browsers), work [offline](/offline) once loaded and do not require any installation.
## [Compile and Flash: Your Program!](/device/usb)
When you have your code ready, you connect your Calliope mini to a computer via a USB cable, so it appears as a mounted drive (named MINI). If you are using the Calliope mini REV2 you also see another drive (FLASH) that handels up to 25 additional programs.
Compilation to ARM thumb machine code from [Blocks](/blocks) or [JavaScript](/javascript) happens in the browser. You save the ARM binary
program to a file, which you then copy to the micro:bit drive, which flashes the micro:bit device with the new program.
## Simulator: Test Your Code
You can run your code using the micro:bit simulator, all within the confines of a web browser.
The simulator has support for the LED screen, buttons, as well as compass, accelerometer, and digital I/O pins.
```sim
basic.forever(() => {
basic.showString("Hi!");
})
input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => {
led.stopAnimation();
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .`);
});
input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Down), () => {
led.stopAnimation();
basic.showLeds(`
. # . # .
# . # . #
# . . . #
. # . # .
. . # . .`);
});
```
## Learn!
We have tons of [projects](/projects), [examples](/examples) and [courses](/courses) to get your started!
## C++ Runtime
The [C++ micro:bit runtime](http://lancaster-university.github.io/microbit-docs/), created at [Lancaster University](http://www.lancaster.ac.uk/), provides access to the hardware functions of the micro:bit,
as well as a set of helper functions (such as displaying a number/image/string on the LED screen).
The [micro:bit library](/reference) mirrors the functions of the C++ library.
When code is compiled to ARM machine code, the calls to JavaScript micro:bit functions are replaced with calls to the corresponding C++ functions.
## [Command Line Tools](/cli)
Looking to use @homeurl@ in your favorite editor? Install the [command line tools](/cli) and get rolling!
## [Extensions](/extensions)
Create, edit and distribute your own blocks and JavaScript using [extensions](/extensions). Extensions are hosted on GitHub and may be written using C++, JavaScript and/or ARM thumb.
## [Open Source](/open-source)
The code for the Calliope mini is [open source](/open-source) on GitHub. Contributors are welcome!
```package
radio
```

14
docs/blocks.md Normal file
View File

@ -0,0 +1,14 @@
# Blocks language
### @description Langugage constructs for the Block editor.
```namespaces
for (let i = 0;i<5;++i) {}
if (true){}
let x = 0;
Math.random(5);
```
## See Also
[logic](/blocks/logic), [loops](/blocks/loops), [math](/blocks/math), [variables](/blocks/variables)

9
docs/blocks/logic.md Normal file
View File

@ -0,0 +1,9 @@
# Logic
```cards
if(true) {}
true;
true && false;
!true;
1 != 0;
```

View File

@ -1,8 +1,77 @@
# @extends # Boolean
## #examples true or false.
## Example: ``AND`` operator A Boolean has one of two possible values: `true`; `false`. Boolean (logical) operators (*and*, *or*, *not*) take Boolean inputs and yields a Boolean value. Comparison operators on other types ([numbers](/reference/types/number), [strings](/reference/types/string) yields a Boolean value.
The following blocks represent the true and false Boolean values, which can be plugged in anywhere a Boolean value is expected:
```blocks
true;
false;
```
The next three blocks represent the three Boolean (logic) operators:
```blocks
true && false;
true || false;
!true;
```
The next six blocks represent comparison operators that yield a Boolean value. Most comparisons you will do involve [numbers](/reference/types/number):
```blocks
42 == 0;
42 != 0;
42 < 0;
42 > 0;
42 <= 0;
42 >= 0;
```
Boolean values and operators are often used with an [if](/blocks/logic/if) or [while](/blocks/loops/while) statement to determine which code will execute next. For example:
### Functions that return a Boolean
Some functions return a Boolean value, which you can store in a Boolean variable. For example, the following code gets the on/off state of `point (1, 2)` and stores this in the Boolean variable named `on`. Then the code clears the screen if `on` is `true`:
### Boolean operators
Boolean operators take Boolean inputs and evaluate to a Boolean output:
### Conjunction: `A and B`
`A and B` evaluates to `true` if-and-only-if both A and B are true:
```blocks
false && false == false;
false && true == false;
true && false == false;
true && true == true;
```
### Disjunction: `A or B`
`A or B` evaluates to `true` if-and-only-if either A is true or B is true:
```blocks
false || false == false;
false || true == true;
true || false == true;
true || true == true;
```
### Negation: `not A`
`not A` evaluates to the opposite (negation) of A:
```blocks
!false == true;
!true == false;
```
### Example
This example turns on LED `3 , 3`, if LEDs `1 , 1` and `2 , 2` are both on: This example turns on LED `3 , 3`, if LEDs `1 , 1` and `2 , 2` are both on:
@ -12,19 +81,22 @@ if (led.point(1,1) && led.point(2,2)) {
} }
``` ```
## Example: Comparisons of numbers and strings ### Comparisons of numbers and strings
When you compare two Numbers, you get a Boolean value, such as the comparison `x < 5` in the code below: When you compare two Numbers, you get a Boolean value, such as the comparison `x < 5` in the code below:
```blocks ```blocks
input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { let x = Math.random(5)
let x = randint(0, 5) if(x < 5) {
if(x < 5) { basic.showString("low");
basic.showString("low"); } else {
} else { basic.showString("high");
basic.showString("high"); }
}
})
``` ```
See the documentation on [Numbers](/types/number) for more information on comparing two Numbers. See the documentation on [Numbers](/reference/types/number) for more information on comparing two Numbers. You can also [compare strings](/reference/types/string-functions) using the `equals` function.
### See also
[if](/blocks/logic/if), [while](/blocks/loops/while), [number](/reference/types/number)

View File

@ -1,15 +1,28 @@
# @extends # If
## #examples ### @parent blocks/language
## Example: adjusting screen brightness
If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255` when the button A is pressed: Conditionally run code depending on whether a [Boolean](/blocks/logic/boolean) condition is true or false.
```blocks ```blocks
input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { if(true) {
if(input.lightLevel()<100){ }
led.setBrightness(255);
}
})
``` ```
Click on the dark blue gear icon (see above) to add an *else* or *if* to the current block.
### Example: adjusting screen brightness
```blocks
if(input.lightLevel()<100){
led.setBrightness(255);
}
```
If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255`:
### See also
[while loop](/blocks/loops/while), [for](/blocks/loops/for), [boolean](/blocks/logic/boolean)

View File

@ -1,3 +1,7 @@
# @extends # Loops
## #specific ```cards
for(let i = 0;i<5;i++) {}
while(true) {}
basic.forever(() => {});
```

View File

@ -1,20 +0,0 @@
# @extends
## #examples
## Example: Find the highest number
Find the highest number in a list of numbers. Display the highest number on the screen.
```blocks
let list: number[] = []
let highest = 0
highest = 0
list = [5, 8, 6, 2, 4, 3, 7, 1]
for (let value of list) {
if (value > highest) {
highest = value
}
}
basic.showNumber(highest)
```

View File

@ -1,15 +1,20 @@
# @extends # For
## #examples ### @parent blocks/language
## Example: Count to 4 Run part of the program the number of times you say.
### Example: Count to 4
This program will show the numbers 0, 1, 2, 3, and 4 one after another on the LED screen. This program will show the numbers 0, 1, 2, 3, and 4 one after another on the LED screen.
```blocks ```blocks
input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { for(let i = 0; i < 5; ++i) {
for(let i = 0; i < 5; ++i) { basic.showNumber(i)
basic.showNumber(i) }
}
})
``` ```
### See also
[repeat](/blocks/loops/repeat), [while](/blocks/loops/while), [if](/blocks/logic/if), [show number](/reference/basic/show-number)

View File

@ -1,16 +1,12 @@
# @extends # Repeat
## #examples Run part of the program the number of times you say.
## Example: Blinking heart ### Block Editor
Flash the ``heart`` icon on the screen `4` times. ![](/static/mb/blocks/contents-0.png)
### See also
[for](/blocks/loops/for), [while](/blocks/loops/while), [if](/blocks/logic/if), [show number](/reference/basic/show-number)
```blocks
for (let i = 0; i < 4; i++) {
basic.showIcon(IconNames.Heart)
basic.pause(300)
basic.clearScreen()
basic.pause(300)
}
```

View File

@ -1,17 +1,29 @@
# @extends # While
## #examples Repeat code while a [Boolean](/blocks/logic/boolean) `condition` is true.
## Example: diagonal line ```blocks
while(true) {
}
```
The while loop has a *condition* that evaluates to a [Boolean](/blocks/logic/boolean) value. After the `do` keyword, add the code that you want to run while the `condition` is `true`. The while loop concludes with `end while`.
The condition is tested before any code runs. Which means that if the condition is false, the code inside the loop doesn't execute.
### Example: diagonal line
The following example uses a while loop to make a diagonal line on the LED screen (points `0, 0`, `1, 1`, `2, 2`, `3, 3`, `4, 4`). The following example uses a while loop to make a diagonal line on the LED screen (points `0, 0`, `1, 1`, `2, 2`, `3, 3`, `4, 4`).
```blocks ```blocks
input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { let index = 4;
let index = 4; while(index >= 0) {
while(index >= 0) { led.plot(index, index);
led.plot(index, index); index--;
index--; }
}
})
``` ```
### See also
[on button pressed](/reference/input/on-button-pressed), [for](/blocks/loops/for), [if](/blocks/logic/if), [forever](/reference/basic/forever)

36
docs/blocks/math.md Normal file
View File

@ -0,0 +1,36 @@
# Math
### [Numeric](/reference/types/number) values: 0, 1, 2, ...
```block
0;
1;
2;
```
### Arithmetic binary operation (+, -, *, /)
```block
0+1;
0-1;
1*2;
3/4;
```
### Absolute value
```block
Math.abs(-5);
```
### Minimum/maximum of two values
```block
Math.min(0, 1);
```
### Random value
```block
Math.random(5);
```

View File

@ -1,29 +0,0 @@
# random Boolean
Returns a pseudo-random boolean value that is either `true` or `false`.
```sig
Math.randomBoolean()
```
## Returns
* a pseudo-random [boolean](types/boolean) that is either `true` or `false`.
## Example
Make your @boardname@ do a coin toss when it's dropped softly. Have the LEDs show 'heads' or 'tails' as the result of the toss.
```blocks
input.onGesture(Gesture.FreeFall, () => {
if (Math.randomBoolean()) {
basic.showIcon(IconNames.Happy)
} else {
basic.showIcon(IconNames.Sword)
}
})
```
## See Also
[random](/reference/math/random)

View File

@ -1,12 +0,0 @@
# @extends
## #exstart
In this example, ``on start`` sets a dimmer brightness on the screen and the button handler shows a string.
```blocks
input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => {
basic.showString("Hello!")
})
led.setBrightness(50)
```

21
docs/blocks/variables.md Normal file
View File

@ -0,0 +1,21 @@
# Variables
[Assign](/blocks/variables/assign) (set) a variable's value
```blocks
let x = 0;
```
Get a variable's value
```blocks
let x = 0;
x;
```
[Change](/blocks/variables/change-var) a variable's value
```blocks
let x = 0;
x+=1;
```

View File

@ -1,12 +1,12 @@
# Assignment Operator # Assignment Operator
Use an equals sign to make a [variable](/blocks/variables/var) store the [number](/types/number) Use an equals sign to make a [variable](/blocks/variables/var) store the [number](/reference/types/number)
or [string](/types/string) you say. or [string](/reference/types/string) you say.
When you use the equals sign to store something in a variable, the equals sign is called When you use the equals sign to store something in a variable, the equals sign is called
an *assignment operator*, and what you store is called a *value*. an *assignment operator*, and what you store is called a *value*.
## Storing numbers in variables ### Storing numbers in variables
This program makes the variable `item` equal `5` and then shows it on the [LED screen](/device/screen). This program makes the variable `item` equal `5` and then shows it on the [LED screen](/device/screen).
@ -15,7 +15,7 @@ let item = 5
basic.showNumber(item) basic.showNumber(item)
```` ````
## Storing strings in variables ### Storing strings in variables
This program makes the variable `name` equal `Joe` and then shows it on the [LED screen](/device/screen). This program makes the variable `name` equal `Joe` and then shows it on the [LED screen](/device/screen).
@ -24,13 +24,13 @@ let name = "Joe"
basic.showString(name); basic.showString(name);
```` ````
## Notes ### Notes
You can use the assignment operator with variables of You can use the assignment operator with variables of
every [type](/types). A *type* is which kind of thing every [type](/reference/types). A *type* is which kind of thing
a variable can store, like a number or string. a variable can store, like a number or string.
## See also ### See also
[variable](/blocks/variables/var), [types](/types) [variable](/blocks/variables/var), [types](/reference/types)

View File

@ -0,0 +1,40 @@
# Change Value
Set the value for local and global variables.
### @parent blocks/change-value
Change the value of a variable
```blocks
let x = 0
x += 1
```
### Declare a variable
Use the assignment operator to set the value of a [variable](/blocks/variables/var). Change the value of a variable from 0 to 1 using the change item block. Like this:
```blocks
let x = 0
x += 1
```
### Example
Use the assignment operator to set the value of a [variable](/blocks/variables/var). Change the value of a variable from 0 to 1 using the change item block. Then display the new value of the variable on the LED screen. Like this:
```blocks
let x = 0;
x += 1;
basic.showNumber(x);
```
### Notes
* You can use the assignment operator with variables of each of the supported [types](/reference/types).
### See also
[variable](/blocks/variables/var), [types](/reference/types)

View File

@ -1,13 +0,0 @@
# @extends
## #examples
## Example: show the value of a variable
Use the assignment operator to set the value of a [variable](/blocks/variables/var). Change the value of a variable from 0 to 1 using the change item block. Then display the new value of the variable on the LED screen. Like this:
```blocks
let x = 0;
x += 1;
basic.showNumber(x);
```

View File

@ -2,15 +2,15 @@
How to define and use local variables. How to define and use local variables.
## @parent language ### @parent language
A variable is a place where you can store and retrieve data. Variables have a name, a [type](/types), and value: A variable is a place where you can store and retrieve data. Variables have a name, a [type](/reference/types), and value:
* *name* is how you'll refer to the variable * *name* is how you'll refer to the variable
* *type* refers to the kind of data a variable can store * *type* refers to the kind of data a variable can store
* *value* refers to what's stored in the variable * *value* refers to what's stored in the variable
## Var statement ### Var statement
Use the Block Editor variable statement to create a variable Use the Block Editor variable statement to create a variable
and the [assignment operator](/blocks/variables/assign) and the [assignment operator](/blocks/variables/assign)
@ -35,7 +35,7 @@ A variable is created for the number returned by the [brightness](/reference/led
let b = led.brightness(); let b = led.brightness();
``` ```
## Using variables ### Using variables
Once you've defined a variable, just use the variable's name whenever you need what's stored in the variable. For example, the following code shows the value stored in `counter` on the LED screen: Once you've defined a variable, just use the variable's name whenever you need what's stored in the variable. For example, the following code shows the value stored in `counter` on the LED screen:
@ -52,20 +52,20 @@ counter = counter + 10;
basic.showNumber(counter); basic.showNumber(counter);
``` ```
## Why use variables? ### Why use variables?
If you want to remember and modify data, you'll need a variable. If you want to remember and modify data, you'll need a variable.
A counter is a great example: A counter is a great example:
```blocks ```blocks
let counter = 0; let counter = 0;
input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => { input.onButtonPressed(Button.A, () => {
counter = counter + 1; counter = counter + 1;
basic.showNumber(counter); basic.showNumber(counter);
}); });
``` ```
## Local variables ### Local variables
Local variables exist only within the function or block of code where they're defined. For example: Local variables exist only within the function or block of code where they're defined. For example:
@ -77,11 +77,11 @@ if (led.brightness() > 128) {
} }
``` ```
### Notes #### Notes
* You can use the default variable names if you'd like, however, it's best to use descriptive variable names. To change a variable name in the editor, select the down arrow next to the variable and then click "new variable". * You can use the default variable names if you'd like, however, it's best to use descriptive variable names. To change a variable name in the editor, select the down arrow next to the variable and then click "new variable".
## See also ### See also
[types](/types), [assignment operator](/blocks/variables/assign) [types](/reference/types), [assignment operator](/blocks/variables/assign)

103
docs/browsers.md Normal file
View File

@ -0,0 +1,103 @@
# Unsupported configuration
Your browser is currently not supported. The following configurations are supported:
## Windows
You need one of these browsers running on Windows 7, Windows 8, Windows 8.1, or
Windows 10:
* Internet Explorer 11
* Microsoft Edge
* Google Chrome
* Mozilla Firefox
## Mac
You need one of these browsers running on OS X 10.9 Mavericks, OS X 10.10
Yosemite, OS X 10.11 El Capitan, or macOS 10.12 Sierra:
* Safari
* Google Chrome
* Mozilla Firefox
## Linux
If you're using a Raspberry Pi, please see [the documentation
here](/raspberry-pi).
You need to be running a Linux distribution recent enough to run the most recent
version of one of the following:
* Google Chrome, or Chromium
* Mozilla Firefox, Iceweasel, or Seamonkey
## How to check your OS or browser
### Windows
* Click on the Start menu
* Type 'System'
* Click on the app called 'System'
* The version of Windows you are using will be displayed:
![](/static/configurations/windows-version.png)
### Mac
* Click on the Apple icon in the top left
* Click on 'About this Mac'
* This window will be displayed:
![](/static/configurations/osx-version.png)
### Internet Explorer
* Click on the Settings icon in the top right
* Click 'About Internet Explorer'
* This window will be displayed:
![](/static/configurations/ie-version.png)
### Edge
Edge automatically updates, so you should always be using the latest version
* Click on the menu icon in the top right (three dots)
* Scroll to the bottom
* Information similar to the following will be displayed:
![](/static/configurations/edge-version.png)
### Google Chrome
Google Chrome automatically updates, so you should always be using the latest version
* Click on the menu icon in the top right (three dots)
* Click Help, and About Google Chrome
* Information similar to the following will be displayed:
![](/static/configurations/chrome-version.png)
### Firefox
Firefox automatically updates, so you should always be using the latest version
* Click on the menu icon in the top right (three horizontal lines)
* Click the question mark icon (help button)
* Click 'About Firefox'
![](/static/configurations/firefox-version.png)
### Safari
Safari updates when your operating system updates, so if you are using the
latest version of OS X then you'll be using the latest version of Safari.
* Click on the Safari menu in the top left
* Click 'About Safari'
![](/static/configurations/safari-version.png)
IT administrators should check which browser versions are supported
[here](/browsers/technical).

16
docs/browsers/linux.md Normal file
View File

@ -0,0 +1,16 @@
# Recommended browser for Linux
As you are using Linux, it is recommended that you use [Mozilla
Firefox][firefox] or [Google Chrome][chrome].
Please see [here][technical] for technical information on which browsers are
supported, or [here][versions] to check which version you are using.
[edge]: https://www.microsoft.com/en-us/windows/microsoft-edge
[ie]: https://www.microsoft.com/en-us/download/internet-explorer.aspx
[firefox]: https://www.mozilla.org/en-US/firefox/new/
[chrome]: https://www.google.com/chrome/
[opera]: https://www.opera.com
[safari]: http://www.apple.com/safari/
[technical]: /browsers/technical
[versions]: /browsers

16
docs/browsers/mac.md Normal file
View File

@ -0,0 +1,16 @@
# Recommended browser for Mac
As you are using a Mac, it is recommended that you use [Safari][]. Alternatively,
[Google Chrome][chrome] and [Mozilla Firefox][firefox] are also supported.
Please see [here][technical] for technical information on which browsers are
supported, or [here][versions] to check which version you are using.
[edge]: https://www.microsoft.com/en-us/windows/microsoft-edge
[ie]: https://www.microsoft.com/en-us/download/internet-explorer.aspx
[firefox]: https://www.mozilla.org/en-US/firefox/new/
[chrome]: https://www.google.com/chrome/
[opera]: https://www.opera.com
[safari]: http://www.apple.com/safari/
[technical]: /browsers/technical
[versions]: /browsers

View File

@ -0,0 +1,36 @@
# Technical information about browser support
[pxt.microbit.org][] requires that you use a recent version of a modern
browser, such as Microsoft Edge, Google Chrome, Mozilla Firefox, Safari, Opera,
or IE11. This is because the editor uses modern web technologies such as [web
workers][] to enable compiling [TypeScript][] in the browser, or the using the
same [Monaco][] editor that powers [Visual Studio Code][].
[pxt.microbit.org]: https://pxt.microbit.org
[web workers]: http://www.w3.org/TR/workers/
[typescript]: http://www.typescriptlang.org
[monaco]: https://microsoft.github.io/monaco-editor/
[visual studio code]: http://code.visualstudio.com
Most modern browsers automatically update themselves, but in some environments
such as schools these automatic updates are disabled for security. **We
strongly recommend that you use the most recent version of any of these
browsers**, but if you can't then you must use at least:
| Browser | Minimum version | Release date | Windows | Mac |
| ----------------- | --------------- | -------------- | ----------- | ---------- |
| Edge | 12 | March 2015 | Windows 10+ | N/A |
| Internet Explorer | 11 | October 2013 | Windows 7+ | N/A |
| Mozilla Firefox | 31 ESR | July 2014 | Windows XP+ | OS X 10.6+ |
| Google Chrome | 38 | October 2014 | Windows XP+ | OS X 10.6+ |
| Safari | 9 | September 2015 | N/A | OS X 10.9+ |
| Opera | 21 | May 2014 | Windows 7+ | OS X 10.9+ |
Please see our information for which browsers are recommended for [Windows][],
[Mac][], [Linux][], or [Raspberry Pi][].
[Windows]: /browsers/windows
[Mac]: /browsers/mac
[Linux]: /browsers/linux
[Raspberry Pi]: /raspberry-pi

18
docs/browsers/windows.md Normal file
View File

@ -0,0 +1,18 @@
# Recommended browser for Windows
We recommend [Microsoft Edge][edge] if you are running Windows 10, but users on
Windows 7 or higher can use [Internet Explorer 11][ie] or recent versions of
[Mozilla Firefox][firefox], [Google Chrome][chrome], or [Opera][opera].
Please see [here][technical] for technical information on which browsers are
supported, or [here][versions] to check which version you are using.
[edge]: https://www.microsoft.com/en-us/windows/microsoft-edge
[ie]: https://www.microsoft.com/en-us/download/internet-explorer.aspx
[firefox]: https://www.mozilla.org/en-US/firefox/new/
[chrome]: https://www.google.com/chrome/
[opera]: https://www.opera.com
[safari]: http://www.apple.com/safari/
[technical]: /browsers/technical
[versions]: /browsers

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

View File

@ -1,17 +0,0 @@
# Projects
Here are some cool tutorials to get you started with your @boardname@!
## Basic
```codecard
[
{
"name": "Radio Bridge",
"description": "Send radio messages to editor",
"url": "/projects/radio-bridge",
"imageUrl": "/static/mb/projects/radio-bridge.png",
"cardType": "example"
}
]
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

View File

@ -1,110 +0,0 @@
# Projects
Here are some cool tutorials to get you started with your @boardname@!
## Basic
```codecard
[
{
"name": "Get Ready",
"url":"/calliope/firststeps/firstSteps",
"description": "Find out how to start working with the Calliope mini",
"imageUrl": "/calliope/firststeps/connecting.jpg",
"largeImageUrl": "/calliope/firststeps/firstSteps.jpg",
"cardType": "tutorial",
"label": "Never seen a mini? Start Here!",
"labelClass": "green small ribbon"
},
{
"name": "The 5x5 LED matrix",
"url":"/calliope/firststeps/5x5LED",
"description": "Learn how to create and show images, numbers or letters on the LED matrix",
"imageUrl": "/calliope/firststeps/5x5LED.jpg",
"largeImageUrl": "/calliope/firststeps/5x5LED_L.jpg",
"cardType": "tutorial",
"label": "New? Start Here!",
"labelClass": "yellow small ribbon"
},
{
"name": "Radio",
"url":"/calliope/firststeps/Radio",
"description": "Find out how to use the radion function and how to send messages from one Calliope mini to another one",
"imageUrl": "/calliope/firststeps/Radio.jpg",
"largeImageUrl": "/calliope/firststeps/Radio_L.jpg",
"cardType": "tutorial",
"label": "",
"labelClass": "orange small ribbon"
},
{
"name": "Loops",
"url":"/calliope/firststeps/Loops",
"description": "Loops are important to be able to execute program instructions multiple times",
"imageUrl": "/calliope/firststeps/Loops.jpg",
"largeImageUrl": "/calliope/firststeps/Loops_L.jpg",
"cardType": "tutorial",
"label": "",
"labelClass": "green small ribbon"
},
{
"name": "Mathematics",
"url":"/calliope/firststeps/Mathematics",
"description": "The Calliope mini can become your little math helper",
"imageUrl": "/calliope/firststeps/Mathematics.jpg",
"largeImageUrl": "/calliope/firststeps/Mathematics_L.jpg",
"cardType": "tutorial",
"label": "",
"labelClass": "green small ribbon"
},
{
"name": "Inputs",
"url":"/calliope/firststeps/Inputs",
"description": "Use conditions for different actions",
"imageUrl": "/calliope/firststeps/Inputs.jpg",
"largeImageUrl": "/calliope/firststeps/Inputs_L.jpg",
"cardType": "tutorial",
"label": "",
"labelClass": "green small ribbon"
},
{
"name": "Sensors",
"url":"/calliope/firststeps/Sensors",
"description": "Measure temperature, light and orientation",
"imageUrl": "/calliope/firststeps/Sensors.jpg",
"largeImageUrl": "/calliope/firststeps/Sensors_L.jpg",
"cardType": "tutorial",
"label": "",
"labelClass": "green small ribbon"
},
{
"name": "Output",
"url":"/calliope/firststeps/Output",
"description": "Audio, light and motion",
"imageUrl": "/calliope/firststeps/Output.jpg",
"largeImageUrl": "/calliope/firststeps/Output_L.jpg",
"cardType": "tutorial",
"label": "",
"labelClass": "green small ribbon"
},
{
"name": "Decisions",
"url":"/calliope/firststeps/Decisions",
"description": "If..., then it happens... or it happens...",
"imageUrl": "/calliope/firststeps/Decisions.jpg",
"largeImageUrl": "/calliope/firststeps/Decisions_L.jpg",
"cardType": "tutorial",
"label": "",
"labelClass": "green small ribbon"
},
{
"name": "Variables",
"url":"/calliope/firststeps/Variables",
"description": "A variable is not a static value, its what you determine it to be.",
"imageUrl": "/calliope/firststeps/Variables.jpg",
"largeImageUrl": "/calliope/firststeps/Variables_L.jpg",
"cardType": "tutorial",
"label": "",
"labelClass": "green small ribbon"
}
]
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View File

@ -1,58 +0,0 @@
# ERSTE SCHRITTE: The 5X5 LED MATRIX
## Introduction @unplugged
Amongst other things, the Calliope mini comes with 25 red LEDs that can be turned on and off individually. If, for example, you wanted to display your name, you could program individual LEDs to light up in sequence so as to display the letters of your name one after the other. As this would be rather complex, you can also enter the character string into a text field and the Calliope Mini will light up the necessary LEDs in the correct order for you.
## Step 1 @fullscreen
### DISPLAYING A CHARACTER STRING
To show your chosen sting of characters on the LED matrix, select the show string block from the Basic menu. Next, drag and attach this block to the Start block in the main screen. The text contained within the inverted commas will now be displayed on the Calliope mini when the program is started.
```blocks
basic.showString("hi!")
```
## Step 2 @fullscreen
### DISPLAYING NUMBERS
If youd prefer to show a number instead of text, replace the text block in the main screen with the show number block from the Basic menu.
```blocks
basic.showNumber(0)
```
## Step 3 @fullscreen
### DISPLAYING IMAGES
To display a heart, a smiley or even a duck on your Calliope mini, Choose the show iconn block from the Basic menu and select any number of different images by simply clicking on the picture in the block.
```blocks
basic.showIcon(IconNames.Heart)
```
## Step 4 @fullscreen
You can also create your very own images:
Just select this block from the Basic menu and click in the boxes to create your very own image.
```blocks
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
```
## Step 4 @fullscreen
Wenn du keine Pause zwischen 2 Bildern festlegst, zeigt der Calliope mini das erste Bild null Sekunden lang, also gar nicht. Den Warte ms Block findest du im Menü Kontrolle.
```blocks
basic.showIcon(IconNames.Heart)
basic.pause(100)
basic.showIcon(IconNames.Yes)
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,23 +0,0 @@
# ERSTE SCHRITTE: DAS 5X5 LED RASTER
## Introduction @unplugged
Options within a program can be made dependent not only on inputs, but also on other conditions. For example, you can create an oracle that randomly shows a sad or a happy smiley:
## Step 1 @fullscreen
### If then do relationship
The actions below the "then“ are only executed if the condition before is fulfilled.
In this case, the heart will not be visible on the LED grid, as the decision variable is not equal to 1. You can find the if…then block in the Logic section.
## Step 2 @fullscreen
### And on we go
After the if…then block the program continues in any case, no matter whether the condition was fulfilled before or not.
## Step 3 @fullscreen
### If then else
If you expand the if…then block, the first if condition is checked first, if it is not fulfilled the second if condition is checked. Only those actions are triggered for which the associated condition is fulfilled.
Click on the + on the bottom of the block to unfold the if…then block. The probability to display either a happy or a sad smiley on the LED grid is 50/50.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -1,32 +0,0 @@
# FIRST STEPS: INPUTS
## Introduction @unplugged
So far all the programmed text, numbers and images have been displayed on the LED matrix immediately after being loaded onto the Calliope mini. However, if you would prefer to have an event take place after a specific input, you need to use the one of the main blocks from the Input section. In this case we are using the "on button A pressed“ block. By using this block, the Calliope mini will wait until your chosen condition is met before anything is displaying.
## Step 1 @fullscreen
### Buttons
The Calliope mini has two input buttons: Button A (in red) and Button B (in blue). When one of the buttons is pressed, the circuit is completed.
By using the "on button A pressed“ block from Input, you can display your output as soon as button A has been pressed.
## Step 2 @fullscreen
### Shake
You can request the position and movement of the Calliope mini and run an action once a change of the values has been detected.
Use the "on shake“ block from the Input section. Add an "show string Hi!" block from the Basic section and change the content of the string.Your text will be displayed when you shake the Calliope mini. The gesture can be changed by using the dropdown menu to choose the condition.
## Step 3 @fullscreen
### Pins
The Calliope mini has five rounded corners: -, +, 0 , 1, 2, and 3. If you place one finger on the corner and another finger on one of the numbered corners, a small electrical current will flow through your body and back to the Calliope mini, thus closing the electrical circuit.
Use the „on pin Pin0 pressed" block from Input. Use the "show string Hi!" block from the basic section.
Your text will be displayed when pin and pin 0 are both pressed at the same time.
## Step 4 @fullscreen
### Various input
You can program the Calliope mini to respond to more than one input. There are two possible ways of doing this:
You can use indiviual events separated from each other with different actions to run after that condition is met.
Nevertheless, you can also use an "if" or "while" condition (from the Logic and Loops sections) and wait for your inputs to be met.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View File

@ -1,18 +0,0 @@
# FIRST STEPS: LOOPS
## Introduction @unplugged
As you may have noticed in previous exercises, your program was executed only once by Calliope mini. To change this, you can use loops. Use an infinite loop so that the text runs over the LED grid of your Calliope mini infinitely often.
## Step 1 @fullscreen
### Infinite loop
The simplest way is to use a foverever block, from the basic section.
Everything inside will be repeated forever.
## Step 2 @fullscreen
Of course, you can also specify how often something should be repeated:
### Repeat block
Use the „on start“ block or any other block that usually initiates a one time cycle. Take the "Repeat 4 times" block from the Loops section and enter the desired number in the number field. Whatever task is within this block will be executed for the number of times you entered within the “Repeat …“ number.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View File

@ -1,17 +0,0 @@
# FIRST STEPS: MATHEMATICS
## Introduction @unplugged
Calliope mini offers you the possibility to use different mathematical operations. You can calculate numbers, create random numbers and save your results in variables.
## Step 1 @fullscreen
### Calculation of numbers
The Calliope mini is able to perform the 4 basic arithmetic operations addition, subtraction, multiplication and division out of the box:
You can find the required block in the menu Math. From the block's drop-down list you can choose between the four basic arithmetic operations and the exponentiation. To see the result of your calculation, you have to put the block inside a „show number" block from the Basic section. The Calliope mini displays the result of your calculation on the LED grid.
## Step 2 @fullscreen
### Random numbers
You can have Calliope mini create a random number: You can find the corresponding block in the menu Math ("pick random 0 to 10"). By changing the two numbers within the block, you determine how small or how large the random number is allowed to become.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View File

@ -1,23 +0,0 @@
# ERSTE SCHRITTE: DAS 5X5 LED RASTER
## Introduction @unplugged
As well as the red LED matrix the Calliope mini also has a built-in loudspeaker (or piezo speaker to be more precise) that allows you to play different tones and an LED with which you can display a huge variety of different colours.
## Step 1 @fullscreen
### The RGB-LED
The white square under the LED matrix is the RGB-LED. Itworks in exactly the same way as watercolours do. Within this LED there are three smaller LEDs: one red, one green and one blue. When you select a colour in your programming environment, the Calliope mini will automatically display this colour by mixing the three base colours together,
Within the Basic section you select the "set led to red“ block and
## Step 2 @fullscreen
### Light sensor
The light is measured by the LED matrix. You can select the light sensor by dragging the block from the Input section into the number block. With this block you can change the colour you want to display. Simply click on the red tap and choose another colour from the menu.
To turn the LED off, you can use the "turn build-in led off“ block or put the value "0“ on the name of the color.
## Step 3 @fullscreen
### The speaker
You can play individual notes or music pieces. Simply open the Music section and drag the "play tone 262 Hz for 1 beat“ and chance the value of the tone to see how you can adjust the height of the note.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View File

@ -1,25 +0,0 @@
# FIRST STEPS: RADIO
## Introduction @unplugged
There is a Radio module built into the Calliope Mini. This allows for several Calliope mini to communicate with each other and transmit information. To try this out yourself, you will need at least two Calliope mini.
## Step 1 @fullscreen
### Allocating a channel
Firstly you must decide on a channel to use. Only those Calliope mini that are using the same channel will be able to exchange messages with each other. A Calliope mini will not be able to transmit or receive over several channels at the same time. To be able to send information, you must open the radio block and use the radio set group block.
Please ensure that the channel number you select is between 0 and 255.
## Step 2 @fullscreen
### Sending a message
To send a message you should select the "radio send string“ block. Now you can enter the string that will be sent on the channel.
## Step 3 @fullscreen
###Receive a message
Set the same channel as on the sending Calliope mini one.
Use the "on radio received receivedString“ block to look for data.
Include the "show string receivedString“ inside.
Lets try with two (or more) Calliope mini!

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View File

@ -1,30 +0,0 @@
# ERSTE SCHRITTE: DAS 5X5 LED RASTER
## Introduction @unplugged
The Calliope mini is equipped with a number of sensors: It has a temperature sensor, a light sensor, a compass as well as a microphone.
## Step 1 @fullscreen
### Displaying sensor data
In order to display data from your sensors on the Calliope minis LED matrix, you need to select a sensor (value). To do so go to the Basic section and select the "show number 0“ block. Within the number you can now change the "0“ to the value of a sensor.
## Step 2 @fullscreen
### Acceleration sensor
You can select the acceleration values by dragging the block from the Input section and place it on top of the "0“ (which will disappear).
## Step 3 @fullscreen
### Light sensor
The light is measured by the LED matrix. You can select the light sensor by dragging the block from the Input section into the number block.
## Step 4 @fullscreen
### Compass
The built in magnetometer allows the Calliope mini to tell in which direction it is facing. This sensor will provide a value between 0 and 360 degrees. The compass will need to be calibrated before use. Follow the instructions on the Calliope mini and tilt it in a circular fashion to display a complete circle. You can start using it by dragging the block from the Input section into the number block.
## Step 4 @fullscreen
### Temperature sensor
You can select the temperature sensor by dragging the block from the Input section into the number block.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

View File

@ -1,20 +0,0 @@
# ERSTE SCHRITTE: DAS 5X5 LED RASTER
## Introduction @unplugged
As in a football match, where the number of goals scored during the match can change, the value of a variable can also change during a running program.
By clicking on the Variables section and then on the "Make a variable…“ button within this section you will generate a new variable. Now you can determine the name.
## Step 1 @fullscreen
By clicking on the Variables section and then on the "Make a variable…“ button within this section you will generate a new variable. Now you can determine the name.
## Step 2 @fullscreen
You can find a separate block for each variable, which you can use to display its value on the LED grid of Calliope mini by selecting the "show number 0“ block and use the "set variable to 0“ block from the Variables section and add this on a line before. if you change this number, the number on the grid will change accordingly.
## Step 3 @fullscreen
### Count your score
By combining what you have learned so far, you can program a simple score counter: When button A is pressed, the number of goals variable is increased by one numerical value and then displayed. Have a try!

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

View File

@ -1,61 +0,0 @@
# First Steps
## Introduction @unplugged
### 1) Connecting
Connect your mini to your computer via a micro USB cable or Bluetooth. Macs, PCs, Chromebooks, Linux systems, Smartphones and Tablets are supported.
Your Calliope mini will show up on your computer as a drive called 'MINI'.
Open your favourite browser and head to our website and select Editor in the main navigation.
For example drag and drop some blocks and try your program on the Simulator within the editor.
Click the Download button in the editor. This will download a 'hex' file, which is a compact format of your program that your mini can read. Once the file has been downloaded, just copy it to your Calliope mini just like copying a file to a USB stick.
![Connecting Image](/calliope/firststeps/connecting.jpg)
## Introduction @unplugged
### 2) Power it Up
The Calliope mini requires a power source to work. You can either connect your Calliope mini directly to a computer using a Micro USB cable or you can power it using a battery pack.
Here are the instructions on how to connect the battery pack to your Calliope mini:
The supplied battery pack requires two AAA batteries.
Carefully insert the small white plastic connector from the battery pack into the boards battery socket.
Be careful to insure that the ridge on the plug is facing upwards.
If the plug slides easily into the socket then you are attaching it correctly. Otherwise, turn the plug round and re-insert it into the socket. Slide it to "on“ and your Calliope mini is powered by the batteries.
![Powering Image](/calliope/firststeps/powerItUp.png)
## Introduction @unplugged
### 3) Play!
You can now play arround or try some of our other guided first-steps tutorials...
[Learn how to write your name on the LED-Matrix](#tutorial:/calliope/firststeps/5x5LED)
[Play with colors and sound](#tutorial:/calliope/firststeps/Output)
[See how to Controll your mini with the buttons and pins](#tutorial:/calliope/firststeps/Inputs)
## Step 1
Play!
You can now play arround or try some of our other guided first-steps tutorials...
[Learn how to write your name on the LED-Matrix](#tutorial:/calliope/firststeps/5x5LED)
[Play with colors and sound](#tutorial:/calliope/firststeps/Output)
[See how to Controll your mini with the buttons and pins](#tutorial:/calliope/firststeps/Inputs)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 KiB

View File

@ -1,47 +0,0 @@
# Projects
Here are some cool tutorials to get you started with your @boardname@!
## Basic
```codecard
[
{
"name": "Shop",
"url":"https://shop.calliope.cc",
"description": "You can get the mini at the official calliope store.",
"imageUrl": "/calliope/links/thumbnail_shop.gif",
"largeImageUrl": "",
"label": "",
"buttonLabel": "Open Calliope Shop",
"labelClass": "green small ribbon"
}, {
"name": "Projects",
"url":"https://calliope.cc/en/projekte",
"description": "A collection of calliope mini projects",
"imageUrl": "/calliope/links/thumbnail_projects.gif",
"largeImageUrl": "",
"label": "",
"buttonLabel": "View Projects",
"labelClass": "green small ribbon"
}, {
"name": "Teaching materials",
"url":"https://calliope.cc/schulen/schulmaterial",
"description": "",
"imageUrl": "/calliope/links/thumbnail_didactic_material.gif",
"largeImageUrl": "",
"label": "",
"buttonLabel": "View",
"labelClass": "green small ribbon"
}, {
"name": "Forum",
"url":"https://forum.calliope.cc",
"description": "Be a part of our comunity",
"imageUrl": "/calliope/links/thumbnail_community.gif",
"largeImageUrl": "",
"label": "",
"buttonLabel": "Open Forum",
"labelClass": "green small ribbon"
}
]
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Some files were not shown because too many files have changed in this diff Show More