mirror of
https://github.com/ocogeclub/ocoge.git
synced 2024-11-21 15:19:48 +00:00
[update] 軽微な修正
This commit is contained in:
parent
0571402c5e
commit
9384d8cd96
@ -5,9 +5,9 @@ const pig = require('@ocogeclub/pigpio');
|
||||
|
||||
let pi = -1;
|
||||
let i2c_hand = -1;
|
||||
exports.init = async (i2c_bus, i2c_addr, win = null) => {
|
||||
if (win !== null) {
|
||||
win.addEventListener('beforeunload', async () => {
|
||||
exports.init = async (i2c_bus, i2c_addr, wael = null) => {
|
||||
if (wael !== null) {
|
||||
wael('beforeunload', async () => {
|
||||
await exports.stop();
|
||||
});
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ Blockly.JavaScript['ugj_grideye_init'] = function (block) {
|
||||
Blockly.JavaScript.provideFunction_(
|
||||
'require_amg8833', [`const _amg8833 = require('${modpath}');`]
|
||||
);
|
||||
var code = `await _amg8833.init(${elutil.i2c_bus}, ${dropdown_addr}, window);\n`;
|
||||
var code = `await _amg8833.init(${elutil.i2c_bus}, ${dropdown_addr}, window.addEventListener);\n`;
|
||||
return code;//
|
||||
};
|
||||
/********************** */
|
||||
|
@ -16,7 +16,7 @@ Blockly.Blocks['ugj_dht11'] = {
|
||||
Blockly.JavaScript['ugj_dht11'] = function (block) {
|
||||
var value_pin = Blockly.JavaScript.valueToCode(block, 'pin', Blockly.JavaScript.ORDER_ATOMIC);
|
||||
let pypath = elutil.path.join(elutil.blocks_sensors_dir, 'dht11', 'dht11.py');
|
||||
var code = `let _th = require('child_process').spawnSync('python3', ['${pypath}', '${value_pin}']).stdout.toString();
|
||||
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);
|
||||
|
@ -316,9 +316,9 @@ let pig = -1;
|
||||
let pi = -1;
|
||||
let i2c_hand = -1;
|
||||
//Initialize the sensors
|
||||
exports.init = async (i2c_bus, i2c_addr, win = null) => {
|
||||
if (win !== null) {
|
||||
win.addEventListener('beforeunload', async () => {
|
||||
exports.init = async (i2c_bus, i2c_addr, wael = null) => {
|
||||
if (wael !== null) {
|
||||
wael('beforeunload', async () => {
|
||||
await exports.stop();
|
||||
});
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ Blockly.JavaScript['ugj_gesture_init'] = function (block) {
|
||||
Blockly.JavaScript.provideFunction_(
|
||||
'require_paj7620', [`const _paj7620 = require('${modpath}');`]
|
||||
);
|
||||
var code = `await _paj7620.init(${elutil.i2c_bus}, ${value_i2c_addr}, window);
|
||||
var code = `await _paj7620.init(${elutil.i2c_bus}, ${value_i2c_addr}, window.addEventListener);
|
||||
`;
|
||||
return code;
|
||||
};
|
||||
|
@ -2165,7 +2165,7 @@ Blockly.Blocks['ugj_spawnsync'] = {
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip("外部プログラムを実行して子プロセスを生成し、子プロセスが終了するまで待ちます。");
|
||||
this.setTooltip("外部プログラムを実行して子プロセスを生成し、子プロセスが終了するまで待ちます。タイムアウトは10秒です。");
|
||||
this.setHelpUrl("");
|
||||
this.setStyle('special_blocks')
|
||||
}
|
||||
@ -2173,9 +2173,7 @@ Blockly.Blocks['ugj_spawnsync'] = {
|
||||
Blockly.JavaScript['ugj_spawnsync'] = function (block) {
|
||||
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 variable_data = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('data'), Blockly.Variables.NAME_TYPE);
|
||||
var code = `${value_data} = require('child_process').spawnSync(${value_childprocess}).stdout.toString();\n`;
|
||||
// var code = `${variable_data} = require('child_process').execFileSync(${value_childprocess});\n`;
|
||||
var code = `${value_data} = require('child_process').spawnSync(${value_childprocess}, {timeout: 10000}).stdout.toString();\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
@ -2214,7 +2212,7 @@ Blockly.JavaScript['ugj_spawn'] = function (block) {
|
||||
`${value_data} = _data.toString();`,
|
||||
statements_do,
|
||||
"})",
|
||||
`window.addEventListener( 'beforeunload', function() { _child.kill() }, false );`,
|
||||
`window.addEventListener( 'beforeunload', () => _child.kill(), false );`,
|
||||
''
|
||||
].join("\n");
|
||||
return code;
|
||||
|
Loading…
Reference in New Issue
Block a user