mirror of
https://github.com/ocogeclub/ocoge.git
synced 2024-11-24 08:29:48 +00:00
[update] GPIOライブラリを pigpio から lgpio へ変更
This commit is contained in:
parent
bb0db8b9eb
commit
3984b9bfdd
@ -1,10 +0,0 @@
|
|||||||
(async () => {
|
|
||||||
var _E7_95_AA_E5_8F_B7;
|
|
||||||
|
|
||||||
|
|
||||||
for (_E7_95_AA_E5_8F_B7 = 3; _E7_95_AA_E5_8F_B7 >= 1; _E7_95_AA_E5_8F_B7 -= 1) {
|
|
||||||
console.log(_E7_95_AA_E5_8F_B7);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
})();
|
|
64
index.html
64
index.html
@ -290,9 +290,9 @@
|
|||||||
<sep></sep>
|
<sep></sep>
|
||||||
<category name="GPIO" css-icon="customIcon fab fa-raspberry-pi" categorystyle="gpio_category">
|
<category name="GPIO" css-icon="customIcon fab fa-raspberry-pi" categorystyle="gpio_category">
|
||||||
<label text="基本"></label>
|
<label text="基本"></label>
|
||||||
<block type="ugj_gpio_start"></block>
|
<block type="ugj_gpiochip_open"></block>
|
||||||
<block type="ugj_gpio_stop"></block>
|
<block type="ugj_gpiochip_close"></block>
|
||||||
<block type="ugj_gpio_setoutput">
|
<block type="ugj_gpio_claim_output">
|
||||||
<value name="gpio">
|
<value name="gpio">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">5</field>
|
<field name="NUM">5</field>
|
||||||
@ -300,19 +300,15 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_gpio_write">
|
<block type="ugj_gpio_write">
|
||||||
<value name="ugj_gpio_num">
|
<value name="gpio">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">5</field>
|
<field name="NUM">5</field>
|
||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
<value name="ugj_gpio_value">
|
<field name="level">1</field>
|
||||||
<shadow type="math_number">
|
|
||||||
<field name="NUM">1</field>
|
|
||||||
</shadow>
|
|
||||||
</value>
|
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_gpio_setinput">
|
<block type="ugj_gpio_claim_input">
|
||||||
<field name="updown">pi.PUD_DOWN</field>
|
<field name="lflag">pi.SET_PULL_DOWN</field>
|
||||||
<value name="gpio">
|
<value name="gpio">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">6</field>
|
<field name="NUM">6</field>
|
||||||
@ -327,27 +323,24 @@
|
|||||||
</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_gpio_setpwmfreqrange">
|
<block type="ugj_tx_pwm">
|
||||||
<field name="pwmfreq">50</field>
|
|
||||||
<value name="gpio">
|
<value name="gpio">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">5</field>
|
<field name="NUM">5</field>
|
||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
<value name="pwm_frequency">
|
||||||
<block type="ugj_gpio_setpwmdutycycle">
|
|
||||||
<value name="dutycycle">
|
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">0</field>
|
<field name="NUM">50</field>
|
||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
<value name="gpio">
|
<value name="pwm_duty_cycle">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">5</field>
|
<field name="NUM">30</field>
|
||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_gpio_servo">
|
<block type="ugj_tx_servo">
|
||||||
<value name="gpio">
|
<value name="gpio">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">12</field>
|
<field name="NUM">12</field>
|
||||||
@ -360,7 +353,7 @@
|
|||||||
</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_openclose">
|
<block type="ugj_serial_open">
|
||||||
<field name="baud">9600</field>
|
<field name="baud">9600</field>
|
||||||
<value name="tty">
|
<value name="tty">
|
||||||
<shadow type="text">
|
<shadow type="text">
|
||||||
@ -368,7 +361,8 @@
|
|||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<block type="ugj_gpio_serialread">
|
<block type="ugj_serial_close"></block>
|
||||||
|
<block type="ugj_serial_read">
|
||||||
<value name="count">
|
<value name="count">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">1</field>
|
<field name="NUM">1</field>
|
||||||
@ -391,27 +385,27 @@
|
|||||||
</value>
|
</value>
|
||||||
</block>
|
</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_gpio_i2copen">
|
<block type="ugj_i2c_open">
|
||||||
<value name="i2c_addr">
|
<value name="i2c_address">
|
||||||
<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_gpio_i2cclose"></block>
|
<block type="ugj_i2c_close"></block>
|
||||||
<block type="ugj_gpio_i2cwritebyte">
|
<block type="ugj_i2c_write_byte_data">
|
||||||
<value name="reg">
|
<value name="reg">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">0</field>
|
<field name="NUM">0</field>
|
||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
<value name="byteData">
|
<value name="byte_val">
|
||||||
<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_gpio_i2creadbyte">
|
<block type="ugj_i2c_read_byte_data">
|
||||||
<value name="reg">
|
<value name="reg">
|
||||||
<shadow type="math_number">
|
<shadow type="math_number">
|
||||||
<field name="NUM">0</field>
|
<field name="NUM">0</field>
|
||||||
@ -420,12 +414,6 @@
|
|||||||
</block>
|
</block>
|
||||||
<label text="センサー" web-line="4.0" web-line-width="200"></label>
|
<label text="センサー" web-line="4.0" web-line-width="200"></label>
|
||||||
<label text="Extra" web-line="4.0" web-line-width="200"></label>
|
<label text="Extra" web-line="4.0" web-line-width="200"></label>
|
||||||
<block type="ugj_gpio_start_remote">
|
|
||||||
<field name="host"></field>
|
|
||||||
</block>
|
|
||||||
<block type="ugj_gpio_sleep">
|
|
||||||
<field name="sec">1</field>
|
|
||||||
</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-gamepad" categorystyle="multimedia_category">
|
<category name="マルチメディア" css-icon="customIcon fas fa-gamepad" categorystyle="multimedia_category">
|
||||||
@ -599,14 +587,6 @@
|
|||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
<label text="リモートGPIO" web-line="4.0" web-line-width="200"></label>
|
|
||||||
<block type="ugj_gpio_start_remote">
|
|
||||||
<value name="host">
|
|
||||||
<shadow type="text">
|
|
||||||
<field name="TEXT">192.168.0.229</field>
|
|
||||||
</shadow>
|
|
||||||
</value>
|
|
||||||
</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_library_load">
|
<block type="ugj_library_load">
|
||||||
<value name="lib">
|
<value name="lib">
|
||||||
|
@ -4,10 +4,8 @@
|
|||||||
# install node.js (=electron node version) via n (https://github.com/tj/n)
|
# install node.js (=electron node version) via n (https://github.com/tj/n)
|
||||||
curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n
|
curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n
|
||||||
sudo bash n 14.16.0
|
sudo bash n 14.16.0
|
||||||
# Install latest version of n via npm globally
|
|
||||||
# sudo npm install -g n
|
|
||||||
# install python code formatter
|
# install python code formatter
|
||||||
python3 -m pip install yapf
|
python3 -m pip install black
|
||||||
# install desktop entry
|
# install desktop entry
|
||||||
cp -r ./files/share ~/.local/
|
cp -r ./files/share ~/.local/
|
||||||
# install binary files if exists
|
# install binary files if exists
|
||||||
@ -19,8 +17,8 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# build ocoge
|
# build ocoge
|
||||||
# prepare for installation electron
|
# uncomment if electron will be installed on RPi OS
|
||||||
echo 'arch=armv7l' > ~/.npmrc
|
# echo 'arch=armv7l' > ~/.npmrc
|
||||||
cd ..
|
cd ..
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{ "targets":
|
{ "targets":
|
||||||
[ { "target_name" : "ocoge_pigpiod"
|
[ { "target_name" : "ocoge_lgpio"
|
||||||
, "sources" : [ "ocoge_pigpiod.cpp" ]
|
, "sources" : [ "ocoge_lgpio.cpp" ]
|
||||||
, "defines" : [ "NAPI_DISABLE_CPP_EXCEPTIONS" ]
|
, "defines" : [ "NAPI_DISABLE_CPP_EXCEPTIONS" ]
|
||||||
, "include_dirs" : [ "<!@(node -p \"require( 'node-addon-api' ).include\")" ]
|
, "include_dirs" : [ "<!@(node -p \"require( 'node-addon-api' ).include\")" ]
|
||||||
, "dependencies" : ["<!(node -p \"require('node-addon-api').gyp\")"]
|
, "dependencies" : ["<!(node -p \"require('node-addon-api').gyp\")"]
|
||||||
, "libraries" : [ "-lpigpiod_if2", "-lrt" ]
|
, "libraries" : [ "-llgpio" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
8
local_modules/ocoge_lgpio/index.js
Normal file
8
local_modules/ocoge_lgpio/index.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module.exports = require('bindings')('ocoge_lgpio');
|
||||||
|
|
||||||
|
module.exports.SET_ACTIVE_LOW = 4;
|
||||||
|
module.exports.SET_OPEN_DRAIN = 8;
|
||||||
|
module.exports.SET_OPEN_SOURCE = 16;
|
||||||
|
module.exports.SET_PULL_UP = 32;
|
||||||
|
module.exports.SET_PULL_DOWN = 64;
|
||||||
|
module.exports.SET_PULL_NONE = 128;
|
@ -1,16 +1,15 @@
|
|||||||
/** PIGPIO デーモンを Node.js から利用するモジュール ** */
|
/** lgpio を Node.js から利用するモジュール ** */
|
||||||
/** 関数名・書式は Python Interface に準拠 ******************* */
|
/** 関数名・書式は lgpio Python に準拠 ******************* */
|
||||||
|
|
||||||
#include <napi.h>
|
#include <napi.h>
|
||||||
#include <pigpiod_if2.h>
|
#include <lgpio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace Napi;
|
using namespace Napi;
|
||||||
|
|
||||||
int pi = 0;
|
// gpiochipデバイスを開く
|
||||||
|
Value gpiochipOpen(const CallbackInfo& info)
|
||||||
Value Usleep(const CallbackInfo& info)
|
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
if (info.Length() < 1)
|
if (info.Length() < 1)
|
||||||
@ -24,78 +23,12 @@ Value Usleep(const CallbackInfo& info)
|
|||||||
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
||||||
return env.Null();
|
return env.Null();
|
||||||
}
|
}
|
||||||
|
unsigned int gpioDev = info[0].As<Number>().DoubleValue();
|
||||||
usleep(info[0].As<Number>().DoubleValue());
|
return Number::New(env, lgGpiochipOpen(gpioDev));
|
||||||
|
|
||||||
return env.Null();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gpiochipデバイスを閉じる
|
||||||
// pigpio 初期化
|
Value gpiochipClose(const CallbackInfo& info)
|
||||||
Value Start(const CallbackInfo& info)
|
|
||||||
{
|
|
||||||
Env env = info.Env();
|
|
||||||
pi = pigpio_start(0, 0);
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
// リモート
|
|
||||||
Value StartRemote(const CallbackInfo& info)
|
|
||||||
{
|
|
||||||
Env env = info.Env();
|
|
||||||
if (info.Length() < 2)
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong number of arguments")
|
|
||||||
.ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
if (!info[0].IsString() || !info[1].IsString())
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string addrStr = info[0].As<String>().Utf8Value();
|
|
||||||
std::string portStr = info[1].As<String>().Utf8Value();
|
|
||||||
|
|
||||||
pi = pigpio_start(&addrStr[0], &portStr[0]);
|
|
||||||
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
|
|
||||||
// pigpio 後始末
|
|
||||||
Value Stop(const CallbackInfo& info)
|
|
||||||
{
|
|
||||||
Env env = info.Env();
|
|
||||||
pigpio_stop(pi);
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
|
|
||||||
// GPIO 端子のモードを設定
|
|
||||||
Value SetMode(const CallbackInfo& info)
|
|
||||||
{
|
|
||||||
Env env = info.Env();
|
|
||||||
if (info.Length() < 2)
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong number of arguments")
|
|
||||||
.ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
if (!info[0].IsNumber() || !info[1].IsNumber())
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int gpio = info[0].As<Number>().DoubleValue();
|
|
||||||
unsigned int mode = info[1].As<Number>().DoubleValue();
|
|
||||||
|
|
||||||
return Number::New(env,
|
|
||||||
set_mode(pi, gpio, mode)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GPIO 端子のモードを取得
|
|
||||||
Value GetMode(const CallbackInfo& info)
|
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
if (info.Length() < 1)
|
if (info.Length() < 1)
|
||||||
@ -109,16 +42,12 @@ Value GetMode(const CallbackInfo& info)
|
|||||||
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
||||||
return env.Null();
|
return env.Null();
|
||||||
}
|
}
|
||||||
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
unsigned int gpio = info[0].As<Number>().DoubleValue();
|
return Number::New(env, lgGpiochipClose(handle));
|
||||||
|
|
||||||
return Number::New(env,
|
|
||||||
get_mode(pi, gpio)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GPIOの内部プルアップ/ダウン抵抗の設定/クリア
|
// GPIO のモードを出力にする(ことを要求?)
|
||||||
Value SetPullUpDown(const CallbackInfo& info)
|
Value gpioClaimOutput(const CallbackInfo& info)
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
if (info.Length() < 2)
|
if (info.Length() < 2)
|
||||||
@ -133,160 +62,16 @@ Value SetPullUpDown(const CallbackInfo& info)
|
|||||||
return env.Null();
|
return env.Null();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int gpio = info[0].As<Number>().DoubleValue();
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
unsigned int pud = info[1].As<Number>().DoubleValue();
|
unsigned int gpio = info[1].As<Number>().DoubleValue();
|
||||||
|
|
||||||
return Number::New(env,
|
return Number::New(env,
|
||||||
set_pull_up_down(pi, gpio, pud)
|
lgGpioClaimOutput(handle, 0, gpio, 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GPIOの電圧を読む
|
// GPIO のモードを入力にする(ことを要求?)
|
||||||
Value Read(const CallbackInfo& info)
|
Value gpioClaimInput(const CallbackInfo& info)
|
||||||
{
|
|
||||||
Env env = info.Env();
|
|
||||||
if (info.Length() < 1)
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong number of arguments")
|
|
||||||
.ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
if (!info[0].IsNumber())
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int gpio = info[0].As<Number>().DoubleValue();
|
|
||||||
|
|
||||||
return Number::New(env,
|
|
||||||
gpio_read(pi, gpio)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GPIO の電圧をセットする
|
|
||||||
Value Write(const CallbackInfo& info)
|
|
||||||
{
|
|
||||||
Env env = info.Env();
|
|
||||||
if (info.Length() < 2)
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong number of arguments")
|
|
||||||
.ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
if (!info[0].IsNumber() || !info[1].IsNumber())
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int gpio = info[0].As<Number>().DoubleValue();
|
|
||||||
unsigned int value = info[1].As<Number>().DoubleValue();
|
|
||||||
|
|
||||||
return Number::New(env,
|
|
||||||
gpio_write(pi, gpio, value)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// サーボパルス幅をセットする
|
|
||||||
Value SetServoPulsewidth(const CallbackInfo& info)
|
|
||||||
{
|
|
||||||
Env env = info.Env();
|
|
||||||
if (info.Length() < 2)
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong number of arguments")
|
|
||||||
.ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
if (!info[0].IsNumber() || !info[1].IsNumber())
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int user_gpio = info[0].As<Number>().DoubleValue();
|
|
||||||
unsigned int pulsewidth = info[1].As<Number>().DoubleValue();
|
|
||||||
|
|
||||||
return Number::New(env,
|
|
||||||
set_servo_pulsewidth(pi, user_gpio, pulsewidth)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// PWM周波数を設定する
|
|
||||||
Value SetPwmFrequency(const CallbackInfo& info)
|
|
||||||
{
|
|
||||||
Env env = info.Env();
|
|
||||||
if (info.Length() < 2)
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong number of arguments")
|
|
||||||
.ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
if (!info[0].IsNumber() || !info[1].IsNumber())
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int user_gpio = info[0].As<Number>().DoubleValue();
|
|
||||||
unsigned int frequency = info[1].As<Number>().DoubleValue();
|
|
||||||
|
|
||||||
return Number::New(env,
|
|
||||||
set_PWM_frequency(pi, user_gpio, frequency)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// PWMのレンジを設定する
|
|
||||||
Value SetPwmRange(const CallbackInfo& info)
|
|
||||||
{
|
|
||||||
Env env = info.Env();
|
|
||||||
if (info.Length() < 2)
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong number of arguments")
|
|
||||||
.ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
if (!info[0].IsNumber() || !info[1].IsNumber())
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int user_gpio = info[0].As<Number>().DoubleValue();
|
|
||||||
unsigned int range = info[1].As<Number>().DoubleValue();
|
|
||||||
|
|
||||||
return Number::New(env,
|
|
||||||
set_PWM_range(pi, user_gpio, range)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// PWMのデューティ比を指定して出力を開始する
|
|
||||||
Value SetPwmDutycycle(const CallbackInfo& info)
|
|
||||||
{
|
|
||||||
Env env = info.Env();
|
|
||||||
if (info.Length() < 2)
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong number of arguments")
|
|
||||||
.ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
if (!info[0].IsNumber() || !info[1].IsNumber())
|
|
||||||
{
|
|
||||||
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
|
||||||
return env.Null();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int user_gpio = info[0].As<Number>().DoubleValue();
|
|
||||||
unsigned int dutycycle = info[1].As<Number>().DoubleValue();
|
|
||||||
|
|
||||||
return Number::New(env,
|
|
||||||
set_PWM_dutycycle(pi, user_gpio, dutycycle)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// シリアルポートを開く
|
|
||||||
Value SerialOpen(const CallbackInfo& info)
|
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
if (info.Length() < 3)
|
if (info.Length() < 3)
|
||||||
@ -295,27 +80,152 @@ Value SerialOpen(const CallbackInfo& info)
|
|||||||
.ThrowAsJavaScriptException();
|
.ThrowAsJavaScriptException();
|
||||||
return env.Null();
|
return env.Null();
|
||||||
}
|
}
|
||||||
if (!info[0].IsString() || !info[1].IsNumber() || !info[2].IsNumber())
|
if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
||||||
{
|
{
|
||||||
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
||||||
return env.Null();
|
return env.Null();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ser_tty = info[0].As<String>().Utf8Value();
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
|
unsigned int gpio = info[1].As<Number>().DoubleValue();
|
||||||
|
unsigned int lflag = info[2].As<Number>().DoubleValue();
|
||||||
|
|
||||||
|
return Number::New(env,
|
||||||
|
lgGpioClaimInput(handle, lflag, gpio)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GPIOの電圧を読む
|
||||||
|
Value gpioRead(const CallbackInfo& info)
|
||||||
|
{
|
||||||
|
Env env = info.Env();
|
||||||
|
if (info.Length() < 2)
|
||||||
|
{
|
||||||
|
TypeError::New(env, "Wrong number of arguments")
|
||||||
|
.ThrowAsJavaScriptException();
|
||||||
|
return env.Null();
|
||||||
|
}
|
||||||
|
if (!info[0].IsNumber() || !info[1].IsNumber())
|
||||||
|
{
|
||||||
|
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
||||||
|
return env.Null();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
|
unsigned int gpio = info[1].As<Number>().DoubleValue();
|
||||||
|
|
||||||
|
return Number::New(env,
|
||||||
|
lgGpioRead(handle, gpio)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GPIO の電圧をセットする
|
||||||
|
Value gpioWrite(const CallbackInfo& info)
|
||||||
|
{
|
||||||
|
Env env = info.Env();
|
||||||
|
if (info.Length() < 3)
|
||||||
|
{
|
||||||
|
TypeError::New(env, "Wrong number of arguments")
|
||||||
|
.ThrowAsJavaScriptException();
|
||||||
|
return env.Null();
|
||||||
|
}
|
||||||
|
if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
||||||
|
{
|
||||||
|
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
||||||
|
return env.Null();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
|
unsigned int gpio = info[1].As<Number>().DoubleValue();
|
||||||
|
unsigned int level = info[2].As<Number>().DoubleValue();
|
||||||
|
|
||||||
|
return Number::New(env,
|
||||||
|
lgGpioWrite(handle, gpio, level)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// サーボパルス幅をセットする
|
||||||
|
Value txServo(const CallbackInfo& info)
|
||||||
|
{
|
||||||
|
Env env = info.Env();
|
||||||
|
if (info.Length() < 3)
|
||||||
|
{
|
||||||
|
TypeError::New(env, "Wrong number of arguments")
|
||||||
|
.ThrowAsJavaScriptException();
|
||||||
|
return env.Null();
|
||||||
|
}
|
||||||
|
if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
||||||
|
{
|
||||||
|
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
||||||
|
return env.Null();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
|
unsigned int gpio = info[1].As<Number>().DoubleValue();
|
||||||
|
unsigned int pulseWidth = info[2].As<Number>().DoubleValue();
|
||||||
|
|
||||||
|
return Number::New(env,
|
||||||
|
lgTxServo(handle, gpio, pulseWidth, 50, 0, 0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// PWMを設定して出力
|
||||||
|
Value txPwm(const CallbackInfo& info)
|
||||||
|
{
|
||||||
|
Env env = info.Env();
|
||||||
|
if (info.Length() < 4)
|
||||||
|
{
|
||||||
|
TypeError::New(env, "Wrong number of arguments")
|
||||||
|
.ThrowAsJavaScriptException();
|
||||||
|
return env.Null();
|
||||||
|
}
|
||||||
|
if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber() || !info[3].IsNumber())
|
||||||
|
{
|
||||||
|
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
||||||
|
return env.Null();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
|
unsigned int gpio = info[1].As<Number>().DoubleValue();
|
||||||
|
unsigned int pwmFrequency = info[2].As<Number>().DoubleValue();
|
||||||
|
unsigned int pwmDutyCycle = info[3].As<Number>().DoubleValue();
|
||||||
|
|
||||||
|
return Number::New(env,
|
||||||
|
lgTxPwm(handle, gpio, pwmFrequency, pwmDutyCycle, 0,0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// シリアルポートを開く
|
||||||
|
Value serialOpen(const CallbackInfo& info)
|
||||||
|
{
|
||||||
|
Env env = info.Env();
|
||||||
|
if (info.Length() < 2)
|
||||||
|
{
|
||||||
|
TypeError::New(env, "Wrong number of arguments")
|
||||||
|
.ThrowAsJavaScriptException();
|
||||||
|
return env.Null();
|
||||||
|
}
|
||||||
|
if (!info[0].IsString() || !info[1].IsNumber())
|
||||||
|
{
|
||||||
|
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
||||||
|
return env.Null();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string tty = info[0].As<String>().Utf8Value();
|
||||||
// char *c = new char[ser_tty.size()+1];
|
// char *c = new char[ser_tty.size()+1];
|
||||||
// std::strcpy(c, ser_tty.c_str());
|
// std::strcpy(c, ser_tty.c_str());
|
||||||
// &ser_tty[0] で参照できるらしいけど危険?
|
// &ser_tty[0] で参照できるらしいけど危険?
|
||||||
|
|
||||||
unsigned int baud = info[1].As<Number>().DoubleValue();
|
unsigned int baud = info[1].As<Number>().DoubleValue();
|
||||||
unsigned int ser_flags = info[2].As<Number>().DoubleValue();
|
|
||||||
|
|
||||||
return Number::New(env,
|
return Number::New(env,
|
||||||
serial_open(pi, &ser_tty[0], baud, ser_flags)
|
lgSerialOpen(&tty[0], baud, 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// シリアルポートを閉じる
|
// シリアルポートを閉じる
|
||||||
Value SerialClose(const CallbackInfo& info)
|
Value serialClose(const CallbackInfo& info)
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
if (info.Length() < 1)
|
if (info.Length() < 1)
|
||||||
@ -333,11 +243,11 @@ Value SerialClose(const CallbackInfo& info)
|
|||||||
unsigned int handle = info[0].As<Number>().DoubleValue();
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
|
|
||||||
return Number::New(env,
|
return Number::New(env,
|
||||||
serial_close(pi, handle)
|
lgSerialClose(handle)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// シリアルデバイスからデータを読む
|
// シリアルデバイスからデータを受け取る
|
||||||
Value SerialRead(const CallbackInfo& info)
|
Value SerialRead(const CallbackInfo& info)
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
@ -355,19 +265,19 @@ Value SerialRead(const CallbackInfo& info)
|
|||||||
|
|
||||||
unsigned int handle = info[0].As<Number>().DoubleValue();
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
unsigned int count = info[1].As<Number>().DoubleValue();
|
unsigned int count = info[1].As<Number>().DoubleValue();
|
||||||
char buf[count+1];
|
char rxBuf[count+1];
|
||||||
for (unsigned int i = 0; i <= count; i++)
|
for (unsigned int i = 0; i <= count; i++)
|
||||||
{
|
{
|
||||||
buf[i] = 0;
|
rxBuf[i] = 0;
|
||||||
}
|
}
|
||||||
serial_read(pi, handle, buf, count);
|
lgSerialRead(handle, rxBuf, count);
|
||||||
return String::New(env,
|
return String::New(env,
|
||||||
buf
|
rxBuf
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// シリアルデバイスにバイト列を書き込む(data: string)
|
// シリアルデバイスにバイト列を送る(data: string)
|
||||||
Value SerialWrite(const CallbackInfo& info)
|
Value serialWrite(const CallbackInfo& info)
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
if (info.Length() < 2)
|
if (info.Length() < 2)
|
||||||
@ -383,42 +293,41 @@ Value SerialWrite(const CallbackInfo& info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int handle = info[0].As<Number>().DoubleValue();
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
std::string buf = info[1].As<String>().Utf8Value();
|
std::string txBuf = info[1].As<String>().Utf8Value();
|
||||||
|
|
||||||
unsigned int count = buf.length();
|
unsigned int count = txBuf.length();
|
||||||
|
|
||||||
return Number::New(env,
|
return Number::New(env,
|
||||||
serial_write(pi, handle, &buf[0], count)
|
lgSerialWrite(handle, &txBuf[0], count)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// I2Cバスアドレスのデバイスのハンドルを返す
|
// I2Cバスアドレスのデバイスのハンドルを返す
|
||||||
Value I2cOpen(const CallbackInfo& info)
|
Value i2cOpen(const CallbackInfo& info)
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
if (info.Length() < 3)
|
if (info.Length() < 2)
|
||||||
{
|
{
|
||||||
TypeError::New(env, "Wrong number of arguments")
|
TypeError::New(env, "Wrong number of arguments")
|
||||||
.ThrowAsJavaScriptException();
|
.ThrowAsJavaScriptException();
|
||||||
return env.Null();
|
return env.Null();
|
||||||
}
|
}
|
||||||
if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber())
|
if (!info[0].IsNumber() || !info[1].IsNumber())
|
||||||
{
|
{
|
||||||
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
|
||||||
return env.Null();
|
return env.Null();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int i2c_bus = info[0].As<Number>().DoubleValue();
|
unsigned int i2cDev = info[0].As<Number>().DoubleValue();
|
||||||
unsigned int i2c_addr = info[1].As<Number>().DoubleValue();
|
unsigned int i2cAddr = info[1].As<Number>().DoubleValue();
|
||||||
unsigned int i2c_flags = info[2].As<Number>().DoubleValue();
|
|
||||||
|
|
||||||
return Number::New(env,
|
return Number::New(env,
|
||||||
i2c_open(pi, i2c_bus, i2c_addr, i2c_flags)
|
lgI2cOpen(i2cDev, i2cAddr, 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// オープン済みI2Cハンドルを閉じる
|
// オープン済みI2Cハンドルを閉じる
|
||||||
Value I2cClose(const CallbackInfo& info)
|
Value i2cClose(const CallbackInfo& info)
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
if (info.Length() < 1)
|
if (info.Length() < 1)
|
||||||
@ -436,12 +345,12 @@ Value I2cClose(const CallbackInfo& info)
|
|||||||
unsigned int handle = info[0].As<Number>().DoubleValue();
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
|
|
||||||
return Number::New(env,
|
return Number::New(env,
|
||||||
i2c_close(pi, handle)
|
lgI2cClose(handle)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// I2Cハンドルに関連付けられているデバイスの指定されたレジスタに1バイトを書き込む
|
// I2Cハンドルに関連付けられているデバイスの指定されたレジスタに1バイトを書き込む
|
||||||
Value I2cWriteByteData(const CallbackInfo& info)
|
Value i2cWriteByteData(const CallbackInfo& info)
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
if (info.Length() < 3)
|
if (info.Length() < 3)
|
||||||
@ -457,16 +366,16 @@ Value I2cWriteByteData(const CallbackInfo& info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int handle = info[0].As<Number>().DoubleValue();
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
unsigned int i2c_reg = info[1].As<Number>().DoubleValue();
|
unsigned int i2cReg = info[1].As<Number>().DoubleValue();
|
||||||
unsigned int bVal = info[2].As<Number>().DoubleValue();
|
unsigned int byteVal = info[2].As<Number>().DoubleValue();
|
||||||
|
|
||||||
return Number::New(env,
|
return Number::New(env,
|
||||||
i2c_write_byte_data(pi, handle, i2c_reg, bVal)
|
lgI2cWriteByteData(handle, i2cReg, byteVal)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// I2Cハンドルに関連付けられているデバイスの指定されたレジスタから1バイトを読み込む
|
// I2Cハンドルに関連付けられているデバイスの指定されたレジスタから1バイトを読み込む
|
||||||
Value I2cReadByteData(const CallbackInfo& info)
|
Value i2cReadByteData(const CallbackInfo& info)
|
||||||
{
|
{
|
||||||
Env env = info.Env();
|
Env env = info.Env();
|
||||||
if (info.Length() < 2)
|
if (info.Length() < 2)
|
||||||
@ -482,13 +391,13 @@ Value I2cReadByteData(const CallbackInfo& info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int handle = info[0].As<Number>().DoubleValue();
|
unsigned int handle = info[0].As<Number>().DoubleValue();
|
||||||
unsigned int i2c_reg = info[1].As<Number>().DoubleValue();
|
unsigned int i2cReg = info[1].As<Number>().DoubleValue();
|
||||||
|
|
||||||
return Number::New(env,
|
return Number::New(env,
|
||||||
i2c_read_byte_data(pi, handle, i2c_reg)
|
lgI2cReadByteData(handle, i2cReg)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
// I2Cハンドルに関連付けられているデバイスの指定されたレジスタから単一の16ビットワードを読み取る
|
// I2Cハンドルに関連付けられているデバイスの指定されたレジスタから単一の16ビットワードを読み取る
|
||||||
Value I2cReadWordData(const CallbackInfo& info)
|
Value I2cReadWordData(const CallbackInfo& info)
|
||||||
{
|
{
|
||||||
@ -512,33 +421,30 @@ Value I2cReadWordData(const CallbackInfo& info)
|
|||||||
i2c_read_word_data(pi, handle, i2c_reg)
|
i2c_read_word_data(pi, handle, i2c_reg)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
Object
|
Object
|
||||||
Init(Env env, Object exports)
|
Init(Env env, Object exports)
|
||||||
{
|
{
|
||||||
exports.Set(String::New(env, "usleep"), Function::New(env, Usleep));
|
exports.Set(String::New(env, "gpiochip_open"), Function::New(env, gpiochipOpen));
|
||||||
exports.Set(String::New(env, "start"), Function::New(env, Start));
|
exports.Set(String::New(env, "gpiochip_close"), Function::New(env, gpiochipClose));
|
||||||
exports.Set(String::New(env, "start_remote"), Function::New(env, StartRemote));
|
exports.Set(String::New(env, "gpio_claim_input"), Function::New(env, gpioClaimInput));
|
||||||
exports.Set(String::New(env, "stop"), Function::New(env, Stop));
|
exports.Set(String::New(env, "gpio_claim_output"), Function::New(env, gpioClaimOutput));
|
||||||
exports.Set(String::New(env, "set_mode"), Function::New(env, SetMode));
|
exports.Set(String::New(env, "gpio_read"), Function::New(env, gpioRead));
|
||||||
exports.Set(String::New(env, "get_mode"), Function::New(env, GetMode));
|
exports.Set(String::New(env, "gpio_write"), Function::New(env, gpioWrite));
|
||||||
exports.Set(String::New(env, "set_pull_up_down"), Function::New(env, SetPullUpDown));
|
exports.Set(String::New(env, "tx_servo"), Function::New(env, txServo));
|
||||||
exports.Set(String::New(env, "read"), Function::New(env, Read));
|
exports.Set(String::New(env, "tx_pwm"), Function::New(env, txPwm));
|
||||||
exports.Set(String::New(env, "write"), Function::New(env, Write));
|
exports.Set(String::New(env, "serial_open"), Function::New(env, serialOpen));
|
||||||
exports.Set(String::New(env, "set_servo_pulsewidth"), Function::New(env, SetServoPulsewidth));
|
exports.Set(String::New(env, "serial_close"), Function::New(env, serialClose));
|
||||||
exports.Set(String::New(env, "set_PWM_frequency"), Function::New(env, SetPwmFrequency));
|
|
||||||
exports.Set(String::New(env, "set_PWM_range"), Function::New(env, SetPwmRange));
|
|
||||||
exports.Set(String::New(env, "set_PWM_dutycycle"), Function::New(env, SetPwmDutycycle));
|
|
||||||
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_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, "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_data"), Function::New(env, I2cWriteByteData));
|
exports.Set(String::New(env, "i2c_write_byte_data"), Function::New(env, i2cWriteByteData));
|
||||||
exports.Set(String::New(env, "i2c_read_byte_data"), Function::New(env, I2cReadByteData));
|
exports.Set(String::New(env, "i2c_read_byte_data"), Function::New(env, i2cReadByteData));
|
||||||
exports.Set(String::New(env, "i2c_read_word_data"), Function::New(env, I2cReadWordData));
|
|
||||||
|
// exports.Set(String::New(env, "i2c_read_word_data"), Function::New(env, I2cReadWordData));
|
||||||
|
|
||||||
return exports;
|
return exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
NODE_API_MODULE( ocoge_pigpiod, Init )
|
NODE_API_MODULE( ocoge_lgpio, Init )
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "ocoge_pigpiod",
|
"name": "ocoge_lgpio",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"private": true,
|
"private": true,
|
@ -1,7 +0,0 @@
|
|||||||
module.exports = require('bindings')('ocoge_pigpiod');
|
|
||||||
|
|
||||||
module.exports.INPUT = 0;
|
|
||||||
module.exports.OUTPUT = 1;
|
|
||||||
module.exports.PUD_OFF = 0;
|
|
||||||
module.exports.PUD_DOWN = 1;
|
|
||||||
module.exports.PUD_UP = 2;
|
|
48
package-lock.json
generated
48
package-lock.json
generated
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "ocoge",
|
"name": "ocoge",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@electron/get": {
|
"@electron/get": {
|
||||||
"version": "1.12.4",
|
"version": "1.13.0",
|
||||||
"resolved": "https://registry.npmjs.org/@electron/get/-/get-1.12.4.tgz",
|
"resolved": "https://registry.npmjs.org/@electron/get/-/get-1.13.0.tgz",
|
||||||
"integrity": "sha512-6nr9DbJPUR9Xujw6zD3y+rS95TyItEVM0NVjt1EehY2vUWfIgPiIPVHxCvaTS0xr2B+DRxovYVKbuOWqC35kjg==",
|
"integrity": "sha512-+SjZhRuRo+STTO1Fdhzqnv9D2ZhjxXP6egsJ9kiO8dtP68cDx7dFCwWi64dlMQV7sWcfW1OYCW4wviEBzmRsfQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
@ -237,9 +237,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"boolean": {
|
"boolean": {
|
||||||
"version": "3.0.4",
|
"version": "3.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/boolean/-/boolean-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/boolean/-/boolean-3.1.4.tgz",
|
||||||
"integrity": "sha512-5pyOr+w2LNN72F2mAq6J0ckHUfJYSgRKma7e/wlcMMhgOLV9OI0ERhERYXxUqo+dPyVxcbXKy9n+wg13+LpNnA==",
|
"integrity": "sha512-3hx0kwU3uzG6ReQ3pnaFQPSktpBw6RHN3/ivDKEuU8g1XSfafowyvDnadjv1xp8IZqhtSukxlwv9bF6FhX8m0w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
@ -270,9 +270,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"buffer-from": {
|
"buffer-from": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
||||||
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
|
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"cacheable-lookup": {
|
"cacheable-lookup": {
|
||||||
@ -465,9 +465,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config-chain": {
|
"config-chain": {
|
||||||
"version": "1.1.12",
|
"version": "1.1.13",
|
||||||
"resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.12.tgz",
|
"resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz",
|
||||||
"integrity": "sha512-a1eOIcu8+7lUInge4Rpf/n4Krkf3Dd9lqhljRzII1/Zno/kRtUWnznPO3jOKBmTEktkt3fkxisUcivoj0ebzoA==",
|
"integrity": "sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -482,9 +482,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"core-js": {
|
"core-js": {
|
||||||
"version": "3.12.1",
|
"version": "3.16.3",
|
||||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.12.1.tgz",
|
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.16.3.tgz",
|
||||||
"integrity": "sha512-Ne9DKPHTObRuB09Dru5AjwKjY4cJHVGu+y5f7coGn1E9Grkc3p2iBwE9AI/nJzsE29mQF7oq+mhYYRqOMFN1Bw==",
|
"integrity": "sha512-lM3GftxzHNtPNUJg0v4pC2RC6puwMd6VZA7vXUczi+SKmCWSf4JwO89VJGMqbzmB7jlK7B5hr3S64PqwFL49cA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
@ -605,9 +605,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"electron": {
|
"electron": {
|
||||||
"version": "12.0.8",
|
"version": "13.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-12.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/electron/-/electron-13.2.3.tgz",
|
||||||
"integrity": "sha512-bN2wYNnnma7ugBsiwysO1LI6oTTV1lDHOXuWip+OGjDUiz0IiJmZ+r0gAIMMeypVohZh7AA1ftnKad7tJ8sH4A==",
|
"integrity": "sha512-FzWhbKHjq7ZTpPQFaYiLPL64erC8/BOsu5NlNN9nQ6f7rIP8ygKlNAlQit3vbOcksQAwItDUCIw4sW0mcaRpCA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@electron/get": "^1.0.1",
|
"@electron/get": "^1.0.1",
|
||||||
@ -616,9 +616,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "14.17.0",
|
"version": "14.17.12",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.12.tgz",
|
||||||
"integrity": "sha512-w8VZUN/f7SSbvVReb9SWp6cJFevxb4/nkG65yLAya//98WgocKm5PLDAtSs5CtJJJM+kHmJjO/6mmYW4MHShZA==",
|
"integrity": "sha512-vhUqgjJR1qxwTWV5Ps5txuy2XMdf7Fw+OrdChRboy8BmWUPkckOhphaohzFG6b8DW7CrxaBMdrdJ47SYFq1okw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1651,8 +1651,8 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"ocoge_pigpiod": {
|
"ocoge_lgpio": {
|
||||||
"version": "file:local_modules/ocoge_pigpiod",
|
"version": "file:local_modules/ocoge_lgpio",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bindings": "^1.5.0",
|
"bindings": "^1.5.0",
|
||||||
"node-addon-api": "^1.7.1"
|
"node-addon-api": "^1.7.1"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ocoge",
|
"name": "ocoge",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"description": "\"大岩産 Code Generator\" は、Google Blockly ライブラリを使用した、Raspberry Pi 上で動作するブロックプログラム開発・実行環境です。",
|
"description": "\"大岩産 Code Generator\" は、Google Blockly ライブラリを使用した、Raspberry Pi 上で動作するブロックプログラム開発・実行環境です。",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -19,12 +19,12 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/ocogeclub/ocoge#readme",
|
"homepage": "https://github.com/ocogeclub/ocoge#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "^13.1.5",
|
"electron": "^13.2.2",
|
||||||
"electron-rebuild": "^2.3.5"
|
"electron-rebuild": "^2.3.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"nodemailer": "^6.6.0",
|
"nodemailer": "^6.6.0",
|
||||||
"ocoge_pigpiod": "file:local_modules/ocoge_pigpiod"
|
"ocoge_lgpio": "file:local_modules/ocoge_lgpio"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,507 +146,629 @@ Blockly.Python['ugj_controls_forEach'] = function (block) {
|
|||||||
|
|
||||||
/** GPIO *****************************************************************************************************/
|
/** GPIO *****************************************************************************************************/
|
||||||
|
|
||||||
/************* */
|
/************ */
|
||||||
/** GPIO Start */
|
/** GPIO Open */
|
||||||
/************* */
|
/************ */
|
||||||
var ugjGpioStartDefinition = {
|
var ugjGpiochipOpenDefinition = {
|
||||||
"type": "ugj_gpio_start",
|
"type": "ugj_gpiochip_open",
|
||||||
"message0": "%{BKY_GPIO_START_TITLE}",
|
"message0": "%{BKY_GPIOCHIP_OPEN_TITLE}",
|
||||||
"previousStatement": null,
|
"previousStatement": null,
|
||||||
"nextStatement": null,
|
"nextStatement": null,
|
||||||
"tooltip": "%{BKY_GPIO_START_TOOLTIP}",
|
"tooltip": "%{BKY_GPIOCHIP_OPEN_TOOLTIP}",
|
||||||
"helpUrl": "",
|
"helpUrl": "",
|
||||||
"style": "gpio_blocks"
|
"style": "gpio_blocks"
|
||||||
};
|
};
|
||||||
Blockly.Blocks['ugj_gpio_start'] = {
|
Blockly.Blocks['ugj_gpiochip_open'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.jsonInit(ugjGpioStartDefinition);
|
this.jsonInit(ugjGpiochipOpenDefinition);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_start'] = function (block) {
|
Blockly.JavaScript['ugj_gpiochip_open'] = function (block) {
|
||||||
Blockly.JavaScript.provideFunction_(
|
Blockly.JavaScript.provideFunction_(
|
||||||
'require_ocpig', [`const pi = require('ocoge_pigpiod');\n`]
|
'require_oclg', [`const pi = require('ocoge_lgpio');\n`]
|
||||||
)
|
)
|
||||||
var code = `pi.start();\n`; //
|
var code = `var lgHand = pi.gpiochip_open(0);\n`; //
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
Blockly.Python['ugj_gpio_start'] = function (block) {
|
Blockly.Python['ugj_gpiochip_open'] = function (block) {
|
||||||
Blockly.Python.provideFunction_(
|
Blockly.Python.provideFunction_(
|
||||||
'import_pigpio', ['import pigpio']
|
'import_lgpio', ['import lgpio as pi']
|
||||||
)
|
)
|
||||||
var code = `pi = pigpio.pi()\n`; //
|
var code = `lgHand = pi.gpiochip_open(0)\n`; //
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
// remote gpio
|
|
||||||
var ugjGpioStartRemoteDefinition = {
|
/************* */
|
||||||
"type": "ugj_gpio_start_remote",
|
/** GPIO Close */
|
||||||
"message0": "%{BKY_GPIO_START_REMOTE_TITLE}",
|
/************* */
|
||||||
|
var ugjGpiochipCloseDefinition = {
|
||||||
|
"type": "ugj_gpiochip_close",
|
||||||
|
"message0": "%{BKY_GPIOCHIP_CLOSE_TITLE}",
|
||||||
|
"previousStatement": null,
|
||||||
|
"nextStatement": null,
|
||||||
|
"tooltip": "%{BKY_GPIOCHIP_CLOSE_TOOLTIP}",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
|
Blockly.Blocks['ugj_gpiochip_close'] = {
|
||||||
|
init: function () {
|
||||||
|
this.jsonInit(ugjGpiochipCloseDefinition);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Blockly.JavaScript['ugj_gpiochip_close'] = function (block) {
|
||||||
|
var code = 'pi.gpiochip_close(lgHand);\n';
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
Blockly.Python['ugj_gpiochip_close'] = function (block) {
|
||||||
|
var code = 'pi.gpiochip_close(lgHand)\n';
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*********************** */
|
||||||
|
/** GPIO Claim Output ** */
|
||||||
|
/*********************** */
|
||||||
|
var ugjGpioClaimOutputDefinition = {
|
||||||
|
"type": "ugj_gpio_claim_output",
|
||||||
|
"message0": "%{BKY_GPIO_CLAIM_OUTPUT_TITLE}",
|
||||||
"args0": [
|
"args0": [
|
||||||
{
|
{
|
||||||
"type": "input_value",
|
"type": "input_value",
|
||||||
"name": "host",
|
"name": "gpio",
|
||||||
"check": "String"
|
"check": "Number"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inputsInline": true,
|
"inputsInline": true,
|
||||||
"previousStatement": null,
|
"previousStatement": null,
|
||||||
"nextStatement": null,
|
"nextStatement": null,
|
||||||
"tooltip": "%{BKY_GPIO_START_REMOTE_TOOLTIP}",
|
"tooltip": "%{BKY_GPIO_CLAIM_OUTPUT_TOOLTIP}",
|
||||||
"helpUrl": "",
|
"helpUrl": "",
|
||||||
"style": "gpio_blocks"
|
"style": "gpio_blocks"
|
||||||
};
|
};
|
||||||
Blockly.Blocks['ugj_gpio_start_remote'] = {
|
Blockly.Blocks['ugj_gpio_claim_output'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.jsonInit(ugjGpioStartRemoteDefinition);
|
this.jsonInit(ugjGpioClaimOutputDefinition);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_start_remote'] = function (block) {
|
Blockly.JavaScript['ugj_gpio_claim_output'] = function (block) {
|
||||||
var value_host = Blockly.JavaScript.valueToCode(block, 'host', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var code = `pi.start_remote(${value_host}, '8888');\n`; //
|
var code = `pi.gpio_claim_output(lgHand, ${value_gpio});\n`;
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
Blockly.Python['ugj_gpio_start_remote'] = function (block) {
|
Blockly.Python['ugj_gpio_claim_output'] = function (block) {
|
||||||
Blockly.Python.provideFunction_(
|
var value_gpio = Blockly.Python.valueToCode(block, 'gpio', Blockly.Python.ORDER_ATOMIC);
|
||||||
'import_pigpio', ['import pigpio']
|
var code = `pi.gpio_claim_output(lgHand, ${value_gpio})\n`;
|
||||||
)
|
|
||||||
var value_host = Blockly.Python.valueToCode(block, 'host', Blockly.Python.ORDER_ATOMIC);
|
|
||||||
var code = `pi = pigpio.pi(${value_host}, '8888')\n`;
|
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
/************ */
|
/********************** */
|
||||||
/** GPIO Stop */
|
/** GPIO Claim Input ** */
|
||||||
/************ */
|
/********************** */
|
||||||
var ugjGpioStopDefinition = {
|
var ugjGpioClaimInputDefinition = {
|
||||||
"type": "ugj_gpio_stop",
|
"type": "ugj_gpio_claim_input",
|
||||||
"message0": "%{BKY_GPIO_STOP_TITLE}",
|
"message0": "%{BKY_GPIO_CLAIM_INPUT_TITLE}",
|
||||||
|
"args0": [
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "gpio",
|
||||||
|
"check": "Number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "field_dropdown",
|
||||||
|
"name": "lflag",
|
||||||
|
"options": [
|
||||||
|
[
|
||||||
|
"プルアップ",
|
||||||
|
"pi.SET_PULL_UP"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"プルダウン",
|
||||||
|
"pi.SET_PULL_DOWN"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"プル無し",
|
||||||
|
"pi.SET_PULL_NONE"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputsInline": true,
|
||||||
"previousStatement": null,
|
"previousStatement": null,
|
||||||
"nextStatement": null,
|
"nextStatement": null,
|
||||||
"tooltip": "%{BKY_GPIO_STOP_TOOLTIP}",
|
"tooltip": "%{BKY_GPIO_CLAIM_INPUT_TOOLTIP}",
|
||||||
"helpUrl": "",
|
"helpUrl": "",
|
||||||
"style": "gpio_blocks"
|
"style": "gpio_blocks"
|
||||||
};
|
};
|
||||||
Blockly.Blocks['ugj_gpio_stop'] = {
|
Blockly.Blocks['ugj_gpio_claim_input'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.jsonInit(ugjGpioStopDefinition);
|
this.jsonInit(ugjGpioClaimInputDefinition);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_stop'] = function (block) {
|
Blockly.JavaScript['ugj_gpio_claim_input'] = function (block) {
|
||||||
var code = 'pi.stop();\n';
|
|
||||||
return code;
|
|
||||||
};
|
|
||||||
Blockly.Python['ugj_gpio_stop'] = function (block) {
|
|
||||||
var code = `pi.stop()\n`;
|
|
||||||
return code;
|
|
||||||
};
|
|
||||||
|
|
||||||
/********************* */
|
|
||||||
/** GPIO Set Output ** */
|
|
||||||
/********************* */
|
|
||||||
Blockly.Blocks['ugj_gpio_setoutput'] = {
|
|
||||||
init: function () {
|
|
||||||
this.appendValueInput("gpio")
|
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("GPIO");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("を出力モードにする");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("GPIO端子のモードを出力に設定します。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Blockly.JavaScript['ugj_gpio_setoutput'] = function (block) {
|
|
||||||
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var code = `pi.set_mode(${value_gpio}, pi.OUTPUT);\n`;
|
var dropdown_lflag = block.getFieldValue('lflag');
|
||||||
|
var code = `pi.gpio_claim_input(lgHand, ${value_gpio}, ${dropdown_lflag});\n`;
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
Blockly.Python['ugj_gpio_claim_input'] = function (block) {
|
||||||
/*********************************** */
|
var value_gpio = Blockly.Python.valueToCode(block, 'gpio', Blockly.Python.ORDER_ATOMIC);
|
||||||
/** GPIO Set Input and PullupDown ** */
|
var dropdown_lflag = block.getFieldValue('lflag');
|
||||||
/*********************************** */
|
var code = `pi.gpio_claim_input(lgHand, ${value_gpio}, ${dropdown_lflag})\n`;
|
||||||
Blockly.Blocks['ugj_gpio_setinput'] = {
|
|
||||||
init: function () {
|
|
||||||
this.appendValueInput("gpio")
|
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("GPIO");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("を入力モードにして")
|
|
||||||
.appendField(new Blockly.FieldDropdown([["プルアップ", "pi.PUD_UP"], ["プルダウン", "pi.PUD_DOWN"]]), "updown");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("GPIO端子を入力モードにして、プルアップ・プルダウンを設定します。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Blockly.JavaScript['ugj_gpio_setinput'] = function (block) {
|
|
||||||
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
|
||||||
var dropdown_updown = block.getFieldValue('updown');
|
|
||||||
var code = `pi.set_mode(${value_gpio}, pi.INPUT);\n`;
|
|
||||||
code += `pi.set_pull_up_down(${value_gpio}, ${dropdown_updown});\n`;
|
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
/********************* */
|
/********************* */
|
||||||
/** Read GPIO Value ** */
|
/** Read GPIO Value ** */
|
||||||
/***********************/
|
/***********************/
|
||||||
|
var ugjGpioReadDefinition = {
|
||||||
|
"type": "ugj_gpio_read",
|
||||||
|
"message0": "%{BKY_GPIO_READ_TITLE}",
|
||||||
|
"args0": [
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "gpio",
|
||||||
|
"check": "Number"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputsInline": true,
|
||||||
|
"output": "Number",
|
||||||
|
"tooltip": "%{BKY_GPIO_READ_TOOLTIP",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
Blockly.Blocks['ugj_gpio_read'] = {
|
Blockly.Blocks['ugj_gpio_read'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendValueInput("gpio")
|
this.jsonInit(ugjGpioReadDefinition);
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("GPIO");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("の値");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setOutput(true, "Number");
|
|
||||||
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("GPIO端子の値をデジタル値(0または1)で読み取ります。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_read'] = function (block) {
|
Blockly.JavaScript['ugj_gpio_read'] = function (block) {
|
||||||
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var code = `pi.read(${value_gpio})`;
|
var code = `pi.gpio_read(lgHand, ${value_gpio})`;
|
||||||
return [code, Blockly.JavaScript.ORDER_NONE];
|
return [code, Blockly.JavaScript.ORDER_NONE];
|
||||||
};
|
};
|
||||||
|
Blockly.Python['ugj_gpio_read'] = function (block) {
|
||||||
|
var value_gpio = Blockly.Python.valueToCode(block, 'gpio', Blockly.Python.ORDER_ATOMIC);
|
||||||
|
var code = `pi.gpio_read(lgHand, ${value_gpio})`;
|
||||||
|
return [code, Blockly.Python.ORDER_NONE];
|
||||||
|
};
|
||||||
|
|
||||||
/*******************************************/
|
/*******************************************/
|
||||||
/** GPIO Write Value - Common GPIO on/off **/
|
/** GPIO Write Value - Common GPIO on/off **/
|
||||||
/*******************************************/
|
/*******************************************/
|
||||||
|
var ugjGpioWriteDefinition = {
|
||||||
|
"type": "ugj_gpio_write",
|
||||||
|
"message0": "%{BKY_GPIO_WRITE_TITLE}",
|
||||||
|
"args0": [
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "gpio",
|
||||||
|
"check": "Number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "field_dropdown",
|
||||||
|
"name": "level",
|
||||||
|
"options": [
|
||||||
|
[
|
||||||
|
"0",
|
||||||
|
"0"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"1",
|
||||||
|
"1"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputsInline": true,
|
||||||
|
"previousStatement": null,
|
||||||
|
"nextStatement": null,
|
||||||
|
"tooltip": "%{BKY_GPIO_WRITE_TOOLTIP}",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
Blockly.Blocks['ugj_gpio_write'] = {
|
Blockly.Blocks['ugj_gpio_write'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendValueInput("ugj_gpio_num")
|
this.jsonInit(ugjGpioWriteDefinition);
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("GPIO");
|
|
||||||
this.appendValueInput("ugj_gpio_value")
|
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("を");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("にする");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("GPIO端子の値をデジタル値(0または1)で出力します。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_write'] = function (block) {
|
Blockly.JavaScript['ugj_gpio_write'] = function (block) {
|
||||||
var value_ugj_gpio_num = Blockly.JavaScript.valueToCode(block, 'ugj_gpio_num', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var value_ugj_gpio_value = Blockly.JavaScript.valueToCode(block, 'ugj_gpio_value', Blockly.JavaScript.ORDER_ATOMIC);
|
var dropdown_level = block.getFieldValue('level');
|
||||||
var code = `pi.write(${value_ugj_gpio_num}, ${value_ugj_gpio_value});\n`;
|
var code = `pi.gpio_write(lgHand, ${value_gpio}, ${dropdown_level});\n`;
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
Blockly.Python['ugj_gpio_write'] = function (block) {
|
||||||
|
var value_gpio = Blockly.Python.valueToCode(block, 'gpio', Blockly.Python.ORDER_ATOMIC);
|
||||||
|
var dropdown_level = block.getFieldValue('level');
|
||||||
|
var code = `pi.gpio_write(lgHand, ${value_gpio}, ${dropdown_level})\n`;
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************/
|
/*****************/
|
||||||
/** Servo motor **/
|
/** Servo motor **/
|
||||||
/*****************/
|
/*****************/
|
||||||
Blockly.Blocks['ugj_gpio_servo'] = {
|
var ugjTxServoDefinition = {
|
||||||
|
"type": "ugj_tx_servo",
|
||||||
|
"message0": "%{BKY_TX_SERVO_TITLE}",
|
||||||
|
"args0": [
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "gpio",
|
||||||
|
"check": "Number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "pulsewidth",
|
||||||
|
"check": "Number"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputsInline": true,
|
||||||
|
"previousStatement": null,
|
||||||
|
"nextStatement": null,
|
||||||
|
"tooltip": "%{BKY_TX_SERVO_TOOLTIP}",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
|
Blockly.Blocks['ugj_tx_servo'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendValueInput("gpio")
|
this.jsonInit(ugjTxServoDefinition);
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("GPIO");
|
|
||||||
this.appendValueInput("pulsewidth")
|
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("のサーボモータの回転を");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("にする");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("サーボモータの回転をパルス幅(1000~2000μsec)までの数値で指定します。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_servo'] = function (block) {
|
Blockly.JavaScript['ugj_tx_servo'] = function (block) {
|
||||||
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var value_pulsewidth = Blockly.JavaScript.valueToCode(block, 'pulsewidth', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_pulsewidth = Blockly.JavaScript.valueToCode(block, 'pulsewidth', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var code = `pi.set_servo_pulsewidth(${value_gpio}, ${value_pulsewidth});\n`;
|
var code = `pi.tx_servo(lgHand, ${value_gpio}, ${value_pulsewidth});\n`;
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
Blockly.Python['ugj_tx_servo'] = function (block) {
|
||||||
|
var value_gpio = Blockly.Python.valueToCode(block, 'gpio', Blockly.Python.ORDER_ATOMIC);
|
||||||
|
var value_pulsewidth = Blockly.Python.valueToCode(block, 'pulsewidth', Blockly.Python.ORDER_ATOMIC);
|
||||||
|
var code = `pi.tx_servo(lgHand, ${value_gpio}, ${value_pulsewidth})\n`;
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
/********************************* */
|
/************************************************* */
|
||||||
/** Set PWM Frequency and Range ** */
|
/** starts software timed PWM on an output GPIO ** */
|
||||||
/********************************* */
|
/************************************************* */
|
||||||
Blockly.Blocks['ugj_gpio_setpwmfreqrange'] = {
|
var ugjTxPwmDefinition = {
|
||||||
|
"type": "ugj_tx_pwm",
|
||||||
|
"message0": "%{BKY_TX_PWM_TITLE}",
|
||||||
|
"args0": [
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "gpio",
|
||||||
|
"check": "Number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "pwm_frequency",
|
||||||
|
"check": "Number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "pwm_duty_cycle",
|
||||||
|
"check": "Number"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputsInline": true,
|
||||||
|
"previousStatement": null,
|
||||||
|
"nextStatement": null,
|
||||||
|
"tooltip": "%{BKY_TX_PWM_TOOLTIP}",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
|
Blockly.Blocks['ugj_tx_pwm'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendValueInput("gpio")
|
this.jsonInit(ugjTxPwmDefinition);
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("GPIO");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("のパルス周波数を")
|
|
||||||
.appendField(new Blockly.FieldDropdown([["10", "10"], ["20", "20"], ["40", "40"], ["50", "50"], ["80", "80"], ["100", "100"], ["200", "200"], ["400", "400"], ["800", "800"], ["8000", "8000"]]), "pwmfreq")
|
|
||||||
.appendField("Hzにする");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("パルス周波数をセットして、GPIO端子がPWM出力できるようにします。レンジは100固定です。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_setpwmfreqrange'] = function (block) {
|
Blockly.JavaScript['ugj_tx_pwm'] = function(block) {
|
||||||
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var dropdown_pwmfreq = block.getFieldValue('pwmfreq');
|
var value_pwm_frequency = Blockly.JavaScript.valueToCode(block, 'pwm_frequency', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var code = [
|
var value_pwm_duty_cycle = Blockly.JavaScript.valueToCode(block, 'pwm_duty_cycle', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
`pi.set_PWM_frequency(${value_gpio}, ${dropdown_pwmfreq});`,
|
var code = `pi.tx_pwm(lgHand, ${value_gpio}, ${value_pwm_frequency}, ${value_pwm_duty_cycle});\n`;
|
||||||
// `pi.set_PWM_range(${value_gpio}, 100);`,
|
|
||||||
""
|
|
||||||
].join('\n');
|
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
Blockly.Python['ugj_tx_pwm'] = function(block) {
|
||||||
/******************************************** */
|
var value_gpio = Blockly.Python.valueToCode(block, 'gpio', Blockly.Python.ORDER_ATOMIC);
|
||||||
/** Starts or stops PWM pulses on the GPIO ** */
|
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);
|
||||||
Blockly.Blocks['ugj_gpio_setpwmdutycycle'] = {
|
var code = `pi.tx_pwm(lgHand, ${value_gpio}, ${value_pwm_frequency}, ${value_pwm_duty_cycle})\n`;
|
||||||
init: function () {
|
|
||||||
this.appendValueInput("dutycycle")
|
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("デューティ比");
|
|
||||||
this.appendValueInput("gpio")
|
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("% のパルスを GPIO");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("から出力する");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("デューティ比(1~100%)を指定して出力を開始します。0を指定すると出力を停止します。事前に必ずパルス周波数ブロックが実行されるようにしてください。");
|
|
||||||
this.setHelpUrl("https://ja.wikipedia.org/wiki/%E3%83%87%E3%83%A5%E3%83%BC%E3%83%86%E3%82%A3%E6%AF%94");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Blockly.JavaScript['ugj_gpio_setpwmdutycycle'] = function (block) {
|
|
||||||
var value_dutycycle = Blockly.JavaScript.valueToCode(block, 'dutycycle', Blockly.JavaScript.ORDER_ATOMIC);
|
|
||||||
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
|
||||||
var code = `pi.set_PWM_dutycycle(${value_gpio}, ${value_dutycycle});\n`;
|
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
/********************** */
|
/********************** */
|
||||||
/** Open Serial Port ** */
|
/** Open Serial Port ** */
|
||||||
/********************** */
|
/********************** */
|
||||||
Blockly.Blocks['ugj_gpio_serialopen'] = {
|
var ugjSerialOpenDefinition = {
|
||||||
|
"type": "ugj_serial_open",
|
||||||
|
"message0": "%{BKY_SERIAL_OPEN_TITLE}",
|
||||||
|
"args0": [
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "tty",
|
||||||
|
"check": "String"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "field_dropdown",
|
||||||
|
"name": "baud",
|
||||||
|
"options": [
|
||||||
|
[
|
||||||
|
"9600",
|
||||||
|
"9600"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"19200",
|
||||||
|
"19200"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"115200",
|
||||||
|
"115200"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputsInline": true,
|
||||||
|
"previousStatement": null,
|
||||||
|
"nextStatement": null,
|
||||||
|
"tooltip": "%{BKY_SERIAL_OPEN_TOOLTIP}",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
|
Blockly.Blocks['ugj_serial_open'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendValueInput("tty")
|
this.jsonInit(ugjSerialOpenDefinition);
|
||||||
.setCheck("String")
|
|
||||||
.appendField("シリアルポート");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("を速度")
|
|
||||||
.appendField(new Blockly.FieldDropdown([["9600", "9600"], ["19200", "19200"], ["115200", "115200"]]), "baud")
|
|
||||||
.appendField("bpsで開く");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("シリアルデバイスとの接続を開きます。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_serialopen'] = function (block) {
|
Blockly.JavaScript['ugj_serial_open'] = function (block) {
|
||||||
var value_tty = Blockly.JavaScript.valueToCode(block, 'tty', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_tty = Blockly.JavaScript.valueToCode(block, 'tty', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var dropdown_baud = block.getFieldValue('baud');
|
var dropdown_baud = block.getFieldValue('baud');
|
||||||
var code = `let serhand = pi.serial_open(${value_tty}, ${dropdown_baud}, 0);`;
|
var code = `let ser_hand = pi.serial_open(${value_tty}, ${dropdown_baud}, 0);\n`;
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
/********************** */
|
Blockly.Python['ugj_serial_open'] = function (block) {
|
||||||
|
var value_tty = Blockly.Python.valueToCode(block, 'tty', Blockly.Python.ORDER_ATOMIC);
|
||||||
|
var dropdown_baud = block.getFieldValue('baud');
|
||||||
|
var code = `ser_hand = pi.serial_open(${value_tty}, ${dropdown_baud}, 0)\n`;
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
/*********************** */
|
||||||
/** Close Serial Port ** */
|
/** Close Serial Port ** */
|
||||||
/********************** */
|
/*********************** */
|
||||||
|
var ugjSerialCloseDefinition = {
|
||||||
|
"type": "ugj_serial_close",
|
||||||
|
"message0": "%{BKY_SERIAL_CLOSE_TITLE}",
|
||||||
|
"inputsInline": true,
|
||||||
|
"previousStatement": null,
|
||||||
|
"nextStatement": null,
|
||||||
|
"tooltip": "%{BKY_SERIAL_CLOSE_TOOLTIP}",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
Blockly.Blocks['ugj_serial_close'] = {
|
Blockly.Blocks['ugj_serial_close'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendDummyInput()
|
this.jsonInit(ugjSerialCloseDefinition);
|
||||||
.appendField("シリアルポートを閉じる");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("シリアルデバイスとの接続を閉じます。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_serial_close'] = function (block) {
|
Blockly.JavaScript['ugj_serial_close'] = function (block) {
|
||||||
var code = 'pi.serial_close(serhand);';
|
var code = 'pi.serial_close(ser_hand);\n';
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
Blockly.Python['ugj_serial_close'] = function (block) {
|
||||||
|
var code = 'pi.serial_close(ser_hand)\n';
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
/************************** */
|
/************************** */
|
||||||
/** Write Data to Serial ** */
|
/** Write Data to Serial ** */
|
||||||
/************************** */
|
/************************** */
|
||||||
|
var ugjSerialWriteDefinition = {
|
||||||
|
"type": "ugj_serial_write",
|
||||||
|
"message0": "%{BKY_SERIAL_WRITE_TITLE}",
|
||||||
|
"args0": [
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "data",
|
||||||
|
"check": "String"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputsInline": true,
|
||||||
|
"previousStatement": null,
|
||||||
|
"nextStatement": null,
|
||||||
|
"tooltip": "%{BKY_SERIAL_WRITE_TOOLTIP}",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
Blockly.Blocks['ugj_serial_write'] = {
|
Blockly.Blocks['ugj_serial_write'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendValueInput("data")
|
this.jsonInit(ugjSerialWriteDefinition);
|
||||||
.setCheck("String")
|
|
||||||
.appendField("シリアルポートに");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("を送信する");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("シリアル接続されたデバイスにデータを送信します。シリアルポートは開かれていなくてはいけません。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_serial_write'] = function (block) {
|
Blockly.JavaScript['ugj_serial_write'] = function (block) {
|
||||||
var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_data = Blockly.JavaScript.valueToCode(block, 'data', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var code = `pi.serial_write(serhand, ${value_data});\n`;
|
var code = `pi.serial_write(ser_hand, ${value_data});\n`;
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
Blockly.Python['ugj_serial_write'] = function (block) {
|
||||||
|
var value_data = Blockly.Python.valueToCode(block, 'data', Blockly.Python.ORDER_ATOMIC);
|
||||||
|
var code = `pi.serial_write(ser_hand, ${value_data})\n`;
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
/************************ */
|
/************************ */
|
||||||
/** Read Data from Serial */
|
/** Read Data from Serial */
|
||||||
/************************ */
|
/************************ */
|
||||||
Blockly.Blocks['ugj_gpio_serialread'] = {
|
var ugjSerialReadDefinition = {
|
||||||
|
"type": "ugj_serial_read",
|
||||||
|
"message0": "%{BKY_SERIAL_READ_TITLE}",
|
||||||
|
"args0": [
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "count",
|
||||||
|
"check": "Number"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputsInline": true,
|
||||||
|
"output": null,
|
||||||
|
"tooltip": "%{BKY_SERIAL_READ_TOOLTIP}",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
|
Blockly.Blocks['ugj_serial_read'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendValueInput("count")
|
this.jsonInit(ugjSerialReadDefinition);
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("シリアルポートから");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("文字読み込む");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setOutput(true, null);
|
|
||||||
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("オープン済みシリアルポートから、指定のバイト数だけデータを読み込みます。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_serialread'] = function (block) {
|
Blockly.JavaScript['ugj_serial_read'] = function (block) {
|
||||||
var value_count = Blockly.JavaScript.valueToCode(block, 'count', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_count = Blockly.JavaScript.valueToCode(block, 'count', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var code = `pi.serial_read(serhand, ${value_count})`;
|
var code = `pi.serial_read(ser_hand, ${value_count});\n`;
|
||||||
return [code, Blockly.JavaScript.ORDER_NONE];
|
return [code, Blockly.JavaScript.ORDER_NONE];
|
||||||
};
|
};
|
||||||
|
Blockly.Python['ugj_serial_read'] = function (block) {
|
||||||
|
var value_count = Blockly.Python.valueToCode(block, 'count', Blockly.Python.ORDER_ATOMIC);
|
||||||
|
var code = `pi.serial_read(ser_hand, ${value_count})\n`;
|
||||||
|
return [code, Blockly.Python.ORDER_NONE];
|
||||||
|
};
|
||||||
|
|
||||||
/********************* */
|
/********************* */
|
||||||
/** Open I2C Device ** */
|
/** Open I2C Device ** */
|
||||||
/********************* */
|
/********************* */
|
||||||
Blockly.Blocks['ugj_gpio_i2copen'] = {
|
var ugjI2cOpenDefinition = {
|
||||||
|
"type": "ugj_i2c_open",
|
||||||
|
"message0": "%{BKY_I2C_OPEN_TITLE}",
|
||||||
|
"args0": [
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "i2c_address",
|
||||||
|
"check": "Number"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputsInline": true,
|
||||||
|
"previousStatement": null,
|
||||||
|
"nextStatement": null,
|
||||||
|
"tooltip": "%{BKY_I2C_OPEN_TOOLTIP}",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
|
Blockly.Blocks['ugj_i2c_open'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendValueInput("i2c_addr")
|
this.jsonInit(ugjI2cOpenDefinition);
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("アドレス");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("の I2C デバイスを開く");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("I2C接続されたデバイスとの通信を開始します。一度にオープンできるI2Cデバイスはひとつだけです。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_i2copen'] = function (block) {
|
Blockly.JavaScript['ugj_i2c_open'] = function (block) {
|
||||||
var value_i2c_addr = Blockly.JavaScript.valueToCode(block, 'i2c_addr', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_i2c_address = Blockly.JavaScript.valueToCode(block, 'i2c_address', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var code = `let i2cHand = pi.i2c_open(1, ${value_i2c_addr}, 0);`;
|
var code = `let i2c_hand = pi.i2c_open(1, ${value_i2c_address});\n`;
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
Blockly.Python['ugj_i2c_open'] = function (block) {
|
||||||
|
var value_i2c_address = Blockly.Python.valueToCode(block, 'i2c_address', Blockly.Python.ORDER_ATOMIC);
|
||||||
|
var code = `i2c_hand = pi.i2c_open(1, ${value_i2c_address})\n`;
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
/********************** */
|
/********************** */
|
||||||
/** Close I2C Device ** */
|
/** Close I2C Device ** */
|
||||||
/********************** */
|
/********************** */
|
||||||
Blockly.Blocks['ugj_gpio_i2cclose'] = {
|
var ugjI2cCloseDefinition = {
|
||||||
|
"type": "ugj_i2c_close",
|
||||||
|
"message0": "%{BKY_I2C_CLOSE_TITLE}",
|
||||||
|
"inputsInline": true,
|
||||||
|
"previousStatement": null,
|
||||||
|
"nextStatement": null,
|
||||||
|
"tooltip": "%{BKY_I2C_CLOSE_TOOLTIP}",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
|
Blockly.Blocks['ugj_i2c_close'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendDummyInput()
|
this.jsonInit(ugjI2cCloseDefinition);
|
||||||
.appendField("I2C デバイスを閉じる");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("I2C接続されたデバイスと通信を切断します。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_i2cclose'] = function (block) {
|
Blockly.JavaScript['ugj_i2c_close'] = function (block) {
|
||||||
var code = `pi.i2c_close(i2cHand);`;
|
var code = `pi.i2c_close(i2c_hand);\n`;
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
Blockly.Python['ugj_i2c_close'] = function (block) {
|
||||||
|
var code = `pi.i2c_close(i2c_hand)\n`;
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************** */
|
/****************************************************************** */
|
||||||
/** Writes a single byte to the specified register of the device ** */
|
/** Writes a single byte to the specified register of the device ** */
|
||||||
/****************************************************************** */
|
/****************************************************************** */
|
||||||
|
var ugjI2cWriteByteDataDefinition = {
|
||||||
Blockly.Blocks['ugj_gpio_i2cwritebyte'] = {
|
"type": "ugj_i2c_write_byte_data",
|
||||||
|
"message0": "%{BKY_I2C_WRITE_BYTE_DATA_TITLE}",
|
||||||
|
"args0": [
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "reg",
|
||||||
|
"check": "Number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "byte_val",
|
||||||
|
"check": "Number"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputsInline": true,
|
||||||
|
"previousStatement": null,
|
||||||
|
"nextStatement": null,
|
||||||
|
"tooltip": "%{BKY_I2C_WRITE_BYTE_DATA_TOOLTIP}",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
|
Blockly.Blocks['ugj_i2c_write_byte_data'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendValueInput("reg")
|
this.jsonInit(ugjI2cWriteByteDataDefinition);
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("レジスタ");
|
|
||||||
this.appendValueInput("byteData")
|
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("に");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("を書き込む");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("デバイスの指定されたレジスタに1バイトを書き込みます。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_i2cwritebyte'] = function (block) {
|
Blockly.JavaScript['ugj_i2c_write_byte_data'] = function (block) {
|
||||||
var value_reg = Blockly.JavaScript.valueToCode(block, 'reg', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_reg = Blockly.JavaScript.valueToCode(block, 'reg', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var value_bytedata = Blockly.JavaScript.valueToCode(block, 'byteData', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_byte_val = Blockly.JavaScript.valueToCode(block, 'byte_val', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var code = `pi.i2c_write_byte_data(i2cHand, ${value_reg}, ${value_bytedata});\n`;
|
var code = `pi.i2c_write_byte_data(i2c_hand, ${value_reg}, ${value_byte_val});\n`;
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
Blockly.Python['ugj_i2c_write_byte_data'] = function (block) {
|
||||||
|
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 = `pi.i2c_write_byte_data(i2c_hand, ${value_reg}, ${value_byte_val})\n`;
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************** */
|
/****************************************************************** */
|
||||||
/** Read a single byte from the specified resister of the device ** */
|
/** Read a single byte from the specified resister of the device ** */
|
||||||
/****************************************************************** */
|
/****************************************************************** */
|
||||||
Blockly.Blocks['ugj_gpio_i2creadbyte'] = {
|
var ugjI2cReadByteDataDefinition = {
|
||||||
|
"type": "ugj_i2c_read_byte_data",
|
||||||
|
"message0": "%{BKY_I2C_READ_BYTE_DATA_TITLE}",
|
||||||
|
"args0": [
|
||||||
|
{
|
||||||
|
"type": "input_value",
|
||||||
|
"name": "reg",
|
||||||
|
"check": "Number"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputsInline": true,
|
||||||
|
"output": null,
|
||||||
|
"tooltip": "%{BKY_I2C_READ_BYTE_DATA_TOOLTIP}",
|
||||||
|
"helpUrl": "",
|
||||||
|
"style": "gpio_blocks"
|
||||||
|
};
|
||||||
|
Blockly.Blocks['ugj_i2c_read_byte_data'] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.appendValueInput("reg")
|
this.jsonInit(ugjI2cReadByteDataDefinition);
|
||||||
.setCheck("Number")
|
|
||||||
.appendField("レジスタ");
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField("の値");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setOutput(true, null);
|
|
||||||
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("デバイスの指定されたレジスタから1バイトを読み込みます。");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_gpio_i2creadbyte'] = function (block) {
|
Blockly.JavaScript['ugj_i2c_read_byte_data'] = function (block) {
|
||||||
var value_reg = Blockly.JavaScript.valueToCode(block, 'reg', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_reg = Blockly.JavaScript.valueToCode(block, 'reg', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var code = `pi.i2c_read_byte_data(i2cHand, ${value_reg})`;
|
var code = `pi.i2c_read_byte_data(i2c_hand, ${value_reg});\n`;
|
||||||
return [code, Blockly.JavaScript.ORDER_NONE];
|
return [code, Blockly.JavaScript.ORDER_NONE];
|
||||||
};
|
};
|
||||||
|
Blockly.Python['ugj_i2c_read_byte_data'] = function (block) {
|
||||||
|
var value_reg = Blockly.Python.valueToCode(block, 'reg', Blockly.Python.ORDER_ATOMIC);
|
||||||
|
var code = `pi.i2c_read_byte_data(i2c_hand, ${value_reg})\n`;
|
||||||
|
return [code, Blockly.Python.ORDER_NONE];
|
||||||
|
|
||||||
/********************************************************************************** */
|
|
||||||
/** Extra Method : Sleep with C++ Native Module *************************************/
|
|
||||||
/** Warning: This block freezes the whole application. Cannot terminate, exit, etc. */
|
|
||||||
/********************************************************************************** */
|
|
||||||
Blockly.Blocks['ugj_gpio_sleep'] = {
|
|
||||||
init: function () {
|
|
||||||
this.appendDummyInput()
|
|
||||||
.appendField(new Blockly.FieldDropdown([["1", "1"], ["3", "3"], ["5", "5"], ["10", "10"]]), "sec")
|
|
||||||
.appendField("秒間プログラムを強制的に停止する");
|
|
||||||
this.setInputsInline(true);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
this.setStyle('gpio_blocks')
|
|
||||||
this.setTooltip("実行環境全体を完全に一時停止します。停止中はすべての操作ができなくなります。※実験用");
|
|
||||||
this.setHelpUrl("");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Blockly.JavaScript['ugj_gpio_sleep'] = function (block) {
|
|
||||||
var dropdown_sec = block.getFieldValue('sec');
|
|
||||||
var code = `pi.usleep(${dropdown_sec} * 1000000);\n`;
|
|
||||||
return code;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Multimedia *****************************************************************************************************/
|
/** Multimedia *****************************************************************************************************/
|
||||||
|
|
||||||
/******************* */
|
/******************* */
|
||||||
|
@ -76,12 +76,39 @@ Blockly.Msg["UGJ_FOREACH_TITLE"] = "リスト %1 の各 %2 について %3 %4";
|
|||||||
Blockly.Msg["UGJ_FOREACH_ITEM"] = "項目";
|
Blockly.Msg["UGJ_FOREACH_ITEM"] = "項目";
|
||||||
Blockly.Msg["UGJ_FOREACH_TOOLTIP"] = "リストの各項目について、その項目を変数「項目」としてステートメントを実行します。";
|
Blockly.Msg["UGJ_FOREACH_TOOLTIP"] = "リストの各項目について、その項目を変数「項目」としてステートメントを実行します。";
|
||||||
|
|
||||||
Blockly.Msg["GPIO_START_TITLE"] = "GPIO を使えるようにする";
|
Blockly.Msg["GPIOCHIP_OPEN_TITLE"] = "GPIO を使えるようにする";
|
||||||
Blockly.Msg["GPIO_START_TOOLTIP"] = "GPIOを初期化して接続します。";
|
Blockly.Msg["GPIOCHIP_OPEN_TOOLTIP"] = "GPIOを初期化して接続します。";
|
||||||
Blockly.Msg["GPIO_STOP_TITLE"] = "GPIO の後片付けをする";
|
Blockly.Msg["GPIOCHIP_CLOSE_TITLE"] = "GPIO の後片付けをする";
|
||||||
Blockly.Msg["GPIO_STOP_TOOLTIP"] = "GPIOとの接続を終了します。";
|
Blockly.Msg["GPIOCHIP_CLOSE_TOOLTIP"] = "GPIOとの接続を終了します。";
|
||||||
Blockly.Msg["GPIO_START_REMOTE_TITLE"] = "ホスト %1 のGPIO を使えるようにする";
|
Blockly.Msg["GPIOCHIP_CLOSE_TITLE"] = "GPIO の後片付けをする";
|
||||||
Blockly.Msg["GPIO_START_REMOTE_TOOLTIP"] = "他のマシンのリモートGPIOに接続します。";
|
Blockly.Msg["GPIO_CLAIM_INPUT_TITLE"] = "GPIO %1 を入力モードにして %2";
|
||||||
|
Blockly.Msg["GPIO_CLAIM_INPUT_TOOLTIP"] = "GPIO端子を入力モードにして、プルアップ・プルダウン・無しを設定します。";
|
||||||
|
Blockly.Msg["GPIO_CLAIM_OUTPUT_TITLE"] = "GPIO %1 を出力モードにする";
|
||||||
|
Blockly.Msg["GPIO_CLAIM_OUTPUT_TOOLTIP"] = "GPIO端子のモードを出力に設定します。";
|
||||||
|
Blockly.Msg["GPIO_READ_TITLE"] = "GPIO %1 の値";
|
||||||
|
Blockly.Msg["GPIO_READ_TOOLTIP"] = "GPIO端子の値をデジタル値(0または1)で読み取ります。";
|
||||||
|
Blockly.Msg["GPIO_WRITE_TITLE"] = "GPIO %1 の値を %2 にする";
|
||||||
|
Blockly.Msg["GPIO_WRITE_TOOLTIP"] = "GPIO端子の値をデジタル値(0または1)で出力します。";
|
||||||
|
Blockly.Msg["TX_SERVO_TITLE"] = "GPIO %1 のサーボモータの回転を %2 にする";
|
||||||
|
Blockly.Msg["TX_SERVO_TOOLTIP"] = "サーボモータの回転をパルス幅(1000~2000μsec)までの数値で指定します。";
|
||||||
|
Blockly.Msg["TX_PWM_TITLE"] = "PWM : GPIO %1 に、パルス周波数 %2 Hz, デューティー比 %3 %%で出力";
|
||||||
|
Blockly.Msg["TX_PWM_TOOLTIP"] = "パルス周波数をセットして、GPIO端子がPWM出力できるようにします。レンジは100固定です。";
|
||||||
|
Blockly.Msg["I2C_OPEN_TITLE"] = "アドレス %1 の I2C デバイスを開く";
|
||||||
|
Blockly.Msg["I2C_OPEN_TOOLTIP"] = "I2C接続されたデバイスとの通信を開始します。一度にオープンできるI2Cデバイスはひとつだけです。";
|
||||||
|
Blockly.Msg["SERIAL_OPEN_TITLE"] = "シリアルポート %1 を速度 %2 bpsで開く";
|
||||||
|
Blockly.Msg["SERIAL_OPEN_TOOLTIP"] = "シリアルデバイスとの接続を開きます。";
|
||||||
|
Blockly.Msg["SERIAL_CLOSE_TITLE"] = "シリアルポートを閉じる";
|
||||||
|
Blockly.Msg["SERIAL_CLOSE_TOOLTIP"] = "シリアルデバイスとの接続を閉じます。";
|
||||||
|
Blockly.Msg["SERIAL_WRITE_TITLE"] = "シリアルポートに %1 を送信する";
|
||||||
|
Blockly.Msg["SERIAL_WRITE_TOOLTIP"] = "シリアル接続されたデバイスにデータを送信します。シリアルポートは開かれていなくてはいけません。";
|
||||||
|
Blockly.Msg["SERIAL_READ_TITLE"] = "シリアルポートから %1 文字読み込む";
|
||||||
|
Blockly.Msg["SERIAL_READ_TOOLTIP"] = "オープン済みシリアルポートから、指定のバイト数だけデータを読み込みます。";
|
||||||
|
Blockly.Msg["I2C_CLOSE_TITLE"] = "I2C デバイスを閉じる";
|
||||||
|
Blockly.Msg["I2C_CLOSE_TOOLTIP"] = "I2C接続されたデバイスと通信を切断します。";
|
||||||
|
Blockly.Msg["I2C_WRITE_BYTE_DATA_TITLE"] = "レジスタ %1 に %2 を書き込む";
|
||||||
|
Blockly.Msg["I2C_WRITE_BYTE_DATA_TOOLTIP"] = "デバイスの指定されたレジスタに1バイトを書き込みます。";
|
||||||
|
Blockly.Msg["I2C_READ_BYTE_DATA_TITLE"] = "レジスタ %1 の値";
|
||||||
|
Blockly.Msg["I2C_READ_BYTE_DATA_TOOLTIP"] = "デバイスの指定されたレジスタから1バイトを読み込みます。";
|
||||||
|
|
||||||
Blockly.Msg["UGJ_CANVAS_INIT_TITLE"] = "キャンバスを表示";
|
Blockly.Msg["UGJ_CANVAS_INIT_TITLE"] = "キャンバスを表示";
|
||||||
Blockly.Msg["UGJ_CANVAS_INIT_TOOLTIP"] = "キャンバスを表示し、使用できるようにします。";
|
Blockly.Msg["UGJ_CANVAS_INIT_TOOLTIP"] = "キャンバスを表示し、使用できるようにします。";
|
||||||
|
Loading…
Reference in New Issue
Block a user