dsair2_basic
差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
dsair2_basic [2019/02/16 19:53] – [文字を大きくする] yaasan | dsair2_basic [2023/09/02 11:01] (現在) – [DSair BASIC (DSbasic)] yaasan | ||
---|---|---|---|
行 1: | 行 1: | ||
====== DSair BASIC (DSbasic) ====== | ====== DSair BASIC (DSbasic) ====== | ||
- | [[DSair2_ukeng]] | + | Keywords: BASIC, Programming, |
+ | |||
+ | 【お知らせ】DSbasicはバグ報告は受け付けますが、使用方法については一切サポートしません。 | ||
+ | |||
+ | [[DSair2_ukeng]] | ||
DSbasic is a very easy programming solution on your smartphone! This function works in DSair2' | DSbasic is a very easy programming solution on your smartphone! This function works in DSair2' | ||
- | DSbasicは、スマートフォン(Android, | + | DSbasicは、スマートフォン(Android, |
- | {{http:// | + | {{http:// |
- | [[http:// | + | [[http:// |
行 20: | 行 24: | ||
* Support Locomotive and Turnouts control via BASIC language | * Support Locomotive and Turnouts control via BASIC language | ||
* MP3 Play suported in MP3 files of FlashAir SD card. | * MP3 Play suported in MP3 files of FlashAir SD card. | ||
- | ===== Function ===== | + | ===== BASIC Function ===== |
+ | |||
+ | ==== DSair2 Unique Functions | ||
LocAddr is Locomotive address. Default protocol is DCC. If you want to control Marklin' | LocAddr is Locomotive address. Default protocol is DCC. If you want to control Marklin' | ||
行 30: | 行 36: | ||
|ACC| AccAddr, Direction| diverse=0, straight=1 | | |ACC| AccAddr, Direction| diverse=0, straight=1 | | ||
|DIR| LocAddr, Direction| FWD=1, REV=2 | | |DIR| LocAddr, Direction| FWD=1, REV=2 | | ||
- | |FNC| LocAddr, FuncNo, FuncON/OFF| FuncNo=0-28 | | + | |FNC| LocAddr, FuncNo, FuncON/OFF| FuncNo=0-28, FuncON/ |
- | |FNX| LocAddr, FuncNo| FuncNo=0-28 | | + | |FNX| LocAddr, FuncNo| FuncNo=0-28, |
|MP3PLAY| FileName with Path | MP3PLAY " | |MP3PLAY| FileName with Path | MP3PLAY " | ||
|MP3STOP| - | MP3STOP | | |MP3STOP| - | MP3STOP | | ||
- | |GETACC| AccAddr(1-2044) | | | + | |GETACC| AccAddr(1-2044) |指定アドレスのポイント状態(0=div, |
+ | |GETACCW| AccAddr(1-2044) |指定アドレス以降16個分のポイント状態(0=div, | ||
|getslotaddr| SlotNo(0-3) | 4つのユーザー指定アドレススロットからアドレスを取得します。 | | |getslotaddr| SlotNo(0-3) | 4つのユーザー指定アドレススロットからアドレスを取得します。 | | ||
- | |S88START| - | | | + | |getslotspd| SlotNo(0-3) | 4つのユーザー指定アドレススロットから速度を取得します。 | |
- | |S88GET| S88Sensor address(1-16) | Supported | + | |getslotfnc| SlotNo(0-3), |
- | |DCPWM| PWMDuty(0-1203) | | | + | |getslotfncw| SlotNo(0-3) | 4つのユーザー指定アドレススロットからファンクション状態を29bit分返します。 | |
+ | |S88START| - | S88機能を有効にします。S88の関数を使う場合は必ずBASICプログラムの最初に記述して下さい。括弧はつけないでください。 | ||
+ | |S88GET,GETS88| S88Sensor address(1-16) | S88センサーの値(0=OFF, | ||
+ | |GETS88W| S88Sensor address(1-16) | S88センサーの値を16bit分返します。 | ||
+ | |DCPWM| PWMDuty(0-1023) | | | ||
+ | |DCDIR| Direction| FWD=1, REV=2 | | ||
The parameters of function mean as the followings.\\ | The parameters of function mean as the followings.\\ | ||
行 51: | 行 63: | ||
BASIC functions are described in [[https:// | BASIC functions are described in [[https:// | ||
- | ==== BASIC functions ==== | + | ==== Main functions ==== |
- | FOR,NEXT,IF,GOTO,END IF,ELSE,WHILE,WEND, | + | * FOR |
- | PRINT, | + | * NEXT |
- | RND, | + | * IF |
+ | * GOTO | ||
+ | * END IF | ||
+ | * ELSE | ||
+ | * WHILE | ||
+ | * WEND | ||
+ | * CALL | ||
+ | | ||
+ | ==== Drawing functions ==== | ||
+ | |||
+ | |||
+ | * COLOR | ||
+ | * LOCATE | ||
+ | * LINE | ||
+ | * PAINT | ||
+ | * CIRCLE | ||
+ | * PUT | ||
+ | * SCREEN | ||
+ | * CLS | ||
+ | * WIDTH | ||
+ | * PALETTE | ||
+ | * | ||
+ | |||
+ | ==== Math functions ==== | ||
+ | |||
+ | asc, sqr, int, cint | ||
+ | abs, cos, sin, tan | ||
+ | atn, exp, log, rnd, atan2 | ||
+ | |||
+ | ==== Text functions ==== | ||
+ | |||
+ | * val 文字を数値に変換 | ||
+ | * str$ 数値を文字列に変換 | ||
+ | * ltrim$ 左側文字列を抜き出す | ||
+ | * rtrim$ 右側文字列を抜き出す | ||
+ | * left$ | ||
+ | * right$ | ||
+ | * mid$ | ||
+ | * string$ | ||
+ | * space$ スペースを抜き出す | ||
+ | * tab | ||
+ | * ucase$ 英字を大文字にする | ||
+ | * lcase$ 英字を小文字にする | ||
+ | * mid$ | ||
+ | * | ||
+ | |||
+ | |||
+ | |||
+ | ==== Key Input functions ==== | ||
+ | |||
+ | * inkey$ | ||
+ | * input | ||
+ | |||
+ | ==== Mouse Input functions ==== | ||
+ | |||
+ | * getmouse | ||
+ | * | ||
+ | |||
+ | ==== Etc functions ==== | ||
+ | |||
+ | * timer | ||
+ | * SLEEP | ||
+ | * swap | ||
+ | * | ||
===== Examples ===== | ===== Examples ===== | ||
行 148: | 行 223: | ||
==== S88 decoder example ==== | ==== S88 decoder example ==== | ||
- | S88デコーダのセンサデータを取得するサンプルです。 | + | S88デコーダのセンサデータを取得し、Roco BR621(Addr.3)の往復運転を行うサンプルです。 |
+ | |||
+ | Detail: [[http:// | ||
< | < | ||
+ | screen(7) | ||
s88start | s88start | ||
- | testb = getacc(1) | + | |
- | test = s88get(1) | + | pwr 1 |
- | 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 " |
- | 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 " | ||
+ | dir 3,2 | ||
+ | spd 3,200 | ||
+ | sleep 12000 | ||
+ | spd 3,0 | ||
+ | |||
+ | fnc 3,0,0 | ||
+ | fnc 3,1,0 | ||
+ | |||
+ | print " | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Speed based Announce example ==== | ||
+ | |||
+ | This automatic announce program is triggered by slot 1 speed. | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | {{http:// | ||
+ | |||
+ | < | ||
+ | screen(7) | ||
+ | |||
+ | print " | ||
+ | print " | ||
+ | print " | ||
+ | |||
+ | state=0 | ||
+ | currentspd = getslotspd(0) | ||
+ | |||
+ | while 1 | ||
+ | |||
+ | sleep(1000) | ||
+ | if currentspd<> | ||
+ | print " | ||
+ | currentspd = getslotspd(0) | ||
+ | end if | ||
+ | |||
+ | if state=0 then | ||
+ | if getslotspd(0)>512 then | ||
+ | state = 1 | ||
+ | print "Next Station" | ||
+ | mp3play " | ||
+ | end if | ||
+ | end if | ||
+ | |||
+ | if state=1 then | ||
+ | if getslotspd(0)<100 then | ||
+ | state = 0 | ||
+ | print "Stop at Station" | ||
+ | mp3play " | ||
+ | end if | ||
+ | end if | ||
+ | wend | ||
end | end | ||
</ | </ | ||
行 233: | 行 369: | ||
NEXT i | NEXT i | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ===== 活用例 ===== | ||
+ | |||
+ | 皆様のDSbasicの活用例、サンプル、解説などお待ちしております。 | ||
+ | |||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
行 238: | 行 386: | ||
===== Special Thanks ===== | ===== Special Thanks ===== | ||
- | DSbasic is powered by wwwbasic and Ace text editor. | + | DSbasic is powered by [[https:// |
dsair2_basic.txt · 最終更新: 2023/09/02 11:01 by yaasan