From ef353e065019d4c17108fde331c5cd7821f3efd9 Mon Sep 17 00:00:00 2001 From: ocogeclub Date: Sat, 19 Aug 2023 08:53:45 +0900 Subject: [PATCH] =?UTF-8?q?[update]=20Blockly=E3=81=AE=E3=82=B3=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=82=B8=E3=82=A7=E3=83=8D=E3=83=AC=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=81=AE=E4=BB=95=E6=A7=98=E5=A4=89=E6=9B=B4=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blocks/blocks.js | 332 +++++++---------- blocks/dht11/dht11.py | 171 --------- blocks/dht11/index.js | 71 ---- blocks/index.js | 4 +- blocks/pico_slave/index.js | 66 ---- blocks/sensors/amg8833.js | 30 +- blocks/sensors/bme280.js | 10 +- blocks/sensors/paj7620.js | 11 +- index.html | 26 -- lib/irrp.py | 515 --------------------------- lib/oled.py | 47 --- local_modules/amg8833/amg8833x.js | 15 - local_modules/bme280/bme280x.js | 6 - local_modules/paj7620/paj7620x.js | 4 - local_modules/rgpio/index.js | 2 - local_modules/rgpio/rgpio.cpp | 2 +- oled-i2c-rgpio/README.md | 285 --------------- oled-i2c-rgpio/examples/README.md | 15 - oled-i2c-rgpio/examples/package.json | 25 -- oled-i2c-rgpio/examples/rgba.js | 39 -- oled-i2c-rgpio/examples/test.png | Bin 648 -> 0 bytes oled-i2c-rgpio/package-lock.json | 108 ------ oled-i2c-rgpio/package.json | 19 - oled_circle.js | 23 -- 24 files changed, 151 insertions(+), 1675 deletions(-) delete mode 100644 blocks/dht11/dht11.py delete mode 100644 blocks/dht11/index.js delete mode 100644 blocks/pico_slave/index.js delete mode 100644 lib/irrp.py delete mode 100644 lib/oled.py delete mode 100644 oled-i2c-rgpio/README.md delete mode 100644 oled-i2c-rgpio/examples/README.md delete mode 100644 oled-i2c-rgpio/examples/package.json delete mode 100644 oled-i2c-rgpio/examples/rgba.js delete mode 100644 oled-i2c-rgpio/examples/test.png delete mode 100644 oled-i2c-rgpio/package-lock.json delete mode 100644 oled-i2c-rgpio/package.json delete mode 100644 oled_circle.js diff --git a/blocks/blocks.js b/blocks/blocks.js index 56c45cc..5c47721 100644 --- a/blocks/blocks.js +++ b/blocks/blocks.js @@ -30,12 +30,12 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "math_blocks" }]); -Blockly.JavaScript['oc_text_to_number'] = function (block) { +javascript.javascriptGenerator.forBlock['oc_text_to_number'] = function (block, generator) { var value_text = Blockly.JavaScript.valueToCode(block, 'text', Blockly.JavaScript.ORDER_ATOMIC); var code = `Number(${value_text})`; return [code, Blockly.JavaScript.ORDER_NONE]; }; -Blockly.Python['oc_text_to_number'] = function (block) { +python.pythonGenerator.forBlock['oc_text_to_number'] = function (block, generator) { var value_text = Blockly.Python.valueToCode(block, 'text', Blockly.Python.ORDER_ATOMIC); var code = `int(${value_text})`; return [code, Blockly.Python.ORDER_NONE]; @@ -62,12 +62,12 @@ Blockly.Blocks['ugj_codechar'] = { this.jsonInit(ugjCodecharDefinition); } }; -Blockly.JavaScript['ugj_codechar'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_codechar'] = function (block, generator) { var value_code = Blockly.JavaScript.valueToCode(block, 'code', Blockly.JavaScript.ORDER_ATOMIC); var code = `String.fromCharCode(${value_code})`; return [code, Blockly.JavaScript.ORDER_NONE]; }; -Blockly.Python['ugj_codechar'] = function (block) { +python.pythonGenerator.forBlock['ugj_codechar'] = function (block, generator) { var value_code = Blockly.Python.valueToCode(block, 'code', Blockly.Python.ORDER_ATOMIC); var code = `chr(${value_code})`; return [code, Blockly.Python.ORDER_NONE]; @@ -94,12 +94,12 @@ Blockly.Blocks['ugj_charcode'] = { this.jsonInit(ugjCharcodeDefinition); } }; -Blockly.JavaScript['ugj_charcode'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_charcode'] = function (block, generator) { var value_char = Blockly.JavaScript.valueToCode(block, 'char', Blockly.JavaScript.ORDER_ATOMIC); var code = `${value_char}.charCodeAt(0)`; return [code, Blockly.JavaScript.ORDER_NONE]; }; -Blockly.Python['ugj_charcode'] = function (block) { +python.pythonGenerator.forBlock['ugj_charcode'] = function (block, generator) { var value_char = Blockly.Python.valueToCode(block, 'char', Blockly.Python.ORDER_ATOMIC); var code = `ord(${value_char})`; return [code, Blockly.Python.ORDER_NONE]; @@ -117,12 +117,12 @@ Blockly.Blocks['ugj_bintodec'] = { this.setStyle('math_blocks'); } }; -Blockly.JavaScript['ugj_bintodec'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_bintodec'] = function (block, generator) { var value_bin = Blockly.JavaScript.valueToCode(block, 'bin', Blockly.JavaScript.ORDER_ATOMIC); var code = `parseInt (${value_bin}, 2)`; return [code, Blockly.JavaScript.ORDER_NONE]; }; -Blockly.Python['ugj_bintodec'] = function (block) { +python.pythonGenerator.forBlock['ugj_bintodec'] = function (block, generator) { var value_bin = Blockly.Python.valueToCode(block, 'bin', Blockly.Python.ORDER_ATOMIC); var code = `int(${value_bin}, 2)`; return [code, Blockly.Python.ORDER_NONE]; @@ -149,12 +149,12 @@ Blockly.Blocks['ugj_hextodec'] = { this.jsonInit(ugjHextodecDefinition); } }; -Blockly.JavaScript['ugj_hextodec'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_hextodec'] = function (block, generator) { var value_hex = Blockly.JavaScript.valueToCode(block, 'hex', Blockly.JavaScript.ORDER_ATOMIC); var code = `parseInt (${value_hex}, 16)`; return [code, Blockly.JavaScript.ORDER_ATOMIC]; }; -Blockly.Python['ugj_hextodec'] = function (block) { +python.pythonGenerator.forBlock['ugj_hextodec'] = function (block, generator) { var value_hex = Blockly.Python.valueToCode(block, 'hex', Blockly.Python.ORDER_ATOMIC); var code = `int(${value_hex}, 16)`; return [code, Blockly.Python.ORDER_NONE]; @@ -181,12 +181,12 @@ Blockly.Blocks['ugj_dectohex'] = { this.jsonInit(ugjDectohexDefinition); } }; -Blockly.JavaScript['ugj_dectohex'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_dectohex'] = function (block, generator) { var value_dec = Blockly.JavaScript.valueToCode(block, 'dec', Blockly.JavaScript.ORDER_ATOMIC); var code = `'0x' + (${value_dec}).toString(16).toUpperCase()`; return [code, Blockly.JavaScript.ORDER_NONE]; }; -Blockly.Python['ugj_dectohex'] = function (block) { +python.pythonGenerator.forBlock['ugj_dectohex'] = function (block, generator) { var value_dec = Blockly.Python.valueToCode(block, 'dec', Blockly.Python.ORDER_ATOMIC); var code = `f'{${value_dec}:#04x}'`; return [code, Blockly.Python.ORDER_NONE]; @@ -209,15 +209,15 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -javascript.javascriptGenerator.forBlock['ugj_gpio_open'] = function (block, generator) { - // Blockly.JavaScript['ugj_gpio_open'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_gpio_open'] = function (block, generator, generator) { + // javascript.javascriptGenerator.forBlock['ugj_gpio_open'] = function (block, generator) { Blockly.JavaScript.provideFunction_( 'require_gpio', [`const _rg = require('${apptool.gpio_lib}');`] ); var code = `await _rg.rgpio_sbc();\n`; // return code; }; -Blockly.Python['ugj_gpio_open'] = function (block) { +python.pythonGenerator.forBlock['ugj_gpio_open'] = function (block, generator) { Blockly.Python.provideFunction_( 'import_pin', ['from machine import Pin'] ); @@ -237,11 +237,11 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.JavaScript['ugj_gpio_close'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_gpio_close'] = function (block, generator) { var code = 'await _rg.sbc_stop();\n'; return code; }; -Blockly.Python['ugj_gpio_close'] = function (block) { +python.pythonGenerator.forBlock['ugj_gpio_close'] = function (block, generator) { var code = ''; return code; }; @@ -270,12 +270,12 @@ Blockly.Blocks['oc_gpio_set_output'] = { this.jsonInit(ugjGpioSetOutputDefinition); } }; -Blockly.JavaScript['oc_gpio_set_output'] = function (block) { +javascript.javascriptGenerator.forBlock['oc_gpio_set_output'] = function (block, generator) { var value_ugpio = Blockly.JavaScript.valueToCode(block, 'ugpio', Blockly.JavaScript.ORDER_ATOMIC); var code = `await _rg.gpio_set_output(${value_ugpio});\n`; return code; }; -Blockly.Python['oc_gpio_set_output'] = function (block) { +python.pythonGenerator.forBlock['oc_gpio_set_output'] = function (block, generator) { var value_ugpio = Blockly.Python.valueToCode(block, 'ugpio', Blockly.Python.ORDER_ATOMIC); var code = `_pin[${value_ugpio}] = Pin(${value_ugpio}, Pin.OUT)\n`; return code; @@ -318,13 +318,13 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.JavaScript['oc_gpio_set_input'] = function (block) { +javascript.javascriptGenerator.forBlock['oc_gpio_set_input'] = function (block, generator) { var value_ugpio = Blockly.JavaScript.valueToCode(block, 'ugpio', Blockly.JavaScript.ORDER_ATOMIC); var dropdown_lflag = block.getFieldValue('lflag'); var code = `await _rg.gpio_set_input(${value_ugpio}, _rg.${dropdown_lflag});\n`; return code; }; -Blockly.Python['oc_gpio_set_input'] = function (block) { +python.pythonGenerator.forBlock['oc_gpio_set_input'] = function (block, generator) { var value_gpio = Blockly.Python.valueToCode(block, 'ugpio', Blockly.Python.ORDER_ATOMIC); var dropdown_lflag = block.getFieldValue('lflag'); let lflag; @@ -358,12 +358,12 @@ Blockly.Blocks['ugj_gpio_read'] = { this.jsonInit(ugjGpioReadDefinition); } }; -Blockly.JavaScript['ugj_gpio_read'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_gpio_read'] = function (block, generator) { var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC); var code = `await _rg.gpio_read(${value_gpio})`; return [code, Blockly.JavaScript.ORDER_NONE]; }; -Blockly.Python['ugj_gpio_read'] = function (block) { +python.pythonGenerator.forBlock['ugj_gpio_read'] = function (block, generator) { var value_gpio = Blockly.Python.valueToCode(block, 'gpio', Blockly.Python.ORDER_ATOMIC); var code = `_pin[${value_gpio}].value()`; return [code, Blockly.Python.ORDER_NONE]; @@ -408,13 +408,13 @@ Blockly.Blocks['ugj_gpio_write'] = { this.jsonInit(ugjGpioWriteDefinition); } }; -Blockly.JavaScript['ugj_gpio_write'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_gpio_write'] = function (block, generator) { var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC); var dropdown_level = block.getFieldValue('level'); var code = `await _rg.gpio_write(${value_gpio}, ${dropdown_level});\n`; return code; }; -Blockly.Python['ugj_gpio_write'] = function (block) { +python.pythonGenerator.forBlock['ugj_gpio_write'] = function (block, generator) { var value_gpio = Blockly.Python.valueToCode(block, 'gpio', Blockly.Python.ORDER_ATOMIC); var dropdown_level = block.getFieldValue('level'); var code = `_pin[${value_gpio}].value(${dropdown_level})\n`; @@ -451,14 +451,14 @@ Blockly.Blocks['ugj_pwm'] = { this.jsonInit(ugjPwmDefinition); } }; -// Blockly.JavaScript['ugj_pwm'] = function (block) { +// javascript.javascriptGenerator.forBlock['ugj_pwm'] = function (block, generator) { // var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC); // var value_pwm_frequency = Blockly.JavaScript.valueToCode(block, 'pwm_frequency', Blockly.JavaScript.ORDER_ATOMIC); // var value_pwm_duty_cycle = Blockly.JavaScript.valueToCode(block, 'pwm_duty_cycle', Blockly.JavaScript.ORDER_ATOMIC); // var code = `await _rg.pwm(${value_gpio}, ${value_pwm_frequency}, ${value_pwm_duty_cycle});\n`; // return code; // }; -Blockly.Python['ugj_pwm'] = function (block) { +python.pythonGenerator.forBlock['ugj_pwm'] = function (block, generator) { var value_gpio = Blockly.Python.valueToCode(block, 'gpio', Blockly.Python.ORDER_ATOMIC); var value_pwm_frequency = Blockly.Python.valueToCode(block, 'pwm_frequency', Blockly.Python.ORDER_ATOMIC); var value_pwm_duty_cycle = Blockly.Python.valueToCode(block, 'pwm_duty_cycle', Blockly.Python.ORDER_ATOMIC); @@ -489,7 +489,7 @@ Blockly.Blocks['oc_pwm_duty'] = { this.setStyle('gpio_blocks'); } }; -Blockly.Python['oc_pwm_duty'] = function (block) { +python.pythonGenerator.forBlock['oc_pwm_duty'] = function (block, generator) { var value_gpio = Blockly.Python.valueToCode(block, 'gpio', Blockly.Python.ORDER_ATOMIC); var value_duty = Blockly.Python.valueToCode(block, 'duty', Blockly.Python.ORDER_ATOMIC); var code = `_pin[${value_gpio}].duty_u16(${value_duty})\n`; @@ -538,7 +538,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.JavaScript['oc_serial_open'] = function (block) { +javascript.javascriptGenerator.forBlock['oc_serial_open'] = function (block, generator) { var value_port = Blockly.JavaScript.valueToCode(block, 'port', Blockly.JavaScript.ORDER_ATOMIC); var variable_ser_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('ser_hand'), Blockly.Names.NameType.VARIABLE); var dropdown_baud = block.getFieldValue('baud'); @@ -565,7 +565,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.JavaScript['oc_serial_close'] = function (block) { +javascript.javascriptGenerator.forBlock['oc_serial_close'] = function (block, generator) { var variable_ser_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('ser_hand'), Blockly.Names.NameType.VARIABLE); var code = `await _rg.serial_close(${variable_ser_hand});\n`; return code; @@ -598,7 +598,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.JavaScript['oc_serial_read'] = function (block) { +javascript.javascriptGenerator.forBlock['oc_serial_read'] = function (block, generator) { var variable_ser_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('ser_hand'), Blockly.Names.NameType.VARIABLE); var value_count = Blockly.JavaScript.valueToCode(block, 'count', Blockly.JavaScript.ORDER_ATOMIC); var code = `await _rg.serial_read(${variable_ser_hand}, ${value_count})`; @@ -633,7 +633,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.JavaScript['oc_serial_write'] = function (block) { +javascript.javascriptGenerator.forBlock['oc_serial_write'] = function (block, generator) { var variable_ser_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('ser_hand'), Blockly.Names.NameType.VARIABLE); var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC); // TODO: Assemble JavaScript into code variable. @@ -664,7 +664,7 @@ Blockly.Blocks['oc_i2c_open'] = { this.setStyle("gpio_blocks"); } }; -Blockly.JavaScript['oc_i2c_open'] = function (block) { +javascript.javascriptGenerator.forBlock['oc_i2c_open'] = function (block, generator) { var value_addr = Blockly.JavaScript.valueToCode(block, 'addr', Blockly.JavaScript.ORDER_ATOMIC); var variable_i2c_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('i2c_hand'), Blockly.Names.NameType.VARIABLE); // Blockly.JavaScript.provideFunction_( @@ -673,7 +673,7 @@ Blockly.JavaScript['oc_i2c_open'] = function (block) { var code = `${variable_i2c_hand} = await _rg.i2c_open(${apptool.i2c_bus}, ${value_addr});\n`; return code; }; -Blockly.Python['oc_i2c_open'] = function (block) { +python.pythonGenerator.forBlock['oc_i2c_open'] = function (block, generator) { var value_addr = Blockly.Python.valueToCode(block, 'addr', Blockly.Python.ORDER_ATOMIC); var variable_i2c_hand = Blockly.Python.nameDB_.getName(block.getFieldValue('i2c_hand'), Blockly.Names.NameType.VARIABLE); Blockly.Python.provideFunction_( @@ -700,12 +700,12 @@ Blockly.Blocks['oc_i2c_close'] = { this.setStyle("gpio_blocks"); } }; -Blockly.JavaScript['oc_i2c_close'] = function (block) { +javascript.javascriptGenerator.forBlock['oc_i2c_close'] = function (block, generator) { var variable_i2c_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('i2c_hand'), Blockly.Names.NameType.VARIABLE); var code = `await _rg.i2c_close(${variable_i2c_hand});\n`; return code; }; -Blockly.Python['oc_i2c_close'] = function (block) { +python.pythonGenerator.forBlock['oc_i2c_close'] = function (block, generator) { var code = ``; return code; }; @@ -730,7 +730,7 @@ Blockly.Blocks['oc_i2c_write_byte'] = { this.setStyle('gpio_blocks'); } }; -Blockly.JavaScript['oc_i2c_write_byte'] = function (block) { +javascript.javascriptGenerator.forBlock['oc_i2c_write_byte'] = function (block, generator) { var variable_i2c_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('i2c_hand'), Blockly.Names.NameType.VARIABLE); var value_byte_val = Blockly.JavaScript.valueToCode(block, 'byte_val', Blockly.JavaScript.ORDER_ATOMIC); var code = `await _rg.i2c_write_byte(${variable_i2c_hand}, ${value_byte_val});\n`; @@ -770,14 +770,14 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.JavaScript['ugj_i2c_write_byte_data'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_i2c_write_byte_data'] = function (block, generator) { var variable_i2c_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('i2c_hand'), Blockly.Names.NameType.VARIABLE); var value_reg = Blockly.JavaScript.valueToCode(block, 'reg', Blockly.JavaScript.ORDER_ATOMIC); var value_byte_val = Blockly.JavaScript.valueToCode(block, 'byte_val', Blockly.JavaScript.ORDER_ATOMIC); var code = `await _rg.i2c_write_byte_data(${variable_i2c_hand}, ${value_reg}, ${value_byte_val});\n`; return code; }; -Blockly.Python['ugj_i2c_write_byte_data'] = function (block) { +python.pythonGenerator.forBlock['ugj_i2c_write_byte_data'] = function (block, generator) { var value_reg = Blockly.Python.valueToCode(block, 'reg', Blockly.Python.ORDER_ATOMIC); var value_byte_val = Blockly.Python.valueToCode(block, 'byte_val', Blockly.Python.ORDER_ATOMIC); var code = `_i2c_hand.writeto_mem(_addr, ${value_reg}, (${value_byte_val}).to_bytes(1,'big'))\n`; @@ -811,13 +811,13 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.JavaScript['ugj_i2c_read_byte_data'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_i2c_read_byte_data'] = function (block, generator) { var variable_i2c_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('i2c_hand'), Blockly.Names.NameType.VARIABLE); var value_reg = Blockly.JavaScript.valueToCode(block, 'reg', Blockly.JavaScript.ORDER_ATOMIC); var code = `await _rg.i2c_read_byte_data(${variable_i2c_hand}, ${value_reg})`; return [code, Blockly.JavaScript.ORDER_ATOMIC]; }; -Blockly.Python['ugj_i2c_read_byte_data'] = function (block) { +python.pythonGenerator.forBlock['ugj_i2c_read_byte_data'] = function (block, generator) { var value_reg = Blockly.Python.valueToCode(block, 'reg', Blockly.Python.ORDER_ATOMIC); var code = `int.from_bytes(_i2c_hand.readfrom_mem(_addr, ${value_reg}, 1), 'big')\n`; return [code, Blockly.Python.ORDER_ATOMIC]; @@ -842,7 +842,7 @@ Blockly.Blocks['ugj_i2c_read_word_data'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_i2c_read_word_data'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_i2c_read_word_data'] = function (block, generator) { var variable_i2c_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('i2c_hand'), Blockly.Names.NameType.VARIABLE); var value_reg = Blockly.JavaScript.valueToCode(block, 'reg', Blockly.JavaScript.ORDER_ATOMIC); var code = `await _rg.i2c_read_word_data(${variable_i2c_hand}, ${value_reg})`; @@ -882,14 +882,14 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.JavaScript['ugj_i2c_write_i2c_block_data'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_i2c_write_i2c_block_data'] = function (block, generator) { var variable_i2c_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('i2c_hand'), Blockly.Names.NameType.VARIABLE); var value_reg = Blockly.JavaScript.valueToCode(block, 'reg', Blockly.JavaScript.ORDER_ATOMIC); var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC); var code = `await _rg.i2c_write_i2c_block_data (${variable_i2c_hand}, ${value_reg}, ${value_data});`; return code; }; -Blockly.Python['ugj_i2c_write_i2c_block_data'] = function (block) { +python.pythonGenerator.forBlock['ugj_i2c_write_i2c_block_data'] = function (block, generator) { var value_reg = Blockly.Python.valueToCode(block, 'reg', Blockly.Python.ORDER_ATOMIC); var value_data = Blockly.Python.valueToCode(block, 'data', Blockly.Python.ORDER_ATOMIC); var code = `_i2c_hand.writeto_mem(_addr, ${value_reg}, bytearray(${value_data}))\n`; @@ -923,13 +923,13 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.JavaScript['ugj_i2c_read_device'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_i2c_read_device'] = function (block, generator) { var variable_i2c_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('i2c_hand'), Blockly.Names.NameType.VARIABLE); var value_count = Blockly.JavaScript.valueToCode(block, 'count', Blockly.JavaScript.ORDER_ATOMIC); var code = `await _rg.i2c_read_device(${variable_i2c_hand}, ${value_count})`; return [code, Blockly.JavaScript.ORDER_ATOMIC]; }; -// Blockly.Python['ugj_i2c_read_device'] = function (block) { +// python.pythonGenerator.forBlock['ugj_i2c_read_device'] = function (block, generator) { // var value_count = Blockly.Python.valueToCode(block, 'count', Blockly.Python.ORDER_ATOMIC); // var code = `await pi.i2c_read_device(i2c_hand, ${value_count}).decode()`; // return [code, Blockly.Python.ORDER_ATOMIC]; @@ -962,13 +962,13 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.JavaScript['ugj_i2c_write_device'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_i2c_write_device'] = function (block, generator) { var variable_i2c_hand = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('i2c_hand'), Blockly.Names.NameType.VARIABLE); var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC); var code = `await _rg.i2c_write_device(${variable_i2c_hand}, ${value_data})\n`; return code; }; -// Blockly.Python['ugj_i2c_write_device'] = function (block) { +// python.pythonGenerator.forBlock['ugj_i2c_write_device'] = function (block, generator) { // var value_data = Blockly.Python.valueToCode(block, 'data', Blockly.Python.ORDER_ATOMIC); // var code = `await pi.i2c_write_device(i2c_hand, ${value_data}.encode())\n`; // return code; @@ -993,7 +993,7 @@ Blockly.Blocks['ugj_face_init'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_face_init'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_face_init'] = function (block, generator) { Blockly.JavaScript.provideFunction_( 'require_tfjs', [`const _tf = require('@tensorflow/tfjs-node');`] ); @@ -1022,7 +1022,7 @@ Blockly.Blocks['ugj_face_display'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_face_display'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_face_display'] = function (block, generator) { var code = [ "_videoEl.style.display = 'inline-block';", `const _overlay = document.createElement('canvas');`, @@ -1050,7 +1050,7 @@ Blockly.Blocks['ugj_face_detect'] = { this.setStyle('multimedia_blocks'); } }; -Blockly.JavaScript['ugj_face_detect'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_face_detect'] = function (block, generator) { var value_preditions = Blockly.JavaScript.valueToCode(block, 'preditions', Blockly.JavaScript.ORDER_ATOMIC); var code = `${value_preditions} = await _model.estimateFaces(_videoEl, false);`; return code; @@ -1070,7 +1070,7 @@ Blockly.Blocks['ugj_face_location'] = { this.setStyle('multimedia_blocks'); } }; -Blockly.JavaScript['ugj_face_location'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_face_location'] = function (block, generator) { var value_prediction = Blockly.JavaScript.valueToCode(block, 'prediction', Blockly.JavaScript.ORDER_NONE); var dropdown_member = block.getFieldValue('member'); var code = `${value_prediction}.${dropdown_member}`; @@ -1093,7 +1093,7 @@ Blockly.Blocks['ugj_face_draw'] = { this.setStyle('multimedia_blocks'); } }; -Blockly.JavaScript['ugj_face_draw'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_face_draw'] = function (block, generator) { var value_prediction = Blockly.JavaScript.valueToCode(block, 'prediction', Blockly.JavaScript.ORDER_NONE); var checkbox_with_landmark = block.getFieldValue('with_landmark') === 'TRUE'; var code = `const _start = ${value_prediction}.topLeft; @@ -1138,7 +1138,7 @@ Blockly.Blocks['oc_speechcommands_init'] = { this.setStyle('multimedia_blocks'); } }; -Blockly.JavaScript['oc_speechcommands_init'] = function (block) { +javascript.javascriptGenerator.forBlock['oc_speechcommands_init'] = function (block, generator) { var value_custom_model = Blockly.JavaScript.valueToCode(block, 'custom_model', Blockly.JavaScript.ORDER_NONE); var variable_classlabels = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('classlabels'), Blockly.Names.NameType.VARIABLE); Blockly.JavaScript.provideFunction_( @@ -1192,7 +1192,7 @@ Blockly.Blocks['oc_speechcommand_listen'] = { this.setStyle('multimedia_blocks'); } }; -Blockly.JavaScript['oc_speechcommand_listen'] = function (block) { +javascript.javascriptGenerator.forBlock['oc_speechcommand_listen'] = function (block, generator) { var variable_scores = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('scores'), Blockly.Names.NameType.VARIABLE); var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); var number_probabilitythreshold = block.getFieldValue('probabilityThreshold'); @@ -1227,7 +1227,7 @@ Blockly.Blocks['ugj_canvas_say'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_canvas_say'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_canvas_say'] = function (block, generator) { var value_say = Blockly.JavaScript.valueToCode(block, 'say', Blockly.JavaScript.ORDER_ATOMIC); var value_sec = block.getFieldValue('sec'); var code = [ @@ -1236,7 +1236,7 @@ Blockly.JavaScript['ugj_canvas_say'] = function (block) { ].join('\n'); return code; }; -Blockly.Python['ugj_canvas_say'] = function (block) { +python.pythonGenerator.forBlock['ugj_canvas_say'] = function (block, generator) { var value_say = Blockly.Python.valueToCode(block, 'say', Blockly.Python.ORDER_ATOMIC); var value_sec = Blockly.Python.valueToCode(block, 'sec', Blockly.Python.ORDER_ATOMIC); var code = `print(${value_say})\n`; @@ -1260,7 +1260,7 @@ Blockly.Blocks['ugj_canvas_init'] = { this.jsonInit(ugj_canvas_init_definition); } }; -Blockly.JavaScript['ugj_canvas_init'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_canvas_init'] = function (block, generator) { var code = [ `let _canvas = document.getElementById('gcanvas');`, `_canvas.style.display = 'inline-block';`, @@ -1286,7 +1286,7 @@ Blockly.Blocks['ugj_canvas_finalize'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_canvas_finalize'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_canvas_finalize'] = function (block, generator) { var code = `document.getElementById('gcanvas').style.display = 'none';\n`; return code; }; @@ -1309,7 +1309,7 @@ Blockly.Blocks['ugj_canvas_loadimg'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_canvas_loadimg'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_canvas_loadimg'] = function (block, generator) { var value_imgfilename = Blockly.JavaScript.valueToCode(block, 'imgfilename', Blockly.JavaScript.ORDER_ATOMIC); var code = [ `let _img = new Image();`, @@ -1347,7 +1347,7 @@ Blockly.Blocks['ugj_canvas_clearrect'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_canvas_clearrect'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_canvas_clearrect'] = function (block, generator) { var value_x = Blockly.JavaScript.valueToCode(block, 'x', Blockly.JavaScript.ORDER_ATOMIC); var value_y = Blockly.JavaScript.valueToCode(block, 'y', Blockly.JavaScript.ORDER_ATOMIC); var value_w = Blockly.JavaScript.valueToCode(block, 'w', Blockly.JavaScript.ORDER_ATOMIC); @@ -1372,7 +1372,7 @@ Blockly.Blocks['ugj_canvas_width'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_canvas_width'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_canvas_width'] = function (block, generator) { var code = '_canvas.width'; return [code, Blockly.JavaScript.ORDER_NONE]; }; @@ -1391,7 +1391,7 @@ Blockly.Blocks['ugj_canvas_height'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_canvas_height'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_canvas_height'] = function (block, generator) { var code = '_canvas.height'; return [code, Blockly.JavaScript.ORDER_NONE]; }; @@ -1425,7 +1425,7 @@ Blockly.Blocks['ugj_canvas_drawcircle'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_canvas_drawcircle'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_canvas_drawcircle'] = function (block, generator) { var value_x = Blockly.JavaScript.valueToCode(block, 'x', Blockly.JavaScript.ORDER_ATOMIC); var value_y = Blockly.JavaScript.valueToCode(block, 'y', Blockly.JavaScript.ORDER_ATOMIC); var value_r = Blockly.JavaScript.valueToCode(block, 'r', Blockly.JavaScript.ORDER_ATOMIC); @@ -1471,7 +1471,7 @@ Blockly.Blocks['ugj_canvas_drawrect'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_canvas_drawrect'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_canvas_drawrect'] = function (block, generator) { var value_x = Blockly.JavaScript.valueToCode(block, 'x', Blockly.JavaScript.ORDER_ATOMIC); var value_y = Blockly.JavaScript.valueToCode(block, 'y', Blockly.JavaScript.ORDER_ATOMIC); var value_w = Blockly.JavaScript.valueToCode(block, 'w', Blockly.JavaScript.ORDER_ATOMIC); @@ -1512,7 +1512,7 @@ Blockly.Blocks['ugj_event_key'] = { this.setStyle('multimedia_blocks'); } }; -Blockly.JavaScript['ugj_event_key'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_event_key'] = function (block, generator) { var value_key = Blockly.JavaScript.valueToCode(block, 'key', Blockly.JavaScript.ORDER_ATOMIC); var dropdown_updown = block.getFieldValue('updown'); var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); @@ -1542,7 +1542,7 @@ Blockly.Blocks['ugj_sound_play'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_sound_play'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_sound_play'] = function (block, generator) { var dropdown_sound = block.getFieldValue('sound'); var code = `ugj_soundPlay('${dropdown_sound}');\n`; return code; @@ -1579,7 +1579,7 @@ Blockly.Blocks['ugj_socket'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_socket'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_socket'] = function (block, generator) { var value_host = Blockly.JavaScript.valueToCode(block, 'host', Blockly.JavaScript.ORDER_ATOMIC); var value_port = Blockly.JavaScript.valueToCode(block, 'port', Blockly.JavaScript.ORDER_ATOMIC); var statements_connect = Blockly.JavaScript.statementToCode(block, 'connect'); @@ -1620,7 +1620,7 @@ Blockly.Blocks['ugj_socket_write'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_socket_write'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_socket_write'] = function (block, generator) { var value_cmd = Blockly.JavaScript.valueToCode(block, 'cmd', Blockly.JavaScript.ORDER_ATOMIC); var code = [ `_client.write(${value_cmd});`, @@ -1653,7 +1653,7 @@ Blockly.Blocks['ugj_network_httpserver'] = { this.setStyle('network_blocks') } }; -Blockly.JavaScript['ugj_network_httpserver'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_network_httpserver'] = function (block, generator) { var value_url = Blockly.JavaScript.valueToCode(block, 'url', Blockly.JavaScript.ORDER_ATOMIC); // var variable_url = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('URL'), Blockly.Variables.NAME_TYPE); var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); @@ -1694,7 +1694,7 @@ Blockly.Blocks['ugj_network_axios_geturl'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_network_axios_geturl'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_network_axios_geturl'] = function (block, generator) { var value_url = Blockly.JavaScript.valueToCode(block, 'url', Blockly.JavaScript.ORDER_ATOMIC); var functionName = Blockly.JavaScript.provideFunction_( '_getUrl', @@ -1741,7 +1741,7 @@ Blockly.Blocks['ugj_network_sendmail'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_network_sendmail'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_network_sendmail'] = function (block, generator) { var value_to = Blockly.JavaScript.valueToCode(block, 'to', Blockly.JavaScript.ORDER_ATOMIC); var value_subject = Blockly.JavaScript.valueToCode(block, 'subject', Blockly.JavaScript.ORDER_ATOMIC); var value_text = Blockly.JavaScript.valueToCode(block, 'text', Blockly.JavaScript.ORDER_ATOMIC); @@ -1789,7 +1789,7 @@ Blockly.Blocks['ugj_library_skyway'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_library_skyway'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_library_skyway'] = function (block, generator) { var code = `'${apptool.path.join(apptool.library_path, 'skyway.min.js')}'`; return [code, Blockly.JavaScript.ORDER_NONE]; }; @@ -1808,7 +1808,7 @@ Blockly.Blocks['ugj_webchat'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_webchat'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_webchat'] = function (block, generator) { var code = [ `const _blackboard = document.getElementById('blackboard');`, "_blackboard.style.display = 'inline-block';", @@ -1838,7 +1838,7 @@ Blockly.Blocks['ugj_getusermedia'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_getusermedia'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_getusermedia'] = function (block, generator) { var code = [ `navigator.mediaDevices.getUserMedia({video: true, audio: false})`, ' .then(_stream => {', @@ -1877,7 +1877,7 @@ Blockly.Blocks['ugj_skyway_newpeer'] = { this.setStyle('network_blocks') } }; -Blockly.JavaScript['ugj_skyway_newpeer'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_skyway_newpeer'] = function (block, generator) { var value_my_id = Blockly.JavaScript.valueToCode(block, 'my_id', Blockly.JavaScript.ORDER_ATOMIC); // var variable_my_id = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('my_id'), Blockly.Variables.NAME_TYPE); // var text_name = block.getFieldValue('NAME'); @@ -1921,7 +1921,7 @@ Blockly.Blocks['ugj_skyway_called'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_skyway_called'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_skyway_called'] = function (block, generator) { var code = [ "_peer.on('call', _call => {", " _call.answer(_localStream);", @@ -1954,7 +1954,7 @@ Blockly.Blocks['ugj_skyway_events'] = { this.setStyle('network_blocks') } }; -Blockly.JavaScript['ugj_skyway_events'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_skyway_events'] = function (block, generator) { var value_remote_id = Blockly.JavaScript.valueToCode(block, 'remote_id', Blockly.JavaScript.ORDER_ATOMIC); // var variable_remote_id = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('remote_id'), Blockly.Variables.NAME_TYPE); var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); @@ -1987,7 +1987,7 @@ Blockly.Blocks['ugj_skyway_eventopen'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_skyway_eventopen'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_skyway_eventopen'] = function (block, generator) { var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); var code = [ " _connect.on('open', () => {", @@ -2019,7 +2019,7 @@ Blockly.Blocks['ugj_skyway_eventdata'] = { this.setStyle('network_blocks') } }; -Blockly.JavaScript['ugj_skyway_eventdata'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_skyway_eventdata'] = function (block, generator) { var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC); // var variable_data = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('data'), Blockly.Variables.NAME_TYPE); var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); @@ -2053,7 +2053,7 @@ Blockly.Blocks['ugj_skyway_eventsend'] = { this.setStyle('network_blocks') } }; -Blockly.JavaScript['ugj_skyway_eventsend'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_skyway_eventsend'] = function (block, generator) { var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC); // var variable_data = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('data'), Blockly.Variables.NAME_TYPE); var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); @@ -2092,7 +2092,7 @@ Blockly.Blocks['ugj_file_readsync'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_file_readsync'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_file_readsync'] = function (block, generator) { var value_filename = Blockly.JavaScript.valueToCode(block, 'filename', Blockly.JavaScript.ORDER_ATOMIC); var dropdown_encoding = block.getFieldValue('encoding'); let filepath = apptool.path.join(apptool.doc_root, value_filename.replace(/\'/g, '')); @@ -2123,7 +2123,7 @@ Blockly.Blocks['ugj_localstorage_save'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_localstorage_save'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_localstorage_save'] = function (block, generator) { var value_keyvalue = Blockly.JavaScript.valueToCode(block, 'keyValue', Blockly.JavaScript.ORDER_ATOMIC); var value_keyname = Blockly.JavaScript.valueToCode(block, 'keyName', Blockly.JavaScript.ORDER_ATOMIC); var code = `localStorage.setItem(${value_keyname}, ${value_keyvalue});\n`; @@ -2147,7 +2147,7 @@ Blockly.Blocks['ugj_localstorage_load'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_localstorage_load'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_localstorage_load'] = function (block, generator) { var value_keyname = Blockly.JavaScript.valueToCode(block, 'keyName', Blockly.JavaScript.ORDER_ATOMIC); var code = `localStorage.getItem(${value_keyname})`; return [code, Blockly.JavaScript.ORDER_NONE]; @@ -2170,7 +2170,7 @@ Blockly.Blocks['ugj_localstorage_remove'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_localstorage_remove'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_localstorage_remove'] = function (block, generator) { var value_key = Blockly.JavaScript.valueToCode(block, 'key', Blockly.JavaScript.ORDER_ATOMIC); var code = `localStorage.removeItem(${value_key});\n`; return code; @@ -2200,7 +2200,7 @@ Blockly.Blocks['ugj_event_answer'] = { this.setStyle('special_blocks') } }; -Blockly.JavaScript['ugj_event_answer'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_event_answer'] = function (block, generator) { var value_question = Blockly.JavaScript.valueToCode(block, 'question', Blockly.JavaScript.ORDER_ATOMIC); var value_answer = Blockly.JavaScript.valueToCode(block, 'answer', Blockly.JavaScript.ORDER_ATOMIC); // var variable_answer = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('answer'), Blockly.Variables.NAME_TYPE); @@ -2249,7 +2249,7 @@ Blockly.Blocks['ugj_spawnsync'] = { this.setStyle('special_blocks') } }; -Blockly.JavaScript['ugj_spawnsync'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_spawnsync'] = function (block, generator) { var value_childprocess = Blockly.JavaScript.valueToCode(block, 'childprocess', Blockly.JavaScript.ORDER_NONE); var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC); var code = `${value_data} = require('child_process').spawnSync(${value_childprocess}, {timeout: 10000}).stdout.toString();\n`; @@ -2282,7 +2282,7 @@ Blockly.Blocks['ugj_spawn'] = { this.setStyle('special_blocks') } }; -Blockly.JavaScript['ugj_spawn'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_spawn'] = function (block, generator) { var value_childprocess = Blockly.JavaScript.valueToCode(block, 'childprocess', Blockly.JavaScript.ORDER_NONE); var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC); var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); @@ -2319,7 +2319,7 @@ Blockly.Blocks['aquestalk_pi'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['aquestalk_pi'] = function (block) { +javascript.javascriptGenerator.forBlock['aquestalk_pi'] = function (block, generator) { var value_talk = Blockly.JavaScript.valueToCode(block, 'talk', Blockly.JavaScript.ORDER_ATOMIC); var code = `'${apptool.path.join(apptool.executable_path, 'aquestalkpi/AquesTalkPi')} -g 50 ' + ${value_talk} + ' | aplay', { shell: true }`; return [code, Blockly.JavaScript.ORDER_NONE]; @@ -2341,7 +2341,7 @@ Blockly.Blocks['ugj_child_fswebcam'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_child_fswebcam'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_child_fswebcam'] = function (block, generator) { var value_filename = Blockly.JavaScript.valueToCode(block, 'filename', Blockly.JavaScript.ORDER_ATOMIC); var code = `'fswebcam', ['-r', '480x360', '${apptool.doc_root}' + ${value_filename}]`; return [code, Blockly.JavaScript.ORDER_NONE]; @@ -2360,78 +2360,10 @@ Blockly.Blocks['ugj_child_julius'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_child_julius'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_child_julius'] = function (block, generator) { var code = `'${apptool.path.join(apptool.executable_path, 'julius/julius-simple')}', ['-C', '${apptool.path.join(apptool.executable_path, 'julius/dictation-kit/am-gmm.jconf')}', '-gram', '${apptool.path.join(apptool.executable_path, 'julius/dic/assistant')}', '-nostrip']`; return [code, Blockly.JavaScript.ORDER_NONE]; }; -// irrp.py - pigpioによる赤外線リモコンの学習 -Blockly.Blocks['ugj_child_irrecord'] = { - init: function () { - this.appendValueInput("gpio") - .setCheck("Number") - .appendField("GPIO"); - this.appendDummyInput() - .appendField("でリモコンの信号を受信"); - this.setInputsInline(true); - this.setOutput(true, "shcmd"); - this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND); - this.setStyle('special_blocks') - this.setTooltip("受信した赤外線リモコンの信号を文字列として取得します。"); - this.setHelpUrl(""); - } -}; -Blockly.JavaScript['ugj_child_irrecord'] = function (block) { - var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC); - var code = `'python3', ['${apptool.path.join(apptool.library_path, 'irrp.py')}', '-r', '-g', '${value_gpio}', 'signal', '--post', '130']`; - return [code, Blockly.JavaScript.ORDER_NONE]; -}; -// 送信 -Blockly.Blocks['ugj_child_irplayback'] = { - init: function () { - this.appendValueInput("gpio") - .setCheck("Number") - .appendField("GPIO"); - this.appendValueInput("signal") - .setCheck("String") - .appendField("からリモコン信号"); - this.appendDummyInput() - .appendField("を送信"); - this.setInputsInline(true); - this.setOutput(true, "shcmd"); - this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND); - this.setStyle('special_blocks') - this.setTooltip("学習済みの赤外線リモコンの信号を送信します。"); - this.setHelpUrl(""); - } -}; -Blockly.JavaScript['ugj_child_irplayback'] = function (block) { - var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC); - var value_signal = Blockly.JavaScript.valueToCode(block, 'signal', Blockly.JavaScript.ORDER_ATOMIC);//.replace('{','\\{').replace('}','\\}').replace(/"/g,'\\"').replace(/ /g,'\\ ') - var code = `'python3', ['${apptool.path.join(apptool.library_path, 'irrp.py')}', '-p', '-g', '${value_gpio}', '--irdata', ${value_signal}, 'signal']`; - return [code, Blockly.JavaScript.ORDER_NONE]; -}; -// ハッシュ生成 -Blockly.Blocks['ugj_child_irrcvr'] = { - init: function () { - this.appendValueInput("gpio") - .setCheck("Number") - .appendField("GPIO"); - this.appendDummyInput() - .appendField("で受信したリモコン信号から識別コードを生成"); - this.setInputsInline(true); - this.setOutput(true, "shcmd"); - this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND); - this.setStyle('special_blocks') - this.setTooltip("受信した赤外線リモコンの信号からハッシュを生成します。"); - this.setHelpUrl(""); - } -}; -Blockly.JavaScript['ugj_child_irrcvr'] = function (block) { - var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC); - // var code = `'python3', ['./scripts/irrcvr.py', '-g', '${value_gpio}']`; - var code = `'${apptool.path.join(apptool.executable_path, 'ir_hash/ir_hash')}', ['${value_gpio}']`; - return [code, Blockly.JavaScript.ORDER_NONE]; -}; // Python スクリプト Blockly.Blocks['ugj_child_pyscript'] = { @@ -2446,7 +2378,7 @@ Blockly.Blocks['ugj_child_pyscript'] = { this.setStyle('special_blocks'); } }; -Blockly.JavaScript['ugj_child_pyscript'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_child_pyscript'] = function (block, generator) { var value_script_path = Blockly.JavaScript.valueToCode(block, 'script_path', Blockly.JavaScript.ORDER_ATOMIC); // TODO: Assemble JavaScript into code variable. var code = `'python3', ['${apptool.doc_root}/' + ${value_script_path}]`; @@ -2468,7 +2400,7 @@ Blockly.Blocks['ugj_blackboard_show'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_blackboard_show'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_blackboard_show'] = function (block, generator) { var code = "document.getElementById('blackboard').style.display = 'inline-block';\n"; return code; }; @@ -2497,7 +2429,7 @@ Blockly.Blocks['ugj_blackboard_write'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_blackboard_write'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_blackboard_write'] = function (block, generator) { var value_text = Blockly.JavaScript.valueToCode(block, 'text', Blockly.JavaScript.ORDER_ATOMIC); var value_color = Blockly.JavaScript.valueToCode(block, 'color', Blockly.JavaScript.ORDER_ATOMIC); var dropdown_style = block.getFieldValue('style'); @@ -2553,7 +2485,7 @@ Blockly.Blocks['ugj_clearblackboard'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_clearblackboard'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_clearblackboard'] = function (block, generator) { var code = `document.getElementById('blackboard').innerHTML = '';\n`; return code; }; @@ -2573,7 +2505,7 @@ Blockly.Blocks['ugj_blackboard_content'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_blackboard_content'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_blackboard_content'] = function (block, generator) { var code = `document.getElementById('blackboard').innerText`; return [code, Blockly.JavaScript.ORDER_NONE]; }; @@ -2603,7 +2535,7 @@ Blockly.Blocks['ugj_sleep'] = { this.jsonInit(ugjSleepDefinition); } }; -Blockly.JavaScript['ugj_sleep'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_sleep'] = function (block, generator) { var value_sec = Blockly.JavaScript.valueToCode(block, 'sec', Blockly.JavaScript.ORDER_ATOMIC); var functionName = Blockly.JavaScript.provideFunction_( '_sleep', @@ -2613,7 +2545,7 @@ Blockly.JavaScript['ugj_sleep'] = function (block) { var code = `await ${functionName}(${value_sec});\n`; return code; }; -Blockly.Python['ugj_sleep'] = function (block) { +python.pythonGenerator.forBlock['ugj_sleep'] = function (block, generator) { var value_sec = Blockly.Python.valueToCode(block, 'sec', Blockly.Python.ORDER_ATOMIC); Blockly.Python.provideFunction_( 'import_sleep', ['from utime import sleep'] @@ -2641,7 +2573,7 @@ Blockly.Blocks['ugj_async_iife'] = { this.setStyle('special_blocks'); } }; -Blockly.JavaScript['ugj_async_iife'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_async_iife'] = function (block, generator) { var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); var code = `(async () => { ${statements_do} @@ -2664,11 +2596,11 @@ Blockly.Blocks['ugj_text_cr'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_text_cr'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_text_cr'] = function (block, generator) { var code = "'\\r'"; return [code, Blockly.JavaScript.ORDER_ATOMIC]; }; -Blockly.Python['ugj_text_cr'] = function (block) { +python.pythonGenerator.forBlock['ugj_text_cr'] = function (block, generator) { var code = "'\\r'"; return [code, Blockly.Python.ORDER_ATOMIC]; }; @@ -2686,7 +2618,7 @@ Blockly.Blocks['ugj_text_lf'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_text_lf'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_text_lf'] = function (block, generator) { var code = "'\\n'"; return [code, Blockly.JavaScript.ORDER_ATOMIC]; }; @@ -2704,7 +2636,7 @@ Blockly.Blocks['ugj_text_null'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_text_null'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_text_null'] = function (block, generator) { var code = "'\\0'"; return [code, Blockly.JavaScript.ORDER_ATOMIC]; }; @@ -2723,7 +2655,7 @@ Blockly.Blocks['ugj_text_cursor'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_text_cursor'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_text_cursor'] = function (block, generator) { var code = "'▋'"; return [code, Blockly.JavaScript.ORDER_ATOMIC]; }; @@ -2743,7 +2675,7 @@ Blockly.Blocks['ugj_library_load'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_library_load'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_library_load'] = function (block, generator) { var value_lib = Blockly.JavaScript.valueToCode(block, 'lib', Blockly.JavaScript.ORDER_ATOMIC); var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); var code = [ @@ -2788,7 +2720,7 @@ Blockly.Blocks['ugj_control_button'] = { this.setStyle('special_blocks') } }; -Blockly.JavaScript['ugj_control_button'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_control_button'] = function (block, generator) { var value_label = Blockly.JavaScript.valueToCode(block, 'label', Blockly.JavaScript.ORDER_ATOMIC); var value_textcolor = Blockly.JavaScript.valueToCode(block, 'textcolor', Blockly.JavaScript.ORDER_ATOMIC); var value_bgcolor = Blockly.JavaScript.valueToCode(block, 'bgcolor', Blockly.JavaScript.ORDER_ATOMIC); @@ -2824,7 +2756,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "text_blocks" }]); -Blockly.Python['oc_rp2_input'] = function (block) { +python.pythonGenerator.forBlock['oc_rp2_input'] = function (block, generator) { Blockly.Python.provideFunction_( 'import_sys', ['import sys'] ); @@ -2848,7 +2780,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "text_blocks" }]); -Blockly.Python['oc_rp2_print'] = function (block) { +python.pythonGenerator.forBlock['oc_rp2_print'] = function (block, generator) { var value_text = Blockly.Python.valueToCode(block, 'text', Blockly.Python.ORDER_ATOMIC); var code = `print(${value_text}, end='')\n`; return code; @@ -2871,7 +2803,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "rp2_blocks" }]); -Blockly.Python['oc_rp2_ujson_dumps'] = function (block) { +python.pythonGenerator.forBlock['oc_rp2_ujson_dumps'] = function (block, generator) { var value_obj = Blockly.Python.valueToCode(block, 'obj', Blockly.Python.ORDER_ATOMIC); Blockly.Python.provideFunction_( 'import_ujson', ['import ujson'] @@ -2897,7 +2829,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "rp2_blocks" }]); -Blockly.Python['oc_rp2_ujson_loads'] = function (block) { +python.pythonGenerator.forBlock['oc_rp2_ujson_loads'] = function (block, generator) { var value_json = Blockly.Python.valueToCode(block, 'json', Blockly.Python.ORDER_ATOMIC); Blockly.Python.provideFunction_( 'import_ujson', ['import ujson'] @@ -2926,7 +2858,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.Python['oc_rp2_ir_rx'] = function (block) { +python.pythonGenerator.forBlock['oc_rp2_ir_rx'] = function (block, generator) { var value_gpio = Blockly.Python.valueToCode(block, 'gpio', Blockly.Python.ORDER_ATOMIC); Blockly.Python.provideFunction_( 'import_upyirrx', ['from UpyIrRx import UpyIrRx'] @@ -2953,7 +2885,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.Python['oc_rp2_ir_record'] = function (block) { +python.pythonGenerator.forBlock['oc_rp2_ir_record'] = function (block, generator) { var value_timeout = Blockly.Python.valueToCode(block, 'timeout', Blockly.Python.ORDER_ATOMIC); var functionName = Blockly.Python.provideFunction_( '_rx_record', @@ -2988,7 +2920,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.Python['oc_rp2_ir_tx'] = function (block) { +python.pythonGenerator.forBlock['oc_rp2_ir_tx'] = function (block, generator) { var value_gpio = Blockly.Python.valueToCode(block, 'gpio', Blockly.Python.ORDER_ATOMIC); Blockly.Python.provideFunction_( 'import_upyirtx', ['from UpyIrTx import UpyIrTx'] @@ -3015,7 +2947,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "gpio_blocks" }]); -Blockly.Python['oc_rp2_ir_transmit'] = function (block) { +python.pythonGenerator.forBlock['oc_rp2_ir_transmit'] = function (block, generator) { var value_signal = Blockly.Python.valueToCode(block, 'signal', Blockly.Python.ORDER_ATOMIC); var code = `_tx.send(${value_signal})\n`; return code; @@ -3041,7 +2973,7 @@ Blockly.Blocks['oc_i2cslave'] = { this.setStyle('gpio_blocks'); } }; -Blockly.Python['oc_i2cslave'] = function (block) { +python.pythonGenerator.forBlock['oc_i2cslave'] = function (block, generator) { var value_i2c_addr = Blockly.Python.valueToCode(block, 'i2c_addr', Blockly.Python.ORDER_ATOMIC); var variable_data = Blockly.Python.nameDB_.getName(block.getFieldValue('data'), Blockly.Names.NameType.VARIABLE); var statements_do = Blockly.Python.statementToCode(block, 'do'); @@ -3082,7 +3014,7 @@ Blockly.Blocks['ugj_dev_run_js'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_dev_run_js'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_dev_run_js'] = function (block, generator) { var value_arg = Blockly.JavaScript.valueToCode(block, 'arg', Blockly.JavaScript.ORDER_ATOMIC); var value_code = Blockly.JavaScript.valueToCode(block, 'code', Blockly.JavaScript.ORDER_ATOMIC); var value_password = Blockly.JavaScript.valueToCode(block, 'password', Blockly.JavaScript.ORDER_ATOMIC); @@ -3113,7 +3045,7 @@ Blockly.Blocks['testblock'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['testblock'] = function (block) { +javascript.javascriptGenerator.forBlock['testblock'] = function (block, generator) { var value_foo = Blockly.JavaScript.valueToCode(block, 'foo', Blockly.JavaScript.ORDER_ATOMIC); // TODO: Assemble JavaScript into code variable. var code = `${value_foo} = 42;\n`; @@ -3149,7 +3081,7 @@ Blockly.Blocks['ugj_control_for'] = { this.setStyle('loop_blocks'); } }; -Blockly.JavaScript['ugj_control_for'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_control_for'] = function (block, generator) { var value_index = Blockly.JavaScript.valueToCode(block, 'index', Blockly.JavaScript.ORDER_ATOMIC); // var variable_index = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('index'), Blockly.Variables.NAME_TYPE); var value_from = Blockly.JavaScript.valueToCode(block, 'from', Blockly.JavaScript.ORDER_ATOMIC); @@ -3168,7 +3100,7 @@ Blockly.JavaScript['ugj_control_for'] = function (block) { ].join('\n'); return code; }; -Blockly.Python['ugj_control_for'] = function (block) { +python.pythonGenerator.forBlock['ugj_control_for'] = function (block, generator) { var value_index = Blockly.Python.valueToCode(block, 'index', Blockly.Python.ORDER_ATOMIC); // var variable_index = Blockly.Python.nameDB_.getName(block.getFieldValue('index'), Blockly.Variables.NAME_TYPE); var value_from = Blockly.Python.valueToCode(block, 'from', Blockly.Python.ORDER_ATOMIC); @@ -3207,7 +3139,7 @@ Blockly.Blocks['ugj_controls_foreach'] = { this.setStyle('loop_blocks'); } }; -Blockly.JavaScript['ugj_controls_foreach'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_controls_foreach'] = function (block, generator) { var value_list = Blockly.JavaScript.valueToCode(block, 'list', Blockly.JavaScript.ORDER_ATOMIC); var value_item = Blockly.JavaScript.valueToCode(block, 'item', Blockly.JavaScript.ORDER_ATOMIC); var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); @@ -3220,7 +3152,7 @@ Blockly.JavaScript['ugj_controls_foreach'] = function (block) { ].join('\n'); return code; }; -Blockly.Python['ugj_controls_foreach'] = function (block) { +python.pythonGenerator.forBlock['ugj_controls_foreach'] = function (block, generator) { var value_list = Blockly.Python.valueToCode(block, 'list', Blockly.Python.ORDER_ATOMIC); var value_item = Blockly.Python.valueToCode(block, 'item', Blockly.Python.ORDER_ATOMIC); var statements_do = Blockly.Python.statementToCode(block, 'do'); @@ -3253,7 +3185,7 @@ Blockly.Python['ugj_controls_foreach'] = function (block) { // this.setHelpUrl(""); // } // }; -// Blockly.JavaScript['ugj_set_interval'] = function (block) { +// javascript.javascriptGenerator.forBlock['ugj_set_interval'] = function (block, generator) { // var value_sec = Blockly.JavaScript.valueToCode(block, 'sec', Blockly.JavaScript.ORDER_ATOMIC); // var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); // var code = [ @@ -3279,7 +3211,7 @@ Blockly.Python['ugj_controls_foreach'] = function (block) { // this.setHelpUrl(""); // } // }; -// Blockly.JavaScript['ugj_special_clearinterval'] = function (block) { +// javascript.javascriptGenerator.forBlock['ugj_special_clearinterval'] = function (block, generator) { // var code = 'clearInterval(_interval);\n'; // return code; // }; @@ -3302,7 +3234,7 @@ Blockly.Python['ugj_controls_foreach'] = function (block) { // this.setHelpUrl(""); // } // }; -// Blockly.JavaScript['ugj_set_timeout'] = function (block) { +// javascript.javascriptGenerator.forBlock['ugj_set_timeout'] = function (block, generator) { // var value_sec = Blockly.JavaScript.valueToCode(block, 'sec', Blockly.JavaScript.ORDER_ATOMIC); // var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); // var code = `let _interval = setTimeout(async () => {\n${statements_do}}, ${value_sec}*1000);\n`; @@ -3348,7 +3280,7 @@ Blockly.Blocks['ugj_serial_open'] = { this.jsonInit(ugjSerialOpenDefinition); } }; -Blockly.JavaScript['ugj_serial_open'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_serial_open'] = function (block, generator) { // var value_tty = Blockly.JavaScript.valueToCode(block, 'tty', Blockly.JavaScript.ORDER_ATOMIC); var dropdown_baud = block.getFieldValue('baud'); // Blockly.JavaScript.provideFunction_( @@ -3358,7 +3290,7 @@ Blockly.JavaScript['ugj_serial_open'] = function (block) { // var code = `await _rg.serial_open('/dev/serial0', ${dropdown_baud});\n`; return code; }; -// Blockly.Python['ugj_serial_open'] = function (block) { +// python.pythonGenerator.forBlock['ugj_serial_open'] = function (block, generator) { // var value_tty = Blockly.Python.valueToCode(block, 'tty', Blockly.Python.ORDER_ATOMIC); // var dropdown_baud = block.getFieldValue('baud'); // Blockly.Python.provideFunction_( @@ -3385,11 +3317,11 @@ Blockly.Blocks['ugj_serial_close'] = { this.jsonInit(ugjSerialCloseDefinition); } }; -Blockly.JavaScript['ugj_serial_close'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_serial_close'] = function (block, generator) { var code = 'await _rg.serial_close(_ser_hand);\n'; return code; }; -// Blockly.Python['ugj_serial_close'] = function (block) { +// python.pythonGenerator.forBlock['ugj_serial_close'] = function (block, generator) { // var code = 'pi.serial_close(ser_hand)\n'; // return code; // }; @@ -3418,12 +3350,12 @@ Blockly.Blocks['ugj_serial_write'] = { this.jsonInit(ugjSerialWriteDefinition); } }; -Blockly.JavaScript['ugj_serial_write'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_serial_write'] = function (block, generator) { var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC); var code = `let ret = await _rg.serial_write(_ser_hand, ${value_data});\nconsole.log(ret);\n`; return code; }; -// Blockly.Python['ugj_serial_write'] = function (block) { +// python.pythonGenerator.forBlock['ugj_serial_write'] = function (block, generator) { // var value_data = Blockly.Python.valueToCode(block, 'data', Blockly.Python.ORDER_ATOMIC); // var code = `await pi.serial_write(ser_hand, ${value_data}.encode())\n`; // return code; @@ -3453,12 +3385,12 @@ Blockly.Blocks['ugj_serial_read'] = { this.jsonInit(ugjSerialReadDefinition); } }; -Blockly.JavaScript['ugj_serial_read'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_serial_read'] = function (block, generator) { var value_count = Blockly.JavaScript.valueToCode(block, 'count', Blockly.JavaScript.ORDER_ATOMIC); var code = `await _rg.serial_read(_ser_hand, ${value_count})`; return [code, Blockly.JavaScript.ORDER_ATOMIC]; }; -// Blockly.Python['ugj_serial_read'] = function (block) { +// python.pythonGenerator.forBlock['ugj_serial_read'] = function (block, generator) { // var value_count = Blockly.Python.valueToCode(block, 'count', Blockly.Python.ORDER_ATOMIC); // var code = `await pi.serial_read(ser_hand, ${value_count}).decode()`; // return [code, Blockly.Python.ORDER_ATOMIC]; diff --git a/blocks/dht11/dht11.py b/blocks/dht11/dht11.py deleted file mode 100644 index 55ebee9..0000000 --- a/blocks/dht11/dht11.py +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from __future__ import absolute_import, division, print_function, unicode_literals - -import time -import pigpio - - -class DHT11(object): - """ - The DHT11 class is a stripped version of the DHT22 sensor code by joan2937. - You can find the initial implementation here: - - https://github.com/srounet/pigpio/tree/master/EXAMPLES/Python/DHT22_AM2302_SENSOR - - example code: - >>> pi = pigpio.pi() - >>> sensor = DHT11(pi, 4) # 4 is the data GPIO pin connected to your sensor - >>> for response in sensor: - .... print("Temperature: {}".format(response['temperature'])) - .... print("Humidity: {}".format(response['humidity'])) - """ - - def __init__(self, pi, gpio): - """ - pi (pigpio): an instance of pigpio - gpio (int): gpio pin number - """ - self.pi = pi - self.gpio = gpio - self.high_tick = 0 - self.bit = 40 - self.temperature = 0 - self.humidity = 0 - self.either_edge_cb = None - self.setup() - - def setup(self): - """ - Clears the internal gpio pull-up/down resistor. - Kills any watchdogs. - """ - self.pi.set_pull_up_down(self.gpio, pigpio.PUD_OFF) - self.pi.set_watchdog(self.gpio, 0) - self.register_callbacks() - - def register_callbacks(self): - """ - Monitors RISING_EDGE changes using callback. - """ - self.either_edge_cb = self.pi.callback( - self.gpio, pigpio.EITHER_EDGE, self.either_edge_callback - ) - - def either_edge_callback(self, gpio, level, tick): - """ - Either Edge callbacks, called each time the gpio edge changes. - Accumulate the 40 data bits from the dht11 sensor. - """ - level_handlers = { - pigpio.FALLING_EDGE: self._edge_FALL, - pigpio.RISING_EDGE: self._edge_RISE, - pigpio.EITHER_EDGE: self._edge_EITHER, - } - handler = level_handlers[level] - diff = pigpio.tickDiff(self.high_tick, tick) - handler(tick, diff) - - def _edge_RISE(self, tick, diff): - """ - Handle Rise signal. - """ - val = 0 - if diff >= 50: - val = 1 - if diff >= 200: # Bad bit? - self.checksum = 256 # Force bad checksum - - if self.bit >= 40: # Message complete - self.bit = 40 - elif self.bit >= 32: # In checksum byte - self.checksum = (self.checksum << 1) + val - if self.bit == 39: - # 40th bit received - self.pi.set_watchdog(self.gpio, 0) - total = self.humidity + self.temperature - # is checksum ok ? - if not (total & 255) == self.checksum: - raise - elif 16 <= self.bit < 24: # in temperature byte - self.temperature = (self.temperature << 1) + val - elif 0 <= self.bit < 8: # in humidity byte - self.humidity = (self.humidity << 1) + val - else: # skip header bits - pass - self.bit += 1 - - def _edge_FALL(self, tick, diff): - """ - Handle Fall signal. - """ - self.high_tick = tick - if diff <= 250000: - return - self.bit = -2 - self.checksum = 0 - self.temperature = 0 - self.humidity = 0 - - def _edge_EITHER(self, tick, diff): - """ - Handle Either signal. - """ - self.pi.set_watchdog(self.gpio, 0) - - def read(self): - """ - Start reading over DHT11 sensor. - """ - self.pi.write(self.gpio, pigpio.LOW) - time.sleep(0.017) # 17 ms - self.pi.set_mode(self.gpio, pigpio.INPUT) - self.pi.set_watchdog(self.gpio, 200) - time.sleep(0.2) - - def close(self): - """ - Stop reading sensor, remove callbacks. - """ - self.pi.set_watchdog(self.gpio, 0) - if self.either_edge_cb: - self.either_edge_cb.cancel() - self.either_edge_cb = None - - def __iter__(self): - """ - Support the iterator protocol. - """ - return self - - def __next__(self): - """ - Call the read method and return temperature and humidity informations. - """ - self.read() - response = {"humidity": self.humidity, "temperature": self.temperature} - return response - - -if __name__ == "__main__": - import sys - - args = sys.argv - pin = int(args[1]) - pi = pigpio.pi() - sensor = DHT11(pi, pin) - for d in sensor: - # print("temperature: {}".format(d["temperature"])) - # print("humidity: {}".format(d["humidity"])) - - print( - '{"temperature":' - + str(d["temperature"]) - + ',"humidity":' - + str(d["humidity"]) - + "}", - flush=True, - ) - break - # time.sleep(1) - sensor.close() diff --git a/blocks/dht11/index.js b/blocks/dht11/index.js deleted file mode 100644 index 72d2477..0000000 --- a/blocks/dht11/index.js +++ /dev/null @@ -1,71 +0,0 @@ -Blockly.Blocks['ugj_dht11'] = { - init: function () { - this.appendValueInput("pin") - .setCheck("Number") - .appendField("GPIO"); - this.appendDummyInput() - .appendField("の DHT11 センサーの値を取得"); - this.setInputsInline(true); - this.setPreviousStatement(true, null); - this.setNextStatement(true, null); - this.setTooltip(""); - this.setHelpUrl("気温・湿度センサーDHT11で、気温(摂氏)、湿度(%)を計測します。計測値は計測値ブロックで参照します。"); - this.setStyle('sensor_blocks'); - } -}; -Blockly.JavaScript['ugj_dht11'] = function (block) { - var value_pin = Blockly.JavaScript.valueToCode(block, 'pin', Blockly.JavaScript.ORDER_ATOMIC); - let pypath = apptool.path.join(apptool.blocks_dir, 'sensors', 'dht11', 'dht11.py'); - var code = `let _th = require('child_process').spawnSync('python3', ['${pypath}', '${value_pin}'], {timeout: 5000}).stdout.toString(); - let _dhtdata = JSON.parse(_th);`; - // let _dht11data[0] = - // console.log('t=' + obj.temperature); - // console.log('h=' + obj.humidity); - return code; -}; -Blockly.Blocks['ugj_dht11_data'] = { - init: function () { - this.appendDummyInput() - .appendField(new Blockly.FieldDropdown([["気温", "temperature"], ["湿度", "humidity"]]), "th"); - this.setInputsInline(true); - this.setOutput(true, null); - this.setStyle('sensor_blocks'); - this.setTooltip("DHT11 の計測値を返します。"); - this.setHelpUrl(""); - } -}; -Blockly.JavaScript['ugj_dht11_data'] = function (block) { - var dropdown_th = block.getFieldValue('th'); - var code = `_dhtdata.${dropdown_th}`; - return [code, Blockly.JavaScript.ORDER_ATOMIC]; -}; - -flyout_contents = flyout_contents.concat([ - { - "kind": "label", - "text": "温湿度センサー DHT11", - "web-line": "4.0", - "web-line-width": "200" - }, - { - "kind": "block", - "type": "ugj_dht11", - "inputs": { - "pin": { - "shadow": { - "type": "math_number", - "fields": { - "NUM": "8" - } - } - } - } - }, - { - "kind": "block", - "type": "ugj_dht11_data", - "fields": { - "th": "temperature" - } - } -]); \ No newline at end of file diff --git a/blocks/index.js b/blocks/index.js index 0f0f1a5..0908e6d 100644 --- a/blocks/index.js +++ b/blocks/index.js @@ -30,7 +30,5 @@ registerCategory('sensors', [ // サブカテゴリファイル名 "paj7620.js", "bme280.js", "ssd1306.js", - // "dht11", - // "pico_slave", - "z-line.js" // フライアウト下端の不可視ライン。スクリプトにカテゴリ名を含むので注意 + "z-line.js" // フライアウト下端の不可視ライン。フライアウトのアップデートをここで行っているので変更・削除に注意! ]); diff --git a/blocks/pico_slave/index.js b/blocks/pico_slave/index.js deleted file mode 100644 index 3c5eddd..0000000 --- a/blocks/pico_slave/index.js +++ /dev/null @@ -1,66 +0,0 @@ -Blockly.Blocks['oc_i2cslave'] = { - init: function () { - this.appendValueInput("i2c_addr") - .setCheck("Number") - .appendField("PICOスレーブ:I2Cアドレス"); - this.appendDummyInput() - .appendField(new Blockly.FieldVariable("データ"), "data") - .appendField("を受け取ったら"); - this.appendStatementInput("do") - .setCheck(null); - this.setInputsInline(false); - this.setPreviousStatement(true, null); - this.setTooltip("Raspberry Pi Pico(及びその互換機)を I2Cスレーブ化します。受信データは1バイトデータです。i2c_slave.py が必要です。"); - this.setHelpUrl(""); - this.setStyle('gpio_blocks'); - } -}; -Blockly.Python['oc_i2cslave'] = function (block) { - var value_i2c_addr = Blockly.Python.valueToCode(block, 'i2c_addr', Blockly.Python.ORDER_ATOMIC); - var variable_data = Blockly.Python.nameDB_.getName(block.getFieldValue('data'), Blockly.Names.NameType.VARIABLE); - var statements_do = Blockly.Python.statementToCode(block, 'do'); - Blockly.Python.provideFunction_( - 'import_i2cslave', ['from i2cSlave import i2c_slave'] - ); - var code = `_i2cs = i2c_slave(0,sda=0,scl=1,slaveAddress=${value_i2c_addr}) -while True: - ${variable_data} = int(_i2cs.get()) -${statements_do} -`; - return code; -}; - - -flyout_contents = flyout_contents.concat([ - { - "kind": "label", - "text": "RPi Pico I2Cスレーブ化", - "web-line": "4.0", - "web-line-width": "200" - }, { - "kind": "block", - "type": "oc_i2cslave", - "fields": { - "data": { - "name": "データ" - } - }, - "inputs": { - "i2c_addr": { - "shadow": { - "type": "ugj_hextodec", - "inputs": { - "hex": { - "shadow": { - "type": "text", - "fields": { - "TEXT": "41" - } - } - } - } - } - } - } - } -]) \ No newline at end of file diff --git a/blocks/sensors/amg8833.js b/blocks/sensors/amg8833.js index 2be2934..41cb299 100644 --- a/blocks/sensors/amg8833.js +++ b/blocks/sensors/amg8833.js @@ -51,18 +51,12 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "sensor_blocks" }]); -Blockly.JavaScript['ugj_grideye_init'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_grideye_init'] = function (block, generator) { var dropdown_addr = block.getFieldValue('addr'); - // Blockly.JavaScript.provideFunction_( - // 'require_gpio', [`const _pi = require('` + apptool.gpio_lib + `');`] - // ); - // let modpath = apptool.path.join(apptool.blocks_dir, 'sensors', 'amg8833', `AMG8833x.js`); Blockly.JavaScript.provideFunction_( 'require_amg8833', [`const _amg8833 = require('@ocoge/amg8833');`] - // 'require_amg8833', [`const _amg8833 = require('${modpath}');`] ); var code = `await _amg8833.init(_rg, ${apptool.i2c_bus}, ${dropdown_addr});\n`; - // var code = `await _amg8833.init(${apptool.i2c_bus}, ${dropdown_addr}, window.addEventListener);\n`; return code;// }; /********************** */ @@ -76,7 +70,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "sensor_blocks" }]); -Blockly.JavaScript['ugj_grideye_thermistor'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_grideye_thermistor'] = function (block, generator) { var code = `await _amg8833.read_thermistor()`; return [code, Blockly.JavaScript.ORDER_NONE]; }; @@ -93,7 +87,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "sensor_blocks" }]); -Blockly.JavaScript['ugj_grideye_read'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_grideye_read'] = function (block, generator) { var code = 'await _amg8833.read_temp_array()'; return [code, Blockly.JavaScript.ORDER_ATOMIC]; }; @@ -110,7 +104,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "sensor_blocks" }]); -Blockly.JavaScript['ugj_grideye_stop'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_grideye_stop'] = function (block, generator) { var code = 'await _amg8833.stop();\n'; return code; }; @@ -129,7 +123,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "multimedia_blocks" }]); -Blockly.JavaScript['ugj_grideye_canvas_create'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_grideye_canvas_create'] = function (block, generator) { var code = `let _grideye_canvas = document.createElement('canvas'); _grideye_canvas.setAttribute('width', 8); _grideye_canvas.setAttribute('height', 8); @@ -190,7 +184,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "multimedia_blocks" }]); -Blockly.JavaScript['ugj_draw_grideyedata'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_draw_grideyedata'] = function (block, generator) { var value_amg8833data = Blockly.JavaScript.valueToCode(block, 'amg8833data', Blockly.JavaScript.ORDER_ATOMIC); var colour_color_high = block.getFieldValue('color_high'); var value_temp_high = Blockly.JavaScript.valueToCode(block, 'temp_high', Blockly.JavaScript.ORDER_ATOMIC); @@ -241,7 +235,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "multimedia_blocks" }]); -Blockly.JavaScript['ugj_teachable_machine'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_teachable_machine'] = function (block, generator) { Blockly.JavaScript.provideFunction_( 'require_ts', [`const _tf = require('@tensorflow/tfjs-node');`] ); @@ -269,7 +263,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "multimedia_blocks" }]); -Blockly.JavaScript['ugj_grideye_predict_class'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_grideye_predict_class'] = function (block, generator) { var functionName = Blockly.JavaScript.provideFunction_( // left output にするための関数化 '_predictClass', [ @@ -307,7 +301,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "multimedia_blocks" }]); -Blockly.JavaScript['ugj_grideye_add_example'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_grideye_add_example'] = function (block, generator) { var value_class_id = Blockly.JavaScript.valueToCode(block, 'class_id', Blockly.JavaScript.ORDER_ATOMIC); var code = `_classifier.addExample (_net.infer(_grideye_canvas, true), ${value_class_id});`; return code; @@ -323,7 +317,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "multimedia_blocks" }]); -Blockly.JavaScript['ugj_tensorset_stringify'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_tensorset_stringify'] = function (block, generator) { var code = `JSON.stringify( Object.entries(_classifier.getClassifierDataset()).map(([label, data])=>[label, Array.from(data.dataSync()), data.shape]) )`; return [code, Blockly.JavaScript.ORDER_NONE]; }; @@ -346,7 +340,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "multimedia_blocks" }]); -Blockly.JavaScript['ugj_tensorset_parse'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_tensorset_parse'] = function (block, generator) { var value_class_data_json = Blockly.JavaScript.valueToCode(block, 'class_data_json', Blockly.JavaScript.ORDER_ATOMIC); var code = `_classifier.setClassifierDataset( Object.fromEntries( JSON.parse(${value_class_data_json}).map(([label, data, shape])=>[label, _tf.tensor(data, shape)]) ) );`; return code; @@ -372,7 +366,7 @@ Blockly.defineBlocksWithJsonArray([{ "helpUrl": "", "style": "math_blocks" }]); -Blockly.JavaScript['ugj_temp'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_temp'] = function (block, generator) { var number_temp = block.getFieldValue('temp'); var code = `${number_temp}`; return [code, Blockly.JavaScript.ORDER_NONE]; diff --git a/blocks/sensors/bme280.js b/blocks/sensors/bme280.js index bfb328c..cabf042 100644 --- a/blocks/sensors/bme280.js +++ b/blocks/sensors/bme280.js @@ -15,16 +15,10 @@ Blockly.Blocks['ugj_bme280'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_bme280'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_bme280'] = function (block, generator) { var dropdown_addr = block.getFieldValue('addr'); - // Blockly.JavaScript.provideFunction_( - // 'require_gpio', [`const _pi = require('` + apptool.gpio_lib + `');`] - // ); - // let modpath = apptool.path.join(apptool.blocks_dir, 'sensors', 'bme280', 'BME280x.js'); - // let modpath = apptool.path.join(apptool.blocks_dir, 'sensors', 'bme280', `BME280x.js`); Blockly.JavaScript.provideFunction_( 'require_bme280', [`const _bme280 = require('@ocoge/bme280');`] - // 'require_bme280', [`const _bme280 = require('${modpath}');`] ); var code = `const options = { i2cBusNo: ${apptool.i2c_bus}, @@ -51,7 +45,7 @@ Blockly.Blocks['ugj_bme280_data'] = { this.setHelpUrl(""); } }; -Blockly.JavaScript['ugj_bme280_data'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_bme280_data'] = function (block, generator) { var dropdown_thp = block.getFieldValue('thp'); var code = `_bmedata[${dropdown_thp}]`; return [code, Blockly.JavaScript.ORDER_ATOMIC]; diff --git a/blocks/sensors/paj7620.js b/blocks/sensors/paj7620.js index 27a5e54..1cdc1ab 100644 --- a/blocks/sensors/paj7620.js +++ b/blocks/sensors/paj7620.js @@ -30,15 +30,10 @@ Blockly.Blocks['ugj_gesture_init'] = { this.jsonInit(ugjGestureInitDefinition); } }; -Blockly.JavaScript['ugj_gesture_init'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_gesture_init'] = function (block, generator) { var value_i2c_addr = Blockly.JavaScript.valueToCode(block, 'i2c_addr', Blockly.JavaScript.ORDER_ATOMIC); - // Blockly.JavaScript.provideFunction_( - // 'require_gpio', [`const _pi = require('` + apptool.gpio_lib + `');`] - // ); - // let modpath = apptool.path.join(apptool.blocks_dir, 'sensors', 'paj7620', 'PAJ7620x.js'); Blockly.JavaScript.provideFunction_( 'require_paj7620', [`const _paj7620 = require('@ocoge/paj7620');`] - // 'require_paj7620', [`const _paj7620 = require('${modpath}');`] ); var code = `await _paj7620.init(_rg, ${apptool.i2c_bus}, ${value_i2c_addr}); `; @@ -62,7 +57,7 @@ Blockly.Blocks['ugj_gesture_read'] = { this.jsonInit(ugjGestureReadDefinition); } }; -Blockly.JavaScript['ugj_gesture_read'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_gesture_read'] = function (block, generator) { var code = 'await _paj7620.return_gesture()'; return [code, Blockly.JavaScript.ORDER_ATOMIC]; }; @@ -84,7 +79,7 @@ Blockly.Blocks['ugj_gesture_stop'] = { this.jsonInit(ugjGestureStopDefinition); } }; -Blockly.JavaScript['ugj_gesture_stop'] = function (block) { +javascript.javascriptGenerator.forBlock['ugj_gesture_stop'] = function (block, generator) { var code = 'await _paj7620.stop();\n'; return code; }; diff --git a/index.html b/index.html index 38ee6a9..46fee7f 100644 --- a/index.html +++ b/index.html @@ -915,32 +915,6 @@ - - - - 23 - - - - - - - 22 - - - - - - - - - - - - 23 - - - diff --git a/lib/irrp.py b/lib/irrp.py deleted file mode 100644 index e113006..0000000 --- a/lib/irrp.py +++ /dev/null @@ -1,515 +0,0 @@ -#!/usr/bin/env python - -# irrp.py -# 2015-12-21 -# Public Domain - -""" -A utility to record and then playback IR remote control codes. - -To record use - -./irrp.py -r -g4 -fcodes 1 2 3 4 5 6 - -where - --r record --g the GPIO connected to the IR receiver --f the file to store the codes - -and 1 2 3 4 5 6 is a list of codes to record. - -To playback use - -./irrp.py -p -g17 -fcodes 2 3 4 - -where - --p playback --g the GPIO connected to the IR transmitter --f the file storing the codes to transmit - -and 2 3 4 is a list of codes to transmit. - -OPTIONS - --r record --p playback --g GPIO (receiver for record, transmitter for playback) --f file - -id1 id2 id3 list of ids to record or transmit - -RECORD - ---glitch ignore edges shorter than glitch microseconds, default 100 us ---post expect post milliseconds of silence after code, default 15 ms ---pre expect pre milliseconds of silence before code, default 200 ms ---short reject codes with less than short pulses, default 10 ---tolerance consider pulses the same if within tolerance percent, default 15 ---no-confirm don't require a code to be repeated during record - -TRANSMIT - ---freq IR carrier frequency, default 38 kHz ---gap gap in milliseconds between transmitted codes, default 100 ms -""" - -import time -import json -import os -import argparse - -import pigpio # http://abyz.co.uk/rpi/pigpio/python.html - -p = argparse.ArgumentParser() - -g = p.add_mutually_exclusive_group(required=True) -g.add_argument("-p", "--play", help="play keys", action="store_true") -g.add_argument("-r", "--record", help="record keys", action="store_true") - -p.add_argument("-g", "--gpio", help="GPIO for RX/TX", required=True, type=int) -# p.add_argument("-f", "--file", help="Filename", required=True) -p.add_argument("--irdata", help="IR Data") - -p.add_argument('id', nargs='+', type=str, help='IR codes') - -p.add_argument("--freq", help="frequency kHz", type=float, default=38.0) - -p.add_argument("--gap", help="key gap ms", type=int, default=100) -p.add_argument("--glitch", help="glitch us", type=int, default=100) -p.add_argument("--post", help="postamble ms", type=int, default=15) -p.add_argument("--pre", help="preamble ms", type=int, default=200) -p.add_argument("--short", help="short code length", type=int, default=10) -p.add_argument("--tolerance", help="tolerance percent", type=int, default=15) - -p.add_argument("-v", "--verbose", help="Be verbose", action="store_true") -p.add_argument("--no-confirm", help="No confirm needed", action="store_true") - -args = p.parse_args() - -GPIO = args.gpio -# FILE = args.file -IRDATA = args.irdata -GLITCH = args.glitch -PRE_MS = args.pre -POST_MS = args.post -FREQ = args.freq -VERBOSE = args.verbose -SHORT = args.short -GAP_MS = args.gap -NO_CONFIRM = args.no_confirm -TOLERANCE = args.tolerance - -POST_US = POST_MS * 1000 -PRE_US = PRE_MS * 1000 -GAP_S = GAP_MS / 1000.0 -CONFIRM = not NO_CONFIRM -TOLER_MIN = (100 - TOLERANCE) / 100.0 -TOLER_MAX = (100 + TOLERANCE) / 100.0 - -last_tick = 0 -in_code = False -code = [] -fetching_code = False - -def backup(f): - """ - f -> f.bak -> f.bak1 -> f.bak2 - """ - try: - os.rename(os.path.realpath(f)+".bak1", os.path.realpath(f)+".bak2") - except: - pass - - try: - os.rename(os.path.realpath(f)+".bak", os.path.realpath(f)+".bak1") - except: - pass - - try: - os.rename(os.path.realpath(f), os.path.realpath(f)+".bak") - except: - pass - -def carrier(gpio, frequency, micros): - """ - Generate carrier square wave. - """ - wf = [] - cycle = 1000.0 / frequency - cycles = int(round(micros/cycle)) - on = int(round(cycle / 2.0)) - sofar = 0 - for c in range(cycles): - target = int(round((c+1)*cycle)) - sofar += on - off = target - sofar - sofar += off - wf.append(pigpio.pulse(1< TOLER_MAX): - return False - - for i in range(len(p1)): - p1[i] = int(round((p1[i]+p2[i])/2.0)) - - if VERBOSE: - print("after compare", p1, flush=True) - - return True - -def tidy_mark_space(records, base): - - ms = {} - - # Find all the unique marks (base=0) or spaces (base=1) - # and count the number of times they appear, - - for rec in records: - rl = len(records[rec]) - for i in range(base, rl, 2): - if records[rec][i] in ms: - ms[records[rec][i]] += 1 - else: - ms[records[rec][i]] = 1 - - if VERBOSE: - print("t_m_s A", ms, flush=True) - - v = None - - for plen in sorted(ms): - - # Now go through in order, shortest first, and collapse - # pulses which are the same within a tolerance to the - # same value. The value is the weighted average of the - # occurences. - # - # E.g. 500x20 550x30 600x30 1000x10 1100x10 1700x5 1750x5 - # - # becomes 556(x80) 1050(x20) 1725(x10) - # - if v == None: - e = [plen] - v = plen - tot = plen * ms[plen] - similar = ms[plen] - - elif plen < (v*TOLER_MAX): - e.append(plen) - tot += (plen * ms[plen]) - similar += ms[plen] - - else: - v = int(round(tot/float(similar))) - # set all previous to v - for i in e: - ms[i] = v - e = [plen] - v = plen - tot = plen * ms[plen] - similar = ms[plen] - - v = int(round(tot/float(similar))) - # set all previous to v - for i in e: - ms[i] = v - - if VERBOSE: - print("t_m_s B", ms, flush=True) - - for rec in records: - rl = len(records[rec]) - for i in range(base, rl, 2): - records[rec][i] = ms[records[rec][i]] - -def tidy(records): - - tidy_mark_space(records, 0) # Marks. - - tidy_mark_space(records, 1) # Spaces. - -def end_of_code(): - global code, fetching_code - if len(code) > SHORT: - normalise(code) - fetching_code = False - else: - code = [] - print("Short code, probably a repeat, try again", flush=True) - -def cbf(gpio, level, tick): - - global last_tick, in_code, code, fetching_code - - if level != pigpio.TIMEOUT: - - edge = pigpio.tickDiff(last_tick, tick) - last_tick = tick - - if fetching_code: - - if (edge > PRE_US) and (not in_code): # Start of a code. - in_code = True - pi.set_watchdog(GPIO, POST_MS) # Start watchdog. - - elif (edge > POST_US) and in_code: # End of a code. - in_code = False - pi.set_watchdog(GPIO, 0) # Cancel watchdog. - end_of_code() - - elif in_code: - code.append(edge) - - else: - pi.set_watchdog(GPIO, 0) # Cancel watchdog. - if in_code: - in_code = False - end_of_code() - -pi = pigpio.pi() # Connect to Pi. - -if not pi.connected: - exit(0) - -if args.record: # Record. - - # try: - # f = open(FILE, "r") - # records = json.load(f) - # f.close() - # except: - # records = {} - records = {} - - pi.set_mode(GPIO, pigpio.INPUT) # IR RX connected to this GPIO. - - pi.set_glitch_filter(GPIO, GLITCH) # Ignore glitches. - - cb = pi.callback(GPIO, pigpio.EITHER_EDGE, cbf) - - # Process each id - - print("読み取り開始:", flush=True) - for arg in args.id: - print("リモコンのボタンを押してください。", flush=True) - code = [] - fetching_code = True - while fetching_code: - time.sleep(0.1) - print("OK", flush=True) - time.sleep(0.5) - - if CONFIRM: - press_1 = code[:] - done = False - - tries = 0 - while not done: - print("確認のためもう一度同じボタンを押してください。", flush=True) - code = [] - fetching_code = True - while fetching_code: - time.sleep(0.1) - press_2 = code[:] - the_same = compare(press_1, press_2) - if the_same: - done = True - records[arg] = press_1[:] - print("OK", flush=True) - time.sleep(0.5) - else: - tries += 1 - if tries <= 3: - print("信号が一致しません。", flush=True) - else: - print("信号が一致しませんでした。終了します。", flush=True) - done = True - time.sleep(0.5) - else: # No confirm. - records[arg] = code[:] - - pi.set_glitch_filter(GPIO, 0) # Cancel glitch filter. - pi.set_watchdog(GPIO, 0) # Cancel watchdog. - - tidy(records) - - # backup(FILE) - - # f = open(FILE, "w") - # f.write(json.dumps(records, sort_keys=True).replace("],", "],\n")+"\n") - # f.close() - - # print('\n', flush=True) - print(json.dumps(records), flush=True) - -else: # Playback. - - # try: - # f = open(FILE, "r") - # except: - # print("Can't open: {}".format(FILE)) - # exit(0) - - # print(FILE, flush=True) - records = json.loads(IRDATA) - # records = json.loads(FILE) - # print(records, flush=True) - - # f.close() - - pi.set_mode(GPIO, pigpio.OUTPUT) # IR TX connected to this GPIO. - - pi.wave_add_new() - - emit_time = time.time() - - if VERBOSE: - print("送信中", flush=True) - - for arg in args.id: - if arg in records: - - code = records[arg] - - # Create wave - - marks_wid = {} - spaces_wid = {} - - wave = [0]*len(code) - - for i in range(0, len(code)): - ci = code[i] - if i & 1: # Space - if ci not in spaces_wid: - pi.wave_add_generic([pigpio.pulse(0, 0, ci)]) - spaces_wid[ci] = pi.wave_create() - wave[i] = spaces_wid[ci] - else: # Mark - if ci not in marks_wid: - wf = carrier(GPIO, FREQ, ci) - pi.wave_add_generic(wf) - marks_wid[ci] = pi.wave_create() - wave[i] = marks_wid[ci] - - delay = emit_time - time.time() - - if delay > 0.0: - time.sleep(delay) - - pi.wave_chain(wave) - - if VERBOSE: - print("key " + arg, flush=True) - - while pi.wave_tx_busy(): - time.sleep(0.002) - - emit_time = time.time() + GAP_S - - for i in marks_wid: - pi.wave_delete(marks_wid[i]) - - marks_wid = {} - - for i in spaces_wid: - pi.wave_delete(spaces_wid[i]) - - spaces_wid = {} - - print("Id: {}".format(arg), flush=True) - else: - print("Id {} not found".format(arg), flush=True) - -pi.stop() # Disconnect from Pi. - diff --git a/lib/oled.py b/lib/oled.py deleted file mode 100644 index 4f10b5a..0000000 --- a/lib/oled.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- - -import sys -import Adafruit_SSD1306 -from PIL import Image -from PIL import ImageDraw -from PIL import ImageFont - -# Settings -FONT_SIZE = 12 -LINE_SPACING = 4 - -args = sys.argv -linenum = int(args[1]) # 0 origin -if linenum >= 0: - text = args[2] - -RST = 24 - -disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST) - -disp.begin() - -if linenum < 0: - disp.clear() - disp.display() - exit() - -width = disp.width -height = disp.height -image = Image.new('1', (width, height)) -draw = ImageDraw.Draw(image) - -#draw.rectangle((0, 0, width, height), outline=0, fill=0) - -font = ImageFont.truetype( - '/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf', 12) - -LINE_HEIGHT = FONT_SIZE + LINE_SPACING - -x = 0 -y = linenum * LINE_HEIGHT -draw.rectangle((x, y, width, y+LINE_HEIGHT), outline=0, fill=0) # 行消去 -draw.text((0, y), text, font=font, fill=255) - -disp.image(image) -disp.display() diff --git a/local_modules/amg8833/amg8833x.js b/local_modules/amg8833/amg8833x.js index bf4f5fd..a696d3c 100644 --- a/local_modules/amg8833/amg8833x.js +++ b/local_modules/amg8833/amg8833x.js @@ -1,24 +1,13 @@ 'use strict'; const err_msg = 'AMG8833 is already opened. Please close old connection to use new one.'; -// const pig = require(`${apptool.gpio_lib}`); -// let pi = -1; let rg; let i2c_hand = -1; exports.init = async (_rg, i2c_bus, i2c_addr, wael = null) => { - // if (wael !== null) { - // wael('beforeunload', async () => { - // await exports.stop(); - // }); - // } - // if (pi >= 0) { throw new Error(err_msg); return; } - // pi = await pig._rgpiod_start('', ''); - // console.log('pi=' + pi); rg = _rg; if (i2c_hand >= 0) { throw new Error(err_msg); return; } i2c_hand = await rg.i2c_open(i2c_bus, i2c_addr, 0); - // i2c_hand = await pig._i2c_open(pi, i2c_bus, i2c_addr, 0); console.log('i2c_hand=' + i2c_hand); await rg.i2c_write_byte_data(i2c_hand, 0x00, 0x00); //Normal mode await rg.i2c_write_byte_data(i2c_hand, 0x02, 0x00); //10FPS @@ -47,10 +36,6 @@ exports.stop = async () => { await rg.i2c_close(i2c_hand); i2c_hand = -1; } - // if (pi >= 0) { - // await pig._rgpiod_stop(pi); - // pi = -1; - // } } /* diff --git a/local_modules/bme280/bme280x.js b/local_modules/bme280/bme280x.js index 9bb7254..b1aa007 100644 --- a/local_modules/bme280/bme280x.js +++ b/local_modules/bme280/bme280x.js @@ -1,7 +1,5 @@ 'use strict'; -// this.pig = null; -// this.pi = null; this.rg = null; this.i2cBusNo = null; @@ -43,8 +41,6 @@ this.REGISTER_TEMP_DATA = 0xFA; this.REGISTER_HUMIDITY_DATA = 0xFD; exports.init = async (rg, options) => { - // this.pig = require(`${apptool.gpio_lib}`); - // this.pi = await this.rg.rgpiod_start('', ''); this.rg = rg; this.i2cBusNo = (options && options.hasOwnProperty('i2cBusNo')) ? options.i2cBusNo : 1; @@ -98,8 +94,6 @@ exports.cancel = async () => { if (this.i2cHand >= 0) { await this.rg.i2c_close(this.i2cHand); this.i2cHand = null; - // await this.rg.rgpiod_stop(this.pi); - // this.pi = null; } } diff --git a/local_modules/paj7620/paj7620x.js b/local_modules/paj7620/paj7620x.js index 183902a..7e031e9 100644 --- a/local_modules/paj7620/paj7620x.js +++ b/local_modules/paj7620/paj7620x.js @@ -461,10 +461,6 @@ exports.stop = async () => { await rg.i2c_close(i2c_hand); i2c_hand = -1; } - // if (sbc >= 0) { - // await rg.rgpiod_stop(sbc); - // sbc = -1; - // } } /* diff --git a/local_modules/rgpio/index.js b/local_modules/rgpio/index.js index 3f192de..b9b5bfe 100644 --- a/local_modules/rgpio/index.js +++ b/local_modules/rgpio/index.js @@ -147,6 +147,4 @@ module.exports.i2c_write_device_sync = (handle, data, count = -1) => { // 終了処理 module.exports.close_all_handle = async () => { await module.exports.sbc_stop(); - // await module.exports.serial_close(); - // await module.exports.i2c_close(); } \ No newline at end of file diff --git a/local_modules/rgpio/rgpio.cpp b/local_modules/rgpio/rgpio.cpp index 7eb54b0..0a3025a 100644 --- a/local_modules/rgpio/rgpio.cpp +++ b/local_modules/rgpio/rgpio.cpp @@ -1,5 +1,5 @@ /** lgpio を Node.js から利用するモジュール ** */ -/** 関数名・書式は lgpio Python に準拠 ******************* */ +/** 関数名・書式は rgpio Python に準拠 ******************* */ #include #include diff --git a/oled-i2c-rgpio/README.md b/oled-i2c-rgpio/README.md deleted file mode 100644 index 1b7ecb0..0000000 --- a/oled-i2c-rgpio/README.md +++ /dev/null @@ -1,285 +0,0 @@ -![‘npm version’](http://img.shields.io/npm/v/oled-js.svg?style=flat) ![‘downloads over month’](http://img.shields.io/npm/dm/oled-js.svg?style=flat) - -OLED JS Pi over i2c-bus -======================== - -## What is this? - -This is fork of package [`oled-js-pi`](https://github.com/kd7yva/oled-js-pi) that works thru `i2c-bus` package and not use package `i2c`. - -A NodeJS driver for I2C/SPI compatible monochrome OLED screens; to be used on the Raspberry Pi! Works with 128 x 32, 128 x 64 and 96 x 16 sized screens, of the SSD1306 OLED/PLED Controller (read the [datasheet here](http://www.adafruit.com/datasheets/SSD1306.pdf)). - -This based on the Blog Post and code by Suz Hinton - [Read her blog post about how OLED screens work](http://meow.noopkat.com/oled-js/)! - -OLED screens are really cool - now you can control them with JavaScript! - -## Install - -If you haven't already, install [NodeJS](http://nodejs.org/). - -`npm install oled-i2c-bus` - -## I2C screens -Hook up I2C compatible oled to the Raspberry Pi. Pins: SDL and SCL - -### I2C example - -```javascript -var i2c = require('i2c-bus'), - i2cBus = i2c.openSync(1), - oled = require('oled-i2c-bus'); - -var opts = { - width: 128, - height: 64, - address: 0x3D -}; - -var oled = new oled(i2cBus, opts); - -// do cool oled things here - -``` - -### Wait, how do I find out the I2C address of my OLED screen? -Check your screen's documentation... - -## Available methods - -### clearDisplay -Fills the buffer with 'off' pixels (0x00). Optional bool argument specifies whether screen updates immediately with result. Default is true. - -Usage: -```javascript -oled.clearDisplay(); -``` - -### dimDisplay -Lowers the contrast on the display. This method takes one argument, a boolean. True for dimming, false to restore normal contrast. - -Usage: -```javascript -oled.dimDisplay(true|false); -``` - -### invertDisplay -Inverts the pixels on the display. Black becomes white, white becomes black. This method takes one argument, a boolean. True for inverted state, false to restore normal pixel colors. - -Usage: -```javascript -oled.invertDisplay(true|false); -``` - -### turnOffDisplay -Turns the display off. - -Usage: -```javascript -oled.turnOffDisplay(); -``` - -### turnOnDisplay -Turns the display on. - -Usage: -```javascript -oled.turnOnDisplay(); -``` - - -### drawPixel -Draws a pixel at a specified position on the display. This method takes one argument: a multi-dimensional array containing either one or more sets of pixels. - -Each pixel needs an x position, a y position, and a color. Colors can be specified as either 0 for 'off' or black, and 1 or 255 for 'on' or white. - -Optional bool as last argument specifies whether screen updates immediately with result. Default is true. - -Usage: -```javascript -// draws 4 white pixels total -// format: [x, y, color] -oled.drawPixel([ - [128, 1, 1], - [128, 32, 1], - [128, 16, 1], - [64, 16, 1] -]); -``` - -### drawLine -Draws a one pixel wide line. - -Arguments: -+ int **x0, y0** - start location of line -+ int **x1, y1** - end location of line -+ int **color** - can be specified as either 0 for 'off' or black, and 1 or 255 for 'on' or white. - -Optional bool as last argument specifies whether screen updates immediately with result. Default is true. - -Usage: -```javascript -// args: (x0, y0, x1, y1, color) -oled.drawLine(1, 1, 128, 32, 1); -``` - -### fillRect -Draws a filled rectangle. - -Arguments: -+ int **x0, y0** - top left corner of rectangle -+ int **w, h** - width and height of rectangle -+ int **color** - can be specified as either 0 for 'off' or black, and 1 or 255 for 'on' or white. - -Optional bool as last argument specifies whether screen updates immediately with result. Default is true. - -Usage: -```javascript -// args: (x0, y0, x1, y1, color) -oled.fillRect(1, 1, 10, 20, 1); -``` - -### drawBitmap -Draws a bitmap using raw pixel data returned from an image parser. The image sourced must be monochrome, and indexed to only 2 colors. Resize the bitmap to your screen dimensions first. Using an image editor or ImageMagick might be required. - -Optional bool as last argument specifies whether screen updates immediately with result. Default is true. - -Tip: use a NodeJS image parser to get the pixel data, such as [pngparse](https://www.npmjs.org/package/pngparse). A demonstration of using this is below. - - -Example usage: -``` -npm install pngparse -``` - -```javascript -var pngparse = require('pngparse'); - -pngparse.parseFile('indexed_file.png', function(err, image) { - oled.drawBitmap(image.data); -}); -``` - -This method is provided as a primitive convenience. A better way to display images is to use NodeJS package [png-to-lcd](https://www.npmjs.org/package/png-to-lcd) instead. It's just as easy to use as drawBitmap, but is compatible with all image depths (lazy is good!). It will also auto-dither if you choose. You should still resize your image to your screen dimensions. This alternative method is covered below: - -``` -npm install png-to-lcd -``` - -```javascript -var pngtolcd = require('png-to-lcd'); - -pngtolcd('nyan-cat.png', true, function(err, bitmap) { - oled.buffer = bitmap; - oled.update(); -}); -``` - -### drawRGBAImage -Draw an RGBA coded image at specific coordinates. This only supports a monochrome -OLED so transparent pixels must be 100% transparent, off pixels should have an -RGB value of (0, 0, 0), and pixels with any color value will be considered on. - -Use a library such as [pngjs](https://www.npmjs.com/package/pngjs) to read a png -file into the required rgba data structure. - -Example: -```JavaScript -const fs = require('fs'); -const PNG = require('pngjs').PNG; -const i2c = require('i2c-bus'); -const oled = require('oled-i2c-bus'); - -var i2cBus = i2c.openSync(0); - -var opts = { - width: 128, - height: 64, - address: 0x3C -}; - -var display = new oled(i2cBus, opts); - -display.clearDisplay(); -display.turnOnDisplay(); - -fs.createReadStream('./test.png') -.pipe(new PNG({ filterType: 4 })) -.on('parsed', function () { - setInterval(() => { drawImage(this) }, 1000); -}); - -function drawImage(image) { - let x = Math.floor(Math.random() * (display.WIDTH) - image.width / 2); - let y = Math.floor(Math.random() * (display.HEIGHT) - image.height / 2); - display.drawRGBAImage(image, x, y); -} -``` - - -### startScroll -Scrolls the current display either left or right. -Arguments: -+ string **direction** - direction of scrolling. 'left' or 'right' -+ int **start** - starting row of scrolling area -+ int **stop** - end row of scrolling area - -Usage: -```javascript -// args: (direction, start, stop) -oled.startscroll('left', 0, 15); // this will scroll an entire 128 x 32 screen -``` - -### stopScroll -Stops all current scrolling behaviour. - -Usage: -```javascript -oled.stopscroll(); -``` - -### setCursor -Sets the x and y position of 'cursor', when about to write text. This effectively helps tell the display where to start typing when writeString() method is called. - -Call setCursor just before writeString(). - -Usage: -```javascript -// sets cursor to x = 1, y = 1 -oled.setCursor(1, 1); -``` - -### writeString -Writes a string of text to the display. -Call setCursor() just before, if you need to set starting text position. - -Arguments: -+ obj **font** - font object in JSON format (see note below on sourcing a font) -+ int **size** - font size, as multiplier. Eg. 2 would double size, 3 would triple etc. -+ string **text** - the actual text you want to show on the display. -+ int **color** - color of text. Can be specified as either 0 for 'off' or black, and 1 or 255 for 'on' or white. -+ bool **wrapping** - true applies word wrapping at the screen limit, false for no wrapping. If a long string without spaces is supplied as the text, just letter wrapping will apply instead. - -Optional bool as last argument specifies whether screen updates immediately with result. Default is true. - -Before all of this text can happen, you need to load a font buffer for use. A good font to start with is NodeJS package [oled-font-5x7](https://www.npmjs.org/package/oled-font-5x7). - -Usage: -``` -npm install oled-font-5x7 -``` - -```javascript -var font = require('oled-font-5x7'); - -// sets cursor to x = 1, y = 1 -oled.setCursor(1, 1); -oled.writeString(font, 1, 'Cats and dogs are really cool animals, you know.', 1, true); -``` - -### update -Sends the entire buffer in its current state to the oled display, effectively syncing the two. This method generally does not need to be called, unless you're messing around with the framebuffer manually before you're ready to sync with the display. It's also needed if you're choosing not to draw on the screen immediately with the built in methods. - -Usage: -```javascript -oled.update(); -``` diff --git a/oled-i2c-rgpio/examples/README.md b/oled-i2c-rgpio/examples/README.md deleted file mode 100644 index 8cd2943..0000000 --- a/oled-i2c-rgpio/examples/README.md +++ /dev/null @@ -1,15 +0,0 @@ - -OLED JS Pi over i2c-bus -======================== - -## What is this directory? - -This directory contains a working example of NodeJS, a (typically) ARM board (Orange Pi Zero), and a 128x64 I2C SSD1306 display. - -## Install - -``` -npm install -cp ../oled.js node_modules/oled-i2c-bus/ -node clock.js -``` diff --git a/oled-i2c-rgpio/examples/package.json b/oled-i2c-rgpio/examples/package.json deleted file mode 100644 index e97e957..0000000 --- a/oled-i2c-rgpio/examples/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "examples", - "version": "1.0.0", - "description": "Testing OLED SSD1306 display with nodeJS", - "main": "clock.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "https://github.com/haraldkubota/oled-i2c-bus" - }, - "keywords": [ - "oled", - "i2c" - ], - "author": "Harald Kubota", - "license": "MIT", - "dependencies": { - "i2c-bus": "^1.1.2", - "oled-font-5x7": "^1.0.0", - "oled-i2c-bus": "^1.0.11", - "pngjs": "^3.3.3" - } -} diff --git a/oled-i2c-rgpio/examples/rgba.js b/oled-i2c-rgpio/examples/rgba.js deleted file mode 100644 index 76adb44..0000000 --- a/oled-i2c-rgpio/examples/rgba.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * rgba.js - * Display an RGBA image at random locations on a small I2C connected display - * - * 2018-08-19 v1.0 Bryan Nielsen - */ - - -"use strict"; - -const fs = require('fs'); -const PNG = require('pngjs').PNG; -const i2c = require('i2c-bus'); -const oled = require('../oled');// 'oled-i2c-bus'); - -var i2cBus = i2c.openSync(0); - -var opts = { - width: 128, - height: 64, - address: 0x3C -}; - -var display = new oled(i2cBus, opts); - -display.clearDisplay(); -display.turnOnDisplay(); - -fs.createReadStream('./test.png') -.pipe(new PNG({ filterType: 4 })) -.on('parsed', function () { - setInterval(() => { drawImage(this) }, 1000); -}); - -function drawImage(image) { - let x = Math.floor(Math.random() * (display.WIDTH) - image.width / 2); - let y = Math.floor(Math.random() * (display.HEIGHT) - image.height / 2); - display.drawRGBAImage(image, x, y); -} diff --git a/oled-i2c-rgpio/examples/test.png b/oled-i2c-rgpio/examples/test.png deleted file mode 100644 index ebc585889573b119630040acc4cfa375fecdddc1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 648 zcmV;30(bq1P)WFU8GbZ8()Nlj2>E@cM*00HbtL_t(Y$JLfUYg17e zho9SmV2UW=4i!4YCE6}#2)59nbj(ybICK)bIb=0i%upx&0xr^$$w9Y%0*5Xog>=(G zlO^IJ!6J8Sn(SKNdOz4uNCf6VL~~ z0^fii!0(WE1GojGz+K=T@BnxSJOXZy_52L9fj3E#d}orWv+7HAjupIBSD3P?D?ux>Q+4BFQfn;Xow_ukVKHoGNBy97)Gz9}`X~5# zSnGtGolsMp(03_lXVwBp)K|dskhh&A$zG)RCa?`W2G%;A4hIJZbh}+nPEHsM1`LNo zMxzk`g+hU1vB<*00_AdMGT072qTA9@tHi-DL@WnQn>Gst#?V-0mK5*Vtc zX*zYlG)*(WVT5CDhMe0BP>rnb18i+=O&wrNV?PqE{uduf?ys3#U)1^k)#ZIyxHxW^ i%W*5u18b7^k^e8)pT(41DCM{S0000=4.0.0" - } - }, - "node_modules/pngparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pngparse/-/pngparse-2.0.1.tgz", - "integrity": "sha512-RyB1P0BBwt3CNIZ5wT53lR1dT3CUtopnMOuP8xZdHjPhI/uXNNRnkx1yQb/3MMMyyMeo6p19fiIRHcLopWIkxA==", - "dev": true - }, - "node_modules/rgpio": { - "resolved": "local_modules/rgpio", - "link": true - }, - "node_modules/temporal": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/temporal/-/temporal-0.3.8.tgz", - "integrity": "sha512-Oifg/Jy1FqoxgAHhfrwjnO9PKrqv9JYR/KgsmsMKjpPaYWdJmzWnCVhSFAxv7ygdYILj6Kd+v4YQtaxF0ZCjGA==", - "dev": true, - "dependencies": { - "es6-shim": "latest" - }, - "engines": { - "node": ">=0.8.0" - } - } - } -} diff --git a/oled-i2c-rgpio/package.json b/oled-i2c-rgpio/package.json deleted file mode 100644 index b4c47c6..0000000 --- a/oled-i2c-rgpio/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "oled-i2c-bus", - "version": "1.0.12", - "description": "NodeJS module for controlling oled devices on the Raspbery Pi (including the SSD1306 OLED screens)", - "main": "oled.js", - "devDependencies": { - "oled-font-5x7": "~1.0.0", - "png-to-lcd": "~1.0.2", - "pngjs": "^3.3.3", - "pngparse": "~2.0.1", - "temporal": "^0.3.8" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { - "rgpio": "file:local_modules/rgpio" - } -} diff --git a/oled_circle.js b/oled_circle.js deleted file mode 100644 index b100626..0000000 --- a/oled_circle.js +++ /dev/null @@ -1,23 +0,0 @@ -const main = async () => { - var oled; - - const _rg = require('rgpio'); - - const _oled = require('/home/ichij/ocogeclub/ocoge/blocks/sensors/ssd1306/oled.js'); - - - await _rg.rgpio_sbc(); - var _opts = { - width: 128, - height: 64, - address: 0x3c, - bus: 5 - }; - oled = new _oled(_rg, _opts); - oled.clearDisplay(); - oled.turnOnDisplay(); - - oled.drawCircle(63, 31, 8, 1) - -} -main(); \ No newline at end of file