当前位置: 首页>>代码示例>>C++>>正文


C++ delayms函数代码示例

本文整理汇总了C++中delayms函数的典型用法代码示例。如果您正苦于以下问题:C++ delayms函数的具体用法?C++ delayms怎么用?C++ delayms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了delayms函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ram

void ram(void)
{
    int c=0, pos=0,del=0;

    struct pos_s tail[MAX_SNAKE_LEN];
    snake.tail = tail;

    // load the highscore
    highscore = highscore_get();

    // initially reset everything
    reset();

    while (1) {
        if(!(++c % snake.speed)) {
            handle_input();

            pos = (snake.t_start+1) % MAX_SNAKE_LEN;
            snake.tail[pos].x = snake.tail[snake.t_start].x;
            snake.tail[pos].y = snake.tail[snake.t_start].y;

            if(snake.dir == 0)
                snake.tail[pos].x++;
            else if(snake.dir == 1)
                snake.tail[pos].y++;
            else if(snake.dir == 2)
                snake.tail[pos].x--;
            else if(snake.dir == 3)
                snake.tail[pos].y--;

            snake.t_start = pos;

            if (pos < snake.len) {
                del = MAX_SNAKE_LEN - (snake.len - pos);
            } else
                del = pos - snake.len;

            // remove last, add first line
            draw_block(snake.tail[del].x, snake.tail[del].y, 0xFF);
            draw_block(snake.tail[pos].x, snake.tail[pos].y, 0b00011000);

            // check for obstacle hit..
            if (hitWall() || hitSelf()) {
                death_anim();
                if (showHighscore())
                    break;
                reset();
            } else if (hitFood())
                next_level();

            lcdDisplay();
        }

#ifdef SIMULATOR
        delayms(50);
#else
        delayms(3);
#endif
    }
}
开发者ID:cokesme,项目名称:f1rmware,代码行数:60,代码来源:snake.c

示例2: ram

/** reaction.c
 *  First l0dable for my r0ket
 *  Improvement is welcome
 *
 * AUTHOR: hubba
*/
void ram(void)
{
    char x = gpioGetValue(RB_LED1);
    int rand_wait = 0;
    int react_time=0;
    int start_time = 0;
    int end_time = 0;

    gpioSetValue (RB_LED1,0);           //upperleft LED off
    lcdClear();
    lcdPrintln("Hello");
    lcdPrintln(GLOBAL(nickname));
    lcdPrintln("ReACTION");
    lcdRefresh();
    delayms(500);
    while(1)
    {
        react_time = 0;
        lcdPrintln("Press ENTER if ");
        lcdPrintln("LED is on!");
        lcdRefresh();
        rand_wait = getRandom();
        rand_wait = rand_wait%50;
        rand_wait = 40 + rand_wait*4;        // Minimum pause time is 400ms
        for(int i =0; i<=rand_wait; i++)     //directly calling delayms(rand_wait) didn't work
        {
            delayms(10);
        }
        gpioSetValue (RB_LED1, 1);          //upperleft LED ON
        getInputWaitRelease();
        start_time = getTimer()*(SYSTICKSPEED);
        while (getInputWait() != BTN_ENTER);    //wait for user input
        {

        }
        end_time =  getTimer()*(SYSTICKSPEED);
        react_time = end_time - start_time;     //measure  used time
        lcdClear();
        lcdPrint("Needed ");
        lcdPrintInt(react_time);
        lcdPrintln(" ms");
        lcdPrintln("DOWN: Exit");
        lcdPrintln("0ther: New game");
        lcdRefresh();
        gpioSetValue (RB_LED1,0);           //upperleft LED off

        getInputWaitRelease();
        if(getInputWait() ==  BTN_DOWN)     //Check for Exit/new game
        {
            gpioSetValue (RB_LED1, x);      //upperleft LED as before l0dable executed
            return;
        }
    }
    /* NEVER LAND HERE */
    lcdPrintln("Flow-Error");
    lcdRefresh();
    return;
};
开发者ID:blubkatze,项目名称:r0ket,代码行数:64,代码来源:reaction.c

