led.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  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.led');
  10. goog.require('Blockly.Blocks');
  11. Blockly.Blocks.led.HUE = 198;
  12. Blockly.Blocks['led_neopixel_setup'] = {
  13. init: function() {
  14. this.appendDummyInput()
  15. // .appendField(new Blockly.FieldImage("http://cocorobo.cn/cocoblockly/blockly/media/cocomod_blockly_ledLight.png", 140, 40, "0"));
  16. .appendField(new Blockly.FieldImage("./../blockly/media/main-light.png", 50, 40, "0"));
  17. this.appendDummyInput()
  18. .appendField(Blockly.Msg.LED_SETUP);
  19. this.appendDummyInput()
  20. .appendField(Blockly.Msg.LED_PIN)
  21. .appendField(new Blockly.FieldNumber(6, 0, 13), "neopixel_initpin")
  22. .appendField(Blockly.Msg.LED_BRTN)
  23. .appendField(new Blockly.FieldNumber(20, 0, 255), "neopixel_initbright");
  24. this.appendDummyInput()
  25. .appendField(Blockly.Msg.LED_PANELWIDTH)
  26. .appendField(new Blockly.FieldDropdown([
  27. ["1", "1"],
  28. ["2", "2"],
  29. ["3", "3"],
  30. ["4", "4"],
  31. ["5", "5"],
  32. ["6", "6"],
  33. ]), "neopixel_initwidth");
  34. this.appendDummyInput()
  35. .appendField(Blockly.Msg.LED_PANELHEIGHT)
  36. .appendField(new Blockly.FieldDropdown([
  37. ["1", "1"],
  38. ["2", "2"],
  39. ["3", "3"],
  40. ["4", "4"],
  41. ["5", "5"],
  42. ["6", "6"],
  43. ]), "neopixel_initheight");
  44. this.setColour(Blockly.Blocks.led.HUE);
  45. this.setTooltip('');
  46. this.setHelpUrl('');
  47. }
  48. };
  49. Blockly.Blocks['led_setrotation'] = {
  50. init: function() {
  51. this.appendDummyInput()
  52. .appendField(Blockly.Msg.LED_SET_ROTATION)
  53. // .appendField(new Blockly.FieldDropdown([["0","led_setrotation_option_0"], ["90","led_setrotation_option_90"], ["180","led_setrotation_option_180"], ["270","led_setrotation_option_270"]]), "led_setrotation_option")
  54. .appendField(new Blockly.FieldDropdown([
  55. ["0", "0"],
  56. ["90", "1"],
  57. ["180", "2"],
  58. ["270", "3"]
  59. ]), "led_setrotation_option")
  60. .appendField(Blockly.Msg.LED_SET_ROTATION_DEGREE);
  61. this.setPreviousStatement(true, null);
  62. this.setNextStatement(true, null);
  63. this.setColour(Blockly.Blocks.led.HUE);
  64. this.setTooltip("");
  65. this.setHelpUrl("");
  66. }
  67. };
  68. Blockly.Blocks['led_setbright'] = {
  69. init: function() {
  70. this.appendValueInput("BRIGHTNESS")
  71. .setCheck(Blockly.Types.NUMBER.checkList)
  72. .appendField(Blockly.Msg.LED_SET_BRIGHTNESS);
  73. this.setInputsInline(true);
  74. this.setPreviousStatement(true);
  75. this.setNextStatement(true);
  76. this.setColour(Blockly.Blocks.led.HUE);
  77. this.setTooltip('');
  78. this.setHelpUrl('');
  79. },
  80. onchange: function() {
  81. var bright = Blockly.Python.valueToCode(this, "BRIGHTNESS", Blockly.Python.ORDER_ATOMIC)
  82. if (bright < 0 || bright > 255) {
  83. this.setWarningText(Blockly.Msg.LED_BRIGHTNESS_WARNING, 'fastled_setbright');
  84. } else {
  85. this.setWarningText(null, 'fastled_setbright');
  86. }
  87. },
  88. getBlockType: function() {
  89. return Blockly.Types.NUMBER;
  90. }
  91. };
  92. Blockly.Blocks['led_set_width_height'] = {
  93. init: function() {
  94. this.appendValueInput("WIDTH")
  95. .setCheck("Number")
  96. .appendField(Blockly.Msg.LED_WIDTH);
  97. this.appendValueInput("HEIGHT")
  98. .setCheck("Number")
  99. .appendField(Blockly.Msg.LED_HEIGHT);
  100. this.setOutput(true, "String");
  101. this.setInputsInline(true);
  102. this.setColour(Blockly.Blocks.led.HUE);
  103. this.setTooltip("");
  104. this.setHelpUrl("");
  105. }
  106. };
  107. Blockly.Blocks['led_set_position'] = {
  108. init: function() {
  109. this.appendValueInput("POSX")
  110. .setCheck("Number")
  111. .appendField("X:");
  112. this.appendValueInput("POSY")
  113. .setCheck("Number")
  114. .appendField("Y:");
  115. this.setOutput(true, "String");
  116. this.setInputsInline(true);
  117. this.setColour(Blockly.Blocks.led.HUE);
  118. this.setTooltip("");
  119. this.setHelpUrl("");
  120. }
  121. };
  122. Blockly.Blocks['led_drawpixel'] = {
  123. init: function() {
  124. this.appendDummyInput()
  125. .appendField(
  126. new Blockly.FieldImage("./blockly/media/pixel.png", 25, 25, "15"));
  127. this.appendDummyInput()
  128. .appendField(Blockly.Msg.LED_DRAW + Blockly.Msg.LED_PIXEL);
  129. this.appendValueInput("COLOR")
  130. .setCheck("String")
  131. .appendField(Blockly.Msg.LED_COLOR);
  132. this.appendValueInput("POS")
  133. .setCheck("String")
  134. .appendField(Blockly.Msg.LED_COORDINATE);
  135. this.setInputsInline(false);
  136. this.setPreviousStatement(true);
  137. this.setNextStatement(true);
  138. this.setColour(Blockly.Blocks.led.HUE);
  139. this.setTooltip('');
  140. this.setHelpUrl('');
  141. }
  142. };
  143. Blockly.Blocks['led_drawrect'] = {
  144. init: function() {
  145. this.appendDummyInput()
  146. .appendField(
  147. new Blockly.FieldImage("./../blockly/media/rect.png", 25, 25, "15"));
  148. this.appendDummyInput()
  149. .appendField(Blockly.Msg.LED_DRAW)
  150. .appendField(new Blockly.FieldDropdown([
  151. [Blockly.Msg.OLCD_FULL, "fill"],
  152. [Blockly.Msg.OLCD_STROKED, "draw"]
  153. ]), "rect_type")
  154. .appendField(Blockly.Msg.LED_RECTANGLE);
  155. this.appendValueInput("COLOR")
  156. .setCheck("String")
  157. .appendField(Blockly.Msg.LED_COLOR);
  158. this.appendValueInput("SIZE")
  159. .setCheck("String")
  160. .appendField(Blockly.Msg.LED_SIZE);
  161. this.appendValueInput("POS")
  162. .setCheck("String")
  163. .appendField(Blockly.Msg.LED_COORDINATE);
  164. this.setInputsInline(false);
  165. this.setPreviousStatement(true);
  166. this.setNextStatement(true);
  167. this.setColour(Blockly.Blocks.led.HUE);
  168. this.setTooltip('');
  169. this.setHelpUrl('');
  170. }
  171. };
  172. Blockly.Blocks['led_drawline'] = {
  173. init: function() {
  174. this.appendDummyInput()
  175. .appendField(
  176. new Blockly.FieldImage("./../blockly/media/line.png", 25, 25, "15"));
  177. this.appendDummyInput()
  178. .appendField(Blockly.Msg.LED_DRAW + Blockly.Msg.LED_LINE);
  179. this.appendValueInput("COLOR")
  180. .setCheck("String")
  181. .appendField(Blockly.Msg.LED_COLOR);
  182. this.appendValueInput("POSA")
  183. .setCheck("String")
  184. .appendField(Blockly.Msg.LED_LINE_START);
  185. this.appendValueInput("POSB")
  186. .setCheck("String")
  187. .appendField(Blockly.Msg.LED_LINE_END);
  188. this.setInputsInline(false);
  189. this.setPreviousStatement(true);
  190. this.setNextStatement(true);
  191. this.setColour(Blockly.Blocks.led.HUE);
  192. this.setTooltip('');
  193. this.setHelpUrl('');
  194. }
  195. };
  196. Blockly.Blocks['led_showall'] = {
  197. init: function() {
  198. this.appendDummyInput()
  199. .appendField(Blockly.Msg.LED_SHOW_ALL);
  200. this.setPreviousStatement(true, null);
  201. this.setNextStatement(true, null);
  202. this.setColour(Blockly.Blocks.led.HUE);
  203. this.setTooltip('');
  204. this.setHelpUrl('');
  205. }
  206. };
  207. Blockly.Blocks['led_clear'] = {
  208. init: function() {
  209. this.appendDummyInput()
  210. .appendField(Blockly.Msg.LED_CLEAR);
  211. this.setPreviousStatement(true, null);
  212. this.setNextStatement(true, null);
  213. this.setColour(Blockly.Blocks.led.HUE);
  214. this.setTooltip('');
  215. this.setHelpUrl('');
  216. }
  217. };
  218. Blockly.Blocks['led_text'] = {
  219. init: function() {
  220. this.appendDummyInput()
  221. .appendField(Blockly.Msg.LED_COORDINATE)
  222. .appendField("x")
  223. .appendField(new Blockly.FieldTextInput("1"), "x_val")
  224. .appendField("y")
  225. .appendField(new Blockly.FieldTextInput("1"), "y_val");
  226. this.appendValueInput("text_color")
  227. .setCheck("String")
  228. .appendField(Blockly.Msg.LED_TEXT)
  229. this.appendValueInput("back_color")
  230. .setCheck("String")
  231. .appendField(Blockly.Msg.LED_BACKCOLOR)
  232. this.appendDummyInput()
  233. .appendField(Blockly.Msg.LED_SIZE)
  234. .appendField(new Blockly.FieldNumber(1, 0, 4, 1), "text_size");
  235. this.setPreviousStatement(true, null);
  236. this.setNextStatement(true, null);
  237. this.setInputsInline(true);
  238. this.setColour(Blockly.Blocks.led.HUE);
  239. this.setTooltip('');
  240. this.setHelpUrl('');
  241. }
  242. };
  243. Blockly.Blocks['led_scrolling_text'] = {
  244. init: function() {
  245. this.appendDummyInput()
  246. .appendField("Scrolling");
  247. this.appendDummyInput()
  248. .appendField("speed")
  249. .appendField(new Blockly.FieldTextInput("100"), "led_scrolling_speed");
  250. this.appendValueInput("led_scrolling_color")
  251. .setCheck("String")
  252. this.setPreviousStatement(true, null);
  253. this.setNextStatement(true, null);
  254. this.setInputsInline(true);
  255. this.setColour(Blockly.Blocks.led.HUE);
  256. this.setTooltip("");
  257. this.setHelpUrl("");
  258. }
  259. };
  260. Blockly.Blocks['led_pattern_5x5'] = {
  261. init: function() {
  262. this.appendDummyInput()
  263. .appendField(
  264. new Blockly.FieldImage("./../blockly/media/pattern.png", 25, 25, "15"))
  265. .appendField(Blockly.Msg.LED_DRAW + Blockly.Msg.LED_PATTERN);
  266. this.appendDummyInput()
  267. .appendField(" ")
  268. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "0_0")
  269. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "0_1")
  270. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "0_2")
  271. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "0_3")
  272. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "0_4")
  273. .appendField(" ");
  274. this.appendDummyInput()
  275. .appendField(" ")
  276. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "1_0")
  277. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "1_1")
  278. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "1_2")
  279. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "1_3")
  280. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "1_4")
  281. .appendField(" ");
  282. this.appendDummyInput()
  283. .appendField(" ")
  284. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "2_0")
  285. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "2_1")
  286. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "2_2")
  287. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "2_3")
  288. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "2_4")
  289. .appendField(" ");
  290. this.appendDummyInput()
  291. .appendField(" ")
  292. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "3_0")
  293. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "3_1")
  294. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "3_2")
  295. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "3_3")
  296. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "3_4")
  297. .appendField(" ");
  298. this.appendDummyInput()
  299. .appendField(" ")
  300. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "4_0")
  301. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "4_1")
  302. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "4_2")
  303. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "4_3")
  304. .appendField((new Blockly.FieldColour("#3B5587")).setColours(["#3B5587", "#FFFFFF", "#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#FF00FF", "#FFC0CB"]), "4_4")
  305. .appendField(" ");
  306. this.setPreviousStatement(true);
  307. this.setNextStatement(true);
  308. this.setColour(Blockly.Blocks.led.HUE);
  309. this.setTooltip('');
  310. this.setHelpUrl('');
  311. }
  312. };
  313. /*
  314. draw a num or vocabulary in 5x5
  315. */
  316. Blockly.Blocks['led_drawWord_5x5'] = {
  317. init: function() {
  318. this.appendDummyInput()
  319. .appendField(
  320. new Blockly.FieldImage("./../blockly/media/text.png", 25, 25, "15"));
  321. this.appendValueInput("WORD")
  322. .appendField(Blockly.Msg.LED_WORD);
  323. this.appendValueInput("COLOR")
  324. .appendField(Blockly.Msg.LED_COLOR);
  325. this.setPreviousStatement(true);
  326. this.setNextStatement(true);
  327. this.setColour(Blockly.Blocks.led.HUE);
  328. this.setTooltip('');
  329. this.setHelpUrl('');
  330. }
  331. };
  332. /*
  333. *draw a text with option:
  334. * scroll
  335. * setFont
  336. */
  337. Blockly.Blocks['led_text_input'] = {
  338. init: function() {
  339. this.appendDummyInput()
  340. .appendField(new Blockly.FieldImage("./../blockly/media/text.png", 25, 25, "15"));
  341. this.appendDummyInput()
  342. .appendField(Blockly.Msg.LED_SCROLL)
  343. .appendField(new Blockly.FieldDropdown([
  344. [Blockly.Msg.LED_SCROLL_NO, '0'],
  345. [Blockly.Msg.LED_SCROLL_YES, '1']
  346. ]), "scroll")
  347. this.appendDummyInput()
  348. .appendField(Blockly.Msg.LED_FONT)
  349. .appendField(new Blockly.FieldDropdown([
  350. ["5x5", '1'],
  351. ["5x7", '2'],
  352. ["10x12", "3"]
  353. ]), "font")
  354. .appendField("px")
  355. this.appendValueInput("TEXT")
  356. .appendField(Blockly.Msg.LED_TEXT);
  357. this.appendValueInput("COLOR")
  358. .appendField(Blockly.Msg.LED_COLOR);
  359. this.appendValueInput("POS")
  360. .appendField(Blockly.Msg.LED_COORDINATE);
  361. this.setPreviousStatement(true);
  362. this.setNextStatement(true);
  363. this.setColour(Blockly.Blocks.led.HUE);
  364. this.setTooltip('');
  365. this.setHelpUrl('');
  366. }
  367. };
  368. /*
  369. *draw emotion { :) , :| , :( }
  370. */
  371. Blockly.Blocks['led_draw_emotion'] = {
  372. init: function() {
  373. this.appendDummyInput("image")
  374. .appendField(new Blockly.FieldImage("./../blockly/media/pattern.png", 25, 25, "15"), "face_image");
  375. this.appendDummyInput()
  376. .appendField(Blockly.Msg.LED_DRAW)
  377. .appendField(new Blockly.FieldDropdown([
  378. [":) SMILE", '1'],
  379. [":| NORMAL", '2'],
  380. [":( SAD", '3']
  381. ]), "face")
  382. this.appendValueInput("COLOR")
  383. .appendField(Blockly.Msg.LED_COLOR);
  384. // this.appendValueInput("POS")
  385. // .appendField(Blockly.Msg.LED_COORDINATE);
  386. this.updateImage_();
  387. this.setPreviousStatement(true);
  388. this.setNextStatement(true);
  389. this.setColour(Blockly.Blocks.led.HUE);
  390. this.setTooltip('');
  391. this.setHelpUrl('');
  392. },
  393. updateImage_: function() {
  394. var input = this.getInput("image");
  395. var type = this.getFieldValue("face");
  396. switch (type) {
  397. case "1":
  398. input.removeField("face_image");
  399. input.appendField(new Blockly.FieldImage("./../blockly/media/emotion.png", 40, 40, "15"), "face_image");
  400. break;
  401. case "2":
  402. input.removeField("face_image");
  403. input.appendField(new Blockly.FieldImage("./../blockly/media/normal-face.png", 40, 40, "15"), "face_image");
  404. break;
  405. case "3":
  406. input.removeField("face_image");
  407. input.appendField(new Blockly.FieldImage("./../blockly/media/sad-face.png", 40, 40, "15"), "face_image");
  408. break;
  409. }
  410. }
  411. };
  412. /**
  413. * draw pixel in led strip
  414. */
  415. Blockly.Blocks['led_draw_strip'] = {
  416. init: function() {
  417. this.appendDummyInput()
  418. .appendField(
  419. new Blockly.FieldImage("./../blockly/media/strip_pixel.png", 25, 25, "15"));
  420. // new Blockly.FieldImage("./../blockly/media/strip_pixel.png", 25, 25, "15"));
  421. this.appendDummyInput()
  422. .appendField(Blockly.Msg.LED_STRIP_PIXEL);
  423. this.appendValueInput("COLOR")
  424. .setCheck("String")
  425. .appendField(Blockly.Msg.LED_COLOR);
  426. this.appendValueInput("LOC")
  427. .setCheck("Number")
  428. .appendField(Blockly.Msg.LED_STRIP_LOCATION);
  429. this.setInputsInline(false);
  430. this.setPreviousStatement(true);
  431. this.setNextStatement(true);
  432. this.setColour(Blockly.Blocks.led.HUE);
  433. this.setTooltip('');
  434. this.setHelpUrl('');
  435. }
  436. };
  437. Blockly.Blocks['led_set_color'] = {
  438. init: function() {
  439. this.appendDummyInput()
  440. .appendField(Blockly.Msg.COLOR)
  441. .appendField(new Blockly.FieldColour("#ff0000"), "COLOR");
  442. this.setOutput(true, "String");
  443. this.setColour(Blockly.Blocks.led.HUE);
  444. this.setTooltip("");
  445. this.setHelpUrl("");
  446. }
  447. };
  448. Blockly.Blocks['led_set_colorRGB'] = {
  449. init: function() {
  450. this.appendDummyInput()
  451. .appendField(Blockly.Msg.COLOR);
  452. this.appendValueInput("RED_VAL")
  453. .setCheck(null)
  454. .appendField(Blockly.Msg.RED);
  455. this.appendValueInput("GREEN_VAL")
  456. .setCheck(null)
  457. .appendField(Blockly.Msg.GREEN);
  458. this.appendValueInput("BLUE_VAL")
  459. .setCheck(null)
  460. .appendField(Blockly.Msg.BLUE);
  461. this.setInputsInline(true);
  462. this.setOutput(true, "String");
  463. this.setColour(Blockly.Blocks.led.HUE);
  464. this.setTooltip("");
  465. this.setHelpUrl("http://help.cocorobo.cn/#/cocomod/color-analyzer?id=rgb-%E5%8F%96%E8%89%B2%E5%99%A8");
  466. }
  467. }