Exemple #1
0
void ram(void) {
    lcdClear();
    lcdPrintln("r0ket");
    lcdPrintln("Release: ");
    lcdPrintln(IntToStrX(getrelease(),8));
    lcdRefresh();
    while(!getInputRaw())work_queue();
}
Exemple #2
0
int main(void)
{
	cpu_clock_init_();
//	cpu_clock_pll1_max_speed();
	scu_pinmux(RF_EN_PIN,SCU_GPIO_NOPULL|RF_EN_FUNC);
	GPIO_DIR(RF_EN_GPORT) |= RF_EN_GPIN;
	gpio_clear(RF_EN_GPORT, RF_EN_GPIN); /* RF off */

    // Config LED as out
	scu_pinmux(LED1_PIN,SCU_GPIO_NOPULL|LED1_FUNC);
	GPIO_DIR(LED1_GPORT) |= LED1_GPIN;

	inputInit();

    lcdInit();
    lcdFill(0xff);
	setSystemFont();
	char tu=0,td=0,tl=0,tr=0,tm=0;
	char led=0;
	lcdPrintln("Sec-Test v2");
	lcdPrintln("");

	int ctr=0;
	int k=0;
	/* Blink LED1 on the board. */
	while (1) 
	{
		lcdSetCrsr(0,16);
		lcdPrint(IntToStr(tu,2,F_HEX)); lcdPrintln(" Up");
		lcdPrint(IntToStr(td,2,F_HEX)); lcdPrintln(" Down");
		lcdPrint(IntToStr(tl,2,F_HEX)); lcdPrintln(" Left");
		lcdPrint(IntToStr(tr,2,F_HEX)); lcdPrintln(" Right");
		lcdPrint(IntToStr(tm,2,F_HEX)); lcdPrintln(" Enter");
		lcdDisplay(); 
		switch(getInput()){
			case BTN_UP:
				tu=1-tu;
				if (tu){
				}else{
				};
				break;
			case BTN_DOWN:
				td=1-td;
				if (td){
				}else{
				};
				break;
			case BTN_LEFT:
				tl=1-tl;
				if (tl){
				}else{
				};
				break;
			case BTN_RIGHT:
				tr=1-tr;
				if (tr){
				}else{
				};
				break;
			case BTN_ENTER:
				tm=1-tm;
				if (tm){
				}else{
				};
				break;
		};

		led=1-led;
		if (led){
			gpio_set(LED1_GPORT, LED1_GPIN); /* LED on */
		}else{
			gpio_clear(LED1_GPORT, LED1_GPIN); /* LED off */
//			delayNop(200000);
		};

		ctr++;
		lcdNl();
		lcdPrint(IntToStrX(ctr,4));
	}

	return 0;
}
Exemple #3
0
void ram(void)
{
    int inpt,dirc,c,grows = 0,dx,dy,points,point_s=1;
    size_t n = 0, snake_size = 5, speed=MIN_SPEED;
    struct elem snake[MAX_SNAKE_LEN], food;
	char test[512]; /* scratch space */
  o_init (test, sizeof(test));

  reset(snake,&snake_size,&dirc,&speed,&points,&point_s);

  food = rnd();

    while (1)
    {
        head:
        if(!(++c % speed))
           {


inpt = getInputRaw();

dx=DoString(0,0,IntToStrX(points,2));
    dx=(SIZE_X-dx)/2;
    if(dx<0)
        dx=0;
    dy=(SIZE_Y-getFontHeight())/2;

         lcdFill(255);
      o_rectangle(1,0,SIZE_X-2,SIZE_Y-2);
      o_set_gray (0);
         o_fill ();

        //o_identity (); /* reset tranforms */

      o_set_gray (50);

      setExtFont("UBUNTU29");

    lcdSetPixel(1,1,1);
    DoString(dx,dy,IntToStrX(points,2));

      o_set_gray (255);


    for(n=0;n<snake_size;++n)
    {
        o_rectangle
(snake[n].x*SNAKE_DEM,snake[n].y*SNAKE_DEM,SNAKE_DEM,SNAKE_DEM); /*
fill background with black */
      o_fill ();     /* fill with 50% {
                       reset(snake,&snake_size);
                       goto head;
                   }gray */
    }
    o_rectangle
(food.x*SNAKE_DEM,food.y*SNAKE_DEM,SNAKE_DEM,SNAKE_DEM); /* fill
background with black */
      o_fill ();


      lcdDisplay();

        if (inpt == BTN_UP && dirc != 1)
            {
              dirc = 3;
            }
          else if (inpt == BTN_DOWN && dirc != 3)
            {
              dirc = 1;
            }
          else if (inpt == BTN_LEFT && dirc != 0)
            {
              dirc = 2;
            }
          else if (inpt == BTN_RIGHT && dirc !=2)
            {
              dirc = 0;
            }
//

               struct elem t = snake[snake_size-1];

               if(dirc == 0)
                ++t.x;
               else if(dirc == 1)
                ++t.y;
                else if(dirc == 2)
                --t.x;
               else if(dirc == 3)
                --t.y;

               if(t.x < 0 || t.y < 0 || t.y > SIZE_Y/SNAKE_DEM-1 ||
t.x > SIZE_X/SNAKE_DEM)
               {
                       reset(snake,&snake_size,&dirc,&speed,&points,&point_s);
                       goto head;
                   }

               for(n=0;n<snake_size-1;++n)
               {
                   if(snake[n].x == t.x && snake[n].y == t.y)
                   {
                       reset(snake,&snake_size,&dirc,&speed,&points,&point_s);
                       goto head;
                   }
                   else if(snake[n].x == food.x && snake[n].y == food.y)
                   {
                       grows = 1;
                       ++snake_size;
                       ++points;
                       if(speed > MAX_SPEED) --speed;
                        food = rnd();
                   }
               }

                if(!grows)
                {
               for(n=0;n<snake_size-1;++n)
               {
                   snake[n] = snake[n+1];
               }
                }
                else
                    grows = 0;

               snake[snake_size-1] = t;
           }
           else
               delayms(3);


           }



    }