当前位置: 首页>>代码示例>>C++>>正文


C++ LCD类代码示例

本文整理汇总了C++中LCD的典型用法代码示例。如果您正苦于以下问题:C++ LCD类的具体用法?C++ LCD怎么用?C++ LCD使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LCD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: menu

void menu() {

	//Add your code here
	//You may add more functions or volatile variables
	//But DO NOT modify anything else

	//Press S1 to display the first group member's student id
	//Press S1 again to display the second group member's student id
	//Debouncing need to be done for S1 to work properly
	//16 char for each row LCD
	char row1[]= "F12  M67  B12   ";
	char row2[]= "                ";


	char MidS= sensor.middle_sensor;
	char MidL= MidS & 0xF0;
	MidL= MidL>>4;
	char MidR= MidS & 0x0F;

	char FrontS= sensor.front_sensor;
	char FrontL= FrontS & 0xF0;
	FrontL= FrontL>>4;
	char FrontR= FrontS & 0x0F;

	char BackS= sensor.back_sensor;
	char BackL= BackS & 0xF0;
	BackL= BackL>>4;
	char BackR= BackS & 0x0F;


	//////////////////////////////////convert to ascii number
	if ( MidL <10 )
	{
		MidL += 0x30;
	}
	else
	{
		MidL +=55;
	}

	if (MidR <10)
	{
		MidR += 0x30;
	}
	else
	{
		MidR +=55;
	}

	row1[6]= MidL;
	row1[7]= MidR;

	////////////////////////// c TO d, 3 TO b/f
	if ( FrontL <10 )
	{
		FrontL += 0x30;
	}
	else
	{
		FrontL +=55;
	}

	if (FrontR <10)
	{
		FrontR += 0x30;
	}
	else
	{
		FrontR +=55;
	}

	row1[1]= FrontL;
	row1[2]= FrontR;
	//////////////////////////
	if ( BackL <10 )
	{
		BackL += 0x30;
	}
	else
	{
		BackL +=55;
	}

	if (BackR <10)
	{
		BackR += 0x30;
	}
	else
	{
		BackR +=55;
	}

	row1[11]= BackL;
	row1[12]= BackR;



	lcd.setLineOne(row1);
	row2[0] = condition + 48;
	row2[2] = nextCondition + 48;
//.........这里部分代码省略.........
开发者ID:mayyuen318,项目名称:may,代码行数:101,代码来源:TowerBuilder_student.cpp

示例2: Pad

void MenuItem::Pad(LCD& lcd, byte cols, size_t written) const {
	while (written < cols) {
		written += lcd.print(F(" "));
	}
}
开发者ID:michaelkoetter,项目名称:ArduinoLapse,代码行数:5,代码来源:Menu.cpp

示例3: main

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;
}
开发者ID:stejsoftware,项目名称:Edison-Demo,代码行数:65,代码来源:main.cpp

示例4: main

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);
}
开发者ID:,项目名称:,代码行数:96,代码来源:

示例5: Render

void ConfigMenuItem::Render(LCD& lcd, byte cols, byte rows) const {
	size_t size = 0;
	long value = m_value->Get();

	// render label
	lcd.setCursor(0, 0);
	size = lcd.print(m_label);
	Pad(lcd, cols, size);

	// render value
	lcd.setCursor(2, 1);
	size = m_value->PrintValue(lcd);
	Pad(lcd, cols - 4, size);

	// render navigation
	lcd.setCursor(0, 1);
	if (value > m_value->GetMin()) {
		lcd.print(ARROW_LEFT);
	} else {
		lcd.print(F(" "));
	}
	lcd.print(F(" "));

	lcd.setCursor(cols - 2, 1);
	lcd.print(F(" "));
	if (value < m_value->GetMax()) {
		lcd.print(ARROW_RIGHT);
	} else {
		lcd.print(F(" "));
	}
}
开发者ID:michaelkoetter,项目名称:ArduinoLapse,代码行数:31,代码来源:Menu.cpp

示例6: main

