ユーザ用ツール

サイト用ツール


dsair2_basic

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
次のリビジョン両方とも次のリビジョン
dsair2_basic [2019/02/13 19:02] – [Function] yaasandsair2_basic [2019/02/17 10:02] – [Function] yaasan
行 1: 行 1:
 ====== DSair BASIC (DSbasic) ====== ====== DSair BASIC (DSbasic) ======
  
-[[DSair2_ukeng]]+Keywords: BASIC, Programming, 教育, Education, Maker, DIY, interpreter,
  
-DSbasic is a very easy programming solution on your smartphone! This function works in DSair2's webapp on your browser.+[[DSair2_ukeng]] ([[DSair2|JPN]])
  
-DSbasicは、スマートフォン(Android,iOS)上で動作する、鉄道模型制御向けに最適化されたBASIC開発環境です。命令を打ち込んで実行するだけで、お好きな自動運転や、運転支援機能を実現できます。+DSbasic is a very easy programming solution on your smartphone! This function works in DSair2's webapp on your browser.\\  
 +DSbasicは、スマートフォン(Android,iOS)上で動作する、鉄道模型制御向けに最適化されたBASIC開発環境です。命令を打ち込んで実行するだけで、お好きな自動運転や、運転支援機能を実現できます。BASICファイルは、SDカードに置けば、ファイル一覧からロードできます。修正したプログラムは、スマホのメモリに保存できます。
  
 {{http://buin2gou.sakura.ne.jp/sblo_files/powerele/image/flashair_28Pixel20229-thumbnail2.png}}\\  {{http://buin2gou.sakura.ne.jp/sblo_files/powerele/image/flashair_28Pixel20229-thumbnail2.png}}\\ 
行 36: 行 37:
 |MP3STOP| - | MP3STOP | |MP3STOP| - | MP3STOP |
 |GETACC| AccAddr(1-2044) | | |GETACC| AccAddr(1-2044) | |
 +|getslotaddr| SlotNo(0-3) | 4つのユーザー指定アドレススロットからアドレスを取得します。 |
 +|getslotspd| SlotNo(0-3) | 4つのユーザー指定アドレススロットから速度を取得します。 |
 +|getslotfnc| SlotNo(0-3), FuncNo(0-28) | 4つのユーザー指定アドレススロットからファンクション状態を取得します。 |
 |S88START| - | | |S88START| - | |
 |S88GET| S88Sensor address(1-16) | Supported 1 S88 decoder | |S88GET| S88Sensor address(1-16) | Supported 1 S88 decoder |
 +|DCPWM| PWMDuty(0-1203) | |
 +|DCDIR| Direction| FWD=1, REV=2 |
 +
 +The parameters of function mean as the followings.\\ 
 +引数の意味は以下の通りです。
 +
 +|AccAddr| 1-2044 |ポイントアドレス,MM2の場合は1-320|
 +|LocAddr| 1-9999 |機関車アドレス,MM2の場合は1-255。|
 +|FuncNo | 0-28 | ファンクション番号|
 +|FuncON/OFF | 0-1 | 0=OFF, 1=ON |
 +|Direction | 1-2| 0 or 1=FWD, 2=REV |
  
 BASIC functions are described in [[https://github.com/google/wwwbasic|wwwbasic]] user manual. BASIC functions are described in [[https://github.com/google/wwwbasic|wwwbasic]] user manual.
行 134: 行 149:
 sleep 3000 sleep 3000
 print "STOP! Finish!" print "STOP! Finish!"
 +</code>
 +
 +==== S88 decoder example ====
 +
 +S88デコーダのセンサデータを取得し、Roco BR621(Addr.3)の往復運転を行うサンプルです。
 +
 +Detail: [[http://powerele.sblo.jp/article/185548716.html|DSair2で自動運転をしてみる]]
 +
 +<code>
 +screen(7)
 +s88start
 +
 +pwr 1
 +print "START S88 Control"
 +
 +dir 3,1
 +fnc 3,0,1
 +fnc 3,1,1
 +fnx 3,2
 +spd 3,200
 +
 +while s88get(1)=0 
 +print "RUN!"
 +sleep 1000
 +wend
 +
 +print "S88 Adr.1 Detected"
 +spd 3,0
 +sleep 2000
 +
 +print "REV"
 +dir 3,2
 +spd 3,200
 +sleep 12000
 +spd 3,0
 +
 +fnc 3,0,0
 +fnc 3,1,0
 +
 +print "end."
 +end
 +</code>
 +
 +
 +==== Speed based Announce example ====
 +
 +This automatic announce program is triggered by slot 1 speed.
 +
 +[[http://powerele.sblo.jp/article/185561119.html|DSbasicで運転支援機能]]
 +
 +{{http://buin2gou.sakura.ne.jp/sblo_files/powerele/image/DSbasic_21-thumbnail2.png}}
 +
 +<code>
 +screen(7)
 +
 +print "Announce supporter"
 +print "Addr:";getslotaddr(0)
 +print "Speed:";getslotspd(0)
 +
 +state=0
 +currentspd = getslotspd(0)
 +
 +while 1 
 +
 +sleep(1000)
 +if currentspd<>getslotspd(0) then
 +print "Current Speed is ";getslotspd(0)
 +currentspd = getslotspd(0)
 +end if
 +
 +if state=0 then
 +if getslotspd(0)>512 then
 +state = 1
 +print "Next Station"
 +mp3play "NextStationAnnounce.mp3"
 +end if
 +end if
 +
 +if state=1 then
 +if getslotspd(0)<100 then
 +state = 0
 +print "Stop at Station"
 +mp3play "StopStationAnnounce.mp3"
 +end if
 +end if
 +wend
 +end
 </code> </code>
 ===== Hints ===== ===== Hints =====
  
-==== 文字を大きくする ====+==== Font size / 文字を大きくする ====
  
 screen(7)コマンドを最初に宣言すると、文字が大きくなります(おおよそ二倍) screen(7)コマンドを最初に宣言すると、文字が大きくなります(おおよそ二倍)
行 145: 行 247:
 </code> </code>
  
 +==== Comment / コメント ====
 +
 +If you want to use comment, type like the following.
 +
 +<code>
 +'Comment example
 +'コメントです
 +</code>
 ==== 関数・サブルーチンを宣言する ==== ==== 関数・サブルーチンを宣言する ====
  
dsair2_basic.txt · 最終更新: 2023/09/02 11:01 by yaasan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki