UdonLibrary 1.0.0
機械システム研究部 C++ ライブラリ
読み取り中…
検索中…
一致する文字列を見つけられません
ユーティリティ

Show 関数

様々なオブジェクトを出力でき、マルチプラットフォームで動作します。PC の場合標準出力、マイコンの場合 USB シリアルへ送信します。また Udon::Showln 関数を用いると最後に改行を出力します。

void setup()
{
Serial.begin(115200); // マイコンを使用する場合必要
Udon::Show("Hello world!");
}
void Show(Args &&... args)
区切り文字ありで出力する
Definition Show.hpp:339

ユーザー定義型の出力

struct Sample
{
int i;
double d;
};
void setup()
{
Serial.begin(115200);
Udon::Show(Sample{ 10, 20.0 });
Udon::Show(Sample{ 10, 20.0 });
}
#define UDON_ENUMERABLE(...)
メンバ変数の列挙を可能にする
Definition EnumerableMacro.hpp:11
{ 10, 20 }{ 10, 20 }

Assert 関数

Assert(bool expression, const char* const message = "", AssertAction action = AssertAction::Abort)

expression が false となるとき、任意のメッセージを出力しプログラムを中断する関数です。actionUdon::AssertAction::Skip を指定することで中断しないように設定できます。

#include <Udon.hpp>
static Udon::PadPS5BT pad;
void setup()
{
Serial.begin(115200);
Udon::Assert(pad.begin(), "PS5 BT failed to start!");
}
Bluetooth経由PS5コントローラークラス
Definition PadPS5BT.hpp:31
bool begin()
コントローラーと通信開始
Definition PadPS5BT.hpp:53
void Assert(bool expression, const char *const message="", AssertAction action=AssertAction::Abort)
アサート
Definition Assert.hpp:20

Normalized 関数

double Normalized(double value, double min, double max)

-∞~+∞ の範囲を min~max の範囲に変換するします。最小値が設定できるようになった剰余算のイメージです。

Normalized(190, -180, 180) == 10
Normalized(-200, -180, 180) == -20