/*--------------------------------------------------------------------------------------------------
  Name         :  NokiaLCD.h
  Description  :  Header file for Nokia 84x48 graphic LCD driver.
--------------------------------------------------------------------------------------------------*/
#ifndef NOKIALCD_H
#define NOKIALCD_H

#include "Platform.h"

#ifndef LINUX
#include "p18f452.h"

// PIN assign
#define LCD_DC_PIN   PORTDbits.RD2
#define LCD_SCE_PIN  PORTDbits.RD3
#define LCD_SDIN_PIN PORTDbits.RD1
#define LCD_SCLK_PIN PORTDbits.RD0
#define LCD_RES_PIN  PORTCbits.RC4

#define LCD_DC_DIR   TRISDbits.TRISD2
#define LCD_SCE_DIR  TRISDbits.TRISD3
#define LCD_SDIN_DIR TRISDbits.TRISD1
#define LCD_SCLK_DIR TRISDbits.TRISD0
#define LCD_RES_DIR  TRISCbits.TRISC4

#endif

// LCD Caracteristics
#define LCD_X_RES                  84
#define LCD_Y_RES                  48
#define LCD_CACHE_SIZE 504 // ((LCD_X_RES * LCD_Y_RES) / 8)

typedef enum {
    LCD_CMD  = 0,
    LCD_DATA = 1
} LcdCmdData;

typedef enum {
    PIXEL_OFF =  0,
    PIXEL_ON  =  1,
    PIXEL_XOR =  2
} LcdPixelMode;

typedef enum {
    FONT_1X = 1,
    FONT_2X = 2
} LcdFontSize;

void LcdInit ( void );
void LcdClear ( void );
void LcdUpdate ( void );
void LcdGotoXY ( UInt8 x, UInt8 y );
void LcdSetCacheIdx ( UInt16 anIndex );
void LcdChr ( LcdFontSize size, UInt8 ch );
void LcdStr ( LcdFontSize size, UInt8 *dataPtr );
void LcdPixel ( UInt8 x, UInt8 y, LcdPixelMode mode );
void LcdLine ( UInt8 x1, UInt8 y1, UInt8 x2, UInt8 y2, LcdPixelMode mode );
void LcdSend ( UInt8 data, LcdCmdData cd );

#endif  //  NOKIALCD_H
