Defines | Functions

lh155.h File Reference

low-level display functions More...

Go to the source code of this file.

Defines

#define HL_LCD_WIDTH   (240)
 display width in pixel
#define HL_LCD_HEIGHT   (64)
 display height in pixel
#define HL_LCD_WIDTH_BYTES   (HL_LCD_WIDTH/8)
 display width in bytes
#define HL_LCD_PARAM_MASK   (0x0F)
 Sharp LH155 LCD Controller Commands.
#define HL_LCD_X_ADR_L_CMD   (0x00)
 set X address low nibble
#define HL_LCD_X_ADR_H_CMD   (0x10)
 set X address high bit
#define HL_LCD_Y_ADR_L_CMD   (0x20)
 set Y address low nibble
#define HL_LCD_Y_ADR_H_CMD   (0x30)
 set Y address high nibble
#define HL_LCD_START_LINE_L   (0x40)
 set low nibble of first line to display
#define HL_LCD_START_LINE_H   (0x50)
 set high nibble of first line to display
#define HL_LCD_SET_RE   (0xF1)
 set RE flag
#define HL_LCD_CLR_RE   (0xF0)
 clear RE flag
#define HL_LCD_ALT_LINE_L   (0x60)
 set low nibble of number of alternating reverse line
#define HL_LCD_ALT_LINE_H   (0x70)
 set high nibble of number of alternating reverse line
#define HL_LCD_DISP_CTRL_1   (0x80)
 display control 1
#define HL_LCD_DISP_CTRL_2   (0x90)
 display control 2
#define HL_LCD_INC_CTRL   (0xA0)
 control auto-increment of X or Y address
#define HL_LCD_PWR_CTRL_1   (0xB0)
 power control 1
#define HL_LCD_PWR_CTRL_2   (0xD0)
 power control 2
#define HL_LCD_PWR_CTRL_3   (0xE0)
 power control 3
#define HL_LCD_REG_RD_ADR   (0xC0)
 set address for register read
#define HL_LCD_INC_CTRL_AIM   (0x04)
 auto-increment control
#define HL_LCD_INC_CTRL_AYI   (0x02)
#define HL_LCD_INC_CTRL_AXI   (0x01)

Functions

void HL_LCD_WriteCmd (uint8_t cmd)
 write a command byte to the controller
void HL_LCD_WriteData (uint8_t Data)
 write a data byte to the controller
uint8_t HL_LCD_ReadData (void)
 read a data byte from the controller
void HL_LCD_SetX (uint8_t XAdr)
 set display X address
void HL_LCD_SetY (uint8_t YAdr)
 set display Y address
void HL_LCD_WriteByte (uint8_t XAdr, uint8_t YAdr, uint8_t Data)
 write a data byte to the specified display address
void HL_LCD_Init (void)
 perform initialization for display after power-up
uint8_t hl_pixel_setXY_mask (uint8_t x, uint8_t y)
 set X and Y register and calculate bit mask for pixel
uint8_t hl_pixel_setXY_bit (uint8_t x, uint8_t y)
 set X and Y register and calculate bit number for pixel
void HL_LCD_PowerOff (void)
 Switch display off to save power.
void HL_LCD_PowerOn (void)
 Switch display on after power save.

Detailed Description

low-level display functions

This file defines constants and low-level access functions for a LCD display using the Sharp LH155 controller chip

The display is organized into 64 horizontal lines, each line contains 32 bytes with pixel data. The last two bytes of these are not displayed, but can be addressed using the LH155 registers. We did not test if they can be used for storage.


Define Documentation

#define HL_LCD_DISP_CTRL_1   (0x80)

display control 1

RE==0: set Shift, Segment display on/off, All on/off, Graphics display on/off

RE==1: set Segments external source, Segment source mode

#define HL_LCD_DISP_CTRL_2   (0x90)

display control 2

set Graphic display normal/reverse, n-line reverse on/off, data for display swap, Segment output normal/reverse

#define HL_LCD_INC_CTRL_AIM   (0x04)

auto-increment control

auto-increment mode: when unset, increment after every data access; when set, only increment after write access

#define HL_LCD_INC_CTRL_AXI   (0x01)

set auto-increment for X

#define HL_LCD_INC_CTRL_AYI   (0x02)

set auto-increment for Y

#define HL_LCD_PARAM_MASK   (0x0F)

Sharp LH155 LCD Controller Commands.

The command is specified in the high nibble of the command byte, the lower nibble contains parameters (if any).

bits used as parameter to command


Function Documentation

uint8_t HL_LCD_ReadData ( void   ) 

read a data byte from the controller

Remember that the controller needs a read cycle to put data into its output register, therefore the first byte read after setting X or Y address is a dummy byte and the second byte is usable data

void HL_LCD_WriteByte ( uint8_t  XAdr,
uint8_t  YAdr,
uint8_t  Data 
)

write a data byte to the specified display address

Parameters:
XAdr X address (in bytes!)
YAdr Y address (in lines)
Data data byte to write
uint8_t hl_pixel_setXY_bit ( uint8_t  x,
uint8_t  y 
)

set X and Y register and calculate bit number for pixel

hl_pixel_setXY_bit() is called by hl_pixel_setXY_mask(), to perform the address setting steps in the controller. It returns the bit number which will be changed

Parameters:
x X position (in pixels)
y Y position
Returns:
bit number
uint8_t hl_pixel_setXY_mask ( uint8_t  x,
uint8_t  y 
)

set X and Y register and calculate bit mask for pixel

hl_pixel_setXY_mask() prepares the controller to access a pixel at the specified address and returns a bitmask suitable in a read-modify-write operation. The mask contains a 1 at the bit position which is addressed.

Parameters:
x X position (in pixels)
y Y position
Returns:
bitmask