示例3: mandelMove

void mandelMove() {
    //long delta_r = (mandel.rmax - mandel.rmin)/10;
    //long delta_i = (mandel.imax - mandel.imin)/10;

	long rs =(mandel.rmax-mandel.rmin)/RESY;
	long is =(mandel.imax-mandel.imin)/RESX;

	char key = getInputWaitTimeout(10);

	if (key == BTN_LEFT) {
		mandel.imax -=is;
		mandel.imin -=is;
		mandel.dleft = true;
	} else if (key == BTN_RIGHT) {
		mandel.imax += is;
		mandel.imin += is;
		mandel.dright = true;
	} else if (key == BTN_DOWN) {
		mandel.rmax += rs;
		mandel.rmin += rs;
		mandel.ddown = true;
	} else if (key == BTN_UP) {
		mandel.rmax -= rs;
		mandel.rmin -= rs;
		mandel.dup = true;
	} else if (key == BTN_ENTER) {
		if (mandel.presscount < mandel.presslimitzin) {
			mandel.presscount = mandel.presscount + 1;
		}
	} else if (key == BTN_NONE) {
		//delayms_queue(15);
		if(mandel.presscount > 0 ) {
			mandel.presscount = mandel.presscount - 1;
			mandel.clickmark = true;
		}
		if (mandel.presscount == 0 ) {
			mandel.clickmark = false;
		}
	}
	if (mandel.presscount > mandel.presslimitzout && mandel.clickmark && key == BTN_ENTER && mandel.zoomlevel >= mandel.maxzoomout) {
		mandel.imin = mandel.imin - (mandel.imax-mandel.imin)/8;
		mandel.imax = mandel.imax + (mandel.imax-mandel.imin)/8;
		mandel.rmin = mandel.rmin -(mandel.rmax-mandel.rmin)/8;
		mandel.rmax = mandel.rmax +(mandel.rmax-mandel.rmin)/8;
        mandel.dirty = true;
        delayms(10);
        mandel.zoomlevel = mandel.zoomlevel - 1 ;
	 }
       else if (mandel.presscount == mandel.presslimitzin && key == BTN_ENTER && mandel.zoomlevel <= mandel.maxzoomin ) {
        mandel.imin = mandel.imin + (mandel.imax-mandel.imin)/8;
        mandel.imax = mandel.imax - (mandel.imax-mandel.imin)/8;
        mandel.rmin = mandel.rmin +(mandel.rmax-mandel.rmin)/8;
        mandel.rmax = mandel.rmax -(mandel.rmax-mandel.rmin)/8;
        mandel.dirty = true;
        delayms(10);
        mandel.zoomlevel = mandel.zoomlevel + 1 ;
     }
}
开发者ID:cokesme,项目名称:f1rmware,代码行数:58,代码来源:mandel.c

示例4: lcd_init

void lcd_init(unsigned char color)
{
    P5DIR |= CSX + SDA + SCLK + RESX;
    
  P5OUT |= CSX;
  P5OUT &= ~SDA;
  P5OUT &= ~SCLK;

  P5OUT &= ~RESX;
  delayms(20);
  P5OUT |= RESX;
  delayms(20);

  // Sleep out...
  n6100_send(0x11,2);   
  // Ajusta o contraste...
  n6100_sendcom1(0x25, 0x50);
  // Liga o display e o booster...    
  n6100_send(0x29,2);
  n6100_send(0x03,2);
  delayms(10);  
    
  // Color Format... (8bits/pixel)
  n6100_sendcom1(0x3a, 0x02);
  // Inicializa a tabela de cores 8bits/pixel
  n6100_send(0x2d,2);
  // red
  n6100_send(0x00,0);
  n6100_send(0x02,0);
  n6100_send(0x05,0);
  n6100_send(0x07,0);
  n6100_send(0x09,0);
  n6100_send(0x0b,0);
  n6100_send(0x0d,0);
  n6100_send(0x0f,0);
  // green
  n6100_send(0x00,0);
  n6100_send(0x02,0);
  n6100_send(0x05,0);
  n6100_send(0x07,0);
  n6100_send(0x09,0);
  n6100_send(0x0b,0);
  n6100_send(0x0d,0);
  n6100_send(0x0f,0);
  // blue
  n6100_send(0x00,0);
  n6100_send(0x05,0);
  n6100_send(0x0b,0);
  n6100_send(0x0f,0);

  // Memory Access Control...  
  n6100_sendcom1(0x36, invertido);
  // Agradecimentos...
  lcd_fillrect(0, 0, 132, 132, color);
  //n6100_putlogo(2, 2, 128, 128, (unsigned char *)Matrix);
  //delayms(4000);
}
开发者ID:flaviohpo,项目名称:microquad,代码行数:57,代码来源:lcd6100.c

