顯示具有 osep 標籤的文章。 顯示所有文章
顯示具有 osep 標籤的文章。 顯示所有文章

2025年8月24日

osep scratch telegram擴充模組

 如何使用osep scratch telegram擴充模組

安裝telegram app

建立telegrambot機器人

    1. 新增聯絡人 BotFather,https://t.me/botfather 

    2. 輸入/newbot

    3. 輸入 Bot 名稱

    4.輸入 Bot 使用者名稱,必須為 bot 結尾

    5.成功建立後取得 Telegram API token,這個token後面會用到


    6.在聯絡人功能中輸入 Bot 使用者名稱

    7.新增 Bot 為聯絡人

    8.在群組中加入Bot機器人

    9.取得 Chat ID:在瀏覽器中輸入下列網址(紅字部分改為你的token):

    https://api.telegram.org/bot"YOUR_BOT_TOKEN"/getUpdates 

    


如果沒有看到cat id可以先在telegram群組中先輸入簡單文字訊息,再執行網址。
 
osep scratch temegram擴充模組
有了token和cat id,就可以在osep scratch中的telegrambot擴充模組中,透過積木傳送訊息了

 
 

 

   

2025年8月23日

push notification api擴充套件

先把push notification api安裝起來,同意權限。
這時你就會有一組API key可以用,必要時重新產生新的api key
填入抬頭和內容及訊息要連接網址(可空白)。
有api key就可以在osep scratch使用擴充套件了

2025年7月14日

osep讀取雲端硬碟sb3檔案

 osep scratch如何直接讀取雲端硬碟上的sb3檔案

先把雲端硬碟的程式安裝起來,就可以直接讀取了。在ubuntu下設定->線上帳號,選擇你要登入的雲端硬碟,就Ok了。


 odysee影片:https://odysee.com/osep_read_googledrive:5?r=B3zsNLqGZNtsJ3QNk95mfXcp249s6BJD

 

夢21

2024年1月10日

osep_scratch切換鏡頭

 記錄一下自已改的地方

src/lib/video/camera.js

在const requestStack = [];後面加上

/*add by chen 20221209 end */

