diff --git a/CNAME b/CNAME deleted file mode 100644 index c98a1d1..0000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -blockly.webduino.io diff --git a/README.md b/README.md index 576b1ed..8471708 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,38 @@ # Webduino-Blockly -The Visual Programming Editor for [Webduino](http://webduino.io). +The Visual Programming Editor for Webduino. Google's [Blockly](https://github.com/google/blockly) is a web-based, visual programming editor. Users can drag blocks together to build programs. -## Installation +## Prerequisite + +- [Node.js](https://nodejs.org) and NPM +- [Bower](http://bower.io) -First, make sure [bower](http://bower.io) has been installed. +## Installation ```Shell -$ git clone https://github.com/webduinoio/webduino-blockly.git -$ cd webduino-blockly -$ bower install +git clone https://github.com/webduinoio/webduino-blockly.git +cd webduino-blockly +npm install +bower install +``` + +## Run + +``` +npm run start ``` -Now, webduino-blockly has been successfully installed. Open your browser point it to **index.html**. +Navigate to and start hacking! ## Generated-Code Usage -#### Browser +You can use the code which generated by Webduino Blockly in your own application + +Our APIs support both browser and Node.js, here's how you use it: +#### In Browser ```html @@ -37,15 +50,15 @@ Now, webduino-blockly has been successfully installed. Open your browser point i ``` -#### Node.js +#### In Node.js Require the module first by: ```javascript require('webduino-blockly'); -``` -Then paste-in the code generated by Blockly. +// ... The code generated by Webduino Blockly. +``` ## License diff --git a/blocks/webduino.js b/blocks/webduino.js index 8b85aea..40db763 100644 --- a/blocks/webduino.js +++ b/blocks/webduino.js @@ -827,8 +827,8 @@ Blockly.Blocks['math_round_digit'] = { this.appendValueInput("round_") .appendField(new Blockly.FieldDropdown([ [Blockly.Msg.WEBDUINO_MATH_ROUND, "round"], - [Blockly.Msg.WEBDUINO_MATH_ROUND_UP, "floor"], - [Blockly.Msg.WEBDUINO_MATH_ROUND_DOWN, "ceil"] + [Blockly.Msg.WEBDUINO_MATH_ROUND_UP, "ceil"], + [Blockly.Msg.WEBDUINO_MATH_ROUND_DOWN, "floor"] ]), "type_") .appendField(Blockly.Msg.WEBDUINO_MATH_ROUND_TO, "到小數點") .appendField(new Blockly.FieldDropdown([ diff --git a/package.json b/package.json index 6e5ae9b..e4027b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webduino-blockly", - "version": "0.0.11", + "version": "0.0.12", "main": "index.js", "description": "The Visual Programming Editor for Webduino", "repository": "https://github.com/webduinoio/webduino-blockly.git", diff --git a/webduino-blockly.js b/webduino-blockly.js index b64d66c..8db0de6 100644 --- a/webduino-blockly.js +++ b/webduino-blockly.js @@ -74,6 +74,11 @@ return board ? board.getPin(pinNum) : undef; } + function bitGPIO(pinNum) { + var pinMaps = [25, 32, 33, 13, 15, 35, 12, 14, 16, 17, 26, 27, 2, 18, 19, 23, 5]; + return pinMaps[pinNum]; + } + function searchBoard(options) { var keys = Object.keys(options), candidate, @@ -705,6 +710,7 @@ scope.boardReady = boardReady; scope.getPin = getPin; + scope.bitGPIO = bitGPIO; scope.getLed = getLed; scope.getRelay = getRelay; scope.getRGBLed = getRGBLed;