예제 #1
0
파일: light.c 프로젝트: alkin/tidecc
// *************************************************************************************************
// @fn          update_light
// @brief       Update light status 
// @param       none
// @return      none
// *************************************************************************************************
void update_light(void)
{
	if(!sys.flag.low_battery && light.value >= LIGHT_LEVEL)
	{
		// Config front light duty cicle and blink rate
		light.front_blink = 6;
		light.front_duty = 10;
		
		// Enable front light Timer
		light.front_enable = TRUE;
		Timer0_A1_Start();
		
		// Enable back light Timer
		light.back_enable = TRUE;
		Timer0_A2_Start(); 
	
		// Turn on lights
		set_light(LIGHT_ALL, LIGHT_ON);
	}
	else
	{
		// Disable front light Timer
		light.front_enable = FALSE;
		Timer0_A1_Stop();
		
		// Disable back light Timer
		light.back_enable = FALSE;
		Timer0_A2_Stop(); 
		
		// Turn off lights
		set_light(LIGHT_ALL, LIGHT_OFF);
	}
}
예제 #2
0
파일: uart.c 프로젝트: kwan3217/Loginator
int autobaud(int port) {
  int lighton=0;
  int leastErrors=99999;
  int leastBaud=-1;
  unsigned int chars,errors;
  for(int i=0;i<STANDARD_BAUD_NUM;i++) {
    lighton=1-lighton;
    set_light(port,lighton);
    int result=countCharBaud(port,standardBaud[i],&chars,&errors);
    if(result>0) {
      baud[port]=standardBaud[i];
      set_light(port,OFF);
      return result;
    }
  	if(result==-2) {
	    if(errors<(chars/10) && errors<leastErrors) {
	      leastErrors=errors;
        leastBaud=i;
      }
	  }
	  drainToSD(&uartbuf[port]);
  }
  //No spped was perfect, use the best speed
  if(leastBaud>=0) {
    baud[port]=standardBaud[leastBaud];
	set_light(port,OFF);
	return 2;
  }
  //No speed was close enough, don't use the port
  uartMode[port]=PKT_NONE;
  baud[port]=0;
  set_light(port,OFF);
  return -1;
}
예제 #3
0
void hexbright::init_hardware() {
  // These next 8 commands are for reference and cost nothing,
  //  as we are initializing the values to their default state.
  pinModeFast(DPIN_PWR, OUTPUT);
  digitalWriteFast(DPIN_PWR, LOW);
  pinModeFast(DPIN_RLED_SW, INPUT);
  pinModeFast(DPIN_GLED, OUTPUT);
  pinModeFast(DPIN_DRV_MODE, OUTPUT);
  pinModeFast(DPIN_DRV_EN, OUTPUT);
  digitalWriteFast(DPIN_DRV_MODE, LOW);
  digitalWriteFast(DPIN_DRV_EN, LOW);
  
#if (DEBUG!=DEBUG_OFF)
  // Initialize serial busses
  Serial.begin(9600);
  Wire.begin();
  Serial.println("DEBUG MODE ON");
#endif
#if (DEBUG!=DEBUG_OFF && DEBUG!=DEBUG_PRINT)
  if(DEBUG==DEBUG_LIGHT) {
    // do a full light range sweep, (printing all light intensity info)
    set_light(0,1000,update_delay*1002);
  } else if (DEBUG==DEBUG_TEMP) {
    set_light(0, MAX_LEVEL, NOW);
  } else if (DEBUG==DEBUG_LOOP) {
    // note the use of TIME_MS/update_delay.
    set_light(0, MAX_LEVEL, 2500/update_delay);
  }
  
#ifdef FREE_RAM
  Serial.print("Ram available: ");
  Serial.print(freeRam());
  Serial.println("/1024 bytes");
#endif
#ifdef FLASH_CHECKSUM
  Serial.print("Flash checksum: ");
  Serial.println(flash_checksum());
#endif

#endif // DEBUG!=DEBUG_OFF
  
#ifdef ACCELEROMETER
  enable_accelerometer();
#endif
  
  // was this power on from battery? if so, it was a button press, even if it was too fast to register.
  read_charge_state();
  if(get_charge_state()==BATTERY)
    press_button();
  
  continue_time = micros();
}
예제 #4
0
int check_ball(uint32_t d, uint32_t t){
	int found = 0; 
	set_light(LIT_LEFT, LIT_OFF);
	if(d < WALL){ 
		if( d < min.d){
			min.d = d;
			min.t = t;
			printf("Distance: %d Angle: %d NEW MIN!\n", d);
			set_light(LIT_LEFT, LIT_RED);
			found = 1;
		}
	}
	return found;
}
예제 #5
0
파일: main.c 프로젝트: rghunter/LoggoDAQ
void blinklock(int maintainWatchdog, int blinkcode) {
  if(blinkcode==0) {
    for(;;) {
      set_light(0,ON);
      delay_ms(50);
      set_light(0,OFF);
      set_light(1,ON);
      delay_ms(50);
      set_light(1,OFF);
    }
  } else {
    for(;;) {
      for(int i=0;i<blinkcode;i++) {
        set_light(0,ON);
        delay_ms(250);
        set_light(0,OFF);
        delay_ms(250);
      }
      set_light(1,ON);
      delay_ms(250);
      set_light(1,OFF);
      delay_ms(250);
    }
  }
}
예제 #6
0
void error_message(char *message){
	printf("%s", message);
	fflush(stdout);
	ev3_clear_lcd();
	ev3_text_lcd_normal(0,0, message);
	while(1){
		set_light(LIT_RIGHT, LIT_RED);
		set_light(LIT_LEFT, LIT_OFF);
		sleep(1);
		set_light(LIT_RIGHT, LIT_OFF);
		set_light(LIT_LEFT, LIT_RED);
		sleep(1);
	}
}
예제 #7
0
void hexbright::init_hardware() {
  // We just powered on! That means either we got plugged
  // into USB, or the user is pressing the power button.
  pinModeFast(DPIN_PWR, INPUT);
  digitalWriteFast(DPIN_PWR, LOW);
  // Initialize GPIO
  pinModeFast(DPIN_RLED_SW, INPUT);
  pinModeFast(DPIN_GLED, OUTPUT);
  pinModeFast(DPIN_DRV_MODE, OUTPUT);
  pinModeFast(DPIN_DRV_EN, OUTPUT);
  digitalWriteFast(DPIN_DRV_MODE, LOW);
  digitalWriteFast(DPIN_DRV_EN, LOW);
  
#if (DEBUG!=DEBUG_OFF)
  // Initialize serial busses
  Serial.begin(9600);
  Wire.begin();
  Serial.println("DEBUG MODE ON");
#endif
#if (DEBUG!=DEBUG_OFF && DEBUG!=DEBUG_PRINT)
  if(DEBUG==DEBUG_LIGHT) {
    // do a full light range sweep, (printing all light intensity info)
    set_light(0,1000,update_delay*1002);
  } else if (DEBUG==DEBUG_TEMP) {
    set_light(0, MAX_LEVEL, NOW);
  } else if (DEBUG==DEBUG_LOOP) {
    // note the use of TIME_MS/update_delay.
    set_light(0, MAX_LEVEL, 2500/update_delay);
  }
  
#ifdef FREE_RAM
  Serial.print("Ram available: ");
  Serial.print(freeRam());
  Serial.println("/1024 bytes");
#endif
#ifdef FLASH_CHECKSUM
  Serial.print("Flash checksum: ");
  Serial.println(flash_checksum());
#endif

#endif // DEBUG!=DEBUG_OFF
  
#ifdef ACCELEROMETER
  enable_accelerometer();
#endif
  
  continue_time = micros();
}
void setup() {
  set_short("Xrazzicaz' Boot Camp");
  add_property("determinate", "");
  set_light( 75 );
  add_property("no teleport", 1);
  
  set_long("This is a small training room, designed to help the new "
           "adventurer get off to a good start on Discworld.  The air is "
           "stale with the combined stench of sweat, beer, and old "
           "warriors.  Off to one side is a rather unusual training "
           "dummy above which is a small plaque.\n");
  add_item( "face", "As you stare at it, squinting and turning your head "
            "side to side, you realise it looks rather like your old maths "
            "teacher!\n");
  add_item( "floor", "The floor is made of flagstones, cemented together "
            "with centuries of accumulated muck.\n");
  add_item( "wall", "The walls are marked with mysterious stains that may or "
            "may not be blood.  But surely training dummies don't bleed.\n");
  add_item( "ceiling", "The ceiling appears to be dingy patches of plaster "
            "stuck between old oak rafters that have turned black with "
            "age.\n");
/* Make it so you cannot godmother out of here */
  add_property("no godmother", 1);

  add_exit( "combat", PATH + "combat", "door" );
  add_alias( "southeast", "foyer");
}/*setup*/
        void ForwardPositonalLightShader::update_properties(
                                                            const Mat4& trans,
                                                            const RenderEngine& engine) const
        {
            //TODO remove global camera.
            //                auto mvp =
            
            set_uniform_matrix4("transformation_mat", trans);
//            set_uniform_matrix4("camera_mat", engine.get_global_camera()->get_camera_mat());
//            set_uniform_matrix4("projection_mat", engine.get_global_camera()->get_projection_mat());
            set_uniform_matrix4("camera_mat", Locator::get_game().get_camera()->get_camera_mat());
            set_uniform_matrix4("projection_mat", Locator::get_game().get_camera()->get_projection_mat());

            set_uniform_matrix3("normal_mat",  trans.get_mat3().inverse().transpose());
            
            
            
            set_light("positional_light.light", engine.get_active_light());
            
            set_pos_light("positional_light",static_cast<const PositionalLight*>(engine.get_active_light()),trans);
            

//            
            //TODO 
            set_uniform3f("camera_pos", Locator::get_game().get_camera()->get_world_pos());
            set_uniform3f("camera_pos", Locator::get_game().get_camera()->get_world_pos());
            
            set_uniform3f("camera_pos", Locator::get_game().get_camera()->get_world_pos());
            set_uniform3f("camera_pos", Locator::get_game().get_camera()->get_world_pos());
//            //use the new texture
//            material.get_texture("diffuse").bind_texture(m_program_id, m_uniform_map["texture_sampler"]);
        }
