41 lcdParallel*
lcdParallel_init(
char cols,
char lines,
char dotsize,
char rs,
char enable,
42 char d0,
char d1,
char d2,
char d3)
44 return lcdParallel_init8(cols, lines, dotsize, rs, enable, d0, d1, d2, d3, 0, 0, 0, 0);
47 lcdParallel* lcdParallel_init_i2c(
char cols,
char lines,
char dotsize,
char sda,
char scl) {
52 char d0,
char d1,
char d2,
char d3,
53 char d4,
char d5,
char d6,
char d7)
55 lcdParallel* device = (lcdParallel*) malloc(
sizeof(lcdParallel));
56 memset(device, 0,
sizeof(lcdParallel));
59 device->_enable_pin = enable;
61 device->_data_pins[0] = d0;
62 device->_data_pins[1] = d1;
63 device->_data_pins[2] = d2;
64 device->_data_pins[3] = d3;
65 device->_data_pins[4] = d4;
66 device->_data_pins[5] = d5;
67 device->_data_pins[6] = d6;
68 device->_data_pins[7] = d7;
70 if (d4 == d5 & d5 == d6 & d6 == d7) {
71 device->_displayfunction = LCDP_4BITMODE | LCDP_1LINE | LCDP_5x8DOTS;
73 device->_displayfunction = LCDP_8BITMODE | LCDP_1LINE | LCDP_5x8DOTS;
77 dotsize = LCDP_5x8DOTS;
79 dotsize = LCDP_5x10DOTS;
82 device->_displayfunction |= LCDP_2LINE;
85 device->_numlines = lines;
87 device->_row_offsets[0] = 0x00;
88 device->_row_offsets[1] = 0x40;
89 device->_row_offsets[2] = 0x00 + cols;
90 device->_row_offsets[3] = 0x40 + cols;
93 if ((dotsize != LCDP_5x8DOTS) && (lines == 1)) {
94 device->_displayfunction |= LCDP_5x10DOTS;
98 low(device->_enable_pin);
101 low(device->_data_pins[0]);
102 low(device->_data_pins[1]);
103 low(device->_data_pins[2]);
104 low(device->_data_pins[3]);
105 if (device->_displayfunction & LCDP_8BITMODE) {
106 low(device->_data_pins[4]);
107 low(device->_data_pins[5]);
108 low(device->_data_pins[6]);
109 low(device->_data_pins[7]);
117 low(device->_rs_pin);
118 low(device->_enable_pin);
122 if (!(device->_displayfunction & LCDP_8BITMODE)) {
145 lcdParallel_send(device, LCDP_FUNCTIONSET | device->_displayfunction, LCDP_SEND_COMMAND);
149 lcdParallel_send(device, LCDP_FUNCTIONSET | device->_displayfunction, LCDP_SEND_COMMAND);
153 lcdParallel_send(device, LCDP_FUNCTIONSET | device->_displayfunction, LCDP_SEND_COMMAND);
157 lcdParallel_send(device, LCDP_FUNCTIONSET | device->_displayfunction, LCDP_SEND_COMMAND);
160 device->_displaycontrol = LCDP_DISPLAYON | LCDP_CURSOROFF | LCDP_BLINKOFF;
167 device->_displaymode = LCDP_ENTRYLEFT | LCDP_ENTRYSHIFTDECREMENT;
169 lcdParallel_send(device, LCDP_ENTRYMODESET | device->_displaymode, LCDP_SEND_COMMAND);