本文整理汇总了C++中LCD::set_ddram_addr方法的典型用法代码示例。如果您正苦于以下问题:C++ LCD::set_ddram_addr方法的具体用法?C++ LCD::set_ddram_addr怎么用?C++ LCD::set_ddram_addr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LCD
的用法示例。
在下文中一共展示了LCD::set_ddram_addr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}