mirror of
https://github.com/ocogeclub/ocoge.git
synced 2024-11-21 15:19:48 +00:00
[update] new rp2 blocks
This commit is contained in:
parent
f47fc30e93
commit
a97a207d55
@ -10,7 +10,7 @@ const ugj_const = {
|
|||||||
library_dirname: 'lib',
|
library_dirname: 'lib',
|
||||||
document_root: 'Documents',
|
document_root: 'Documents',
|
||||||
tmp_dir: '.ocogeclub/tmp', //ホームディレクトリからのパス
|
tmp_dir: '.ocogeclub/tmp', //ホームディレクトリからのパス
|
||||||
executable_path: '.ocogeclub/apps/', //ホームディレクトリからのパス
|
executable_path: 'ocogeclub/bin/', //ホームディレクトリからのパス
|
||||||
localStorage_fname: 'ocoge.json',
|
localStorage_fname: 'ocoge.json',
|
||||||
error_ja_all: 'エラーが発生しました。\n『おこげ倶楽部』までお問い合わせください。',
|
error_ja_all: 'エラーが発生しました。\n『おこげ倶楽部』までお問い合わせください。',
|
||||||
pig: 'pigpio',
|
pig: 'pigpio',
|
||||||
@ -315,7 +315,7 @@ class appTool {
|
|||||||
class webTool {
|
class webTool {
|
||||||
constructor() {
|
constructor() {
|
||||||
// GPIOブロックは使えません
|
// GPIOブロックは使えません
|
||||||
this.gpio_lib = ugj_const.pig;
|
this.gpio_lib = ugj_const.rg;
|
||||||
this.lang = 'js';
|
this.lang = 'js';
|
||||||
this.blocks_dir = ugj_const.blocks_dir;
|
this.blocks_dir = ugj_const.blocks_dir;
|
||||||
}
|
}
|
||||||
|
984
blocks/blocks.js
984
blocks/blocks.js
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,7 @@ registerCategory('sensors', [ // カテゴリディレクトリ名
|
|||||||
"amg8833",
|
"amg8833",
|
||||||
"paj7620",
|
"paj7620",
|
||||||
"bme280",
|
"bme280",
|
||||||
"dht11",
|
// "dht11",
|
||||||
"pico_slave",
|
// "pico_slave",
|
||||||
"z-line" // フライアウト下端の不可視ライン。スクリプトにカテゴリ名を含むので注意
|
"z-line" // フライアウト下端の不可視ライン。スクリプトにカテゴリ名を含むので注意
|
||||||
]);
|
]);
|
||||||
|
@ -12,10 +12,10 @@ exports.init = async (i2c_bus, i2c_addr, wael = null) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (pi >= 0) { throw new Error(err_msg); return; }
|
if (pi >= 0) { throw new Error(err_msg); return; }
|
||||||
pi = await pig._gpiod_start('', '');
|
pi = await pig._rgpiod_start('', '');
|
||||||
console.log('pi=' + pi);
|
console.log('pi=' + pi);
|
||||||
if (i2c_hand >= 0) { throw new Error(err_msg); return; }
|
if (i2c_hand >= 0) { throw new Error(err_msg); return; }
|
||||||
i2c_hand = await pig._i2c_open(pi, i2c_bus, i2c_addr);
|
i2c_hand = await pig._i2c_open(pi, i2c_bus, i2c_addr, 0);
|
||||||
console.log('i2c_hand=' + i2c_hand);
|
console.log('i2c_hand=' + i2c_hand);
|
||||||
await pig._i2c_write_byte_data(pi, i2c_hand, 0x00, 0x00); //Normal mode
|
await pig._i2c_write_byte_data(pi, i2c_hand, 0x00, 0x00); //Normal mode
|
||||||
await pig._i2c_write_byte_data(pi, i2c_hand, 0x02, 0x00); //10FPS
|
await pig._i2c_write_byte_data(pi, i2c_hand, 0x02, 0x00); //10FPS
|
||||||
@ -45,7 +45,7 @@ exports.stop = async () => {
|
|||||||
i2c_hand = -1;
|
i2c_hand = -1;
|
||||||
}
|
}
|
||||||
if (pi >= 0) {
|
if (pi >= 0) {
|
||||||
await pig._gpiod_stop(pi);
|
await pig._rgpiod_stop(pi);
|
||||||
pi = -1;
|
pi = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,11 +43,11 @@ this.REGISTER_HUMIDITY_DATA = 0xFD;
|
|||||||
|
|
||||||
exports.init = async (options) => {
|
exports.init = async (options) => {
|
||||||
this.pig = require(`${apptool.gpio_lib}`);
|
this.pig = require(`${apptool.gpio_lib}`);
|
||||||
this.pi = await this.pig._gpiod_start('', '');
|
this.pi = await this.pig._rgpiod_start('', '');
|
||||||
|
|
||||||
this.i2cBusNo = (options && options.hasOwnProperty('i2cBusNo')) ? options.i2cBusNo : 1;
|
this.i2cBusNo = (options && options.hasOwnProperty('i2cBusNo')) ? options.i2cBusNo : 1;
|
||||||
this.i2cAddress = (options && options.hasOwnProperty('i2cAddress')) ? options.i2cAddress : this.BME280_DEFAULT_I2C_ADDRESS();
|
this.i2cAddress = (options && options.hasOwnProperty('i2cAddress')) ? options.i2cAddress : this.BME280_DEFAULT_I2C_ADDRESS();
|
||||||
this.i2cHand = await this.pig._i2c_open(this.pi, this.i2cBusNo, this.i2cAddress);
|
this.i2cHand = await this.pig._i2c_open(this.pi, this.i2cBusNo, this.i2cAddress, 0);
|
||||||
|
|
||||||
let r;
|
let r;
|
||||||
r = await this.pig._i2c_write_byte_data(this.pi, this.i2cHand, this.REGISTER_CHIPID, 0);
|
r = await this.pig._i2c_write_byte_data(this.pi, this.i2cHand, this.REGISTER_CHIPID, 0);
|
||||||
@ -96,7 +96,7 @@ exports.cancel = async () => {
|
|||||||
if (this.i2cHand >= 0) {
|
if (this.i2cHand >= 0) {
|
||||||
await this.pig._i2c_close(this.pi, this.i2cHand);
|
await this.pig._i2c_close(this.pi, this.i2cHand);
|
||||||
this.i2cHand = null;
|
this.i2cHand = null;
|
||||||
await this.pig._gpiod_stop(this.pi);
|
await this.pig._rgpiod_stop(this.pi);
|
||||||
this.pi = null;
|
this.pi = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,8 +312,8 @@ const initRegisterArray = [
|
|||||||
const debug = 1;
|
const debug = 1;
|
||||||
|
|
||||||
const err_msg = 'PAJ7620 is already opened. Please close old connection to use new one.';
|
const err_msg = 'PAJ7620 is already opened. Please close old connection to use new one.';
|
||||||
let pig = -1;
|
let rg = -1;
|
||||||
let pi = -1;
|
let sbc = -1;
|
||||||
let i2c_hand = -1;
|
let i2c_hand = -1;
|
||||||
//Initialize the sensors
|
//Initialize the sensors
|
||||||
exports.init = async (i2c_bus, i2c_addr, wael = null) => {
|
exports.init = async (i2c_bus, i2c_addr, wael = null) => {
|
||||||
@ -322,13 +322,13 @@ exports.init = async (i2c_bus, i2c_addr, wael = null) => {
|
|||||||
await exports.stop();
|
await exports.stop();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
pig = require(`${apptool.gpio_lib}`);
|
rg = require(`rgpio`);//${apptool.gpio_lib}
|
||||||
if (pi >= 0) { throw new Error(err_msg); return; }
|
if (sbc >= 0) { throw new Error(err_msg); return; }
|
||||||
pi = await pig._gpiod_start('', '');
|
sbc = await rg._rgpiod_start('', '');
|
||||||
if (i2c_hand >= 0) { throw new Error(err_msg); return; }
|
if (i2c_hand >= 0) { throw new Error(err_msg); return; }
|
||||||
i2c_hand = await pig._i2c_open(pi, i2c_bus, i2c_addr);
|
i2c_hand = await rg._i2c_open(sbc, i2c_bus, i2c_addr, 0);
|
||||||
if (debug)
|
if (debug)
|
||||||
console.log("pi=" + pi + ", i2c_hand=" + i2c_hand);
|
console.log("sbc=" + sbc + ", i2c_hand=" + i2c_hand);
|
||||||
|
|
||||||
await sleep(.001);
|
await sleep(.001);
|
||||||
await paj7620SelectBank(BANK0);
|
await paj7620SelectBank(BANK0);
|
||||||
@ -355,7 +355,7 @@ exports.init = async (i2c_bus, i2c_addr, wael = null) => {
|
|||||||
|
|
||||||
// Write a byte to a register on the Gesture sensor
|
// Write a byte to a register on the Gesture sensor
|
||||||
const paj7620WriteReg = async (addr, cmd) =>
|
const paj7620WriteReg = async (addr, cmd) =>
|
||||||
await pig._i2c_write_word_data(pi, i2c_hand, addr, cmd);
|
await rg._i2c_write_word_data(sbc, i2c_hand, addr, cmd);
|
||||||
|
|
||||||
//Select a register bank on the Gesture Sensor
|
//Select a register bank on the Gesture Sensor
|
||||||
const paj7620SelectBank = async bank => {
|
const paj7620SelectBank = async bank => {
|
||||||
@ -365,7 +365,7 @@ const paj7620SelectBank = async bank => {
|
|||||||
|
|
||||||
//Read a block of bytes of length "qty" starting at address "addr" from the Gesture sensor
|
//Read a block of bytes of length "qty" starting at address "addr" from the Gesture sensor
|
||||||
const paj7620ReadReg = async (addr, qty) => {
|
const paj7620ReadReg = async (addr, qty) => {
|
||||||
return await pig._i2c_read_i2c_block_data(pi, i2c_hand, addr, qty);
|
return await rg._i2c_read_i2c_block_data(sbc, i2c_hand, addr, qty);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return a vlaue from the gestire sensor which can be used in a program
|
//Return a vlaue from the gestire sensor which can be used in a program
|
||||||
@ -457,12 +457,12 @@ exports.return_gesture = async () => {
|
|||||||
|
|
||||||
exports.stop = async () => {
|
exports.stop = async () => {
|
||||||
if (i2c_hand >= 0) {
|
if (i2c_hand >= 0) {
|
||||||
await pig._i2c_close(pi, i2c_hand);
|
await rg._i2c_close(sbc, i2c_hand);
|
||||||
i2c_hand = -1;
|
i2c_hand = -1;
|
||||||
}
|
}
|
||||||
if (pi >= 0) {
|
if (sbc >= 0) {
|
||||||
await pig._gpiod_stop(pi);
|
await rg._rgpiod_stop(sbc);
|
||||||
pi = -1;
|
sbc = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
258
index.html
258
index.html
@ -111,7 +111,7 @@
|
|||||||
<field name="MODE">WHILE</field>
|
<field name="MODE">WHILE</field>
|
||||||
</block>
|
</block>
|
||||||
<block type="controls_for">
|
<block type="controls_for">
|
||||||
<field name="VAR" id="oFFZ#D{*XbIVL=!W~X]w">番号</field>
|
<field name="VAR" iid="oFFZ#D{*XbIVL=!W~X]w">番号</field>
|
||||||
<value name="FROM">
|
<value name="FROM">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">1</field>
|
<field name="NUM">1</field>
|
||||||
@ -129,7 +129,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="controls_forEach">
|
<block type="controls_forEach">
|
||||||
<field name="VAR" id="k4+0elF%?J]_)8fo((-m">項目</field>
|
<field name="VAR" iid="k4+0elF%?J]_)8fo((-m">項目</field>
|
||||||
</block>
|
</block>
|
||||||
<block type="controls_flow_statements">
|
<block type="controls_flow_statements">
|
||||||
<field name="FLOW">BREAK</field>
|
<field name="FLOW">BREAK</field>
|
||||||
@ -214,8 +214,15 @@
|
|||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
|
<block type="oc_text_to_number">
|
||||||
|
<value name="text">
|
||||||
|
<shadow type="text">
|
||||||
|
<field name="TEXT">0</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
</block>
|
||||||
</category>
|
</category>
|
||||||
<category name="文字列" css-icon="customIcon fas fa-font" categorystyle="text_category">
|
<category name="テキスト" css-icon="customIcon fas fa-font" categorystyle="text_category">
|
||||||
<block type="text">
|
<block type="text">
|
||||||
<field name="TEXT"></field>
|
<field name="TEXT"></field>
|
||||||
</block>
|
</block>
|
||||||
@ -287,7 +294,7 @@
|
|||||||
<field name="END">FIRST</field>
|
<field name="END">FIRST</field>
|
||||||
<value name="VALUE">
|
<value name="VALUE">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="3kh{pye%.qbQf]}y64q6" variabletype="">list</field>
|
<field name="VAR" iid="3kh{pye%.qbQf]}y64q6" variabletype="">list</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
@ -297,7 +304,7 @@
|
|||||||
<field name="WHERE">FROM_START</field>
|
<field name="WHERE">FROM_START</field>
|
||||||
<value name="VALUE">
|
<value name="VALUE">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="3kh{pye%.qbQf]}y64q6" variabletype="">list</field>
|
<field name="VAR" iid="3kh{pye%.qbQf]}y64q6" variabletype="">list</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
@ -307,7 +314,7 @@
|
|||||||
<field name="WHERE">FROM_START</field>
|
<field name="WHERE">FROM_START</field>
|
||||||
<value name="LIST">
|
<value name="LIST">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="3kh{pye%.qbQf]}y64q6" variabletype="">list</field>
|
<field name="VAR" iid="3kh{pye%.qbQf]}y64q6" variabletype="">list</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
@ -334,8 +341,8 @@
|
|||||||
<label text="基本"></label>
|
<label text="基本"></label>
|
||||||
<block type="ugj_gpio_open"></block>
|
<block type="ugj_gpio_open"></block>
|
||||||
<block type="ugj_gpio_close"></block>
|
<block type="ugj_gpio_close"></block>
|
||||||
<block type="ugj_gpio_set_output">
|
<block type="oc_gpio_set_output">
|
||||||
<value name="gpio">
|
<value name="ugpio">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">5</field>
|
<field name="NUM">5</field>
|
||||||
</shadow>
|
</shadow>
|
||||||
@ -349,9 +356,9 @@
|
|||||||
</value>
|
</value>
|
||||||
<field name="level">1</field>
|
<field name="level">1</field>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_gpio_set_input">
|
<block type="oc_gpio_set_input">
|
||||||
<field name="lflag">PULL_DOWN</field>
|
<field name="lflag">SET_PULL_NONE</field>
|
||||||
<value name="gpio">
|
<value name="ugpio">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">6</field>
|
<field name="NUM">6</field>
|
||||||
</shadow>
|
</shadow>
|
||||||
@ -364,41 +371,21 @@
|
|||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<label text="パルス" web-line="4.0" web-line-width="200"></label>
|
|
||||||
<block type="ugj_pwm">
|
|
||||||
<value name="gpio">
|
|
||||||
<shadow type="math_number">
|
|
||||||
<field name="NUM">29</field>
|
|
||||||
</shadow>
|
|
||||||
</value>
|
|
||||||
<value name="pwm_frequency">
|
|
||||||
<shadow type="math_number">
|
|
||||||
<field name="NUM">50</field>
|
|
||||||
</shadow>
|
|
||||||
</value>
|
|
||||||
</block>
|
|
||||||
<block type="oc_pwm_duty">
|
|
||||||
<value name="gpio">
|
|
||||||
<shadow type="math_number">
|
|
||||||
<field name="NUM">29</field>
|
|
||||||
</shadow>
|
|
||||||
</value>
|
|
||||||
<value name="duty">
|
|
||||||
<shadow type="math_number">
|
|
||||||
<field name="NUM">0</field>
|
|
||||||
</shadow>
|
|
||||||
</value>
|
|
||||||
</block>
|
|
||||||
<label text="I2C" web-line="4.0" web-line-width="200"></label>
|
<label text="I2C" web-line="4.0" web-line-width="200"></label>
|
||||||
<block type="ugj_i2c_open">
|
<block type="oc_i2c_open">
|
||||||
<value name="i2c_address">
|
<field name="i2c_hand">I2Cデバイス</field>
|
||||||
|
<value name="addr">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">0</field>
|
<field name="NUM">0</field>
|
||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_i2c_close"></block>
|
<block type="oc_i2c_close">
|
||||||
|
<field name="i2c_hand">I2Cデバイス</field>
|
||||||
|
</block>
|
||||||
|
<!-- <block type="ugj_i2c_close"></block> -->
|
||||||
<block type="oc_i2c_write_byte">
|
<block type="oc_i2c_write_byte">
|
||||||
|
<field name="i2c_hand">I2Cデバイス</field>
|
||||||
<value name="byte_val">
|
<value name="byte_val">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">0</field>
|
<field name="NUM">0</field>
|
||||||
@ -418,6 +405,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_i2c_read_byte_data">
|
<block type="ugj_i2c_read_byte_data">
|
||||||
|
<field name="i2c_hand">I2Cデバイス</field>
|
||||||
<value name="reg">
|
<value name="reg">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">0</field>
|
<field name="NUM">0</field>
|
||||||
@ -425,6 +413,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_i2c_read_word_data">
|
<block type="ugj_i2c_read_word_data">
|
||||||
|
<field name="i2c_hand">I2Cデバイス</field>
|
||||||
<value name="reg">
|
<value name="reg">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">0</field>
|
<field name="NUM">0</field>
|
||||||
@ -432,6 +421,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_i2c_write_i2c_block_data">
|
<block type="ugj_i2c_write_i2c_block_data">
|
||||||
|
<field name="i2c_hand">I2Cデバイス</field>
|
||||||
<value name="reg">
|
<value name="reg">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">0</field>
|
<field name="NUM">0</field>
|
||||||
@ -444,6 +434,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_i2c_read_device">
|
<block type="ugj_i2c_read_device">
|
||||||
|
<field name="i2c_hand">I2Cデバイス</field>
|
||||||
<value name="count">
|
<value name="count">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">1</field>
|
<field name="NUM">1</field>
|
||||||
@ -451,6 +442,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_i2c_write_device">
|
<block type="ugj_i2c_write_device">
|
||||||
|
<field name="i2c_hand">I2Cデバイス</field>
|
||||||
<value name="data">
|
<value name="data">
|
||||||
<shadow type="text_join">
|
<shadow type="text_join">
|
||||||
<mutation items="2"></mutation>
|
<mutation items="2"></mutation>
|
||||||
@ -466,7 +458,35 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<label text="シリアル" web-line="4.0" web-line-width="200"></label>
|
<label text="シリアル" web-line="4.0" web-line-width="200"></label>
|
||||||
<block type="ugj_serial_open">
|
<block type="oc_serial_open">
|
||||||
|
<field name="ser_hand">シリアルデバイス</field>
|
||||||
|
<field name="baud">9600</field>
|
||||||
|
<value name="port">
|
||||||
|
<shadow type="text">
|
||||||
|
<field name="TEXT">/dev/ttyACM0</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
</block>
|
||||||
|
<block type="oc_serial_close">
|
||||||
|
<field name="ser_hand">シリアルデバイス</field>
|
||||||
|
</block>
|
||||||
|
<block type="oc_serial_read">
|
||||||
|
<field name="ser_hand">シリアルデバイス</field>
|
||||||
|
<value name="count">
|
||||||
|
<shadow type="math_number">
|
||||||
|
<field name="NUM">0</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
</block>
|
||||||
|
<block type="oc_serial_write">
|
||||||
|
<field name="ser_hand">シリアルデバイス</field>
|
||||||
|
<value name="data">
|
||||||
|
<shadow type="text">
|
||||||
|
<field name="TEXT">hello</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
</block>
|
||||||
|
<!-- <block type="ugj_serial_open">
|
||||||
<field name="baud">9600</field>
|
<field name="baud">9600</field>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_serial_close"></block>
|
<block type="ugj_serial_close"></block>
|
||||||
@ -491,7 +511,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block> -->
|
||||||
<label text="Extra" web-line="4.0" web-line-width="200"></label>
|
<label text="Extra" web-line="4.0" web-line-width="200"></label>
|
||||||
<label text="_" web-line="4.0" web-line-width="200"></label>
|
<label text="_" web-line="4.0" web-line-width="200"></label>
|
||||||
</category>
|
</category>
|
||||||
@ -613,7 +633,7 @@
|
|||||||
<field name="updown">keydown</field>
|
<field name="updown">keydown</field>
|
||||||
<value name="key">
|
<value name="key">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="Tf-2_OhUEAcOe;U}wu%I">キー</field>
|
<field name="VAR" iid="Tf-2_OhUEAcOe;U}wu%I">キー</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
@ -623,7 +643,7 @@
|
|||||||
<block type="ugj_face_detect">
|
<block type="ugj_face_detect">
|
||||||
<value name="preditions">
|
<value name="preditions">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="TLZRpW`yXuYE3Z31)B=2">検出結果</field>
|
<field name="VAR" iid="TLZRpW`yXuYE3Z31)B=2">検出結果</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
@ -636,7 +656,7 @@
|
|||||||
<field name="WHERE">FROM_START</field>
|
<field name="WHERE">FROM_START</field>
|
||||||
<value name="VALUE">
|
<value name="VALUE">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="_W]y2e!_~suF]yM;LQ1~">検出結果</field>
|
<field name="VAR" iid="_W]y2e!_~suF]yM;LQ1~">検出結果</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
<value name="AT">
|
<value name="AT">
|
||||||
@ -656,7 +676,7 @@
|
|||||||
<field name="WHERE">FROM_START</field>
|
<field name="WHERE">FROM_START</field>
|
||||||
<value name="VALUE">
|
<value name="VALUE">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="E-Bsl~,RZG]E)v`k![_p">検出結果</field>
|
<field name="VAR" iid="E-Bsl~,RZG]E)v`k![_p">検出結果</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
<value name="AT">
|
<value name="AT">
|
||||||
@ -676,7 +696,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</block> -->
|
</block> -->
|
||||||
<block type="oc_speechcommands_init">
|
<block type="oc_speechcommands_init">
|
||||||
<field name="classlabels" id="aV;:;wdjQ;:3+(Bx8Z!$">ラベル</field>
|
<field name="classlabels" iid="aV;:;wdjQ;:3+(Bx8Z!$">ラベル</field>
|
||||||
<value name="custom_model">
|
<value name="custom_model">
|
||||||
<shadow type="text">
|
<shadow type="text">
|
||||||
<field name="TEXT"></field>
|
<field name="TEXT"></field>
|
||||||
@ -684,11 +704,11 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<!-- <block type="oc_speechcommand_listen">
|
<!-- <block type="oc_speechcommand_listen">
|
||||||
<field name="classlabels" id="-aysulrCq~BT0?GQL|V:">ラベル</field>
|
<field name="classlabels" iid="-aysulrCq~BT0?GQL|V:">ラベル</field>
|
||||||
<field name="scores" id="#?-HvxDFqQ#vb+swl_k:">スコア</field>
|
<field name="scores" iid="#?-HvxDFqQ#vb+swl_k:">スコア</field>
|
||||||
</block> -->
|
</block> -->
|
||||||
<block type="oc_speechcommand_listen">
|
<block type="oc_speechcommand_listen">
|
||||||
<field name="scores" id="|!AWY]V:il;fu;lRwDC*">スコア</field>
|
<field name="scores" iid="|!AWY]V:il;fu;lRwDC*">スコア</field>
|
||||||
</block>
|
</block>
|
||||||
<label text="_" web-line="4.0" web-line-width="200"></label>
|
<label text="_" web-line="4.0" web-line-width="200"></label>
|
||||||
</category>
|
</category>
|
||||||
@ -723,7 +743,7 @@
|
|||||||
<block type="ugj_network_httpserver">
|
<block type="ugj_network_httpserver">
|
||||||
<value name="url">
|
<value name="url">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="b`}7sB~6O9+IKJ!vJzA`">URL</field>
|
<field name="VAR" iid="b`}7sB~6O9+IKJ!vJzA`">URL</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
<value name="response">
|
<value name="response">
|
||||||
@ -743,7 +763,7 @@
|
|||||||
<block type="ugj_skyway_newpeer">
|
<block type="ugj_skyway_newpeer">
|
||||||
<value name="my_id">
|
<value name="my_id">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="P$},PvZ}j#)8lw++|u7h">自分のID</field>
|
<field name="VAR" iid="P$},PvZ}j#)8lw++|u7h">自分のID</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
<value name="apikey">
|
<value name="apikey">
|
||||||
@ -756,7 +776,7 @@
|
|||||||
<block type="ugj_skyway_events">
|
<block type="ugj_skyway_events">
|
||||||
<value name="remote_id">
|
<value name="remote_id">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="lN*;t*HFF;@[)a_m3#F8">相手のID</field>
|
<field name="VAR" iid="lN*;t*HFF;@[)a_m3#F8">相手のID</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
@ -764,14 +784,14 @@
|
|||||||
<block type="ugj_skyway_eventdata">
|
<block type="ugj_skyway_eventdata">
|
||||||
<value name="data">
|
<value name="data">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="l[-u+nGf?P~Zu?k(bgP)">発言</field>
|
<field name="VAR" iid="l[-u+nGf?P~Zu?k(bgP)">発言</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_skyway_eventsend">
|
<block type="ugj_skyway_eventsend">
|
||||||
<value name="data">
|
<value name="data">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="NbC3[s+Uilk#moos+bn8">内容</field>
|
<field name="VAR" iid="NbC3[s+Uilk#moos+bn8">内容</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
@ -804,7 +824,7 @@
|
|||||||
</value>
|
</value>
|
||||||
<value name="answer">
|
<value name="answer">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id=":w)sl|yxx4k^W-~-VM#,">答え</field>
|
<field name="VAR" iid=":w)sl|yxx4k^W-~-VM#,">答え</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
@ -877,14 +897,14 @@
|
|||||||
<block type="ugj_spawnsync">
|
<block type="ugj_spawnsync">
|
||||||
<value name="data">
|
<value name="data">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id="9z28J37fMu2VaWhbd4*=">実行結果</field>
|
<field name="VAR" iid="9z28J37fMu2VaWhbd4*=">実行結果</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_spawn">
|
<block type="ugj_spawn">
|
||||||
<value name="data">
|
<value name="data">
|
||||||
<block type="variables_get">
|
<block type="variables_get">
|
||||||
<field name="VAR" id=";i*e;NG!%_g}7}wTeaQc">データストリーム</field>
|
<field name="VAR" iid=";i*e;NG!%_g}7}wTeaQc">データストリーム</field>
|
||||||
</block>
|
</block>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
@ -941,7 +961,7 @@
|
|||||||
<block type="ugj_text_cursor"></block>
|
<block type="ugj_text_cursor"></block>
|
||||||
<label text="特殊" web-line="4.0" web-line-width="200"></label>
|
<label text="特殊" web-line="4.0" web-line-width="200"></label>
|
||||||
<block type="ugj_socket">
|
<block type="ugj_socket">
|
||||||
<field name="data" id="Y^@?sd}wN]H+nmK=[{wL" variabletype="">受信データ</field>
|
<field name="data" iid="Y^@?sd}wN]H+nmK=[{wL" variabletype="">受信データ</field>
|
||||||
<value name="host">
|
<value name="host">
|
||||||
<shadow type="text">
|
<shadow type="text">
|
||||||
<field name="TEXT">localhost</field>
|
<field name="TEXT">localhost</field>
|
||||||
@ -971,72 +991,66 @@
|
|||||||
<!-- <block type="ugj_dev_run_js"></block> -->
|
<!-- <block type="ugj_dev_run_js"></block> -->
|
||||||
<label text="_" web-line="4.0" web-line-width="200"></label>
|
<label text="_" web-line="4.0" web-line-width="200"></label>
|
||||||
</category>
|
</category>
|
||||||
<category name="スニペット" css-icon="customIcon fas fa-egg" categorystyle="snippets_category">
|
<category name="RP2 専用" css-icon="customIcon fab fa-python" categorystyle="rp2_category">
|
||||||
<label text="停止ボタンつきループ" web-line="4.0" web-line-width="200"></label>
|
<label text="テキスト" web-line="4.0" web-line-width="200"></label>
|
||||||
<variables>
|
<block type="oc_rp2_print">
|
||||||
<variable id="O-NNhS!sS_oTSB?7JB]$">停止フラグ</variable>
|
<value name="text">
|
||||||
</variables>
|
<shadow type="text">
|
||||||
<block type="variables_set" id="W+CX}t(}EgABVVPGhJ{." x="-250" y="230">
|
<field name="TEXT"></field>
|
||||||
<field name="VAR" id="O-NNhS!sS_oTSB?7JB]$">停止フラグ</field>
|
</shadow>
|
||||||
<value name="VALUE">
|
|
||||||
<block type="logic_boolean" id="3S{lEWhjtB=1Z6E$#vt?">
|
|
||||||
<field name="BOOL">FALSE</field>
|
|
||||||
</block>
|
|
||||||
</value>
|
</value>
|
||||||
<next>
|
|
||||||
<block type="ugj_control_button" id="#%IHyk19t$l}4$3`z{=x">
|
|
||||||
<value name="label">
|
|
||||||
<shadow type="text" id="Gy,;jCb(+@1)7W$*pc9;">
|
|
||||||
<field name="TEXT">停止</field>
|
|
||||||
</shadow>
|
|
||||||
</value>
|
|
||||||
<value name="textcolor">
|
|
||||||
<shadow type="colour_picker" id="z$a35:]5)iocrfp6^OsL">
|
|
||||||
<field name="COLOUR">#ffffff</field>
|
|
||||||
</shadow>
|
|
||||||
</value>
|
|
||||||
<value name="bgcolor">
|
|
||||||
<shadow type="colour_picker" id="X)Y}Vo.SaQC2+!_$N:2:">
|
|
||||||
<field name="COLOUR">#ff00ff</field>
|
|
||||||
</shadow>
|
|
||||||
</value>
|
|
||||||
<value name="title">
|
|
||||||
<shadow type="text" id="]WtKw+8DZm~NnY=j{+8p">
|
|
||||||
<field name="TEXT">ループを停止します</field>
|
|
||||||
</shadow>
|
|
||||||
</value>
|
|
||||||
<statement name="do">
|
|
||||||
<block type="variables_set" id="NFM7Mp]ym8)My,+bRgW|">
|
|
||||||
<field name="VAR" id="O-NNhS!sS_oTSB?7JB]$">停止フラグ</field>
|
|
||||||
<value name="VALUE">
|
|
||||||
<block type="logic_boolean" id="XE(jO2;SK_c$PtiNgeY[">
|
|
||||||
<field name="BOOL">TRUE</field>
|
|
||||||
</block>
|
|
||||||
</value>
|
|
||||||
</block>
|
|
||||||
</statement>
|
|
||||||
<next>
|
|
||||||
<block type="controls_whileUntil" id="LMyDUJ02*$bUjwr0c.B]">
|
|
||||||
<field name="MODE">UNTIL</field>
|
|
||||||
<value name="BOOL">
|
|
||||||
<block type="variables_get" id="2Ta/:QEx=nW|A7KOS3{g">
|
|
||||||
<field name="VAR" id="O-NNhS!sS_oTSB?7JB]$">停止フラグ</field>
|
|
||||||
</block>
|
|
||||||
</value>
|
|
||||||
<statement name="DO">
|
|
||||||
<block type="ugj_sleep" id="_C=mtOy|HJCo9#m;DS]e">
|
|
||||||
<value name="sec">
|
|
||||||
<shadow type="math_number" id="wG#wMyoc]}%!`N~(GH^=">
|
|
||||||
<field name="NUM">0</field>
|
|
||||||
</shadow>
|
|
||||||
</value>
|
|
||||||
</block>
|
|
||||||
</statement>
|
|
||||||
</block>
|
|
||||||
</next>
|
|
||||||
</block>
|
|
||||||
</next>
|
|
||||||
</block>
|
</block>
|
||||||
|
<block type="oc_rp2_input"></block>
|
||||||
|
<label text="JSON" web-line="4.0" web-line-width="200"></label>
|
||||||
|
<block type="oc_rp2_ujson_dumps"></block>
|
||||||
|
<block type="oc_rp2_ujson_loads"></block>
|
||||||
|
<label text="パルス" web-line="4.0" web-line-width="200"></label>
|
||||||
|
<block type="ugj_pwm">
|
||||||
|
<value name="gpio">
|
||||||
|
<shadow type="math_number">
|
||||||
|
<field name="NUM">29</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
<value name="pwm_frequency">
|
||||||
|
<shadow type="math_number">
|
||||||
|
<field name="NUM">50</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
</block>
|
||||||
|
<block type="oc_pwm_duty">
|
||||||
|
<value name="gpio">
|
||||||
|
<shadow type="math_number">
|
||||||
|
<field name="NUM">29</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
<value name="duty">
|
||||||
|
<shadow type="math_number">
|
||||||
|
<field name="NUM">0</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
</block>
|
||||||
|
<block type="oc_rp2_ir_rx">
|
||||||
|
<value name="gpio">
|
||||||
|
<shadow type="math_number">
|
||||||
|
<field name="NUM">26</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
</block>
|
||||||
|
<block type="oc_rp2_ir_record">
|
||||||
|
<value name="timeout">
|
||||||
|
<shadow type="math_number">
|
||||||
|
<field name="NUM">3</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
</block>
|
||||||
|
<block type="oc_rp2_ir_tx">
|
||||||
|
<value name="gpio">
|
||||||
|
<shadow type="math_number">
|
||||||
|
<field name="NUM">27</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
</block>
|
||||||
|
<block type="oc_rp2_ir_transmit"></block>
|
||||||
</category>
|
</category>
|
||||||
</xml>
|
</xml>
|
||||||
|
|
||||||
|
37
index.js
37
index.js
@ -15,7 +15,7 @@ var sonsor_color = '20';
|
|||||||
var multimedia_color = '240';
|
var multimedia_color = '240';
|
||||||
var network_color = '340';
|
var network_color = '340';
|
||||||
var special_color = '40';
|
var special_color = '40';
|
||||||
var snippets_color = '180';
|
var rp2_color = '180';
|
||||||
// テーマ
|
// テーマ
|
||||||
var theme = Blockly.Theme.defineTheme('ocoge', {
|
var theme = Blockly.Theme.defineTheme('ocoge', {
|
||||||
'base': Blockly.Themes.Classic,
|
'base': Blockly.Themes.Classic,
|
||||||
@ -45,8 +45,8 @@ var theme = Blockly.Theme.defineTheme('ocoge', {
|
|||||||
'special_blocks': {
|
'special_blocks': {
|
||||||
"colourPrimary": special_color
|
"colourPrimary": special_color
|
||||||
},
|
},
|
||||||
'snippets_blocks': {
|
'rp2_blocks': {
|
||||||
"colourPrimary": snippets_color
|
"colourPrimary": rp2_color
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'categoryStyles': {
|
'categoryStyles': {
|
||||||
@ -65,8 +65,8 @@ var theme = Blockly.Theme.defineTheme('ocoge', {
|
|||||||
"special_category": {
|
"special_category": {
|
||||||
"colour": special_color
|
"colour": special_color
|
||||||
},
|
},
|
||||||
"snippets_category": {
|
"rp2_category": {
|
||||||
"colour": snippets_color
|
"colour": rp2_color
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -96,10 +96,9 @@ Blockly.Msg["UGJ_FOREACH_ITEM"] = "項目";
|
|||||||
Blockly.Msg["UGJ_FOREACH_TOOLTIP"] = "リストの各項目について、その項目を変数「項目」としてステートメントを実行します。";
|
Blockly.Msg["UGJ_FOREACH_TOOLTIP"] = "リストの各項目について、その項目を変数「項目」としてステートメントを実行します。";
|
||||||
|
|
||||||
Blockly.Msg["GPIO_OPEN_TITLE"] = "GPIO を使えるようにする";
|
Blockly.Msg["GPIO_OPEN_TITLE"] = "GPIO を使えるようにする";
|
||||||
Blockly.Msg["GPIO_OPEN_TOOLTIP"] = "GPIOを初期化して接続します。";
|
Blockly.Msg["GPIO_OPEN_TOOLTIP"] = "rgpiod デーモンに接続します。";
|
||||||
Blockly.Msg["GPIO_CLOSE_TITLE"] = "GPIO の後片付けをする";
|
|
||||||
Blockly.Msg["GPIO_CLOSE_TOOLTIP"] = "GPIOとの接続を終了します。";
|
|
||||||
Blockly.Msg["GPIO_CLOSE_TITLE"] = "GPIO の後片付けをする";
|
Blockly.Msg["GPIO_CLOSE_TITLE"] = "GPIO の後片付けをする";
|
||||||
|
Blockly.Msg["GPIO_CLOSE_TOOLTIP"] = "rgpiod デーモンから切断します。";
|
||||||
Blockly.Msg["GPIO_SET_INPUT_TITLE"] = "GPIO %1 を入力モードにして %2";
|
Blockly.Msg["GPIO_SET_INPUT_TITLE"] = "GPIO %1 を入力モードにして %2";
|
||||||
Blockly.Msg["GPIO_SET_INPUT_TOOLTIP"] = "GPIO端子を入力モードにして、プルアップ・プルダウン・無しを設定します。";
|
Blockly.Msg["GPIO_SET_INPUT_TOOLTIP"] = "GPIO端子を入力モードにして、プルアップ・プルダウン・無しを設定します。";
|
||||||
Blockly.Msg["GPIO_SET_INPUT_PULLUP"] = "プルアップ";
|
Blockly.Msg["GPIO_SET_INPUT_PULLUP"] = "プルアップ";
|
||||||
@ -114,9 +113,7 @@ Blockly.Msg["GPIO_WRITE_TOOLTIP"] = "GPIO端子の値をデジタル値(0ま
|
|||||||
Blockly.Msg["SERVO_TITLE"] = "GPIO %1 のサーボモータの回転を %2 にする";
|
Blockly.Msg["SERVO_TITLE"] = "GPIO %1 のサーボモータの回転を %2 にする";
|
||||||
Blockly.Msg["SERVO_TOOLTIP"] = "サーボモータの回転をパルス幅(1000~2000μsec)までの数値で指定します。";
|
Blockly.Msg["SERVO_TOOLTIP"] = "サーボモータの回転をパルス幅(1000~2000μsec)までの数値で指定します。";
|
||||||
Blockly.Msg["PWM_TITLE"] = "GPIO %1 をパルス周波数 %2 Hzの PWM 出力に設定";
|
Blockly.Msg["PWM_TITLE"] = "GPIO %1 をパルス周波数 %2 Hzの PWM 出力に設定";
|
||||||
Blockly.Msg["PWM_TOOLTIP"] = "パルス周波数をセットして、GPIO端子がPWM出力できるようにします。(MicorPython 専用)";
|
Blockly.Msg["PWM_TOOLTIP"] = "[RP2] パルス周波数をセットして、GPIO端子がPWM出力できるようにします。";
|
||||||
Blockly.Msg["I2C_OPEN_TITLE"] = "アドレス %1 の I2C デバイスを開く";
|
|
||||||
Blockly.Msg["I2C_OPEN_TOOLTIP"] = "I2C接続されたデバイスとの通信を開始します。一度にオープンできるI2Cデバイスはひとつだけです。";
|
|
||||||
Blockly.Msg["SERIAL_OPEN_TITLE"] = "シリアルポートを速度 %1 bpsで開く";
|
Blockly.Msg["SERIAL_OPEN_TITLE"] = "シリアルポートを速度 %1 bpsで開く";
|
||||||
Blockly.Msg["SERIAL_OPEN_TOOLTIP"] = "シリアルデバイスとの接続を開きます。";
|
Blockly.Msg["SERIAL_OPEN_TOOLTIP"] = "シリアルデバイスとの接続を開きます。";
|
||||||
Blockly.Msg["SERIAL_CLOSE_TITLE"] = "シリアルポートを閉じる";
|
Blockly.Msg["SERIAL_CLOSE_TITLE"] = "シリアルポートを閉じる";
|
||||||
@ -125,22 +122,16 @@ Blockly.Msg["SERIAL_WRITE_TITLE"] = "シリアルポートに %1 を送信する
|
|||||||
Blockly.Msg["SERIAL_WRITE_TOOLTIP"] = "シリアル接続されたデバイスにデータを送信します。シリアルポートは開かれていなくてはいけません。";
|
Blockly.Msg["SERIAL_WRITE_TOOLTIP"] = "シリアル接続されたデバイスにデータを送信します。シリアルポートは開かれていなくてはいけません。";
|
||||||
Blockly.Msg["SERIAL_READ_TITLE"] = "シリアルポートから %1 文字読み込む";
|
Blockly.Msg["SERIAL_READ_TITLE"] = "シリアルポートから %1 文字読み込む";
|
||||||
Blockly.Msg["SERIAL_READ_TOOLTIP"] = "オープン済みシリアルポートから、指定のバイト数だけデータを読み込みます。";
|
Blockly.Msg["SERIAL_READ_TOOLTIP"] = "オープン済みシリアルポートから、指定のバイト数だけデータを読み込みます。";
|
||||||
Blockly.Msg["I2C_CLOSE_TITLE"] = "I2C デバイスを閉じる";
|
|
||||||
Blockly.Msg["I2C_CLOSE_TOOLTIP"] = "I2C接続されたデバイスと通信を切断します。";
|
|
||||||
Blockly.Msg["I2C_WRITE_BYTE_TITLE"] = "デバイスに1バイトデータ %1 を送信";
|
Blockly.Msg["I2C_WRITE_BYTE_TITLE"] = "デバイスに1バイトデータ %1 を送信";
|
||||||
Blockly.Msg["I2C_WRITE_BYTE_TOOLTIP"] = "i2cデバイスに1バイトデータを送信します。0-0xFFの範囲の数字で入力してください。";
|
Blockly.Msg["I2C_WRITE_BYTE_TOOLTIP"] = "i2cデバイスに1バイトデータを送信します。0-0xFFの範囲の数字で入力してください。";
|
||||||
Blockly.Msg["I2C_READ_BYTE_TITLE"] = "I2C デバイスから 1 バイト受け取る";
|
Blockly.Msg["I2C_READ_BYTE_TITLE"] = "I2C デバイスから 1 バイト受け取る";
|
||||||
Blockly.Msg["I2C_READ_BYTE_TOOLTIP"] = "オープン済み I2C デバイスからデータを 1 バイト受け取ります。";
|
Blockly.Msg["I2C_READ_BYTE_TOOLTIP"] = "オープン済み I2C デバイスからデータを 1 バイト受け取ります。";
|
||||||
Blockly.Msg["I2C_WRITE_BYTE_DATA_TITLE"] = "レジスタ %1 に %2 を書き込む";
|
Blockly.Msg["I2C_WRITE_I2C_BLOCK_DATA_TITLE"] = "";
|
||||||
Blockly.Msg["I2C_WRITE_BYTE_DATA_TOOLTIP"] = "デバイスの指定されたレジスタに1バイトを書き込みます。";
|
Blockly.Msg["I2C_WRITE_I2C_BLOCK_DATA_TOOLTIP"] = "";
|
||||||
Blockly.Msg["I2C_READ_BYTE_DATA_TITLE"] = "レジスタ %1 の値";
|
Blockly.Msg["I2C_READ_DEVICE_TITLE"] = "";
|
||||||
Blockly.Msg["I2C_READ_BYTE_DATA_TOOLTIP"] = "デバイスの指定されたレジスタから1バイトを読み込みます。";
|
Blockly.Msg["I2C_READ_DEVICE_TOOLTIP"] = "";
|
||||||
Blockly.Msg["I2C_WRITE_I2C_BLOCK_DATA_TITLE"] = "レジスタ %1 に %2 を書き込む";
|
Blockly.Msg["I2C_WRITE_DEVICE_TITLE"] = "";
|
||||||
Blockly.Msg["I2C_WRITE_I2C_BLOCK_DATA_TOOLTIP"] = "デバイスの指定されたレジスタに最大32バイトのテキストデータを書き込みます。";
|
Blockly.Msg["I2C_WRITE_DEVICE_TOOLTIP"] = "";
|
||||||
Blockly.Msg["I2C_READ_DEVICE_TITLE"] = "i2cデバイスから %1 バイト受け取る";
|
|
||||||
Blockly.Msg["I2C_READ_DEVICE_TOOLTIP"] = "デバイスから指定したバイト数のデータを受け取ります。データが指定の長さより短いこともあります。";
|
|
||||||
Blockly.Msg["I2C_WRITE_DEVICE_TITLE"] = "i2c デバイスに %1 を送信";
|
|
||||||
Blockly.Msg["I2C_WRITE_DEVICE_TOOLTIP"] = "i2c デバイスにデータを送信します。";
|
|
||||||
|
|
||||||
Blockly.Msg["UGJ_CODECHAR_TITLE"] = "コード %1 の文字";
|
Blockly.Msg["UGJ_CODECHAR_TITLE"] = "コード %1 の文字";
|
||||||
Blockly.Msg["UGJ_CODECHAR_TOOLTIP"] = "文字コードを文字に変換します。";
|
Blockly.Msg["UGJ_CODECHAR_TOOLTIP"] = "文字コードを文字に変換します。";
|
||||||
|
@ -1,107 +1,115 @@
|
|||||||
module.exports = require('bindings')('rgpio');
|
module.exports = require('bindings')('rgpio');
|
||||||
|
|
||||||
// module.exports.SET_ACTIVE_LOW = 4;
|
module.exports.SET_ACTIVE_LOW = 4;
|
||||||
// module.exports.SET_OPEN_DRAIN = 8;
|
module.exports.SET_OPEN_DRAIN = 8;
|
||||||
// module.exports.SET_OPEN_SOURCE = 16;
|
module.exports.SET_OPEN_SOURCE = 16;
|
||||||
// module.exports.SET_PULL_UP = 32;
|
module.exports.SET_PULL_UP = 32;
|
||||||
// module.exports.SET_PULL_DOWN = 64;
|
module.exports.SET_PULL_DOWN = 64;
|
||||||
// module.exports.SET_PULL_NONE = 128;
|
module.exports.SET_PULL_NONE = 128;
|
||||||
module.exports.PULL_UP = 32;
|
|
||||||
module.exports.PULL_DOWN = 64;
|
|
||||||
module.exports.PULL_NONE = 128;
|
|
||||||
|
|
||||||
const CHIP_COUNT = 5;
|
|
||||||
const port = '';
|
|
||||||
|
|
||||||
|
// Properties
|
||||||
let sbc = -1;
|
let sbc = -1;
|
||||||
let gpiochip_hand = [];
|
let chip_hand = [];
|
||||||
let ser_hand = -1;
|
|
||||||
let i2c_hand = -1;
|
module.exports.rgpio_sbc = async (host = 'localhost', port = 8889, show_errors = true) => {
|
||||||
module.exports.gpio_open = async () => {
|
if (sbc < 0) {
|
||||||
sbc = await module.exports._gpiod_start('', '');
|
sbc = await module.exports._rgpiod_start(host, port.toString());
|
||||||
if (sbc < 0) return sbc;
|
if (sbc < 0) {
|
||||||
for (let i = 0; i < CHIP_COUNT; i++) {
|
if (show_errors) console.log(sbc);
|
||||||
gpiochip_hand.push(await module.exports._gpiochip_open(sbc, i));
|
|
||||||
}
|
|
||||||
return gpiochip_hand;
|
|
||||||
}
|
|
||||||
module.exports.gpio_close = async () => {
|
|
||||||
if (sbc >= 0) {
|
|
||||||
for (let i = 0; i < CHIP_COUNT; i++) {
|
|
||||||
if (gpiochip_hand[i] >= 0)
|
|
||||||
await module.exports._gpiochip_close(sbc, gpiochip_hand[i]);
|
|
||||||
}
|
}
|
||||||
gpiochip_hand = [];
|
|
||||||
await module.exports._gpiod_stop(sbc);
|
|
||||||
sbc = -1;
|
|
||||||
}
|
}
|
||||||
|
return sbc;
|
||||||
}
|
}
|
||||||
module.exports.gpio_set_output = async gpio => {
|
module.exports.sbc_stop = async () => {
|
||||||
let chip = Math.floor(gpio / 32);
|
await module.exports._rgpiod_stop(sbc);
|
||||||
let pin = Math.floor(gpio % 32);
|
chip_hand = [];
|
||||||
if (gpiochip_hand[chip] >= 0) return await module.exports._gpio_claim_output(sbc, gpiochip_hand[chip], pin);
|
sbc = -1;
|
||||||
}
|
}
|
||||||
module.exports.gpio_write = async (gpio, value) => {
|
module.exports.gpiochip_open = async gpiochip => {
|
||||||
let chip = Math.floor(gpio / 32);
|
if (!chip_hand[gpiochip] || chip_hand[gpiochip] < 0) {
|
||||||
let pin = Math.floor(gpio % 32);
|
chip_hand[gpiochip] = await module.exports._gpiochip_open(sbc, gpiochip);
|
||||||
if (gpiochip_hand[chip] >= 0) return await module.exports._gpio_write(sbc, gpiochip_hand[chip], pin, value);
|
}
|
||||||
|
return chip_hand[gpiochip];
|
||||||
|
// return await module.exports._gpiochip_open(sbc, gpiochip);
|
||||||
}
|
}
|
||||||
module.exports.serial_open = async (tty, baud) => {
|
module.exports.gpio_set_input = async (ugpio, lFlags = 0) => {
|
||||||
if (ser_hand >= 0) await module.exports._serial_close(sbc, ser_hand); // 勝手に閉じる
|
let chip = Math.trunc(ugpio / 32);
|
||||||
ser_hand = await module.exports._serial_open(sbc, tty, baud);
|
let gpio = ugpio % 32;
|
||||||
return ser_hand;
|
let handle = await module.exports.gpiochip_open(chip);
|
||||||
|
return await module.exports._gpio_claim_input(sbc, handle, lFlags, gpio);
|
||||||
}
|
}
|
||||||
module.exports.serial_close = async () => {
|
module.exports.gpio_set_output = async (ugpio, level = 0, lFlags = 0) => {
|
||||||
if (ser_hand >= 0) await module.exports._serial_close(sbc, ser_hand);
|
let chip = Math.trunc(ugpio / 32);
|
||||||
ser_hand = -1;
|
let gpio = ugpio % 32;
|
||||||
|
let handle = await module.exports.gpiochip_open(chip);
|
||||||
|
return await module.exports._gpio_claim_output(sbc, handle, lFlags, gpio, level);
|
||||||
}
|
}
|
||||||
module.exports.serial_write = async data => {
|
module.exports.gpio_read = async (ugpio) => {
|
||||||
if (ser_hand >= 0) return await module.exports._serial_write(sbc, ser_hand, Buffer.from(data));
|
let chip = Math.trunc(ugpio / 32);
|
||||||
|
let gpio = ugpio % 32;
|
||||||
|
let handle = await module.exports.gpiochip_open(chip);
|
||||||
|
return await module.exports._gpio_read(sbc, handle, gpio);
|
||||||
}
|
}
|
||||||
module.exports.serial_read = async count => {
|
module.exports.gpio_write = async (ugpio, level) => {
|
||||||
if (ser_hand >= 0) return new TextDecoder().decode(await module.exports._serial_read(sbc, ser_hand, count));
|
let chip = Math.trunc(ugpio / 32);
|
||||||
// if (ser_hand >= 0) return await module.exports._serial_read(pi, ser_hand, count);//.toString('utf8');
|
let gpio = ugpio % 32;
|
||||||
|
let handle = await module.exports.gpiochip_open(chip);
|
||||||
|
return await module.exports._gpio_write(sbc, handle, gpio, level);
|
||||||
}
|
}
|
||||||
module.exports.i2c_open = async (i2c_bus, i2c_address) => {
|
module.exports.serial_open = async (tty, baud, ser_flags = 0) => {
|
||||||
if (i2c_hand >= 0) await module.exports._i2c_close(i2c_hand); // 勝手に閉じる
|
return await module.exports._serial_open(sbc, tty, baud, ser_flags);
|
||||||
i2c_hand = await module.exports._i2c_open(sbc, i2c_bus, i2c_address);
|
|
||||||
return i2c_hand;
|
|
||||||
}
|
}
|
||||||
module.exports.i2c_close = async () => {
|
module.exports.serial_close = async handle => {
|
||||||
if (i2c_hand >= 0) await module.exports._i2c_close(sbc, i2c_hand);
|
await module.exports._serial_close(sbc, handle);
|
||||||
i2c_hand = -1;
|
}
|
||||||
|
module.exports.serial_read = async (handle, count = 0) => {
|
||||||
|
if (count === 0) {
|
||||||
|
count = await module.exports._serial_data_available(sbc, handle);
|
||||||
|
if (count === 0) return '';
|
||||||
|
}
|
||||||
|
return new TextDecoder().decode(await module.exports._serial_read(sbc, handle, count));
|
||||||
|
}
|
||||||
|
module.exports.serial_write = async (handle, data) => {
|
||||||
|
return await module.exports._serial_write(sbc, handle, Buffer.from(data), -1);
|
||||||
|
}
|
||||||
|
module.exports.serial_data_available = async handle => {
|
||||||
|
await module.exports._serial_data_available(sbc, handle);
|
||||||
|
}
|
||||||
|
module.exports.i2c_open = async (i2c_bus, i2c_address, i2c_flags = 0) => {
|
||||||
|
return await module.exports._i2c_open(sbc, i2c_bus, i2c_address, i2c_flags);
|
||||||
|
}
|
||||||
|
module.exports.i2c_close = async handle => {
|
||||||
|
await module.exports._i2c_close(sbc, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.i2c_write_byte = async (byte_val) => {
|
module.exports.i2c_write_byte = async (handle, byte_val) => {
|
||||||
if (i2c_hand >= 0) return await module.exports._i2c_write_byte(sbc, i2c_hand, byte_val);
|
return await module.exports._i2c_write_byte(sbc, handle, byte_val);
|
||||||
}
|
}
|
||||||
module.exports.i2c_read_byte = async () => {
|
module.exports.i2c_read_byte = async handle => {
|
||||||
if (i2c_hand >= 0) return await module.exports._i2c_read_byte(sbc, i2c_hand);
|
return await module.exports._i2c_read_byte(sbc, handle);
|
||||||
}
|
}
|
||||||
|
module.exports.i2c_write_byte_data = async (handle, reg, byte_val) => {
|
||||||
|
return await module.exports._i2c_write_byte_data(sbc, handle, reg, byte_val);
|
||||||
module.exports.i2c_write_byte_data = async (reg, byte_val) => {
|
|
||||||
if (i2c_hand >= 0) return await module.exports._i2c_write_byte_data(sbc, i2c_hand, reg, byte_val);
|
|
||||||
}
|
}
|
||||||
module.exports.i2c_read_byte_data = async reg => {
|
module.exports.i2c_read_byte_data = async (handle, reg) => {
|
||||||
if (i2c_hand >= 0) return await module.exports._i2c_read_byte_data(sbc, i2c_hand, reg);
|
return await module.exports._i2c_read_byte_data(sbc, handle, reg);
|
||||||
}
|
}
|
||||||
module.exports.i2c_write_i2c_block_data = async (reg, data) => {
|
module.exports.i2c_write_i2c_block_data = async (handle, reg, data) => {
|
||||||
if (i2c_hand >= 0) return await module.exports._i2c_write_i2c_block_data(sbc, i2c_hand, reg, Buffer.from(data));
|
return await module.exports._i2c_write_i2c_block_data(sbc, handle, reg, Buffer.from(data), -1);
|
||||||
}
|
}
|
||||||
module.exports.i2c_read_word_data = async reg => {
|
module.exports.i2c_read_word_data = async (handle, reg) => {
|
||||||
if (i2c_hand >= 0) return await module.exports._i2c_read_word_data(sbc, i2c_hand, reg);
|
return await module.exports._i2c_read_word_data(sbc, handle, reg);
|
||||||
}
|
}
|
||||||
module.exports.i2c_read_device = async count => {
|
module.exports.i2c_read_device = async (handle, count) => {
|
||||||
if (i2c_hand >= 0) return new TextDecoder().decode(await module.exports._i2c_read_device(sbc, i2c_hand, count));
|
return new TextDecoder().decode(await module.exports._i2c_read_device(sbc, handle, count));
|
||||||
}
|
}
|
||||||
module.exports.i2c_write_device = async data => {
|
module.exports.i2c_write_device = async (handle, data) => {
|
||||||
if (i2c_hand >= 0) return await module.exports._i2c_write_device(sbc, i2c_hand, Buffer.from(data));
|
return await module.exports._i2c_write_device(sbc, handle, Buffer.from(data), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 終了処理
|
// 終了処理
|
||||||
module.exports.close_all_handle = async () => {
|
module.exports.close_all_handle = async () => {
|
||||||
await module.exports.gpio_close();
|
await module.exports.sbc_stop();
|
||||||
await module.exports.serial_close();
|
// await module.exports.serial_close();
|
||||||
await module.exports.i2c_close();
|
// await module.exports.i2c_close();
|
||||||
}
|
}
|
@ -16,12 +16,12 @@ Promise _rgpiodStart(const CallbackInfo &info)
|
|||||||
if (info.Length() != 2)
|
if (info.Length() != 2)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _rgpiodStart").Value());
|
||||||
}
|
}
|
||||||
if (!info[0].IsString() || !info[1].IsString())
|
if (!info[0].IsString() || !info[1].IsString())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _rgpiodStart").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -39,12 +39,12 @@ Promise _rgpiodStop(const CallbackInfo &info)
|
|||||||
if (info.Length() != 1)
|
if (info.Length() != 1)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _rgpiodStop").Value());
|
||||||
}
|
}
|
||||||
if (!info[0].IsNumber())
|
if (!info[0].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _rgpiodStop").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -63,12 +63,12 @@ Promise _gpiochipOpen(const CallbackInfo &info)
|
|||||||
if (info.Length() != 2)
|
if (info.Length() != 2)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _gpiochipOpen").Value());
|
||||||
}
|
}
|
||||||
if (!info[0].IsNumber() || !info[1].IsNumber())
|
if (!info[0].IsNumber() || !info[1].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _gpiochipOpen").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -87,12 +87,12 @@ Promise _gpiochipClose(const CallbackInfo &info)
|
|||||||
if (info.Length() != 2)
|
if (info.Length() != 2)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _gpiochipClose").Value());
|
||||||
}
|
}
|
||||||
if (!info[0].IsNumber() || !info[1].IsNumber())
|
if (!info[0].IsNumber() || !info[1].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _gpiochipClose").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -105,18 +105,73 @@ Promise _gpiochipClose(const CallbackInfo &info)
|
|||||||
|
|
||||||
// GPIO のモードを出力にする(ことを要求?)
|
// GPIO のモードを出力にする(ことを要求?)
|
||||||
Promise _gpioClaimOutput(const CallbackInfo &info)
|
Promise _gpioClaimOutput(const CallbackInfo &info)
|
||||||
|
{
|
||||||
|
Env env = info.Env();
|
||||||
|
auto deferred = Napi::Promise::Deferred::New(env);
|
||||||
|
if (info.Length() != 5)
|
||||||
|
{
|
||||||
|
deferred.Reject(
|
||||||
|
TypeError::New(env, "Invalid argument count: _gpioClaimOutput").Value());
|
||||||
|
}
|
||||||
|
if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsNumber() || !info[4].IsNumber())
|
||||||
|
{
|
||||||
|
deferred.Reject(
|
||||||
|
Napi::TypeError::New(env, "Invalid argument types: _gpioClaimOutput").Value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
|
int handle = info[1].As<Number>().Int32Value();
|
||||||
|
int lFlags = info[2].As<Number>().Int32Value();
|
||||||
|
int gpio = info[3].As<Number>().Int32Value();
|
||||||
|
int value = info[4].As<Number>().Int32Value();
|
||||||
|
|
||||||
|
deferred.Resolve(Number::New(env, gpio_claim_output(sbc, handle, lFlags, gpio, value)));
|
||||||
|
}
|
||||||
|
return deferred.Promise();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GPIO のモードを入力にする(ことを要求?)
|
||||||
|
Promise _gpioClaimInput(const CallbackInfo &info)
|
||||||
|
{
|
||||||
|
Env env = info.Env();
|
||||||
|
auto deferred = Napi::Promise::Deferred::New(env);
|
||||||
|
if (info.Length() != 4)
|
||||||
|
{
|
||||||
|
deferred.Reject(
|
||||||
|
TypeError::New(env, "Invalid argument count: _gpioClaimInput").Value());
|
||||||
|
}
|
||||||
|
if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsNumber())
|
||||||
|
{
|
||||||
|
deferred.Reject(
|
||||||
|
Napi::TypeError::New(env, "Invalid argument types: _gpioClaimInput").Value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
|
int handle = info[1].As<Number>().Int32Value();
|
||||||
|
int lFlags = info[2].As<Number>().Int32Value();
|
||||||
|
int gpio = info[3].As<Number>().Int32Value();
|
||||||
|
|
||||||
|
deferred.Resolve(Number::New(env, gpio_claim_input(sbc, handle, lFlags, gpio)));
|
||||||
|
}
|
||||||
|
return deferred.Promise();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GPIOの電圧を読む
|
||||||
|
Promise _gpioRead(const CallbackInfo &info)
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
auto deferred = Napi::Promise::Deferred::New(env);
|
auto deferred = Napi::Promise::Deferred::New(env);
|
||||||
if (info.Length() != 3)
|
if (info.Length() != 3)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _gpioRead").Value());
|
||||||
}
|
}
|
||||||
if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _gpioRead").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -124,14 +179,11 @@ Promise _gpioClaimOutput(const CallbackInfo &info)
|
|||||||
int handle = info[1].As<Number>().Int32Value();
|
int handle = info[1].As<Number>().Int32Value();
|
||||||
int gpio = info[2].As<Number>().Int32Value();
|
int gpio = info[2].As<Number>().Int32Value();
|
||||||
|
|
||||||
deferred.Resolve(Number::New(env, gpio_claim_output(sbc, handle, 0, gpio, 0)));
|
deferred.Resolve(Number::New(env, gpio_read(sbc, handle, gpio)));
|
||||||
}
|
}
|
||||||
return deferred.Promise();
|
return deferred.Promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
// GPIO のモードを入力にする(ことを要求?)
|
|
||||||
// GPIOの電圧を読む
|
|
||||||
|
|
||||||
// GPIO の電圧をセットする
|
// GPIO の電圧をセットする
|
||||||
Promise _gpioWrite(const CallbackInfo &info)
|
Promise _gpioWrite(const CallbackInfo &info)
|
||||||
{
|
{
|
||||||
@ -140,12 +192,12 @@ Promise _gpioWrite(const CallbackInfo &info)
|
|||||||
if (info.Length() != 4)
|
if (info.Length() != 4)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _gpioWrite").Value());
|
||||||
}
|
}
|
||||||
if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsNumber())
|
if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _gpioWrite").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -164,12 +216,12 @@ Promise _serialOpen(const CallbackInfo &info)
|
|||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
auto deferred = Napi::Promise::Deferred::New(env);
|
auto deferred = Napi::Promise::Deferred::New(env);
|
||||||
if (info.Length() != 3)
|
if (info.Length() != 4)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count: _serialOpen").Value());
|
TypeError::New(env, "Invalid argument count: _serialOpen").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsString() || !info[2].IsNumber())
|
else if (!info[0].IsNumber() || !info[1].IsString() || !info[2].IsNumber() || !info[3].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types: _serialOpen").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _serialOpen").Value());
|
||||||
@ -179,7 +231,8 @@ Promise _serialOpen(const CallbackInfo &info)
|
|||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
std::string ser_tty = info[1].As<String>().Utf8Value();
|
std::string ser_tty = info[1].As<String>().Utf8Value();
|
||||||
int baud = info[2].As<Number>().Uint32Value();
|
int baud = info[2].As<Number>().Uint32Value();
|
||||||
deferred.Resolve(Number::New(env, serial_open(sbc, (char *)ser_tty.c_str(), baud, 0)));
|
int ser_flags = info[3].As<Number>().Uint32Value();
|
||||||
|
deferred.Resolve(Number::New(env, serial_open(sbc, (char *)ser_tty.c_str(), baud, ser_flags)));
|
||||||
}
|
}
|
||||||
return deferred.Promise();
|
return deferred.Promise();
|
||||||
}
|
}
|
||||||
@ -192,12 +245,12 @@ Promise _serialClose(const CallbackInfo &info)
|
|||||||
if (info.Length() != 2)
|
if (info.Length() != 2)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _serialClose").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber())
|
else if (!info[0].IsNumber() || !info[1].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _serialClose").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -216,12 +269,12 @@ Promise _serialRead(const CallbackInfo &info)
|
|||||||
if (info.Length() != 3)
|
if (info.Length() != 3)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _serialRead").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _serialRead").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -242,49 +295,76 @@ Promise _serialWrite(const CallbackInfo &info)
|
|||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
auto deferred = Napi::Promise::Deferred::New(env);
|
auto deferred = Napi::Promise::Deferred::New(env);
|
||||||
if (info.Length() != 3)
|
if (info.Length() != 4)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _serialWrite").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsBuffer())
|
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsBuffer() || !info[3].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _serialWrite").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
int handle = info[1].As<Number>().Uint32Value();
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
auto buf = info[2].As<Buffer<char>>();
|
auto buf = info[2].As<Buffer<char>>();
|
||||||
|
int count = info[3].As<Number>().Uint32Value();
|
||||||
|
|
||||||
int count = buf.Length();
|
if (count < 0)
|
||||||
|
count = buf.Length();
|
||||||
deferred.Resolve(Number::New(env, serial_write(sbc, handle, buf.Data(), count)));
|
deferred.Resolve(Number::New(env, serial_write(sbc, handle, buf.Data(), count)));
|
||||||
}
|
}
|
||||||
return deferred.Promise();
|
return deferred.Promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// シリアルデバイスから読み出し可能なバイト数を返す
|
||||||
|
Promise _serialDataAvailable(const CallbackInfo &info)
|
||||||
|
{
|
||||||
|
Env env = info.Env();
|
||||||
|
auto deferred = Napi::Promise::Deferred::New(env);
|
||||||
|
if (info.Length() != 2)
|
||||||
|
{
|
||||||
|
deferred.Reject(
|
||||||
|
TypeError::New(env, "Invalid argument count: _serialDataAvailable").Value());
|
||||||
|
}
|
||||||
|
else if (!info[0].IsNumber() || !info[1].IsNumber())
|
||||||
|
{
|
||||||
|
deferred.Reject(
|
||||||
|
Napi::TypeError::New(env, "Invalid argument types: _serialDataAvailable").Value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
|
deferred.Resolve(Number::New(env, serial_data_available(sbc, handle)));
|
||||||
|
}
|
||||||
|
return deferred.Promise();
|
||||||
|
}
|
||||||
|
|
||||||
// I2Cバスアドレスのデバイスのハンドルを返す
|
// I2Cバスアドレスのデバイスのハンドルを返す
|
||||||
Promise _i2cOpen(const CallbackInfo &info)
|
Promise _i2cOpen(const CallbackInfo &info)
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
auto deferred = Napi::Promise::Deferred::New(env);
|
auto deferred = Napi::Promise::Deferred::New(env);
|
||||||
if (info.Length() != 3)
|
if (info.Length() != 4)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _i2cOpen").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _i2cOpen").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
unsigned int i2c_bus = info[1].As<Number>().Uint32Value();
|
int i2c_bus = info[1].As<Number>().Uint32Value();
|
||||||
unsigned int i2c_addr = info[2].As<Number>().Uint32Value();
|
int i2c_addr = info[2].As<Number>().Uint32Value();
|
||||||
deferred.Resolve(Number::New(env, i2c_open(sbc, i2c_bus, i2c_addr, 0)));
|
int i2c_flags = info[3].As<Number>().Uint32Value();
|
||||||
|
deferred.Resolve(Number::New(env, i2c_open(sbc, i2c_bus, i2c_addr, i2c_flags)));
|
||||||
}
|
}
|
||||||
return deferred.Promise();
|
return deferred.Promise();
|
||||||
}
|
}
|
||||||
@ -296,17 +376,17 @@ Promise _i2cClose(const CallbackInfo &info)
|
|||||||
if (info.Length() != 2)
|
if (info.Length() != 2)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _i2cClose").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber())
|
else if (!info[0].IsNumber() || !info[1].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _i2cClose").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
unsigned int handle = info[1].As<Number>().Uint32Value();
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
deferred.Resolve(Number::New(env, i2c_close(sbc, handle)));
|
deferred.Resolve(Number::New(env, i2c_close(sbc, handle)));
|
||||||
}
|
}
|
||||||
return deferred.Promise();
|
return deferred.Promise();
|
||||||
@ -320,18 +400,18 @@ Promise _i2cWriteByte(const CallbackInfo &info)
|
|||||||
if (info.Length() != 3)
|
if (info.Length() != 3)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _i2cWriteByte").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _i2cWriteByte").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
unsigned int handle = info[1].As<Number>().Uint32Value();
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
unsigned int bVal = info[2].As<Number>().Uint32Value();
|
int bVal = info[2].As<Number>().Uint32Value();
|
||||||
deferred.Resolve(Number::New(env, i2c_write_byte(sbc, handle, bVal)));
|
deferred.Resolve(Number::New(env, i2c_write_byte(sbc, handle, bVal)));
|
||||||
}
|
}
|
||||||
return deferred.Promise();
|
return deferred.Promise();
|
||||||
@ -344,17 +424,17 @@ Promise _i2cReadByte(const CallbackInfo &info)
|
|||||||
if (info.Length() != 2)
|
if (info.Length() != 2)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _i2cReadByte").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[0].IsNumber())
|
else if (!info[0].IsNumber() || !info[0].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _i2cReadByte").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
unsigned int handle = info[1].As<Number>().Uint32Value();
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
deferred.Resolve(Number::New(env, i2c_read_byte(sbc, handle)));
|
deferred.Resolve(Number::New(env, i2c_read_byte(sbc, handle)));
|
||||||
}
|
}
|
||||||
return deferred.Promise();
|
return deferred.Promise();
|
||||||
@ -368,19 +448,19 @@ Promise _i2cWriteByteData(const CallbackInfo &info)
|
|||||||
if (info.Length() != 4)
|
if (info.Length() != 4)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _i2cWriteByteData").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsNumber())
|
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _i2cWriteByteData").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
unsigned int handle = info[1].As<Number>().Uint32Value();
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
unsigned int i2c_reg = info[2].As<Number>().Uint32Value();
|
int i2c_reg = info[2].As<Number>().Uint32Value();
|
||||||
unsigned int bVal = info[3].As<Number>().Uint32Value();
|
int bVal = info[3].As<Number>().Uint32Value();
|
||||||
deferred.Resolve(Number::New(env, i2c_write_byte_data(sbc, handle, i2c_reg, bVal)));
|
deferred.Resolve(Number::New(env, i2c_write_byte_data(sbc, handle, i2c_reg, bVal)));
|
||||||
}
|
}
|
||||||
return deferred.Promise();
|
return deferred.Promise();
|
||||||
@ -393,18 +473,18 @@ Promise _i2cReadByteData(const CallbackInfo &info)
|
|||||||
if (info.Length() != 3)
|
if (info.Length() != 3)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _i2cReadByteData").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _i2cReadByteData").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
unsigned int handle = info[1].As<Number>().Uint32Value();
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
unsigned int i2c_reg = info[2].As<Number>().Uint32Value();
|
int i2c_reg = info[2].As<Number>().Uint32Value();
|
||||||
deferred.Resolve(Number::New(env, i2c_read_byte_data(sbc, handle, i2c_reg)));
|
deferred.Resolve(Number::New(env, i2c_read_byte_data(sbc, handle, i2c_reg)));
|
||||||
}
|
}
|
||||||
return deferred.Promise();
|
return deferred.Promise();
|
||||||
@ -418,21 +498,21 @@ Promise _i2cReadI2cBlockData(const CallbackInfo &info)
|
|||||||
if (info.Length() != 4)
|
if (info.Length() != 4)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _i2cReadI2cBlockData").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsNumber())
|
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _i2cReadI2cBlockData").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
unsigned int handle = info[1].As<Number>().Uint32Value();
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
unsigned int i2cReg = info[2].As<Number>().Uint32Value();
|
int i2c_reg = info[2].As<Number>().Uint32Value();
|
||||||
unsigned int count = info[3].As<Number>().Uint32Value();
|
int count = info[3].As<Number>().Uint32Value();
|
||||||
char buf[count];
|
char buf[count];
|
||||||
int rxCount = i2c_read_i2c_block_data(sbc, handle, i2cReg, buf, count);
|
int rxCount = i2c_read_i2c_block_data(sbc, handle, i2c_reg, buf, count);
|
||||||
auto outBuf = Buffer<char>::Copy(env, buf, rxCount);
|
auto outBuf = Buffer<char>::Copy(env, buf, rxCount);
|
||||||
deferred.Resolve(outBuf);
|
deferred.Resolve(outBuf);
|
||||||
}
|
}
|
||||||
@ -444,24 +524,26 @@ Promise _i2cWriteI2cBlockData(const CallbackInfo &info)
|
|||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
auto deferred = Napi::Promise::Deferred::New(env);
|
auto deferred = Napi::Promise::Deferred::New(env);
|
||||||
if (info.Length() != 4)
|
if (info.Length() != 5)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _i2cWriteI2cBlockData").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsBuffer())
|
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsBuffer() || !info[4].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _i2cWriteI2cBlockData").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
unsigned int handle = info[1].As<Number>().Uint32Value();
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
unsigned int i2c_reg = info[2].As<Number>().Uint32Value();
|
int i2c_reg = info[2].As<Number>().Uint32Value();
|
||||||
auto buf = info[3].As<Buffer<char>>();
|
auto buf = info[3].As<Buffer<char>>();
|
||||||
|
int count = info[4].As<Number>().Uint32Value();
|
||||||
|
|
||||||
unsigned int count = buf.Length();
|
if (count < 0)
|
||||||
|
count = buf.Length();
|
||||||
deferred.Resolve(Number::New(env, i2c_write_i2c_block_data(sbc, handle, i2c_reg, buf.Data(), count)));
|
deferred.Resolve(Number::New(env, i2c_write_i2c_block_data(sbc, handle, i2c_reg, buf.Data(), count)));
|
||||||
}
|
}
|
||||||
return deferred.Promise();
|
return deferred.Promise();
|
||||||
@ -475,18 +557,18 @@ Promise _i2cReadWordData(const CallbackInfo &info)
|
|||||||
if (info.Length() != 3)
|
if (info.Length() != 3)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _i2cReadWordData").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _i2cReadWordData").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
unsigned int handle = info[1].As<Number>().Uint32Value();
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
unsigned int i2c_reg = info[2].As<Number>().Uint32Value();
|
int i2c_reg = info[2].As<Number>().Uint32Value();
|
||||||
deferred.Resolve(Number::New(env, i2c_read_word_data(sbc, handle, i2c_reg)));
|
deferred.Resolve(Number::New(env, i2c_read_word_data(sbc, handle, i2c_reg)));
|
||||||
}
|
}
|
||||||
return deferred.Promise();
|
return deferred.Promise();
|
||||||
@ -499,19 +581,19 @@ Promise _i2cWriteWordData(const CallbackInfo &info)
|
|||||||
if (info.Length() != 4)
|
if (info.Length() != 4)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _i2cWriteWordData").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsNumber())
|
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _i2cWriteWordData").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
unsigned int handle = info[1].As<Number>().Uint32Value();
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
unsigned int i2c_reg = info[2].As<Number>().Uint32Value();
|
int i2c_reg = info[2].As<Number>().Uint32Value();
|
||||||
unsigned int wVal = info[3].As<Number>().Uint32Value();
|
int wVal = info[3].As<Number>().Uint32Value();
|
||||||
|
|
||||||
deferred.Resolve(Number::New(env, i2c_write_word_data(sbc, handle, i2c_reg, wVal)));
|
deferred.Resolve(Number::New(env, i2c_write_word_data(sbc, handle, i2c_reg, wVal)));
|
||||||
}
|
}
|
||||||
@ -526,18 +608,18 @@ Promise _i2cReadDevice(const CallbackInfo &info)
|
|||||||
if (info.Length() != 3)
|
if (info.Length() != 3)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _i2cReadDevice").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _i2cReadDevice").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
unsigned int handle = info[1].As<Number>().Uint32Value();
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
unsigned int count = info[2].As<Number>().Uint32Value();
|
int count = info[2].As<Number>().Uint32Value();
|
||||||
|
|
||||||
char buf[count];
|
char buf[count];
|
||||||
int rxCount = i2c_read_device(sbc, handle, buf, count);
|
int rxCount = i2c_read_device(sbc, handle, buf, count);
|
||||||
@ -552,23 +634,25 @@ Promise _i2cWriteDevice(const CallbackInfo &info)
|
|||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
auto deferred = Napi::Promise::Deferred::New(env);
|
auto deferred = Napi::Promise::Deferred::New(env);
|
||||||
if (info.Length() != 3)
|
if (info.Length() != 4)
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
TypeError::New(env, "Invalid argument count").Value());
|
TypeError::New(env, "Invalid argument count: _i2cWriteDevice").Value());
|
||||||
}
|
}
|
||||||
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsBuffer())
|
else if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsBuffer() || !info[3].IsNumber())
|
||||||
{
|
{
|
||||||
deferred.Reject(
|
deferred.Reject(
|
||||||
Napi::TypeError::New(env, "Invalid argument types").Value());
|
Napi::TypeError::New(env, "Invalid argument types: _i2cWriteDevice").Value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sbc = info[0].As<Number>().Int32Value();
|
int sbc = info[0].As<Number>().Int32Value();
|
||||||
unsigned int handle = info[1].As<Number>().Uint32Value();
|
int handle = info[1].As<Number>().Uint32Value();
|
||||||
auto buf = info[2].As<Buffer<char>>();
|
auto buf = info[2].As<Buffer<char>>();
|
||||||
|
int count = info[3].As<Number>().Uint32Value();
|
||||||
|
|
||||||
unsigned int count = buf.Length();
|
if (count < 0)
|
||||||
|
int count = buf.Length();
|
||||||
deferred.Resolve(Number::New(env, i2c_write_device(sbc, handle, buf.Data(), count)));
|
deferred.Resolve(Number::New(env, i2c_write_device(sbc, handle, buf.Data(), count)));
|
||||||
}
|
}
|
||||||
return deferred.Promise();
|
return deferred.Promise();
|
||||||
@ -577,16 +661,19 @@ Promise _i2cWriteDevice(const CallbackInfo &info)
|
|||||||
Object
|
Object
|
||||||
Init(Env env, Object exports)
|
Init(Env env, Object exports)
|
||||||
{
|
{
|
||||||
exports.Set(String::New(env, "_gpiod_start"), Function::New(env, _rgpiodStart));
|
exports.Set(String::New(env, "_rgpiod_start"), Function::New(env, _rgpiodStart));
|
||||||
exports.Set(String::New(env, "_gpiod_stop"), Function::New(env, _rgpiodStop));
|
exports.Set(String::New(env, "_rgpiod_stop"), Function::New(env, _rgpiodStop));
|
||||||
exports.Set(String::New(env, "_gpiochip_open"), Function::New(env, _gpiochipOpen));
|
exports.Set(String::New(env, "_gpiochip_open"), Function::New(env, _gpiochipOpen));
|
||||||
exports.Set(String::New(env, "_gpiochip_close"), Function::New(env, _gpiochipClose));
|
exports.Set(String::New(env, "_gpiochip_close"), Function::New(env, _gpiochipClose));
|
||||||
|
exports.Set(String::New(env, "_gpio_claim_input"), Function::New(env, _gpioClaimInput));
|
||||||
exports.Set(String::New(env, "_gpio_claim_output"), Function::New(env, _gpioClaimOutput));
|
exports.Set(String::New(env, "_gpio_claim_output"), Function::New(env, _gpioClaimOutput));
|
||||||
|
exports.Set(String::New(env, "_gpio_read"), Function::New(env, _gpioRead));
|
||||||
exports.Set(String::New(env, "_gpio_write"), Function::New(env, _gpioWrite));
|
exports.Set(String::New(env, "_gpio_write"), Function::New(env, _gpioWrite));
|
||||||
exports.Set(String::New(env, "_serial_open"), Function::New(env, _serialOpen));
|
exports.Set(String::New(env, "_serial_open"), Function::New(env, _serialOpen));
|
||||||
exports.Set(String::New(env, "_serial_close"), Function::New(env, _serialClose));
|
exports.Set(String::New(env, "_serial_close"), Function::New(env, _serialClose));
|
||||||
exports.Set(String::New(env, "_serial_read"), Function::New(env, _serialRead));
|
exports.Set(String::New(env, "_serial_read"), Function::New(env, _serialRead));
|
||||||
exports.Set(String::New(env, "_serial_write"), Function::New(env, _serialWrite));
|
exports.Set(String::New(env, "_serial_write"), Function::New(env, _serialWrite));
|
||||||
|
exports.Set(String::New(env, "_serial_data_available"), Function::New(env, _serialDataAvailable));
|
||||||
exports.Set(String::New(env, "_i2c_open"), Function::New(env, _i2cOpen));
|
exports.Set(String::New(env, "_i2c_open"), Function::New(env, _i2cOpen));
|
||||||
exports.Set(String::New(env, "_i2c_close"), Function::New(env, _i2cClose));
|
exports.Set(String::New(env, "_i2c_close"), Function::New(env, _i2cClose));
|
||||||
exports.Set(String::New(env, "_i2c_write_byte"), Function::New(env, _i2cWriteByte));
|
exports.Set(String::New(env, "_i2c_write_byte"), Function::New(env, _i2cWriteByte));
|
||||||
|
2
main.js
2
main.js
@ -172,7 +172,7 @@ let template = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "MicroPython (Test phase)",
|
label: "MicroPython (RP2)",
|
||||||
id: "py",
|
id: "py",
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
click: (item, focusedWindow) => {
|
click: (item, focusedWindow) => {
|
||||||
|
548
package-lock.json
generated
548
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@ -22,24 +22,24 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://git.ocoge.club/ocoge.club/ocoge#readme",
|
"homepage": "https://git.ocoge.club/ocoge.club/ocoge#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@electron-forge/cli": "^6.1.1",
|
"@electron-forge/cli": "^6.2.1",
|
||||||
"@electron-forge/maker-deb": "^6.1.1",
|
"@electron-forge/maker-deb": "^6.2.1",
|
||||||
"@electron/rebuild": "^3.2.13",
|
"@electron/rebuild": "^3.2.13",
|
||||||
"electron": "^24.3.0"
|
"electron": "^25.2.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@blockly/field-slider": "^4.0.16",
|
"@blockly/field-slider": "^4.0.18",
|
||||||
"@tensorflow-models/blazeface": "^0.0.7",
|
"@tensorflow-models/blazeface": "^0.0.7",
|
||||||
"@tensorflow-models/knn-classifier": "^1.2.4",
|
"@tensorflow-models/knn-classifier": "^1.2.4",
|
||||||
"@tensorflow-models/mobilenet": "^2.1.0",
|
"@tensorflow-models/mobilenet": "^2.1.0",
|
||||||
"@tensorflow-models/speech-commands": "^0.5.4",
|
"@tensorflow-models/speech-commands": "^0.5.4",
|
||||||
"@tensorflow/tfjs-node": "^4.5.0",
|
"@tensorflow/tfjs-node": "^4.8.0",
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
"blockly": "^9.3.3",
|
"blockly": "^9.3.3",
|
||||||
"dracula-prism": "^2.1.13",
|
"dracula-prism": "^2.1.13",
|
||||||
"js-beautify": "^1.14.7",
|
"js-beautify": "^1.14.8",
|
||||||
"node-abi": "^3.40.0",
|
"node-abi": "^3.45.0",
|
||||||
"nodemailer": "^6.9.2",
|
"nodemailer": "^6.9.3",
|
||||||
"prismjs": "^1.29.0"
|
"prismjs": "^1.29.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
|
Loading…
Reference in New Issue
Block a user