示例5: openLCD

void openLCD(void) {
    LCD_DIR = 0xFF;              // configure LCD_DAT port for output
    delayms(10);
    cmd2LCD(0x28);               // set 4-bit data, 2-line display, 5x7 font
    cmd2LCD(0x0E);               // turn on display, cursor, not blinking
    cmd2LCD(0x06);               // move cursor right
    cmd2LCD(0x01);               // clear screen, move cursor to home
    delayms(2);                  // wait until "clear display" command is complete
}
开发者ID:mbhatt1,项目名称:Code-Examples,代码行数:9,代码来源:Project3.c

示例6: write_com

/*1602显示程序*/
void write_com(uchar com)
{
	lcdrs=0;
	P0=com;
	delayms(5);
	lcden=1;
	delayms(5);
	lcden=0;
}
开发者ID:zhouxinkai,项目名称:Work,代码行数:10,代码来源:最终程序.c

示例7: write_date

void write_date(uchar date)
{
	lcdrs=1;
	P0=date;
	delayms(5);
	lcden=1;
	delayms(5);
	lcden=0;
}
开发者ID:zhouxinkai,项目名称:Work,代码行数:9,代码来源:最终程序.c

示例8: main

void main()
{
    while(1){
        P2 = 0xff;
        delayms(499);
        P2 = 0x0;
        delayms(499);
    }
}
开发者ID:gentio,项目名称:mcs51,代码行数:9,代码来源:led2.c

示例9: menu_conf_exit

void menu_conf_exit(Uint8 saved, Uint16 menu){

        lcd_dis_saved[saved]();
        delayms(200);
        lcd_dis_menu[menu]();
        delayms(300);
        lcd_dis_saved[saved]();
        delayms(200);
        lcd_dis_menu[menu]();
}
开发者ID:bingjinyeah,项目名称:prjt,代码行数:10,代码来源:menu_conf.c

示例10: lcdInitial

//LCD1602初始化
void lcdInitial()
{
   writeCom(0x38);//显示模式设置
   delayms(5); 
   writeCom(0x08);//显示关闭
   clear_scr();//清屏
   writeCom(0x06); //显示光标移动设置
   delayms(5);
   writeCom(0x0C); //显示开及光标设置 
}
开发者ID:caozhengquan,项目名称:Learning,代码行数:11,代码来源:lesson6_3.c

示例11: main

int main()
{
    int wait;
    // Set up port for start switch
    lcdInit();
    // Set up motors and encoders
    motorInit();
    encodersInit();
    servoInit();
    // Set up IRs
    gp2d12Init(PIN_HEAD_IR);
    digitalSetDirection(PIN_IR,AVRRA_INPUT);
    digitalSetData(PIN_IR,AVRRA_LOW);
    // Set up OP599A - analog already initialized
    digitalSetDirection(PIN_PHOTO,AVRRA_INPUT);
    digitalSetData(PIN_PHOTO,AVRRA_LOW);
    // Set up fan & test
    digitalSetData(PIN_FAN, AVRRA_LOW);
    digitalSetDirection(PIN_FAN, AVRRA_OUTPUT);
    digitalSetData(PIN_FAN, AVRRA_HIGH);
    delayms(25);
    digitalSetData(PIN_FAN, AVRRA_LOW);

    lcdPrint("Wait... ");
    wait = digitalGetData(PIN_START);
    while(wait) {
        // standard delay ..
        delayms(10);
        wait = digitalGetData(PIN_START);
    }

    // Start our map
    mapInit();
    lcdClear();
    PrintHeading(lheading,nStart);
    sei();

    // Run Behaviors
    while(1) {
        // update odometer
        while(rCount > COUNTS_CM(1) ) {
            // odometer is in CM
            odometer = odometer - 1;
            rCount = rCount - COUNTS_CM(1);
        }
        // now run behaviors
        if(arbitrate()>0) {
            // let motors wind down
            delayms(500);
            clearCounters;
            plan();
            clearCounters;
        }
    }
}
开发者ID:mikeferguson,项目名称:crater,代码行数:55,代码来源:main.c