int main(void)
{

	POWEROFF();
	delayU(100);
	POWERUP();

	lcd.setLineOne("Welcome to");
	lcd.setLineTwo("TowerBuilder");
	sei();        //Enable global interrupt

	while(1)
	{
		//Send 1 character to LCD if LCD is ready
		if(lcd.ready())
		lcd.print();

		//Task scheduler
		if(taskDone == FALSE) {

			switch(taskNumber++) {

				case 0:
				button.readButtons();
				menu();
				break;

				case 1:
				adc.convertPOT();
				break;

				case 2:
				sensor.readSensors();
				break;

				case 3:
				first();
				break;

				case 4:

				break;

				case 5:

				break;

				case 6:

				break;

				default:
				taskNumber = 0;
				break;
			}

			taskDone = TRUE;

			//Update servo's channel after each task finished
			while(updateChannel == FALSE);
			servo.servoPWM();
			updateChannel = FALSE;

		}
	}
}
开发者ID:mayyuen318,项目名称:may,代码行数:66,代码来源:TowerBuilder_student.cpp

示例7: displayTimerStatus

void displayTimerStatus(uint8_t remote_system)
{
	timer_status stat;
	char buf[6], l, *text;
	uint16_t val;

	if(remote_system)
	{
		stat = remote.status;
		l = remote.running;
	}
	else
	{
		stat = timer.status;
		l = timer.running;
	}
	//
	//06 Time remaining
	//12 Time to next photo
	//18 Next bulb
	//24 Status
	//30 Battery %

	if(l)
	{
		if(stat.mode & TIMELAPSE)
		{
			val = stat.photosTaken;
			int_to_str(val, buf);
			text = buf;
			l = lcd.measureStringTiny(text);
			lcd.writeStringTiny(80 - l, 6 + SY, text);
			lcd.writeStringTiny(3, 6 + SY, TEXT("Photos:"));

			val = stat.photosRemaining;
			if(stat.infinitePhotos == 0)
			{
				int_to_str(val, buf);
				text = buf;
				l = lcd.measureStringTiny(text);
				lcd.writeStringTiny(80 - l, 12 + SY, text);
				lcd.writeStringTiny(3, 12 + SY, TEXT("Photos rem:"));
			}
			else
			{
				lcd.writeStringTiny(3, 12 + SY, TEXT("Infinite Photos"));
			}

			val = stat.nextPhoto;
			int_to_str(val, buf);
			text = buf;
			l = lcd.measureStringTiny(text);
			lcd.writeStringTiny(80 - l, 18 + SY, text);
			lcd.writeStringTiny(3, 18 + SY, TEXT("Next Photo:"));
		}
	}
	
	text = stat.textStatus;
	l = lcd.measureStringTiny(text);
	lcd.writeStringTiny(80 - l, 24 + SY, text);
	lcd.writeStringTiny(3, 24 + SY, TEXT("Status:"));

	if(remote_system)
		val = (uint16_t) remote.battery;
	else
		val = (uint16_t) battery_percent;
	int_to_str(val, buf);
	text = buf;
	l = lcd.measureStringTiny(text);
	lcd.writeStringTiny(80 - l, 30 + SY, text);
	lcd.writeStringTiny(3, 30 + SY, TEXT("Battery Level:"));

}
开发者ID:dummey,项目名称:TimelapsePlus-Firmware,代码行数:73,代码来源:tlp_menu_functions.cpp

示例8: batteryStatus

volatile char batteryStatus(char key, char first)
{
//	uint16_t batt_high = 645;
//	uint16_t batt_low = 540;
	static uint8_t charging;
	char stat = battery_status();

	if(first)
	{
		charging = (stat > 0);
	}

//	unsigned int batt_level = battery_read_raw();

#define BATT_LINES 36

//	uint8_t lines = ((batt_level - batt_low) * BATT_LINES) / (batt_high - batt_low);
	uint8_t lines = (uint8_t)((uint16_t)battery_percent * BATT_LINES / 100);

	if(lines > BATT_LINES - 1 && stat == 1)
		lines = BATT_LINES - 1;

	if(lines > BATT_LINES || stat == 2)
		lines = BATT_LINES;

	lcd.cls();

	char* text;

	text = getChargingStatus();

	char l = lcd.measureStringTiny(text) / 2;

	if(battery_status())
		lcd.writeStringTiny(41 - l, 31, text);

	// Draw Battery Outline //
	lcd.drawLine(20, 15, 60, 15);
	lcd.drawLine(20, 16, 20, 27);
	lcd.drawLine(21, 27, 60, 27);
	lcd.drawLine(60, 16, 60, 19);
	lcd.drawLine(60, 23, 60, 26);
	lcd.drawLine(61, 19, 61, 23);

	// Draw Battery Charge //
	for(uint8_t i = 0; i <= lines; i++)
	{
		lcd.drawLine(22 + i, 17, 22 + i, 25);
	}

	menu.setTitle(TEXT("Battery Status"));
	menu.setBar(TEXT("RETURN"), BLANK_STR);
	lcd.update();

	if(stat == 0 && charging)
	{
		clock.awake();
		return FN_CANCEL; // unplugged
	}
	if(key == FL_KEY)
		return FN_CANCEL;

	return FN_CONTINUE;
}
开发者ID:dummey,项目名称:TimelapsePlus-Firmware,代码行数:64,代码来源:tlp_menu_functions.cpp

