void main_task()

in sample/app.cpp [37:89]


void main_task( intptr_t unused )
{
    /* Open Bluetooth file */
    g_bluetooth = ev3_serial_open_file( EV3_SERIAL_BT );
    assert( g_bluetooth != NULL );

    /* Bluetooth通信タスクの起動 */
    act_tsk( BT_TASK );


    msg_f("Check Colors", 1);
    msg_f(" create from github.com/korosuke613/etrobocon2017", 2);
    ColorSensor colorSensor(PORT_3);
    TouchSensor touchSensor(PORT_1);
    SonarSensor sonarSensor(PORT_2);
    int time_count = 0;
    char msg[32];
    int color_num;
    std::string color_name[8] = {"NONE", "BLACK", "BLUE", "GREEN", "YELLOW", "RED", "WHITE", "BROWN"};
    rgb_raw_t rgb;
    while(1){
        color_num = (int)colorSensor.getColorNumber();
        colorSensor.getRawColor( rgb );
        sprintf ( msg, "LightValue: %d", colorSensor.getBrightness());
        msg_f ( msg, 4 ) ;
        
        sprintf ( msg, "ColorNumber: %s", color_name[color_num].c_str());
        msg_f ( msg, 5 ) ;
        sprintf ( msg, "    R:%3d G:%3d B:%3d", rgb.r, rgb.g, rgb.b);
        msg_f ( msg, 6 ) ;

        sprintf ( msg, "DistanceEye: %d", sonarSensor.getDistance());
        msg_f ( msg, 7 );

        if(sonarSensor.getDistance() < 10){
            time_count++;
        }

        sprintf ( msg, "DistanceTime: %d", time_count);
        msg_f ( msg, 8 );
        
        if ( touchSensor.isPressed()== 1)
        {
            break; /* タッチセンサが押された */
        }
        tslp_tsk ( 4 ) ;        
    }

    ter_tsk( BT_TASK );
    fclose( g_bluetooth );

    ext_tsk();
}