motor.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. /**
  2. * @license Licensed under the Apache License, Version 2.0 (the "License"):
  3. * http://www.apache.org/licenses/LICENSE-2.0
  4. */
  5. /**
  6. * @fileoverview Ardublockly JavaScript for the Blockly resources and bindings.
  7. */
  8. 'use strict';
  9. goog.provide('Blockly.Blocks.motor');
  10. goog.require('Blockly.Blocks');
  11. Blockly.Blocks.motor.HUE = 345;
  12. // Blockly.Blocks['ultrasonicavoidingrobot'] = {
  13. // init: function() {
  14. // this.appendDummyInput()
  15. // .appendField(new Blockly.FieldImage("https://puu.sh/xLg12/c83265b10a.png", 160, 80, "*"));
  16. // this.appendDummyInput()
  17. // .appendField("Set Echo to Pin")
  18. // .appendField(new Blockly.FieldTextInput("2"), "uarEchoPin")
  19. // .appendField("Set Trig to Pin")
  20. // .appendField(new Blockly.FieldTextInput("3"), "uarTrigPin");
  21. // this.appendDummyInput()
  22. // .appendField("Set Speed to")
  23. // .appendField(new Blockly.FieldNumber(20, 0, 255), "uarSpeed");
  24. // this.appendDummyInput()
  25. // .appendField("Set Detecting Distance")
  26. // .appendField(new Blockly.FieldNumber(20), "uarDistance")
  27. // .appendField("cm");
  28. // this.appendDummyInput()
  29. // .appendField(new Blockly.FieldImage("https://puu.sh/xLgsO/bc6b467578.png", 24, 24, "*"))
  30. // .appendField("Set your movement below:");
  31. // this.setPreviousStatement(true, null);
  32. // this.setNextStatement(true, null);
  33. // this.setColour(230);
  34. // this.setTooltip("");
  35. // this.setHelpUrl("");
  36. // }
  37. // };
  38. // Blockly.Blocks['uardirectionforward'] = {
  39. // init: function() {
  40. // this.appendDummyInput()
  41. // .appendField("Go Forward for")
  42. // .appendField(new Blockly.FieldNumber(10, 0, 300), "uarDirDuration")
  43. // .appendField("seconds");
  44. // this.setPreviousStatement(true, null);
  45. // this.setNextStatement(true, null);
  46. // this.setColour(230);
  47. // this.setTooltip("");
  48. // this.setHelpUrl("");
  49. // }
  50. // };
  51. // Blockly.Blocks['uardirectionbackward'] = {
  52. // init: function() {
  53. // this.appendDummyInput()
  54. // .appendField("Go Backward for")
  55. // .appendField(new Blockly.FieldNumber(10, 0, 300), "uarDirDuration")
  56. // .appendField("seconds");
  57. // this.setPreviousStatement(true, null);
  58. // this.setNextStatement(true, null);
  59. // this.setColour(230);
  60. // this.setTooltip("");
  61. // this.setHelpUrl("");
  62. // }
  63. // };
  64. // Blockly.Blocks['uardirectionleft'] = {
  65. // init: function() {
  66. // this.appendDummyInput()
  67. // .appendField("Rotate Left for")
  68. // .appendField(new Blockly.FieldNumber(10, 0, 300), "uarDirDuration")
  69. // .appendField("seconds");
  70. // this.setPreviousStatement(true, null);
  71. // this.setNextStatement(true, null);
  72. // this.setColour(230);
  73. // this.setTooltip("");
  74. // this.setHelpUrl("");
  75. // }
  76. // };
  77. // Blockly.Blocks['uardirectionright'] = {
  78. // init: function() {
  79. // this.appendDummyInput()
  80. // .appendField("Rotatel Right for")
  81. // .appendField(new Blockly.FieldNumber(10, 0, 300), "uarDirDuration")
  82. // .appendField("seconds");
  83. // this.setPreviousStatement(true, null);
  84. // this.setNextStatement(true, null);
  85. // this.setColour(230);
  86. // this.setTooltip("");
  87. // this.setHelpUrl("");
  88. // }
  89. // };
  90. // Blockly.Blocks['uarfinishsetup'] = {
  91. // init: function() {
  92. // this.appendDummyInput()
  93. // .appendField("Setup Complete");
  94. // this.setPreviousStatement(true, null);
  95. // this.setNextStatement(true, null);
  96. // this.setColour(200);
  97. // this.setTooltip("");
  98. // this.setHelpUrl("");
  99. // }
  100. // };
  101. // Blockly.Blocks['motor_setup'] = {
  102. // init: function() {
  103. // this.appendDummyInput()
  104. // .appendField(new Blockly.FieldImage("https://puu.sh/wtu4O/c2deb70d42.png", 140, 40, "15"));
  105. // this.appendDummyInput()
  106. // .appendField(Blockly.Msg.MOTOR_SETUP);
  107. // //this.setPreviousStatement(true, null);
  108. // //this.setNextStatement(true, ['motor_remote_setup', 'motor_path_planning', 'motor_line_tracking', 'motor_ultrasonic_pin', 'motor_ultrasonic_custom_pin']);
  109. // this.setNextStatement(true, 'motor_type');
  110. // this.setColour(30);
  111. // this.setTooltip('');
  112. // this.setHelpUrl('');
  113. // }
  114. // };
  115. Blockly.Blocks['motor_setup'] = {
  116. init: function() {
  117. this.appendDummyInput()
  118. // .appendField(new Blockly.FieldImage("http://cocorobo.cn/cocoblockly/blockly/media/cocomod_blockly_motorDriver.png", 140, 40, "15"));
  119. .appendField(new Blockly.FieldImage("./../blockly/media/main-motor.png", 50, 40, "15"));
  120. this.appendDummyInput()
  121. .appendField(Blockly.Msg.MOTOR_SETUP);
  122. // this.setPreviousStatement(true, null);
  123. // this.setNextStatement(true, ['motor_remote_setup', 'motor_path_planning', 'motor_line_tracking', 'motor_ultrasonic_pin', 'motor_ultrasonic_custom_pin']);
  124. // this.setNextStatement(true, 'motor_type');
  125. // this.setNextStatement(true, null);
  126. this.setColour(Blockly.Blocks.motor.HUE);
  127. this.setTooltip('');
  128. this.setHelpUrl('');
  129. }
  130. };
  131. // Blockly.Blocks['motor_remote_setup'] = {
  132. // init: function() {
  133. // this.appendDummyInput()
  134. // .appendField(Blockly.Msg.MOTOR_REMOTE_SETUP);
  135. // this.appendDummyInput()
  136. // .appendField(Blockly.Msg.MOTOR_BUTTON)
  137. // .appendField(new Blockly.FieldDropdown([["0","0xFF9867"], ["1","0xFFA25D"], ["2","0xFF629D"], ["3","0xFFE21D"], ["4","0xFF22DD"], ["5","0xFF02FD"], ["6","0xFFC23D"], ["7","0xFFE01F"], ["8","0xFFA857"], ["9","0xFF906F"], ["RIGHT","0xFF5AA5"], ["UP","0xFF18E7"], ["DOWN","0xFF4AB5"], ["LEFT","0xFF10EF"], ["OK", "0xFF38C7"], ["*", "0xFF6897"], ["#", "0xFFB04F"]]), "run")
  138. // .appendField(" -- " + Blockly.Msg.MOTOR_GO);
  139. // this.appendDummyInput()
  140. // .appendField(Blockly.Msg.MOTOR_BUTTON)
  141. // .appendField(new Blockly.FieldDropdown([["0","0xFF9867"], ["1","0xFFA25D"], ["2","0xFF629D"], ["3","0xFFE21D"], ["4","0xFF22DD"], ["5","0xFF02FD"], ["6","0xFFC23D"], ["7","0xFFE01F"], ["8","0xFFA857"], ["9","0xFF906F"], ["RIGHT","0xFF5AA5"], ["UP","0xFF18E7"], ["DOWN","0xFF4AB5"], ["LEFT","0xFF10EF"], ["OK", "0xFF38C7"], ["*", "0xFF6897"], ["#", "0xFFB04F"]]), "reverse")
  142. // .appendField(" -- " + Blockly.Msg.MOTOR_REVERSE);
  143. // this.appendDummyInput()
  144. // .appendField(Blockly.Msg.MOTOR_BUTTON)
  145. // .appendField(new Blockly.FieldDropdown([["0","0xFF9867"], ["1","0xFFA25D"], ["2","0xFF629D"], ["3","0xFFE21D"], ["4","0xFF22DD"], ["5","0xFF02FD"], ["6","0xFFC23D"], ["7","0xFFE01F"], ["8","0xFFA857"], ["9","0xFF906F"], ["RIGHT","0xFF5AA5"], ["UP","0xFF18E7"], ["DOWN","0xFF4AB5"], ["LEFT","0xFF10EF"], ["OK", "0xFF38C7"], ["*", "0xFF6897"], ["#", "0xFFB04F"]]), "turn_left")
  146. // .appendField(" -- " + Blockly.Msg.MOTOR_TURN_LEFT);
  147. // this.appendDummyInput()
  148. // .appendField(Blockly.Msg.MOTOR_BUTTON)
  149. // .appendField(new Blockly.FieldDropdown([["0","0xFF9867"], ["1","0xFFA25D"], ["2","0xFF629D"], ["3","0xFFE21D"], ["4","0xFF22DD"], ["5","0xFF02FD"], ["6","0xFFC23D"], ["7","0xFFE01F"], ["8","0xFFA857"], ["9","0xFF906F"], ["RIGHT","0xFF5AA5"], ["UP","0xFF18E7"], ["DOWN","0xFF4AB5"], ["LEFT","0xFF10EF"], ["OK", "0xFF38C7"], ["*", "0xFF6897"], ["#", "0xFFB04F"]]), "turn_right")
  150. // .appendField(" -- " + Blockly.Msg.MOTOR_TURN_RIGHT);
  151. // this.appendDummyInput()
  152. // .appendField(Blockly.Msg.MOTOR_BUTTON)
  153. // .appendField(new Blockly.FieldDropdown([["0","0xFF9867"], ["1","0xFFA25D"], ["2","0xFF629D"], ["3","0xFFE21D"], ["4","0xFF22DD"], ["5","0xFF02FD"], ["6","0xFFC23D"], ["7","0xFFE01F"], ["8","0xFFA857"], ["9","0xFF906F"], ["RIGHT","0xFF5AA5"], ["UP","0xFF18E7"], ["DOWN","0xFF4AB5"], ["LEFT","0xFF10EF"], ["OK", "0xFF38C7"], ["*", "0xFF6897"], ["#", "0xFFB04F"]]), "stop")
  154. // .appendField(" -- " + Blockly.Msg.MOTOR_STOP);
  155. // this.appendDummyInput()
  156. // .appendField(Blockly.Msg.MOTOR_BUTTON)
  157. // .appendField(new Blockly.FieldDropdown([["0","0xFF9867"], ["1","0xFFA25D"], ["2","0xFF629D"], ["3","0xFFE21D"], ["4","0xFF22DD"], ["5","0xFF02FD"], ["6","0xFFC23D"], ["7","0xFFE01F"], ["8","0xFFA857"], ["9","0xFF906F"], ["RIGHT","0xFF5AA5"], ["UP","0xFF18E7"], ["DOWN","0xFF4AB5"], ["LEFT","0xFF10EF"], ["OK", "0xFF38C7"], ["*", "0xFF6897"], ["#", "0xFFB04F"]]), "speed_0")
  158. // .appendField(" -- "+ Blockly.Msg.MOTOR_SPEED+" 0");
  159. // this.appendDummyInput()
  160. // .appendField(Blockly.Msg.MOTOR_BUTTON)
  161. // .appendField(new Blockly.FieldDropdown([["0","0xFF9867"], ["1","0xFFA25D"], ["2","0xFF629D"], ["3","0xFFE21D"], ["4","0xFF22DD"], ["5","0xFF02FD"], ["6","0xFFC23D"], ["7","0xFFE01F"], ["8","0xFFA857"], ["9","0xFF906F"], ["RIGHT","0xFF5AA5"], ["UP","0xFF18E7"], ["DOWN","0xFF4AB5"], ["LEFT","0xFF10EF"], ["OK", "0xFF38C7"], ["*", "0xFF6897"], ["#", "0xFFB04F"]]), "speed_80")
  162. // .appendField(" -- "+Blockly.Msg.MOTOR_SPEED+" 80");
  163. // this.appendDummyInput()
  164. // .appendField(Blockly.Msg.MOTOR_BUTTON)
  165. // .appendField(new Blockly.FieldDropdown([["0","0xFF9867"], ["1","0xFFA25D"], ["2","0xFF629D"], ["3","0xFFE21D"], ["4","0xFF22DD"], ["5","0xFF02FD"], ["6","0xFFC23D"], ["7","0xFFE01F"], ["8","0xFFA857"], ["9","0xFF906F"], ["RIGHT","0xFF5AA5"], ["UP","0xFF18E7"], ["DOWN","0xFF4AB5"], ["LEFT","0xFF10EF"], ["OK", "0xFF38C7"], ["*", "0xFF6897"], ["#", "0xFFB04F"]]), "speed_100")
  166. // .appendField(" -- "+Blockly.Msg.MOTOR_SPEED+" 100");
  167. // this.appendDummyInput()
  168. // .appendField(Blockly.Msg.MOTOR_BUTTON)
  169. // .appendField(new Blockly.FieldDropdown([["0","0xFF9867"], ["1","0xFFA25D"], ["2","0xFF629D"], ["3","0xFFE21D"], ["4","0xFF22DD"], ["5","0xFF02FD"], ["6","0xFFC23D"], ["7","0xFFE01F"], ["8","0xFFA857"], ["9","0xFF906F"], ["RIGHT","0xFF5AA5"], ["UP","0xFF18E7"], ["DOWN","0xFF4AB5"], ["LEFT","0xFF10EF"], ["OK", "0xFF38C7"], ["*", "0xFF6897"], ["#", "0xFFB04F"]]), "speed_120")
  170. // .appendField(" -- "+Blockly.Msg.MOTOR_SPEED+" 120");
  171. // this.setPreviousStatement(true, 'motor_type');
  172. // this.setColour(30);
  173. // this.setTooltip('');
  174. // this.setHelpUrl('');
  175. // }
  176. // };
  177. // Blockly.Blocks['motor_path_planning'] = {
  178. // init: function() {
  179. // this.appendDummyInput()
  180. // .appendField(Blockly.Msg.MOTOR_PATH_PLANNING);
  181. // this.appendStatementInput("motor_motion")
  182. // //.setCheck(['motor_turn_left', 'motor_turn_right', 'motor_go_forward', 'motor_go_backward']);
  183. // .setCheck('motor_option');
  184. // this.setPreviousStatement(true, 'motor_type');
  185. // this.setColour(330);
  186. // this.setTooltip('');
  187. // this.setHelpUrl('');
  188. // }
  189. // };
  190. // Blockly.Blocks['motor_turn_left'] = {
  191. // init: function() {
  192. // this.appendDummyInput()
  193. // .appendField(Blockly.Msg.MOTOR_TURN_LEFT + "- ")
  194. // .appendField(new Blockly.FieldTextInput("1000"), "delay")
  195. // .appendField(Blockly.Msg.MOTOR_MILLISEC);
  196. // this.setPreviousStatement(true, 'motor_option');
  197. // this.setNextStatement(true, 'motor_option');
  198. // this.setColour(330);
  199. // this.setTooltip('');
  200. // this.setHelpUrl('');
  201. // }
  202. // };
  203. // Blockly.Blocks['motor_turn_right'] = {
  204. // init: function() {
  205. // this.appendDummyInput()
  206. // .appendField(Blockly.Msg.MOTOR_TURN_RIGHT + "- ")
  207. // .appendField(new Blockly.FieldTextInput("1000"), "delay")
  208. // .appendField(Blockly.Msg.MOTOR_MILLISEC);
  209. // this.setPreviousStatement(true, 'motor_option');
  210. // this.setNextStatement(true, 'motor_option');
  211. // this.setColour(330);
  212. // this.setTooltip('');
  213. // this.setHelpUrl('');
  214. // }
  215. // };
  216. // Blockly.Blocks['motor_go_forward'] = {
  217. // init: function() {
  218. // this.appendDummyInput()
  219. // .appendField(Blockly.Msg.MOTOR_GO + "- ")
  220. // .appendField(new Blockly.FieldTextInput("1000"), "delay")
  221. // .appendField(Blockly.Msg.MOTOR_MILLISEC);
  222. // this.setPreviousStatement(true, 'motor_option');
  223. // this.setNextStatement(true, 'motor_option');
  224. // this.setColour(330);
  225. // this.setTooltip('');
  226. // this.setHelpUrl('');
  227. // }
  228. // };
  229. // Blockly.Blocks['motor_go_backward'] = {
  230. // init: function() {
  231. // this.appendDummyInput()
  232. // .appendField(Blockly.Msg.MOTOR_REVERSE + "- ")
  233. // .appendField(new Blockly.FieldTextInput("1000"), "delay")
  234. // .appendField(Blockly.Msg.MOTOR_MILLISEC);
  235. // this.setPreviousStatement(true, 'motor_option');
  236. // this.setNextStatement(true, 'motor_option');
  237. // this.setColour(330);
  238. // this.setTooltip('');
  239. // this.setHelpUrl('');
  240. // }
  241. // };
  242. Blockly.Blocks['motor_speed'] = {
  243. init: function() {
  244. this.appendDummyInput()
  245. .appendField(Blockly.Msg.MOTOR_SPEED)
  246. .appendField(new Blockly.FieldNumber(150, 0, 255), "SPEED");
  247. this.setOutput(true, Blockly.Types.NUMBER.output);
  248. this.setColour(Blockly.Blocks.motor.HUE);
  249. this.setTooltip("");
  250. this.setHelpUrl("");
  251. },
  252. getBlockType: function() {
  253. return Blockly.Types.NUMBER;
  254. }
  255. };
  256. Blockly.Blocks['motorA_move_clockwise'] = {
  257. init: function() {
  258. this.appendDummyInput()
  259. .appendField(Blockly.Msg.MOTOR_MOVE_MOTOR)
  260. .appendField(new Blockly.FieldDropdown([
  261. ["A", "1"],
  262. ["B", "0"]
  263. ]), "MOTOR");
  264. this.appendValueInput("SPEED")
  265. .setCheck("Number");
  266. this.appendDummyInput()
  267. .appendField(Blockly.Msg.MOTOR_MOVE_MSG)
  268. .appendField(new Blockly.FieldDropdown([
  269. [Blockly.Msg.MOTOR_MOVE_DIRECTION1, "0"],
  270. [Blockly.Msg.MOTOR_MOVE_DIRECTION2, "1"]
  271. ]), "DIRECTION");
  272. this.setInputsInline(true);
  273. this.setPreviousStatement(true, null);
  274. this.setNextStatement(true, null);
  275. this.setColour(Blockly.Blocks.motor.HUE);
  276. this.setTooltip('');
  277. this.setHelpUrl('');
  278. }
  279. };
  280. Blockly.Blocks['motorA_move_anticlockwise'] = {
  281. init: function() {
  282. this.appendDummyInput()
  283. .appendField(Blockly.Msg.MOTOR_MOVE_MOTOR)
  284. .appendField(new Blockly.FieldDropdown([
  285. ["A", "1"],
  286. ["B", "0"]
  287. ]), "MOTOR");
  288. this.appendValueInput("SPEED")
  289. .setCheck("Number");
  290. this.appendDummyInput()
  291. .appendField(Blockly.Msg.MOTOR_MOVE_MSG)
  292. .appendField(new Blockly.FieldDropdown([
  293. [Blockly.Msg.MOTOR_MOVE_DIRECTION2, "1"],
  294. [Blockly.Msg.MOTOR_MOVE_DIRECTION1, "0"]
  295. ]), "DIRECTION");
  296. this.setInputsInline(true);
  297. this.setPreviousStatement(true, null);
  298. this.setNextStatement(true, null);
  299. this.setColour(Blockly.Blocks.motor.HUE);
  300. this.setTooltip('');
  301. this.setHelpUrl('');
  302. }
  303. };
  304. Blockly.Blocks['motorB_move_clockwise'] = {
  305. init: function() {
  306. this.appendDummyInput()
  307. .appendField(Blockly.Msg.MOTOR_MOVE_MOTOR)
  308. .appendField(new Blockly.FieldDropdown([
  309. ["B", "0"],
  310. ["A", "1"]
  311. ]), "MOTOR");
  312. this.appendValueInput("SPEED")
  313. .setCheck("Number");
  314. this.appendDummyInput()
  315. .appendField(Blockly.Msg.MOTOR_MOVE_MSG)
  316. .appendField(new Blockly.FieldDropdown([
  317. [Blockly.Msg.MOTOR_MOVE_DIRECTION1, "0"],
  318. [Blockly.Msg.MOTOR_MOVE_DIRECTION2, "1"]
  319. ]), "DIRECTION");
  320. this.setInputsInline(true);
  321. this.setPreviousStatement(true, null);
  322. this.setNextStatement(true, null);
  323. this.setColour(Blockly.Blocks.motor.HUE);
  324. this.setTooltip('');
  325. this.setHelpUrl('');
  326. }
  327. };
  328. Blockly.Blocks['motorB_move_anticlockwise'] = {
  329. init: function() {
  330. this.appendDummyInput()
  331. .appendField(Blockly.Msg.MOTOR_MOVE_MOTOR)
  332. .appendField(new Blockly.FieldDropdown([
  333. ["B", "0"],
  334. ["A", "1"]
  335. ]), "MOTOR");
  336. this.appendValueInput("SPEED")
  337. .setCheck("Number");
  338. this.appendDummyInput()
  339. .appendField(Blockly.Msg.MOTOR_MOVE_MSG)
  340. .appendField(new Blockly.FieldDropdown([
  341. [Blockly.Msg.MOTOR_MOVE_DIRECTION2, "1"],
  342. [Blockly.Msg.MOTOR_MOVE_DIRECTION1, "0"]
  343. ]), "DIRECTION");
  344. this.setInputsInline(true);
  345. this.setPreviousStatement(true, null);
  346. this.setNextStatement(true, null);
  347. this.setColour(Blockly.Blocks.motor.HUE);
  348. this.setTooltip('');
  349. this.setHelpUrl('');
  350. }
  351. };
  352. Blockly.Blocks['motor_stop'] = {
  353. init: function() {
  354. this.appendDummyInput()
  355. .appendField(Blockly.Msg.MOTOR_STOP);
  356. this.setPreviousStatement(true, null);
  357. this.setNextStatement(true, null);
  358. this.setColour(Blockly.Blocks.motor.HUE);
  359. this.setTooltip('');
  360. this.setHelpUrl('');
  361. },
  362. };
  363. // Blockly.Blocks['motor_line_tracking'] = {
  364. // init: function() {
  365. // this.appendDummyInput()
  366. // .appendField(Blockly.Msg.MOTOR_LINE_TRACKING);
  367. // this.appendDummyInput()
  368. // .appendField(Blockly.Msg.LED_PIN)
  369. // .appendField(new Blockly.FieldTextInput("A4"), "pin_0");
  370. // this.appendDummyInput()
  371. // .appendField(Blockly.Msg.LED_PIN)
  372. // .appendField(new Blockly.FieldTextInput("A0"), "pin_1");
  373. // this.appendDummyInput()
  374. // .appendField(Blockly.Msg.MOTOR_SPEED)
  375. // .appendField(new Blockly.FieldTextInput("150"), "speed");
  376. // this.setPreviousStatement(true, null);
  377. // this.setColour(255);
  378. // this.setTooltip('');
  379. // this.setHelpUrl('');
  380. // }
  381. // };
  382. // Blockly.Blocks['motor_ultrasonic_pin'] = {
  383. // init: function() {
  384. // this.appendDummyInput()
  385. // .appendField(Blockly.Msg.MOTOR_ULTRASONIC);
  386. // this.appendDummyInput()
  387. // .appendField(Blockly.Msg.LED_SET_WORD)
  388. // .appendField(new Blockly.FieldTextInput("stA"), "pin_var0")
  389. // .appendField(Blockly.Msg.MOTOR_AS + " "+ Blockly.Msg.LED_PIN)
  390. // .appendField(new Blockly.FieldTextInput("A1"), "pin_0");
  391. // this.appendDummyInput()
  392. // .appendField(Blockly.Msg.LED_SET_WORD)
  393. // .appendField(new Blockly.FieldTextInput("seA"), "pin_var1")
  394. // .appendField(Blockly.Msg.MOTOR_AS + " "+ Blockly.Msg.LED_PIN)
  395. // .appendField(new Blockly.FieldTextInput("A0"), "pin_1");
  396. // this.appendDummyInput()
  397. // .appendField(Blockly.Msg.LED_SET_WORD)
  398. // .appendField(new Blockly.FieldTextInput("stB"), "pin_var2")
  399. // .appendField(Blockly.Msg.MOTOR_AS + " "+ Blockly.Msg.LED_PIN)
  400. // .appendField(new Blockly.FieldTextInput("0"), "pin_2");
  401. // this.appendDummyInput()
  402. // .appendField(Blockly.Msg.LED_SET_WORD)
  403. // .appendField(new Blockly.FieldTextInput("seB"), "pin_var3")
  404. // .appendField(Blockly.Msg.MOTOR_AS + " "+ Blockly.Msg.LED_PIN)
  405. // .appendField(new Blockly.FieldTextInput("1"), "pin_3");
  406. // this.appendDummyInput()
  407. // .appendField(Blockly.Msg.LED_SET_WORD)
  408. // .appendField(new Blockly.FieldTextInput("stC"), "pin_var4")
  409. // .appendField(Blockly.Msg.MOTOR_AS + " "+ Blockly.Msg.LED_PIN)
  410. // .appendField(new Blockly.FieldTextInput("3"), "pin_4");
  411. // this.appendDummyInput()
  412. // .appendField(Blockly.Msg.LED_SET_WORD)
  413. // .appendField(new Blockly.FieldTextInput("seC"), "pin_var5")
  414. // .appendField(Blockly.Msg.MOTOR_AS + " "+ Blockly.Msg.LED_PIN)
  415. // .appendField(new Blockly.FieldTextInput("2"), "pin_5");
  416. // this.appendDummyInput()
  417. // .appendField(Blockly.Msg.LED_SET_WORD)
  418. // .appendField(new Blockly.FieldTextInput("MAX_DISTANCE"), "max_distance_var")
  419. // .appendField(Blockly.Msg.MOTOR_AS)
  420. // .appendField(new Blockly.FieldTextInput("10"), "max_distance");
  421. // this.appendDummyInput()
  422. // .appendField(Blockly.Msg.LED_SET_WORD)
  423. // .appendField(new Blockly.FieldTextInput("REAL_TIME_DISTANCE"), "real_time_distance_var")
  424. // .appendField(Blockly.Msg.MOTOR_AS)
  425. // .appendField(new Blockly.FieldTextInput("6"), "real_time_distance");
  426. // this.setPreviousStatement(true, 'motor_type');
  427. // this.setColour(90);
  428. // this.setTooltip('');
  429. // this.setHelpUrl('');
  430. // }
  431. // };
  432. // Blockly.Blocks['motor_ultrasonic_custom_pin'] = {
  433. // init: function() {
  434. // this.appendDummyInput()
  435. // .appendField(Blockly.Msg.MOTOR_ULTRASONIC_CUST);
  436. // this.appendDummyInput()
  437. // .appendField(Blockly.Msg.LED_SET_WORD)
  438. // .appendField(new Blockly.FieldTextInput("stA"), "custom_pin_var0")
  439. // .appendField(Blockly.Msg.MOTOR_AS + " "+ Blockly.Msg.LED_PIN)
  440. // .appendField(new Blockly.FieldTextInput("A1"), "custom_pin_0");
  441. // this.appendDummyInput()
  442. // .appendField(Blockly.Msg.LED_SET_WORD)
  443. // .appendField(new Blockly.FieldTextInput("seA"), "custom_pin_var1")
  444. // .appendField(Blockly.Msg.MOTOR_AS + " "+ Blockly.Msg.LED_PIN)
  445. // .appendField(new Blockly.FieldTextInput("A0"), "custom_pin_1");
  446. // this.appendDummyInput()
  447. // .appendField(Blockly.Msg.LED_SET_WORD)
  448. // .appendField(new Blockly.FieldTextInput("MAX_DISTANCE"), "custom_max_distance_var")
  449. // .appendField(Blockly.Msg.MOTOR_AS)
  450. // .appendField(new Blockly.FieldTextInput("100"), "custom_max_distance");
  451. // this.appendDummyInput()
  452. // .appendField(Blockly.Msg.LED_SET_WORD)
  453. // .appendField(new Blockly.FieldTextInput("REAL_TIME_DISTANCE"), "custom_real_time_distance_var")
  454. // .appendField(Blockly.Msg.MOTOR_AS)
  455. // .appendField(new Blockly.FieldTextInput("6"), "custom_real_time_distance");
  456. // this.setPreviousStatement(true, 'motor_type');
  457. // this.setNextStatement(true, 'motor_type');
  458. // this.setColour(90);
  459. // this.setTooltip('');
  460. // this.setHelpUrl('');
  461. // }
  462. // };
  463. // Blockly.Blocks['motor_controller'] = {
  464. // init: function() {
  465. // this.appendDummyInput()
  466. // .appendField("Motor")
  467. // .appendField(new Blockly.FieldTextInput("1"), "motor_name")
  468. // .appendField("speed")
  469. // .appendField(new Blockly.FieldNumber(0), "motor_speed");
  470. // this.appendDummyInput()
  471. // .appendField("direction")
  472. // // right --> clockwise --> 1, left --> counter clockwise--> 2
  473. // .appendField(new Blockly.FieldDropdown([["Clockwise","1"], ["Counter Clockwise","2"]]), "motor_direction");
  474. // this.setPreviousStatement(true, null);
  475. // this.setNextStatement(true, null);
  476. // this.setColour(230);
  477. // this.setTooltip("");
  478. // this.setHelpUrl("");
  479. // }
  480. // };
  481. // Blockly.Blocks['motor_stop'] = {
  482. // init: function() {
  483. // this.appendDummyInput()
  484. // .appendField(Blockly.Msg.MOTOR_STOP);
  485. // this.setPreviousStatement(true, 'motor_option');
  486. // this.setColour(330);
  487. // this.setTooltip('');
  488. // this.setHelpUrl('');
  489. // }
  490. // };
  491. // Blockly.Blocks['motor_pause'] = {
  492. // init: function() {
  493. // this.appendDummyInput()
  494. // .appendField("Stop" + "- ")
  495. // .appendField(new Blockly.FieldTextInput("1000"), "delay")
  496. // .appendField(Blockly.Msg.MOTOR_MILLISEC);
  497. // this.setPreviousStatement(true, 'motor_option');
  498. // this.setNextStatement(true, 'motor_option');
  499. // this.setColour(330);
  500. // this.setTooltip('');
  501. // this.setHelpUrl('');
  502. // }
  503. // };
  504. // Blockly.Blocks['robotcar3in1'] = {
  505. // init: function() {
  506. // this.appendDummyInput()
  507. // .appendField("3-in-1 Robot Car");
  508. // this.setColour(230);
  509. // this.setTooltip("");
  510. // this.setHelpUrl("");
  511. // }
  512. // };