#include <string.h>

#include "system.h"
#include "LCD.h"

void showLCD(char * newDisplay, char * display, char row){
	volatile char * LCD_display_ptr = (char *)CHAR_LCD_16X2_BASE;

	if(strcmp(newDisplay, display)){
		int i;
		strcpy(display, newDisplay);

		if (row == 'u'){
			*LCD_display_ptr = LCD_ADDR_U;
		}
		else if (row == 'l'){
			*LCD_display_ptr = LCD_ADDR_L;
		}
		else return;

		for(i = 0; i <16; ++i){
			*(LCD_display_ptr+1) = ' ';
		}

		if (row == 'u'){
			*LCD_display_ptr = LCD_ADDR_U;
		}
		else if (row == 'l'){
			*LCD_display_ptr = LCD_ADDR_L;
		}
		else return;

		while(*display){
			*(LCD_display_ptr+1) = *display;
			++display;
		}
	}
}
