int main()
{
	clock_begin();
	bool success;
	LCD lcd;
	lcd.init();
#if BAUD == 9600
	usart1.init(0x33, true);
#elif BAUD == 38400
	usart1.init(12, true);
#endif
//	usart1.setTriggerTime(50);
	char tmp[32];
	lcd.dis("Zigbee Test");
//	_delay_ms(1000);
	Zigbee zigbee;

	int panid = zigbee.panid();
	// _delay_ms(500);
	int addr = zigbee.addr();
	sprintf(tmp, "PAN: %x\nADDR: %x", panid, addr);
	lcd.clear();
	lcd.dis(tmp);
	while (1);
	{
		_delay_ms(1000);
	}
}
Exemplo n.º 2
0
int main(void){

	
	int x=0;
	int y=0;
	int h=64; 
	
	PosDelta delta;
	MouseData data;
	LCD lcd;
	
	


	lcd.cursorOff();
	lcd << "Synergia 2011";
	lcd.gotoxy(0,1);
	for (a=0; a<16; a++)
	{
		lcd << "*";
		_delay_ms(150);
	}
	lcd.clear();
	
	
	
	{	
		
		mouse >> delta;
		x+=delta.x;
		y+=delta.y;
		
		lcd.gotoxy(0,0);
		lcd << "x:";
		lcd << (int)x/40;
		lcd << "  ";
		
		
		lcd.gotoxy(0,1);
		lcd << "y:";
		lcd << (int)y/40; 
		lcd << "  ";
		
		mouse >> data;
		lcd.gotoxy(6,0);
		lcd << "Qual: ";
		lcd << (int)(unsigned char)data.qual;
		lcd << "     ";
		
		if (!(PINB & (1<<2)))
		{
			x=0;
			y=0;
		}
		
	}
    return 0;
}
Exemplo n.º 3
0
int main() {
    
    Compass testCompass;
    InterfaceKit ifKit;
    LCD lcd;
    Motor motor;
    Spatial spatial;

    CPhidgetManagerHandle device = 0;
    LocalErrorCatcher(
        CPhidgetManager_create(&device));
    
    LocalErrorCatcher(
        CPhidgetManager_set_OnAttach_Handler((CPhidgetManagerHandle) device, 
                                         AttachHandler, NULL));
    
    LocalErrorCatcher(
        CPhidgetManager_set_OnDetach_Handler((CPhidgetManagerHandle ) device,
                                         DetachHandler, NULL));
    
    LocalErrorCatcher(
        CPhidgetManager_set_OnError_Handler((CPhidgetManagerHandle) device,
                                        LibraryErrorHandler, NULL));
    printf("Starting Phidget Playground...\n");
    // Most opening and closing would be via a cast to
    // (CPhidgetHandle), however, this manager has its
    // own handle struct to cast to.
	
	LocalErrorCatcher(
        CPhidgetManager_open((CPhidgetManagerHandle) device));
    
    std::stringstream ss;
    lcd.clear();
	
    for(int i=0;i<1000;i++){
        testCompass.refresh();
        ss << std::fixed <<  std::setprecision(1) << "Heading: " << testCompass.getHeading();
        lcd.setText(ss.str(), 0);
        ss.str(std::string());
        
        ss << std::fixed << std::setprecision(2) << spatial.getAcceleration(AXIS_X) << " " << spatial.getAcceleration(AXIS_Y) << " " << spatial.getAcceleration(AXIS_Z);
        lcd.setText(ss.str(), 1);
        ss.str(std::string());
        
        usleep(100000);
    }

    printf("Press Enter to end...\n");
    getchar();

    LocalErrorCatcher(
        CPhidgetManager_close((CPhidgetManagerHandle) device));
    LocalErrorCatcher(
        CPhidgetManager_delete((CPhidgetManagerHandle) device));

    return 0;
}
Exemplo n.º 4
0
void setup()
{
    ebox_init();
    PB8.mode(OUTPUT_PP);
    lcd.begin(1);
    lcd.clear(RED);
    uart1.begin(9600);
    
    lcd.column_order(1);
    lcd.row_order(1);

    lcd.front_color = RED;
    lcd.back_color = BLACK;
    hsv.s = 1;
    hsv.v = 0.5;
    hsv.h = 0;

    lcd.front_color = RED;
    if(index >= 0x50)index = 0x20;
    for(int i = 0; i < 160; i++){
        hsv.h = i*36/16;
        hsv.h %= 360;
        HSV_to_RGB(hsv,rgb);
        rgb_to_565(rgb,_color[i]);
       lcd.front_color = _color[i];
       lcd.draw_h_line(0,i,128);
    }
    lcd.disp_char8x16(0,0,index++);
    
    lcd.printf(2,2,"1231asddfgdsfgthkfhddddj2nhd");
    

    lcd.front_color = GREEN;
    lcd.draw_circle(50,50,50);
    lcd.draw_line(64,50,r,100);
    

}
Exemplo n.º 5
0
int main()
{
  signal(SIGINT, sig_handler);

  LCD lcd;
  LED led;
  Knob knob;
  Button button;

  int knob_value = 0;
  bool button_value = false;

  char msg[18];
  std::string ip;

  led.on();

  while( (ip = get_ip("wlan0")).length() == 0 )
  {
    lcd.clear();
    lcd.write("looking for IP   ");
    sleep(1);
  }

  led.off();

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.write("My IP Address:");
  lcd.setCursor(1, 0);
  lcd.write(ip.c_str());

  sleep(3);

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.write(ip.c_str());

  while( running == 0 )
  {
    lcd.setCursor(1, 0);
    snprintf(msg, sizeof(msg), "knob: %d%%       ", knob.percent());
    lcd.write(msg);

    if( button.value() )
    {
      led.on();
    }
    else
    {
      led.off();
    }

    if( (button_value != button.value()) || (knob.percent() != knob_value) )
    {
      button_value = button.value();
      knob_value = knob.percent();
   //   post( button_value, knob_value );
    }

    usleep(100000);
  }

  return MRAA_SUCCESS;
}
Exemplo n.º 6
0
void main() {

    // Use 2 lines, 5x8 font for the LCD
    LCD lcd;

    // Initialize the interface.
    lcd.setup();

    // Display on, cursor on, blink on.
    lcd.display_control(true, true, true);

    // Clear display.
    lcd.clear();

    // Set entry mode: increment, no shift.
    lcd.entry_mode(LCD::INCREMENT, false);

    // Write the character 'H'.
    lcd.put_char('H');

    // Write the character 'i'.
    lcd.put_char('i');

    // Write a string.
    lcd.put_string(", Mom!");

    // Read the first character on the first line
    // and copy it to the second line.
    // This is a bit complicated.

    // 1. Set the DDRAM address to the beginning of the first line.
    lcd.set_ddram_addr(0x00);

    // 2. Read the character.
    uint8_t c = lcd.read_char();

    // 3. Set the DDRAM address to the beginning of the second line.
    lcd.set_ddram_addr(0x40);

    // 4. Write the character.
    lcd.put_char(c);

    // Some debugging: print the hex value of the character read.
    {
        uint16_t chars = byte_to_hex(c);
        char a = chars >> 8;
        char b = chars & 0xff;
        lcd.put_char(a);
        lcd.put_char(b);
        lcd.put_char(' ');
    }

    // Some more debugging: print the expected hex value.
    {
        uint16_t chars = byte_to_hex('H');
        char a = chars >> 8;
        char b = chars & 0xff;
        lcd.put_char(a);
        lcd.put_char(b);
        lcd.put_char(' ');
    }

    // Create a custom character glyph and use it.
    // Borrowed the glyph from the CustomCharacter
    // Arduino sketch.
    uint8_t heart[8] = {
            0b00000,
            0b01010,
            0b11111,
            0b11111,
            0b11111,
            0b01110,
            0b00100,
            0b00000
    };

    // Set the first glyph in CGRAM.
    lcd.set_cgram_addr(0x00);
    for (uint8_t i = 0; i < 8; ++i)
        lcd.put_char(heart[i]);

    // Position the cursor right after "Hi, mom!".
    lcd.set_cursor_pos(0, 9);

    lcd.put_char(0x00);

    // Position the cursor on the end of the third line.
    lcd.set_cursor_pos(2, 19);

    lcd.put_char(0x00);

    // Position the cursor on the end of the fourth line.
    lcd.set_cursor_pos(3, 19);

    lcd.put_char(0x00);
}