mirror of
https://github.com/ocogeclub/ocoge.git
synced 2024-11-24 00:19:48 +00:00
[fix] インストーラでインストールした ocoge で、いくつかのファイルパスが正しく取得できなくなっていたのを修正
This commit is contained in:
parent
a94151b86b
commit
8f4a624b55
@ -1,12 +1,10 @@
|
||||
Google/Blockly is licensed under Apache License (Version 2.0).
|
||||
|
||||
Microsoft/pxt-blockly is licensed under MIT.
|
||||
|
||||
ocoge is licensed under MIT.
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 ocoge club, Ueno Gakushujuku
|
||||
Copyright (c) 2021-2022 ocoge club, Ueno Gakushujuku
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -1,9 +1,9 @@
|
||||
# ocoge
|
||||
"大岩産 Code Generator" は、Google Blockly ライブラリを使用した、Raspberry Pi 上で動作するブロックプログラム開発・実行環境です。
|
||||
インストール方法・操作・サンプルなどは、『[PI.ICHIJU.IN](https://pi.ichiju.in)』にて公開予定です。
|
||||
"大岩 Code Generator" は、Google Blockly ライブラリを使用した、Raspberry Pi 上で動作するブロックプログラム開発・実行環境です。
|
||||
インストール方法・操作・サンプルなどは、『[PI.ICHIJU.IN](https://pi.ichiju.in)』にて公開中です。
|
||||
|
||||
### 免責
|
||||
このアプリケーションは特定の環境下で使用する目的で、専門知識を持たない日曜プログラマによって無計画に開発されています。アドバイス・ご意見・ご要望は有難く承りますが、対応の保証はいたしかねます。
|
||||
このアプリケーションは特定の環境下での使用を目的として、専門知識を持たない日曜プログラマによって無計画に開発されています。アドバイス・ご意見・ご要望は有難く承りますが、対応の保証はいたしかねます。
|
||||
また、このアプリケーションを使用したことによるいかなる損害に関しても当方は一切の責任を負わないものとします。
|
||||
|
||||
### Disclaimer
|
||||
|
104
index.html
104
index.html
@ -971,74 +971,70 @@
|
||||
<label text="_" web-line="4.0" web-line-width="200"></label>
|
||||
</category>
|
||||
<category name="スニペット" css-icon="customIcon fas fa-egg" categorystyle="snippets_category">
|
||||
<label text="入出力" web-line="4.0" web-line-width="200"></label>
|
||||
<block type="ugj_event_answer">
|
||||
<value name="answer">
|
||||
<block type="variables_get">
|
||||
<field name="VAR" id=":w)sl|yxx4k^W-~-VM#,">答え</field>
|
||||
<label text="停止ボタンつきループ" web-line="4.0" web-line-width="200"></label>
|
||||
<variables>
|
||||
<variable id="O-NNhS!sS_oTSB?7JB]$">停止フラグ</variable>
|
||||
</variables>
|
||||
<block type="variables_set" id="W+CX}t(}EgABVVPGhJ{." x="-250" y="230">
|
||||
<field name="VAR" id="O-NNhS!sS_oTSB?7JB]$">停止フラグ</field>
|
||||
<value name="VALUE">
|
||||
<block type="logic_boolean" id="3S{lEWhjtB=1Z6E$#vt?">
|
||||
<field name="BOOL">FALSE</field>
|
||||
</block>
|
||||
</value>
|
||||
<value name="question">
|
||||
<shadow type="text">
|
||||
<field name="TEXT">お名前は?</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<statement name="do">
|
||||
<block type="ugj_canvas_say">
|
||||
<value name="say">
|
||||
<shadow type="text">
|
||||
<field name="TEXT">・・・</field>
|
||||
<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="sec">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">2</field>
|
||||
<value name="textcolor">
|
||||
<shadow type="colour_picker" id="z$a35:]5)iocrfp6^OsL">
|
||||
<field name="COLOUR">#ffffff</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<block type="ugj_sleep">
|
||||
<value name="sec">
|
||||
<shadow type="math_number">
|
||||
<field name="NUM">2</field>
|
||||
</shadow>
|
||||
<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>
|
||||
<next>
|
||||
<block type="ugj_canvas_say">
|
||||
<value name="say">
|
||||
<block type="text_join">
|
||||
<mutation items="2"></mutation>
|
||||
<value name="ADD0">
|
||||
<block type="variables_get">
|
||||
<field name="VAR" id=":w)sl|yxx4k^W-~-VM#,">答え</field>
|
||||
</block>
|
||||
</value>
|
||||
<value name="ADD1">
|
||||
<block type="text">
|
||||
<field name="TEXT">たん</field>
|
||||
</block>
|
||||
</value>
|
||||
</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">
|
||||
<field name="NUM">2</field>
|
||||
<shadow type="math_number" id="wG#wMyoc]}%!`N~(GH^=">
|
||||
<field name="NUM">0</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
</next>
|
||||
</statement>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
|
||||
</block>
|
||||
<block type="testblock">
|
||||
<value name="foo">
|
||||
<block type="variables_get">
|
||||
<field name="VAR" id="BJ[VyIz4wdz@n~=d=b+X">変数</field>
|
||||
</block>
|
||||
</value>
|
||||
</next>
|
||||
</block>
|
||||
</category>
|
||||
</xml>
|
||||
|
6
index.js
6
index.js
@ -2,8 +2,10 @@
|
||||
|
||||
let elutil = elUtil_new();
|
||||
|
||||
const testfunc = () => {
|
||||
|
||||
const testfunc = async () => {
|
||||
elutil.openURL('http://ocoge.club');
|
||||
// console.log(elutil.app_path);
|
||||
}
|
||||
|
||||
//============ User Customize Start ===============
|
||||
@ -501,7 +503,7 @@ const ugj_fukidashi = (text, sec) => {
|
||||
let newLineTextList = [];
|
||||
lineTextList.forEach((lineText) => {
|
||||
if (context.measureText(lineText).width > limitedWidth) {
|
||||
characterList = lineText.split("");// 1文字ずつ分割
|
||||
let characterList = lineText.split("");// 1文字ずつ分割
|
||||
let preLineText = "";
|
||||
lineText = "";
|
||||
characterList.forEach((character) => {
|
||||
|
@ -5,9 +5,11 @@
|
||||
// 定数
|
||||
const ugj_const = {
|
||||
app_name: 'ocoge',
|
||||
mascot_path: './img/',
|
||||
mascot_dirname: 'img',
|
||||
mascot_defname: 'tamachee.png',
|
||||
library_path: './lib/',
|
||||
library_dirname: 'lib',
|
||||
document_root: 'Documents',
|
||||
executable_path: '.local/lib/ocogeclub',
|
||||
localStorage_fname: 'ocoge.json',
|
||||
error_ja_all: 'エラーが発生しました。\n『おこげ倶楽部』までお問い合わせください。',
|
||||
pig: 'pigpio',
|
||||
@ -26,14 +28,24 @@ class elUtil {
|
||||
this.shell = require('electron').shell //window.ocogeapi.electron_shell
|
||||
this.saveFilepath = null;
|
||||
this.wsChanged = false;
|
||||
this.mascotFilePath = this.path.join(ugj_const.mascot_path, ugj_const.mascot_defname);
|
||||
this.children = [];
|
||||
this.gpio_backend = ugj_const.pig;
|
||||
this.i2c_bus = ugj_const.i2c_defbus;
|
||||
this.doc_root = process.env["HOME"] + '/Documents/';
|
||||
this.doc_current = process.env["HOME"] + '/Documents';
|
||||
this.executable_path = process.env["HOME"] + '/.local/lib/ocogeclub/'
|
||||
this.doc_root = this.path.join(process.env["HOME"], ugj_const.document_root);
|
||||
this.doc_current = this.path.join(process.env["HOME"], ugj_const.document_root);
|
||||
this.executable_path = this.path.join(process.env["HOME"], ugj_const.executable_path);
|
||||
}
|
||||
// static init = async () => {
|
||||
// return new elUtil(await elUtil.get_app_path());
|
||||
// }
|
||||
// test
|
||||
async init() {
|
||||
this.app_path = await this.ipcRenderer.invoke('get_app_path');
|
||||
this.mascotFilePath = this.path.join(this.app_path, ugj_const.mascot_dirname, ugj_const.mascot_defname);
|
||||
this.library_path = this.path.join(this.app_path, ugj_const.library_dirname);
|
||||
}
|
||||
|
||||
|
||||
// 0で数値の桁合わせ : NUM=値 LEN=桁数
|
||||
zeroPadding(NUM, LEN) {
|
||||
return (Array(LEN).join('0') + NUM).slice(-LEN);
|
||||
@ -308,12 +320,16 @@ class brUtil {
|
||||
|
||||
// Electron 動作 / ブラウザ動作自動判別
|
||||
// const is_el = (typeof window.ocogeapi !== 'undefined')
|
||||
const is_el = (typeof require === 'function')
|
||||
const is_el = (typeof require === 'function');
|
||||
|
||||
// utilクラスのインスタンスを返す
|
||||
const elUtil_new = () => {
|
||||
if (is_el) return new elUtil
|
||||
else return new brUtil
|
||||
if (is_el) {
|
||||
let el = new elUtil;
|
||||
el.init();
|
||||
return el;
|
||||
}
|
||||
else return new brUtil;
|
||||
}
|
||||
|
||||
// "require" for web browsers if contextIsolation is false && nodeIntegration is true:
|
||||
|
3
main.js
3
main.js
@ -204,3 +204,6 @@ ipcMain.handle('save_dialog', (ev, title, defName, filter) => {
|
||||
console.log(filename)
|
||||
return filename
|
||||
})
|
||||
ipcMain.handle('get_app_path', (ev) => {
|
||||
return app.getAppPath()
|
||||
})
|
@ -1378,8 +1378,8 @@ Blockly.Blocks['ugj_face_detect'] = {
|
||||
};
|
||||
Blockly.JavaScript['ugj_face_detect'] = function (block) {
|
||||
var statements_do = Blockly.JavaScript.statementToCode(block, 'do');
|
||||
var code_model = `await _faceapi.nets.tinyFaceDetector.load('${ugj_const.library_path}models/');`;
|
||||
if (with_landmark) { code_model += `\nawait _faceapi.nets.faceLandmark68TinyNet.load('${ugj_const.library_path}models/');`; }
|
||||
var code_model = `await _faceapi.nets.tinyFaceDetector.load('${elutil.path.join(elutil.library_path, 'models/')}');`;
|
||||
if (with_landmark) { code_model += `\nawait _faceapi.nets.faceLandmark68TinyNet.load('${elutil.path.join(elutil.library_path, 'models/')}');`; }
|
||||
var code_detect_face = " let _result = await _faceapi.detectSingleFace(_videoEl, _options)"
|
||||
if (with_landmark) { code_detect_face += `.withFaceLandmarks(true);` }
|
||||
else { code_detect_face += `;` }
|
||||
@ -2324,7 +2324,7 @@ Blockly.Blocks['ugj_library_skyway'] = {
|
||||
}
|
||||
};
|
||||
Blockly.JavaScript['ugj_library_skyway'] = function (block) {
|
||||
var code = `'${ugj_const.library_path}skyway.min.js'`;
|
||||
var code = `'${elutil.path.join(elutil.library_path, 'skyway.min.js')}'`;
|
||||
return [code, Blockly.JavaScript.ORDER_NONE];
|
||||
};
|
||||
|
||||
@ -2614,7 +2614,7 @@ Blockly.Blocks['ugj_file_readsync'] = {
|
||||
Blockly.JavaScript['ugj_file_readsync'] = function (block) {
|
||||
var value_filename = Blockly.JavaScript.valueToCode(block, 'filename', Blockly.JavaScript.ORDER_ATOMIC);
|
||||
var dropdown_encoding = block.getFieldValue('encoding');
|
||||
let filepath = elutil.doc_root + value_filename.replace(/\'/g, '');
|
||||
let filepath = elutil.path.join(elutil.doc_root, value_filename.replace(/\'/g, ''));
|
||||
Blockly.JavaScript.provideFunction_(
|
||||
'require_fs', [`const _fs = require('fs');`]
|
||||
);
|
||||
@ -2837,7 +2837,7 @@ Blockly.Blocks['aquestalk_pi'] = {
|
||||
};
|
||||
Blockly.JavaScript['aquestalk_pi'] = function (block) {
|
||||
var value_talk = Blockly.JavaScript.valueToCode(block, 'talk', Blockly.JavaScript.ORDER_ATOMIC);
|
||||
var code = `'${elutil.executable_path}aquestalkpi/AquesTalkPi -g 50 ' + ${value_talk} + ' | aplay', { shell: true }`;
|
||||
var code = `"${elutil.path.join(elutil.executable_path, 'aquestalkpi/AquesTalkPi') + ' -g 50 ' + value_talk + ' | aplay'}", { shell: true }`;
|
||||
return [code, Blockly.JavaScript.ORDER_NONE];
|
||||
};
|
||||
|
||||
@ -2877,7 +2877,7 @@ Blockly.Blocks['ugj_child_julius'] = {
|
||||
}
|
||||
};
|
||||
Blockly.JavaScript['ugj_child_julius'] = function (block) {
|
||||
var code = `'${elutil.executable_path}julius/julius-simple', ['-C', '${elutil.executable_path}julius/dictation-kit/am-gmm.jconf', '-gram', '${elutil.executable_path}julius/dic/assistant', '-nostrip']`;
|
||||
var code = `'${elutil.path.join(elutil.executable_path, 'julius/julius-simple')}', ['-C', '${elutil.path.join(elutil.executable_path, 'julius/dictation-kit/am-gmm.jconf')}', '-gram', '${elutil.path.join(elutil.executable_path, 'julius/dic/assistant')}', '-nostrip']`;
|
||||
return [code, Blockly.JavaScript.ORDER_NONE];
|
||||
};
|
||||
// irrp.py - pigpioによる赤外線リモコンの学習
|
||||
@ -2898,7 +2898,7 @@ Blockly.Blocks['ugj_child_irrecord'] = {
|
||||
};
|
||||
Blockly.JavaScript['ugj_child_irrecord'] = function (block) {
|
||||
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
||||
var code = `'python3', ['${ugj_const.library_path}irrp.py', '-r', '-g', '${value_gpio}', 'signal', '--post', '130']`;
|
||||
var code = `'python3', ['${elutil.path.join(elutil.library_path, 'irrp.py')}', '-r', '-g', '${value_gpio}', 'signal', '--post', '130']`;
|
||||
return [code, Blockly.JavaScript.ORDER_NONE];
|
||||
};
|
||||
// 送信
|
||||
@ -2923,7 +2923,7 @@ Blockly.Blocks['ugj_child_irplayback'] = {
|
||||
Blockly.JavaScript['ugj_child_irplayback'] = function (block) {
|
||||
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
||||
var value_signal = Blockly.JavaScript.valueToCode(block, 'signal', Blockly.JavaScript.ORDER_ATOMIC);//.replace('{','\\{').replace('}','\\}').replace(/"/g,'\\"').replace(/ /g,'\\ ')
|
||||
var code = `'python3', ['${ugj_const.library_path}irrp.py', '-p', '-g', '${value_gpio}', '--irdata', ${value_signal}, 'signal']`;
|
||||
var code = `'python3', ['${elutil.path.join(elutil.library_path, 'irrp.py')}', '-p', '-g', '${value_gpio}', '--irdata', ${value_signal}, 'signal']`;
|
||||
return [code, Blockly.JavaScript.ORDER_NONE];
|
||||
};
|
||||
// ハッシュ生成
|
||||
@ -2945,7 +2945,7 @@ Blockly.Blocks['ugj_child_irrcvr'] = {
|
||||
Blockly.JavaScript['ugj_child_irrcvr'] = function (block) {
|
||||
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
|
||||
// var code = `'python3', ['./scripts/irrcvr.py', '-g', '${value_gpio}']`;
|
||||
var code = `'${elutil.executable_path}ir_hash/ir_hash', ['${value_gpio}']`;
|
||||
var code = `'${elutil.path.join(elutil.executable_path, 'ir_hash/ir_hash')}', ['${value_gpio}']`;
|
||||
return [code, Blockly.JavaScript.ORDER_NONE];
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user