Exemplo n.º 1
0
int UI::courseSelect(){
	int course = -1;

	display_goto_xy(4, 1);

	while(1){
		if(ecrobot_is_RUN_button_pressed()){
			course = course * (-1);

			if(course == 1){
				display_string(" IN COURSE");
				display_goto_xy(4, 1);
			}
			else{
				display_string("OUT COURSE");
				display_goto_xy(4, 1);
			}
		}		

		if(ecrobot_is_ENTER_button_pressed()){
			display_goto_xy(6, 3);
			display_string("READY");
			break;
		}
		
		display_update();
		
		// 500msecウェイトする
		systick_wait_ms(500); 	
	}

	display_update();

	return course;
}
Exemplo n.º 2
0
void TestIRSeeker(U8 port_id)
{
	S8 data[6];

	ecrobot_get_ir_seeker(port_id, data);

	display_goto_xy(0, 0);
	display_string("IR SEEKER TEST");

	display_goto_xy(0, 1);
	display_string("DIR: ");
	display_int(data[0], 0);

	display_goto_xy(0, 2);
	display_string("INT1/2: ");
	display_int(data[1], 0);
	display_int(data[2], 5);

	display_goto_xy(0, 3);
	display_string("INT3/4: ");
	display_int(data[3], 0);
	display_int(data[4], 5);

	display_goto_xy(0, 4);
	display_string("INT5: ");
	display_int(data[5], 0);
}
Exemplo n.º 3
0
/***********************************************************
* view pic
************************************************************/
void view_pic(fb_info fb_inf, char name[4][20])
{
	display_one("background/view.jpg",fb_inf);
    
	int size = 32 * fb_inf.w/1024;
	
	if(init_ft("font/type.ttf", size) != 0)
	{
		fprintf(stderr, "Error initial font\n");
		return;
	}

	int x = fb_inf.w/4 - size * 3/2;
	int y = fb_inf.h - 20 * fb_inf.h/768;

	display_string("上一页", x, y, fb_inf, COLOR);
	display_string("下一页", x + fb_inf.w/2, y, fb_inf, COLOR);

	int i;
   
	for(i = 0; i < 4; i++)
	{
		char path[128]="image/";
		strncat(path,name[i],strlen(name[i]) - 1);
		if(strstr(path,".jpg") != NULL)
			show(path, fb_inf, i);
	}  
	
}
Exemplo n.º 4
0
// Handles different menu selection
//
// leftRightIndex: index for determining menus
// upDownIndex, currDollars, currCents: needed for calling print_menu
void select_menu(int *leftRightIndex, int upDownIndex, int currDollars, int currCents) {
  if (*leftRightIndex == 0) {
      print_welcome();
  } else if (*leftRightIndex == 1) {
    print_menu(upDownIndex, currDollars, currCents);
  }
  else {
    clear_display();
    delay(1000); //1ms
    LED_toggle();
    display_string("Order Confirmed!");
    display_string("                        ");
    delay(1000000); //1sec
    display_string("Preparing Now...");
    delay(3000000); //3sec
    clear_display();
    delay(1000); //1ms
    display_string("Order Ready!");
    LED_toggle();
    delay(3000000); //3sec
    *leftRightIndex = 0;
    clear_display();
    delay(1000); //1ms
    print_welcome();
  }
}
Exemplo n.º 5
0
void TestCompassSensor(U8 port_id)
{
	display_goto_xy(0, 0);
	display_string("COMPASS TEST");

	display_goto_xy(0, 1);
	display_string("HEADING: ");
	display_int(ecrobot_get_compass_sensor(port_id), 0);
}
Exemplo n.º 6
0
Arquivo: main.c Projeto: mengpq/os
void display_byte_hex(u8 c){
	char output[2];
	u8 low=c&0xF,high=c>>4;
	memset(output,0,sizeof(output));
	if (high<=9) output[0]=high+'0'; else output[0]=high-10+'A';
	display_string(output);
	if (low<=9) output[0]=low+'0'; else output[0]=low-10+'A';
	display_string(output);
}
Exemplo n.º 7
0
int main(void) {
	/* Set up peripheral bus clock */
        /* OSCCONbits.PBDIV = 1; */
  /*OSCCONCLR = 0x100000; /* clear PBDIV bit 1 */
	OSCCONSET = 0x080000; /* set PBDIV bit 0 */

	/* Set up output pins */
	AD1PCFG = 0xFFFF;
	ODCE = 0x0;
	TRISECLR = 0xFF;
	PORTE = 0x0;

	/* Output pins for display signals */
	PORTF = 0xFFFF;
	PORTG = (1 << 9);
	ODCF = 0x0;
	ODCG = 0x0;
	TRISFCLR = 0x70;
	TRISGCLR = 0x200;

	/* Set up input pins */
	TRISDSET = (1 << 8);
	TRISFSET = (1 << 1);

	/* Set up SPI as master */
	SPI2CON = 0;
	SPI2BRG = 4;
	/* SPI2STAT bit SPIROV = 0; */
	SPI2STATCLR = 0x40;
	/* SPI2CON bit CKP = 1; */
        SPI2CONSET = 0x40;
	/* SPI2CON bit MSTEN = 1; */
	SPI2CONSET = 0x20;
	/* SPI2CON bit ON = 1; */
	SPI2CONSET = 0x8000;

	display_init();
	display_string(0, "Vi är så bra!!!");
	display_string(1, "Det löser sig!");
	display_string(2, ":)");
	display_string(3, "Kämpa!");
	display_update();

	display_image(96, icon);

	labinit(); /* Do any lab-specific initialization */

	while( 1 )
	{
	  labwork(); /* Do lab-specific things again and again */
	}
	return 0;
}
Exemplo n.º 8
0
void exit_game()
{
    IEC(0) = ~0xFFFF;
    display_string(0, "                ");
    display_string(1, "   Game Over    ");

    char str[16] = "  Score: ";
    char *scr = itoaconv(score);
    for(int i = 9; *scr; str[i] = *scr++, i++);
    display_string(2, str);

    display_update_text();
    for(;;);
}
Exemplo n.º 9
0
void draw(){
	if(testunit==0){
		display_string(2,title);
		display_string(3,author);
	}else if(testunit==1){
		display_string(1,string_line);
		draw_line(20+frame*4,20,40+frame*4,40);
		draw_line(40+frame*4,20,20+frame*4,40);
		draw_line(30+frame*4,20,30+frame*4,40);
		draw_line(20+frame*4,30,40+frame*4,30);
	}else if(testunit==2){
		display_string(1,string_box);
		draw_box(20,20,20,20,0);
		draw_box(30+frame*4,30,20,20,1);
	}else if(testunit==3){
		display_string(1,string_circle);
		draw_circle(30,30,10,0);
		draw_circle(40+frame*4,40,10,1);
	}else if(testunit==4){
		display_string(1,string_font1);
		display_string_58(0,15,test_string_l,0,1);
		display_string_58(0,24,test_string_l_2,0,1);
		display_string_58(0,33,test_string_s,0,1);
		display_string_58(0,42,test_string_s_2,0,1);
	}else if(testunit==5){
		display_string(1,string_font1);
		display_string_58(20+frame*2,20,test_string,90,1);
	}else if(testunit==6){
		display_string(1,string_font1);
		display_string_58(40+frame*2,30,test_string,180,1);
	}else if(testunit==7){
		display_string(1,string_font1);
		display_string_58(20+frame*2,40,test_string,270,1);
	}else if(testunit==8){
		display_string(2,finish);
	}
	if(frame==15){
		frame=0;
		if(testunit==8){
			;
		}else{
			testunit++;
		}
	}else{
		frame++;
	}
	delayms(100);
}
Exemplo n.º 10
0
/* This function is called repetitively from the main program */
void labwork( void )
{
  
  prime = nextprime ( prime );
  display_string ( 0, itoaconv( prime ));
  display_update();
}
Exemplo n.º 11
0
/* Interrupt Service Routine */
void user_isr( void )
{
	/*T2IF = IFS0 8
	T2IE = IEC0 8
	T2IP = IPC2 26-28
	T2IS = IPC2 24/25
	*/
	//if interrupt clear T2IF and timer counter
	if(IFS(0) & 0x100){
	IFSCLR(0) = 0x100;
	TMR2 = 0;
	if(timeoutcount < 9){
		timeoutcount++;
	}else{
		//print on screen once a second
		timeoutcount = 0;
		time2string(textstring, mytime);
		display_string(3, textstring);
		display_update();
		tick(&mytime);
		//*portE += 1;
		//display_image(96, icon);
	}
}

	if(IFS(0) & 0x8000){
		IFSCLR(0) = 0x8000;
		*portE += 1;
	}
}
Exemplo n.º 12
0
// draw the geometry marker in the given Displayable's drawing list
void GeometryBond::create_cmd_list() {
  char valbuf[32];

  // get the transformed positions, and draw a line between them
  float pos1[3], pos2[3];

  reset_disp_list();
  if(!transformed_atom_coord(0, pos1))
    return;
  if(!transformed_atom_coord(1, pos2))
    return;

  append(DMATERIALOFF);
  DispCmdColorIndex cmdColor;
  cmdColor.putdata(my_color, cmdList);

  DispCmdLineType cmdLineType;
  DispCmdLineWidth cmdLineWidth;
  cmdLineType.putdata(DASHEDLINE, cmdList);
  cmdLineWidth.putdata(4, cmdList);

  // print value of distance at midpoint
  midpoint(valuePos, pos1, pos2);
  // left-align the value so that it doesn't appear to shift its position
  // when the label text size changes.  Shift it to the right by a constant
  // amount so that it doesn't intersect the line.
  valuePos[0] += 0.05f;
  sprintf(valbuf, "%-7.2f", geomValue);
  display_string(valbuf, cmdList);

  // draw a line into the given Displayable
  display_line(pos1, pos2, cmdList);
  
}
/* Interrupt Service Routine */
void user_isr( void ) {

  // check flag
  if(IFS(0) & 0x100){
    // clearing flag
    IFS(0) = 0;
    timeoutcount++;

    if (timeoutcount == 10){
      time2string( textstring, mytime );
      display_string( 3, textstring );
      display_update();
      tick( &mytime );
      timeoutcount = 0;
    }
  }
    
  // code for counting LED
  if(IFS(0) & 0x80){
    // clearing flag
    IFS(0) = 0;
    // for LEDs ticking
    * portE =  * portE + 0x1;
    // only for the last 8 bits
    * E = * E & 0xFF00;
  }

  return;
}
Exemplo n.º 14
0
void display_params(){
	display_string(-0.9f, 0.9f, "reset: i");
	std::stringstream ss;
	ss.str("");
	ss << "1< >2 f: " << rd.get_f();
	display_string(-0.9f, 0.82f, ss.str());
	ss.str("");
	ss << "q< >w k: " << rd.get_k();
	display_string(-0.9f, 0.74f, ss.str());
	ss.str("");
	ss << "a< >s ru:" << rd.get_ru();
	display_string(-0.9f, 0.66f, ss.str());
	ss.str("");
	ss << "z< >x rv:" << rd.get_rv();
	display_string(-0.9f, 0.58f, ss.str());
}
Exemplo n.º 15
0
fprintf (int ign, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
	 int a8, int a9)
{
  char buffer[1024];
  sprintf (buffer, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  display_string (buffer);
}
Exemplo n.º 16
0
fputc (int c, int ign)
{
  char buf[2];
  buf[0] = c;
  buf[1] = 0;
  display_string (buf);
}
Exemplo n.º 17
0
/* main function */
int main(int argc, char *argv[]) 
{
	if (argc < 2)
		argv[1] = "test.jpg";

	fb_info fb_inf;
	if (init_fb(&fb_inf) < 0){
		fprintf(stderr, "Error initial framebuffer\n");
		return 1;
	}
	
	display_jpeg(argv[1], fb_inf);

	
#if 0 
	/* Test mouse */
	//test_mouse(fb_inf);

	if (init_ft("mao.ttf", 0) != 0){
		fprintf(stderr, "Error initial font\n")	;
		return 1;
	}
	
	display_string("显示文字", 432, 400, fb_inf, 0xFF0000);
#endif

	munmap(fb_inf.fbmem, fb_inf.w * fb_inf.h * fb_inf.bpp / 8);

	return 0;
}
Exemplo n.º 18
0
Arquivo: main.c Projeto: mengpq/os
int dump_mem(char *start, char *len){
	if (!is_hex(start) || !is_number(len)) return -1;
	int st=hextoi(start),ed=st+atoi(len),i,total;
	char output[2];
	total=0;
	memset(output,0,sizeof(output));
	for (i=st; i<ed; i++){
		u8 temp=read_mem_byte(i);
		display_byte_hex(temp); 
		++total;
		if (total%8==0 && total%16!=0) display_string("-"); else display_string(" ");
		if ((total)%16==0) display_string("\n");
	}
	if (total%16!=0) display_string("\n");
	return 0;
}
Exemplo n.º 19
0
static int display_address(tvbuff_t *tvb, int offset, proto_tree *tree) {

/* decode and display the v5 address, return offset of next byte */

	int a_type = tvb_get_guint8(tvb, offset);

	proto_tree_add_text( tree, tvb, offset, 1,
			"Address Type: %d (%s)", a_type,
			address_type_table[ MIN( (guint) a_type,
				array_length( address_type_table)-1) ]);

	++offset;

	if ( a_type == 1){		/* IPv4 address */
		proto_tree_add_item( tree, hf_socks_ip_dst, tvb, offset,
					4, FALSE);
		offset += 4;
	}
	else if ( a_type == 3){	/* domain name address */

		offset += display_string(tvb, offset, tree,
			"Remote name");
	}
	else if ( a_type == 4){	/* IPv6 address */
		proto_tree_add_item( tree, hf_socks_ip6_dst, tvb, offset,
				16, FALSE);
		offset += 16;
	}

	return offset;
}
Exemplo n.º 20
0
Arquivo: main.c Projeto: mengpq/os
void clear_screen(){
	int i=0;
	disp_pos = 0;
	for (i=0; i<4000; i++) display_string(" ");
	disp_pos = 0;
	trace_cursor();
}
void display_show_string(char* string,int x,int y){

	display_goto_xy(x, y);
	display_string(string);
	display_update();
	
}
Exemplo n.º 22
0
Arquivo: prompt.c Projeto: ris21/yoda
/* Repaint the statusbar when getting a character in
 * get_prompt_string().  The statusbar text line will be displayed
 * starting with curranswer[index]. */
void update_statusbar_line(const char *curranswer, size_t index)
{
    size_t start_col, page_start;
    char *expanded;

    assert(prompt != NULL && index <= strlen(curranswer));

    start_col = strlenpt(prompt) + 2;
    index = strnlenpt(curranswer, index);
    page_start = get_statusbar_page_start(start_col, start_col + index);

    if (interface_color_pair[TITLE_BAR].bright)
	wattron(bottomwin, A_BOLD);
    wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum);

    blank_statusbar();

    mvwaddnstr(bottomwin, 0, 0, prompt, actual_x(prompt, COLS - 2));
    waddch(bottomwin, ':');
    waddch(bottomwin, (page_start == 0) ? ' ' : '$');

    expanded = display_string(curranswer, page_start, COLS - start_col -
	1, FALSE);
    waddstr(bottomwin, expanded);
    free(expanded);

    wattroff(bottomwin, A_BOLD);
    wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum);
    statusbar_pww = statusbar_xplustabs();
    reset_statusbar_cursor();
    wnoutrefresh(bottomwin);
}
Exemplo n.º 23
0
/* This function is called repetitively from the main program */
void labwork( void )
{
  delay( 1000 );

  time2string( textstring, mytime );
  display_string( 3, textstring );
  display_update();

  getbtns();

  if (getbtns() == 1)
    mytime += (getsw() << 4);
  
  if (getbtns() == 2)
    mytime += (getsw() << 8);

  if (getbtns() == 4)
    mytime += (getsw() << 12);


  volatile int* porte = (volatile int*) 0xbf886110;
  tick( &mytime );
  *porte += 1;
  display_image(96, icon);
}
Exemplo n.º 24
0
void myPrintln(const char *s)
{
	static int y = 0;
	display_goto_xy(0,y);
	display_string(s);
	display_update();
y++;
}
Exemplo n.º 25
0
/* Convert buf into a string that can be displayed on screen.  The
 * caller wants to display buf starting with column start_col, and
 * extending for at most len columns.  start_col is zero-based.  len is
 * one-based, so len == 0 means you get "" returned.  The returned
 * string is dynamically allocated, and should be freed.  If dollars is
 * true, the caller might put "$" at the beginning or end of the line if
 * it's too long. */
