10 char firstCodeText[32];
12 bool isChangedFirstCode =
false;
15 msg_f(
"Please set first code", 4 );
18 sprintf( firstCodeText,
"%05ld", firstCode.
getFirstCode() );
19 msg_f( firstCodeText, 5 );
21 msg_f( getCurrentDigitText( digit ), 6 );
23 ev3_speaker_set_volume( 20 );
24 ev3_speaker_play_tone( 200, 500 );
29 if( ev3_button_is_pressed( ENTER_BUTTON ) ) {
30 isChangedFirstCode =
true;
35 if( ev3_button_is_pressed( UP_BUTTON ) ) {
37 isChangedFirstCode =
true;
39 if( ev3_button_is_pressed( DOWN_BUTTON ) ) {
41 isChangedFirstCode =
true;
43 if( ev3_button_is_pressed( RIGHT_BUTTON ) ) {
45 isChangedFirstCode =
true;
47 if( ev3_button_is_pressed( LEFT_BUTTON ) ) {
49 isChangedFirstCode =
true;
55 if( isChangedFirstCode ) {
56 ev3_speaker_play_tone( 1000, 100 );
57 sprintf( firstCodeText,
"%05ld", firstCode.
getFirstCode() );
58 msg_f( firstCodeText, 5 );
59 msg_f( getCurrentDigitText( digit ), 6 );
63 isChangedFirstCode =
false;
68 sprintf( firstCodeText,
"Input first code for <%05ld>.", firstCode.
getFirstCode() );
69 msg_f( firstCodeText, 4 );
70 ev3_speaker_play_tone( 1500, 50 );
72 ev3_speaker_play_tone( 1500, 50 );
79 char* UserInterface::getCurrentDigitText( int8_t currentDigit ) {
80 static char text[ 32 ];
82 if( currentDigit == 1 ) {
83 sprintf( text,
" -" );
84 }
else if( currentDigit == 2 ) {
85 sprintf( text,
" - " );
86 }
else if( currentDigit == 3 ) {
87 sprintf( text,
" - " );
88 }
else if( currentDigit == 4 ) {
89 sprintf( text,
" - " );
90 }
else if( currentDigit == 5 ) {
91 sprintf( text,
"- " );
95 sprintf( text,
"-----" );
void msg_f(const char *str, int32_t line)
走行体が走り出す前にユーザが入力するインターフェースを提供するクラス