Im trying to make a function to call an exact address on an LCD but the switch() constantly defers to default.
It should take the Row address from the switch() table and then add the column number to it and then goto that address.
C:
#include <xc.h>
#include "lcd.h"
#include "lcd_extra.h"
// These are the line addresses for most 4x20 LCDs.
#define LCD_LINE_1_ADDRESS 0x00
#define LCD_LINE_2_ADDRESS 0x40
#define LCD_LINE_3_ADDRESS 0x14
#define LCD_LINE_4_ADDRESS 0x54
//----------------------------
void lcd_gotoxy(unsigned int row, unsigned int column) {
unsigned int address;
switch (row) {
case 1:
address = LCD_LINE_1_ADDRESS;
break;
case 2:
address = LCD_LINE_2_ADDRESS;
break;
case 3:
address = LCD_LINE_3_ADDRESS;
break;
case 4:
address = LCD_LINE_4_ADDRESS;
break;
default:
address = LCD_LINE_1_ADDRESS;
break;
}
column -= 1;
address = (row + column);
SetDDRamAddr(address);
}
It should take the Row address from the switch() table and then add the column number to it and then goto that address.