本文整理汇总了C++中LCD::drawLine方法的典型用法代码示例。如果您正苦于以下问题:C++ LCD::drawLine方法的具体用法?C++ LCD::drawLine怎么用?C++ LCD::drawLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LCD
的用法示例。
在下文中一共展示了LCD::drawLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: btConnect
//.........这里部分代码省略.........
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)
{
for(c = 0; c < MENU_NAME_LEN - 1; c++) // Write settings item text //
{
if(bt.device[i].name[c])
lcd.writeChar(3 + c * 6, 8 + 9 * (menuSize - menuScroll), bt.device[i].name[c]);
}
}
menuSize++;
}
if(bt.devices)
{
lcd.drawHighlight(2, 7 + 9 * (menuSelected - menuScroll), 81, 7 + 9 * (menuSelected - menuScroll) + 8);
menu.setBar(TEXT("RETURN"), TEXT("CONNECT"));
}
else
{
lcd.writeStringTiny(6, 20, TEXT("No Devices Found"));
menu.setBar(TEXT("RETURN"), BLANK_STR);
}
menu.setTitle(TEXT("Connect"));
lcd.drawLine(0, 3, 0, 40);
lcd.drawLine(83, 3, 83, 40);
}
lcd.update();
}
return FN_CONTINUE;
}
示例3: 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;
}
示例4: 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;
}