Ejemplo n.º 1
0
int16_t main(void)
{
	initRobotBase();
	powerON(); 
	setLEDs(0b111111); 
	mSleep(1000); 
	setLEDs(0b000000);
	mSleep(500);
	uint8_t runningLight = 1;
	for (uint8_t i = 0; i < 6; i++){
		for (uint8_t j = 0; j< 3;j++)
			destination[j] = destinationarray[i][j];
		//mainloopOpen();
		mainloopClosed();
		fancyled(&runningLight);
		/*for (uint8_t j = 0; j< 3;j++)
			source[j] = destination[j];*/
		mSleep(2000);
		
	}
	task_RP6System();
	while(true)
	{
		fancyled(&runningLight);
		if (motioncomplete == 0)
			moveAtSpeed(0,0);
		mSleep(200);
		task_RP6System();
	}
	return 0; 
}
Ejemplo n.º 2
0
uint32 copyMem(volatile uint32 *src, volatile uint32 *target, uint32 len){
	uint32 *STORE2 = (uint32 *)0x40900030;
	
	uint32 i,j;
	uint32 checkSum = 0;
	j=0;

	setLEDs(GREEN);
	for(i=0;i<len;i+=4){
		*STORE2 = i;	//store how far got if it dies

		*target = *src;
		if( *target != *src ){
			error(7, 0);
			readUInt(i);
			readUInt(*target);
			readUInt(*src);
		}		
		src++;
		checkSum += *target++;

		j++;
		if(j==20000)
			setLEDs(BLUE);
		else if(j >= 40000){
			setLEDs(GREEN);
			j=0;
		}
	}
	
	return checkSum;
}
Ejemplo n.º 3
0
int main(void) {
    
    initRobotBase();

    setLEDs(0b111111);
    mSleep(1500);
    setLEDs(0b000000);

    // Set Bumpers state changed event handler:
    BUMPERS_setStateChangedHandler(bumpersStateChanged);

    powerON(); // Turn Encoders, Motor Current Sensors 
    // ATTENTION: Automatic Motor control will not work without this!

    /* RP6 SAGAN GENERATED COMMANDS START */
    
    /*{SAGAN1_COMMANDS_HERE}*/
    
    /* RP6 SAGAN GENERATED COMMANDS STOP */

    stop();
    moveAtSpeed(0, 0);
    BUMPERS_setStateChangedHandler(BUMPERS_stateChanged_empty);
    setLEDs(0b000000);

    while (true) {
        statusLEDs.LED2 = !statusLEDs.LED2; // Toggle LED bit in LED shadow register... 
        statusLEDs.LED5 = !statusLEDs.LED5;
        updateStatusLEDs();
        mSleep(500);
        task_RP6System();
    }
    return 0;
}
Ejemplo n.º 4
0
int main(void)
{
	initRP6M256(); 
	initLCD(); 
			   
	writeString_P_WIFI("\n\nRP6 CONTROL M256 I2C Master Example Program!\n"); 

	// IMPORTANT:
	I2CTWI_initMaster(100); // Initialize the TWI Module for Master operation
							// with 100kHz SCL Frequency
							
	// Register the event handlers:
	I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);

	setLEDs(0b1111); // Turn all LEDs on!

	showScreenLCD("################", "################");
	mSleep(500);
	showScreenLCD("I2C-Master", "Example Program 1");
	mSleep(1000);
	// ---------------------------------------
	setLEDs(0b0000); // All LEDs off!
	
	uint8_t counter = 1;
	
	
	// The command and register used here - in the next example we define them all. 
	#define CMD_SET_ACS_POWER	9 
	#define ACS_PWR_MED  2
	
	// Set ACS to medium power (you can see the ACS value changes in the raw registers):
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_ACS_POWER, ACS_PWR_MED);


	while(true) 
	{
		// Increment a counter and send value to LEDs of the
		// Slave Controller:
		setLEDs(0b0001);
		showScreenLCD("INCREMENT", "COUNTER");
		setCursorPosLCD(1, 11);
		writeIntegerLengthLCD(counter, DEC, 3);
		I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, 3, counter);

		counter++;
	
		// Read and display ALL registers of the slave controller:
		setLEDs(0b0010);

		readAllRegisters();
	
		// Read the light sensors:
		setLEDs(0b0100); 
		readLightSensors();
		
		mSleep(250);
	}
	return 0;
}
int main(void)
{
	initRobotBase();

	setLEDs(0b111111);
	mSleep(500);
	setLEDs(0b000000);

	writeString_P("\nJust a simple counter program\n\n");
	
	uint16_t counter = 0;

	while(true)
	{
		timer = 0; 
		if(counter < 100) 
		{
			writeString_P("Counter: ");
			writeInteger(counter, BIN);
			writeString_P("(BIN) | ");
			writeInteger(counter, OCT);
			writeString_P("(OCT) | ");
			writeInteger(counter, DEC);
			writeString_P("(DEC) | ");
			writeInteger(counter, HEX);
			writeString_P("(HEX) ");
		}
		else
		{
			writeString_P("Counter L: ");
			writeIntegerLength(counter, BIN, 16);  
			writeString_P("(BIN) | ");
			writeIntegerLength(counter, OCT, 6);
			writeString_P("(OCT) | ");
			writeIntegerLength(counter, DEC, 6);
			writeString_P("(DEC) | ");
			writeIntegerLength(counter, HEX, 4);
			writeString_P("(HEX) ");
		}
		
		writeChar(' ');
		writeInteger(timer,DEC); 
		writeString(" *100us");
		writeChar('\n');
		
		counter++;  
		mSleep(100);
	}
	return 0;
}
Ejemplo n.º 6
0
//Blink LEDs for Debugging
void blinkLEDs(unsigned int numTimes)
{
	volatile unsigned int i = 0;

	if (numTimes > 5)
		numTimes = 5; //We Don't have all day man

	setLEDs(OFF);
	for (i = 0; i < numTimes * 2; i++)
	{
		setLEDs(LOGIC_TOGGLE);
		_delay_cycles(MCU_CLOCK / 2); //half second delay
	}
}
Ejemplo n.º 7
0
void showStatus(uint8_t verdieping, uint16_t hoogte, uint8_t motor)
{
    //            "rechtsom     aan", "Hoogte: 100     "
    showScreenLCD("                ", "H:          V:  ");

    setCursorPosLCD(0, 13);
    writeStringLCD_P("aan");

    // motor status
    switch (motor) {
        case MOTOR_IDLE:
            setCursorPosLCD(0, 13);
            writeStringLCD_P("uit");
            break;
        case MOTOR_LEFT:
            setCursorPosLCD(0, 0);
            writeStringLCD_P("Linksom");
            break;
        case MOTOR_RIGHT:
            setCursorPosLCD(0, 0);
            writeStringLCD_P("Rechtsom");
            break;
    }

    setCursorPosLCD(1, 3);
    writeIntegerLCD(hoogte, DEC);

    setCursorPosLCD(1, 15);
    writeIntegerLCD(verdieping, DEC);

    setLEDs(1 << verdieping);
}
Ejemplo n.º 8
0
void KeyboardManager::serviceIRQ(void)
{
  send_cmd(0xAD); // disable the keyboard
  kb_wait();

  uint8 scancode = inportb(0x60);

  if (extended_scancode == 0xE0)
  {
    if (scancode == 0x2A || scancode == 0x36 || scancode >= E0_BASE)
    {
      extended_scancode = 0;
      send_cmd(0xAE); // enable the keyboard
      return;
    }

    scancode = E0_KEYS[scancode];
  }
  else if (extended_scancode == 0xE1 && scancode == 0x1D)
  {
    extended_scancode = 0x100;
    send_cmd(0xAE); // enable the keyboard
    return;
  }
  else if (extended_scancode == 0x100 && scancode == 0x45)
    scancode = E1_PAUSE;

  extended_scancode = 0;

  if (scancode == 0xFF || scancode == 0xFA || scancode == 0xFE || scancode == 0x00) // non parsable codes, ACK and keyb. buffer errors
  {
    debug(A_KB_MANAGER, "Non-parsable scancode %X \n", scancode);
    send_cmd(0xAE); // enable the keyboard
    return;
  }

  if (scancode == 0xE0 || scancode == 0xE1)
  {
    extended_scancode = scancode;
    send_cmd(0xAE); // enable the keyboard
    return;
  }

  modifyKeyboardStatus(scancode);
  setLEDs(); // setting the leds

  if ((scancode & 0200)) // if a key was released just ignore it
  {
    send_cmd(0xAE); // enable the keyboard
    return;
  }

  if (main_console)
  {
    keyboard_buffer_.put(scancode); // put it inside the buffer
    main_console->addJob();
  }

  send_cmd(0xAE); // enable the keyboard
}
Ejemplo n.º 9
0
void PS2KeyboardManager::processKey(PS2Keyboard::Key key) {
  int index = key.code() / 8;
  int bit = key.code() % 8;
  if (key.type() == PS2Keyboard::KEY_PRESSED) {
    pressed_[index] |= 1 << bit;
  } else {
    pressed_[index] &= ~(1 << bit);

    // Handle LEDs.
    byte mask = 0;
    switch (key.code()) {
      case PS2Keyboard::KC_SCROLL_LOCK:
        mask = LED_SCROLL_LOCK;
        break;
      case PS2Keyboard::KC_KP_NUM_LOCK:
        mask = LED_NUM_LOCK;
        break;
      case PS2Keyboard::KC_CAPS_LOCK:
        mask = LED_CAPS_LOCK;
        break;
      default:
        break;
    }
    if (mask != 0)
      setLEDs(mask, ~leds_);
  }
}
Ejemplo n.º 10
0
void RGBWLamp::setColor(HSIColor &color) {
  std::vector<float> LEDs = _colorspace->Hue2LEDs(color);
  for (int i=0; i<LEDs.size(); i++) {
    LEDs[i] = _maxvalues[i] * LEDs[i];
  }
  setLEDs(LEDs, _pins);
}
Ejemplo n.º 11
0
/**
 * Here we do a small LED test 
 * (a running light with direction changing)!
 * For timing we use Stopwatch #1. 
 */