在const requestVideoStream = videoDesc => {
    let streamPromise;
後面加上

let video_value ={};
    const webcamId= `${window.now_webcamId}`;
    if (webcamId == "user"){
        video_value = {facingMode: "user"};
    } else if ( webcamId == "environment" ){
        video_value = {facingMode: "environment"};
    } else{
      video_value = {deviceId: webcamId };
    }

修改video: videoDesc為

video: video_value,
        // video: videoDesc ,video:{facingMode: "user"}, {facingMode: "environment"},video:{deviceId: "xxxx" }


2023年1月24日

osep scratch3 編譯

 1.安裝git 和node js

2.在家目錄下指令

git  clone https://github.com/estea8968/osep_web_serial.git

cd osep_web_serial

npm install

npm run copy

npm start

如果是win系統

 git  clone https://github.com/estea8968/osep_web_serial.git

cd osep_web_serial

npm install

npm run copy:win

npm run start:win

打包npm run build

2022年6月14日

scratch3增加擴充積木(進階)

30天通github

https://github.com/doggy8088/Learn-Git-in-30-days

java script快速入門播放清單

https://youtube.com/playlist?list=PLxNBsYH_m6ywXdOfpVgibRbJzidecajoX

scratch-vm index.js結構

 //require基本架構

const ArgumentType = require('../../extension-support/argument-type');
const BlockType = require('../../extension-support/block-type');
const formatMessage = require('format-message');
const msg = require('./translation');

 

物件

class 物件名稱 {

//物件架構

  constructor(runtime) {
        the_locale = this._setLocale();
        this.runtime = runtime;
    }

//物件資料

  getInfo() {
        the_locale = this._setLocale();
        return {
            id: 'mqtt',
            color1: '#003D79', //'#0C5986',
            color2: '#34B0F7',
            name: 'MQTT',
            blockIconURI: 'data:image/png;base64,',
            blocks: [
                {

               }

}

function(){

}

module.exports = 物件名稱;


語系

方法1:

在index.js中有

const msg = require('./translation');

物件中要有function定義語系

_setLocale() {
        let now_locale = '';
        switch (formatMessage.setup().locale) {
            case 'zh-tw':
                now_locale = 'zh-tw';
                break;
            default:
                now_locale = 'en';
                break;
        }
        return now_locale;
    } 

物件架構是呼叫function定義語系

constructor(runtime) {
        the_locale = this._setLocale();
        this.runtime = runtime;
    }

使用方法:

msg.disconnect[the_locale];

在資料夾下,要有translation.js

 檔案內容:

export const disconnect = {
    'en': 'disconnected',
    'zh-tw': '未連線',
};

方法2:

在index.js中加入語系物件

const formatMessage = require('format-message');

const FormLcdShow = {
    'en': 'LCD show text [VALUE] at [ROW] row',
    'zh-tw': 'LCD顯示文字[VALUE]在第[ROW]列',
};

在物件中加入架構

constructor(runtime,util) {
        the_locale = this._setLocale();
        this.runtime = runtime;
    }

需要有function _setLocale()

_setLocale () {
        let now_locale = '';
        switch (formatMessage.setup().locale){
            case 'en':
                now_locale='en';
                break;
            case 'zh-tw':
                now_locale= 'zh-tw';
                break;
            default:
                now_locale='en';
                break;
        }
        return now_locale;
    }

使用方法

FormLcdShow [the_locale]


積木表示

在物件中使用陣列blocks: [ ]包括所有積木。

每個積木為一物件{}。內容為

opcode: 'digital_write',
                    blockType: BlockType.COMMAND,
                    text: FormDigitalWrite[the_locale],
                    arguments: {
                        PIN: {
                            type: ArgumentType.NUMBER,
                            defaultValue: 'D2',
                            menu: "digital_pins"
                        },

                     }

方法3:

/src/lib/libraries/extensions/index.jsx的

翻譯檔案在/node_modules/scratch-l10n/locales/editor-msgs.js

中文語系在最後面。

格式範例:

"gui.extension.microbitMore.description":"玩轉 micro:bit 的所有功能。(v2-0.2.4)",


2021年11月4日

MQTT記事

 

參考:https://ithelp.ithome.com.tw/articles/10226629

1.安裝MQTT server 

sudo apt install mosquitto
2.安裝MQTT client
sudo apt install mosquitto-clients 
 
mosquitto_sub : 訂閱
mosquitto_pub : 發布
-d : debug 模式 => debug
-t : 訂閱的主題 => topic
-h : Broker 的 IP => host
-m : 發送的內容 => message
-v : 顯示主題名稱 => verbosely
 

終端機-1 (Subscribe)訂閱

mosquitto_sub -d -t Try/MQTT 
或
mosquitto_sub -d -h 54.xx.xx.xx -t Try/MQTT

終端機-2 (Publish)發佈

mosquitto_pub -d -t Try/MQTT -m "Try Message"
mosquitto_pub -d -h 54.xx.xx.xx -t Try/MQTT -m "Try Message"

使用帳密

mosquitto_passwd -c <passwordfile> <username>
指定密碼檔案 
sudo mosquitto_passwd -c /etc/mosquitto/passwd try   
這樣會覆蓋掉原來的passwd檔。先編一個帳密碼
vim usr.pwd
內容如下
user:123456
student:123
使用指令轉成加密檔 
mosquitto_passwd  -U usr.pwd 
sudo mv  usr.pwd /etc/mosquitto/
 

設定ACL(Access Control List)

sudo vi /etc/mosquitto/acl 
內容如下 
# 用戶 try 能夠讀寫 Try/MQTT這個主題
#user try 
#topic readwrite Try/MQTT
(設定後失敗,先註解掉) 

在mosquitto.conf 參數檔案,開啟模式

打開 mosquitto.conf 參數檔案
設定檔位置在 /etc/mosquitto/mosquitto.conf

增加

listener 1883
protocol mqtt
listener 8081 127.0.0.1
protocol websockets
allow_anonymous true
這樣js 才能用ws://127.0.0.1:8081連線 
 
password_file /etc/mosquitto/passwd
per_listener_setting true
acl_file /etc/mosquitto/acl
 
per_listener_setting參數設成true,代表個別設置每個偵聽器物件的安全性: 
allow_anonymous 允許匿名存取,設成false 代表需使用者名稱。
password_file 帳號密碼的檔案
acl_file 對於使用者權限的設置檔案
 
重啟服務
sudo service mosquitto stop
sudo service mosquitto start 
訂閱 
mosquitto_sub -v -d -t Try/MQTT -u "try" -P "xxxx"  
mosquitto_sub -d -t Try/MQTT 
mosquitto_sub -d -h 54.xx.xx.xx -t Try/MQTT
發佈 
mosquitto_pub -d -t Try/MQTT -m "Try Message"  
mosquitto_pub -d -h 54.xx.xx.xx -t Try/MQTT -m "Try Message"
  

 

 測試了一下一個網站還不錯:

http://mqttgo.io/

使用osep離線版線線網址為:

ws://MQTTGO.io:8000/mqtt


 

 

2021年7月1日

在OSEP中使用NodeMCU ESP8266

在OSEP中使用NodeMCU ESP8266

0.認識NodeMCU

D0==>16
D1==>05
D2==>04
D3==>00
D4==>02
D5==>14
D6==>12
D7==>13
D8==>15
D9==>03
D10==>01

GPIO是什麼:https://zh.wikipedia.org/wiki/GPIO

類比腳位是A0

esp8266介紹:https://pcbdesign88.wordpress.com/2018/04/11/nodemcu%E9%96%8B%E7%99%BC%E6%9D%BFesp8266-wifi%E6%A8%A1%E7%B5%84%E4%BB%8B%E7%B4%B9/

 1.安裝osep

安裝osep 

2.arduino ide燒錄韌體(含wifi ssid和密碼)

 arduino ide燒錄設定:https://wdpsestea.blogspot.com/2021/06/arduino-ide-nodemcu.html

注意:NodeMCU ESP8266只支援wifi 2.4G無線連接,請不要設定5G AP的連線

3.執行osep s3-extend-tool連上s3e

 

4.執行線上或是離線版的osep_scrathc3,開啟擴充套件esp8266

osep線上版:https://ys-fang.github.io/OSEP/app/


 

5.數位角位輸出亮led燈

 

使用D2(GPIO12)來亮啟LED燈。


6.讀取數位角位信號



7.做類比數位輸出pwm-呼吸燈

8.讀取類比腳位信號

NodeMCU只有一個類比腳位A0


9.接伺服馬達

伺服馬達是高用電的設備,現在常見的伺服馬達,建議要接5V的外接電源,電流量要300MA,單一NodeMCU的電量不足以支持伺服馬達。圖使用腳位為D2(GPIO4)

10.超音波測距HC-SR04

圖使Echo用D1(GPIO5)和Trig用D2(GPIO4)

其他:

 fritzing:

https://fritzing.org/download/

 https://github.com/fritzing

https://www.npackd.org/p/fritzing/0.9.6


 

教學播放清單:

https://youtube.com/playlist?list=PL52qbzg6rwU65672-2hjKSuNagPTB_0cX

osep_scratch3線上版:https://sites.google.com/view/osep-scratch3/%E7%B7%9A%E4%B8%8A%E8%B3%87%E6%BA%90


2020年9月3日

修改scratch3預載內容

 預載的內容在:scratch-gui/src/lib/default-project資料夾內。

index.js和project-data.js

把要加入的svg檔案拷貝到資料夾內,並使用 md5sum 檔案,算出編碼後的數字,例如:

md5sum osep.svg
48b6771e8ddcb19a37584bf4ce4df834  osep.svg 

把osep.svg重新命名為48b6771e8ddcb19a37584bf4ce4df834.svg

編輯index.js

在前面import中加入

import osep from '!raw-loader!./48b6771e8ddcb19a37584bf4ce4df834.svg';

在最後面加入

{
        id: '48b6771e8ddcb19a37584bf4ce4df834',
        assetType: 'ImageVector',
        dataFormat: 'SVG',
        data: encoder.encode(osep)
    },

 

編輯project-data.js

新增角色加入

{
                isStage: false,
                name: translator(messages.sprite, {index: 1}),
                variables: {},
                lists: {},
                broadcasts: {},
                blocks: {},
                currentCostume: 0,
                costumes: [
                    {
                        assetId: '48b6771e8ddcb19a37584bf4ce4df834',
                        name: translator(messages.costume, {index: 1}),
                        bitmapResolution: 1,
                        md5ext: '48b6771e8ddcb19a37584bf4ce4df834.svg',
                        dataFormat: 'svg',
                        rotationCenterX: 46,
                        rotationCenterY: 50
                    }
                ],
                sounds: [
                    {
                        assetId: '83c36d806dc92327b9e7049a565c6bff',
                        name: translator(messages.meow),
                        dataFormat: 'wav',
                        format: '',
                        rate: 22050,
                        sampleCount: 18688,
                        md5ext: '83c36d806dc92327b9e7049a565c6bff.wav'
                    }
                ],
                volume: 100,
                visible: true,
                x: 200,//角色座標
                y: -150,
                size: 50,//角色大小%
                direction: 90,
                draggable: false,
                rotationStyle: 'all around'
            }

 存檔,重新編譯程式。


src/lib/libraries/sprites.json記錄選取角色的資料, costumes.json圖檔資料

 storage.js

 

左上角超連結在src/playground/render-gui.jsx 

找到const onClickLogo =