timer_awaiton

一定の時間で待つ(タイマーループ割り込み+oncmd等の割り込みジャンプに対応)

timer_awaiton p1

p1=0〜(0) : 待ち時間(1ms単位)

(プラグイン / モジュール : mod_TimerRepeat)

解説

プログラムの実行を一定時間だけ中断します。

timer_waiton のawait版です。
詳細はtimer_waitonの頁を参照ください。

waitとawaitの違い
wait 100 ループ ×3回
・・1000ms・・□処理(200ms)□・・1000ms・・□処理(350ms)□・・1000ms・・
 →合計3550ms
await 1000 ループ ×3回
・・1000ms・・□処理(200ms)□・800ms・□処理(350ms)□・650ms・
 →合計3000ms

awaitは処理がかかった分を自動で差し引いて待ちます。


mod_TimerRepeat.hsp をインクルードした時点で、通常のwait(await,stop)命令がtimer_waiton(timer_awaiton,timer_stop)の機能で上書きされます。(waitと書いてもtimer_waitonの処理が実行されます。)

サンプル

// 
//  waitとawaitの違い
//    ※ mod_TimerRepeat.hspによって waitとawaitの機能は上書きされています。
//

#include "mod_TimerRepeat.hsp"

onkey gosub *key
onclick gosub *click

t2 = timer_getTime()
//wait
repeat 10
	wait 100
	t1=timer_getTime()
	mes "wait "+cnt+" : "+(t1-t2)+"ms",1
	t2=t1
	repeat 1000 ;ちょっとだけ重たい処理
		title ""+cnt
	loop
	mes " /処理 "+(timer_getTime()-t2)+"ms" :pos 0
loop
mes

//await
repeat 10
	await 1000
	t1=timer_getTime()
	mes "await "+cnt+" : "+(t1-t2)+"ms",1
	t2=t1
	repeat 1000 ;ちょっとだけ重たい処理
		title ""+cnt
	loop
	mes " /処理 "+(timer_getTime()-t2)+"ms" :pos 0
loop

stop
*key
	title strf("key - %d, click - %d", keyc, clickc) : keyc++
	return
*click
	title strf("key - %d, click - %d", keyc, clickc) : clickc++
	return

関連項目

timer_repeatタイマーループの始まりの場所を示す(mod_TimerRepeat)
timer_loopタイマーループの始まりに戻る(mod_TimerRepeat)
timer_killタイマーループを終了させる(mod_TimerRepeat)
timer_initタイマーループ初期化処理(_init_end まで)(mod_TimerRepeat)
timer_deinitタイマーループ後始末処理(mod_TimerRepeat)
timer_breakタイマーループから抜けだしてタイマーも終了させる(mod_TimerRepeat)
timer_continueタイマーループをやり直す(mod_TimerRepeat)
timer_cntタイマーループのカウンター(mod_TimerRepeat)
timer_intervalstimer_repeat内で繰り返し間隔の取得(mod_TimerRepeat)
timer_getTimerTime実行中のタイマーループの経過時間を取得(mod_TimerRepeat)
timer_getTimeミリ秒タイマー(mod_TimerRepeat)
timer_setTimerSpeedタイマーループの繰り返し間隔を変更(mod_TimerRepeat)
timer_easeタイマーループ内で時間変化によるイージング値の取得(mod_TimerRepeat)
geteaseT時間変化によるイージング値を取得(mod_TimerRepeat)
timer_setTimerEngineタイマーの実行タイミングを変更する(オート/マニュアル)(mod_TimerRepeat)
timer_fireタイマーのマニュアル実行時に確認/実行を行う。(mod_TimerRepeat)
uniq_startuniq()のスコープ開始(mod_TimerRepeat)
uniqユニークな変数を定義(mod_TimerRepeat)
uniq_enduniq()のスコープ終了(mod_TimerRepeat)
timer_waiton実行を一定時間中断する(タイマーループ割り込み+oncmd等の割り込みジャンプに対応)(mod_TimerRepeat)
timer_awaiton一定の時間で待つ(タイマーループ割り込み+oncmd等の割り込みジャンプに対応)(mod_TimerRepeat)
timer_stopプログラム中断(タイマーループ割り込みに対応)(mod_TimerRepeat)

サンプル逆引き (1)

09.waitとawaitの違い/timer_waitonとtimer_awaitonの効果.hsptitle ""+cnt loop mes " / 重たい処理 "+(d3timer()-t2)+"ms" :..

情報

プラグイン / モジュールmod_TimerRepeat
バージョン2.5
作成日2024/1/5
著作者MIZUSHIKI
URLhttp://suwa.pupu.jp/
備考mod_TimerRepeat.hspをインクルードすること。
タイプ拡張命令
グループプログラム制御命令
対応環境・Windows 版 HSP