void PowerTX434::powerOn (int device) {
  switch(device) {
    case 1: for (int i=0; i<20; i++) { cli(); powerDevice1(); powerON();  sei(); delay(7); } delay(1000); break;
    case 2: for (int i=0; i<20; i++) { cli(); powerDevice2(); powerON();  sei(); delay(7); } delay(1000); break;
    case 3: for (int i=0; i<20; i++) { cli(); powerDevice3(); powerON();  sei(); delay(7); } delay(1000); break;
    case 4: for (int i=0; i<20; i++) { cli(); powerDevice4(); powerON();  sei(); delay(7); } delay(1000); break;
    case 5: for (int i=0; i<20; i++) { cli(); powerDevice5(); powerON();  sei(); delay(7); } delay(1000); break;
  }
}
Beispiel #2
0
int main(int argc, char **argv)
{
    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR ;
    
    u32 old_reg = readPowerManagement(PM_CONTROL_REG);
    writePowerManagement(PM_CONTROL_REG, old_reg |PM_LED_ON); // enable fast
    
	// Reset the clock if needed
	rtcReset();

	// Turn on Sound
	powerON(POWER_SOUND);

	// Set up sound defaults.
	SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);
	IPC->soundData = 0;

	// Set up the interrupt handler
	irqInit();
	irqSet(IRQ_VBLANK, VblankHandler);
	irqEnable(IRQ_VBLANK);

     // Setup FIFO
     
 	irqSet(IRQ_FIFO_NOT_EMPTY,FifoInterruptHandler);
	irqEnable(IRQ_FIFO_NOT_EMPTY);     
    REG_IPC_FIFO_CR =  IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR | IPC_FIFO_RECV_IRQ ;
    
	// Keep the ARM7 out of main RAM
	while (1)
		swiWaitForVBlank();
	
	return 0;
}
Beispiel #3
0
int main(void) {
    
    initRobotBase();

    setLEDs(0b111111);
    mSleep(1500);
    setLEDs(0b000000);

    // Set Bumpers state changed event handler:
    BUMPERS_setStateChangedHandler(bumpersStateChanged);

    powerON(); // Turn Encoders, Motor Current Sensors 
    // ATTENTION: Automatic Motor control will not work without this!

    /* RP6 SAGAN GENERATED COMMANDS START */
    
    /*{SAGAN1_COMMANDS_HERE}*/
    
    /* RP6 SAGAN GENERATED COMMANDS STOP */

    stop();
    moveAtSpeed(0, 0);
    BUMPERS_setStateChangedHandler(BUMPERS_stateChanged_empty);
    setLEDs(0b000000);

    while (true) {
        statusLEDs.LED2 = !statusLEDs.LED2; // Toggle LED bit in LED shadow register... 
        statusLEDs.LED5 = !statusLEDs.LED5;
        updateStatusLEDs();
        mSleep(500);
        task_RP6System();
    }
    return 0;
}
Beispiel #4
0
int16_t main(void)
{
	initRobotBase();
	powerON(); 
	setLEDs(0b111111); 
	mSleep(1000); 
	setLEDs(0b000000);
	mSleep(500);
	uint8_t runningLight = 1;
	for (uint8_t i = 0; i < 6; i++){
		for (uint8_t j = 0; j< 3;j++)
			destination[j] = destinationarray[i][j];
		//mainloopOpen();
		mainloopClosed();
		fancyled(&runningLight);
		/*for (uint8_t j = 0; j< 3;j++)
			source[j] = destination[j];*/
		mSleep(2000);
		
	}
	task_RP6System();
	while(true)
	{
		fancyled(&runningLight);
		if (motioncomplete == 0)
			moveAtSpeed(0,0);
		mSleep(200);
		task_RP6System();
	}
	return 0; 
}
//---------------------------------------------------------------------------------
int main(int argc, char ** argv) {
//---------------------------------------------------------------------------------

	// Reset the clock if needed
	rtcReset();

	//enable sound
	powerON(POWER_SOUND);
	SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);
	IPC->soundData = 0;

	irqInit();
	irqSet(IRQ_VBLANK, VblankHandler);
	SetYtrigger(80);
	vcount = 80;
	irqSet(IRQ_VCOUNT, VcountHandler);
	irqEnable(IRQ_VBLANK | IRQ_VCOUNT);  
	
	irqSet(IRQ_TIMER0, playTimerHandler);
	irqEnable(IRQ_TIMER0);
	
	player = new Player(playTimerHandler);
	player->registerTickCallback(onTick);
	player->registerPatternChangeCallback(onPatternChange);

	// Keep the ARM7 idle
	while (1) swiWaitForVBlank();
}
Beispiel #6
0
void arm9_consoleInit()
{
    powerON(/*POWER_ALL*/POWER_LCD);
    
    // Use the main screen for output
    videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE);
    vramSetBankA(VRAM_A_MAIN_BG);
    BG0_CR = BG_MAP_BASE(31);

    // Set the colour of the font to White.
    BG_PALETTE[255] = RGB15(31,31,31);

    consoleInitDefault((u16*)SCREEN_BASE_BLOCK(31), (u16*)CHAR_BASE_BLOCK(0), 16);
}
Beispiel #7
0
void PA_Init(void){
 	rtcReset();

	//enable sound
	powerON(POWER_SOUND);
	SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);
	IPC->soundData = 0;
	
	PA_NewSPI = PA_ReadSPI();
	IPC->aux = PA_NewSPI;
	
	MIC_On();
	PM_SetAmp(1);
}
Beispiel #8
0
//---------------------------------------------------------------------------------
int main(int argc, char ** argv) {
//---------------------------------------------------------------------------------
    // read User Settings from firmware
    readUserSettings();
    REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; // enable & prepare fifo asap
    rtcReset();

    //enable sound
    powerON(POWER_SOUND);
    writePowerManagement(PM_CONTROL_REG, ( readPowerManagement(PM_CONTROL_REG) & ~PM_SOUND_MUTE ) | PM_SOUND_AMP );
    SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);

    irqInit();

    // Start the RTC tracking IRQ
    initClockIRQ();

    SetYtrigger(80);
    irqSet(IRQ_VCOUNT, VcountHandler);
    irqSet(IRQ_VBLANK, VblankHandler);
    irqSet(IRQ_WIFI, Wifi_Interrupt); // set up wifi interrupt

    irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_WIFI);

    {   // sync with arm9 and init wifi
        u32 fifo_temp;

        while(1) { // wait for magic number
            while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank();
            fifo_temp=REG_IPC_FIFO_RX;
            if(fifo_temp==0x12345678) break;
        }
        while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank();
        fifo_temp=REG_IPC_FIFO_RX; // give next value to wifi_init
        Wifi_Init(fifo_temp);

        irqSet(IRQ_FIFO_NOT_EMPTY,arm7_fifo); // set up fifo irq
        irqEnable(IRQ_FIFO_NOT_EMPTY);
        REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;

        Wifi_SetSyncHandler(arm7_synctoarm9); // allow wifi lib to notify arm9
    } // arm7 wifi init complete


    // Keep the ARM7 mostly idle
    while (1) swiWaitForVBlank();
}
Beispiel #9
0
int main(int argc, char ** argv)
{
	u32 fifo_temp;   
	REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR;

	// Reset the clock if needed
	rtcReset();

	//enable sound
	powerON(POWER_SOUND);
	SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);
	IPC->soundData = 0;

	irqInit();
	irqSet(IRQ_VBLANK, VblankHandler);
	SetYtrigger(80);
	vcount = 80;
	irqSet(IRQ_VCOUNT, VcountHandler);
	irqEnable(IRQ_VBLANK | IRQ_VCOUNT);

	irqSet(IRQ_TIMER0, tob_ProcessMicrophoneTimerIRQ);
	tob_MIC_On();

	irqSet(IRQ_WIFI, Wifi_Interrupt);
	irqEnable(IRQ_WIFI);

	// trade some mail, to get a pointer from arm9
	while(1)
	{
		while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank();
		fifo_temp=REG_IPC_FIFO_RX;
		if(fifo_temp==0x12345678) break;
	}
	while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank();
	fifo_temp=REG_IPC_FIFO_RX;
	Wifi_Init(fifo_temp);

	irqSet(IRQ_FIFO_NOT_EMPTY,arm7_fifo);
	irqEnable(IRQ_FIFO_NOT_EMPTY);
	REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;

	Wifi_SetSyncHandler(arm7_synctoarm9);

	// Keep the ARM7 idle
	while(1) swiWaitForVBlank();
}
int main(void)
{
	initRobotBase(); 
	setLEDs(0b111111);
	mSleep(2500);
	setLEDs(0b100100); 

	BUMPERS_setStateChangedHandler(bumpersStateChanged);
	
	powerON(); 
	
	while(true) 
	{		
		behaviourController();
		task_RP6System();
	}
	return 0;
}
Beispiel #11
0
void PA_Init2D(void){
	// Turn on the screens and 2D cores and switch to mode 0
	powerON(POWER_ALL);
	//  POWER_CR = POWER_ALL_2D;

	REG_POWERCNT &= ~SWITCH_SCREENS; // on s'assure que l'écran est bien
/*
	VRAM_A_CR=VRAM_ENABLE|VRAM_A_MAIN_BG;
	VRAM_B_CR=VRAM_ENABLE|VRAM_B_MAIN_SPRITE;
	VRAM_C_CR=VRAM_ENABLE|VRAM_C_SUB_BG;
	VRAM_D_CR=VRAM_ENABLE|VRAM_D_SUB_SPRITE; */
    videoSetMode(  MODE_0_2D |
                   DISPLAY_SPR_ACTIVE |    //turn on sprites
                   DISPLAY_SPR_1D |        //this is used when in tile mode
				   DISPLAY_SPR_1D_SIZE_128|
                   DISPLAY_SPR_1D_BMP      //and this in bitmap mode
                    );
	videoSetModeSub(  MODE_0_2D |
                   DISPLAY_SPR_ACTIVE |    //turn on sprites
                   DISPLAY_SPR_1D |        //this is used when in tile mode
				   DISPLAY_SPR_1D_SIZE_128|
                   DISPLAY_SPR_1D_BMP      //and this in bitmap mode
                    );

//	DISPLAY_CR = MODE_0_2D | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_ACTIVE|DISPLAY_SPR_1D_SIZE_128|DISPLAY_SPR_1D_BMP;
//	SUB_DISPLAY_CR = MODE_0_2D | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_ACTIVE|DISPLAY_SPR_1D_SIZE_128|DISPLAY_SPR_1D_BMP;


	vramSetMainBanks(VRAM_A_MAIN_SPRITE,VRAM_B_MAIN_BG_0x06000000,VRAM_C_SUB_BG,VRAM_D_SUB_SPRITE);

	// Sprite inits...
	PA_ResetSpriteSys(); // Init's the sprite system
	PA_InitSpriteExtPal(); // Init's sprite extended palettes

	PA_ResetBgSys();
	PA_InitBgExtPal(); // Init's bg extended palettes


	// VBL Inits
	SpriteVBL = PA_UpdateSpriteVBL;

}
Beispiel #12
0
int NDS_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
    //printf("WARNING: You are using the SDL NDS video driver!\n");

    /* Determine the screen depth (use default 8-bit depth) */
    /* we change this during the SDL_SetVideoMode implementation... */
    vformat->BitsPerPixel = 16;     // mode 3
    vformat->BytesPerPixel = 2;
    vformat->Rmask = 0x0000f800;
    vformat->Gmask = 0x000007e0;
    vformat->Bmask = 0x0000001f;
    powerON(POWER_ALL);
    irqInit();
    irqSet(IRQ_VBLANK, on_irq_vblank);
    irqEnable(IRQ_VBLANK);

    //set the mode for 2 text layers and two extended background layers
    //videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
    videoSetMode(MODE_6_2D | DISPLAY_BG2_ACTIVE);

    //set the sub background up for text display (we could just print to one
    //of the main display text backgrounds just as easily
    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text

    //set the first two banks as background memory and the third as sub background memory
    //D is not used..if you need a bigger background then you will need to map
    //more vram banks consecutivly (VRAM A-D are all 0x20000 bytes in size)
    //vramSetMainBanks(VRAM_A_MAIN_BG_0x6000000, VRAM_B_MAIN_BG_0x6020000,VRAM_C_SUB_BG , VRAM_D_LCD);
    vramSetMainBanks(VRAM_A_MAIN_BG,VRAM_B_MAIN_BG,VRAM_C_MAIN_BG,VRAM_D_MAIN_BG);
    //vramSetBankA(VRAM_A_MAIN_BG);
    //vramSetBankB(VRAM_B_MAIN_BG);
    //vramSetBankC(VRAM_C_MAIN_BG);
    //vramSetBankD(VRAM_D_MAIN_BG);
    //vramSetBankE(VRAM_E_MAIN_BG);
    //vramSetBankF(VRAM_F_MAIN_BG);
    //vramSetBankG(VRAM_G_MAIN_BG);
    vramSetBankH(VRAM_H_SUB_BG);
    vramSetBankI(VRAM_I_LCD);

    ////////////////set up text background for text/////////////////////
    SUB_BG0_CR = BG_MAP_BASE(8);

    BG_PALETTE_SUB[255] = RGB15(31,31,31);//by default font will be rendered with color 255
    ///////////////set up our bitmap background///////////////////////

    //BG3_CR = BG_BMP16_512x512;

    //these are rotation backgrounds so you must set the rotation attributes:
    //these are fixed point numbers with the low 8 bits the fractional part
    //this basicaly gives it a 1:1 translation in x and y so you get a nice flat bitmap
    /*  BG3_XDX = 1<<8;
        BG3_XDY = 0;
        BG3_YDX = 0;
        BG3_YDY = 1<<8;
        //our bitmap looks a bit better if we center it so scroll down (256 - 192) / 2
        BG3_CX = 0;
        BG3_CY = 0;
    */
    //consoleInit() is a lot more flexible but this gets you up and running quick
    consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(8), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);


    frontBuffer =(u16*)(0x06000000);
    //backBuffer =(u16*)(0x06000000 + 1024 * 512*2);

    //lcdSwap();
    /* We're done! */
    return 0;
}
Beispiel #13
0
int main(void)
{
    float x_angle = 0, y_angle = 0;
    float x_speed = 0, y_speed = 0;
    float distance = 1;

    powerON(POWER_ALL);
    irqInit();
    irqEnable(IRQ_VBLANK);
    videoSetMode(MODE_0_3D);
    consoleDemoInit();

    /* Set up a timer to count FPS */
    TIMER3_DATA = TIMER_FREQ_1024(1);
    TIMER3_CR = TIMER_DIV_1024 | TIMER_IRQ_REQ;
    irqSet(IRQ_TIMER3, fps_timer_irq);
    irqEnable(IRQ_TIMER3);

    glViewPort(0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1);
    glClearColor(0, 0, 0);
    glClearDepth(GL_MAX_DEPTH);

    iprintf("Hello World!\n\n");

    glReset();
    gluPerspective(35, SCREEN_WIDTH / (float) SCREEN_HEIGHT, 0.1, 40.0);
    gluLookAt(0.0, 0.0, 1.0,   /* Eye */
	      0.0, 0.0, 0.0,   /* Look at */
	      0.0, 1.0, 0.0);  /* Up */

    glMaterialf(GL_AMBIENT, RGB15(8,8,8));
    glMaterialf(GL_DIFFUSE, RGB15(16,16,16));
    glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8,8,8));
    glMaterialf(GL_EMISSION, RGB15(5,5,5));
    glMaterialShinyness();
    glColor(RGB15(31, 31, 31));

    glLight(0, RGB15(20, 15, 15),
	    floattov10(-0.9),
	    floattov10( 0.9),
	    floattov10( 0.2));

    glLight(1, RGB15(15, 15, 20),
	    floattov10( 0.4),
	    floattov10( 0.9),
	    floattov10( 0.2));

    glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK |
	      POLY_FORMAT_LIGHT0 | POLY_FORMAT_LIGHT1);

    while (1) {
	scanKeys();
	if (keysHeld() & KEY_START)  Loader_Exit9();
	if (keysHeld() & KEY_UP)     x_speed += 0.05;
	if (keysHeld() & KEY_DOWN)   x_speed -= 0.05;
	if (keysHeld() & KEY_LEFT)   y_speed += 0.05;
	if (keysHeld() & KEY_RIGHT)  y_speed -= 0.05;
	if (keysHeld() & KEY_R)      distance += 0.05;
	if (keysHeld() & KEY_L)      distance -= 0.05;

	glPushMatrix();

	glTranslate3f32(floattof32( 0.0),
			floattof32( 0.0),
			floattof32(-distance));

	glRotateX(x_angle += x_speed);
	glRotateY(y_angle += y_speed);

	glCallList(display_list_bin);

	glPopMatrix(1);

	glFlush();
	frames++;
	swiWaitForVBlank();
    }

    return 0;
}
Beispiel #14
0
int main()
{	
	struct timeval tv;
	
	powerON(POWER_ALL);

	//set mode 0, enable BG0 and set it to 3D
	videoSetMode(MODE_0_3D);
	
	//Use console
	videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);	//sub bg 0 will be used to print text
	vramSetBankC(VRAM_C_SUB_BG); 
	SUB_BG0_CR = BG_MAP_BASE(31);
	BG_PALETTE_SUB[255] = RGB15(31,31,31);	//by default font will be rendered with color 255
	consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
	
	//iprintf("Starting up...\n");
	
	// install the default exception handler
	defaultExceptionHandler();


	//irqs are nice
	irqInit();
	irqEnable(IRQ_VBLANK);
	
	// set the generic sound parameters
	setGenericSound(	11025,	/* sample rate */
						127,	/* volume */
						64,		/* panning */
						1 );	/* sound format*/
						

	glInit();
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
		
	//this should work the same as the normal gl call
	glViewPort(0,0,255,191);
	
	glClearColor(0,0,0,0);
	glClearDepth(0x7FFF);
	
	vramSetBankA(VRAM_A_TEXTURE);
	vramSetBankB(VRAM_B_TEXTURE);
	
	logo();

	glGenTextures(1, &textureID);
	glBindTexture(0, textureID);
	glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_256 , TEXTURE_SIZE_256, 0, TEXGEN_TEXCOORD , (u8*)die_bmp_bin);
	
	
	glGenTextures(1, &textureID2);
	glBindTexture(0, textureID2);
	glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, (u8*)mario_bmp_bin);
	
	gettimeofday(&tv, NULL);
	//iprintf("Seeding with %d\n", tv.tv_usec);
    srand(tv.tv_usec);

	while(1){
		gameLoop();
	}

	return 0;
}//end main 
Beispiel #15
0
void initProgram()
{
	//------------------------
	// start initializing crap
	//------------------------
	defaultExceptionHandler(); // set up the exception handler

    powerON(POWER_ALL_2D); // turn on everything

	#ifndef DEBUG_MODE
	fb_init(); // initialize top screen video
	#else
	debugInit();
	#endif
	bg_init(); // initialize bottom screen video

	setNewOrientation(ORIENTATION_0);

	// set up extra vram banks to be scratch memory
	vramSetBankE(VRAM_E_LCD);
	vramSetBankF(VRAM_F_LCD);
	vramSetBankG(VRAM_G_LCD);
	vramSetBankH(VRAM_H_LCD);
	vramSetBankI(VRAM_I_LCD);

	fb_setBGColor(30653);
	bg_setBGColor(0);
	drawStartSplash();

	lcdMainOnTop(); // set fb to top screen
	fb_swapBuffers();
	bg_swapBuffers();

	// out of order for competition
	irqInit(); // initialize irqs

    irqSet(IRQ_VBLANK, startvBlank);
	irqEnable(IRQ_VBLANK);

	setMode(INITFAT);
	setSoundInterrupt(); // initialize fifo irq

	setGenericSound(11025, 127, 64, 1);
	waitForInit(); // wait until arm7 has loaded and gone to sleep
	initComplexSound(); // initialize sound variables
	initWifi();
	fixGautami();

	setCursorProperties(0, 2, 0, 0);
	initCapture();
	initClipboard();

	// set defaults to english in case we can't load the langauge file for
	// some reason also takes care of partial translations.
	initLanguage();
	initRandomList();
	fixAndTags();

	resetKeyboard();
	setDate();

	if(!DRAGON_InitFiles())
	{
		// oops, no cf card!
		setMode(DISPLAYCOW);

		setFont(font_arial_11);
		setColor(0xFFFF);

		bg_dispSprite(96, 5, errmsg, 0);
		bg_setClipping(5,25,250,181);
		bg_dispString(0,0,l_nofat);
		bg_swapBuffers();

		while(1)
		{
			// wee, la la la!
		  // More or less, we aren't going to do nothing here
		}
	}

	//--------------------------------------------------------------------
	//finished init, now check to make sure the DSOrganize dir is there...
	//--------------------------------------------------------------------

	findDataDirectory();
	makeDirectories();

	if(DRAGON_FileExists("DSOrganize") != FE_DIR)
	{
		setMode(DISPLAYCOW);

		// oops, not there, we must create!
		DRAGON_mkdir("DSOrganize");
		DRAGON_chdir("DSOrganize");
		DRAGON_mkdir("DAY");
		DRAGON_mkdir("HELP");
		DRAGON_mkdir("LANG");
		DRAGON_mkdir("RESOURCES");
		DRAGON_mkdir("REMINDER");
		DRAGON_mkdir("SCRIBBLE");
		DRAGON_mkdir("TODO");
		DRAGON_mkdir("VCARD");
		DRAGON_mkdir("ICONS");
		DRAGON_mkdir("CACHE");
		DRAGON_mkdir("COOKIES");
		DRAGON_mkdir("HOME");
		DRAGON_chdir("/");

		makeDefaultSettings();

		setFont(font_arial_11);
		setColor(0xFFFF);

		bg_dispSprite(96, 5, errmsg, 0);
		bg_setClipping(5,25,250,181);
		bg_dispString(0,0, l_createdir);
		bg_swapBuffers();

		while(!keysDown())
		{
			scanKeys();
		}
	}

	setMode(INITPLUGIN);

	//-------------------------------------------------------------------
	//finished creating dirs, now check to make sure if they extracted it
	//did their extracting program actually get all the dirs?
	//-------------------------------------------------------------------

	DRAGON_chdir(d_base);

	if(DRAGON_FileExists("Day") != FE_DIR)
	{
		DRAGON_mkdir("DAY");
	}
	if(DRAGON_FileExists("Help") != FE_DIR)
	{
		DRAGON_mkdir("HELP");
	}
	if(DRAGON_FileExists("Lang") != FE_DIR)
	{
		DRAGON_mkdir("LANG");
	}
	if(DRAGON_FileExists("Reminder") != FE_DIR)
	{
		DRAGON_mkdir("REMINDER");
	}
	if(DRAGON_FileExists("Scribble") != FE_DIR)
	{
		DRAGON_mkdir("SCRIBBLE");
	}
	if(DRAGON_FileExists("Todo") != FE_DIR)
	{
		DRAGON_mkdir("TODO");
	}
	if(DRAGON_FileExists("VCard") != FE_DIR)
	{
		DRAGON_mkdir("VCARD");
	}
	if(DRAGON_FileExists("Icons") != FE_DIR)
	{
		DRAGON_mkdir("ICONS");
	}
	if(DRAGON_FileExists("Cache") != FE_DIR)
	{
		DRAGON_mkdir("CACHE");
	}
	if(DRAGON_FileExists("Cookies") != FE_DIR)
	{
		DRAGON_mkdir("COOKIES");
	}
	if(DRAGON_FileExists("Home") != FE_DIR)
	{
		DRAGON_mkdir("HOME");
	}

	DRAGON_chdir("/");

	//-------------------------------------------
	//how about we load the settings for them eh?
	//-------------------------------------------
	loadSettings();

	DRAGON_chdir(d_base);

	if(DRAGON_FileExists("startup.wav") == FE_FILE)
	{
		char tStr[256];

		sprintf(tStr, "%sstartup.wav", d_base);
		loadWavToMemory();
		loadSound(tStr);
	}

	DRAGON_chdir("/");
	initStartScreen();

    irqSet(IRQ_VBLANK, vBlank);
	fb_setBGColor(genericFillColor);
	bg_setBGColor(genericFillColor);
}
Beispiel #16
0
int main(void)
{
	initRobotBase(); 
	setLEDs(0b111111);
	mSleep(2500);
	
	powerON(); // Turn on Encoders, Current sensing, ACS and Power LED.
	
	
	/*
	In the following code segment we use the functions
	
	void move(uint8_t desired_speed, uint8_t dir, uint16_t distance, uint8_t blocking)
	and
	void rotate(uint8_t desired_speed, uint8_t dir, uint16_t angle, uint8_t blocking)
	
	The parameters have the following purposes:
	move:
		uint8_t desired_speed: The Speed the robot should try to maintain all the time
							   during the movement.
							   (but it will slow down a bit before it reaches the desired
							   distance)
							   
		uint8_t dir:		   The Direction the robot should move - this can be
							   FWD for Forwards or BWD for Backwards. 
							   You can also use LEFT or RIGHT here, but this function
							   is not optimized for rotation - you should use rotate
							   instead!
							   
		uint16_t distance:	   The distance we want to move. The distance needs to be
							   given in encoder counts. You can use the macro DIST_MM()
							   to convert the distance from mm to encoder counts if you 
							   have calibrated your Encoder sensors resoultion. 
							   
							   Maximum distance is 65000 encoder counts!
							   (not 65535 like you might have thought. There needs to be
							   a bit space to the top value... anyways - who wants to
							   move about 15m? ;) )
							   
		uint8_t blocking:	   This parameter sets if the function shall block the normal
							   program flow during the movement. 
							   If the parameter is "true", the function will NOT quit 
							   until the robot has moved the given distance!
							   ACS, Bumper, RC5 and other events are still processed and
							   not affected, but the main program will be blocked (s. below). 
							   You can use "BLOCKING" instead of "true" and
							   "NON_BLOCKING" instead of false to make the code more readable!
	
	rotate:
		uint8_t desired_speed: Same as above.
		uint8_t dir:		   Nearly the same as above, but here you should only 
							   use LEFT or RIGHT as parameters even if you can pass
							   BWD or FWD to this function.
		uint16_t angle		   The angle to turn. Attention: This rotation function is
							   not optimal for very small angles - it is optimized to 
							   turn angles over 25°!
							   If you want smaller angles, you need to write your
							   own function!
							   And even for large angles this function is far away
							   from beeing perfect as the encoder errors for rotation
							   are rather big. You need to do some experiments to
							   optimize this for the surfaces you want to use the
							   Robot on. The encoders are mainly intended for very good
							   speed regulation and don't work too well for tracked
							   vehicles' dead reckoning. Not only for RP6 but for EVERY
							   tracked vehicle out there - even for those 
							   with $10.000 price tag.
							   Measuring distances when moving straight forward works
							   OK - but not when rotating as there is a lot of tracks
							   slippery and you always don't move as far as you measured.
							   Solution: Use external sensors for rotation! Like
							   electronic compass, gyroscopes, optical mouse sensor or similar. 
							   Also s. comments in next example!
		
	To block or not to block:	
	If you set the "blocking" parameter to false, then the function will only set all 
	necessary parameters and quit - it will not wait until the movement has finished.
	This code:
	
		move(60, FWD, DIST_MM(300), false); // <-- non blocking
		rotate(50, LEFT, 180, false);		// <-- blocking
		
		mSleep(5000);
		
	would NOT work as intended! The Robot would NOT move 300mm and then turn 180°, instead
	it would only turn 180°! And, if you remove the mSleep(5000) at the end, it would maybe 
	not even do this.
	
	You always need to check if the movement has finished and if you can initiate the 
	next movement if you set the blocking parameter to false!
	
	This:
		move(60, FWD, DIST_MM(300), true); // <-- blocking movement
		rotate(50, LEFT, 180, true);	   // <-- blocking rotation
		
	would work like intended and the robot would move 300mm, turn 180° and stop.	
		
	This is equivalent to this:
	
		move(60, FWD, DIST_MM(300), false); // <-- non-blocking movement
		while(!isMovementComplete())		// Now we need to wait until the movement
				task_RP6System();			// is finished before we go on. 
											// If you set blocking to true, the function
											// does exactly this automatically.
	
		rotate(50, LEFT, 180, false);       // <-- non-blocking rotation
		while(!isMovementComplete())		// Again, we need to wait for the
				task_RP6System();			// movement (rotation) to be finished...
	
	Of course, you do not need to wait for the movement to finish in a while-loop - you can 
	also check this in several different ways and you can do other things while the movement is 
	in progress. You will see some other ways in the next examples.
	You can use the "isMovementComplete()" function for checking if the last movement is
	complete. 
	There is also a function "stop()" that can be used to abort a movement, e.g. if one
	of the sensors has detected an obstacle. But you do not need to use stop, you can also
	initiate the next movement without performing "stop" before.

	*/
	
	// Ok, now back to the example program. If you want this to work accurate, you
	// need to calibrate the encoders (s. RP6 manual)!
	
	// Main loop
	while(true) 
	{		
		setLEDs(0b100100); 
	/*	move(60, FWD, DIST_MM(300), true); // Move 300mm forwards 
										   // at Speed 60*5 ~= 300 counts/second
										   // = 7.5cm/s with 0.25mm resolution
										   // (6.9cm/s with 0.23mm resolution...)
		setLEDs(0b100000); 
		rotate(50, LEFT, 180, true); 	   // rotate 180° left
		setLEDs(0b100100); 
		move(60, FWD, DIST_MM(300), true); // move 30cm forwards
		setLEDs(0b000100); 
		rotate(50, RIGHT, 180, true); 	   // rotate 180° right
		*/
		moveAtSpeed(0,0);        //Bremsen
move(70, BWD, DIST_MM(150), BLOCKING);  //zurückfahren
rotate(40, RIGHT, 30, BLOCKING);          //Drehen
move(70, FWD, DIST_MM(200), BLOCKING);//Vorwärts (am Hindernis vorbei) fahren
rotate(40, LEFT, 30, BLOCKING);   //zurückdrehen
//dann geradeaus weiter 
		
	}
	return 0;
}
Beispiel #17
0
int main()
{	
    struct touchPosition pos;
	float rotateX = 0.0;
	float rotateY = 0.0;

	powerON(POWER_ALL);
    consoleDemoInit();

	//set mode 0, enable BG0 and set it to 3D
	videoSetMode(MODE_0_3D);

	//irqs are nice
	irqInit();
	irqEnable(IRQ_VBLANK);
    
	// initialize gl
	glInit();
    
	// enable antialiasing
	glEnable(GL_ANTIALIAS);
	
	// setup the rear plane
	glClearColor(0,0,0,31); // BG must be opaque for AA to work
	glClearPolyID(63); // BG must have a unique polygon ID for AA to work
	glClearDepth(0x7FFF);

	//this should work the same as the normal gl call
	glViewPort(0,0,255,191);
    
	//any floating point gl call is being converted to fixed prior to being implemented
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(35, 256.0 / 192.0, 0.1, 100);
	
	gluLookAt(	0.0, 0.0, 1.0,		//camera possition 
				0.0, 0.0, 0.0,		//look at
				0.0, 1.0, 0.0);		//up

	while(1)		
	{
        float px, py;
        
    	pos = touchReadXY();
        px = pos.px;
        py = pos.py;

        px = (px * 5) / 256;
        py = (py * 3) / 192;

        px -= 2.5;
        py -= 1.5;

		glPushMatrix();

		//move it away from the camera
		glTranslate3f32(0, 0, floattof32(-1));

		glRotateX(rotateX);
		glRotateY(rotateY);

		glMatrixMode(GL_MODELVIEW);

		//not a real gl function and will likely change
		glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
        
		scanKeys();
		
		u16 keys = keysHeld();
		
		if((keys & KEY_UP)) rotateX += 3;
		if((keys & KEY_DOWN)) rotateX -= 3;
		if((keys & KEY_LEFT)) rotateY += 3;
		if((keys & KEY_RIGHT)) rotateY -= 3;
        
		//draw the obj
		glBegin(GL_TRIANGLE);
			
			glColor3b(255,0,0);
			glVertex3v16(inttov16(-1),inttov16(-1),0);

			glColor3b(0,255,0);
			glVertex3v16(inttov16(1), inttov16(-1), 0);

			glColor3b(0,0,255);
			glVertex3v16(inttov16(0), inttov16(1), 0);
			
		glEnd();

        glLoadIdentity();
        glTranslatef(px,-py,-3.0);
        glBegin(GL_TRIANGLE);
            glVertex3f( 0.0, 1.0, 0.0);
            glVertex3f(-1.0,-1.0, 0.0);
            glVertex3f( 1.0,-1.0, 0.0);
        glEnd();

		glPopMatrix(1);

		glFlush(0);
		swiWaitForVBlank();
	}

	return 0;
}//end main 
Beispiel #18
0
int main(void)
{
    touchPosition touch;

    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);	//sub bg 0 will be used to print text
    vramSetBankC(VRAM_C_SUB_BG);

    SUB_BG0_CR = BG_MAP_BASE(31);

    BG_PALETTE_SUB[255] = RGB15(31,31,31);	//by default font will be rendered with color 255

    //consoleInit() is a lot more fluxible but this gets you up and running quick
    consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
    
