screen.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. 'use strict';
  2. goog.provide('Blockly.Blocks.screen');
  3. goog.require('Blockly.Blocks');
  4. goog.require('Blockly.Types');
  5. Blockly.Blocks['lcd_setup'] = {
  6. init: function() {
  7. this.appendDummyInput()
  8. // .appendField(new Blockly.FieldImage("http://cocorobo.cn/cocoblockly/blockly/media/cocomod_blockly_oledScreen.png", 140, 40, "0"));
  9. .appendField(new Blockly.FieldImage("./../blockly/media/main-screen.png", 50, 40, "0"));
  10. this.appendDummyInput()
  11. .appendField(Blockly.Msg.OLCD_SETUP);
  12. this.setColour(245);
  13. this.setTooltip('');
  14. this.setHelpUrl('');
  15. }
  16. };
  17. Blockly.Blocks['lcd_set_width_height'] = {
  18. init: function() {
  19. this.appendValueInput("WIDTH")
  20. .setCheck("Number")
  21. .appendField(Blockly.Msg.OLCD_WIDTH);
  22. this.appendValueInput("HEIGHT")
  23. .setCheck("Number")
  24. .appendField(Blockly.Msg.OLCD_HEIGHT);
  25. this.setOutput(true, "String");
  26. this.setInputsInline(true);
  27. this.setColour("#5bb2d6");
  28. this.setTooltip("");
  29. this.setHelpUrl("");
  30. }
  31. };
  32. Blockly.Blocks['lcd_set_bool'] = {
  33. init: function() {
  34. this.appendDummyInput()
  35. .appendField(Blockly.Msg.ARD_TYPE_BOOL)
  36. .appendField(new Blockly.FieldCheckbox("TRUE"), "BOOL");
  37. this.setOutput(true, "Boolean");
  38. this.setColour("#5bb2d6");
  39. this.setTooltip("");
  40. this.setHelpUrl("");
  41. }
  42. };
  43. Blockly.Blocks['lcd_get_WH'] = {
  44. init: function() {
  45. this.jsonInit({
  46. colour: CategoryColors.Show,
  47. args0: [{
  48. name: "display_fill",
  49. options: [
  50. [Blockly.Msg.LED_WIDTH, "0"],
  51. [Blockly.Msg.LED_HEIGHT, "1"]
  52. ],
  53. type: "field_dropdown"
  54. }],
  55. nextStatement: null,
  56. previousStatement: null,
  57. helpUrl: "",
  58. tooltip: "",
  59. message0: Blockly.Msg.GLCDD
  60. })
  61. }
  62. };
  63. Blockly.Python['lcd_get_WH'] = function(a) {
  64. var _text = a.getFieldValue("display_fill");
  65. return "tft.size()[" + _text + "]";
  66. };
  67. Blockly.Blocks['lcd_set_position'] = {
  68. init: function() {
  69. this.appendValueInput("POSX")
  70. .setCheck("Number")
  71. .appendField("X:");
  72. this.appendValueInput("POSY")
  73. .setCheck("Number")
  74. .appendField("Y:");
  75. this.setOutput(true, "String");
  76. this.setInputsInline(true);
  77. this.setColour("#5bb2d6");
  78. this.setTooltip("");
  79. this.setHelpUrl("");
  80. }
  81. };
  82. Blockly.Blocks['lcd_set_width'] = {
  83. init: function() {
  84. this.appendValueInput("Width")
  85. .setCheck("Number")
  86. .appendField("Width:");
  87. this.setOutput(true, "String");
  88. this.setInputsInline(true);
  89. this.setColour("#5bb2d6");
  90. this.setTooltip("");
  91. this.setHelpUrl("");
  92. }
  93. };
  94. Blockly.Blocks['lcd_set_Scale'] = {
  95. init: function() {
  96. this.appendValueInput("Scale")
  97. .setCheck("Number")
  98. .appendField(Blockly.Msg.OLCD_SCALE);
  99. this.setOutput(true, "String");
  100. this.setInputsInline(true);
  101. this.setColour("#5bb2d6");
  102. this.setTooltip("");
  103. this.setHelpUrl("");
  104. }
  105. };
  106. Blockly.Blocks['lcd_screen'] = {
  107. init: function() {
  108. // this.appendDummyInput()
  109. // .appendField(
  110. // new Blockly.FieldImage("./../blockly/media/line.png", 25, 25, "15"));
  111. this.appendDummyInput()
  112. .appendField(Blockly.Msg.OLCD_DRAW + Blockly.Msg.OLCD_SCREEN)
  113. .appendField(Blockly.Msg.PROCEDURES_BEFORE_PARAMS)
  114. .appendField(new Blockly.FieldColour("#ff0000"), "COLOR");
  115. // this.appendValueInput("COLOR")
  116. // .setCheck("String")
  117. // .appendField(Blockly.Msg.OLCD_COLOR);
  118. // this.appendValueInput("POSA")
  119. // .setCheck("String")
  120. // .appendField(Blockly.Msg.OLCD_LINE_START);
  121. // this.appendValueInput("POSB")
  122. // .setCheck("String")
  123. // .appendField(Blockly.Msg.OLCD_LINE_END);
  124. //this.setInputsInline(false);
  125. this.setPreviousStatement(true);
  126. this.setNextStatement(true);
  127. this.setColour("#5bb2d6");
  128. this.setTooltip('');
  129. this.setHelpUrl('');
  130. }
  131. };
  132. Blockly.Python['lcd_screen'] = function(a) {
  133. a = a.getFieldValue("COLOR") || Blockly.Python.valueToCode(a, 'COLOR', Blockly.Python.ORDER_ATOMIC);
  134. var d = 0,
  135. e = 0,
  136. f = 0;
  137. try {
  138. 7 == a.length && (d = parseInt(a.substring(1, 3), 16),
  139. e = parseInt(a.substring(3, 5), 16),
  140. f = parseInt(a.substring(5, 7), 16))
  141. } catch (g) {}
  142. // var _code = "FS_RGB = (" + d + "," + e + "," + f + ")\n";
  143. // _code += "FS_COLOR = ((FS_RGB[0] & 0xF8) << 8) | ((FS_RGB[1] & 0xFC) << 3) | (FS_RGB[2] >> 3)\n";
  144. // _code += "tft.fill(FS_COLOR)\n";
  145. //var _code = "tft.fill(TFT.TFTColor(0x" + d + ", 0x" + e + ", 0x" + f + "))\n";
  146. var _code = "(" + d + "," + e + "," + f + ")";
  147. return _code;
  148. };
  149. Blockly.Blocks['lcd_drawline'] = {
  150. init: function() {
  151. // this.appendDummyInput()
  152. // .appendField(
  153. // new Blockly.FieldImage("./../blockly/media/line.png", 25, 25, "15"));
  154. this.appendDummyInput()
  155. .appendField(Blockly.Msg.OLCD_DRAW + Blockly.Msg.OLCD_LINE);
  156. this.appendValueInput("COLOR")
  157. .setCheck("String")
  158. .appendField(Blockly.Msg.OLCD_COLOR);
  159. this.appendValueInput("POSA")
  160. .setCheck("String")
  161. .appendField(Blockly.Msg.OLCD_LINE_START);
  162. this.appendValueInput("POSB")
  163. .setCheck("String")
  164. .appendField(Blockly.Msg.OLCD_LINE_END);
  165. this.setInputsInline(false);
  166. this.setPreviousStatement(true);
  167. this.setNextStatement(true);
  168. this.setColour("#5bb2d6");
  169. this.setTooltip('');
  170. this.setHelpUrl('');
  171. }
  172. };
  173. Blockly.Blocks['lcd_drawvhline'] = {
  174. init: function() {
  175. // this.appendDummyInput()
  176. // .appendField(
  177. // new Blockly.FieldImage("./../blockly/media/line.png", 25, 25, "15"));
  178. this.appendDummyInput()
  179. .appendField(Blockly.Msg.OLCD_DRAW)
  180. .appendField(new Blockly.FieldDropdown([
  181. [Blockly.Msg.OLCD_FULL, "fillrect"],
  182. [Blockly.Msg.OLCD_CIRCLE, "rect"]
  183. ]), "rect_type")
  184. .appendField(Blockly.Msg.OLCD_LINE)
  185. this.appendValueInput("COLOR")
  186. .setCheck("String")
  187. .appendField(Blockly.Msg.OLCD_COLOR);
  188. this.appendValueInput("POSA")
  189. .setCheck("String")
  190. .appendField(Blockly.Msg.OLCD_COORDINATE);
  191. this.appendValueInput("POSB")
  192. .setCheck("String")
  193. .appendField(Blockly.Msg.OLCD_SIZE);
  194. this.setInputsInline(false);
  195. this.setPreviousStatement(true);
  196. this.setNextStatement(true);
  197. this.setColour("#5bb2d6");
  198. this.setTooltip('');
  199. this.setHelpUrl('');
  200. }
  201. };
  202. Blockly.Blocks['ai_lcd_drawvhtext'] = {
  203. init: function() {
  204. this.appendDummyInput()
  205. .appendField(Blockly.Msg.LCDDT);
  206. this.appendValueInput("POSA")
  207. .setCheck("String")
  208. .appendField(Blockly.Msg.LED_COORDINATE);
  209. this.appendValueInput("CONTENT")
  210. .setCheck("String")
  211. .appendField(Blockly.Msg.WIFISERVER_SERVERSEND_CONTENT);
  212. this.appendValueInput("COLOR")
  213. .setCheck("String")
  214. .appendField(Blockly.Msg.LCDDT_C);
  215. this.appendValueInput("BCOLOR")
  216. .setCheck("String")
  217. .appendField(Blockly.Msg.LCDDT_BC);
  218. this.setInputsInline(false);
  219. this.setPreviousStatement(true);
  220. this.setNextStatement(true);
  221. this.setColour("#5bb2d6");
  222. this.setTooltip('');
  223. this.setHelpUrl('');
  224. }
  225. };
  226. Blockly.Blocks['lcd_drawlinelen'] = {
  227. init: function() {
  228. // this.appendDummyInput()
  229. // .appendField(
  230. // new Blockly.FieldImage("./../blockly/media/line.png", 25, 25, "15"));
  231. this.appendDummyInput()
  232. .appendField(Blockly.Msg.OLCD_DRAW)
  233. .appendField(new Blockly.FieldDropdown([
  234. [Blockly.Msg.OLCD_VLINE, "vline"],
  235. [Blockly.Msg.OLCD_HEIGHT, "hline"]
  236. ]), "rect_type")
  237. .appendField(Blockly.Msg.OLCD_LINE)
  238. this.appendValueInput("COLOR")
  239. .setCheck("String")
  240. .appendField(Blockly.Msg.OLCD_COLOR);
  241. this.appendValueInput("POSA")
  242. .setCheck("String")
  243. .appendField(Blockly.Msg.OLCD_LINE_START);
  244. this.appendValueInput("POSB")
  245. .setCheck("String")
  246. .appendField(Blockly.Msg.OLCD_LENGTHIS);
  247. this.setInputsInline(false);
  248. this.setPreviousStatement(true);
  249. this.setNextStatement(true);
  250. this.setColour("#5bb2d6");
  251. this.setTooltip('');
  252. this.setHelpUrl('');
  253. }
  254. };
  255. Blockly.Blocks['lcd_color'] = {
  256. init: function() {
  257. this.appendDummyInput()
  258. .appendField(Blockly.Msg.COLOR)
  259. .appendField(new Blockly.FieldColour("#ff0000"), "COLOR");
  260. this.setOutput(true, null);
  261. this.setColour("#5bb2d6");
  262. this.setTooltip('');
  263. this.setHelpUrl('');
  264. }
  265. };
  266. Blockly.Python['lcd_color'] = function(a) {
  267. // a = a.getFieldValue("COLOR");
  268. // var d = 0
  269. // , e = 0
  270. // , f = 0;
  271. // try {
  272. // 7 == a.length && (d = a.substring(1, 3),
  273. // e = a.substring(3, 5),
  274. // f = a.substring(5, 7));
  275. // }
  276. // catch (g) { }
  277. var _code = Blockly.Python['lcd_screen'](a);
  278. _code = "_TFTColor" + _code + "";
  279. //_code += "tft.fill(TFT.TFTColor(FS_COLOR))\n";
  280. return _code;
  281. };
  282. Blockly.Blocks['lcd_drawrect'] = {
  283. init: function() {
  284. //this.appendDummyInput()
  285. // .appendField(
  286. // new Blockly.FieldImage("./../blockly/media/rect.png", 25, 25, "15"));
  287. this.appendDummyInput()
  288. .appendField(Blockly.Msg.OLCD_DRAW)
  289. // .appendField(new Blockly.FieldDropdown([
  290. // [Blockly.Msg.OLCD_FULL, "fill"],
  291. // [Blockly.Msg.OLCD_STROKED, "draw"]
  292. // ]), "rect_type")
  293. .appendField(Blockly.Msg.LED_PIXEL);
  294. this.appendValueInput("COLOR")
  295. .setCheck("String")
  296. .appendField(Blockly.Msg.OLCD_COLOR);
  297. // this.appendValueInput("SIZE")
  298. // .setCheck("String")
  299. // .appendField(Blockly.Msg.OLCD_SIZE);
  300. this.appendValueInput("POS")
  301. .setCheck("String")
  302. .appendField(Blockly.Msg.OLCD_COORDINATE);
  303. this.setInputsInline(false);
  304. this.setPreviousStatement(true);
  305. this.setNextStatement(true);
  306. this.setColour("#5bb2d6");
  307. this.setTooltip('');
  308. this.setHelpUrl('');
  309. }
  310. };
  311. Blockly.Blocks['lcd_drawcircle'] = {
  312. init: function() {
  313. // this.appendDummyInput()
  314. // .appendField(
  315. // new Blockly.FieldImage("./../blockly/media/circle.png", 25, 25, "15"));
  316. this.appendDummyInput()
  317. .appendField(Blockly.Msg.OLCD_DRAW)
  318. .appendField(new Blockly.FieldDropdown([
  319. [Blockly.Msg.OLCD_FULL, "fillcircle"],
  320. [Blockly.Msg.OLCD_STROKED, "circle"]
  321. ]), "circle_type")
  322. .appendField(Blockly.Msg.OLCD_CIRCLE);
  323. this.appendValueInput("COLOR")
  324. .setCheck("String")
  325. .appendField(Blockly.Msg.OLCD_COLOR);
  326. this.appendValueInput("POSA")
  327. .setCheck("String")
  328. .appendField(Blockly.Msg.OLCD_CENTER_POS);
  329. this.appendValueInput("RADIUS")
  330. .setCheck("Number")
  331. .appendField(Blockly.Msg.OLCD_RADIUS);
  332. this.setInputsInline(false);
  333. this.setPreviousStatement(true);
  334. this.setNextStatement(true);
  335. this.setColour("#5bb2d6");
  336. this.setTooltip('');
  337. this.setHelpUrl('');
  338. }
  339. };
  340. Blockly.Blocks['lcd_drawqrcode'] = {
  341. init: function() {
  342. // this.appendDummyInput()
  343. // .appendField(
  344. // new Blockly.FieldImage("./../blockly/media/circle.png", 25, 25, "15"));
  345. this.appendDummyInput()
  346. .appendField(Blockly.Msg.OLCD_DRAW + Blockly.Msg.LCDRQ);
  347. this.appendValueInput("POSA")
  348. .setCheck("String")
  349. .appendField(Blockly.Msg.OLCD_SET_POS);
  350. this.appendValueInput("CONTENT")
  351. .setCheck("String")
  352. .appendField(Blockly.Msg.WIFISERVER_SERVERSEND_CONTENT);
  353. this.appendValueInput("WIDTH")
  354. .setCheck("Number")
  355. .appendField(Blockly.Msg.OLCD_WT);
  356. this.setInputsInline(false);
  357. this.setPreviousStatement(true);
  358. this.setNextStatement(true);
  359. this.setColour("#5bb2d6");
  360. this.setTooltip('');
  361. this.setHelpUrl('');
  362. }
  363. };
  364. Blockly.Blocks['lcd_drawtext'] = {
  365. init: function() {
  366. // this.appendDummyInput()
  367. // .appendField(
  368. // new Blockly.FieldImage("./../blockly/media/circle.png", 25, 25, "15"));
  369. this.appendDummyInput()
  370. .appendField(Blockly.Msg.OLCD_DRAW + Blockly.Msg.ARD_TYPE_TEXT);
  371. this.appendValueInput("COLOR")
  372. .setCheck("String")
  373. .appendField(Blockly.Msg.OLCD_COLOR);
  374. this.appendValueInput("POSA")
  375. .setCheck("String")
  376. .appendField(Blockly.Msg.OLCD_CENTER_POS);
  377. this.appendValueInput("CONTENT")
  378. .setCheck("String")
  379. .appendField(Blockly.Msg.WIFISERVER_SERVERSEND_CONTENT);
  380. this.appendDummyInput()
  381. .appendField(Blockly.Msg.OLCD_SCALE)
  382. .appendField(new Blockly.FieldNumber(1), 'TextContnet');
  383. this.appendDummyInput()
  384. .appendField(Blockly.Msg.OLCD_WT)
  385. .appendField(new Blockly.FieldCheckbox('TRUE'), 'TextCheckBox');
  386. this.setInputsInline(false);
  387. this.setPreviousStatement(true);
  388. this.setNextStatement(true);
  389. this.setColour("#5bb2d6");
  390. this.setTooltip('');
  391. this.setHelpUrl('');
  392. }
  393. };
  394. Blockly.Blocks['lcd_drawtriangle'] = {
  395. init: function() {
  396. this.appendDummyInput()
  397. .appendField(
  398. new Blockly.FieldImage("./../blockly/media/triangle.png", 25, 25, "15"));
  399. this.appendDummyInput()
  400. .appendField(Blockly.Msg.OLCD_DRAW)
  401. .appendField(new Blockly.FieldDropdown([
  402. [Blockly.Msg.OLCD_FULL, "fill"],
  403. [Blockly.Msg.OLCD_STROKED, "draw"]
  404. ]), "triangle_type")
  405. .appendField(Blockly.Msg.OLCD_TRIANGLE);
  406. this.appendValueInput("COLOR")
  407. .setCheck(null)
  408. .appendField(Blockly.Msg.OLCD_COLOR);
  409. this.appendValueInput("POSA")
  410. .setCheck("String")
  411. .appendField(Blockly.Msg.OLCD_POINT + ' A');
  412. this.appendValueInput("POSB")
  413. .setCheck("String")
  414. .appendField(Blockly.Msg.OLCD_POINT + ' B');
  415. this.appendValueInput("POSC")
  416. .setCheck("String")
  417. .appendField(Blockly.Msg.OLCD_POINT + ' C');
  418. this.setInputsInline(false);
  419. this.setPreviousStatement(true);
  420. this.setNextStatement(true);
  421. this.setColour(245);
  422. this.setTooltip('');
  423. this.setHelpUrl('');
  424. }
  425. };
  426. Blockly.Blocks['lcd_text'] = {
  427. init: function() {
  428. this.appendDummyInput()
  429. .appendField(
  430. new Blockly.FieldImage("./../blockly/media/text.png", 25, 25, "15"));
  431. this.appendDummyInput()
  432. .appendField(Blockly.Msg.OLCD_TEXTNEWLINE)
  433. .appendField(new Blockly.FieldDropdown([
  434. [Blockly.Msg.OLCD_TRUE, "println"],
  435. [Blockly.Msg.OLCD_FALSE, "print"]
  436. ]), "print_type");
  437. this.appendValueInput("INPUT")
  438. .setCheck(null)
  439. .appendField(Blockly.Msg.OLCD_TEXT);
  440. this.appendValueInput("COLOR")
  441. .setCheck("String")
  442. .appendField(Blockly.Msg.OLCD_COLOR);
  443. this.appendValueInput("POS")
  444. .setCheck("String")
  445. .appendField(Blockly.Msg.OLCD_COORDINATE);
  446. this.appendValueInput("SIZE")
  447. .setCheck("Number")
  448. .appendField(Blockly.Msg.OLCD_SIZE);
  449. this.setInputsInline(false);
  450. this.setPreviousStatement(true);
  451. this.setNextStatement(true);
  452. this.setColour(245);
  453. this.setTooltip('');
  454. this.setHelpUrl('');
  455. }
  456. };
  457. Blockly.Blocks['lcd_clear'] = {
  458. init: function() {
  459. this.appendDummyInput()
  460. .appendField(Blockly.Msg.OLCD_CLEAR);
  461. this.setPreviousStatement(true, null);
  462. this.setNextStatement(true, null);
  463. this.setColour(245);
  464. this.setTooltip('');
  465. this.setHelpUrl('');
  466. }
  467. };
  468. Blockly.Blocks['lcd_rotation'] = {
  469. init: function() {
  470. this.appendDummyInput()
  471. .appendField(Blockly.Msg.OLCD_SETROTATION)
  472. .appendField(new Blockly.FieldDropdown([
  473. ["0°", "1"],
  474. ["90°", "2"],
  475. ["180°", "3"],
  476. ["270°", "0"]
  477. ]), "DEGREE")
  478. .appendField(Blockly.Msg.OLCD_SETROTATION_DEGREE)
  479. this.setPreviousStatement(true, null);
  480. this.setNextStatement(true, null);
  481. this.setColour("#5bb2d6");
  482. this.setTooltip('');
  483. this.setHelpUrl('');
  484. }
  485. }
  486. Blockly.Blocks['ai_lcd_invertcanvas'] = {
  487. init: function() {
  488. this.appendDummyInput()
  489. .appendField(Blockly.Msg.LCDSCIC)
  490. .appendField(new Blockly.FieldVariable("canvas"), "varitem")
  491. .appendField(Blockly.Msg.LCDSCIC_I)
  492. this.setPreviousStatement(true, null);
  493. this.setNextStatement(true, null);
  494. this.setColour("#5bb2d6");
  495. this.setTooltip('');
  496. this.setHelpUrl('');
  497. }
  498. }
  499. Blockly.Python.ai_lcd_invertcanvas = function(block) {
  500. var variable_name = Blockly.Python.variableDB_.getName(block.getFieldValue('varitem'), Blockly.Variables.NAME_TYPE);
  501. var _code = variable_name + " = canvas.invert()\n";
  502. return _code;;
  503. }
  504. Blockly.Blocks['lcd_set_color'] = {
  505. init: function() {
  506. this.appendDummyInput()
  507. .appendField(Blockly.Msg.COLOR)
  508. .appendField(new Blockly.FieldColour("#ff0000"), "COLOR");
  509. this.setOutput(true, "String");
  510. this.setColour("#5bb2d6");
  511. this.setTooltip("");
  512. this.setHelpUrl("");
  513. }
  514. };
  515. Blockly.Blocks['lcd_set_colortext'] = {
  516. init: function() {
  517. this.appendDummyInput()
  518. .appendField(Blockly.Msg.COLOR)
  519. .appendField(new Blockly.FieldDropdown([
  520. ["黑色", "BLACK"],
  521. ["紅色", "RED"],
  522. ["綠色", "GREEN"],
  523. ["藍色", "BLUE"],
  524. ["紫色", "PURPLE"],
  525. ["青色", "CYAN"],
  526. ["橙色", "ORANGE"],
  527. ["黃色", "YELLOW"]
  528. ]), "COLOR");
  529. this.setOutput(true, "String");
  530. this.setColour("#5bb2d6");
  531. this.setTooltip("");
  532. this.setHelpUrl("");
  533. }
  534. };
  535. Blockly.Blocks['lcd_set_colorRGB'] = {
  536. init: function() {
  537. this.appendDummyInput()
  538. .appendField(Blockly.Msg.COLOR);
  539. this.appendValueInput("RED_VAL")
  540. .setCheck(null)
  541. .appendField(Blockly.Msg.RED);
  542. this.appendValueInput("GREEN_VAL")
  543. .setCheck(null)
  544. .appendField(Blockly.Msg.GREEN);
  545. this.appendValueInput("BLUE_VAL")
  546. .setCheck(null)
  547. .appendField(Blockly.Msg.BLUE);
  548. this.setInputsInline(true);
  549. this.setOutput(true, "String");
  550. this.setColour(245);
  551. this.setTooltip("");
  552. this.setHelpUrl("http://help.cocorobo.cn/#/cocomod/color-analyzer?id=rgb-%E5%8F%96%E8%89%B2%E5%99%A8");
  553. }
  554. }
  555. Blockly.Blocks['ai_lcd_drawrect'] = {
  556. init: function() {
  557. this.appendDummyInput()
  558. .appendField(Blockly.Msg.OLCD_DRAW)
  559. .appendField(Blockly.Msg.LED_PIXEL);
  560. this.appendValueInput("COLOR")
  561. .setCheck("String")
  562. .appendField(Blockly.Msg.OLCD_COLOR);
  563. this.appendValueInput("POS")
  564. .setCheck("String")
  565. .appendField(Blockly.Msg.OLCD_COORDINATE);
  566. this.setInputsInline(false);
  567. this.setPreviousStatement(true);
  568. this.setNextStatement(true);
  569. this.setColour("#5bb2d6");
  570. this.setTooltip('');
  571. this.setHelpUrl('');
  572. }
  573. };
  574. Blockly.Blocks['ai_camera_filp'] = {
  575. init: function() {
  576. this.appendDummyInput()
  577. .appendField(Blockly.Msg.LCDMF)
  578. .appendField(new Blockly.FieldCheckbox('TRUE'), 'TextCheckBox');
  579. this.setInputsInline(true);
  580. this.setPreviousStatement(true, null);
  581. this.setNextStatement(true, null);
  582. this.setColour("#5bb2d6");
  583. this.setTooltip('');
  584. this.setHelpUrl('');
  585. }
  586. }
  587. Blockly.Python.ai_camera_filp = function(block) {
  588. var _tf = block.getFieldValue('TextCheckBox') == 'TRUE' ? "True" : "False";
  589. var _code = "lcd.mirror(" + _tf + ")\n";
  590. return _code;
  591. }