std::string display_string(const std::string& buf, size_t start_col, size_t len, bool dollars)
{
	char *foo = display_string(buf.c_str(), start_col, len, dollars);
	std::string result(foo);
	free(foo);

	return result;
}
Exemplo n.º 26
0
// 入力を待つ
void UI::waitStart(float angle){
	while(1){
		tail->control(angle);
		if(touchSensor->isPressed()){
			display_goto_xy(6, 5);
			display_string("GO !!");
			display_update();
			break;
		}
		if(blueTooth->isReceived() == 1){
			display_goto_xy(6, 5);
			display_string("GO !!");
			display_update();
			break;
		}
	}
}
Exemplo n.º 27
0
void disp(int row, char *str, int val)
{ 
	if (row == 0) display_clear(0);
	display_goto_xy(0, row);
	display_string(str);
	display_int(val, 0);
	if (row == 7) display_update();
}
Exemplo n.º 28
0
void show(int distance)
{
	display_goto_xy(0, 0);
	display_string("DISTANCE :");
	display_goto_xy(0, 1);
	display_unsigned(distance,10);
	display_update();
}
Exemplo n.º 29
0
/*
 * Set up the required initial conditions for a match, and switch to playing state
 */
void start_game()
{
	/* Seed the RNG */
	srand(TCNT1);

	/* Load in the sprites */
	reticule_SPR = reticule(0);

	/* Generate and draw a level */
	clear_screen();
	free((void*) level_map);
	level_map = generate_flat(WIDTH, 129);	
	if(level_map != NULL)
		draw_level(level_map, SILVER, 0, WIDTH - 1);
	
	/* Set up the players in the field */
	playersX = malloc(players * sizeof(int16_t));
	playersY = malloc(players * sizeof(int16_t));
	players_HP = malloc(players * sizeof(uint8_t));
	if(playersX == NULL || playersY == NULL || players_HP == NULL)
	{
		display_string("Out of memory error!");
		return;
	}
	uint8_t i;
	for(i = 0; i < players; i++)
	{
		playersX[i] = (i + 1) * WIDTH / (players + 1);
		playersY[i] = 120;
		players_HP[i] = MAX_PLAYER_HP;

		free_sprite(player_SPR);
		player_SPR = botleft(i);
		fill_sprite(player_SPR, playersX[i], playersY[i], HEIGHT_NO_UI, WIDTH);
	}

	/* Pick a random player to ... go last
	 * First call to start_turn will cycle to next player. Poor sod. */
	current_player = rand() % players;

	reticuleX = (playersX[current_player] + (RETICULE_DISTANCE * ml_cos(position))/100);
	reticuleY = (playersY[current_player] + (RETICULE_DISTANCE * ml_sin(position))/100);

	/* Initialise movement variables */
	direction = 0;
	launch_speed = 0;

	/* Draw the UI */
	display_string_xy("POWER:", POWER_LABEL_X, POWER_LABEL_Y);
	fill_rectangle(power_outline, WHITE);
	fill_rectangle(power_empty, BLACK);
	display_string_xy("WIND:", WIND_LABEL_X, WIND_LABEL_Y);
	fill_rectangle(wind_outline, WHITE);
	fill_rectangle(wind_empty, BLACK);

	/* Start the first player's turn */
	start_turn();
}
Exemplo n.º 30
0
// Prints the welcome menu to the LCD display
// Welcome menu is "Welcome to Burger King!" marquee followed by
// prompt to press RIGHT to see other menu
void print_welcome()
{
      for (int i = 0; i < 40; i++) {
        delay(1000); //1ms
        for (int j = 0; j < 56 - i; j++) {
          display_string(" "); //space out the display
        }
        display_string("Welcome to Burger King!"); // 23 characters
        delay(100000); //.1 sec
      }
      delay(500000); //.5 sec

      clear_display();
      delay(1000); //1ms
      display_string("Press RIGHT");
      display_string("                             ");
      display_string("for menu");
}