示例9: sysStatus

volatile char sysStatus(char key, char first)
{
	char* text;

	if(first)
	{
	}

	lcd.cls();

	text = getChargingStatus();

	char l = lcd.measureStringTiny(text);

	lcd.writeStringTiny(80 - l, 6 + SY, text);
	lcd.writeStringTiny(3, 6 + SY, TEXT("USB:"));

	char buf[6];
	uint16_t val;

	val = (uint16_t)battery_percent;
	int_to_str(val, buf);
	text = buf;
	l = lcd.measureStringTiny(text);
	lcd.writeStringTiny(80 - l, 12 + SY, text);
	lcd.writeStringTiny(3, 12 + SY, TEXT("Battery:"));

	val = hardware_freeMemory();
	int_to_str(val, buf);
	text = buf;
	l = lcd.measureStringTiny(text);
	lcd.writeStringTiny(80 - l, 18 + SY, text);
	lcd.writeStringTiny(3, 18 + SY, TEXT("Free RAM:"));

	val = clock.seconds;
	int_to_str(val, buf);
	text = buf;
	l = lcd.measureStringTiny(text);
	lcd.writeStringTiny(80 - l, 24 + SY, text);
	lcd.writeStringTiny(3, 24 + SY, TEXT("Clock s:"));

	val = clock.ms;
	int_to_str(val, buf);
	text = buf;
	l = lcd.measureStringTiny(text);
	lcd.writeStringTiny(80 - l, 30 + SY, text);
	lcd.writeStringTiny(3, 30 + SY, TEXT("Clock ms:"));

	menu.setTitle(TEXT("Sys Status"));
	menu.setBar(TEXT("RETURN"), BLANK_STR);
	lcd.update();
	_delay_ms(10);

	if(key == FL_KEY || key == LEFT_KEY)
		return FN_CANCEL;

	return FN_CONTINUE;
}
开发者ID:dummey,项目名称:TimelapsePlus-Firmware,代码行数:58,代码来源:tlp_menu_functions.cpp

示例10: cableReleaseRemote

volatile char cableReleaseRemote(char key, char first)
{
	static char status; //, cable;

	if(first)
	{
		status = 0;
		lcd.cls();
		menu.setTitle(TEXT("BT Cable Remote"));
		menu.setBar(TEXT("Bulb"), TEXT("Photo"));
		lcd.update();
		remote.set(REMOTE_BULB_END);
	}

	if(key == FL_KEY)
	{
		if(status != 1)
		{
			status = 1;
			lcd.eraseBox(8, 18, 8 + 6 * 11, 26);
			lcd.writeString(8, 18, TEXT("(BULB OPEN)"));
			remote.set(REMOTE_BULB_START);
			lcd.update();
		} else
		{
			status = 0;
			lcd.eraseBox(8, 18, 8 + 6 * 11, 26);
			remote.set(REMOTE_BULB_END);
			lcd.update();
		}
	}
	else if(key == FR_KEY && status != 1)
	{
		status = 0;
		lcd.eraseBox(8, 18, 8 + 6 * 11, 26);
		remote.set(REMOTE_CAPTURE);
		lcd.update();
	}
	else if(key != 0)
	{
		status = 0;
		lcd.eraseBox(8, 18, 8 + 6 * 11, 26);
		remote.set(REMOTE_BULB_END);
		lcd.update();
	}

	if(key == LEFT_KEY || !remote.connected)
	{
		remote.set(REMOTE_BULB_END);
		return FN_CANCEL;
	}
	return FN_CONTINUE;
}
开发者ID:dummey,项目名称:TimelapsePlus-Firmware,代码行数:53,代码来源:tlp_menu_functions.cpp

