Ejemplo n.º 1
0
void CKSSetupGUIPane::Init()
{
	mpPane = ge::IPane::Create();
	mpPane->SetSize(ge::SSize(320,245));
	
	tint32 iPosY = 0;
	CreateBitmap(ge::IControl::giNoID, IDB_Back_Setup, ge::SPos(0, 0)); iPosY += 60;
	
	mpDevice_BMP				= CreateBitmap(ge::IControl::giNoID, IDB_Back_Setup_Device, ge::SPos(0, 54));
	mpDevice_Asio_BMP			= CreateBitmap(ge::IControl::giNoID, IDB_Back_Setup_Device_Asio, ge::SPos(0, 54)); 


	
	// Take lock - no questions
	miBlockSetAudioDevice_volatile = 1;

//	Prepare_Popups();

	
	// Audio In devices
	ge::IPopupMenu::SMenuItemList list;
	list.iItemCount = 0;
	mpPopupMenuAudioIn = CreatePop( giCtrl_Sound_Card_In_Popup, IDB_Button_Popup, list, ge::SPos(47, 69), mpPane);
	// Audio devices/ out
	//ge::IPopupMenu::SMenuItemList list;
	//list.iItemCount = 0;
	mpPopupMenuAudioDevices = CreatePop( giCtrl_Sound_Card_Popup, IDB_Button_Popup, list, ge::SPos(47, 107), mpPane);

	// Audio frequency - giCtrl_Sample_Rate_Popup
	list.iItemCount = 0;
	mpPopupMenuAudioRates = CreatePop( giCtrl_Sample_Rate_Popup, IDB_Button_Popup, list, ge::SPos(47, 107+38), mpPane);

	// Audio buffer - giCtrl_Buffer_Size_Popup
	list.iItemCount = 0;
	mpPopupMenuAudioBuffs = CreatePop( giCtrl_Buffer_Size_Popup, IDB_Button_Popup, list, ge::SPos(47, 107+(38*2)), mpPane);
	

	// ASIO Setup
	mpASIO_Button = CreateButton(giCtrl_Asio_Setup, IDB_Button_Close, ge::SPos(59, 57), false);
	
	
	// Close
	CreateButton(giCtrl_Close_Audio_Setup, IDB_Button_Close, ge::SPos(232, 220), false);

	InitAudioDevicePopupValues();
	InitAudioDevicePopupValuesInput();

	//!!! Remove this
	SetupIO();

	// Release lock
	miBlockSetAudioDevice_volatile--;
}
void RbFirmataController::setupArduino(const int & version)
{
	m_EInitializedConnection.disconnect();
    
	//Only do setup once. This is in case it gets called.
	if(m_bSetupStarted)
		return;

	//Signal that we are starting setup.
	m_bSetupStarted = true;

    // print firmware name and version to the console
    //std::cout << this->getFirmwareName(); 
	//std::cout << "firmata v" << this->getMajorFirmwareVersion() << "." << this->getMinorFirmwareVersion() << "\r\n";

	SetupIO();

    // it is now safe to send commands to the Arduino
    m_bSetupComplete = true;

 //       
 //   // Note: pins A0 - A5 can be used as digital input and output.
 //   // Refer to them as pins 14 - 19 if using StandardFirmata from Arduino 1.0.
 //   // If using Arduino 0022 or older, then use 16 - 21.
 //   // Firmata pin numbering changed in version 2.3 (which is included in Arduino 1.0)
 //   
 //   // set pins D2 and A5 to digital input
 //   this->sendDigitalPinMode(2, ARD_INPUT);

 //   // set pin A0 to analog input
 //   this->sendAnalogPinReporting(0, ARD_ANALOG);
 //   
 //   // set pin D13 as digital output
	//this->sendDigitalPinMode(13, ARD_OUTPUT);
 //   // set pin A4 as digital output
 //   this->sendDigitalPinMode(18, ARD_OUTPUT);  // pin 20 if using StandardFirmata from Arduino 0022 or older

 //   // set pin D11 as PWM (analog output)
	//this->sendDigitalPinMode(11, ARD_PWM);
 //   
 //   // attach a servo to pin D9
 //   // servo motors can only be attached to pin D3, D5, D6, D9, D10, or D11
 //   this->sendServoAttach(9);
	//this->sendServo(9, 0, true);

    // Listen for changes on the digital and analog pins
	//m_EDigitalPinChanged = this->EDigitalPinChanged.connect(boost::bind(&RbFirmataController::digitalPinChanged, this, _1));
	//m_EAnalogPinChanged = this->EAnalogPinChanged.connect(boost::bind(&RbFirmataController::analogPinChanged, this, _1));

	m_WaitForIOSetupCond.notify_all();
}
Ejemplo n.º 3
0
RETURN_STATUS InitBluetooth (
  USART_t                             *Usart
)
{
  DBG (INFO_MESSAGE, "InitBluetooth");

  //mUsart = Usart; //FIXME ta instrukcja zawiesza CPU
  SetupIO ();

  DEBUG_CODE(
    ResetIntoAtMode ();
    SendReceiveAtCommand (NULL, mRxSerialBuffer, sizeof (mRxSerialBuffer));
    ASSERT(strstr (mRxSerialBuffer, "OK") != NULL);
    SendReceiveAtCommand ("NAME=MROZO", mRxSerialBuffer, sizeof (mRxSerialBuffer));
    ASSERT(strstr (mRxSerialBuffer, "OK") != NULL);
    SendReceiveAtCommand ("NAME", mRxSerialBuffer, sizeof (mRxSerialBuffer));
    ASSERT(strstr (mRxSerialBuffer, "+NAME:MROZO") != NULL);
    SendReceiveAtCommand("PSWD=1234",mRxSerialBuffer, sizeof (mRxSerialBuffer));
    ASSERT(strstr (mRxSerialBuffer, "OK") != NULL);
  );
Ejemplo n.º 4
0
void main(void) {
    signed char ret = 0;
    signed char lastMenu = 0;
    char pnum = 0;

    SetupIO();
    MOTOR_FORWARD = 0;
    MOTOR_REVERSE = 0;

    Move_shifted_position.ul = 0;
    Move_position[0].ul = 0;
    Move_position[1].ul = 0;
    //PID_SetPoint = 0;
    char idx;
    for (idx = 0; idx < 16; idx++) RotaryDetentIntervals[idx] = 0xFF;

    LoadSettings();
    //FactoryDefault();

    SetupHardware();

    LCD_PowerUp();
    LCD_ClearDisplay();

    LCD_PrintString("CINEFLUX ORBIT\0");
    LCD_SetPosition(1, 0);
    LCD_PrintString(VER);
    Wait_ms(2000);

    const char *COMMAND_0 = "ORBIT MODE\0";
    const char *COMMAND_1 = "WAYPOINT MODE\0";
    const char *COMMAND_3 = "RUN PRESET\0";
    const char *COMMAND_2 = "REALTIME MODE\0";
    const char *COMMAND_4 = "BATTERY VOLTAGE\0";
    const char *COMMAND_5 = "GO TO SLEEP\0";
    const char *COMMAND_6 = "EXTERNAL CTRL MODE\0";
    const char*CommandMenu[7];
    CommandMenu[0] = COMMAND_0;
    CommandMenu[1] = COMMAND_1;
    CommandMenu[2] = COMMAND_2;
    CommandMenu[3] = COMMAND_3;
    CommandMenu[4] = COMMAND_4;
    CommandMenu[5] = COMMAND_5;
    CommandMenu[6] = COMMAND_6;

    bFollowMode = 1;
    LCD_ClearDisplay();
    LCD_PrintString("MOVE TO ZERO DEGREES\0");
    LCD_SetPosition(1, 0);
    LCD_PrintString("THEN CLICK...\0");
    GetClick();
    bClear_MotorPosition = 1;
    while (bClear_MotorPosition) Idle();
    Wait_ms(10);
    bFollowMode = 0;
    LCD_ClearDisplay();

    while (1) {
        UI_Location = UI_LOC_MAINMENU;
        ret = DisplayMenu(CommandMenu, 6, lastMenu);
labelProcessCommand:
        switch (ret) {
            case 0:
            case USER_INPUT_MACRO_ORBITMODE:
                lastMenu = 0;
                ret = CreateOrbitProgram();
                if (ret == -2) RealtimeMode();
                if (ret == -1) RealtimeMode();
                if (ret<-2) goto labelProcessCommand;
                break;
            case 1:
            case USER_INPUT_MACRO_WAYMODE:
                lastMenu = 1;
                ret = CreateWaypointProgram();
                if (ret<-2) goto labelProcessCommand;
                if (ret < 0) {
                    ret = RealtimeMode();
                    if (ret<-2) goto labelProcessCommand;
                }
                break;
            case 3:
                lastMenu = 3;
                ret = GetPresetNumber();
                if (ret == -1) break;
                if (ret == -2) break;
                if (ret<-2) goto labelProcessCommand;
                pnum = ret;
                ret = RunPreset(pnum);
                if (ret<-2) goto labelProcessCommand;
                break;
            case 2:
            case USER_INPUT_MACRO_REALMODE:
                lastMenu = 0;
                ret = RealtimeMode();
                if (ret<-2) goto labelProcessCommand;
                break;
            case 4:
                lastMenu = 0;
                ret = ShowVoltage();
                if (ret<-2) goto labelProcessCommand;
                break;
            case 5:
            case USER_INPUT_MACRO_SLEEP:
                lastMenu = 0;
                GoToSleep();
                break;
            case 6:
            case USER_INPUT_MACRO_EXTMODE:
                lastMenu = 0;
                ret = ExtMode();
                if (ret<-2) goto labelProcessCommand;
                break;
            case USER_INPUT_MACRO_RUNPRESET0:
                ret = RunPreset(1);
                if (ret<-2) goto labelProcessCommand;
                break;
            case USER_INPUT_MACRO_RUNPRESET1:
                ret = RunPreset(2);
                if (ret<-2) goto labelProcessCommand;
                break;
            case USER_INPUT_MACRO_RUNPRESET2:
                ret = RunPreset(3);
                if (ret<-2) goto labelProcessCommand;
                break;
            case USER_INPUT_MACRO_RUNPRESET3:
                ret = RunPreset(4);
                if (ret<-2) goto labelProcessCommand;
                break;
            case USER_INPUT_MACRO_RUNPRESET4:
                ret = RunPreset(5);
                if (ret<-2) goto labelProcessCommand;
                break;

        }
    }
}
Ejemplo n.º 5
0
int main(void)
{

    ind = 0;
	// Setup functions for operation
	CP0Init();
	INTInitialize();
	ADCSetup();
	SetupButtons();
	SetupIO();
	SetupT1CountINT();
	SetupTimer2_3PWM();
        //SetupUART(115200);
        NU32_EnableUART2Interrupt();


	// Wait until LCD screen comes up
	wait(1000);	wait(1000);	wait(1000); wait(1000);
	LCDConfig();
	LCDSetup();


        ClearLCDScreen();

        char msg[32];
        sprintf(msg,"UART demo. Press A to start");
	WriteLCD(1,msg);

        int button = 1;
        while(button == 1) {
            button = BUTTON_A;
        }
        wait(1000);
        while(button == 0)
        {
            button = BUTTON_A;
        }
        wait(1000);
        
        // send dollar signs to enter command mode
        char send1[] = "$$$";
        SerialTransmit(send1);

        wait(1000);wait(1000);wait(1000);
        // print message and wait for press
/*        ClearLCDScreen();
        wait(1000);wait(1000);wait(1000);
        sprintf(msg,"command mode. press A");
	WriteLCD(1,msg);
        wait(1000);wait(1000);wait(1000);
        button = 1;
        while(button == 1) {
            button = BUTTON_A;
        }
        wait(1000);
        while(button == 0)
        {
            button = BUTTON_A;
        }
        wait(1000);
        wait(1000);
*/
        while(next == 0);
        next = 0;

        char send2[] = "GB\n";
        SerialTransmit(send2);

        while(1)
        {
            ClearLCDScreen();
            WriteLCD(0,string);
            wait(10000);
            wait(10000);
            wait(10000);
        }

        // receive response from chip
        char temp[4];
        SerialReceive(temp, 4, CHAR_MODE);
        
//        // print response to lcd
//        ClearLCDScreen();
//        WriteLCD(1,temp);
        

        
        char temp2[32];
        SerialReceive(temp2, 32, HEX_MODE);

        ClearLCDScreen();
        WriteLCD(1,temp2);


 /*
  * Software State machine
  *     POR:
  *         Try to connect
  *
  *
  */

        return 0;
}
Ejemplo n.º 6
0
void main(void) {
    signed char ret = 0;
    signed char lastMenu = 0;
    char pnum = 0;

    SetupIO();
    MOTOR_FORWARD = 0;
    MOTOR_REVERSE = 0;

    Move_shifted_position.ul = 0;
    Move_position[0].ul = 0;
    Move_position[1].ul = 0;
    //PID_SetPoint = 0;
    char idx;
    for (idx = 0; idx < 16; idx++) RotaryDetentIntervals[idx] = 0xFF;

    //LoadSettings();
    FactoryDefault();

    SetupHardware();

    LCD_PowerUp();
    LCD_ClearDisplay();

    LCD_PrintString("CINEFLUX ORBIT\0");
    LCD_SetPosition(1,0);    
    LCD_PrintString(VER);
    Wait_ms(2000);

    const char *COMMAND_0 = "ORBIT MODE\0";
    const char *COMMAND_1 = "WAYPOINT MODE\0";
    const char *COMMAND_3 = "RUN PRESET\0";
    const char *COMMAND_2 = "REALTIME MODE\0";
    const char *COMMAND_4 = "BATTERY VOLTAGE\0";
    const char *COMMAND_5 = "GO TO SLEEP\0";
    const char *COMMAND_6 = "EXTERNAL CTRL MODE\0";
    const char*CommandMenu[7];
    CommandMenu[0] = COMMAND_0;
    CommandMenu[1] = COMMAND_1;
    CommandMenu[2] = COMMAND_2;
    CommandMenu[3] = COMMAND_3;
    CommandMenu[4] = COMMAND_4;
    CommandMenu[5] = COMMAND_5;
    CommandMenu[6] = COMMAND_6;

    bFollowMode = 1;
    LCD_ClearDisplay();
    LCD_PrintString("MOVE TO ZERO DEGREES\0");
    LCD_SetPosition(1, 0);
    LCD_PrintString("THEN CLICK...\0");
    GetClick();
    bClear_MotorPosition = 1;
    while (bClear_MotorPosition) Idle();
    Wait_ms(10);
    bFollowMode = 0;
    LCD_ClearDisplay();

    while (1) {
        ret = DisplayMenu(CommandMenu, 6, lastMenu);
        switch (ret) {
            case 0:
                lastMenu = 0;
                if (!CreateOrbitProgram() == 0)
                    RealtimeMode();
                break;
            case 1:
                lastMenu = 1;
                if (!CreateWaypointProgram() == 0)
                    RealtimeMode();
                break;
            case 3:
                lastMenu = 2;
                ret = GetPresetNumber();
                if (ret == -1) break;
                if (ret == -2) break;
                pnum = ret;
                switch (GetPresetType(pnum)) {
                    case 1:
                        LoadPreset(pnum, (unsigned char *) &CurrentPath);
                        if (!RunWaypointProgram() == 0)
                            RealtimeMode();
                        break;
                    case 2:
                        LoadPreset(pnum, (unsigned char *) &CurrentOrbitProgram);
                        if (!RunOrbitProgram() == 0)
                            RealtimeMode();
                        break;
                }
                break;
            case 2:
                lastMenu = 2;
                RealtimeMode();
                break;
            case 4:
                lastMenu = 0;
                ShowVoltage();
                break;
            case 5:
                lastMenu = 0;
                GoToSleep();
                break;
            case 6:
                lastMenu = 0;
                ExtMode();
                break;
        }
    }
}
Ejemplo n.º 7
0
int main(void)
{
	int delay;
	d2 = 0;
	d1 = 0;
	state = 0;
	reset = 1;
	adc1 = 0;
	adc2 = 0;
	led = 0;
	pwm = 0;
	double volt1 = 0.0;
	double volt2 = 0.0;

	// Setup functions for operation
	CP0Init();
	INTInitialize();
	ADCSetup();
	SetupButtons();
	SetupIO();
	SetupT1CountINT();
	SetupTimer2_3PWM();

	// Wait until LCD screen comes up
	wait(1000);	wait(1000);	wait(1000); wait(1000);
	LCDConfig();
	LCDSetup();

	

	// Start the timer
	T1CONbits.ON = 1;

	while(1)
	{
    		if(reset == 1)
		{
			ClearLCDScreen();
			sprintf(string,"A = Cmd button");
			WriteLCD(1,string);
			reset = 0;
			state = 0;
		}
		else
		{
			switch(state)
			{
				case 0:
					if(state_init[0] != 0)
						state_init[0] = 0;
					wait(100);
					break;
				case 1:
					if(state_init[0] != 1)
					{
						state_init[0] = 1;
						if(state_init[1] == 0)
							state_init[1] = 1;
						else
							state_init[1] = 0;
					}
					wait(100);
					break;
				case 2:
					if(state_init[0] != 2)
					{
						state_init[0] = 2;
						if(state_init[2] == 0)
							state_init[2] = 1;
						else
							state_init[2] = 0;
					}
					wait(100);
					break;
				case 3:
					if(state_init[0] != 3)
					{
						state_init[0] = 3;
						if(state_init[3] == 0)
							state_init[3] = 1;
						else
							state_init[3] = 0;
					}
					wait(100);
					break;
				case 4:
					if(state_init[0] != 4)
					{
						state_init[0] = 4;
						if(state_init[4] == 0)
							state_init[4] = 1;
						else
							state_init[4] = 0;
					}
					wait(100);
					break;
				default:
					wait(100);
					break;
			}
			if(state_init[1] == 0 && state_init[2] == 0 && state_init[3] == 0)
				sprintf(string,"LB=0;RB=0;WPER=0");
			else if(state_init[1] == 1 && state_init[2] == 0 && state_init[3] == 0)
				sprintf(string,"LB=1;RB=0;WPER=0");
			else if(state_init[1] == 0 && state_init[2] == 1 && state_init[3] == 0)
				sprintf(string,"LB=0;RB=1;WPER=0");
			else if(state_init[1] == 1 && state_init[2] == 1 && state_init[3] == 0)
				sprintf(string,"LB=1;RB=1;WPER=0");
			else if(state_init[1] == 0 && state_init[2] == 0 && state_init[3] == 1)
				sprintf(string,"LB=0;RB=0;WPER=1");
			else if(state_init[1] == 1 && state_init[2] == 0 && state_init[3] == 1)
				sprintf(string,"LB=1;RB=0;WPER=1");
			else if(state_init[1] == 0 && state_init[2] == 1 && state_init[3] == 1)
				sprintf(string,"LB=0;RB=1;WPER=1");
			else if(state_init[1] == 1 && state_init[2] == 1 && state_init[3] == 1)
				sprintf(string,"LB=1;RB=1;WPER=1");

			if(state != -1)// && state != 0)
			{
				wait(100);
				WriteLCD(2,string);
			}
		}		
	}
	return 0;
}
Ejemplo n.º 8
0
void
cyg_start(void)
{      

    //================
         SetupIsr();

         SetupRfSpi();
         SetupIO();
         SetupButtomCallback(send_packet);
   //================    
    cyg_thread_create(10,                // Priority - just a number
                      mainfunc,              // entry
                      0,                 // entry parameter
                      "mainfunc",            // Name
                      &stack[0],         // Stack
                      STACK_SIZE,        // Size
                      &main_handle, // Handle
                      &main_thread    // Thread data structure
                    ); 
				 
 
    cyg_thread_create(10,                // Priority - just a number
                      udp_client_process , // entry
                      0,                 // entry parameter
                      "udp_client_process",            // Name
                      &udp_client_stack[0],         // Stack
                      STACK_SIZE,        // Size
                      &udp_client_handle, // Handle
                      &udp_client_thread     // Thread data structure
                    );
 
    cyg_thread_create(10,                // Priority - just a number
                      tcpip_process, // entry
                      0,                 // entry parameter
                      "tcpip_process",            // Name
                      &tcpip_stack[0],         // Stack
                      STACK_SIZE,        // Size
                      &tcpip_handle, // Handle
                      &tcpip_thread     // Thread data structure
                    );
 
 



    cyg_thread_create(10,                // Priority - just a number
                      uz2400_process, // entry
                      0,                 // entry parameter
                      "uz2400_process",            // Name
                      &uz2400_stack[0],         // Stack
                      UZ_STACK_SIZE,        // Sizeuz2400
                      &uz2400_handle, // Handle
                      &uz2400_thread     // Thread data structure
                    );   
				
        cyg_thread_resume(main_handle); // Start it
	
        cyg_thread_resume(tcpip_handle);
        
        cyg_thread_resume(udp_client_handle);
         
   	cyg_thread_resume(uz2400_handle); 

        cyg_scheduler_start();
}