Browse Source

removed internal TDISP_LLD() macro

remotes/origin_old/ugfx_release_2.6
Joel Bodenmann 10 years ago
parent
commit
a278e1c113
  1. 24
      drivers/tdisp/HD44780/tdisp_lld.c
  2. 1
      drivers/tdisp/HD44780/tdisp_lld_config.h
  3. 8
      include/tdisp/lld/tdisp_lld.h
  4. 24
      src/tdisp/tdisp.c

24
drivers/tdisp/HD44780/tdisp_lld.c

@ -43,7 +43,7 @@ static void _writeData(uint8_t data) {
chThdSleepMicroseconds(5);
}
void TDISP_LLD(write_cmd)(uint8_t data) {
void tdisp_lld_write_cmd(uint8_t data) {
setpin_rs(FALSE);
setpin_rw(FALSE);
@ -53,7 +53,7 @@ void TDISP_LLD(write_cmd)(uint8_t data) {
_writeData(data);
}
void TDISP_LLD(write_data)(uint8_t data) {
void tdisp_lld_write_data(uint8_t data) {
setpin_rs(TRUE);
setpin_rw(FALSE);
@ -63,47 +63,47 @@ void TDISP_LLD(write_data)(uint8_t data) {
_writeData(data);
}
bool_t TDISP_LLD(init)(void) {
bool_t tdisp_lld_init(void) {
/* initialise MCU hardware */
init_board();
/* wait some time */
chThdSleepMilliseconds(50);
TDISP_LLD(write_cmd)(0x38);
tdisp_lld_write_cmd(0x38);
chThdSleepMilliseconds(64);
TDISP_LLD(write_cmd)(0x0f);
tdisp_lld_write_cmd(0x0f);
chThdSleepMicroseconds(50);
TDISP_LLD(write_cmd)(0x01);
tdisp_lld_write_cmd(0x01);
chThdSleepMilliseconds(5);
TDISP_LLD(write_cmd)(0x06);
tdisp_lld_write_cmd(0x06);
chThdSleepMicroseconds(50);
return TRUE;
}
void TDISP_LLD(set_cursor)(coord_t col, coord_t row) {
void tdisp_lld_set_cursor(coord_t col, coord_t row) {
uint8_t row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
if(row >= TDISP_ROWS)
row = TDISP_ROWS - 1;
TDISP_LLD(write_cmd)(0x80 | (col + row_offsets[row]));
tdisp_lld_write_cmd(0x80 | (col + row_offsets[row]));
}
void TDISP_LLD(create_char)(uint8_t address, char *charmap) {
void tdisp_lld_create_char(uint8_t address, char *charmap) {
uint8_t i;
/* make sure we don't write somewhere we're not supposed to */
address &= TDISP_MAX_CUSTOM_CHARS;
TDISP_LLD(write_cmd)(0x40 | (address << 3));
tdisp_lld_write_cmd(0x40 | (address << 3));
for(i = 0; i < 8; i++) {
TDISP_LLD(write_data)(charmap[i]);
tdisp_lld_write_data(charmap[i]);
}
}

1
drivers/tdisp/HD44780/tdisp_lld_config.h

@ -36,7 +36,6 @@
/*===========================================================================*/
#define TDISP_DRIVER_NAME "HD44780"
#define TDISP_LLD(x) tdisp_lld_##x##_HD44780
#define TDISP_MAX_CUSTOM_CHARS 0x07

8
include/tdisp/lld/tdisp_lld.h

@ -37,9 +37,11 @@
extern "C" {
#endif
extern bool_t foo(void);
extern void write_cmd(uint8_t data);
extern void write_data(uint8_t data);
extern void tdisp_lld_write_cmd(uint8_t data);
extern void tdisp_lld_write_data(uint8_t data);
extern bool_t tdisp_lld_init(void);
extern void tdisp_lld_set_cursor(coord_t col, coord_t row);
extern void tdisp_lld_create_char(uint8_t address, char *charmap);
#ifdef __cplusplus
}

24
src/tdisp/tdisp.c

@ -36,7 +36,7 @@ static uint8_t _displaycontrol;
bool_t tdispInit(void) {
bool_t ret;
ret = TDISP_LLD(init)();
ret = tdisp_lld_init();
return ret;
}
@ -45,49 +45,49 @@ void tdispSetAttributes(uint8_t attributes) {
switch(attributes) {
case TDISP_ON:
_displaycontrol |= 0x04;
TDISP_LLD(write_cmd)(0x08 | _displaycontrol);
tdisp_lld_write_cmd(0x08 | _displaycontrol);
break;
case TDISP_OFF:
_displaycontrol &=~ 0x04;
TDISP_LLD(write_cmd)(0x08 | _displaycontrol);
tdisp_lld_write_cmd(0x08 | _displaycontrol);
break;
case TDISP_CURSOR_ON:
_displaycontrol |= 0x02;
TDISP_LLD(write_cmd)(0x08 | _displaycontrol);
tdisp_lld_write_cmd(0x08 | _displaycontrol);
break;
case TDISP_CURSOR_OFF:
_displaycontrol &=~ 0x02;
TDISP_LLD(write_cmd)(0x08 | _displaycontrol);
tdisp_lld_write_cmd(0x08 | _displaycontrol);
break;
case TDISP_CURSOR_BLINK_ON:
_displaycontrol |= 0x00;
TDISP_LLD(write_cmd)(0x08 | _displaycontrol);
tdisp_lld_write_cmd(0x08 | _displaycontrol);
break;
case TDISP_CURSOR_BLINK_OFF:
_displaycontrol &=~ 0x00;
TDISP_LLD(write_cmd)(0x08 | _displaycontrol);
tdisp_lld_write_cmd(0x08 | _displaycontrol);
break;
}
}
void tdispClear(void) {
TDISP_LLD(write_cmd)(0x01);
tdisp_lld_write_cmd(0x01);
}
void tdispHome(void) {
TDISP_LLD(write_cmd)(0x02);
tdisp_lld_write_cmd(0x02);
}
void tdispCreateChar(uint8_t address, char *charmap) {
TDISP_LLD(create_char)(address, charmap);
tdisp_lld_create_char(address, charmap);
}
void tdispSetCursor(coord_t col, coord_t row) {
TDISP_LLD(set_cursor)(col, row);
tdisp_lld_set_cursor(col, row);
}
void tdispDrawChar(char c) {
TDISP_LLD(write_data)(c);
tdisp_lld_write_data(c);
}
void tdispDrawString(char *s) {

Loading…
Cancel
Save