Ejemplo n.º 1
0
void print_score(void) 
{
  lcdPrint("    ");
  lcdPrint(IntToStr(player1.score,3,F_LONG));
  lcdPrint("    ");
  lcdPrint(IntToStr(player2.score,3,F_LONG));
}
Ejemplo n.º 2
0
void prettyPrintSize(int size)
{
	unsigned char sizeUnit = 0;
	int decimalPlace = 0;
	static const char *unit[] = {
		"Byte",
		"KiB",
		"MiB",
		"GiB"
	};

	while(size > 1024) {
		decimalPlace = size % 1024;
		size /= 1024;
		sizeUnit++;
	}

	lcdPrint(IntToStr(size,3,F_LONG));
	if(sizeUnit > 0)
	{
		lcdPrint(".");
		lcdPrint(IntToStr(decimalPlace,3,F_LONG | F_ZEROS));
	}
	lcdPrint(" ");
	lcdPrint(unit[sizeUnit]);
}
Ejemplo n.º 3
0
static bool screen_intro() {
	uint32_t highscore;
	char highnick[20];
	char key=0;
	bool step = false;
	//getInputWaitRelease();
	while(key==0) {
		getInputWaitRelease();
		lcdFill(0x00);
		setIntFont(&Font_Invaders);
    setTextColor(0x00,0b11100000);
    lcdSetCrsr(28+18,25+15);lcdPrint(step?"ABC":"abc");
		setIntFont(&Font_7x8);
    setTextColor(0x00,0b00011000);
		lcdSetCrsr(28+18,40+15);lcdPrint("SPACE");
    setTextColor(0x00,0b11111000);
		lcdSetCrsr(18+18,50+15);lcdPrint("INVADERS");

		highscore = highscore_get(highnick);
    setTextColor(0x00,0xff);
		lcdSetCrsr(0,0);lcdPrint(IntToStr(highscore,6,F_LONG));
//		lcdSetCrsr(0,9);lcdPrint(highnick);
		lcdDisplay();
		step = !step;
		key=getInputWaitTimeout(1000);
	}
	//getInputWaitRelease();
	return !(key==BTN_LEFT);
}
Ejemplo n.º 4
0
void gnrTIrqHandler()
{
	if(greenDirection==0) objectMoveLeft(&flier);
	else objectMoveRight(&flier);
	if(flier.y==10) greenDirection=1;
	else if(flier.y== (310-flier.width) && greenDirection!=0) greenDirection=0;
	
	if(detectCollision(&brick, &flier)){
		greenCounter++;
		wait(500000);
		lcdFillWindow(brick.x, brick.x+brick.width - 1, brick.y, brick.y + brick.width - 1, BACKGROUND_COLOUR);
		objectDraw(&brick, 50, 152);
	}
	if(greenCounter>=5 || redCounter >= 5){
		lcdSetFontColour(63, 0, 0);
		if(greenCounter>=redCounter){
			lcdPrint(112, 96, "SEHR GUT");
			lcdFillWindow(10, 26, 106, 122, BACKGROUND_COLOUR);
			lcdSetFontColour(BRICK_COLOUR);
			if(flier.width >= 11){
				flier.width-=10;
				level++;
			}
			lcdDrawChar(10, 106, (char)(level+48));
		}
		else
			lcdPrint(112, 56, "SEHR SCHLECHT");
		wait(3000000);
		lcdFillWindow(112, 128, 56, 264, BACKGROUND_COLOUR);
		redCounter = 0;
		greenCounter = 0;
	}
	
	return;
}
Ejemplo n.º 5
0
//# MENU cpld
void cpld_flash() {
    SETUPgout(EN_1V8);
    ON(EN_1V8);
    delay(1000000); /* wait until cpld boot */
    cpu_clock_set(204);

    lcdPrintln("Program CPLD");
    bytes=0;
    lcdPrint(IntToStr(bytes,5,F_LONG));
    lcdPrint(" bytes...");
    lcdNl();

#define WAIT_LOOP_DELAY (6000000)
#define ALL_LEDS  (PIN_LED1|PIN_LED2|PIN_LED3)
    int i;
    int error;

    refill_cpld_buffer_fs();

    error = cpld_jtag_program(sizeof(cpld_xsvf_buffer),
                              cpld_xsvf_buffer,
                              refill_cpld_buffer_fs);
    if(error) {
        lcdPrintln("Programming failed!");
        lcdPrintln(IntToStr(error,5,0));
        lcdDisplay();
        /* LED3 (Red) steady on error */
        ON(LED4);
        while (1);
    };

    lcdPrintln("Success.");
    lcdDisplay();
    OFF(EN_1V8);
};
Ejemplo n.º 6
0
//# MENU cpld
void cpld_menu(){
	getInputWaitRelease();
	SETUPgout(EN_1V8);
	ON(EN_1V8);
	delayNop(1000000); /* wait until cpld boot */
	cpu_clock_set(204);

	lcdClear();
	lcdPrintln("CPLD");
	lcdNl();
	lcdNl();
	bytes=0;
	lcdPrint(IntToStr(bytes,5,F_LONG));
	lcdPrint(" bytes...");
	lcdNl();

	#define WAIT_LOOP_DELAY (6000000)
	#define ALL_LEDS  (PIN_LED1|PIN_LED2|PIN_LED3)
	int i;
	int error;
	FRESULT res;

	res=f_open(&file, "cpld.xsv", FA_OPEN_EXISTING|FA_READ);
	if(res!=FR_OK){
	    lcdPrintln("FOPEN ERROR");
	    lcdPrintln(f_get_rc_string(res));
	    lcdDisplay();
	    getInputWait();
	    return;
	};
	refill_cpld_buffer_fs();

	error = cpld_jtag_program(sizeof(cpld_xsvf_buffer),
				  cpld_xsvf_buffer,
				  refill_cpld_buffer_fs);
	if(error){
	    lcdPrintln("Programming failed!");
	    lcdPrintln(IntToStr(error,5,0));
	    lcdDisplay();
	    /* LED3 (Red) steady on error */
	    ON(LED3);
	    while (1);
	};


	lcdPrintln("Success.");
	lcdDisplay();

	for (res=0;res<10;res++){
	    /* blink LED1, LED2, and LED3 on success */
	    TOGGLE(LED1);
	    TOGGLE(LED2);
	    TOGGLE(LED3);
	    for (i = 0; i < WAIT_LOOP_DELAY; i++)  /* Wait a bit. */
		__asm__("nop");
	};
	/* XXX: Maybe power toggle needed to start CPLD? */
	OFF(EN_1V8);
};
Ejemplo n.º 7
0
static void refill_cpld_buffer_fs(void) {
    memcpy(cpld_xsvf_buffer,default_xsvf+bytes,BLOCK);

    lcdMoveCrsr(0,-8);
    bytes+=BLOCK;
    lcdPrint(IntToStr(bytes,5,F_LONG)); lcdPrint(" bytes..."); lcdNl();
    lcdDisplay();
}
Ejemplo n.º 8
0
void board_menu_draw(board_t* b)
{
  setTextColor(0, 0xff);
  setIntFont(&Font_7x8);

  const int lineh = getFontHeight();

  lcdSetCrsr(0, 0);
  lcdPrintln("0xb number game");
  lcdPrintln("Push < > ^ v");
  lcdPrintln("Add same blocks");
  lcdPrint("Try to reach '");
  setTextColor(colors[N_COLORS-1].bg, colors[N_COLORS-1].fg);
  lcdPrint("b");
  setTextColor(0, 0xff);
  lcdPrintln("'!");
  lcdNl();

  for (uint i = 0; i < menu_N; i ++) {
    if (i == b->menu_item)
      lcdPrint(">> ");
    else
      lcdPrint("   ");
    lcdPrint(menu_str[i]);

    switch (i) {
      case 3:
        // width
        lcdPrint(" = ");
        lcdPrint(IntToStr(b->w, 2, 0));
        break;
      case 4:
        // height
        lcdPrint(" = ");
        lcdPrint(IntToStr(b->h, 2, 0));
      default:
        break;
    }
    lcdNl();
  }

  if (b->menu_item == 2) {
    lcdPrintln(font_list[b->font]);
    if (b->font == FONT_NONE) {
      uint w = RESX / N_COLORS;
      for (uint8_t i = 0; i < N_COLORS; i++) {
        const color_t* col = colors + i;
        setTextColor(col->bg, col->fg);
        DoRect(i*w, 120, w, 10);
      }
    }
    else {
      setExtFont(font_list[b->font]);
      lcdPrint("789ab");
    }
  }
}
Ejemplo n.º 9
0
static void screen_level() {
	lcdFill(0x00);
	draw_score();
	setIntFont(&Font_7x8);
	lcdSetCrsr(20,32);
  setTextColor(0x00,0xff);
	lcdPrint("Level ");
	lcdPrint(IntToStr(game.level,3,0));
	lcdDisplay();
	delayms_queue(500);
}
Ejemplo n.º 10
0
void printNames(char (*usernames)[16], uint8_t * strength, uint8_t count) {
  int i;
  lcdPrintln("Track it:");
  lcdPrintln("-------------------");
  lcdPrintln(IntToStr(count,5,0));
  for(i=0; i<count; ++i) {
    lcdPrint(usernames[i]);
    lcdPrint(" strength ");
    lcdPrintln(IntToStr(strength[i],5,0));
  }
  lcdRefresh();
}
Ejemplo n.º 11
0
//# MENU Apack
void ppack_menu() {
	lcdClear();
	lcdPrintln("PPack port");
	lcdPrintln("");
	lcdPrintln("up=enable");
	lcdDisplay();
	dac_init(false);

	cpu_clock_set(204); // WARP SPEED! :-)
	hackrf_clock_init();
	rf_path_pin_setup();
	/* Configure external clock in */
	scu_pinmux(SCU_PINMUX_GP_CLKIN, SCU_CLK_IN | SCU_CONF_FUNCTION1);

	sgpio_configure_pin_functions();

	ON(EN_VDD);
	ON(EN_1V8);
	OFF(MIC_AMP_DIS);
	complex_s8_t * samples;

	while(1){
		switch(getInputRaw()){
			case BTN_UP:
			    // ON(MIXER_EN); // hackrf does this
			    cpu_clock_set(204); // WARP SPEED! :-)
			    si5351_init();
			    portapack_init();
			    getInputWaitRelease();

			    break;
			case BTN_DOWN:
			    lcdPrintln("file");
			    writeFile("samples.8", (char*)0x20000000,(uintptr_t)s8ram-0x20000000);
			    break;
			case BTN_LEFT:
			    lcdPrintln("reset");
			    s8ram=(complex_s8_t*)0x20000000;
			    break;
			case BTN_RIGHT:
				break;
			case BTN_ENTER:
				return;
		};
		TOGGLE(LED2);
		delayms(40);
		lcdPrint(IntToStr((uintptr_t)s8ram,8,F_HEX));
		lcdPrint(" ");
		lcdPrintln(IntToStr(sctr,7,F_LONG));
		lcdDisplay();
	};
};
Ejemplo n.º 12
0
static uint8_t mainloop() {
	uint32_t ioconbak = IOCON_PIO1_11;

	uint32_t volatile oldCount=IntCtr;
	uint32_t perMin=0; // counts in last 60 s
	uint32_t startTime=_timectr;
	uint8_t button;
		IOCON_PIO1_11 = 0;
		while (1) {
			//GPIO_GPIO0DATA&=~(1<<11);
			IOCON_PIO1_11 = ioconbak;
			GPIO_GPIO1DATA &= ~(1 << 7);
			GPIO_GPIO1DATA &= ~(1 << 11);
			lcdClear();

			lcdPrintln("   Geiger");
			lcdPrintln("   Counter");
			// ####
			for (int i=0; i< (14*( _timectr-startTime))/(60*100);i++) {
				lcdPrint("#");
			}

			lcdPrintln("");
			lcdPrintln("Counts:");
			lcdPrint(" ");
			lcdPrintInt(IntCtr);
			lcdPrintln(" total");
			lcdPrint(" ");
			lcdPrintInt(  perMin);
			lcdPrintln("/min");
			// remember: We have a 10ms Timer counter
			if ((startTime+60 *100 ) < _timectr) {
				// dumb algo: Just use last 60 seconds count
				perMin=IntCtr-oldCount;
				startTime=_timectr;
				oldCount=IntCtr;
			}
			lcdRefresh();
			delayms(42);
			button = getInputRaw();

			if (button != BTN_NONE) {
				delayms(23);// debounce and wait till user release button
				while (getInputRaw()!=BTN_NONE) delayms(23);
				break;
			}
		}
		IOCON_PIO1_11 = ioconbak;
		return button;

}
Ejemplo n.º 13
0
//# MENU led
void led_menu(){
	getInputWaitRelease();

	uint8_t leds=0;
	uint8_t adc=0;
	while(1){
		lcdClear();
		lcdPrintln("LED:");
		lcdPrintln("");
		lcdPrintln("U Toggle LEDs");
		lcdPrintln("D Toggle ADC");
		lcdPrintln("");
		lcdDisplay();
		switch(getInput()){
			case BTN_UP:
				adc=0;
				leds=1-leds;
				SETUPgout(LED4);
				if(leds){
					ON(LED1);
					ON(LED2);
					ON(LED3);
					ON(LED4);
				}else{
					OFF(LED1);
					OFF(LED2);
					OFF(LED3);
					OFF(LED4);
				};
				break;
			case BTN_DOWN:
				adc=1;
				SETUPadc(LED4);
				break;
			case BTN_ENTER:
				SETUPgout(LED1);
				SETUPgout(LED2);
				SETUPgout(LED3);
				SETUPgout(LED4);
				return;
		};
		if(adc){
			lcdPrint("LED4: ");
			lcdPrint(IntToStr(adc_get_single(ADC0,ADC_CR_CH6)*2*330/1023,4,F_LONG));
			lcdNl();
			lcdDisplay();
		};
		getInputWaitRelease();
	};
};
Ejemplo n.º 14
0
static void refill_cpld_buffer_fs(void) {
    FRESULT res;
    UINT readbytes;

    res=f_read(&file, cpld_xsvf_buffer, BLOCK, &readbytes); 
    lcdMoveCrsr(0,-8);
    bytes+=readbytes;
    lcdPrint(IntToStr(bytes,5,F_LONG));
    lcdPrint(" bytes...");
    if (res!=FR_OK){
	    lcdPrintln(f_get_rc_string(res));
    };
    lcdNl();
    lcdDisplay();
}
Ejemplo n.º 15
0
void InputLine::cursorBlinker(){
	if(cursorWait < 0){
		if(cursorActive){
			lcdPrint('_');
			cursorActive = false;
		  		
		} else {
			lcdPrint(inputLine[cursorPoint]);
			cursorActive = true;		
		}
		cursorWait = CURSORBLINKRATE;
	} else {
		cursorWait--;
	}
}
Ejemplo n.º 16
0
void bootFile(const char * filename){
	FIL file;
	UINT readbytes;
	FRESULT res;

	res=f_open(&file, filename, FA_OPEN_EXISTING|FA_READ);
	if(res!=F_OK){
		lcdPrintln("FOPEN ERROR");
		lcdPrintln(f_get_rc_string(res));
		lcdDisplay();
		getInputWait();
		return;
	};
	uint8_t *destination=&_app_start;
#define BLOCK 1024 * 128
	do {
		res=f_read(&file, destination, BLOCK, &readbytes); 
		destination+=readbytes;
	}while(res==F_OK && readbytes==BLOCK);

	lcdDisplay();
	if(res!=F_OK){
		lcdPrint("Read Error:");
		lcdPrintln(f_get_rc_string(res));
		lcdDisplay();
		getInputWait();
		return;
	};

	systick_interrupt_disable(); /* TODO: maybe disable all interrupts? */
	boot((void*)&_app_start);
};
Ejemplo n.º 17
0
//-----------------------------------------------------------------
// Menu engine
//-----------------------------------------------------------------
void uiDrawEditor(void)
{
    char buffer[LCD_NUM_CHARS];
    memset(buffer, 0, LCD_NUM_CHARS);
    sprintf(buffer,"> %03d  <", editorValue);
    lcdPrint(buffer, 1);
}
Ejemplo n.º 18
0
//-----------------------------------------------------------------
// Version Screen
//-----------------------------------------------------------------
void uiDrawVersionScreen(void)
{
    char buffer[LCD_NUM_CHARS];
    memset(buffer, 0, LCD_NUM_CHARS);
    snprintf(buffer, LCD_NUM_CHARS, "Version  %d.%d    ", MAJOR_VERSION, MINOR_VERSION);
    lcdPrint(buffer, 0);
}
Ejemplo n.º 19
0
void ram(void) {

	lcdClear();
	lcdPrintln("");
	lcdPrintln("");
	lcdPrintln("    BRICKS");
	lcdPrintln("");
	lcdPrintln("");
	lcdPrintln("");
	lcdPrintln("   by briks");
	lcdDisplay();
	delayms(1000);

	int pause = PAUSE_INITIAL;
	for (int i = 1; true; i++) {
		lcdClear();
		lcdPrintln("");
		lcdPrintln("");
		lcdPrintln("");
		lcdPrintln("    Level");
		lcdPrintln("");
		lcdPrint("      ");
		lcdPrintln(IntToStr(i, 2, 0));
		lcdDisplay();
		delayms(1000);
		if (playLevel(i % LEVELS, pause) == 0) {
			return;
		}
		pause = pause - (pause / 4); // shorten pause (increases speed)
	}
}
Ejemplo n.º 20
0
Archivo: spam.c Proyecto: astro/lun1k
void ram() {
    lcdClear();

    lcdPrintln("SPAM:");
    while(getInputRaw() != BTN_LEFT) {
        char c[2] = {0, 0};
        c[0] = (char)getRandom();

        uint8_t pkt[32];
        MO_TYPE_set(pkt, c[0]);
        MO_GEN_set(pkt, 0xFF);
        if (c[0] >= 'A' && c[0] <= 'Z')
            MO_TIME_set(pkt, 1313803870);
        else if (c[0] >= 'a' && c[0] <= 'z')
            MO_TIME_set(pkt, getRandom() % 16777216);
        else
            MO_TIME_set(pkt, (uint32_t)getRandom());
        strcpy((char *)MO_BODY(pkt), "chaosbay.camp.ccc.de");

        if (!mesh_sanity(pkt)) {
            lcdPrint("Sending: ");
            lcdPrintln(c);
            lcdRefresh();

            MPKT *mpkt = meshGetMessage(c[0]);
            mpkt->flags = MF_USED;
            memcpy(mpkt->pkt, pkt, 32);
        }
    }
}
Ejemplo n.º 21
0
void greenAndRed(void){
	greenDirection = 1;
	interval = 2800;
	level = 0;
	extTIrqHandler = gnrTIrqHandler;
	extKIrqHandler = gnrKIrqHandler;
	lcdSetCursor(0,0);
	lcdPixelsDraw(240*320, BACKGROUND_COLOUR);
	lcdSetBackgroundColour(BACKGROUND_COLOUR);
	lcdSetFontColour(BRICK_COLOUR);
	lcdPrint(10,10, "LEVEL 0");
	objectDraw(&brick, 50, 152);
	objectDraw(&flier, 150, 10);
	greenCounter = 0;
	redCounter = 0;
	timerSetMatch(interval);

	while(1){
		
		irqDisableSec();
		lcdSetFontColour(BRICK_COLOUR);
		lcdDrawChar(10, 246, (char)(greenCounter+48));
		lcdSetFontColour(63, 0, 0);
		lcdDrawChar(10, 294, (char)(redCounter+48));
		irqEnableSec();
		waitCycles(0x6fffff);	
		lcdFillWindow(10, 26, 246, 310, BACKGROUND_COLOUR);
		waitCycles(0x6fffff);	
	}	


}
Ejemplo n.º 22
0
void uiDmxDrawScreen(void)
{
    char buffer[LCD_NUM_CHARS];
    memset(buffer, 0, LCD_NUM_CHARS);
    sprintf(buffer,"DMX Addr  %03d   ", dmxGetAddress()+1);
    lcdPrint(buffer, 0);
}
Ejemplo n.º 23
0
int saveConfig(void){
    FIL file;            /* File object */
    UINT writebytes;
    UINT allwrite=0;
    int res;
#if DEBUG
    lcdClear();
#endif

	res=f_open(&file, CONFFILE, FA_OPEN_ALWAYS|FA_WRITE);
#if DEBUG
	lcdPrint("create:");
	lcdPrintln(f_get_rc_string(res));
#endif
	if(res){
		return 1;
	};

    CONF_ITER{
        res = f_write(&file, &the_config[i].value, sizeof(uint8_t), &writebytes);
        allwrite+=writebytes;
        if(res){
#if DEBUG
            lcdPrint("write:");
            lcdPrintln(f_get_rc_string(res));
#endif
            return 1;
        };
    };
#if DEBUG
	lcdPrint("write:");
	lcdPrintln(f_get_rc_string(res));
	lcdPrint(" (");
	lcdPrintInt(allwrite);
	lcdPrintln("b)");
#endif

	res=f_close(&file);
#if DEBUG
	lcdPrint("close:");
	lcdPrintln(f_get_rc_string(res));
#endif
	if(res){
		return 1;
	};
	return 0;
}
Ejemplo n.º 24
0
int main(void)
{
    // PB0:2 as output
    DDRB |= 0x07;
    // startup lcd
    lcdInit();

    // Test output
    lcdPrint("  @shotbyjenn");
    lcdCmd(0xC0);
    lcdPrint("   Jenny Mack");

    while (1==1)
    {
        //
    }
}
Ejemplo n.º 25
0
Archivo: funk.c Proyecto: Bediko/r0ket
void f_send(void){
    uint8_t status;

    status = openbeaconSend();
    lcdPrint("Status:");
    lcdPrintCharHex(status);
    lcdNl();
};
Ejemplo n.º 26
0
/** 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;
};
Ejemplo n.º 27
0
//# MENU CDC
void cdc_menu(){
    uint32_t prompt = 0, rdCnt = 0;
    static uint8_t g_rxBuff[256];
    CDCenable();
    lcdPrintln("CDC enabled.");
    lcdDisplay();
    getInputWaitRelease();

    while(getInputRaw()!=BTN_ENTER){
	if(getInputRaw()==BTN_RIGHT){
	    lcdPrint("status:");
	    lcdPrint(IntToStr(g_vCOM.tx_flags,3,F_HEX));
	    lcdPrint(", ");
	    lcdPrint("c=");
	    lcdPrint(IntToStr(prompt,1,F_LONG));
	    lcdPrintln(".");
	    lcdDisplay();
	    getInputWaitRelease();
	};
	if(getInputRaw()==BTN_LEFT){
	    vcom_write((uint8_t *)"Hello World!\r\n", 14);
	    getInputWaitRelease();
	};
	if ((vcom_connected() != 0) && (prompt == 0)) {
	    prompt = 1;
	}
	/* If VCOM port is opened echo whatever we receive back to host. */
	if (prompt) {
	    rdCnt = vcom_bread(&g_rxBuff[0], 256);
	    if (rdCnt) {
		vcom_write((uint8_t*)"[", 1);
		while(g_vCOM.tx_flags & VCOM_TX_BUSY) __WFI(); // Wait for buffer emtpy
		vcom_write(&g_rxBuff[0], rdCnt);
		while(g_vCOM.tx_flags & VCOM_TX_BUSY) __WFI(); // Wait for buffer emtpy
		vcom_write((uint8_t*)"]", 1);
	    }
	}
	/* Sleep until next IRQ happens */
	__WFI();
    };
    lcdPrintln("disconnect");
    lcdDisplay();
    CDCdisable();
    getInputWaitRelease();
}
Ejemplo n.º 28
0
static void intinDraw() {
  lcdClear();
	lcdPrint(s_int.prompt);
	for (int dx = 0; dx< s_int.digits; dx++){
		DoChar(dx*CHARWIDTH,20,IntToStr(s_int.the_number,s_int.digits,F_LONG|F_ZEROS)[dx]);
	}
  DoChar(s_int.pos * CHARWIDTH, 30, '^');

}
Ejemplo n.º 29
0
uint8_t check_end(void){
	if(player1.score >= MAX_POINTS || player2.score >= MAX_POINTS){
		receive = 0;
		lcdClear();
		lcdNl();
		lcdPrintln("  GAME OVER");
		lcdNl();
		lcdPrint(" Player ");
		lcdPrint(IntToStr(2 - (player1.score > player2.score),1,0));
		lcdPrintln(" won");

		lcdRefresh();

		return 1;
	}

	return 0;
}
Ejemplo n.º 30
0
void pacmanGame()
{
	lcdSetBackgroundColour(BACKGROUND_COLOUR);
	lcdSetFontColour(FOREGROUND_COLOUR);
	lcdSetCursor(0, 0);
	lcdPixelsDraw(240 * 320, BACKGROUND_COLOUR);
	lcdPrint(10, 10, "PACMAN");
	wait(1000000);
	lcdPrint(50, 10, "MOVE WITH 2,4,5,6");
	wait(1000000);
	lcdPrint(76, 10, "PRESS A TO START");
	while (kBuffer != 3)
		continue;
	kBuffer = 16;
	lcdFillWindow(0, 239, 0, 319, BACKGROUND_COLOUR);
	lcdPrint(112, 80, "LEVEL 1");
	wait(1000000);
	pacman::lifes = 3;
	while (1) {
		if (level1()) {
			pacman::lifes = 3;
			pacman::score = 0;
			continue;
		}
		if (level2()) {
			pacman::lifes = 3;
			pacman::score = 0;
			continue;
		}

		if (level3()) {
			pacman::lifes = 3;
			pacman::score = 0;
			continue;
		}

		if (level4()) {
			pacman::lifes = 3;
			pacman::score = 0;
			continue;
		}
	}

}