示例12: led_blinking

void led_blinking(void)
{
 P0=ledout(0x88);
 delayms(100);

 P0=ledout(0x33);
 delayms(100);

 P0=ledout(0x44);
 delayms(100);
}
开发者ID:CatPark,项目名称:MCU51_TestBench,代码行数:11,代码来源:led_pattern.c

示例13: initBoard

void initBoard(void)
{
	PORT_Arduino 	 = 0xff;	// Set Port ready for Input from Arduino, set DataAck=1 (Standy)
	PORT_Ctrl_Status = 0xff;	// Turn all LED Off and ready to read Key#2	status

	WSN_RST			 = 0;		// Reset WSN-02/03 Wireless module
	delayms(10);				// Delay 50ms
	WSN_RST			 = 1;		// Normal Operation
	delayms(10);				// Wait for WSN-02/03 ready
	
} /* initBoard */
开发者ID:WowFunHouse,项目名称:ElWire,代码行数:11,代码来源:Tx0010.c

示例14: debug_stop

void debug_stop(uint8_t data, int stoptime)
{
  PORTD = data;
  if (stoptime == 0)
  {
    while (BUTTON_GetValue());
    delayms(150);
  } else
  {
    delayms(stoptime);
  }
}
开发者ID:bekeband,项目名称:PressureMeter,代码行数:12,代码来源:LiquidCrystal_I2C.c

示例15: lcdInit

void lcdInit(void) {
	SETUPgout(LCD_BL_EN);
	SETUPgout(LCD_RESET);
	SETUPgout(LCD_CS);

	/* prepare SPI */
	SETUPpin(LCD_MOSI);
	SETUPpin(LCD_SCK);

	// Reset the display
    OFF(LCD_RESET);
    delayms(100); /* 1 ms */
    ON(LCD_RESET);
    delayms(100); /* 5 ms */

    lcd_select();

	static uint8_t initseq_d[] = {
		/* The controller is a PCF8833 -
		   documentation can be found online.
		 */
		0x11,              // SLEEP_OUT  (wake up)
		0x3A, 2,           // mode 8bpp  (2= 8bpp, 3= 12bpp, 5= 16bpp)
		0x36, 0b11000000,  // my,mx,v,lao,rgb,x,x,x
		0x25, 0x3a,        // set contrast
		0x29,              // display on 
		0x03,              // BSTRON (booster voltage)
		0x2A, 1, RESX,
		0x2B, 1, RESY
	};
	uint16_t initseq_c = ~  (  /* commands: 1, data: 0 */
			(1<< 0) |
			(1<< 1) | (0<< 2) |
			(1<< 3) | (0<< 4) |
			(1<< 5) | (0<< 6) |
			(1<< 7) |
			(1<< 8) |
			(1<< 9) | (0<<10) | (0<<11) |
			(1<<12) | (0<<13) | (0<<14) |
			0);
	int i = 0;

	lcdWrite(0, 0x01); /* most color displays need the pause */
	delayms(10);

	while(i<sizeof(initseq_d)){
		lcdWrite(initseq_c&1, initseq_d[i++]);
		initseq_c = initseq_c >> 1;
	}
    lcd_deselect();
	lcdFill(0xff); /* Clear display buffer */
	setSystemFont();
}
开发者ID:FlorianHeigl,项目名称:f1rmware,代码行数:53,代码来源:display.c


注:本文中的delayms函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。