예제 #1
0
int main() {
	init();
	// uart starts on PC
	memset(& buffer, 0, BUFFER_SIZE);
	LATAbits.LATA0 = 0;
	printf("\nready to receive message of form '{message}'\n");
	while (!isDone) { } 
	// if we're done then the message is waiting in the buffer to be sent	
	uart1ToUpload();
	waitMs(100);
	//while (!bluetoothReady) { } 
	char * curChar;
	for (curChar = (char *)buffer; * curChar != '\0'; curChar++) {
		char tmp = * curChar;
		U1TXREG = tmp;				
		waitMs(10);
	}
	// turn on LED to indicate finished
	LATAbits.LATA0 = 1;
	uart1ToPc();
	waitMs(100);
	printf("\nFinished uploading!\n");
	while (1) { } // become unstuck in time
	return 0;
}
예제 #2
0
파일: usermain.c 프로젝트: batitous/dvos
void led(void)
{
    UInt32 led=0;
    
    //setGpioDirection(GPIO0_7,GPIO_OUT); //led
    
    waitMs(1000);
    
    dumpKernel();
    
    while(1)
    {
        
        
        if(led==0)
        {
            setGpioValue(GPIO0_7,0);
            led=1;
        }
        else
        {
            setGpioValue(GPIO0_7,1);
            led=0;
        }
        
        waitMs(50);
        
    }
}
예제 #3
0
파일: main.c 프로젝트: mateuszaaa/Projects
void blinkLed(){
    while(1){
        LED_ON;
        waitMs(50);
        LED_OFF;
        waitMs(50);
    }
}
예제 #4
0
파일: kiostream.c 프로젝트: batitous/dvos
Bool getBufferFromStream(KIOStream * stream, UInt8 * buffer, UInt32 len, UInt32 timeout)
{
    UInt32 counter, i;

    for( i = stream->read, counter = 0; counter < len; counter++)
    {
        if(i==stream->write)
        {
            // we don't have enough data, we have to wait some times...
            //stream->receiver = (KThread *)currentTask;
            
            stream->receiver = 0;
            waitMs(timeout);
//            waitUs(timeout*100);
            if(i==stream->write)
            {
                // Timeout !
                return False;
            }

        }

        buffer[counter] = stream->buffer[i & (stream->size-1)];
        i++;
    }

    stream->read = i;

    return True;
}
예제 #5
0
void text_draw_sprite ( u8 *str, u16 x, u16 y, u16 ms )
{
	#define TILE    _base + _positions[chr] * _width * _height
	#define ATTR	 TILE_ATTR_FULL ( _palette, 1, 0, 0, TILE )

	u8 chr, i = 0;


	const u16 size = _genres->size  >> 8;
	const u8 width = _genres->width;

	while ( (chr = *str++) )
	{
		chr -= ' ';
		chr  = ( chr >= 96 ) ? 0 : chr;

		if ( ! _positions[chr] )
		{
			_positions[chr] = _counter++;
			VDP_loadTileData ( _genres->sprites[chr], TILE, size, TRUE );
			VDP_waitVSync();
      }

		VDP_setSprite ( i, x+i*width, y, size, ATTR, i+1 );
		VDP_updateSprites();

		waitMs ( ms );

		++i;
	}
}
예제 #6
0
파일: Wave.cpp 프로젝트: cslux/ledcc
void Wave::createAnimation()
{
    float /*origin_x, origin_y,*/ distance, height, ripple_interval = 1.3;

    fillCubeArray(0x00);
//    QVector<QVector<QVector<quint8> > > tripleVector(iterations(),QVector<QVector<quint8> >(8, QVector<quint8>(8)));

    for (quint16 i=0; i<iterations(); i++)
    {
        if(m_abort)
            return;
        for (quint8 x=0; x<8; x++)
        {
            for (quint8 y=0; y<8; y++)
            {
                distance = distance2d(3.5,3.5,x,y)/9.899495*8;
                height = 4+sin(distance/ripple_interval+static_cast<float>(i)/50)*4;
                setBixel(x,y,static_cast<quint8>(height));
            }
        }
        waitMs(speed());
//        tripleVector[i] = cubeFrame;
        fillCubeArray(0x00);
    }
//    for (int i = 0; i < iterations(); i++) {
//        sendData(tripleVector[i]);
////        if(i/10 == 0)
////            waitMs(speed());
//    }
    Q_EMIT done();
}
예제 #7
0
void WireBoxCornerShrinkGrow::createWireBoxCorner(const quint8 rotate, const quint8 flip)
{
    quint8 xyz = 0;
    for (quint16 j = 0; j < m_iterations; j++)
    {
        for (quint8 i = 0; i < CUBE_SIZE * 2; i++)
        {
            xyz = CUBE_SIZE - 1 - i;
            if (i > CUBE_SIZE - 1)
                xyz = i - CUBE_SIZE;
            fillCubeArray(0x00);
            boxWireframe(0, 0, 0, xyz, xyz, xyz);

            if (flip > 0)
                mirrorZ();
            if (rotate == 1 || rotate == 3)
                mirrorY();
            if (rotate == 2 || rotate == 3)
                mirrorX();
            if(m_abort)
                return;
            waitMs(speed());
        }
    }
}
예제 #8
0
msg_t Light::moduleThread(void* arg) {

	(void) arg;

	bool noRecall = true;
	LedData* state;

	while (!chThdShouldTerminate()) {
		chSemWait(&_sem);

		while (TRUE) {
			noRecall = true;

			for (uint8_t i = 0; i < N_LEDS; ++i) {
				if (!data[i].isEmpty()) {
					state = data[i].getHead();

					switch (state->state) {
						case FADE:
							state->current.setRGB(state->startColor.getR() + state->diff.getR() * state->steps / state->totalSteps,
									state->startColor.getG() + state->diff.getG() * state->steps / state->totalSteps,
									state->startColor.getB() + state->diff.getB() * state->steps / state->totalSteps
									);

							leds[i].shine(state->current);

							state->steps++;

							if (state->steps == state->totalSteps) {
								leds[i].shine(state->endColor);
								data[i].pop();

								if (!data[i].isEmpty())
									noRecall = false;
							}
							else
								noRecall = false;

							break;

						case SHINE:
							break;

						case INACTIVE:
							break;
					}
				}
			}

			waitMs(_threadDelay);

			if (noRecall)
				break;
		}
	}

	return (msg_t)0;
}
예제 #9
0
void _show_scr( const Image *img, u32 ms )
{
   SYS_disableInts();
   VDP_setEnable(FALSE);
      VDP_drawImageEx( BPLAN, img, TILE_ATTR_FULL( PAL0, FALSE, FALSE, FALSE, TILE_USERINDEX ), 0, 0, TRUE, FALSE );
   VDP_setEnable(TRUE);
   SYS_enableInts();

   waitMs(ms);
}
예제 #10
0
static void _init( u16 hard )
{
   if ( hard == 0 ) // 0 is soft reset
   {
      VDP_drawText ( "BUG HUNT", 16, 9 );
      VDP_drawText ( "FOR SEGA MEGADRIVE", 11, 11 );
      VDP_drawText ( "BY THE AFROMONKEYS, 2015", 8, 13 );

      waitMs(3000);


      // That's weird.
      // Resetting in SGDK v1.11 invokes JOY_init() that
      // makes Justifier | Menacer not to be detected if
      // mouse is on PORT_1

      if ( JOY_getPortType(PORT_1) != PORT_TYPE_PAD )
      {
         VDP_drawText ( "PLEASE, REBOOT YOUR SYSTEM", 7, 19 );

         while ( 1 );
      }

      _start_entry(); // even more reset
   }


   sd_reset();
   SYS_assertReset(); // makes gensKmod crash, WTF?!



   VDP_init();
   //JOY_init();  // can cause mouse + justifer issues

   h_scroll = 0;
   VDP_setScrollingMode ( HSCROLL_PLANE, VSCROLL_PLANE );     /* The scroll mode never change during the game */
   VDP_setPlanSize(64,32);

   save_init( );

   SPR_init(0);                                             /* Sprite Engine INIT */
   VDP_setPalette(PAL3, sprpal.data);                       /* Sprite Palette (never change during the game) */

   /* PAD & Mouse (PORT_1) & Lightgun (PORT_2) Support */
   _JOYint ( TRUE );
   LightgunInit ( PORT_2 );

   VINT_SCROLL_FLAG  = FALSE;
   VINT_JOY_UPDATE   = FALSE;

   SYS_setVIntCallback((_voidCallback*) VIntCallback);

   FIRST_TIME_FLAG = TRUE;
}
예제 #11
0
void display_memFree(u16 displayTimeMs){
    char free_memStr[6];
    int free_mem = MEM_getFree();
    intToStr(free_mem, free_memStr, 6);
    VDP_drawText("FREE MEM :", 10, 9);
    VDP_drawText(free_memStr, 10, 10);
    VDP_waitVSync();
    waitMs(displayTimeMs);
    VDP_drawText("          ", 10, 9);
    VDP_drawText("          ", 10, 10);
}
예제 #12
0
파일: Loadbar.cpp 프로젝트: cslux/ledcc
void Loadbar::createAnimation()
{
    fillCubeArray(0x00);
    for (quint8 i = 0; i < CUBE_SIZE; i++)
    {
        setPlane(m_axis, i);
        if(m_abort)
            return;
        waitMs(speed());
    }
    waitMs(speed() * 2);
    for (quint8 i = 0; i < CUBE_SIZE; i++)
    {
        clearPlane(m_axis, i);
        if(m_abort)
            return;
        waitMs(speed());
    }
    Q_EMIT done();
}
예제 #13
0
void R_LCD_Create(void)
{
    volatile uint32_t wt_count;
    
    RTCEN = 1U;    /* supply LCD clock */
    LCDON = 0U;    /* disable LCD clock operation */
    LCMK0 = 1U;    /* disable INTLCD0 interrupt */
    LCIF0 = 0U;    /* clear INTLCD0 interrupt flag */
    LCDM1 |= _01_LCD_VOLTAGE_LOW;
    LCDM0 = _00_LCD_DISPLAY_WAVEFORM_A | _0D_LCD_DISPLAY_MODE1;
    LCDM0 |= _40_LCD_VOLTAGE_MODE_INTERNAL;
    /* Set CAPL and CAPH pins */
    ISCLCD &= (uint8_t)~_01_LCD_CAPLH_BUFFER_VALID;
    P12 &= 0x3FU;
    PM12 |= 0xC0U;
    /* Set segment pins */
    PFSEG0 |= 0xC0U;
    PFSEG1 |= 0xFFU;
    PFSEG2 |= 0xF9U;
    PFSEG3 |= 0x9FU;
    PFSEG4 |= 0x7EU;
    PMC1 &= 0xF7U;
    P1 &= 0x76U;
    PM1 &= 0x76U;
    P3 &= 0xFEU;
    PM3 &= 0xFEU;
    PMC4 &= 0xFDU;
    P4 &= 0xF1U;
    PM4 &= 0xF1U;
    P5 &= 0xE0U;
    PM5 &= 0xE0U;
    P6 &= 0xFCU;
    PM6 &= 0xFCU;
    P7 &= 0xE0U;
    PM7 &= 0xE0U;
    PMC12 &= 0xFEU;
    P12 &= 0xFEU;
    PM12 &= 0xFEU;
    PMC14 &= 0xC3U;
    P14 &= 0x00U;
    PM14 &= 0x00U;
    LCDM1 |= _00_LCD_DISPLAY_PATTERN_A;
    LCDC0 = _00_LCD_SOURCE_CLOCK_FSUB | _05_LCD_CLOCK_FLCD_64;
    VLCD = _0C_LCD_BOOST_VOLTAGE_140V;

    /* Change the waiting time according to the system */
	  waitMs(5);
// 	 for (wt_count = 0U; wt_count <= LCD_REFVOLTAGE_WAITTIME; wt_count++)
//    {
//        NOP();
//    }
}
예제 #14
0
void text_draw ( u8 *str, u8 x, u8 y, u16 ms )
{
	#define POSITION	_base + _positions[chr] * _tiles + inc


	u8 chr;

	u16 k;
	u16 j;
	u16 i   = 0;
	u16 inc = 0;

   u8 *aux = str;

	while ( (chr = *aux++) )
	{
		inc = 0;
		chr -= ' ';
		if ( chr >= 96 ) chr = 0;

		if ( ! _positions[chr] )
		{
			_positions[chr] = _counter++;
			VDP_loadTileData ( _genres->sprites[chr], POSITION, _tiles, TRUE );
			VDP_waitDMACompletion();
		}
   }

	while ( (chr = *str++) )
	{
		inc = 0;
		chr -= ' ';
		if ( chr >= 96 ) chr = 0;

		for ( j = 0; j < _height; j++ )
		{
			for ( k = 0; k < _width; k++ )
			{
				VDP_setTileMapXY ( BPLAN, TILE_ATTR_FULL ( _palette, TRUE, 0, 0, POSITION ), i*_width + x + j, y + k );
				++inc;
			}
		}

		waitMs ( ms );
		++i;
	}
}
예제 #15
0
void MainWindow::stopCommunication()
{
    disconnect( mSerialThread, SIGNAL(controlState(bool,bool,bool,bool,bool,bool)),0,0);
    disconnect( mSerialThread, SIGNAL(charReceived(int,int)),0,0);

    uint32_t counter = 10;
    while (mSerialThread->stop() == false)
    {
        counter--;
        if (counter==0)
        {
            break;
        }
        waitMs(200);
    }

    closeUART();
}
예제 #16
0
void typeText ( char *str, u8 x, u8 y, u16 ms )
{
	u8 i, len = strlen ( str );

	for ( i=0; i<len; i++ )
	{
	    const char aux[2] = { str[i], '\0' };

        SYS_disableInts();
		VDP_drawText ( aux, x++, y );
		SYS_enableInts();

		if ( aux[0] != ' ' )
        {
            waitMs(ms);
        }
	}
}
예제 #17
0
파일: Wall.cpp 프로젝트: cslux/ledcc
void Wall::createAnimation()
{
    quint8 i = 0;

    fillCubeArray(0x00);

    if (m_direction)
        setPlane(m_axis, 0);
    else
        setPlane(m_axis, 7);

    for (i = 0; i < CUBE_SIZE ; i++)
    {
        if(m_abort)
            return;
        waitMs(speed());
        shift(m_axis, m_direction);
    }
    Q_EMIT done();
}
예제 #18
0
/**
 * @brief Main module thread
 */