void runningLight(void)
{
	static uint8_t runLight = 1; 
	static uint8_t dir;  // Moving direction for running light
	// The "static" keyword in front of these two local variables means that they 
	// are NOT cleared when leaving this function. Their content is kept and they
	// act just like global variables (but they are only accessible within 
	// this function)! You already saw this on RP6 Robot Base Examples... 
	
	// We want a 100ms delay between the calls, which results in 10Hz refresh rate of
	// the running light.
	// ATTENTION: DO NOT USE "==" to compare to the stopwatch values, 
	// use only ">" or "<" or ">=" because you could miss the point where the stopwatch 
	// has the exact value!
	if(getStopwatch1() > 100) // 100ms
	{
		// Set status LEDs to the value of the variable testLEDs:
		setLEDs(runLight); 
	
		// Shift the LED bit left or right depending on direction:
		if(dir == 0)
			runLight <<= 1; 
		else
			runLight >>= 1;
			
		// Change the direction if we reached one of the two outer LEDs:
		if(runLight > 7 ) 
			dir = 1;			
		else if (runLight < 2 ) 
			dir = 0;
		
		// Reset Stopwatch1:
		setStopwatch1(0);
	}
Ejemplo n.º 12
0
int main(void)
{
	initRP6M256(); 
	initLCD();

	// ---------------------------------------
	WDT_setRequestHandler(watchDogRequest); 

	// ---------------------------------------
	I2CTWI_initMaster(100);  
	I2CTWI_setRequestedDataReadyHandler(I2C_requestedDataReady);
	I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);


	setLEDs(0b1111);
	mSleep(1000);
	setLEDs(0b0000);
	
	// ---------------------------------------
	// Setup ACS power:
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_ACS_POWER, ACS_PWR_OFF);
	// Enable Watchdog for Interrupt requests:
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT, true);
	// Enable timed watchdog requests:
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT_RQ, true);

	startStopwatch1();
	startStopwatch2();
	startStopwatch3();
	
	while(true) 
	{ 
		/*
		mSleep(600);
		warnForObs();
		mSleep(600);
		task_checkINT();
		mSleep(600);
		light_detection();
		mSleep(600);
	    task_I2CTWI();
		mSleep(600);*/
		writeIntegerLength_WIFI(adcBat,DEC,4);
		behaviourController();
	}
	return 0;
}
Ejemplo n.º 13
0
void fancyled(uint8_t *runningLight)
{
	setLEDs(*runningLight); 
	*runningLight <<= 1; 
	if(*runningLight > 32)
		*runningLight = 1;

}
void ApplePS2Keyboard::setDevicePowerState( UInt32 whatToDo )
{
  switch ( whatToDo )
  {
    case kPS2C_DisableDevice:

      //
      // Disable keyboard.
      //

      setKeyboardEnable( false );

      break;

    case kPS2C_EnableDevice:

          //
          // Reset the keyboard to its default state.
          //
          
          PS2Request * request = _device->allocateRequest();
          if (request)
          {
              request->commands[0].command = kPS2C_WriteDataPort;
              request->commands[0].inOrOut = kDP_SetDefaults;
              request->commands[1].command = kPS2C_ReadDataPortAndCompare;
              request->commands[1].inOrOut = kSC_Acknowledge;
              request->commandsCount = 2;
              _device->submitRequestAndBlock(request);
              _device->freeRequest(request);
          }

      
      //
      // Initialize the keyboard LED state.
      //

      setLEDs(_ledState);

      //
      // Enable the keyboard clock (should already be so), the keyboard
      // IRQ line, and the keyboard Kscan -> scan code translation mode.
      //

      setCommandByte( kCB_EnableKeyboardIRQ | kCB_TranslateMode,
                      kCB_DisableKeyboardClock );

      //
      // Finally, we enable the keyboard itself, so that it may start
      // reporting key events.
      //

      setKeyboardEnable( true );

      break;
  }
}
Ejemplo n.º 15
0
void KeyboardManager::serviceIRQ(void)
{
  uint8 scancode = kmi->data;
#if QEMU_SENDS_SCANCODE_SET2
  if(scancode == 0xf0)
    next_is_up_ = 1;
#endif
  // left shift release (0xAA) and right shift release (0xB6) must not be ignored when scancode set 1 is sent by qemu:
  if (scancode > 0x80 && scancode != 0xAA && scancode != 0xB6)
    return;

#if QEMU_SENDS_SCANCODE_SET2
  scancode = SET1_SCANCODES[scancode];
  if(next_is_up_)
  {
    next_is_up_ = 0;
    modifyKeyboardStatus(scancode | 0x80);
    return;
  }
#endif

  if (extended_scancode == 0xE0)
  {
    if (scancode == 0x2A || scancode == 0x36 || scancode >= E0_BASE)
    {
      extended_scancode = 0;
    }

    scancode = E0_KEYS[scancode];
  }
  else if (extended_scancode == 0xE1 && scancode == 0x1D)
  {
    extended_scancode = 0x100;
  }
  else if (extended_scancode == 0x100 && scancode == 0x45)
    scancode = E1_PAUSE;

  extended_scancode = 0;

  if (scancode == 0xFF || scancode == 0xFA || scancode == 0xFE || scancode == 0x00) // non parsable codes, ACK and keyb. buffer errors
  {
    debug(A_KB_MANAGER, "Non-parsable scancode %X \n", scancode);
  }

  if (scancode == 0xE0 || scancode == 0xE1)
  {
    extended_scancode = scancode;
  }

  modifyKeyboardStatus(scancode);
  setLEDs(); // setting the leds
  if (main_console)
  {
    keyboard_buffer_.put(scancode); // put it inside the buffer
  }

}
Ejemplo n.º 16
0
int main(void)
{
	initRobotBase(); 
	setLEDs(0b111111);
	mSleep(2500);
	setLEDs(0b100100); 

	BUMPERS_setStateChangedHandler(bumpersStateChanged);
	
	powerON(); 
	
	while(true) 
	{		
		behaviourController();
		task_RP6System();
	}
	return 0;
}
Ejemplo n.º 17
0
void setup(void)
{
	initRP6Control();

	setLEDs(0b0000);
	dischargePeakDetector();

	initLCD();
	clearLCD();
}
Ejemplo n.º 18
0
// Declare Global variables
int main(void) {
  // Set up Create and module
  initializeCommandModule();

  powerOnRobot();
    // Is the Robot on
  byteTx(CmdStart);
    // Start the create
  baud(Baud57600);
    // Set the baud rate for the Create and Command Module
  defineSongs();
    // Define some songs so that we know the robot is on.
  byteTx(CmdControl);
    // Deprecated form of safe mode. I use it because it will
    // turn of all LEDs, so it's essentially a reset.
  byteTx(CmdFull);
    // We are operating in FULL mode.

  // Play the reset song and wait while it plays.
  byteTx(CmdPlay);
  byteTx(RESET_SONG);
  delayMs(750);

  // Turn the power button on to something.
  turnOnPowerButtonLight();
  delayMs(20);


  // Infinite operation loop
  int timerLoop = 0; 
  const int timerLimit = 15;
  
  initializeUSBBuffer();
  initializeRobotBuffer();
  initializeSensorArray();
  
  setLEDs(BOTHLED, FULL);
  enableReports();
  enableSensors();
  
  while(1) {
	pollSensors();
	if(timerLoop == timerLimit){
		compileReport();
		sendUSBBuffer();
		timerLoop = 0;
		delayMs(1);
  	}
	timerLoop++;
	pollRemoteSensors();
	pollRemote();
	executeCommand();
	delayMs(5);
	}
}
Ejemplo n.º 19
0
void ApplePS2Keyboard::setNumLockFeedback(bool locked)
{
  //
  // Set the keyboard LEDs to reflect the state of num lock.
  //
  // It is safe to issue this request from the interrupt/completion context.
  //

  _ledState = locked ? (_ledState | kLED_NumLock):(_ledState & ~kLED_NumLock);
  setLEDs(_ledState);
}
Ejemplo n.º 20
0
// Declare Global variables
int main(void) {
  // Set up Create and module
  initializeCommandModule();

  powerOnRobot();
    // Is the Robot on
  byteTx(CmdStart);
    // Start the create
  baud(Baud57600);
    // Set the baud rate for the Create and Command Module
  defineSongs();
    // Define some songs so that we know the robot is on.
  byteTx(CmdControl);
    // Deprecated form of safe mode. I use it because it will
    // turn of all LEDs, so it's essentially a reset.
  byteTx(CmdFull);
    // We are operating in FULL mode.

  // Play the reset song and wait while it plays.
  byteTx(CmdPlay);
  byteTx(RESET_SONG);
  delayMs(750);

  // Turn the power button on to something.
  delayMs(20);
  
  initializeUSBBuffer();
  initializeRobotBuffer();
  initializeSensorArray();
  
  setLEDs(BOTHLED, FULL);
  enableReports();
  enableSensors();
  
  int fakeTimer = 0;

  // Infinite operation loop
  while(1) {
	  
	  if (fakeTimer == 4) {
		  compileReport();
		  sendUSBBuffer();
		  fakeTimer = 0;
	  }
	  
	  pollSensors();
	  delayMs(250);
	  
	  fakeTimer++;
	  
  }
}
Ejemplo n.º 21
0
void KeyboardManager::serviceIRQ(void)
{
  uint8 scancode = kmi->data;
  if(scancode == 0xf0)
    next_is_up_ = 1;
  if (scancode > 0x80)
    return;

  scancode = SET1_SCANCODES[scancode];
  if(next_is_up_)
  {
    next_is_up_ = 0;
    modifyKeyboardStatus(scancode | 0x80);
    return;
  }

  if (extended_scancode == 0xE0)
  {
    if (scancode == 0x2A || scancode == 0x36 || scancode >= E0_BASE)
    {
      extended_scancode = 0;
    }

    scancode = E0_KEYS[scancode];
  }
  else if (extended_scancode == 0xE1 && scancode == 0x1D)
  {
    extended_scancode = 0x100;
  }
  else if (extended_scancode == 0x100 && scancode == 0x45)
    scancode = E1_PAUSE;

  extended_scancode = 0;

  if (scancode == 0xFF || scancode == 0xFA || scancode == 0xFE || scancode == 0x00) // non parsable codes, ACK and keyb. buffer errors
  {
    debug(A_KB_MANAGER, "Non-parsable scancode %X \n", scancode);
  }

  if (scancode == 0xE0 || scancode == 0xE1)
  {
    extended_scancode = scancode;
  }

  modifyKeyboardStatus(scancode);
  setLEDs(); // setting the leds
  if (main_console)
  {
    keyboard_buffer_.put(scancode); // put it inside the buffer
  }

}
Ejemplo n.º 22
0
//control passed here from bootTestCrt.S after creating stack
int boot(){	
	uint32 *STORE1 = (uint32 *)0x4090002c;	//Use RTC alarms as
	uint32 *STORE2 = (uint32 *)0x40900030;	// storage for debugging
	
	int i,j;

	*STORE1 = 0x98765;
	
	setupLEDs();
	setLEDs(GREEN);
		
	uint32 *kernel = (uint32 *)(RAM_START + KERNEL_OFFSET);
	uint32 *tags = (uint32 *)(RAM_START + TAGS_OFFSET);

	uint32 cs;
	
	setLEDs(GREEN);

	//now we need to copy the kernel code to where it likes to be
	cs = copyMem((uint32*)kernel_start,kernel, (kernel_end - kernel_start));

	if(cs != KERN_CHECKSUM)
		error(5,0);

	setup_tags(tags);

	setLEDs(BLUE);

	uint32 mtype = MACH_TYPE_HPIPAQ214;

	void (*theKernel)(uint32 zero, uint32 mtype, uint32 *tags);
	theKernel = (void (*)(uint32, uint32, uint32 *))kernel; /* set the kernel address */

	theKernel(0, mtype, tags);    /* jump to kernel with register set */

death:	__asm("nop");
	goto death;

}
Ejemplo n.º 23
0
/* called by timer every 20ms */
void adjustLights()
{
    if (!pauseLED)
    {   if (stepIndex<stepCount)
        {   stepIndex++;
            float v[LEDS];
            morph(v);
            for (int i=0; i<LEDS; i++)
            {   v[i]+=offset[i];
            }
            setLEDs(v);
        }
    }
}
Ejemplo n.º 24
0
void procData()
{
	procTimer2.stop(); //Stop the delay timer
	String response = thisFrame.getResponseString();
	if (response.length() <1)
		Serial.println("Sensor value wasn't returned.");

	// Split the response into elements using ":" as a separator character (ascii 58)
	int a = splitString(response, 58, colours);
	// Calculate and scale colour values
	normaliseValues();
	// Set the PWM values
	setLEDs();
}
Ejemplo n.º 25
0
void testLPABallon( void )
{
	initLCD(); 		 // Initialize the LC-Display (LCD)
	showScreenLCD("################", "################");
	mSleep(500);
	showScreenLCD("Tst LPA BallonLIB", "versie 29jun15");
	mSleep(500);
	// ---------------------------------------
	setLEDs(0b0000); // All LEDs off!

	// This text is fixed on the LCD. Only the
	// key and ADC values are changed later on!
	showScreenLCD("hoogte: ", "VS:       BS:");
	while(true) 
	{
      // read some simulations parameter values and display them on teh LCD
      showSimParams();
      // Check if a key is pressed:
      uint8_t key = getPressedKeyNumber(); 
      // This function returns a 0 if no key is pressed and the key number from 1 to 5 otherwise.
      if(key) // If a key is pressed... (key != 0)
      {
         // ... and depending on which key was pressed, we 
         // call some library functions related to the burner and the valve.

         switch(key)
         {
            case 1: 
               Balloon_set_burner(ON);
               break;
            case 2:
               Balloon_set_burner(OFF);
               break;
            case 3: 
               Balloon_set_valve(OPEN);
               break;
            case 4: 
               Balloon_set_valve(CLOSED);
               break;
            case 5: 
               break;
         }
         // ... wait until the key is released again...
         while(getPressedKeyNumber())
         {
            showSimParams(); // use busy waiting for polling keys
         }
      }
	}
}
Ejemplo n.º 26
0
/**
 * A small running light that uses Stopwatch 1 for timing.
 * The running light is updated every 100ms (= refresh frequency of 10Hz)
 */
