ユーザ用ツール

サイト用ツール


dsair2_basic

差分

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

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
次のリビジョン両方とも次のリビジョン
dsair2_basic [2019/02/14 17:18]
– [Function] yaasan
dsair2_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) | | |DCPWM| PWMDuty(0-1203) | |
 +|DCDIR| Direction| FWD=1, REV=2 |
  
 The parameters of function mean as the followings.\\  The parameters of function mean as the followings.\\ 
行 148: 行 153:
 ==== S88 decoder example ==== ==== S88 decoder example ====
  
-S88デコーダのセンサデータを取得するサンプルです。+S88デコーダのセンサデータを取得し、Roco BR621(Addr.3)の往復運転を行うサンプルです。 
 + 
 +Detail: [[http://powerele.sblo.jp/article/185548716.html|DSair2で自動運転をしてみる]]
  
 <code> <code>
 +screen(7)
 s88start s88start
-testb = getacc(1) + 
-test = s88get(1) +pwr 
-print s88get(2) +print "START S88 Control" 
-print s88get(3) + 
-print s88get(4) +dir 3,1 
-print s88get(5+fnc 3,0,1 
-print s88get(6) +fnc 3,1,1 
-print s88get(7+fnx 3,2 
-print s88get(8+spd 3,200 
-print s88get(9+ 
-print s88get(10+while s88get(1)=0  
-print s88get(11+print "RUN!" 
-print s88get(12+sleep 1000 
-print s88get(13+wend 
-print s88get(14+ 
-print s88get(15+print "S88 Adr.1 Detected" 
-print s88get(16)+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(0then 
 +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 end
 </code> </code>
 ===== Hints ===== ===== Hints =====
  
-==== 文字を大きくする ====+==== Font size / 文字を大きくする ====
  
 screen(7)コマンドを最初に宣言すると、文字が大きくなります(おおよそ二倍) screen(7)コマンドを最初に宣言すると、文字が大きくなります(おおよそ二倍)
行 181: 行 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