msg_t Moti::moduleThread(void* arg) {

	(void) arg;

	while (!chThdShouldTerminate()) {

		if (_isStarted) {

			Moti::detectStuck();
			Moti::detectSpin();
			Moti::detectShake();
			Moti::detectFall();

		}

		waitMs(_threadDelay);
	}

	return (msg_t)0;
}
예제 #19
0
//Processes Credits screen
void Credits()
{
    JOY_setEventHandler( &BtnNada );    //Set Event handler to nothing
    const u8 x=1;       //Constant column value for text disp
    u8 y=1;             //Variable row ~
    const wait=3000;    //Time in MS to wait

    echo_play_bgm(BGM_14);  //Play IceHockey2
    DrawBG(0);              //cls
    DrawBG(10);             //Draw Hockey rink

    //Setup text planes and colors
    VDP_setTextPlan(PLAN_B);
    VDP_setTextPriority(PTRUE);
    VDP_setPaletteColor((OBJPAL * 16)+15,0xEE);   //Yellow
    VDP_setTextPalette(OBJPAL);

    //Draw a line, increment row, draw next line, repeat in screen chunks

    //            1234567890123456789012345678901234567
    VDP_drawText("+-----------------------------------+",x,y);y++;
    VDP_drawText("| ULTRA AIR HOCKEY (Genesis), V1.0  |",x,y);y++;
    VDP_drawText("|              Credits              |",x,y);y++;
    VDP_drawText("+-----------------------------------+",x,y);y++;
    VDP_drawText("|Producer                     Tamkis|",x,y);y++;
    VDP_drawText("|Art creator                  Tamkis|",x,y);y++;
    VDP_drawText("+-----------------------------------+",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                Music              |",x,y);y++;
    VDP_drawText("|All songs were converted to the    |",x,y);y++;
    VDP_drawText("|Echo sound engine                  |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|      Various module music artists |",x,y);y++;
    VDP_drawText("|Unless otherwise noted, all modules|",x,y);y++;
    VDP_drawText("|are from modarchive.org/           |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|http://modarchive.org/index.php?req|",x,y);y++;
    VDP_drawText("|uest=view_by_moduleid&query=NUMBER |",x,y);y++;
    VDP_drawText("v                                   v",x,y);y++;

    //wait MS, clear the text plane, repeat for next screen chunk
    waitMs(wait);
    VDP_clearPlan(BPLAN,0);
    y=1;

    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|hockey_fever.xm  The Einstein Crew |",x,y);y++;
    VDP_drawText("|144817                             |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|nes_mes2.mod        Goto80         |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|PITTITLE.mod        (Unknown)      |",x,y);y++;
    VDP_drawText("|112082                             |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|ice-hockey_94theme.mod Subtance/   |",x,y);y++;
    VDP_drawText("|inflow 121145                      |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|organmaster.mod     Gamma7         |",x,y);y++;
    VDP_drawText("|169287                             |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|intro101.mod        w.o.t.w of     |",x,y);y++;
    VDP_drawText("|supplex                            |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|hurry_up.mod        reflex/rebels  |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("v                                   v",x,y);y++;

    waitMs(wait);
    VDP_clearPlan(BPLAN,0);
    y=1;

    VDP_drawText("|slowmotion.mod     tobbx/Tobbe Lars|",x,y);y++;
    VDP_drawText("|157022                             |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|Castle_load.mod     Exodus         |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|complexity.mod      (Unknown)      |",x,y);y++;
    VDP_drawText("|92979                              |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|Reflexity_music.mod (subsong #3)   |",x,y);y++;
    VDP_drawText("|Unknown             109459         |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|chipmunks.mod       Jester/Sanity  |",x,y);y++;
    VDP_drawText("|36792                              |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|icehockey2.mod      Subversion     |",x,y);y++;
    VDP_drawText("|123683                             |",x,y);y++;
    VDP_drawText("+-----------------------------------+",x,y);y++;
    VDP_drawText("v                                   v",x,y);y++;

    waitMs(wait);
    VDP_clearPlan(BPLAN,0);
    y=1;

    VDP_drawText("|             Sound effects         |",x,y);y++;
    VDP_drawText("|Unless otherwise noted, all sfx are|",x,y);y++;
    VDP_drawText("|from Freesound.org                 |",x,y);y++;
    VDP_drawText("|http://www.freesound.org/people/   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|ID(+16) Name            URL        |",x,y);y++;
    VDP_drawText("|01      Menu highlight             |",x,y);y++;
    VDP_drawText("|broumbroum/sounds/50561/           |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|02      Menu select                |",x,y);y++;
    VDP_drawText("|Bertrof/sounds/131658/             |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|03      Puck hit                   |",x,y);y++;
    VDP_drawText("|krb21/sounds/118604/               |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|04/30   Puck deflect               |",x,y);y++;
    VDP_drawText("|BranRainey/sounds/108737/          |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("v                                   v",x,y);y++;

    waitMs(wait);
    VDP_clearPlan(BPLAN,0);
    y=1;

    VDP_drawText("|05      Bumper hit                 |",x,y);y++;
    VDP_drawText("|timgormly/sounds/170140/           |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|06      Powerup get                |",x,y);y++;
    VDP_drawText("|RandomationPictures/sounds/138491/ |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|07      Powerup use                |",x,y);y++;
    VDP_drawText("|jobro/sounds/35464/                |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|08      Goal siren                 |",x,y);y++;
    VDP_drawText("|UncleSigmund/sounds/117122/        |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|09-29   Announcer guy stuff        |",x,y);y++;
    VDP_drawText("|All generated w Acapela Box using  |",x,y);y++;
    VDP_drawText("|the English (UK) Peter voice       |",x,y);y++;
    VDP_drawText("|https://acapela-box.com/AcaBox/    |",x,y);y++;
    VDP_drawText("|index.php                          |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("v                                   v",x,y);y++;

    waitMs(wait);
    VDP_clearPlan(BPLAN,0);
    y=1;

    VDP_drawText("|31      Buzzer                     |",x,y);y++;
    VDP_drawText("|cognito%20perceptu/sounds/17468/   |",x,y);y++;
    VDP_drawText("+-----------------------------------+",x,y);y++;
    VDP_drawText("|             Beta testers          |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|DUDE #1    - Stuff                 |",x,y);y++;
    VDP_drawText("|DUDE #2    - Stuff                 |",x,y);y++;
    VDP_drawText("|DUDE #3    - Stuff                 |",x,y);y++;
    VDP_drawText("+-----------------------------------+",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|            Special Thanks         |",x,y);y++;
    VDP_drawText("|Oerg866 and SiktheHedgehog         |",x,y);y++;
    VDP_drawText("|Echo Sound Engine and related tools|",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|Stephane              Help, SGDK   |",x,y);y++;
    VDP_drawText("|Nemesis  Exodus emulator (debuging)|",x,y);y++;
    VDP_drawText("v                                   v",x,y);y++;

    waitMs(wait);
    VDP_clearPlan(BPLAN,0);
    y=1;

    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("+===================================+",x,y);y++;
    VDP_drawText("|                YOU                |",x,y);y++;
    VDP_drawText("|            FOR PLAYING!           |",x,y);y++;
    VDP_drawText("|  Ultra Air Hockey (Genesis) V1.0  |",x,y);y++;
    VDP_drawText("|        EagleSoft Ltd 2015         |",x,y);y++;
    VDP_drawText("|       www.eaglesoftltd.com        |",x,y);y++;
    VDP_drawText("+===================================+",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;

    waitMs(wait);
    echo_wait_sfx(SFX_02);      //Play select sfx
    VDP_fadeOutAll(100,_FALSE);
    DrawBG(0);                  //cls
}
예제 #20
0
파일: main.c 프로젝트: mateuszaaa/Projects
int main(void)
{
    int pwm;
    int adc_on;
    int adc_off;
    uint16_t i;
    element elem;

    robot.rotation_target = 0;
    robot.right_motor_pos =0;
    robot.left_motor_pos =0;
    robot.right_motor_target =0;
    robot.left_motor_target =0;
	SysTick_Config(168000000/8/1000000); // interrupr 1000000 per secound

    
   initTimer3(1);
   initMotors();
   initEncoders();
   initUsart3();
//   enableUSART3RXNEInterrupt();
   initADC();
   initIRSensors();
   initLED();
   initSPI2();

   LED_OFF;
   waitMs(1000);
   LED_ON;

   initPIDStructures();
   stopMotors();
   resetEncoders();
   updateRobotState();
   robot.left_ir_sensor_target = measures.left_ir_sensor;
   robot.right_ir_sensor_target = measures.right_ir_sensor;

   initQueue(&robot_queue);
   //addMove(&robot_queue,FORWARD,2000);
   addMove(&robot_queue,ROTATE,20000);
//   addMove(&robot_queue,FORWARD,9000);
//   addMove(&robot_queue,ROTATE,0);
//   addMove(&robot_queue,ROTATE,6000);
//   addMove(&robot_queue,FORWARD,9000);
//   addMove(&robot_queue,ROTATE,6000);
//   addMove(&robot_queue,ROTATE,12000);
//   addMove(&robot_queue,FORWARD,9000);
//   addMove(&robot_queue,ROTATE,12000);
//   addMove(&robot_queue,ROTATE,3000);
//   nextMove();
   

   LED_ON;
    while(1)
    {
        if ( isBatteryWeak() ){
            stopMotors();
            blinkLed();
        }
        if (flags.update_robot == 1){
            moveRobot();
            updateRobotState(); 
            flags.update_robot =0;
        }

        if (flags.usart_custom == 1){


            USART3_transmitString(itoa((int) robot.rotation, buf,10));
            USART3_transmitString(" ");
            USART3_transmitString(itoa((int) robot.rotation_target, buf,10));
            USART3_transmitString("\n");


        }
    }
//        flags.usart_custom == 0;
//        USART3_transmitString("lewe_kolo_diff ");
//        USART3_transmitString(itoa((int) robot.left_motor_target - robot.left_motor_pos , buf,10));
//        USART3_transmitByte('\n');
//        USART3_transmitString("lewe kolo pwm ");
//        USART3_transmitString(itoa((int) getTranslation(LEFT_MOTOR) , buf,10));
//        USART3_transmitByte('\n');
//    
//        USART3_transmitString("prawe kolo diff ");
//        USART3_transmitString(itoa((int) robot.right_motor_target - robot.right_motor_pos , buf,10));
//        USART3_transmitByte('\n');
//        USART3_transmitString("prawe kolo pwm ");
//        USART3_transmitString(itoa((int) getTranslation(RIGHT_MOTOR) , buf,10));
//        USART3_transmitByte('\n');
//    }
//
//    if (flags.usart_graph == 1){
//        static uint8_t usart_start = 1;
//        if (usart_start ){
//            usart_start=0;
//            USART3_transmitString("\n");
//            USART3_transmitString("\n");
//            USART3_transmitString("\n");
//            USART3_transmitString("__start__\n");
//            USART3_transmitString("lewe_kolo_pozycja ");
//            USART3_transmitString("lewe_kolo_cel ");
//            USART3_transmitString("lewe_kolo_diff ");
//            USART3_transmitString("lewe_kolo_pwm_T ");
//            USART3_transmitString("prawe_kolo_pozycja ");
//            USART3_transmitString("prawe_kolo_cel ");
//            USART3_transmitString("prawe_kolo_diff ");
//            USART3_transmitString("prawe_kolo_pwm_T \n");
//            USART3_transmitString(" \n");
//        }
//
//        USART3_transmitString(itoa((int) robot.right_motor_pos , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) robot.right_motor_target , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) robot.right_motor_target - robot.right_motor_pos , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) getTranslation(RIGHT_MOTOR) , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) robot.left_motor_pos , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) robot.left_motor_target , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) robot.left_motor_target - robot.left_motor_pos , buf,10));
//        USART3_transmitString(" ");
//        USART3_transmitString(itoa((int) getTranslation(LEFT_MOTOR) , buf,10));
//        USART3_transmitByte('\n');
//        flags.usart_graph = 0;
//    }
//    }
//


return 0;
}