/////////////
    powerON(POWER_ALL);

    // set mode 0, enable BG0 and set it to 3D
    videoSetMode(MODE_0_3D);
    vramSetBankA(VRAM_A_TEXTURE);

    // irqs are nice
    irqInit();
    irqEnable(IRQ_VBLANK);
    
    // initialize gl
    glInit();
    
    // setup the rear plane
    glClearColor(2, 4, 3, 16);
    glClearDepth(GL_MAX_DEPTH);
    
    // this should work the same as the normal gl call
    glViewPort(0,0, 255,191);
    
    glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
    
    glMatrixMode(GL_PROJECTION);
    
    glLoadIdentity();
    //~ glOrtho(0, 1, 192.0/256.0, 0, -10, 10);
    glOrthof32(0, 1<<12, (192<<12)/256, 0, -10<<12, 10<<12);
    
    REG_POWERCNT^= POWER_SWAP_LCDS;
/////////////


    flux_init();
    create_frame_groups();
    create_button_groups();
    create_titleframe();
    
    dmaCopy(fluxcolors, syscol_table, sizeof(fluxcolors));
    
    dword rc1= create_rect(NOPARENT, 20,20, 128,96, 0x808080);
    dword rc= create_rect(NOPARENT, 10,10, 128,96, 0x404040|TRANSL_3);
    dword frm= clone_frame("titleframe", rc);
    clone_frame("titleframe", rc1);
    //~ clone_group("button", rc, 10,30, 30,14, ALIGN_LEFT|ALIGN_TOP);

    create_rect(rc, 10,10, 10,10, 0xFFFFFF|TRANSL_1);
    create_rect(rc, 20,10, 10,10, 0xFFFFFF|TRANSL_2);
    create_rect(rc, 30,10, 10,10, 0xFFFFFF|TRANSL_3);
    create_rect(rc, 10,15, 30,10, 0xFFFFFF|TRANSL_1);
    
    create_text(rc, 10,30, 40,40, "Text! Space!\nNewline!", 0xFFFFFF, FONT_DEFAULT);
    
    bool redraw_all= true;
    bool touch_wasdown= false;
    int lasttouch_x, lasttouch_y;
    while(1)
    {
	scanKeys();
    	u32 keysheld= keysHeld();
	u32 keysdown= keysDown();
	touch= touchReadXY();
	
	if(keysdown&KEY_A)
	{
	    redraw_all^= 1;
	    iprintf("redraw each frame: %s\n", redraw_all? "on": "off");
	}
	
	if(keysdown&KEY_B)
	{
	    do_texalpha^= 1;
	    iprintf("texture alpha: %s\n", do_texalpha? "on": "off");
	}
	
	if(touch.x || touch.y)
	{
	    flux_mouse_event(touch.px, touch.py, 1);
	    lasttouch_x= touch.px, lasttouch_y= touch.py;
	    touch_wasdown= true;
	}
	else
	{
	    if(touch_wasdown) flux_mouse_event(lasttouch_x, lasttouch_y, 0);
	    touch_wasdown= false;
	}
	    

	flux_tick();
	if(redraw_all)
	{
	    redraw_rect(&viewport);
	    update_rect(&viewport);
	}
	
	swiWaitForVBlank();
    }

    return 0;
}