aiyboard.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /**
  2. * @license
  3. * Visual Blocks Editor
  4. *
  5. * Copyright 2012 Google Inc.
  6. * https://developers.google.com/blockly/
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. /**
  21. * @fileoverview Colour blocks for Blockly.
  22. * @author fraser@google.com (Neil Fraser)
  23. */
  24. 'use strict';
  25. goog.provide('Blockly.Blocks.AIYBoard');
  26. goog.require('Blockly.Blocks');
  27. /**
  28. * Common HSV hue for all blocks in this category.
  29. */
  30. Blockly.Blocks.AIYBoard.HUE = "#6844d1";
  31. Blockly.Blocks['AIYBoard_from'] = {
  32. /**
  33. * Block for log setup.
  34. * @this Blockly.Block
  35. */
  36. init: function() {
  37. this.setColour(Blockly.Blocks.AIYBoard.HUE);
  38. this.appendValueInput("INPUT")
  39. .appendField(Blockly.Msg.AIYBOARD_FROM)
  40. // this.setInputsInline(false);
  41. // this.setOutput(true);
  42. this.setPreviousStatement(true);
  43. this.setNextStatement(true);
  44. },
  45. };
  46. Blockly.Blocks['AIYBoard_import'] = {
  47. /**
  48. * Block for log setup.
  49. * @this Blockly.Block
  50. */
  51. init: function() {
  52. this.setColour(Blockly.Blocks.AIYBoard.HUE);
  53. this.appendDummyInput()
  54. .appendField(Blockly.Msg.AIYBOARD_IMPORT)
  55. .appendField(new Blockly.FieldDropdown([
  56. ["Board","Board"],
  57. ["Led","Led"],
  58. ]),"BOARD")
  59. // this.setInputsInline(false);
  60. this.setOutput(true);
  61. // this.setPreviousStatement(true);
  62. // this.setNextStatement(true);
  63. },
  64. };
  65. Blockly.Blocks['AIYBoard_Board'] = {
  66. /**
  67. * Block for log setup.
  68. * @this Blockly.Block
  69. */
  70. init: function() {
  71. this.setColour(Blockly.Blocks.AIYBoard.HUE);
  72. this.appendDummyInput()
  73. .appendField(Blockly.Msg.AIYBOARD_AIY_BOARD);
  74. // this.setInputsInline(false);
  75. this.setOutput(true);
  76. // this.setPreviousStatement(true);
  77. // this.setNextStatement(true);
  78. },
  79. };
  80. Blockly.Blocks['AIYBoard_LED_state'] = {
  81. /**
  82. * Block for log setup.
  83. * @this Blockly.Block
  84. */
  85. init: function() {
  86. this.setColour(Blockly.Blocks.AIYBoard.HUE);
  87. this.appendValueInput("INPUT")
  88. .appendField(Blockly.Msg.AIYBOARD_LED_STATE);
  89. this.setInputsInline(true);
  90. this.setOutput(true);
  91. // this.setPreviousStatement(true);
  92. // this.setNextStatement(true);
  93. },
  94. };
  95. Blockly.Blocks['AIYBoard_LED_status'] = {
  96. /**
  97. * Block for log setup.
  98. * @this Blockly.Block
  99. */
  100. init: function() {
  101. this.setColour(Blockly.Blocks.AIYBoard.HUE);
  102. this.appendValueInput("INPUT")
  103. .appendField(Blockly.Msg.AIYBOARD_LED_STATUS);
  104. this.setInputsInline(true);
  105. this.setOutput(true);
  106. // this.setPreviousStatement(true);
  107. // this.setNextStatement(true);
  108. },
  109. };
  110. Blockly.Blocks['AIYBoard_LED_setting'] = {
  111. init: function() {
  112. this.setColour(Blockly.Blocks.AIYBoard.HUE);
  113. this.appendDummyInput()
  114. .appendField("LED")
  115. .appendField(new Blockly.FieldDropdown([
  116. ["BEACON_DARK","BEACON_DARK"],
  117. ["ON","ON"],
  118. ["PULSE_QUICK","PULSE_QUICK"]
  119. ]),"SETTING")
  120. this.setOutput(true);
  121. }
  122. }
  123. Blockly.Blocks['AIYBoard_board'] = {
  124. init:function() {
  125. this.setColour(Blockly.Blocks.AIYBoard.HUE)
  126. this.appendDummyInput()
  127. .appendField("Board")
  128. this.setOutput(true)
  129. },
  130. }
  131. Blockly.Blocks['AIYBoard_button'] = {
  132. init:function() {
  133. this.setColour(Blockly.Blocks.AIYBoard.HUE)
  134. this.appendDummyInput()
  135. .appendField("Button")
  136. this.setOutput(true)
  137. },
  138. }
  139. /**
  140. * board kit
  141. * press button function
  142. */
  143. Blockly.Blocks['AIYBoard_button_press'] = {
  144. init: function() {
  145. this.setColour(Blockly.Blocks.AIYBoard.HUE)
  146. this.appendDummyInput()
  147. .appendField("On Button Press")
  148. this.appendStatementInput("STACK")
  149. this.setPreviousStatement(true);
  150. this.setNextStatement(true);
  151. }
  152. }
  153. Blockly.Blocks['AIYBoard_board_led_status'] = {
  154. init:function() {
  155. this.setColour(Blockly.Blocks.AIYBoard.HUE)
  156. this.appendValueInput("INPUT")
  157. .appendField("Board led status")
  158. this.setPreviousStatement(true);
  159. this.setNextStatement(true)
  160. }
  161. }
  162. Blockly.Blocks['AIYBoard_board_led_state'] = {
  163. init:function() {
  164. this.setColour(Blockly.Blocks.AIYBoard.HUE)
  165. this.appendValueInput("INPUT")
  166. .appendField("Board led state")
  167. this.setPreviousStatement(true);
  168. this.setNextStatement(true)
  169. }
  170. }