void setup() {
   set_short( "uninitialised search room" );
   set_long( "You are in an uninitialized search room.  "
            "This is an example of a room that gets cloned and configured "
            "afterwards.  In this room, it's the function set_marker that's " 
            "used to define its look, and most if the exits as well.  And "
            "the function set_destination that is used to find, possibly "
            "clone and configure, the rooms that fit the keywords you search "
            "for.  The handler called SEARCH in the code, is \""+
            SEARCH +"\" and the one called QUIT_HANDLER, is \""+ 
            QUIT_HANDLER +"\".\n" );
   add_property( "no map", 1 );
   /* set_light sets the amount of light the room has.  See help light
    * for a list of what the number means:)
    */
   set_light( 50 );

   add_exit( "exit", LEARNING +"search", "path" );
   /* add_property is used to add a value to an object, that can later be
    * queried for with query_property.
    * The "commented functions" and "keywords" properties are specific for 
    * rooms in the learning domain and is used to make it possible to search
    * for subjects. 
    * See /d/learning/handlers/search.c for the way this is done.
    */
   add_property( "commented functions", 
                ({ "set_destination", "query_quit_handler", 
                   "query_cloning_info" }) );
예제 #11
0
create() {
    set_short("Winding Path");
 
    set_long("\
This is a winding, thickly wooded path winding east and west through the\n\
the Forest of Elwoode.  The thick canopy of leaves overhead shelters the\n\
trail almost completely from the elements.  An opening in the vegetation\n\
lies to the north.\n");
 
    add_exit(ROOMS+"garg001", "north");
    /* what the f**k is this? COMMENT any changes, dammit!  - Slider 2/16/2000 */
	// Sorry Slider, the exit was mine to lead to Barrowmere. - Frij
	add_exit("/room/circ/roads/west1b","south");
    add_exit(ROOMS+"path4", "west");
    add_exit(ROOMS+"path2", "east");
 
    add_item("leaves",
"The cool, fragrant leaves protect the path from the elements.\n");
 
    add_item("path",
"The force of many feet through the ages has etched this path deeply into\n\
the earth.  You wonder where it leads.....\n");
 
    add_item("opening",
"It looks dangerous.  You feel a cautious sort of dread as you consider \n\
what may be beyond the vegetation.\n");
 
   add_item("vegetation",
"There's an opening in the vegetation that leads north.\n");
 
   set_light(1);
    add_property("outside");  // added by Frijoles
   reset(0);
}
void setup() {
  set_short( "bedroom" );
  set_long( "This is a small bedroom above the shop.  There is a window "
            "in the north wall.\n");
  
  set_light( 60 );

  // This is usually calculated for you and only needed if you want the room
  // to be bigger than normal.
  set_room_size( 10 ); 

  // set the movement zone.
  set_zone( "Tiny Town");

  /*
   * lots of add_items are needed here to describe all the things in the
   * room.
   */


  add_exit("window", PATH+"shop-ledge", "window");
  add_exit("down", PATH +"item-shop", "stair" );

  // make them move downwards 9feet when they go down the stairs
  modify_exit("down", ({ "downgrade", 9 }));
void setup() {
  set_short("Desert");
  set_long("This is the end of Desert\n");
  set_light( 80 );
  add_exit("east", DESERT + "desert4", "road");
  add_exit("west", DESERT + "desert2", "road");
}
예제 #14
0
void setup() {
//  string *doms, com;
//  int i;
  
  set_light(100);
  set_short("Site access control room");
  set_long("This room allows Demi-Gods and higher to easily remove "+
    "troublesome players and even creators.  You can also banish a site "+
    "from here entirely, but be absolutely certain that is approved by "+
    "a God before you do so (or face demotion).\n\n"+
    "Available commands:\n"+
    "For specific character names\n"+
    "----------------------------\n"+
    "banish <player> <reason>         : Banish a player name.\n"+
    "unbanish <player>                : Unbanish a player name.\n"+
    "suspend <player> <time>          : Suspend someones access for <time> hours.\n"+
    "unsuspend <player>               : Unsuspend someones access.\n\n"+
    "For entire sites\n"+
    "----------------\n"+
    "access                           : Show the current access of various sites.\n"+
    "unsite*banish [<ident>@]<ip>     : Completely unbanish a site.\n"+
    "grant [<ident>@]<ip>             : Grant access to a specific\n"+
    "                                    user/machine\n"+
    "nonew [<ident>@]<ip> <reason>    : Disallow new players from a site.\n"+
    "noaccess [<ident>@]<ip> <reason> : Disallow all access from a site.\n"+
    "noguest [<ident>@]<ip> <reason>  : Disallow guests from a site.\n");

add_exit("norte", ADMIN+"admin3","standard");
  seteuid("Admin");
} /* setup() */
예제 #15
0
void setup() {
  set_light(100);
  set_short("Small Gods Street outside Temple");
  set_long(
"You are on Small Gods Street outside the Temple of Small Gods.  "+
"A large gateway to the west leads into the Temple.  The "+
"street continues north and south.\n");
 
  add_exit("north", ROOM+"smallgod1", "road");
  add_exit("south", ROOM+"smallgod3", "road");
  add_exit("west", TEMPLE, "gate");
 
  add_item("temple",
"It is the Temple of Small Gods.  It is covered in small statues.\n");
  add_alias("temple of small gods", "temple");
  add_item("gateway",
"This is a large wrought-iron set of gates which have been open for so many years "+
"that they appear to have rusted permanently open.  Various and sundry "+
"religious symbols are situated over the top of the gateway.\n");
  add_alias("gate", "gateway");
  add_alias("gates", "gateway");
  add_item("symbols", "From the look of it the many different symbols are all "+
"collected from the myriad of small obscure gods that are worshipped "+
"in Ankh-Morpork.\n");
  add_alias("symbol", "symbols");
 
  set_zone("ankh morpork");
 
  set_monster(NUM, "city");
}
예제 #16
0
reset() {
  set_light(1);
  
  set_emotes(1, ({
	"A carriage barrels through the street causing passerbys to flee.\n",
	"Smoke wafts through on the back of a short gust from a nearby hearth.\n",
  }));
void setup() {
  // make sure that the short says "A simple item shop" rather than "The ..."
  add_property( "determinate", "A " );
  
  set_short( "simple item shop" );
  set_long( "This is a nice looking shop.  Obviously your shop would have "
            "a much more interesting description.\n");
  
  set_light( 60 );

  // This is usually calculated for you and only needed if you want the room
  // to be bigger than normal.
  set_room_size( 10 ); 

  // set the movement zone.
  set_zone( "Tiny Town");

  add_exit( "north", TTOWNROADS +"womble01", "door" );
  modify_exit( "nouth", ({
    "exit mess", "Chimes start playing as $N "
      "leave$s through the north door.",
      "enter mess", ({ 
        1,
          "$N enters from the south.",
          "$N enter from the south." }),
      "move mess", "Chimes start playing as you leave the shop.\n"
      }));
void setup() {
  set_short("Plains");
  set_long("This is the end of Plains\n");
  set_light( 80 );
  add_exit("east", PLAIN + "plain5", "road");
  add_exit("west", PLAIN + "plain3", "road");
}
void setup() {
   set_short("add_item room #4, many verbs ");
   set_light(100);

   set_long( "add_item room #4, many verbs \n"
            "Sometimes you have two or more identical verbs - or at least "
            "identical in how you want to treat them.  Take our oak tree "
            "we can cut it, slice it, saw it, etc...  Now all of these have "
            "the same meaning. How do we do this?\n"
            "A large oak.\nA note.\n");
   
   add_item("note", ({ "long", "It can be read.",
      "read", "Here is the code for the tree:\n"
      "    add_item(\"large oak tree\", ({\n"
      "      \"long\",\n"
      "              \"It looks like it is very well protected.\"\n"
      "      ({\"cut\",\"slice\",\"saw\",\"destroy\",\"kill\" }),\n"
      "              \"It seems to have no effect.\\n\"       }});\n\n"
      "Pretty obvious hunh?  Note that kill probably does not work( I "
      "say probably cuz things might change)  That is beacuse user commands "
      "have precidence over object actions in rooms.  Also be aware that a "
      "add_action on an item that a person is holding will most likely stop "
      "your verbs from being used (unless it's coded right:).  Soul commands "
      "do not have precedence, however.  So verbs like \"pick\" which would "
      "normally say \"You pick your nose\" can be trapped appropriately.\n" 
   }) );
void setup() {
//  string *doms, com;
//  int i;
  
  set_light(100);
  set_short("domain-control room");
  add_property("determinate", "the ");
  set_long("You float in nothingness, before a vast turtle, its shell pocked "
    "by asteroid craters. In all directions stars twinkle in the black " 
    "curtain of space.\n" 
"Available commands:\n"
"  list                         : list all domains.\n"
"  list <domain>                : list members of a domain.\n"
"  create <domain>              : create a domain (you are lord).\n"
"  create <domain> <lord>       : create a domain for someone else.\n" 
"  add <creator> <domain>       : add a creator to a domain you own.\n" 
"  delete <creator> <domain>    : remove a creator from a domain you own.\n" 
"  project <cre> <dom> <proj>   : Set the creators project.\n"
"  deputy <cre> <dom>           : Appoint creator as a deputy.\n"
"  undeputy <cre> <dom>         : Remove creator as a deputy.\n"
);

  add_item("turtle", "On its back you can see four elephants, and they bear " +
    "the weight of the disc upon their wide backs.\n");
  add_item("elephants", "The four great elephants labour endlessly in the " +
    "task of turning the disc upon their backs.\n");
  add_item("disc", "The whole discworld, from hub to rim, rides upon the " +
    "elephant's backs.\n");
  add_alias("elephant", "elephants");
  add_exit("north", ROOM+"development", "corridor");
  add_exit("south", ROOM+"site_control", "corridor");
  add_exit("west", ROOM+"access_control", "corridor");
  seteuid("Admin");
} /* setup() */
예제 #21
0
파일: hill1.c 프로젝트: nfarrar/mudfiles
void reset(int arg) {
  if(arg) return;

  set_light(1);
  add_property("hills");

  set_short("Rolling Hills");
  set_long(LB("You stand on the edge of a great land of rolling hills.  "+
	"A wide track winds its way through here, heading south back to "+
	"the lands of men.  The hum of insects is heard in the air, lending "+
	"a natural feel to this otherwise quiet land.  The hills seem "+
	"empty, and a light mist shrouds the distance."));
  add_item("insects", LB("The sound of crickets and cicadas give the "+
	"only signs of activity here."));
  add_item("hills", LB("The hills that surround you are quiet and "+
	"apparently largely uninhabited, except for insects and small "+
	"animals.  The skies are strangely empty of avians, and you "+
	"see no man-made structures around you.  You intuit an unexplained "+
	"spookiness in this forlorn place, however."));
  add_item("track", LB("The dirt track leads back to the village to the "+
	"south.  It is the only safe road into this land, and thus the "+
	"most travelled, but that is only relative."));
  add_item("mist", LB("The mist, which only obscures the distances, "+
	"lends to the loneliness of the land."));
  add_exit("north","hill2");
  add_exit("west", "hill4");
  add_exit("south","track3");
}
예제 #22
0
파일: dungeon_north.c 프로젝트: cfong57/mud
void extra_create()
{ 
  set_no_teleport(1); 
  set_short( "Cellaria's dungeon, entrance to storage" );
  set_long(wrap("In the north part of the dungeon, the air is a bit warmer, "+
  "but that only makes the humidity worse. Here you can see some signs of "+
  "life, as the flawless walls from earlier devolve into merely packed dirt, "+
  "with an occasional tree root poking out. There is an iron cell door to "+
  "the north, and slumped against it is a recently-deceased body. The body's "+
  "hand reaches towards the door's keyhole, as if its last action was to "+
  "try to pick it.\n"));
  set_light(-35); 
  add_monster("/u/a/allanon/area/lumber_camp/mon/bandit.c");
  set_item_desc(([
  ({"walls", "dirt", "tree root", "root"}) : "Since you have gone in a ways, "+
  "you are probably right beneath the forest floor now, so it is only "+
  "natural that it would be harder to make a good tunnel.\n", 
  "body" : "The body seems fresh, as it is still leaking some blood. It has "+
  "not yet started to decompose; you don't feel like staying around to watch "+
  "that happen. Its hand reaches towards the door in a plaintive gesture. "+
  "Perhaps whoever it was tried in vain to open the door and flee from "+
  "assailants by locking themself inside. You notice with some curiosity that "+
  "the body seems to be somewhat frozen. But it certainly isn't that cold "+
  "here...right?\n",
  "keyhole" : "Upon closer examination, you find that the door's keyhole is "+
  "very strange. The tumbler is long and thin - you have never before seen "+
  "a key of such a shape.\n"]));            
예제 #23
0
void create() {
    seteuid(getuid(this_object()));
    set_light(1);
    set_short("Magical Mind Altering Altar");
    set_long(
"This room is clean and has almost brand new furniture in it.  A strange\n"+
"tilted altar is in the middle of the room.  Tables with wheels, which are\n"+
"covered with magical devices, have been pushed up against the walls.\n");
    addi("furniture",
"The furniture is all made of oak.\n");
    addi("altar",
"The altar is made out of wood and is tilted at a strange angle.\n");
    addi("tables",
"The tables are covered with various wands, rings, orbs, magical herbs, and\n"+
"some things you cannot even identify.\n");
    addi("table",
"Each table is made out of sturdy oak and can be wheeled around the room.\n");
    addi("devices","The devices are very peculiar.\n");
    addi("device",
"One device catches your eye.  It is squirting water down a drain.\n");
    addi("water","The water looks cool and refreshing.\n");
    addi("drain","The drain is on the floor.\n");
    addi("floor","The floor is well swept granite.\n");
    addi("walls","The stone walls are bare of decorations.\n");
    addi("wall","All the walls are the same.\n");
    addi("stone","All the stone in this room is granite.\n");
    addi("granite","The granite is grey and rough.\n");
   // new("/obj/mon/wizard")->move(this_object());
}
예제 #24
0
create() {
   set_short("North Elwoode Street");
 
   set_long("\
You are on a pleasant thoroughfare on the north end of the village of \n\
Elwoode.  The street is a bit quieter here than the center of town; the\n\
shops are a bit more seedy-looking.  The street continues north out of\n\
town and south towards the center of town.  A dark alley gapes hollowly\n\
to the west.\n");
 
   add_exit(ROOMS+"elwood03", "south");

/* This must not be done, removed since was getting player bug things
   add_exit(ROOMS + "elwood05","north");
*/
   add_exit(ROOMS+"elwood4a", "west");
 
   add_item("street",
"Yep - it's a street all right!  You're standing on it!");
 
   add_item("alley",
"It looks dark and more than a little dangerous.  You may not want to go\n\
in there alone!");
 
   add_item("shops",
"They're not much to look at.  None of them appear to be open for business.");
    
   set_light(1);
   reset(0);
}
예제 #25
0
void init(int use_http, char *address, int port){
    // Setup periferal and library
    init_gui();
    init_motors();
    init_sensor();
	init_compass();
	calibrate_compass(0); // 0 = do not execute a new calibration of the compass	

	// Load ball predefined positions
	get_positions(POINTS_FILE_NAME, &positions, &n_points);

	// Start bluetooth
	if(use_http)
		bluetooth_test_init(address, port);
    else 
		bluetooth_init();
	
	//bluetooth_register_and_start(fAction_t, fAck_t, fLead_t, fStart_t, fStop_t, fWait_t, fKick_t, fCancel_t);
    bluetooth_register_and_start(&follower_action_cb, NULL, &lead_cb, &start_cb, &stop_cb, NULL, NULL, &cancel_cb);

	// Reset global variables
  	send_action_flag = 1;
	act = 0;
    end_game = 0;
    start_game = 0;
    wait = 0;
	cancel = 0;
	// Waiting for the game start
	set_light(LIT_LEFT, LIT_GREEN);
	set_light(LIT_RIGHT, LIT_GREEN);
    while(!start_game); //start game, robot rank and snake size  initialized by start_cb

	// Initial position
	home.x = BORDER_X_MAX/2;
	home.y = (snake_size - robot_rank -1)*40 + 20;
	center.x = BORDER_X_MAX/4;
	center.y = BORDER_Y_MAX/2;
	robot = home;
	
	printf("[DEBUG] Starting position X: %d, Y: %d, T: %d\n", robot.x , robot.y, robot.t);
	
	update_sensor(SENSOR_GYRO);
    gyro_init_val = get_sensor_value(SENSOR_GYRO);
    set_light(LIT_LEFT, LIT_OFF);
	set_light(LIT_RIGHT, LIT_OFF);
}
예제 #26
0
create() {
    set_short("Slider's Prison");

    set_long(
"Uh-oh....you've ended up in Slider's Prison!  Maybe if you're nice, he'll\n"+
"let you out!  Then again, maybe not!\n");
    set_light(1);
}
예제 #27
0
void light(void)
{
    shining = 1;
    set_light(5);
    set_short("A small, shining stone");
    set_long("A small stone shining with a warm light. You feel "+
             "comforted when you look at it.\n");
}
예제 #28
0
int get_ball(){
	int tries = 2; //number of tries when scanning to find the ball
	int found = 0;
    int angle;
	int dist;
	while(tries > 0){
	    found = scan_for_ball();
    	if(found == 1){
            // Min point found
            if(min.d <120){
                // Grab the ball
                set_motors_speed(NORMAL_SPEED);
				angle = min.d * 2.1 - 67;
                run_relative(angle);
                while(!command_finish());
				dist = (angle*18.0/360);
				robot.x += dist * sin(robot.t);
				robot.y += dist * cos(robot.t);
				//add check that the ball is really there
                tries = (grab_and_check())? 0: 2;
            }else{
                // Avvicinati
                set_motors_speed(NORMAL_SPEED);
				angle = (int)((min.d * 2.1 -67)*3/4);
                run_relative(angle);
				dist = (angle*18.0/360);
				robot.x += dist * sin(robot.t);
				robot.y += dist * cos(robot.t);
                while(!command_finish());
            }
        }else{
              // Minimum not found
			  //set_motors_speed(NORMAL_SPEED);
              //run_relative(0);
              //while(!command_finish());
              tries--;
        }
    }

    set_light(LIT_LEFT, LIT_OFF);
    set_light(LIT_RIGHT, LIT_OFF);
	
	//update robot angle
	robot.t = get_gyro_value();
    return found;    
}
예제 #29
0
void
setup()
{
    set_short( "Quest Room" );
    set_long( "This room is used to create, list, and remove quests.\n" );
    set_light( 100 );
    add_exit( "west" , ROOM+"development" , "corridor" );
}
void setup() {
  set_short("Plains");
  set_long("This is Plains at the junction with Rabbit Lane.
\n");
  set_light( 80 );
  add_exit("east", PLAIN + "plain2", "road");
  add_exit("west", RABBIT + "rabbit4", "road");
}