Commits

Trammell Hudson committed 20d86ec Draft

still off by a bit

Comments (0)

Files changed (2)

 )
 {
 	lcd_select(x * 6, y * 8, 1);
-	lcd_command(((y & 3) << 6) | ((x & 7) * 6), 0);
-	//lcd_command(0x00, 0);
+	uint8_t col = 0;
+	if (x < 8)
+		col = (x - 0);
+	else
+	if (x < 16)
+		col = (x - 8);
+	else
+	if (x < 24)
+		col = (x - 16);
+	else
+	if (x < 32)
+		col = (x - 24);
+	else
+	if (x < 40)
+		col = (x - 32);
+	else
+		return;
+
+	uint8_t row = (y % 8);
+	lcd_command(row << 6 | (col*6), 0);
 
 	const char * f = font[c];
 
 }
 
 
-#if 0
-static uint8_t
-lcd_read(void)
-{
-	out(LCD_DI, rs);
-	ddr(LCD_DATA_PORT, 0); // all in
-	out(LCD_RW, 1); // read
-
-	_delay_us(10);
-	out(LCD_EN, 1);
-	_delay_us(100);
-	out(LCD_EN, 0);
-	
-
-	out(LCD_EN, 1);
-	LCD_DATA_PORT = byte;
-	_delay_us(10);
-	out(LCD_EN, 0);
-#endif
-
-
 static uint8_t
 lcd_command(
 	const uint8_t byte,
 
 	out(LCD_EN, 1);
 	LCD_DATA_PORT = byte;
-	_delay_us(100);
+	_delay_us(1);
 	out(LCD_EN, 0);
 
 	// value has been sent, wait a tick, read the status
-	_delay_us(50);
+	_delay_us(5);
 	LCD_DATA_PORT = 0x00; // no pull ups
 	LCD_DATA_DDR = 0x00;
-	_delay_us(25);
+	_delay_us(1);
 	out(LCD_RW, 1); // read
 	out(LCD_DI, 0); // status command
 
-	_delay_us(25);
+	_delay_us(2);
 	
 	out(LCD_EN, 1);
 	_delay_us(1);
 	uint8_t rc = LCD_DATA_PIN;
-	_delay_us(100);
+	_delay_us(1);
 	out(LCD_EN, 0);
 
 	out(LCD_RW, 0); // read
 		lcd_display(i, j, x++);
 #else
 		lcd_char(i, j, x);
-		x = (x + 1) & 0x7F;
 		if (i++ == 40)
 		{
 			i = 0;
+			x = (x + 1) & 0x7F;
 			if (j++ == 8)
 				j = 0;
 		}