Trammell Hudson avatar Trammell Hudson committed 2c87479 Draft

Enable start page 0 on LCD and display typed text

Comments (0)

Files changed (1)

 	lcd_command(0x00, 0);
 	_delay_ms(1);
 
+	// Display start page 0
+	lcd_command(0x3E, 0);
+	_delay_ms(1);
+
 	out(pin, 0);
 }
 
 
 
 static void
+lcd_clear(void)
+{
+	for (uint8_t j = 0 ; j < 8 ; j++)
+		for (uint8_t i = 0 ; i < 40 ; i++)
+			lcd_char(i, j, ' ');
+}
+
+
+static void
 redraw(void)
 {
 	static uint8_t val;
 	redraw();
 
 	uint8_t last_key = 0;
+	uint8_t cur_row = 0;
+	uint8_t cur_col = 0;
 
 	char buf[16];
 	int off = 0;
 		{
 			last_key = key;
 			if (key == '\n')
+			{
+				usb_serial_putchar('\n');
 				usb_serial_putchar('\r');
-			usb_serial_putchar(key);
+				cur_row = (cur_row + 1) % 8;
+				cur_col = 0;
+			} else
+			if (key == '\e')
+			{
+				lcd_clear();
+				cur_row = cur_col = 0;
+			} else {
+				usb_serial_putchar(key);
+				lcd_char(cur_col, cur_row, key);
+				if (++cur_col == 40)
+				{
+					cur_row = (cur_row + 1) % 8;
+					cur_col = 0;
+				}
+			}
 		}
 
 		if (bit_is_clear(TIFR0, OCF0A))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.