void task_LEDs(void)
{
	static uint16_t runningLight = 1; 
	if(getStopwatch1() > 100) // have we reached AT LEAST 100ms = 0.1s?
	{
		// Update chaselight:
		setLEDs(runningLight); 	
		runningLight <<= 1; 
		if(runningLight > 32) 
			runningLight = 1;
			
		 // Don't forget to reset the stopwatch to 0 again:
		setStopwatch1(0);   
	}
}
Ejemplo n.º 27
0
int main(void)
{
	initRP6M256();  
	initLCD();
    
	writeString_P_WIFI("\n\nRP6 CONTROL M32 I2C Master Example Program!\n"); 
    writeString_P_WIFI("\nMoving...\n"); 

	// ---------------------------------------
	WDT_setRequestHandler(watchDogRequest); 
	
	// ---------------------------------------
	// Init TWI Interface:
	I2CTWI_initMaster(100);  
	I2CTWI_setRequestedDataReadyHandler(I2C_requestedDataReady);
	I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);


	setLEDs(0b1111);

	showScreenLCD("################", "################");
	mSleep(1000);
	showScreenLCD("I2C-Master", "Movement...");
	mSleep(1000);
	setLEDs(0b0000);
	
	// ---------------------------------------
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_ACS_POWER, ACS_PWR_MED);
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT, true);
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT_RQ, true);

	while(true) 
	{ 
		setLEDs(0b1001); 
		showScreenLCD("MOVE", "FWD");
		writeString_P_WIFI("\nMoving Forwards...\n"); 
		move(70, FWD, DIST_MM(300), BLOCKING);
		setLEDs(0b1000); 
		showScreenLCD("ROTATE", "LEFT");
		writeString_P_WIFI("\nRotating Left...\n"); 
		rotate(60, LEFT, 180, BLOCKING);
		setLEDs(0b1001); 
		showScreenLCD("MOVE", "FWD");
		writeString_P_WIFI("\nMoving Forwards...\n"); 
		move(70, FWD, DIST_MM(300), BLOCKING);
		setLEDs(0b0001); 
		showScreenLCD("ROTATE", "RIGHT");
		writeString_P_WIFI("\nRotating Right...\n"); 
		rotate(60, RIGHT, 180, BLOCKING);
	}
	return 0;
}
void ApplePS2Keyboard::initKeyboard()
{
    //
    // Reset the keyboard to its default state.
    //

    PS2Request * request = _device->allocateRequest();
    if (request)
    {
        request->commands[0].command = kPS2C_WriteDataPort;
        request->commands[0].inOrOut = kDP_SetDefaults;
        request->commands[1].command = kPS2C_ReadDataPortAndCompare;
        request->commands[1].inOrOut = kSC_Acknowledge;
        request->commandsCount = 2;
        _device->submitRequestAndBlock(request);
        _device->freeRequest(request);
    }
    
    // start out with all keys up
    bzero(_keyBitVector, sizeof(_keyBitVector));
    
    //
    // Initialize the keyboard LED state.
    //

    setLEDs(_ledState);

    //
    // Enable the keyboard clock (should already be so), the keyboard IRQ line,
    // and the keyboard Kscan -> scan code translation mode.
    //

    setCommandByte(kCB_EnableKeyboardIRQ | kCB_TranslateMode,
            kCB_DisableKeyboardClock);

    //
    // Finally, we enable the keyboard itself, so that it may start reporting
    // key events.
    //
    
    setKeyboardEnable(true);
}
Ejemplo n.º 29
0
/**
 * Here we react on any obstacle that we may hit. 
 * If any of the bumpers detects an obstacle, we stop the motors and start
 * LED blink.
 */
void bumpersStateChanged(void) {
    
    if (bumper_left || bumper_right) {
        
        stop();
        moveAtSpeed(0, 0); // stop moving!
        
        setLEDs(0b111111);
        updateStatusLEDs();
        mSleep(500);
        
        while (true) {
            statusLEDs.LED2 = !statusLEDs.LED2; // Toggle LED bit in LED shadow register... 
            statusLEDs.LED5 = !statusLEDs.LED5;
            updateStatusLEDs();
            mSleep(500);
            task_RP6System();
        }
    }
}
Ejemplo n.º 30
0
/**
 * Show a running light...
 */
void runningLight(void)
{
	static uint8_t runLight = 1; 
	static uint8_t dir;  
	
	if(getStopwatch1() > 100)
	{
		setLEDs(runLight); 
	
		if(dir == 0)
			runLight <<= 1; 
		else
			runLight >>= 1;
			
		if(runLight > 7 ) 
			dir = 1;			
		else if (runLight < 2 ) 
			dir = 0;
		
		setStopwatch1(0);
	}