示例11: shutterLagTest

volatile char shutterLagTest(char key, char first)
{
//  static uint8_t cable;
	uint16_t start_lag, end_lag;

	if(first)
	{
//    cable = 0;
		lcd.cls();
		menu.setTitle(TEXT("Shutter Lag Test"));
		menu.setBar(TEXT("Test 1"), TEXT("Test 2 "));
		lcd.update();
	}

	if(key == FL_KEY || key == FR_KEY)
	{
		lcd.eraseBox(10, 18, 80, 38);
		lcd.writeString(10, 18, TEXT("Result:"));

		ENABLE_SHUTTER;
		ENABLE_MIRROR;
		ENABLE_AUX_PORT;

		_delay_ms(100);

		if(key == FR_KEY)
		{
			MIRROR_UP;
			_delay_ms(1000);
		}

		SHUTTER_OPEN;
		clock.tare();

		while(!AUX_INPUT1)
		{
			if(clock.eventMs() >= 1000)
				break;
		}

		start_lag = (uint16_t)clock.eventMs();

		_delay_ms(50);

		SHUTTER_CLOSE;
		clock.tare();

		while(AUX_INPUT1)
		{
			if(clock.eventMs() > 1000)
				break;
		}

		end_lag = (uint16_t)clock.eventMs();

		lcd.writeNumber(56, 18, start_lag, 'U', 'L');
		lcd.writeNumber(56, 28, end_lag, 'U', 'L');

		lcd.update();
	}

	if(key == LEFT_KEY)
		return FN_CANCEL;

	return FN_CONTINUE;
}
开发者ID:dummey,项目名称:TimelapsePlus-Firmware,代码行数:66,代码来源:tlp_menu_functions.cpp

示例12: usbPlug

volatile char usbPlug(char key, char first)
{
	static char connected = 0;

	if(first || (PTP_Connected != connected) || (PTP_Ready))
	{
		connected = PTP_Connected;
		char exp_name[7];

		if(PTP_Connected)
		{
			if(PTP_Ready)
			{
				lcd.cls();
				lcd.writeString(3, 7,  PTP_CameraModel);
				if(camera.shutterName(exp_name, camera.shutter))
				{
					lcd.writeString(3, 15, exp_name);
				}
				if(camera.apertureName(exp_name, camera.aperture))
				{
					lcd.writeString(3, 23, TEXT("f"));
					lcd.writeString(3+6, 23, exp_name);
				}
				if(camera.isoName(exp_name, camera.iso))
				{
					lcd.writeString(3, 31, TEXT("ISO"));
					lcd.writeString(3+24, 31, exp_name);
				}
				menu.setTitle(TEXT("Camera Info"));
				menu.setBar(TEXT("RETURN"), TEXT("PHOTO"));
				lcd.update();
				connectUSBcamera = 1;

			}
			else
			{
				lcd.cls();
				lcd.writeString(3, 7,  TEXT(" Connected!  "));
				lcd.writeString(3, 15, TEXT(" Retrieving  "));
				lcd.writeString(3, 23, TEXT("   Device    "));
				lcd.writeString(3, 31, TEXT("   Info...   "));
				menu.setTitle(TEXT("Camera Info"));
				menu.setBar(TEXT("RETURN"), BLANK_STR);
				lcd.update();
				connectUSBcamera = 1;

			}
		}
		else
		{
			lcd.cls();
			lcd.writeString(3, 7, TEXT("Plug camera  "));
			lcd.writeString(3, 15, TEXT("into left USB"));
			lcd.writeString(3, 23, TEXT("port...      "));
			lcd.writeString(3, 31, TEXT("             "));
			menu.setTitle(TEXT("Connect USB"));
			menu.setBar(TEXT("CANCEL"), BLANK_STR);
			lcd.update();
			connectUSBcamera = 1;
		}
	}

	if(key == FL_KEY || key == LEFT_KEY)
	{
		if(!PTP_Connected)
			connectUSBcamera = 0;

		return FN_CANCEL;
	}
	else if(key == FR_KEY)
	{
		if(PTP_Ready) camera.capture();
	}
	else if(key == UP_KEY)
	{
		if(PTP_Ready) camera.isoUp(camera.iso);
	}
	else if(key == DOWN_KEY)
	{
		if(PTP_Ready) camera.isoDown(camera.iso);
	}

	return FN_CONTINUE;
}
开发者ID:dummey,项目名称:TimelapsePlus-Firmware,代码行数:85,代码来源:tlp_menu_functions.cpp

