Compare commits
50 Commits
Author | SHA1 | Date | |
---|---|---|---|
0fac3cac8f | |||
a67d9ef1ab | |||
ca61374286 | |||
37330188ef | |||
4922a4a833 | |||
9db5db5067 | |||
75331e4297 | |||
cdc0d12a98 | |||
e08148cac6 | |||
e947f4859b | |||
92508d2daf | |||
5098eaac5a | |||
3a0d4df65c | |||
c26a81dee9 | |||
0054dede9a | |||
7e9c646684 | |||
b2282b1a81 | |||
e4c0e582d3 | |||
0e18b13ea1 | |||
ab6268ea7a | |||
999a40bb0d | |||
0d4af4ea12 | |||
5209222438 | |||
f21ff4ad20 | |||
2d5a96d215 | |||
30fe647f51 | |||
2361d1910a | |||
7921caaaff | |||
8bf34ae19c | |||
0dc03c81b7 | |||
1a398e0db9 | |||
f614cb9b2b | |||
794909f09f | |||
24107d1968 | |||
dfca86999f | |||
a487c3d3ac | |||
e7ea0ba581 | |||
212da01f5b | |||
4e72713797 | |||
5d27ddb4a5 | |||
fea143f1d2 | |||
13677c47a9 | |||
ab73d77322 | |||
b8aa63411c | |||
bdc5122ce4 | |||
9709d43dad | |||
56904acb99 | |||
63d3909cad | |||
23e835b108 | |||
be1ea9a742 |
@ -7,14 +7,17 @@ Here are some fun programs for your @boardname@!
|
||||
```codecard
|
||||
[{
|
||||
"name": "Blinky",
|
||||
"description": "A blinking LED",
|
||||
"url":"/examples/blinky"
|
||||
},
|
||||
{
|
||||
"name": "Name Tag",
|
||||
"description": "Scroll your name on the screen",
|
||||
"url":"/examples/name-tag"
|
||||
},
|
||||
{
|
||||
"name": "Rando",
|
||||
"description": "Randomly blinking LEDs",
|
||||
"url":"/examples/rando"
|
||||
}]
|
||||
```
|
||||
@ -24,12 +27,15 @@ Here are some fun programs for your @boardname@!
|
||||
```codecard
|
||||
[{
|
||||
"name": "Plot Acceleration",
|
||||
"description": "chart acceleration on the LED screen",
|
||||
"url":"/examples/plot-acceleration"
|
||||
}, {
|
||||
"name": "Plot Light Level",
|
||||
"description": "chart light level on the LED screen",
|
||||
"url":"/examples/plot-light-level"
|
||||
}, {
|
||||
"name": "Plot Analog Pin",
|
||||
"description": "chart analog input on the LED screen",
|
||||
"url":"/examples/plot-analog-pin"
|
||||
}]
|
||||
```
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"appref": "v0.9.11"
|
||||
"appref": "v0.9.23"
|
||||
}
|
||||
|
@ -5,12 +5,11 @@ but this may feel a bit awkward to programmers more comfortable with an object-o
|
||||
and objects are built from these classes.
|
||||
|
||||
Starting with ECMAScript 2015, also known as ECMAScript 6, JavaScript programmers will be able to build their applications using
|
||||
this object-oriented class-based approach. TypeScript, allows you to use these techniques now, compiling them
|
||||
down to JavaScript that works across all major browsers and platforms, without having to wait for the next version of JavaScript.
|
||||
this object-oriented class-based approach. TypeScript, allows you to use these techniques.
|
||||
|
||||
Let's take a look at a simple class-based example:
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
class Greeter {
|
||||
greeting: string;
|
||||
constructor(message: string) {
|
||||
@ -34,16 +33,12 @@ This calls into the constructor we defined earlier, creating a new object with t
|
||||
|
||||
# Inheritance
|
||||
|
||||
### ~hint
|
||||
### Inheritance is not supported yet for the @boardname@. Coming soon...
|
||||
### ~
|
||||
|
||||
In TypeScript, we can use common object-oriented patterns.
|
||||
Of course, one of the most fundamental patterns in class-based programming is being able to extend existing classes to create new ones using inheritance.
|
||||
|
||||
Let's take a look at an example:
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
class Animal {
|
||||
name: string;
|
||||
constructor(theName: string) { this.name = theName; }
|
||||
@ -105,7 +100,7 @@ In TypeScript, each member is `public` by default.
|
||||
You may still mark a member `public` explicitly.
|
||||
We could have written the `Animal` class from the previous section in the following way:
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
class Animal {
|
||||
public name: string;
|
||||
public constructor(theName: string) { this.name = theName; }
|
||||
@ -119,7 +114,7 @@ class Animal {
|
||||
|
||||
When a member is marked `private`, it cannot be accessed from outside of its containing class. For example:
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
class Animal {
|
||||
private name: string;
|
||||
constructor(theName: string) { this.name = theName; }
|
||||
@ -138,7 +133,7 @@ The same applies to `protected` members.
|
||||
|
||||
Let's look at an example to better see how this plays out in practice:
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
class Animal {
|
||||
private name: string;
|
||||
constructor(theName: string) { this.name = theName; }
|
||||
@ -174,7 +169,7 @@ Even though `Employee` also has a `private` member called `name`, it's not the o
|
||||
The `protected` modifier acts much like the `private` modifier with the exception that members
|
||||
declared `protected` can also be accessed by instances of deriving classes. For example,
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
class Person {
|
||||
protected name: string;
|
||||
constructor(name: string) { this.name = name; }
|
||||
@ -204,7 +199,7 @@ we can still use it from within an instance method of `Employee` because `Employ
|
||||
A constructor may also be marked `protected`.
|
||||
This means that the class cannot be instantiated outside of its containing class, but can be extended. For example,
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
class Person {
|
||||
protected name: string;
|
||||
protected constructor(theName: string) { this.name = theName; }
|
||||
@ -233,7 +228,7 @@ let john = new Person("John"); // Error: The 'Person' constructor is protected
|
||||
You can make properties readonly by using the `readonly` keyword.
|
||||
Readonly properties must be initialized at their declaration or in the constructor.
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
class Octopus {
|
||||
readonly name: string;
|
||||
readonly numberOfLegs: number = 8;
|
||||
@ -252,7 +247,7 @@ This turns out to be a very common practice.
|
||||
*Parameter properties* let you create and initialize a member in one place.
|
||||
Here's a further revision of the previous `Octopus` class using a parameter property:
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
class Octopus {
|
||||
readonly numberOfLegs: number = 8;
|
||||
constructor(readonly name: string) {
|
||||
|
@ -6,15 +6,14 @@ For the @boardname@, we support a "static" subset of TypeScript (itself a supers
|
||||
|
||||
## Supported language features
|
||||
|
||||
* variables with `let`, `const`, and `var`
|
||||
* variables with `let` and `const`
|
||||
* functions with lexical scoping and recursion
|
||||
* top-level code in the file; hello world really is `console.log("Hello world")`
|
||||
* `if ... else if ... else` statements
|
||||
* `while` and `do ... while` loops
|
||||
* `for(;;)` loops (see below about `for ... in/of`)
|
||||
* `for(;;)` loops and for ... of
|
||||
* `break/continue`; also with labeled loops
|
||||
* `switch` statement (on numbers only)
|
||||
* `debugger` statement for breakpoints
|
||||
* conditional operator `? :`; lazy boolean operators
|
||||
* namespaces (a form of modules)
|
||||
* all arithmetic operators (including bitwise operators); note that in microcontroller targets
|
||||
@ -25,6 +24,7 @@ For the @boardname@, we support a "static" subset of TypeScript (itself a supers
|
||||
* classes with fields, methods and constructors; `new` keyword
|
||||
* array literals `[1, 2, 3]`
|
||||
* enums
|
||||
* class inheritance
|
||||
|
||||
## Unsupported language features
|
||||
|
||||
@ -32,10 +32,10 @@ We generally stay away from the more dynamic parts of JavaScript.
|
||||
Things you may miss and we may implement:
|
||||
|
||||
* exceptions (`throw`, `try ... catch`, `try ... finally`)
|
||||
* `for ... of` statements
|
||||
* `for ... in` statements
|
||||
* object literals `{ foo: 1, bar: "two" }`
|
||||
* method-like properties (get/set accessors)
|
||||
* class inheritance
|
||||
* `debugger` statement for breakpoints
|
||||
|
||||
For JS-only targets we may implement the following:
|
||||
|
||||
@ -55,4 +55,4 @@ Things that we are not very likely to implement:
|
||||
* `eval`
|
||||
* `delete` statement
|
||||
* `for ... in` statements
|
||||
* JSX (HTML as part of JavaScript)
|
||||
* JSX (HTML as part of JavaScript)
|
||||
|
@ -3,7 +3,7 @@
|
||||
Functions are the fundamental building block of programs. Here is the simplest
|
||||
way to make a function that adds two numbers:
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
// Named function
|
||||
function add(x : number, y : number) {
|
||||
return x + y;
|
||||
@ -19,7 +19,7 @@ For the @boardname@, you must specify a [type](/js/types) for each function para
|
||||
Functions can refer to variables outside of the function body.
|
||||
When they do so, they're said to `capture` these variables.
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
let z = 100;
|
||||
|
||||
function addToZ(x: number, y: number) {
|
||||
@ -29,11 +29,9 @@ function addToZ(x: number, y: number) {
|
||||
basic.showNumber(addToZ(1, 2))
|
||||
```
|
||||
|
||||
## Typing the function
|
||||
|
||||
Let's add a return type to our add function:
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
function add(x: number, y: number): number {
|
||||
return x + y;
|
||||
}
|
||||
@ -41,11 +39,24 @@ function add(x: number, y: number): number {
|
||||
|
||||
TypeScript can figure the return type out by looking at the return statements, so you can optionally leave this off in many cases.
|
||||
|
||||
# Arrow Functions
|
||||
|
||||
Arrow functions (also known as "lamba" functions) are used extensively to provide event handlers for
|
||||
many APIs. For example:
|
||||
|
||||
```typescript
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
|
||||
})
|
||||
```
|
||||
|
||||
[Read more about arrow functions...](http://devdocs.io/javascript/functions/arrow_functions)
|
||||
|
||||
# Optional and Default Parameters
|
||||
|
||||
In TypeScript, the number of arguments given to a function has to match the number of parameters the function expects.
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
function buildName(firstName: string, lastName: string) {
|
||||
return firstName + " " + lastName;
|
||||
}
|
||||
@ -60,7 +71,7 @@ When they do, their value is `undefined`.
|
||||
We can get this functionality in TypeScript by adding a `?` to the end of parameters we want to be optional.
|
||||
For example, let's say we want the last name parameter from above to be optional:
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
function buildName(firstName: string, lastName?: string) {
|
||||
if (lastName)
|
||||
return firstName + " " + lastName;
|
||||
@ -80,7 +91,7 @@ In TypeScript, we can also set a value that a parameter will be assigned if the
|
||||
These are called default-initialized parameters.
|
||||
Let's take the previous example and default the last name to `"Smith"`.
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
function buildName(firstName: string, lastName = "Smith") {
|
||||
return firstName + " " + lastName;
|
||||
}
|
||||
@ -94,7 +105,7 @@ let result4 = buildName("Bob", "Adams"); // ah, just right
|
||||
Default-initialized parameters that come after all required parameters are treated as optional, and just like optional parameters, can be omitted when calling their respective function.
|
||||
This means optional parameters and trailing default parameters will share commonality in their types, so both
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
function buildName(firstName: string, lastName?: string) {
|
||||
// ...
|
||||
}
|
||||
@ -102,7 +113,7 @@ function buildName(firstName: string, lastName?: string) {
|
||||
|
||||
and
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
function buildName(firstName: string, lastName = "Smith") {
|
||||
// ...
|
||||
}
|
||||
@ -115,7 +126,7 @@ Unlike plain optional parameters, default-initialized parameters don't *need* to
|
||||
If a default-initialized parameter comes before a required parameter, users need to explicitly pass `undefined` to get the default initialized value.
|
||||
For example, we could write our last example with only a default initializer on `firstName`:
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
function buildName(firstName = "Will", lastName: string) {
|
||||
return firstName + " " + lastName;
|
||||
}
|
||||
@ -134,7 +145,7 @@ In JavaScript, you can work with the arguments directly using the `arguments` va
|
||||
|
||||
In TypeScript, you can gather these arguments together into a variable:
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
function buildName(firstName: string, ...restOfName: string[]) {
|
||||
return firstName + " " + restOfName.join(" ");
|
||||
}
|
||||
@ -148,7 +159,7 @@ The compiler will build an array of the arguments passed in with the name given
|
||||
|
||||
The ellipsis is also used in the type of the function with rest parameters:
|
||||
|
||||
```ts-ignore
|
||||
```typescript-ignore
|
||||
function buildName(firstName: string, ...restOfName: string[]) {
|
||||
return firstName + " " + restOfName.join(" ");
|
||||
}
|
||||
|
@ -18,13 +18,6 @@ This also is true when simulating in the browser.
|
||||
* comparison operators - [read more](http://devdocs.io/javascript/operators/comparison_operators)
|
||||
* conditional operator - [read more](http://devdocs.io/javascript/operators/conditional_operator)
|
||||
|
||||
## More
|
||||
|
||||
* lambda functions `() => { ... }`
|
||||
* array literals `[1, 2, 3]`
|
||||
* strings, with a few common methods
|
||||
* [string templates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) (`` `x is ${x}` ``)
|
||||
|
||||
### ~button /js/statements
|
||||
NEXT: Statements
|
||||
### ~
|
@ -5,7 +5,6 @@ The following JavaScript statements are supported for the @boardname@:
|
||||
## Variable declarations
|
||||
* `const` statement - [read more](http://devdocs.io/javascript/statements/const)
|
||||
* `let` statement - [read more](http://devdocs.io/javascript/statements/let)
|
||||
* `var` statement - [read more](http://devdocs.io/javascript/statements/var)
|
||||
|
||||
## Block-structured statements
|
||||
|
||||
|
@ -3,11 +3,27 @@
|
||||
For programs to be useful, we need to be able to work with some of the simplest units of data:
|
||||
numbers, strings, structures, boolean values, and the like.
|
||||
|
||||
# Type Inference
|
||||
|
||||
In TypeScript, there are several places where type inference is used to provide type information when there is
|
||||
no explicit type annotation. For example, in this code
|
||||
|
||||
```typescript
|
||||
let x = 3;
|
||||
let y = x + 3
|
||||
```
|
||||
|
||||
The type of the `x` variable is inferred to be `number`. Similarly, the type of `y` variable also is inferred to be `number`.
|
||||
This kind of inference takes place when initializing variables and members,
|
||||
setting parameter default values, and determining function return types.
|
||||
|
||||
All the examples below give an example type annotation, but will work just the same without the annotation.
|
||||
|
||||
# Boolean
|
||||
|
||||
The most basic datatype is the simple true/false value, which is called a `boolean` value.
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
let isDone: boolean = false;
|
||||
```
|
||||
|
||||
@ -20,7 +36,7 @@ However, for the @boardname@, `numbers` are integer values.
|
||||
|
||||
Integer values can be specified via decimal, hexadecimal and octal notation:
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
let decimal: number = 42;
|
||||
let hex: number = 0xf00d;
|
||||
let binary: number = 0b1010;
|
||||
@ -32,7 +48,7 @@ let octal: number = 0o744;
|
||||
As in other languages, we use the type `string` to refer to textual data.
|
||||
Use double quotes (`"`) or single quotes (`'`) to surround string data.
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
let color: string = "blue";
|
||||
color = 'red';
|
||||
```
|
||||
@ -40,7 +56,7 @@ color = 'red';
|
||||
You can also use *template strings*, which can span multiple lines and have embedded expressions.
|
||||
These strings are surrounded by the backtick/backquote (`` ` ``) character, and embedded expressions are of the form `${ expr }`.
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
let fullName: string = `Bob Bobbington`;
|
||||
let age: number = 37;
|
||||
let sentence: string = `Hello, my name is ${ fullName }.
|
||||
@ -50,7 +66,7 @@ I'll be ${ age + 1 } years old next month.`
|
||||
|
||||
This is equivalent to declaring `sentence` like so:
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
let fullName: string = `Bob Bobbington`;
|
||||
let age: number = 37;
|
||||
let sentence: string = "Hello, my name is " + fullName + ".\n\n" +
|
||||
@ -63,13 +79,13 @@ Arrays allow you to work with an expandable sequence of values, addressed by an
|
||||
Array types can be written in one of two ways.
|
||||
In the first, you use the type of the elements followed by `[]` to denote an array of that element type:
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
let list: number[] = [1, 2, 3];
|
||||
```
|
||||
|
||||
The second way uses a generic array type, `Array<elemType>`:
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
let list: Array<number> = [1, 2, 3];
|
||||
```
|
||||
|
||||
@ -77,13 +93,12 @@ let list: Array<number> = [1, 2, 3];
|
||||
For the @boardname@, all elements of an array must have the same type.
|
||||
### ~
|
||||
|
||||
|
||||
# Enum
|
||||
|
||||
A helpful addition to the standard set of datatypes from JavaScript is the `enum`.
|
||||
As in languages like C#, an enum is a way of giving more friendly names to sets of numeric values.
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
enum Color {Red, Green, Blue}
|
||||
let c: Color = Color.Green;
|
||||
```
|
||||
@ -92,14 +107,14 @@ By default, enums begin numbering their members starting at `0`.
|
||||
You can change this by manually setting the value of one of its members.
|
||||
For example, we can start the previous example at `1` instead of `0`:
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
enum Color {Red = 1, Green, Blue}
|
||||
let c: Color = Color.Green;
|
||||
```
|
||||
|
||||
Or, even manually set all the values in the enum:
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
enum Color {Red = 1, Green = 2, Blue = 4}
|
||||
let c: Color = Color.Green;
|
||||
```
|
||||
@ -108,13 +123,12 @@ let c: Color = Color.Green;
|
||||
|
||||
The TypeScript type `any` is not supported in the @boardname@.
|
||||
|
||||
|
||||
# Void
|
||||
|
||||
`void` is the absence of having any type at all.
|
||||
You may commonly see this as the return type of functions that do not return a value:
|
||||
|
||||
```ts
|
||||
```typescript
|
||||
function warnUser(): void {
|
||||
basic.showString("This is my warning message");
|
||||
}
|
||||
@ -122,21 +136,6 @@ function warnUser(): void {
|
||||
|
||||
Declaring variables of type `void` is not useful.
|
||||
|
||||
# Type Inference
|
||||
|
||||
In TypeScript, there are several places where type inference is used to provide type information when there is
|
||||
no explicit type annotation. For example, in this code
|
||||
|
||||
```ts
|
||||
let x = 3;
|
||||
let y = x + 3
|
||||
```
|
||||
|
||||
The type of the `x` variable is inferred to be `number`. Similarly, the type of `y` variable also is inferred to be `number`.
|
||||
This kind of inference takes place when initializing variables and members,
|
||||
setting parameter default values, and determining function return types.
|
||||
|
||||
|
||||
### ~button /js/classes
|
||||
NEXT: Classes
|
||||
### ~
|
@ -1,8 +1,16 @@
|
||||
# Variable Declarations
|
||||
|
||||
Declaring a variable should be done using the ``let`` keyword:
|
||||
|
||||
```typescript
|
||||
let a = 10;
|
||||
```
|
||||
|
||||
## ``var`` vs ``let``
|
||||
|
||||
Declaring a variable in JavaScript has always traditionally been done with the `var` keyword.
|
||||
|
||||
```typescript
|
||||
```typescript-ignore
|
||||
var a = 10;
|
||||
```
|
||||
|
||||
@ -16,6 +24,10 @@ let a = 10;
|
||||
|
||||
The key difference is not in the syntax, but in the semantics, which we'll now dive into.
|
||||
|
||||
### ~hint
|
||||
### Use `let` instead of `var` to introduce a new variable.
|
||||
### ~
|
||||
|
||||
## Block-scoping
|
||||
|
||||
When a variable is declared using `let`, it uses what some call *lexical-scoping* or *block-scoping*.
|
||||
|
@ -39,8 +39,8 @@ coll.push("cat")
|
||||
|
||||
## 4. Write the five (5) lines of code that will add the following five words to `data->coll`: puppy, clock, night, cat, cow.
|
||||
|
||||
```ts
|
||||
let coll = (<string[]>[])
|
||||
```typescript
|
||||
let coll : string[] = [];
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
@ -4,6 +4,7 @@ Provides access to basic @boardname@ functionality.
|
||||
|
||||
```cards
|
||||
basic.showNumber(0);
|
||||
basic.showIcon(IconNames.Heart);
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
@ -24,6 +25,7 @@ basic.plotLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
`);
|
||||
basic.showArrow(ArrowNames.North);
|
||||
basic.showAnimation(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
@ -35,6 +37,8 @@ basic.showAnimation(`
|
||||
|
||||
### See Also
|
||||
|
||||
[showNumber](/reference/basic/show-number), [showLeds](/reference/basic/show-leds), [showString](/reference/basic/show-string),
|
||||
[showNumber](/reference/basic/show-number),
|
||||
[showIcon](/reference/basic/show-icon),
|
||||
[showLeds](/reference/basic/show-leds), [showString](/reference/basic/show-string),
|
||||
[clearScreen](/reference/basic/clear-screen), [forever](/reference/basic/forever), [pause](/reference/basic/pause),
|
||||
[showAnimation](/reference/basic/show-animation)
|
||||
|
23
docs/reference/basic/show-arrow.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Show Arrow
|
||||
|
||||
Shows the selected arrow on the LED screen
|
||||
|
||||
```sig
|
||||
basic.showArrow(ArrowNames.North)
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
This program shows all eight arrows.
|
||||
|
||||
```blocks
|
||||
for (let index = 0; index <= 7; index++) {
|
||||
basic.showArrow(index)
|
||||
basic.pause(300)
|
||||
}
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[showIcon](/reference/basic/show-icon),
|
||||
[showLeds](/reference/basic/show-leds)
|
21
docs/reference/basic/show-icon.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Show Icon
|
||||
|
||||
Shows the selected icon on the LED screen
|
||||
|
||||
```sig
|
||||
basic.showIcon(IconNames.Heart)
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
This program shows a happy face and then a sad face with the ``show icon`` function, with a one second pause in between.
|
||||
|
||||
```blocks
|
||||
basic.showIcon(IconNames.Happy)
|
||||
basic.pause(1000)
|
||||
basic.showIcon(IconNames.Sad)
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[showLeds](/reference/basic/show-leds)
|
29
docs/reference/music/play-builtin-melody.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Play Built-in Melody
|
||||
|
||||
Play a built in musical melody through pin ``P0`` of the @boardname@.
|
||||
|
||||
## Simulator
|
||||
|
||||
This function only works on the @boardname@ and in some browsers.
|
||||
|
||||
```sig
|
||||
music.playBuiltinMelody(Melodies.Entertainer)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``melody`` is the kind of built-in melody you want to play
|
||||
|
||||
## Example
|
||||
|
||||
This example plays the ``Entertainer`` melody.
|
||||
|
||||
```blocks
|
||||
music.playBuiltinMelody(Melodies.Entertainer)
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[play tone](/reference/music/play-tone), [rest](/reference/music/rest), [ring tone](/reference/music/ring-tone) , [tempo](/reference/music/tempo), [set tempo](/reference/music/set-tempo),
|
||||
[change tempo by](/reference/music/change-tempo-by)
|
||||
|
BIN
docs/static/blocks/iconnames/heart.PNG
vendored
Before Width: | Height: | Size: 5.0 KiB |
@ -166,6 +166,9 @@
|
||||
"led.unplot|param|y": "TODO",
|
||||
"music": "Generation of music tones through pin ``P0``.",
|
||||
"music.beat": "Returns the duration of a beat in milli-seconds",
|
||||
"music.beginMelody": "Starts playing a melody through pin ``P0``.\nNotes are expressed as a string of characters with this format: NOTE[octave][:duration]",
|
||||
"music.beginMelody|param|options": "melody options, once / forever, in the foreground / background",
|
||||
"music.builtInMelody": "Gets the melody array of a built-in melody.",
|
||||
"music.changeTempoBy": "Change the tempo by the specified amount",
|
||||
"music.changeTempoBy|param|bpm": "The change in beats per minute to the tempo, eg: 20",
|
||||
"music.noteFrequency": "Gets the frequency of a note.",
|
||||
|
@ -17,7 +17,7 @@
|
||||
"AnalogPin.P20|block": "P20 (write only)",
|
||||
"AnalogPin.P5|block": "P5 (write only)",
|
||||
"AnalogPin.P6|block": "P6 (write only)",
|
||||
"AnalogPin.P7|block": "P5 (write only)",
|
||||
"AnalogPin.P7|block": "P7 (write only)",
|
||||
"AnalogPin.P8|block": "P8 (write only)",
|
||||
"AnalogPin.P9|block": "P9 (write only)",
|
||||
"BaudRate.BaudRate115200|block": "115200",
|
||||
@ -86,7 +86,6 @@
|
||||
"IconNames.LeftTriangle|block": "left triangle",
|
||||
"IconNames.Meh|block": "meh",
|
||||
"IconNames.No|block": "no",
|
||||
"IconNames.Pacman|block": "pac man",
|
||||
"IconNames.Pitchfork|block": "pitchfork",
|
||||
"IconNames.QuarterNote|block": "quarter note",
|
||||
"IconNames.Rabbit|block": "rabbit",
|
||||
@ -115,6 +114,30 @@
|
||||
"LedSpriteProperty.Y|block": "y",
|
||||
"Math.randomBoolean|block": "pick random true or false",
|
||||
"Math|block": "Math",
|
||||
"Melodies.BaDing|block": "ba ding",
|
||||
"Melodies.Baddy|block": "baddy",
|
||||
"Melodies.Birthday|block": "birthday",
|
||||
"Melodies.Blues|block": "blues",
|
||||
"Melodies.Chase|block": "chase",
|
||||
"Melodies.Dadadadum|block": "dadadum",
|
||||
"Melodies.Entertainer|block": "entertainer",
|
||||
"Melodies.Funeral|block": "funereal",
|
||||
"Melodies.Funk|block": "funk",
|
||||
"Melodies.JumpDown|block": "jump down",
|
||||
"Melodies.JumpUp|block": "jump up",
|
||||
"Melodies.Nyan|block": "nyan",
|
||||
"Melodies.Ode|block": "ode",
|
||||
"Melodies.PowerDown|block": "power down",
|
||||
"Melodies.PowerUp|block": "power up",
|
||||
"Melodies.Prelude|block": "prelude",
|
||||
"Melodies.Punchline|block": "punchline",
|
||||
"Melodies.Ringtone|block": "ringtone",
|
||||
"Melodies.Wawawawaa|block": "wawawawaa",
|
||||
"Melodies.Wedding|block": "wedding",
|
||||
"MelodyOptions.ForeverInBackground|block": "forever in background",
|
||||
"MelodyOptions.Forever|block": "forever",
|
||||
"MelodyOptions.OnceInBackground|block": "once in background",
|
||||
"MelodyOptions.Once|block": "once",
|
||||
"Note.CSharp3|block": "C#3",
|
||||
"Note.CSharp4|block": "C#4",
|
||||
"Note.CSharp5|block": "C#5",
|
||||
@ -200,6 +223,8 @@
|
||||
"led.unplot|block": "unplot|x %x|y %y",
|
||||
"led|block": "led",
|
||||
"music.beat|block": "%fraction|beat",
|
||||
"music.beginMelody|block": "start|melody %melody=device_builtin_melody| repeating %options",
|
||||
"music.builtInMelody|block": "%melody",
|
||||
"music.changeTempoBy|block": "change tempo by (bpm)|%value",
|
||||
"music.noteFrequency|block": "%note",
|
||||
"music.playTone|block": "play|tone %note=device_note|for %duration=device_beat",
|
||||
|
@ -1,4 +1,44 @@
|
||||
{
|
||||
"Gesture.LogoDown": "Déclenché lorsque le logo est vers le bas et l’écran est vertical",
|
||||
"Gesture.LogoDown|block": "logo vers le bas",
|
||||
"Gesture.LogoUp|block": "logo vers le haut",
|
||||
"Gesture.ScreenDown|block": "écran vers le bas",
|
||||
"Gesture.ScreenUp|block": "écran vers le haut",
|
||||
"Gesture.Shake|block": "secouer",
|
||||
"Gesture.SixG|block": "6g",
|
||||
"Gesture.TiltLeft|block": "incliner à gauche",
|
||||
"Gesture.TiltRight|block": "incliner à droite",
|
||||
"IconNames.Angry|block": "fâché",
|
||||
"IconNames.Asleep|block": "endormi",
|
||||
"IconNames.Butterfly|block": "papillon",
|
||||
"IconNames.Chessboard|block": "échiquier",
|
||||
"IconNames.Confused|block": "confus",
|
||||
"IconNames.Cow|block": "vache",
|
||||
"IconNames.Diamond|block": "diamant",
|
||||
"IconNames.Duck|block": "canard",
|
||||
"IconNames.Fabulous|block": "fabuleux",
|
||||
"IconNames.Ghost|block": "fantôme",
|
||||
"IconNames.Giraffe|block": "girafe",
|
||||
"IconNames.Happy|block": "heureux",
|
||||
"IconNames.Heart|block": "coeur",
|
||||
"IconNames.House|block": "maison",
|
||||
"IconNames.LeftTriangle|block": "triangle gauche",
|
||||
"IconNames.Meh|block": "meh",
|
||||
"IconNames.No|block": "non",
|
||||
"IconNames.Pacman|block": "pac man",
|
||||
"IconNames.Pitchfork|block": "pitchfork",
|
||||
"IconNames.QuarterNote|block": "note",
|
||||
"IconNames.Rabbit|block": "lapin",
|
||||
"IconNames.Rollerskate|block": "patins à roulette",
|
||||
"IconNames.Sad|block": "triste",
|
||||
"IconNames.Silly|block": "bête",
|
||||
"IconNames.Skull|block": "crâne",
|
||||
"IconNames.SmallDiamond|block": "petit diamant",
|
||||
"IconNames.SmallHeart|block": "petit coeur",
|
||||
"IconNames.SmallSquare|block": "petit carré",
|
||||
"IconNames.Snake|block": "serpent",
|
||||
"IconNames.Square|block": "carré",
|
||||
"LedSpriteProperty.Blink|block": "clignotement",
|
||||
"LedSpriteProperty.Brightness|block": "luminosité",
|
||||
"Math.randomBoolean|block": "choisir au hasard vrai ou faux",
|
||||
"Math|block": "Maths",
|
||||
@ -30,6 +70,7 @@
|
||||
"input.magneticForce|block": "force magnétique (µT) |%NAME",
|
||||
"input.onButtonPressed|block": "lorsque le button|%NAME|est pressé",
|
||||
"input.onGesture|block": "lorsque|%NAME",
|
||||
"input.onPinPressed|block": "lorsque le pin %NAME|est pressé",
|
||||
"input.onPinReleased|block": "lorsque la broche %NAME|est lachée",
|
||||
"input.pinIsPressed|block": "broche %NAME| est pressée",
|
||||
"input.rotation|block": "rotation (°)|%NAME",
|
||||
|
@ -1,92 +1,40 @@
|
||||
{
|
||||
"Math.randomBoolean":"硬貨を弾くことのようなちょうど 'true' または 'false' の値をランダムに生成します。",
|
||||
"String.fromCharCode":"指定された ASCII 文字コードから文字列を確認します。",
|
||||
"basic":"基本的なマイクロ: ビット機能へのアクセスを提供します。",
|
||||
"basic.clearScreen":"すべての Led をオフにします。",
|
||||
"basic.forever":"永遠にバック グラウンドでコードを繰り返します。各イテレーションを実行するその他のコードを使用できます。",
|
||||
"basic.pause":"ミリ秒で指定された時間一時停止します。",
|
||||
"basic.plotLeds":"LED 画面にイメージを描画します。",
|
||||
"basic.showAnimation":"アニメーションとして LED スクリーンのシーケンスを示しています。",
|
||||
"basic.showLeds":"LED 画面にイメージを描画します。",
|
||||
"basic.showNumber":"画面上の数字をスクロールします。数が画面上に収まる場合 (つまりは 1 桁)、スクロールしません。",
|
||||
"basic.showString":"一度に 1 つの文字の表示のテキストを表示します。文字列が画面上に収まる場合 (すなわち、1 つの文字)、スクロールしません。",
|
||||
"control":"ランタイムおよびイベント ユーティリティ。",
|
||||
"control.inBackground":"スケジュールは、バック グラウンドで実行されるコードします。",
|
||||
"control.reset":"BBC のマイクロ: ビットをリセットします。",
|
||||
"game":"単一 LED スプライト ゲーム エンジン",
|
||||
"game.addScore":"現在のスコアにポイントを追加します。",
|
||||
"game.gameOver":"ゲーム アニメーションを表示します。",
|
||||
"game.score":"現在のスコアを取得します。",
|
||||
"game.setScore":"現在のスコアの値を設定します",
|
||||
"game.startCountdown":"ゲームのカウント ダウン タイマーを開始します。",
|
||||
"images":"作成、操作および LED の画像を表示します。",
|
||||
"images.createBigImage":"2 フレームを持つイメージを作成します。",
|
||||
"images.createImage":"LED 画面に合ったイメージを作成します。",
|
||||
"input":"イベントやセンサーからのデータ",
|
||||
"input.acceleration":"ミリ gravitys の加速度値を取得 (ボードを敷設するときフラット スクリーンを x = 0、y = 0、z = 1024年)",
|
||||
"input.buttonIsPressed":"'、' と 'B' のボタンの状態 (押されてかどうか) を取得します。",
|
||||
"input.calibrate":"時代遅れ、コンパス キャリブレーションは自動です。",
|
||||
"input.compassHeading":"度で、現在のコンパス コンパス針路を取得します。",
|
||||
"input.lightLevel":"'0 ' (暗い)「255」明るいから適用範囲内の LED スクリーン光レベルを読み取ります。",
|
||||
"input.magneticForce":"「マイクロ ・ テスラ」(μ '' T '') の磁気力の値を取得します。シミュレータでは、この関数はサポートされていません。",
|
||||
"input.onButtonPressed":"'、'、' B '(両方の' A + B ') ボタンが押されたときに何か",
|
||||
"input.onGesture":"画面を向いているときに実行するコードをアタッチします。",
|
||||
"input.onLogoDown":"ロゴは下方向とボードが垂直方向に実行されるコードをアタッチします。",
|
||||
"input.onLogoUp":"ロゴは上方向きとボードが垂直方向に実行されるコードをアタッチします。",
|
||||
"input.onPinPressed":"(「P0 '' や '' P1 '' 両方 '' P2 '') ピンが押されたときに何かを行います。",
|
||||
"input.onScreenDown":"画面が直面しているときに実行するコードをアタッチします。",
|
||||
"input.onScreenUp":"画面を向いているときに実行するコードをアタッチします。",
|
||||
"input.onShake":"デバイスを振るときに実行するコードをアタッチします。",
|
||||
"input.pinIsPressed":"(押すか) ピンの状態を取得します。回路を閉じるために地面を保持する必要があります。",
|
||||
"input.rotation":"度の 'x ' に沿って回転デバイスのピッチです。",
|
||||
"input.runningTime":"電源から経過したミリ秒数を取得します。",
|
||||
"input.setAccelerometerRange":"吊り下げた状態で加速度計のサンプル範囲を設定します。",
|
||||
"input.temperature":"摂氏温度を取得度 (° C)。",
|
||||
"led":"LED 画面を制御します。",
|
||||
"led.brightness":"画面の明るさから得る 0 (オフ) 255 (完全明るい)。",
|
||||
"led.fadeIn":"画面がフェードインします。",
|
||||
"led.fadeOut":"画面の明るさをフェードアウトします。",
|
||||
"led.plot":"オンに指定した LED を使用して x 座標と y 座標 (x は横方向、y は縦方向)。(0, 0) は左上。",
|
||||
"led.plotAll":"すべての LED が点灯します。",
|
||||
"led.plotBarGraph":"'値' と '高' の値に基づく垂直棒グラフを表示します。\n場合は '高' は 0、グラフを自動的に調整を取得します。",
|
||||
"led.point":"使用して指定された LED のオン\/オフ状態を取得 x 座標と y 座標。(0, 0) は左上。",
|
||||
"led.screenshot":"LED 画面のスクリーン ショットを取り、画像を返します。",
|
||||
"led.setBrightness":"画面の明るさ 0 (オフ) に設定 255 (完全明るい)。",
|
||||
"led.setDisplayMode":"黒と白とグレースケールの Led を表示するための表示モードを設定します。",
|
||||
"led.stopAnimation":"現在のアニメーションをキャンセルし、保留中のアニメーション他をクリアします。",
|
||||
"led.toggle":"特定のピクセルを切り替えます",
|
||||
"led.toggleAll":"現在の LED ディスプレイを反転します",
|
||||
"led.unplot":"指定した LED を使用してオフに x 座標と y 座標 (x は横方向、y は縦方向)。(0, 0) は左上。",
|
||||
"music":"ピン「P0 '' を介して音楽の音の生成。",
|
||||
"music.beat":"ビートのデュレーションをミリ秒単位で返します",
|
||||
"music.changeTempoBy":"指定した量によってテンポを変更します。",
|
||||
"music.noteFrequency":"ノートの頻度を取得します。",
|
||||
"music.playTone":"指定された期間のピン 'P0' を通じて調子を果たしています。",
|
||||
"music.rest":"かかっている (何も果たしている) ピン 'P0' により指定した時刻に。",
|
||||
"music.ringTone":"ピン「P0 '' から音をを再生します。",
|
||||
"music.setTempo":"テンポを一定に設定します",
|
||||
"music.tempo":"1 分あたりのビートのテンポを返します。速度はテンポ (bpm = 1 分あたりのビート) ノートを遊んで。テンポの値が大きいほど、高速のノートが再生されます。",
|
||||
"pins":"アナログ\/デジタル信号、サーボ、i2c、ピンで電流を制御します。",
|
||||
"pins.analogPitch":"現在のピッチ端子にパルス幅変調 (PWM) 信号を出力します。'アナログ設定ピッチ pin' を使用して、ピッチのピンを定義します。",
|
||||
"pins.analogReadPin":"つまり、0 から 1023年の間から成る値としてアナログ、としてコネクタ値を読み取る。",
|
||||
"pins.analogSetPeriod":"アナログで与えられた値に出力のパルス幅変調 (PWM) を構成 * * マイクロ秒 * * または '' 1\/1000年ミリ秒。\nこのピンはアナログ出力 ('アナログ書き込みピン' を使用) として構成されていない場合、操作には影響がありません。",
|
||||
"pins.analogSetPitchPin":"'ピン-> アナログ ピッチ' を使用するときに使用される pin を設定します。",
|
||||
"pins.analogWritePin":"アナログ コネクタの値を設定します。値は、0 から 1023年の間で構成する必要があります。",
|
||||
"pins.digitalReadPin":"0 または 1 のいずれかとして指定した pin またはコネクタを読む",
|
||||
"pins.digitalWritePin":"0 または 1 のいずれかにピンまたはコネクタの値を設定します。",
|
||||
"pins.i2cReadNumber":"7 ビット I2C アドレスから 1 つの番号を読み取る。",
|
||||
"pins.i2cWriteNumber":"7 ビット I2C アドレスに 1 つの番号を書きます。",
|
||||
"pins.map":"1 つの範囲から別の数字を再マップします。つまり、'から低 'の値 'に高'、値、中間などに中間値方' に ''から高' の値マッピングでしょう。",
|
||||
"pins.onPulsed":"デジタル入力にこの pin を構成し、タイムスタンプがこのピンは '高' または '低' 期間のイベントを生成します。",
|
||||
"pins.pulseDuration":"マイクロ秒で最後のパルスの期間を取得します。この関数は、' onPulsed ' ハンドラーから呼び出す必要があります。",
|
||||
"pins.servoSetPulse":"アナログ\/pwm 出力としてこの IO ピンを構成します、20 ms にする期間を構成し、それは与えられる値に基づいて、パルス幅を設定します * * マイクロ秒 * * または '' 1\/1000年ミリ秒です。",
|
||||
"pins.servoWritePin":"それに応じてシャフトを制御するサーボに値を書き込みます。標準サーボの軸をその方向に移動 (単位は度)、シャフトの角度に設定されます。連続回転サーボに、これは (' 0 ' 1 つの方向、「180」に満ちているフルスピード速度の他、と '' 90」の動きではないことに近い値であること) とサーボ スピードを設定します。",
|
||||
"pins.setPull":"このピンのプルを構成します。",
|
||||
"serial":"シリアル接続を介してデータを読み書きします。",
|
||||
"serial.readLine":"シリアル ポートからテキスト行を読み取ります。",
|
||||
"serial.redirect":"USBTX と USBRX 以外のピンを使用するシリアルのインスタンスの動的な設定。",
|
||||
"serial.writeLine":"連続するテキストの行を印刷します。",
|
||||
"serial.writeNumber":"連続する数値値を出力します。",
|
||||
"serial.writeString":"シリアル接続を使用してテキストの一部を送信します。",
|
||||
"serial.writeValue":"書き込み、「名前: 値」ペアのシリアル ライン。"
|
||||
"Math.randomBoolean": "「真」か「偽」をランダムに生成します。",
|
||||
"basic.clearScreen": "すべてのLEDをオフにします。",
|
||||
"basic.forever": "ずっとコードをバックグラウンドで繰り返し実行します。",
|
||||
"basic.pause": "ミリ秒で指定された時間、一時停止します。",
|
||||
"basic.plotLeds": "LED 画面にイメージを描画します。",
|
||||
"basic.showIcon": "選択されたアイコンを、LED画面に表示します。",
|
||||
"basic.showLeds": "LED 画面にイメージを描画します。",
|
||||
"basic.showNumber": "画面上のに数字をスクロールさせます。数が1桁で、画面上に収まる場合、スクロールしません。",
|
||||
"basic.showString": "一度に1文字ずつ、テキストを画面に表示します。1文字だけの場合は、スクロールしません。",
|
||||
"input.acceleration": "加速度値を取得します。(スクリーンを上に向けて置いたとき、xは0、yも0、zは-1024です)",
|
||||
"input.buttonIsPressed": "``A`` か ``B`` のボタンが押されているかを取得します。",
|
||||
"input.compassHeading": "現在の、コンパスの値を取得します。",
|
||||
"input.lightLevel": "LEDスクリーンに当たる光の明るさを 0 (暗い) から 255 (明るい)の範囲で取得します。",
|
||||
"input.onButtonPressed": "ボタン (``A``, ``B`` or both ``A+B``) が押されたときに実行されます。",
|
||||
"input.onGesture": "ジェスチャ(例えば、ゆさぶる)が行われたときに実行します。",
|
||||
"input.onPinPressed": "ピンが押されたときに実行されます。",
|
||||
"input.onPinReleased": "ピンがタッチされなくなったときに実行されます。",
|
||||
"input.pinIsPressed": "ピンがタッチされているかの状態を取得します。状態を取得するためには、グラウンドにつながっている必要があります。",
|
||||
"input.rotation": "デバイスの、ピッチかロールを度数で取得します。",
|
||||
"input.runningTime": "電源が入ってから経過したミリ秒数を取得します。",
|
||||
"input.temperature": "摂氏で、温度を取得します。",
|
||||
"led.brightness": "画面の明るさを 0 (オフ) 255 (フルに明るい)の範囲で取得します。",
|
||||
"led.enable": "画面を表示、または非表示にします。",
|
||||
"led.plot": "X、Y座標で指定したLEDを点灯します。(0, 0)が左上です。",
|
||||
"led.point": "X、Y座標で指定されたLEDの、ON/OFFの状態を取得します。(0,0)が左上です。",
|
||||
"led.setBrightness": "画面の明るさを 0 (オフ) 255 (フルに明るい)の範囲で設定します。",
|
||||
"led.stopAnimation": "現在のアニメーションをキャンセルし、保留中のアニメーションもクリアします。",
|
||||
"led.toggle": "指定された場所のLEDの点滅を切り替えます。",
|
||||
"led.unplot": "X、Y座標で指定された場所のLEDを消灯します。(0, 0) は左上です。",
|
||||
"music.beat": "拍の長さをミリ秒で返します",
|
||||
"music.changeTempoBy": "テンポを指定した数だけ増減します。",
|
||||
"music.playTone": "指定された長さの間、``P0``から音を鳴らします。",
|
||||
"music.rest": "``P0`` から、指定された時間だけ音を鳴らさない様にします。",
|
||||
"music.rest|param|ms": "残り時間(ミリ秒)",
|
||||
"music.ringTone": "ピン``P0`` から音をを再生します。",
|
||||
"music.setTempo": "テンポを設定します",
|
||||
"music.tempo": "現在のテンポを、bpm (1分間あたりの拍の数)で返します。テンポの値が大きくなると、より早く音楽が再生されます。",
|
||||
"serial.readLine": "シリアルポートからテキストを読み取ります。"
|
||||
}
|
@ -106,7 +106,8 @@
|
||||
"String.fromCharCode|block": "文字コード %code|の文字",
|
||||
"basic.clearScreen|block": "表示を消す",
|
||||
"basic.forever|block": "ずっと",
|
||||
"basic.pause|block": "ひと休み(ミリ秒) %pause",
|
||||
"basic.pause|block": "一時停止(ミリ秒) %pause",
|
||||
"basic.showIcon|block": "アイコン %i を表示",
|
||||
"basic.showLeds|block": "LEDに表示",
|
||||
"basic.showNumber|block": "数を表示|%number",
|
||||
"basic.showString|block": "文字列を表示|%text",
|
||||
@ -121,9 +122,12 @@
|
||||
"images.createImage|block": "画像を作成",
|
||||
"images|block": "画像",
|
||||
"input.acceleration|block": "加速度(ミリG)|%NAME",
|
||||
"input.buttonIsPressed|block": "ボタン|%NAME|が押されている",
|
||||
"input.compassHeading|block": "方角(°)",
|
||||
"input.lightLevel|block": "明るさ",
|
||||
"input.magneticForce|block": "磁力(µT)|%NAME",
|
||||
"input.onButtonPressed|block": "ボタン|%NAME|が押されたとき",
|
||||
"input.onGesture|block": "%NAME|とき",
|
||||
"input.onPinPressed|block": "端子 %name|がタッチされたとき",
|
||||
"input.onPinReleased|block": "端子 %NAME|がタッチされなくなったとき",
|
||||
"input.pinIsPressed|block": "端子 %NAME|がタッチされている",
|
||||
@ -134,11 +138,17 @@
|
||||
"led.brightness|block": "明るさ",
|
||||
"led.enable|block": "表示をオンまたはオフにする %on",
|
||||
"led.plot|block": "点灯|x %x|y %y",
|
||||
"led.point|block": "点灯しているか|x %x|y %y",
|
||||
"led.setBrightness|block": "明るさを設定する %value",
|
||||
"led.stopAnimation|block": "アニメーションを停止",
|
||||
"led.toggle|block": "反転|x %x|y %y",
|
||||
"led.unplot|block": "消灯|x %x|y %y",
|
||||
"led|block": "LED",
|
||||
"music.beat|block": "%fraction|拍",
|
||||
"music.changeTempoBy|block": "テンポを増減する(bpm)|%value",
|
||||
"music.playTone|block": "音 %note=device_note|を %duration=device_beat|拍の間鳴らす",
|
||||
"music.rest|block": "休符(ミリ秒)|%duration=device_beat",
|
||||
"music.ringTone|block": "音を鳴らす(Hz)|%note=device_note",
|
||||
"music.setTempo|block": "テンポを設定する(bpm)|%value",
|
||||
"music.tempo|block": "テンポ(bpm)",
|
||||
"music|block": "音楽",
|
||||
|
@ -7,6 +7,19 @@
|
||||
"AcceleratorRange.OneG|block": "1 g",
|
||||
"AcceleratorRange.TwoG": "Akselerometerets måleområde er opp til 2 ganger tyngekraften",
|
||||
"AcceleratorRange.TwoG|block": "2 g",
|
||||
"AnalogPin.P11|block": "P11 (bare utgang)",
|
||||
"AnalogPin.P12|block": "P12 (bare utgang)",
|
||||
"AnalogPin.P13|block": "P13 (bare utgang)",
|
||||
"AnalogPin.P14|block": "P14 (bare utgang)",
|
||||
"AnalogPin.P15|block": "P15 (bare utgang)",
|
||||
"AnalogPin.P16|block": "P16 (bare utgang)",
|
||||
"AnalogPin.P19|block": "P19 (bare utgang)",
|
||||
"AnalogPin.P20|block": "P20 (bare utgang)",
|
||||
"AnalogPin.P5|block": "P5 (bare utgang)",
|
||||
"AnalogPin.P6|block": "P6 (bare utgang)",
|
||||
"AnalogPin.P7|block": "P7 (bare utgang)",
|
||||
"AnalogPin.P8|block": "P8 (bare utgang)",
|
||||
"AnalogPin.P9|block": "P9 (bare utgang)",
|
||||
"BaudRate.BaudRate115200|block": "115200",
|
||||
"BaudRate.BaudRate9600|block": "9600",
|
||||
"BeatFraction.Breve|block": "4",
|
||||
@ -31,6 +44,8 @@
|
||||
"Direction.Right|block": "høyre",
|
||||
"DisplayMode.BackAndWhite|block": "svart og hvitt",
|
||||
"DisplayMode.Greyscale|block": "gråtone",
|
||||
"EventCreationMode.CreateAndFire": "En hendelse opprettes og den tilhørende hendelsesbehandleren startes. (Må ikke brukes inne i et interrupt.)",
|
||||
"EventCreationMode.CreateOnly": "En hendelse opprettes, men behandling av hendelsen startes ikke.",
|
||||
"Gesture.EightG": "Hendelse når et støt på over 8G detekteres",
|
||||
"Gesture.EightG|block": "8 G",
|
||||
"Gesture.FreeFall": "Hendelse når micro:bit faller!",
|
||||
@ -121,7 +136,12 @@
|
||||
"PinPullMode.PullUp|block": "høy",
|
||||
"PulseValue.High|block": "høy",
|
||||
"PulseValue.Low|block": "lav",
|
||||
"Rotation.Pitch|block": "vinkel forover-bakover",
|
||||
"Rotation.Roll|block": "vinkel høyre-venstre",
|
||||
"String.charAt|block": "tegn fra %this=text|posisjon %pos",
|
||||
"String.compare|block": "sammenlign %this=text| med %that",
|
||||
"String.fromCharCode|block": "tekst fra tegnverdi %code",
|
||||
"String.substr|block": "del av %this=text|fra posisjon %start|med lengde %length",
|
||||
"String|block": "Tekst",
|
||||
"basic.clearScreen|block": "tøm skjermen",
|
||||
"basic.forever|block": "gjenta for alltid",
|
||||
@ -138,6 +158,7 @@
|
||||
"game.addScore|block": "endre poengsum med|%points",
|
||||
"game.gameOver|block": "game over",
|
||||
"game.score|block": "poengsum",
|
||||
"game.setScore|block": "sett poengsum til %points",
|
||||
"game.startCountdown|block": "start nedtelling|(ms) %duration",
|
||||
"game|block": "spill",
|
||||
"images.createBigImage|block": "lag stort bilde",
|
||||
@ -159,20 +180,28 @@
|
||||
"input.temperature|block": "temperatur (°C)",
|
||||
"input|block": "inngang",
|
||||
"led.brightness|block": "lysstyrke",
|
||||
"led.enable|block": "skjerm på %on",
|
||||
"led.plotBarGraph|block": "søylediagram av %value |opp til %high",
|
||||
"led.plot|block": "tenn|x %x|y %y",
|
||||
"led.point|block": "lyser i|x %x|y %y",
|
||||
"led.setBrightness|block": "sett lysstyrke %value",
|
||||
"led.stopAnimation|block": "stopp animasjon",
|
||||
"led.toggle|block": "bytt|x %x|y %y",
|
||||
"led.unplot|block": "slukk|x %x|y %y",
|
||||
"led|block": "LED",
|
||||
"music.beat|block": "%fraction|takt",
|
||||
"music.changeTempoBy|block": "endre tempo med (bpm)|%value",
|
||||
"music.noteFrequency|block": "%note",
|
||||
"music.playTone|block": "spill|tone %note=device_note|i %duration=device_beat",
|
||||
"music.rest|block": "pause (ms) |%duration = device_beat",
|
||||
"music.ringTone|block": "ring tone (Hz)|%note=device_note",
|
||||
"music.setTempo|block": "sett tempo til (bpm)|%value",
|
||||
"music.tempo|block": "tempo (bpm)",
|
||||
"music|block": "musikk",
|
||||
"pins.analogPitch|block": "analog tone %frequency|i (ms) %ms",
|
||||
"pins.analogReadPin|block": "les analogverdi|fra %name",
|
||||
"pins.analogSetPeriod|block": "analog sett periodetid|på %pin|til (µs) %micros",
|
||||
"pins.analogSetPitchPin|block": "analog tone kontakt %name",
|
||||
"pins.analogWritePin|block": "skriv analog|til %name|verdi %value",
|
||||
"pins.digitalReadPin|block": "les digitalverdi|fra %name",
|
||||
"pins.digitalWritePin|block": "skriv digital|til %name|verdi %value",
|
||||
@ -183,15 +212,29 @@
|
||||
"pins.pulseDuration|block": "pulslengde (µs)",
|
||||
"pins.servoSetPulse|block": "servo skriv pulslengde|på %value|til (µs) %micros",
|
||||
"pins.servoWritePin|block": "servo skriv|til %name|verdi %value",
|
||||
"pins.setEvents|block": "la kontakt %pin|lage %type|-hendelser",
|
||||
"pins.setPull|block": "sett utilkoblet verdi|for %pin|til %pull",
|
||||
"pins.spiWrite|block": "SPI skriv %value",
|
||||
"pins|block": "tilkoblinger",
|
||||
"serial.onDataReceived|block": "når serieport|mottar %delimiters=serial_delimiter_conv",
|
||||
"serial.readLine|block": "serieport|les linje",
|
||||
"serial.readString|block": "serieport|les tekst",
|
||||
"serial.readUntil|block": "serieport|les fram til %delimiter=serial_delimiter_conv",
|
||||
"serial.redirect|block": "sett serieport|tilkobling|send %tx| motta %rx|med hastighet %rate",
|
||||
"serial.writeLine|block": "serieport|skriv linje %text",
|
||||
"serial.writeNumber|block": "serieport|skriv tall %value",
|
||||
"serial.writeString|block": "serieport|skriv tekst %text",
|
||||
"serial.writeValue|block": "serieport|skriv verdi %name|= %value",
|
||||
"serial|block": "føljetong",
|
||||
"{id:category}Basic": "Basis",
|
||||
"{id:category}Control": "Styring",
|
||||
"{id:category}Game": "Spill",
|
||||
"{id:category}Images": "Bilder",
|
||||
"{id:category}Input": "Inndata",
|
||||
"{id:category}Led": "Skjerm",
|
||||
"{id:category}Math": "Matematikk",
|
||||
"{id:category}Music": "Musikk",
|
||||
"{id:category}Pins": "Tilkobling",
|
||||
"{id:category}Serial": "Serieport",
|
||||
"{id:category}String": "Tekst"
|
||||
}
|
2
libs/core/enums.d.ts
vendored
@ -284,7 +284,7 @@ declare namespace led {
|
||||
P5 = 12, // MICROBIT_ID_IO_P5
|
||||
//% block="P6 (write only)"
|
||||
P6 = 13, // MICROBIT_ID_IO_P6
|
||||
//% block="P5 (write only)"
|
||||
//% block="P7 (write only)"
|
||||
P7 = 14, // MICROBIT_ID_IO_P7
|
||||
//% block="P8 (write only)"
|
||||
P8 = 15, // MICROBIT_ID_IO_P8
|
||||
|
@ -10,7 +10,7 @@ namespace Math {
|
||||
* Generates a `true` or `false` value randomly, just like flipping a coin.
|
||||
*/
|
||||
//% blockId=logic_random block="pick random true or false"
|
||||
//% help=math/random-boolean color=230
|
||||
//% help=math/random-boolean
|
||||
export function randomBoolean(): boolean {
|
||||
return Math.random(2) == 0;
|
||||
}
|
||||
|
@ -27,85 +27,122 @@ THE SOFTWARE.
|
||||
|
||||
enum IconNames {
|
||||
//% block="heart"
|
||||
//% blockImage=1
|
||||
Heart = 0,
|
||||
//% block="small heart"
|
||||
//% blockImage=1
|
||||
SmallHeart,
|
||||
//% block="yes"
|
||||
//% blockImage=1
|
||||
Yes,
|
||||
//% block="no"
|
||||
//% blockImage=1
|
||||
No,
|
||||
//% block="happy"
|
||||
//% blockImage=1
|
||||
Happy,
|
||||
//% block="sad"
|
||||
//% blockImage=1
|
||||
Sad,
|
||||
//% block="confused"
|
||||
//% blockImage=1
|
||||
Confused,
|
||||
//% block="angry"
|
||||
//% blockImage=1
|
||||
Angry,
|
||||
//% block="asleep"
|
||||
//% blockImage=1
|
||||
Asleep,
|
||||
//% block="surprised"
|
||||
//% blockImage=1
|
||||
Surprised,
|
||||
//% block="silly"
|
||||
//% blockImage=1
|
||||
Silly,
|
||||
//% block="fabulous"
|
||||
//% blockImage=1
|
||||
Fabulous,
|
||||
//% block="meh"
|
||||
//% blockImage=1
|
||||
Meh,
|
||||
//% block="t-shirt"
|
||||
//% blockImage=1
|
||||
TShirt,
|
||||
//% block="roller skate"
|
||||
//% blockImage=1
|
||||
Rollerskate,
|
||||
//% block="duck"
|
||||
//% blockImage=1
|
||||
Duck,
|
||||
//% block="house"
|
||||
//% blockImage=1
|
||||
House,
|
||||
//% block="tortoise"
|
||||
//% blockImage=1
|
||||
Tortoise,
|
||||
//% block="butterfly"
|
||||
//% blockImage=1
|
||||
Butterfly,
|
||||
//% block="stick figure"
|
||||
//% blockImage=1
|
||||
StickFigure,
|
||||
//% block="ghost"
|
||||
//% blockImage=1
|
||||
Ghost,
|
||||
//% block="sword"
|
||||
//% blockImage=1
|
||||
Sword,
|
||||
//% block="giraffe"
|
||||
//% blockImage=1
|
||||
Giraffe,
|
||||
//% block="skull"
|
||||
//% blockImage=1
|
||||
Skull,
|
||||
//% block="umbrella"
|
||||
//% blockImage=1
|
||||
Umbrella,
|
||||
//% block="snake"
|
||||
//% blockImage=1
|
||||
Snake,
|
||||
//% block="rabbit"
|
||||
//% blockImage=1
|
||||
Rabbit,
|
||||
//% block="cow"
|
||||
//% blockImage=1
|
||||
Cow,
|
||||
//% block="quarter note"
|
||||
//% blockImage=1
|
||||
QuarterNote,
|
||||
//% block="eigth note"
|
||||
//% blockImage=1
|
||||
EigthNote,
|
||||
//% block="pitchfork"
|
||||
//% blockImage=1
|
||||
Pitchfork,
|
||||
//% block="pac man"
|
||||
Pacman,
|
||||
//% block="target"
|
||||
//% blockImage=1
|
||||
Target,
|
||||
//% block="triangle"
|
||||
//% blockImage=1
|
||||
Triangle,
|
||||
//% block="left triangle"
|
||||
//% blockImage=1
|
||||
LeftTriangle,
|
||||
//% block="chess board"
|
||||
//% blockImage=1
|
||||
Chessboard,
|
||||
//% block="diamond"
|
||||
//% blockImage=1
|
||||
Diamond,
|
||||
//% block="small diamond"
|
||||
//% blockImage=1
|
||||
SmallDiamond,
|
||||
//% block="square"
|
||||
//% blockImage=1
|
||||
Square,
|
||||
//% block="small square"
|
||||
SmallSquare,
|
||||
//% blockImage=1
|
||||
SmallSquare
|
||||
}
|
||||
|
||||
enum ArrowNames {
|
||||
@ -136,6 +173,7 @@ namespace basic {
|
||||
//% blockId=basic_show_icon
|
||||
//% block="show icon %i" icon="\uf00a"
|
||||
//% parts="ledmatrix"
|
||||
//% help=basic/show-icon
|
||||
export function showIcon(icon: IconNames) {
|
||||
let res = images.iconImage(icon)
|
||||
res.showImage(0)
|
||||
@ -146,6 +184,7 @@ namespace basic {
|
||||
//% block="show arrow %i=device_arrow"
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true
|
||||
//% help=basic/show-arrow
|
||||
export function showArrow(i: number) {
|
||||
let res = images.arrowImage(i)
|
||||
res.showImage(0)
|
||||
@ -453,12 +492,6 @@ namespace images {
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .`;
|
||||
case IconNames.Pacman: return `
|
||||
. # # # #
|
||||
# # # # .
|
||||
# # # . .
|
||||
# # # # .
|
||||
. # # # #`;
|
||||
case IconNames.Target: return `
|
||||
. . # . .
|
||||
. # # # .
|
||||
|
@ -112,7 +112,7 @@ enum class Gesture {
|
||||
EightG = MICROBIT_ACCELEROMETER_EVT_8G
|
||||
};
|
||||
|
||||
//% color=300 weight=99 icon="\uf192"
|
||||
//% color=#B4009E weight=99 icon="\uf192"
|
||||
namespace input {
|
||||
/**
|
||||
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
||||
@ -212,7 +212,7 @@ namespace input {
|
||||
double y = uBit.accelerometer.getY();
|
||||
double z = uBit.accelerometer.getZ();
|
||||
return (int)sqrt(x*x+y*y+z*z);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
||||
|
@ -8,7 +8,7 @@ enum class DisplayMode_ {
|
||||
// TODO DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
|
||||
};
|
||||
|
||||
//% color=3 weight=35 icon="\uf205"
|
||||
//% color=#5C2D91 weight=97 icon="\uf205"
|
||||
namespace led {
|
||||
|
||||
/**
|
||||
@ -93,7 +93,7 @@ namespace led {
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on or off the display
|
||||
* Turns on or off the display
|
||||
*/
|
||||
//% help=led/enable blockId=device_led_enable block="led enable %on"
|
||||
//% advanced=true parts="ledmatrix"
|
||||
|
119
libs/core/melodies.ts
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
// Melodies from file microbitmusictunes.c https://github.com/bbcmicrobit/MicroPython
|
||||
|
||||
enum Melodies {
|
||||
//% block="dadadum" blockIdentity=music.builtInMelody
|
||||
Dadadadum = 0,
|
||||
//% block="entertainer" blockIdentity=music.builtInMelody
|
||||
Entertainer,
|
||||
//% block="prelude" blockIdentity=music.builtInMelody
|
||||
Prelude,
|
||||
//% block="ode" blockIdentity=music.builtInMelody
|
||||
Ode,
|
||||
//% block="nyan" blockIdentity=music.builtInMelody
|
||||
Nyan,
|
||||
//% block="ringtone" blockIdentity=music.builtInMelody
|
||||
Ringtone,
|
||||
//% block="funk" blockIdentity=music.builtInMelody
|
||||
Funk,
|
||||
//% block="blues" blockIdentity=music.builtInMelody
|
||||
Blues,
|
||||
//% block="birthday" blockIdentity=music.builtInMelody
|
||||
Birthday,
|
||||
//% block="wedding" blockIdentity=music.builtInMelody
|
||||
Wedding,
|
||||
//% block="funereal" blockIdentity=music.builtInMelody
|
||||
Funeral,
|
||||
//% block="punchline" blockIdentity=music.builtInMelody
|
||||
Punchline,
|
||||
//% block="baddy" blockIdentity=music.builtInMelody
|
||||
Baddy,
|
||||
//% block="chase" blockIdentity=music.builtInMelody
|
||||
Chase,
|
||||
//% block="ba ding" blockIdentity=music.builtInMelody
|
||||
BaDing,
|
||||
//% block="wawawawaa" blockIdentity=music.builtInMelody
|
||||
Wawawawaa,
|
||||
//% block="jump up" blockIdentity=music.builtInMelody
|
||||
JumpUp,
|
||||
//% block="jump down" blockIdentity=music.builtInMelody
|
||||
JumpDown,
|
||||
//% block="power up" blockIdentity=music.builtInMelody
|
||||
PowerUp,
|
||||
//% block="power down" blockIdentity=music.builtInMelody
|
||||
PowerDown,
|
||||
}
|
||||
|
||||
namespace music {
|
||||
|
||||
export function getMelody(melody: Melodies): string[] {
|
||||
switch (melody) {
|
||||
case Melodies.Dadadadum:
|
||||
return ['r4:2', 'g', 'g', 'g', 'eb:8', 'r:2', 'f', 'f', 'f', 'd:8'];
|
||||
case Melodies.Entertainer:
|
||||
return ['d4:1', 'd#', 'e', 'c5:2', 'e4:1', 'c5:2', 'e4:1', 'c5:3', 'c:1', 'd', 'd#', 'e', 'c', 'd', 'e:2', 'b4:1', 'd5:2', 'c:4'];
|
||||
case Melodies.Prelude:
|
||||
return ['c4:1', 'e', 'g', 'c5', 'e', 'g4', 'c5', 'e', 'c4', 'e', 'g', 'c5', 'e', 'g4', 'c5', 'e', 'c4', 'd', 'g', 'd5', 'f', 'g4', 'd5', 'f', 'c4', 'd', 'g', 'd5', 'f', 'g4', 'd5', 'f', 'b3', 'd4', 'g', 'd5', 'f', 'g4', 'd5', 'f', 'b3', 'd4', 'g', 'd5', 'f', 'g4', 'd5', 'f', 'c4', 'e', 'g', 'c5', 'e', 'g4', 'c5', 'e', 'c4', 'e', 'g', 'c5', 'e', 'g4', 'c5', 'e'];
|
||||
case Melodies.Ode:
|
||||
return ['e4', 'e', 'f', 'g', 'g', 'f', 'e', 'd', 'c', 'c', 'd', 'e', 'e:6', 'd:2', 'd:8', 'e:4', 'e', 'f', 'g', 'g', 'f', 'e', 'd', 'c', 'c', 'd', 'e', 'd:6', 'c:2', 'c:8'];
|
||||
case Melodies.Nyan:
|
||||
return ['f#5:2', 'g#', 'c#:1', 'd#:2', 'b4:1', 'd5:1', 'c#', 'b4:2', 'b', 'c#5', 'd', 'd:1', 'c#', 'b4:1', 'c#5:1', 'd#', 'f#', 'g#', 'd#', 'f#', 'c#', 'd', 'b4', 'c#5', 'b4', 'd#5:2', 'f#', 'g#:1', 'd#', 'f#', 'c#', 'd#', 'b4', 'd5', 'd#', 'd', 'c#', 'b4', 'c#5', 'd:2', 'b4:1', 'c#5', 'd#', 'f#', 'c#', 'd', 'c#', 'b4', 'c#5:2', 'b4', 'c#5', 'b4', 'f#:1', 'g#', 'b:2', 'f#:1', 'g#', 'b', 'c#5', 'd#', 'b4', 'e5', 'd#', 'e', 'f#', 'b4:2', 'b', 'f#:1', 'g#', 'b', 'f#', 'e5', 'd#', 'c#', 'b4', 'f#', 'd#', 'e', 'f#', 'b:2', 'f#:1', 'g#', 'b:2', 'f#:1', 'g#', 'b', 'b', 'c#5', 'd#', 'b4', 'f#', 'g#', 'f#', 'b:2', 'b:1', 'a#', 'b', 'f#', 'g#', 'b', 'e5', 'd#', 'e', 'f#', 'b4:2', 'c#5'];
|
||||
case Melodies.Ringtone:
|
||||
return ['c4:1', 'd', 'e:2', 'g', 'd:1', 'e', 'f:2', 'a', 'e:1', 'f', 'g:2', 'b', 'c5:4'];
|
||||
case Melodies.Funk:
|
||||
return ['c2:2', 'c', 'd#', 'c:1', 'f:2', 'c:1', 'f:2', 'f#', 'g', 'c', 'c', 'g', 'c:1', 'f#:2', 'c:1', 'f#:2', 'f', 'd#'];
|
||||
case Melodies.Blues:
|
||||
return ['c2:2', 'e', 'g', 'a', 'a#', 'a', 'g', 'e', 'c2:2', 'e', 'g', 'a', 'a#', 'a', 'g', 'e', 'f', 'a', 'c3', 'd', 'd#', 'd', 'c', 'a2', 'c2:2', 'e', 'g', 'a', 'a#', 'a', 'g', 'e', 'g', 'b', 'd3', 'f', 'f2', 'a', 'c3', 'd#', 'c2:2', 'e', 'g', 'e', 'g', 'f', 'e', 'd'];
|
||||
case Melodies.Birthday:
|
||||
return ['c4:3', 'c:1', 'd:4', 'c:4', 'f', 'e:8', 'c:3', 'c:1', 'd:4', 'c:4', 'g', 'f:8', 'c:3', 'c:1', 'c5:4', 'a4', 'f', 'e', 'd', 'a#:3', 'a#:1', 'a:4', 'f', 'g', 'f:8'];
|
||||
case Melodies.Wedding:
|
||||
return ['c4:4', 'f:3', 'f:1', 'f:8', 'c:4', 'g:3', 'e:1', 'f:8', 'c:4', 'f:3', 'a:1', 'c5:4', 'a4:3', 'f:1', 'f:4', 'e:3', 'f:1', 'g:8'];
|
||||
case Melodies.Funeral:
|
||||
return ['c3:4', 'c:3', 'c:1', 'c:4', 'd#:3', 'd:1', 'd:3', 'c:1', 'c:3', 'b2:1', 'c3:4'];
|
||||
case Melodies.Punchline:
|
||||
return ['c4:3', 'g3:1', 'f#', 'g', 'g#:3', 'g', 'r', 'b', 'c4'];
|
||||
case Melodies.Baddy:
|
||||
return ['c3:3', 'r', 'd:2', 'd#', 'r', 'c', 'r', 'f#:8'];
|
||||
case Melodies.Chase:
|
||||
return ['a4:1', 'b', 'c5', 'b4', 'a:2', 'r', 'a:1', 'b', 'c5', 'b4', 'a:2', 'r', 'a:2', 'e5', 'd#', 'e', 'f', 'e', 'd#', 'e', 'b4:1', 'c5', 'd', 'c', 'b4:2', 'r', 'b:1', 'c5', 'd', 'c', 'b4:2', 'r', 'b:2', 'e5', 'd#', 'e', 'f', 'e', 'd#', 'e'];
|
||||
case Melodies.BaDing:
|
||||
return ['b5:1', 'e6:3'];
|
||||
case Melodies.Wawawawaa:
|
||||
return ['e3:3', 'r:1', 'd#:3', 'r:1', 'd:4', 'r:1', 'c#:8'];
|
||||
case Melodies.JumpUp:
|
||||
return ['c5:1', 'd', 'e', 'f', 'g'];
|
||||
case Melodies.JumpDown:
|
||||
return ['g5:1', 'f', 'e', 'd', 'c'];
|
||||
case Melodies.PowerUp:
|
||||
return ['g4:1', 'c5', 'e', 'g:2', 'e:1', 'g:3'];
|
||||
case Melodies.PowerDown:
|
||||
return ['g5:1', 'd#', 'c', 'g4:2', 'b:1', 'c5:3'];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -1,112 +1,112 @@
|
||||
enum Note {
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=262
|
||||
C = 262,
|
||||
//% block=C#
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=277
|
||||
CSharp = 277,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=294
|
||||
D = 294,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=311
|
||||
Eb = 311,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=330
|
||||
E = 330,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=349
|
||||
F = 349,
|
||||
//% block=F#
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=370
|
||||
FSharp = 370,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=392
|
||||
G = 392,
|
||||
//% block=G#
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=415
|
||||
GSharp = 415,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=440
|
||||
A = 440,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=466
|
||||
Bb = 466,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=494
|
||||
B = 494,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=131
|
||||
C3 = 131,
|
||||
//% block=C#3
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=139
|
||||
CSharp3 = 139,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=147
|
||||
D3 = 147,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=156
|
||||
Eb3 = 156,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=165
|
||||
E3 = 165,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=175
|
||||
F3 = 175,
|
||||
//% block=F#3
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=185
|
||||
FSharp3 = 185,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=196
|
||||
G3 = 196,
|
||||
//% block=G#3
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=208
|
||||
GSharp3 = 208,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=220
|
||||
A3 = 220,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=233
|
||||
Bb3 = 233,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=247
|
||||
B3 = 247,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=262
|
||||
C4 = 262,
|
||||
//% block=C#4
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=277
|
||||
CSharp4 = 277,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=294
|
||||
D4 = 294,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=311
|
||||
Eb4 = 311,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=330
|
||||
E4 = 330,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=349
|
||||
F4 = 349,
|
||||
//% block=F#4
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=370
|
||||
FSharp4 = 370,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=392
|
||||
G4 = 392,
|
||||
//% block=G#4
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=415
|
||||
GSharp4 = 415,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=440
|
||||
A4 = 440,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=466
|
||||
Bb4 = 466,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=494
|
||||
B4 = 494,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=523
|
||||
C5 = 523,
|
||||
//% block=C#5
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=555
|
||||
CSharp5 = 555,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=587
|
||||
D5 = 587,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=622
|
||||
Eb5 = 622,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=659
|
||||
E5 = 659,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=698
|
||||
F5 = 698,
|
||||
//% block=F#5
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=740
|
||||
FSharp5 = 740,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=784
|
||||
G5 = 784,
|
||||
//% block=G#5
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=831
|
||||
GSharp5 = 831,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=880
|
||||
A5 = 880,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
//% blockIdentity=music.noteFrequency enumval=932
|
||||
Bb5 = 932,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
B5 = 989,
|
||||
//% blockIdentity=music.noteFrequency enumval=988
|
||||
B5 = 988,
|
||||
}
|
||||
|
||||
enum BeatFraction {
|
||||
@ -126,12 +126,24 @@ enum BeatFraction {
|
||||
Breve = 64
|
||||
}
|
||||
|
||||
enum MelodyOptions {
|
||||
//% block="once""
|
||||
Once = 1,
|
||||
//% block="forever"
|
||||
Forever = 2,
|
||||
//% block="once in background"
|
||||
OnceInBackground = 4,
|
||||
//% block="forever in background"
|
||||
ForeverInBackground = 8
|
||||
}
|
||||
|
||||
/**
|
||||
* Generation of music tones through pin ``P0``.
|
||||
*/
|
||||
//% color=#D83B01 weight=98 icon="\uf025"
|
||||
namespace music {
|
||||
let beatsPerMinute: number = 120;
|
||||
let freqTable: number[] = [];
|
||||
|
||||
/**
|
||||
* Plays a tone through pin ``P0`` for the given duration.
|
||||
@ -141,6 +153,7 @@ namespace music {
|
||||
//% help=music/play-tone weight=90
|
||||
//% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" blockGap=8
|
||||
//% parts="headphone"
|
||||
//% useEnumVal = 1
|
||||
export function playTone(frequency: number, ms: number): void {
|
||||
pins.analogPitch(frequency, ms);
|
||||
}
|
||||
@ -152,6 +165,7 @@ namespace music {
|
||||
//% help=music/ring-tone weight=80
|
||||
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" blockGap=8
|
||||
//% parts="headphone"
|
||||
//% useEnumVal = 1
|
||||
export function ringTone(frequency: number): void {
|
||||
pins.analogPitch(frequency, 0);
|
||||
}
|
||||
@ -175,12 +189,15 @@ namespace music {
|
||||
//% weight=50 help=music/note-frequency
|
||||
//% blockId=device_note block="%note"
|
||||
//% shim=TD_ID blockHidden=true
|
||||
//% blockFieldEditor="note_editor"
|
||||
//% useEnumVal = 1
|
||||
export function noteFrequency(name: Note): number {
|
||||
return name;
|
||||
}
|
||||
|
||||
function init() {
|
||||
if (beatsPerMinute <= 0) beatsPerMinute = 120;
|
||||
if (freqTable.length == 0) freqTable = [28, 29, 31, 33, 35, 37, 39, 41, 44, 46, 49, 52, 55, 58, 62, 65, 69, 73, 78, 82, 87, 92, 98, 104, 110, 117, 123, 131, 139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247, 262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494, 523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988, 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976, 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951, 4186]
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,4 +253,127 @@ namespace music {
|
||||
beatsPerMinute = Math.max(1, bpm);
|
||||
}
|
||||
}
|
||||
|
||||
let currentMelody: Melody;
|
||||
let currentBackgroundMelody: Melody;
|
||||
|
||||
/**
|
||||
* Gets the melody array of a built-in melody.
|
||||
* @param name the note name, eg: Note.C
|
||||
*/
|
||||
//% weight=50 help=music/builtin-melody
|
||||
//% blockId=device_builtin_melody block="%melody"
|
||||
//% blockHidden=true
|
||||
export function builtInMelody(melody: Melodies): string[] {
|
||||
return getMelody(melody);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts playing a melody through pin ``P0``.
|
||||
* Notes are expressed as a string of characters with this format: NOTE[octave][:duration]
|
||||
* @param melody the melody array to play, eg: ['g5:1']
|
||||
* @param options melody options, once / forever, in the foreground / background
|
||||
*/
|
||||
//% help=music/start-melody weight=60
|
||||
//% blockId=device_start_melody block="start|melody %melody=device_builtin_melody| repeating %options"
|
||||
//% parts="headphone"
|
||||
export function beginMelody(melodyArray: string[], options: MelodyOptions = MelodyOptions.Once) {
|
||||
init();
|
||||
if (currentMelody != undefined) {
|
||||
if (((options & MelodyOptions.OnceInBackground) == 0)
|
||||
&& ((options & MelodyOptions.ForeverInBackground) == 0)
|
||||
&& currentMelody.background == true) {
|
||||
currentBackgroundMelody = currentMelody;
|
||||
}
|
||||
currentMelody = new Melody(melodyArray, options);
|
||||
} else {
|
||||
currentMelody = new Melody(melodyArray, options);
|
||||
// Only start the fiber once
|
||||
control.inBackground(() => {
|
||||
while (currentMelody.hasNextNote()) {
|
||||
playNextNote(currentMelody);
|
||||
if (!currentMelody.hasNextNote() && currentBackgroundMelody) {
|
||||
// Swap the background melody back
|
||||
currentMelody = currentBackgroundMelody;
|
||||
currentBackgroundMelody = null;
|
||||
}
|
||||
}
|
||||
currentMelody = null;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function playNextNote(melody: Melody): void {
|
||||
// cache elements
|
||||
let currNote = melody.nextNote();
|
||||
let currentPos = melody.currentPos;
|
||||
let currentDuration = melody.currentDuration;
|
||||
let currentOctave = melody.currentOctave;
|
||||
|
||||
let note: number;
|
||||
let isrest: boolean = false;
|
||||
let beatPos: number;
|
||||
let parsingOctave: boolean = true;
|
||||
|
||||
for (let pos = 0; pos < currNote.length; pos++) {
|
||||
let noteChar = currNote.charAt(pos);
|
||||
switch (noteChar) {
|
||||
case 'a': case 'A': note = 1; break;
|
||||
case 'b': case 'B': note = 3; break;
|
||||
case 'c': case 'C': note = 4; break;
|
||||
case 'd': case 'D': note = 6; break;
|
||||
case 'e': case 'E': note = 8; break;
|
||||
case 'f': case 'F': note = 9; break;
|
||||
case 'g': case 'G': note = 11; break;
|
||||
case 'r': case 'R': isrest = true; break;
|
||||
case '#': note++; break;
|
||||
case 'b': note--; break;
|
||||
case ':': parsingOctave = false; beatPos = pos; break;
|
||||
default: if (parsingOctave) currentOctave = parseInt(noteChar);
|
||||
}
|
||||
}
|
||||
if (!parsingOctave) {
|
||||
currentDuration = parseInt(currNote.substr(beatPos + 1, currNote.length - beatPos));
|
||||
}
|
||||
let beat = (60000 / beatsPerMinute) / 4;
|
||||
if (isrest) {
|
||||
music.rest(currentDuration * beat)
|
||||
} else {
|
||||
let keyNumber = note + (12 * (currentOctave - 1));
|
||||
let frequency = keyNumber >= 0 && keyNumber < freqTable.length ? freqTable[keyNumber] : 0;
|
||||
music.playTone(frequency, currentDuration * beat);
|
||||
}
|
||||
melody.currentDuration = currentDuration;
|
||||
melody.currentOctave = currentOctave;
|
||||
melody.currentPos = melody.repeating == true && currentPos == melody.melodyArray.length - 1 ? 0 : currentPos + 1;
|
||||
}
|
||||
|
||||
class Melody {
|
||||
public melodyArray: string[];
|
||||
public currentDuration: number;
|
||||
public currentOctave: number;
|
||||
public currentPos: number;
|
||||
public repeating: boolean;
|
||||
public background: boolean;
|
||||
|
||||
constructor(melodyArray: string[], options: MelodyOptions) {
|
||||
this.melodyArray = melodyArray;
|
||||
this.repeating = ((options & MelodyOptions.Forever) != 0);
|
||||
this.repeating = this.repeating ? true : ((options & MelodyOptions.ForeverInBackground) != 0)
|
||||
this.background = ((options & MelodyOptions.OnceInBackground) != 0);
|
||||
this.background = this.background ? true : ((options & MelodyOptions.ForeverInBackground) != 0);
|
||||
this.currentDuration = 4; //Default duration (Crotchet)
|
||||
this.currentOctave = 4; //Middle octave
|
||||
this.currentPos = 0;
|
||||
}
|
||||
|
||||
hasNextNote() {
|
||||
return this.repeating || this.currentPos < this.melodyArray.length;
|
||||
}
|
||||
|
||||
nextNote(): string {
|
||||
const currentNote = this.melodyArray[this.currentPos];
|
||||
return currentNote;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ enum class AnalogPin {
|
||||
P5 = MICROBIT_ID_IO_P5,
|
||||
//% block="P6 (write only)"
|
||||
P6 = MICROBIT_ID_IO_P6,
|
||||
//% block="P5 (write only)"
|
||||
//% block="P7 (write only)"
|
||||
P7 = MICROBIT_ID_IO_P7,
|
||||
//% block="P8 (write only)"
|
||||
P8 = MICROBIT_ID_IO_P8,
|
||||
|
@ -26,6 +26,7 @@
|
||||
"led.cpp",
|
||||
"led.ts",
|
||||
"music.ts",
|
||||
"melodies.ts",
|
||||
"pins.cpp",
|
||||
"pins.ts",
|
||||
"serial.cpp",
|
||||
|
@ -34,7 +34,7 @@ enum Delimiters {
|
||||
Hash = 6,
|
||||
};
|
||||
|
||||
//% weight=2 color=30 icon="\uf287"
|
||||
//% weight=2 color=#002050 icon="\uf287"
|
||||
//% advanced=true
|
||||
namespace serial {
|
||||
// note that at least one // followed by % is needed per declaration!
|
||||
|
8
libs/core/shims.d.ts
vendored
@ -212,7 +212,7 @@ declare namespace basic {
|
||||
|
||||
|
||||
|
||||
//% color=300 weight=99 icon="\uf192"
|
||||
//% color=#B4009E weight=99 icon="\uf192"
|
||||
declare namespace input {
|
||||
|
||||
/**
|
||||
@ -430,7 +430,7 @@ declare namespace control {
|
||||
|
||||
|
||||
|
||||
//% color=3 weight=35 icon="\uf205"
|
||||
//% color=#5C2D91 weight=97 icon="\uf205"
|
||||
declare namespace led {
|
||||
|
||||
/**
|
||||
@ -500,7 +500,7 @@ declare namespace led {
|
||||
function setDisplayMode(mode: DisplayMode): void;
|
||||
|
||||
/**
|
||||
* Turns on or off the display
|
||||
* Turns on or off the display
|
||||
*/
|
||||
//% help=led/enable blockId=device_led_enable block="led enable %on"
|
||||
//% advanced=true parts="ledmatrix" shim=led::enable
|
||||
@ -671,7 +671,7 @@ declare namespace pins {
|
||||
|
||||
|
||||
|
||||
//% weight=2 color=30 icon="\uf287"
|
||||
//% weight=2 color=#002050 icon="\uf287"
|
||||
//% advanced=true
|
||||
declare namespace serial {
|
||||
|
||||
|
3
libs/devices/_locales/ja/devices-jsdoc-strings.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"devices.onGamepadButton|param|body": "ボタンが押されたときに実行するコード"
|
||||
}
|
3
libs/devices/_locales/ja/devices-strings.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"MesDeviceInfo.Shaken|block": "ゆさぶられる"
|
||||
}
|
62
libs/devices/_locales/no/devices-strings.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"MesAlertEvent.DisplayToast|block": "meldingsvindu",
|
||||
"MesAlertEvent.FindMyPhone|block": "finn telefonen",
|
||||
"MesAlertEvent.PlayRingtone|block": "ringetone",
|
||||
"MesAlertEvent.PlaySound|block": "spill lyd",
|
||||
"MesAlertEvent.RingAlarm2|block": "ring alarm 2",
|
||||
"MesAlertEvent.RingAlarm3|block": "ring alarm 3",
|
||||
"MesAlertEvent.RingAlarm4|block": "ring alarm 4",
|
||||
"MesAlertEvent.RingAlarm5|block": "ring alarm 5",
|
||||
"MesAlertEvent.RingAlarm6|block": "ring alarm 6",
|
||||
"MesAlertEvent.RingAlarm|block": "ring alarm",
|
||||
"MesAlertEvent.Vibrate|block": "vibrasjon",
|
||||
"MesCameraEvent.LaunchPhotoMode|block": "åpne fotomodus",
|
||||
"MesCameraEvent.LaunchVideoMode|block": "åpne videomodus",
|
||||
"MesCameraEvent.StartVideoCapture|block": "ta opp video",
|
||||
"MesCameraEvent.StopPhotoMode|block": "stopp fotomodus",
|
||||
"MesCameraEvent.StopVideoCapture|block": "stopp videoopptak",
|
||||
"MesCameraEvent.StopVideoMode|block": "stopp videomodus",
|
||||
"MesCameraEvent.TakePhoto|block": "ta bilde",
|
||||
"MesCameraEvent.ToggleFrontRear|block": "bytt forside-bakside",
|
||||
"MesDeviceInfo.DisplayOff|block": "skjerm av",
|
||||
"MesDeviceInfo.DisplayOn|block": "skjerm på",
|
||||
"MesDeviceInfo.IncomingCall|block": "anrop",
|
||||
"MesDeviceInfo.IncomingMessage|block": "melding mottatt",
|
||||
"MesDeviceInfo.OrientationLandscape|block": "liggende orientering",
|
||||
"MesDeviceInfo.OrientationPortrait|block": "stående orientering",
|
||||
"MesDeviceInfo.Shaken|block": "ristet",
|
||||
"MesDpadButtonInfo.ADown|block": "A trykkes ned",
|
||||
"MesDpadButtonInfo.AUp|block": "A slippes opp",
|
||||
"MesDpadButtonInfo.BDown|block": "B trykkes ned",
|
||||
"MesDpadButtonInfo.BUp|block": "B slippes opp",
|
||||
"MesDpadButtonInfo.CDown|block": "C trykkes ned",
|
||||
"MesDpadButtonInfo.CUp|block": "C slippes opp",
|
||||
"MesDpadButtonInfo.DDown|block": "D trykkes ned",
|
||||
"MesDpadButtonInfo.DUp|block": "D slippes opp",
|
||||
"MesDpadButtonInfo._1Down|block": "1 trykkes ned",
|
||||
"MesDpadButtonInfo._1Up|block": "1 slippes opp",
|
||||
"MesDpadButtonInfo._2Down|block": "2 trykkes ned",
|
||||
"MesDpadButtonInfo._2Up|block": "2 slippes opp",
|
||||
"MesDpadButtonInfo._3Down|block": "3 trykkes ned",
|
||||
"MesDpadButtonInfo._3Up|block": "3 slippes opp",
|
||||
"MesDpadButtonInfo._4Down|block": "4 trykkes ned",
|
||||
"MesDpadButtonInfo._4Up|block": "4 slippes opp",
|
||||
"MesRemoteControlEvent.forward|block": "framover",
|
||||
"MesRemoteControlEvent.nextTrack|block": "neste spor",
|
||||
"MesRemoteControlEvent.pause|block": "pause",
|
||||
"MesRemoteControlEvent.play|block": "spill av",
|
||||
"MesRemoteControlEvent.previousTrack|block": "forrige spor",
|
||||
"MesRemoteControlEvent.rewind|block": "tilbake",
|
||||
"MesRemoteControlEvent.stop|block": "stopp",
|
||||
"MesRemoteControlEvent.volumeDown|block": "volum ned",
|
||||
"MesRemoteControlEvent.volumeUp|block": "volum opp",
|
||||
"devices.onGamepadButton|block": "når spillkontroll-knapp |%NAME trykkes",
|
||||
"devices.onNotified|block": "når varslet om|%event",
|
||||
"devices.onSignalStrengthChanged|block": "når signalstyrken endrer seg",
|
||||
"devices.raiseAlertTo|block": "varsle med|%property",
|
||||
"devices.signalStrength|block": "signalstyrke",
|
||||
"devices.tellCameraTo|block": "fjernstyring kamera|%property",
|
||||
"devices.tellRemoteControlTo|block": "fjernstyring musikkspiller|%property",
|
||||
"devices|block": "enheter",
|
||||
"{id:category}Devices": "Fjernstyring"
|
||||
}
|
@ -6,7 +6,10 @@
|
||||
"enums.d.ts",
|
||||
"shims.d.ts",
|
||||
"devices.cpp",
|
||||
"_locales/fr/devices-jsdoc-strings.json"
|
||||
"_locales/fr/devices-jsdoc-strings.json",
|
||||
"_locales/no/devices-strings.json",
|
||||
"_locales/ja/devices-strings.json",
|
||||
"_locales/ja/devices-jsdoc-strings.json"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
|
9
libs/radio/_locales/ja/radio-jsdoc-strings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"radio.onDataPacketReceived": "無線でパケットを受信したときにコードが実行されます。",
|
||||
"radio.sendNumber": "無線を使って繋がっているデバイスに、数字をブロードキャストします。",
|
||||
"radio.sendString": "無線で繋がっているデバイスに、文字列とあわせてデバイスのシリアル番号と実行時間をブロードキャストします。",
|
||||
"radio.sendValue": "無線で繋がっているデバイスに、名前と値のペアとあわせてデバイスのシリアル番号と実行時間をブロードキャストします。",
|
||||
"radio.setGroup": "無線のグループ ID を設定します。 1 つのグループ ID上に流れる情報だけを、受信することができます。グループIDは、0-255の間で指定できます。",
|
||||
"radio.setTransmitPower": "無線での送信に使うパワーを指定します。",
|
||||
"radio.setTransmitSerialNumber": "無線で、デバイスのシリアル番号を送信するかどうかを指定できます。"
|
||||
}
|
10
libs/radio/_locales/ja/radio-strings.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"radio.onDataPacketReceived|block": "無線で受信したとき",
|
||||
"radio.sendNumber|block": "無線で数字を送信 %value",
|
||||
"radio.sendString|block": "無線で文字列を送信 %msg",
|
||||
"radio.sendValue|block": "無線で送信 | %name |= %value",
|
||||
"radio.setGroup|block": "無線のグループを設定 %ID",
|
||||
"radio.setTransmitPower|block": "無線の送信パワー %power",
|
||||
"radio.setTransmitSerialNumber|block": "無線でシリアル番号を送信 %transmit",
|
||||
"{id:category}Radio": "無線"
|
||||
}
|
@ -13,7 +13,9 @@
|
||||
"_locales/sv-SE/radio-strings.json",
|
||||
"_locales/no/radio-strings.json",
|
||||
"_locales/si-LK/radio-jsdoc-strings.json",
|
||||
"_locales/no/radio-jsdoc-strings.json"
|
||||
"_locales/no/radio-jsdoc-strings.json",
|
||||
"_locales/ja/radio-strings.json",
|
||||
"_locales/ja/radio-jsdoc-strings.json"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.9.13",
|
||||
"version": "0.9.29",
|
||||
"description": "micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -36,6 +36,6 @@
|
||||
"semantic-ui-less": "^2.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.11.41"
|
||||
"pxt-core": "0.11.51"
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +333,7 @@
|
||||
"coloredToolbox": true,
|
||||
"monacoToolbox": true,
|
||||
"hasAudio": true,
|
||||
"blocklyOptions": {
|
||||
"blocklyOptions": {
|
||||
"grid": {
|
||||
"spacing": 45,
|
||||
"length": 7,
|
||||
|
BIN
sim/public/blocks/iconnames/angry.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/asleep.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/butterfly.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
sim/public/blocks/iconnames/chessboard.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/confused.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/cow.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/diamond.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/duck.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/eigthnote.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/fabulous.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/ghost.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/giraffe.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/happy.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/heart.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/house.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/lefttriangle.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/meh.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/no.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/pitchfork.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
sim/public/blocks/iconnames/quarternote.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/rabbit.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/rollerskate.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/sad.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/silly.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/skull.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/smalldiamond.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/smallheart.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/smallsquare.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/snake.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/square.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/stickfigure.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/surprised.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/sword.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/target.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/tortoise.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/triangle.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/tshirt.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/umbrella.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
sim/public/blocks/iconnames/yes.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
@ -562,8 +562,9 @@ namespace pxsim.visuals {
|
||||
const x = state.accelerometerState.accelerometer.getX();
|
||||
const y = -state.accelerometerState.accelerometer.getY();
|
||||
const af = 8 / 1023;
|
||||
const s = 1 - Math.min(0.1, Math.pow(Math.max(Math.abs(x), Math.abs(y)) / 1023, 2) / 35);
|
||||
|
||||
this.element.style.transform = "perspective(30em) rotateX(" + y * af + "deg) rotateY(" + x * af + "deg)"
|
||||
this.element.style.transform = `perspective(30em) rotateX(${y * af}deg) rotateY(${x * af}deg) scale(${s}, ${s})`
|
||||
this.element.style.perspectiveOrigin = "50% 50% 50%";
|
||||
this.element.style.perspective = "30em";
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ span.blocklyTreeLabel {
|
||||
.blocklyToolboxDiv, .monacoToolboxDiv {
|
||||
background-color: white !important;
|
||||
border-left: 1px solid #ecf0f1 !important;
|
||||
box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.12), 0px 0px 2px 0px rgba(0,0,0,0.24);
|
||||
box-shadow: 4px 0px 2px -4px rgba(0,0,0,0.12), 4px 0px 2px -4px rgba(0,0,0,0.24);
|
||||
}
|
||||
|
||||
.blocklyFlyoutBackground {
|
||||
|