Beispiel #1
0
void UserMain( void * pd )
{

    initWithWeb();
    Nunchuck_Init(); // FIXME
    LLInit(1);
    TheWSHandler = MyDoWSUpgrade;

    stepper.Init();
    ConfigureStepper( &stepper, 1 );
    stepSpeed = 100;
    stepDir = 1;
    StartStepper( 1, stepDir, stepSpeed );
    stepForever = true;
    OSSemInit( &SockReadySem, 0 );
    OSCritInit( &I2CLock );

    iprintf("Application: %s\r\nNNDK Revision: %s\r\n",AppName,GetReleaseTag());
    OSTimeDly(2);
    OSSimpleTaskCreate(ReportTask, 5);
    OSSimpleTaskCreate(InputTask, MAIN_PRIO-1);
    OSSimpleTaskCreate(RangingTask, 2);

    EnableEncoder(EncodeStep, ButtonChange, ButtonDoubleClick );

    ClearTaskTimes();
    SMPoolPtr pp;

    while(1) {
        fd_set error_fds;
        FD_ZERO( &error_fds );
        OSCritEnter( &I2CLock, 0 );
        nun.Update();
        OSCritLeave( &I2CLock );

        serv_x.SetPos(nun.stick.x);
        serv_y.SetPos(nun.stick.y);

//        iprintf("%lu\na_x: %4.4d - a_y: %4.4d - a_z: %4.4d\ns_x: %3.3d - s_y: %3.3d - b_z: %d - b_c: %d\n\n",
//            TimeTick, nun.accel.x, nun.accel.y, nun.accel.z,
//            nun.stick.x, nun.stick.y,
//            nun.button.z, nun.button.c);
//        iprintf("range: %u\n", lidarRange);
            if (ws_fd > 0){
                SendConfigReport(ws_fd);
            }

    }
}