示例13: shutter_load

volatile char shutter_load(char key, char first)
{
	static char menuSize;
	static char menuSelected;
	static char itemSelected;
	uint8_t c;
	char ch, update, menuScroll;

	update = 0;

	if(first)
	{
		menuScroll = 0;
		update = 1;
	}

	if(key == UP_KEY && menuSelected > 0)
	{
		menuSelected--;
		update = 1;

	}
	else if(key == DOWN_KEY && menuSelected < menuSize - 1)
	{
		menuSelected++;
		update = 1;
	}

	if(update)
	{
		lcd.cls();

		if(menuSelected > 2)
			menuScroll = menuSelected - 2;

		menuSize = 0;
		char i = 0;

		for(char x = 1; x < MAX_STORED; x++)
		{
			i++;
			ch = eeprom_read_byte((uint8_t*)&stored[i - 1].Name[0]);

			if(ch == 0 || ch == 255)
				continue;

			for(c = 0; c < MENU_NAME_LEN - 1; c++) // Write settings item text //
			{
				if(i >= menuScroll && i <= menuScroll + 5)
				{
					ch = eeprom_read_byte((uint8_t*)&stored[i - 1].Name[c]);

					if(ch == 0) break;

					if(ch < 'A' || ch > 'Z')
						ch = ' ';

					lcd.writeChar(3 + c * 6, 8 + 9 * (menuSize - menuScroll), ch);

					if(menuSize == menuSelected)
						itemSelected = i - 1;
				}
			}
			menuSize++;
		}

		lcd.drawHighlight(2, 7 + 9 * (menuSelected - menuScroll), 81, 7 + 9 * (menuSelected - menuScroll) + 8);

		menu.setTitle(TEXT("Load Saved"));
		menu.setBar(TEXT("CANCEL"), TEXT("LOAD"));

		lcd.drawLine(0, 3, 0, 40);
		lcd.drawLine(83, 3, 83, 40);

		lcd.update();
	}

	switch(key)
	{
	   case FL_KEY:
	   case LEFT_KEY:
		   return FN_CANCEL;

	   case FR_KEY:
	   case RIGHT_KEY:
		   timer.load(itemSelected);
		   menu.message(TEXT("Loaded"));
		   menu.back();
		   menu.select(0);
		   return FN_SAVE;
	}

	return FN_CONTINUE;
}
开发者ID:dummey,项目名称:TimelapsePlus-Firmware,代码行数:94,代码来源:tlp_menu_functions.cpp

示例14: motionTrigger

