Esempio n. 1
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);
}
Esempio n. 2
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");
    }
  }
}
Esempio n. 3
0
static bool screen_gameover() {
	char key =0;
	while(key==0) {
		lcdFill(0x00);
		setIntFont(&Font_7x8);
    setTextColor(0x00,0b11100000);
		lcdSetCrsr(14+15,32+15);lcdPrint("GAME OVER");
    setTextColor(0x00,0xff);
		lcdSetCrsr(0,0);lcdPrint(IntToStr(game.score,6,F_LONG));
		if (highscore_set(game.score, GLOBAL(nickname))){
      setTextColor(0x00,0b00011000);
      lcdSetCrsr(0,9);lcdPrint("HIGHSCORE!");
		};
		lcdDisplay();
		key=getInputWaitTimeout(5000);
	}
	//getInputWaitRelease();
	return !(key==BTN_LEFT);
}
Esempio n. 4
0
void processText(struct text *t)
{

    if( t->flags & FLAGS_CLS )
       lcdClear() ;
    lcdSetCrsr(t->x, t->y);
    t->text[16] = 0;
    lcdPrint(t->text);
    lcdRefresh();
}
Esempio n. 5
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);
}
Esempio n. 6
0
void drawCommonThings(int charging) {
    lcdClear();
    lcdNl();
    lcdPrintln("  Battery status");

    // Draw battery frame.
    drawHLine(63,  14, 112,  0b00000011);
    drawHLine(93,  14, 112,  0b00000011);
    drawVLine(14,  63,  93,  0b00000011);
    drawVLine(112, 63,  73,  0b00000011);
    drawVLine(112, 83,  93,  0b00000011);
    drawHLine(73,  112, 116, 0b00000011);
    drawHLine(83,  112, 116, 0b00000011);
    drawVLine(116, 73,  83,  0b00000011);

    // Print if not charging.
    lcdSetCrsr(0, 40);
    if(!charging){
        lcdPrintln("  (not charging)");
    };
    lcdSetCrsr(0, 30);
}
Esempio n. 7
0
void spectrum_callback(uint8_t* buf, int bufLen)
{
	TOGGLE(LED2);
	if (displayMode == MODE_SPECTRUM)
		lcdClear();
	else if (displayMode == MODE_WATERFALL)
		lcdShift(0,1,0);

	for(int i = 0; i < 128; i++) // display 128 FFT magnitude points
	{
		// FFT unwrap:
		uint8_t v;
		if(i < 64) // negative frequencies
			v = buf[(bufLen/2)+64+i];
		else // positive frequencies
			v = buf[i-64];

		// fill display
		if (displayMode == MODE_SPECTRUM)
		{
			for(int j = 0; j < (v/2); j++)
				lcdBuffer[i+RESX*(RESY-j)] = 0x00;
		}
		else if (displayMode == MODE_WATERFALL)
		{
			lcdSetPixel(i,RESY-1,v);
		}
	}

	// text info
	lcdSetCrsr(0,0);
	lcdPrint("f=");
	lcdPrint(IntToStr(freq/1000000,4,F_LONG));
	lcdPrintln("MHz                ");
	lcdPrintln("-5MHz    0    +5MHz");
	lcdDisplay();
}
Esempio n. 8
0
//# MENU antenna
void antenna_main()
{
	frequency=(int64_t)input_int("Frequency:",(int)(frequency/1000000),50,4000,4)*1000000;

	lcdClear();
	lcdSetCrsr(0,0);
	lcdPrintln("Antenna Frequency");

	lcdNl();
	lcdPrint(" ");
	lcdPrint(IntToStr(frequency/1000000,4,F_LONG));
	lcdPrintln(" MHz ");

	lcdNl();
	lcdPrintln("Antenna Length");

	float meter = SPEEDOFLIGHT/frequency;

	lcdNl();
	lcdPrint(" ");
	lcdPrint(IntToStr(meter * 1000, 4, F_LONG ));
	lcdPrint(" mm");
	lcdNl();
	lcdPrint(" ");
	lcdPrint(IntToStr(meter * 1000 / 2, 4, F_LONG ));
	lcdPrint(" mm");
	lcdNl();
	lcdPrint(" ");
	lcdPrint(IntToStr(meter * 1000 / 4, 4, F_LONG ));
	lcdPrint(" mm");

	lcdDisplay();

	getInputWaitRepeat();

}
Esempio n. 9
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;
}
Esempio n. 10
0
void ram(void){
    getInputWaitRelease();

    uint8_t old_state=-1;
    uint8_t charging_count=0;

    while(1){
        uint32_t mv = batteryGetVoltage();

        if (batteryCharging()) {
            if(!(charging_count % 50)){
                drawCommonThings(true);
                lcdPrintln("   Charging ...");

                if(charging_count>=50)  drawRectFill(16, 65, 22, 26, 0b11100000);
                if(charging_count>=100) drawRectFill(40, 65, 22, 26, 0b11110000);
                if(charging_count>=150) drawRectFill(64, 65, 22, 26, 0b10011100);
                if(charging_count>=200) drawRectFill(88, 65, 22, 26, 0b00011100);
                old_state = 0;
            }

            if(++charging_count > 250) charging_count=0;
            delayms(5);
        } else if (mv<3550 && old_state != 1){
            drawCommonThings(false);
            lcdPrintln("    Charge NOW!");
            drawRectFill(16, 65, 5, 26, 0b11100000);
            old_state = 1;
        }else if (mv<3650 && mv>=3550 && old_state != 2){
            drawCommonThings(false);
            lcdPrintln("    Charge soon");
            drawRectFill(16, 65, 22, 26, 0b11100000);
            old_state = 2;
        }else if (mv<4000 && mv>=3650 && old_state != 3){
            drawCommonThings(false);
            lcdPrintln("        OK");
            drawRectFill(16, 65, 22, 26, 0b11100000);
            drawRectFill(40, 65, 22, 26, 0b11110000);
            old_state = 3;
        }else if (mv<4120 && mv>=4000 && old_state != 4){
            drawCommonThings(false);
            lcdPrintln("       Good");
            drawRectFill(16, 65, 22, 26, 0b11100000);
            drawRectFill(40, 65, 22, 26, 0b11110000);
            drawRectFill(64, 65, 22, 26, 0b10011100);
            old_state = 4;
        }else if (mv>=4120 && old_state != 5) {
            drawCommonThings(false);
            lcdPrintln("       Full");
            drawRectFill(16, 65, 22, 26, 0b11100000);
            drawRectFill(40, 65, 22, 26, 0b11110000);
            drawRectFill(64, 65, 22, 26, 0b10011100);
            drawRectFill(88, 65, 22, 26, 0b00011100);
            old_state = 5;
        }

        // print voltage
        lcdSetCrsr(0, 100);
        uint8_t v = mv/1000;
        lcdPrint("      ");
        lcdPrint(IntToStr(v,2,0));
        lcdPrint(".");
        lcdPrint(IntToStr(mv%1000, 3, F_ZEROS | F_LONG));
        lcdPrintln("V");

        lcdDisplay();

        switch(getInput()){
            case BTN_LEFT:
                return;
            case BTN_ENTER:
                return;
        };
    };
}
Esempio n. 11
0
void ram() {

	int raw_key, key;
	int i, j;
	int score, lastlvl, linec;

	new_stone();
	new_stone();

	// epmty grid
	for(i = 0; i < GRID_HEIGHT; i++)
		for(j = 0; j < GRID_WIDTH; j++)
			grid[i][j] = 0;
	
	// prepare screen
	lcdClear();
	for(i = 0; i < 96; i++) {
		lcdSetPixel(i, 2, 1);
		lcdSetPixel(i, 65, 1);
	}
	for(i = 3; i < 65; i++) {
		lcdSetPixel(2, i, 1);
		lcdSetPixel(35, i, 1);
		lcdSetPixel(93, i, 1);
	}

	score = 0;
	lastlvl=0;
	linec = 0;

	lcdSetCrsr(37,25);
	lcdPrint("level: 0");

	lcdSetCrsr(37,40);
	lcdPrint("score:");
	lcdSetCrsr(37,50);
	lcdPrintInt(0);
	
	for(;;) {

		// handle input
		raw_key = getInputRaw();
		key = 0;
		for(i = 0; i < 5; i++) {
			if(raw_key & (1 << i)) {
				if(!key_rep[i] || key_rep[i] == KEY_REPEAT_DELEAY) key |= 1 << i;
				key_rep[i] += key_rep[i] < KEY_REPEAT_DELEAY;
			}
			else key_rep[i] = 0;
		}


		// rotate
		if(key & BTN_UP) {
			i = rot;
			rot = (rot << 1) % 15;
			if(collision(0)) rot = i;
		}

		// horizontal movement
		i = x_pos;
		x_pos += !!(key & BTN_RIGHT) - !!(key & BTN_LEFT);
		if(i != x_pos && collision(0)) x_pos = i;

		// vertical movement
		ticks++;
		if(key & BTN_DOWN || ticks >= ticks_per_drop) {
			ticks = 0;
			y_pos++;
			if(collision(0)) {
				y_pos--;

				// check for game over
				if(collision(1)) return;

				// copy stone to grid
				int x, y;
				for(y = 0; y < 4; y++) {
					for(x = 0; x < 4; x++) {
						if(stones[stone][(x << 2) + y] & rot)
							grid[y + y_pos][x + x_pos] = 1;
					}
				}

				// check for complete lines
				for(y = 0; y < GRID_HEIGHT; y++) {
					for(x = 0; x < GRID_WIDTH; x++)
						if(!grid[y][x]) break;

					if(x == GRID_WIDTH) {

						lines++;
						linec++;	// temporary line counter
						ticks_per_drop = STARTING_SPEED - lines / 10;
						if(ticks_per_drop < 1) ticks_per_drop = 1;

						for(i = y; i > 0; i--)
							for(x = 0; x < GRID_WIDTH; x++)
								grid[i][x] = grid[i - 1][x];

						switch(linec){
							case 1:
								score += 40*(lines/10+1);
								break;
							case 2:
								score += 100*(lines/10+1);
								break;
							case 3:
								score += 300*(lines/10+1);
								break;
							case 4:
								score += 1200*(lines/10+1);
								break;
						} 
					}
				}

				if (lines/10>lastlvl){
					lcdSetCrsr(37,25);
					lcdPrint("level: ");
					lcdPrintInt(lines/10);
				}
				if (linec > 0){
					lcdSetCrsr(37,40);
					lcdPrint("score:");
					lcdSetCrsr(37,50);
					lcdPrintInt(score);
				}
				
				lastlvl=lines/10;
				linec = 0;
				
				// get a new stone
				new_stone();
			}
		}

		draw_grid();
        lcdDisplay();
		delayms(TICK_LENGTH);
	}
	return;
}
Esempio n. 12
0
File: select.c Progetto: derf/r0ket
int selectFile(char *filename, char *extension)
{
    int skip = 0;
    int selected = 0;
    char pwd[FLEN];
    memset(pwd, 0, FLEN);
    font=&Font_7x8;

	while(1) {
		int total;
		char files[PERPAGE][FLEN+2];
		int count = retrieve_files(files, PERPAGE, skip, extension, pwd, &total);
		if (selected >= count) {
			selected = count - 1;
		}

		/* optimization: don't reload filelist if only redraw needed */
		redraw:

		lcdClear();
		lcdPrint("[");
		lcdPrint(pwd);
		lcdPrintln("]");

		for (int i = 0; i < 98; i++) {
			lcdSetPixel(i, 9, 1);
		}

		lcdSetCrsr(0, 12);

		if (!count) {
			lcdPrintln("- empty");
		} else {
			for (int i = 0; i < count; i++) {
				if (selected == i) {
					lcdPrint("*");
				} else {
					lcdPrint(" ");
				}
				lcdSetCrsrX(14);

				lcdPrintln(files[i]);
			}
		}
		lcdRefresh();

		char key = getInputWaitRepeat();
		switch (key) {
		case BTN_DOWN:
			if (selected < count - 1) {
				selected++;
				goto redraw;
			} else {
				if (skip < total - PERPAGE) {
					skip++;
				} else {
					skip = 0;
					selected = 0;
					continue;
				}
			}
			break;
		case BTN_UP:
			if (selected > 0) {
				selected--;
				goto redraw;
			} else {
				if (skip > 0) {
					skip--;
				} else {
					skip = total - PERPAGE;
					if (skip < 0) {
						skip = 0;
					}
					selected = PERPAGE - 1;
					continue;
				}
			}
			break;
		case BTN_LEFT:
			if (pwd[0] == 0) {
				return -1;
			} else {
				pwd[0] = 0;
				continue;
			}
		case BTN_ENTER:
		case BTN_RIGHT:
			if (count) {
				if (files[selected][strlen(files[selected]) - 1] == '/') {
					/* directory selected */
					strcpy(pwd, files[selected]);
					continue;
				} else {
					strcpy(filename, pwd);
					strcpy(filename + strlen(pwd), files[selected]);
					getInputWaitRelease(); /* ?! */
					return 0;
				}
			}
		}
	}
}