# lcd_one_dot_matrix

LCD library for LCDs with just one big dot matrix for use as simple character device

Author | Pavel Milanes Costa, Copyright © 2015, all rights reserved. pavelmc@gmail.com
Adapted-by |
Compiler | >=2.4p3

Description

    	This modules have the (same) following pinouts:

    	1		GND		Ground or 0.0 volts
    	2		VDD		(2.7 to 5.5 V)
    	3		VEE		(-1.0 to -2.3V) This is used for display contrast, see datasheet !!!
    	4		A0		Instruction (off) / Data (on) selector
    	5		R/W		Read/Write, tie it to GND, this lib doesn't read.
    	6		E3		Enable chip 3
    	7		D0		bit 0 data
    	8		D1		bit 1 data
    	9		D2		bit 2 data
    	10		D3		bit 3 data
    	11		D4		bit 4 data
    	12		D5		bit 5 data
    	13		D6		bit 6 data
    	14		D7		bit 7 data
    	15		LED K	Backlight Led Cathode (hole, but no pin on)
    	16		LED A	Backlight Led Anode (hole, but no pin on)
    	17		E1		Enable chip 1
    	18		E2		Enable chip 2

    	This LCD need 12 pins from your PIC and will eat about ~1k more of your memory over
    	the classic lcd library, plus some data banks, and only implement charcater capability
    	no graphs here.

    	As per the datasheet the command set of this lib is compatible with this chips:
    	AX6120, AX6121, SBN1661, SBN0080, SED1520, SED1521 and SED1522
    	others can be supported.

    	You must define a full 8 bit dataport for data communication

    		alias lcd_dataport 				is portB

    		Also need to define the handshake and enable pins

    		alias lcd_a0				is pin_C0
    		alias lcd_e1				is pin_C1
    		alias lcd_e2				is pin_C2
    		alias lcd_e3				is pin_C3

    	You need to set all this pins/ports to 'output' direction

    	This lib asume your hardware use 3 chips to manage the 160 columns in a 40+80+40 splits,
    	then, when used in character mode (not graphics) you can use a 26x4 area (pretty good!!!)
    	so this size is hard coded on the lib code. If your hardware use other split or size
    	of the matrix: copy this file, adapt it, create another lib and submmit it to jallib project

    	Then include the library

    		include lcd_one_dot_matrix.jal

    	Call the init of the lib and you are rocking now

    		lcd_init()

Sources

    Datasheets of two type of GLCD modules & dot matrix controllers
    	- DATA IMAGE PY163210 REV:A (thanks to sally Kao at DATA IMAGE enterprise)
    	- XIAMEN OCULAR GDM16032D VER1.0 (from website)
    	- Datasheets for the SBN1661, AX6120 and SED1520 dot matrix LCD controllers

    	As usual nowdays, a variety of sources on the internet...

Dependencies

- delay
- glcd_5x7_font

## Summary

### Global variables/contants

- `const LCD_CHARS = 26`
- `const byte _CMD_PAGE_MASK = 0b1011_1000`
- `const byte _CMD_STATIC_OFF = 0b1010_0101`
- `var byte _lcd_curr_col`
- `var byte _lcd_curr_row`
- `const byte _CMD_STATIC_ON = 0b1010_0100`
- `const byte _CMD_DUTY_32 = 0b1010_1001`
- `const byte _CMD_RESET = 0b1110_0010`
- `const LCD_ROWS = 4`
- `const byte _CMD_LINE_START_0 = 0b1100_0000`
- `const byte _CMD_ON = 0b1010_1111`
- `var bit _lcd_le1`
- `var bit _lcd_le2`
- `var bit _lcd_le3`
- `const byte _CMD_ADC_FWD = 0b1010_0000`
- `const byte _CMD_OFF = 0b1010_1110`

### Procedures

- `lcd_clear_row(byte in r)`
- `lcd_init()`
- `lcd_cursor_position(byte in line, byte in pos)`
- `lcd_write_char(byte in data)`
- `lcd_clear_screen()`
- `lcd'put(byte in data)`

Private

- `_lcd_set_column(byte in col)`
- `_lcd_on(bit in start)`
- `_lcd_set_page(byte in page)`
- `_lcd_send_cmd(byte in sd, bit in d)`
- `_lcd_write(byte in sd)`

### Functions

## API details

### Global variables/contants

- `const LCD_CHARS = 26`

  No documentation found

- `const byte _CMD_PAGE_MASK = 0b1011_1000`

      Page selecion mask

- `const byte _CMD_STATIC_OFF = 0b1010_0101`

      Disable the segments outputs

- `var byte _lcd_curr_col`

  No documentation found

- `var byte _lcd_curr_row`

      current position of the row and col

- `const byte _CMD_STATIC_ON = 0b1010_0100`

      Enable the segments outputs

- `const byte _CMD_DUTY_32 = 0b1010_1001`

      This config use 32 lines (olso 1/16 lines)

- `const byte _CMD_RESET = 0b1110_0010`

      Reset by software, this don'touch display image

- `const LCD_ROWS = 4`

      This lib use a 160x32 dot matrix, in character mode you can use 4 rows and 26 chars
      Whit this arrangement you have 4 columns(dots) to spare, this lib place 2 before and left 2
      after the character block to center the data on the display.

- `const byte _CMD_LINE_START_0 = 0b1100_0000`

      Chip start line, where? line 0

- `const byte _CMD_ON = 0b1010_1111`

      Chip on

- `var bit _lcd_le1`

      load enable flags to set

- `var bit _lcd_le2`

  No documentation found

- `var bit _lcd_le3`

  No documentation found

- `const byte _CMD_ADC_FWD = 0b1010_0000`

      Default command set for the AX6120/SB1661/SED1520 dot matrix controllers

- `const byte _CMD_OFF = 0b1010_1110`

      Chip off

### Procedures

- `lcd_clear_row(byte in r)`

      lcd_clear_row - clears a LCD row

- `lcd_init()`

      lcd_init - initialize the lib

- `lcd_cursor_position(byte in line, byte in pos)`

      lcd_cursor_position - Specify row and column (0-based)

      This is an array of 26 chars on every row and 4 rows
      Any position beyond/out the end of the working area is discarded

- `lcd_write_char(byte in data)`

      lcd_write_char - write one char to LCD

- `lcd_clear_screen()`

      lcd_clear_screen - clears the LCD

- `lcd'put(byte in data)`

      lcd'put - write one char to screen (pseudo var, enables streams)

Private

- `_lcd_set_column(byte in col)`

  No documentation found

- `_lcd_on(bit in start)`

  No documentation found

- `_lcd_set_page(byte in page)`

  No documentation found

- `_lcd_send_cmd(byte in sd, bit in d)`

  No documentation found

- `_lcd_write(byte in sd)`

  No documentation found

### Functions

## Related samples

Here are the list of samples which use this library:

18f25k22 | 18f25k22_lcd_one_dot_matrix.jal