volatile char motionTrigger(char key, char first)
{
	uint8_t i;
	uint16_t val;
	static uint16_t lv[3];
	static uint8_t threshold = 2;

	if(key == LEFT_KEY)
	{
		if(threshold > 0) threshold--;
		first = 1;
	}
	if(key == RIGHT_KEY)
	{
		if(threshold < 4) threshold++;
		first = 1;
	}

	if(first)
	{
		sleepOk = 0;
		clock.tare();
		lcd.cls();
		menu.setTitle(TEXT("Motion Sensor"));
		menu.setBar(TEXT("RETURN"), BLANK_STR);

		lcd.drawLine(10, 22, 84-10, 22);
		lcd.drawLine(11, 21, 11, 23);
		lcd.drawLine(84-11, 21, 84-11, 23);
		lcd.drawLine(12, 20, 12, 24);
		lcd.drawLine(84-12, 20, 84-12, 24);
		lcd.drawLine(13, 20, 13, 24);
		lcd.drawLine(84-13, 20, 84-13, 24);
		lcd.setPixel(42, 21);
		lcd.setPixel(42+10, 21);
		lcd.setPixel(42-10, 21);
		lcd.setPixel(42+20, 21);
		lcd.setPixel(42-20, 21);

		i = threshold * 10;
		lcd.drawLine(42-3-20+i, 16, 42+3-20+i, 16);
		lcd.drawLine(42-2-20+i, 17, 42+2-20+i, 17);
		lcd.drawLine(42-1-20+i, 18, 42+1-20+i, 18);
		lcd.setPixel(42-20+i, 19);

		lcd.writeStringTiny(19, 25, TEXT("SENSITIVITY"));

		lcd.update();
		lcd.backlight(0);
		hardware_flashlight(0);
		_delay_ms(50);
		for(i = 0; i < 3; i++)
		{
			lv[i] = (uint16_t)hardware_readLight(i);
		}
	}

	uint8_t thres = 4 - threshold + 2;
	if((4 - threshold) > 2) thres += ((4 - threshold) - 1) * 2;

	for(i = 0; i < 3; i++)
	{
		val = (uint16_t)hardware_readLight(i);
		if(clock.eventMs() > 1000 && val > thres && (val < (lv[i] - thres) || val > (lv[i] + thres)))
		{
			clock.tare();
			shutter_capture();
		}
		lv[i] = val;
	}

	if(key == FL_KEY)
	{
		sleepOk = 1;
		lcd.backlight(255);
		return FN_CANCEL;
	}

	return FN_CONTINUE;
}
开发者ID:dummey,项目名称:TimelapsePlus-Firmware,代码行数:80,代码来源:tlp_menu_functions.cpp

示例15: btConnect

volatile char btConnect(char key, char first)
{
	static uint8_t sfirst = 1;
	uint8_t i;
	static uint8_t menuSize;
	static uint8_t menuSelected;
	uint8_t c;
	uint8_t update, menuScroll;
	update = 0;

	if(sfirst)
	{
		menuScroll = 0;
		menuSelected = 0;
		sfirst = 0;

		update = 1;
		if(bt.state != BT_ST_CONNECTED)
		{
			bt.advertise();
			bt.scan();
		}
	}

	switch(key)
	{
		case LEFT_KEY:
		case FL_KEY:
			sfirst = 1;
			if(bt.state != BT_ST_CONNECTED) bt.sleep();
			return FN_CANCEL;

		case FR_KEY:
			if(bt.state == BT_ST_CONNECTED)
			{
				bt.disconnect();
			}
			else
			{
				bt.connect(bt.device[menuSelected].addr);
			}
			break;
	}

	update = 1;
	switch(bt.event)
	{
		case BT_EVENT_DISCOVERY:
			debug(STR("dicovery!\r\n"));
			break;
		case BT_EVENT_SCAN_COMPLETE:
			debug(STR("done!\r\n"));
			if(bt.state != BT_ST_CONNECTED) bt.scan();
			break;
		case BT_EVENT_DISCONNECT:		
			bt.scan();
			break;
		default:
			update = 0;
	}

	bt.event = BT_EVENT_NULL; // clear event so we don't process it twice

	if(first)
	{
		update = 1;
	}

	if(key == UP_KEY && menuSelected > 0)
	{
		menuSelected--;
		update = 1;
	}
	else if(key == DOWN_KEY && menuSelected < menuSize - 1)
	{
		menuSelected++;
		update = 1;
	}

	if(update)
	{
		lcd.cls();

		if(bt.state == BT_ST_CONNECTED)
		{
			menu.setTitle(TEXT("Connect"));
			lcd.writeStringTiny(18, 20, TEXT("Connected!"));
			menu.setBar(TEXT("RETURN"), TEXT("DISCONNECT"));
		}
		else
		{
			if(menuSelected > 2)
				menuScroll = menuSelected - 2;

			menuSize = 0;

			for(i = 0; i < bt.devices; i++)
			{
				if(i >= menuScroll && i <= menuScroll + 4)
				{
//.........这里部分代码省略.........
开发者ID:dummey,项目名称:TimelapsePlus-Firmware,代码行数:101,代码来源:tlp_menu_functions.cpp


注:本文中的LCD类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。