|
@@ -108,7 +108,7 @@ static void strobe(const struct lcdDataStruct *lcd) {
|
|
|
|
|
|
static void sendDataCmd(const struct lcdDataStruct *lcd, unsigned char data) {
|
|
|
register unsigned char myData = data;
|
|
|
- unsigned char i, d4;
|
|
|
+ unsigned char d4;
|
|
|
|
|
|
if (lcd->bits == 4) {
|
|
|
d4 = (myData >> 4) & 0x0F;
|
|
@@ -131,17 +131,13 @@ static void sendDataCmd(const struct lcdDataStruct *lcd, unsigned char data) {
|
|
|
*/
|
|
|
|
|
|
static void putCommand(const struct lcdDataStruct *lcd, unsigned char command) {
|
|
|
- pthread_mutex_lock(&mutex);
|
|
|
digitalWrite(lcd->rsPin, 0);
|
|
|
sendDataCmd(lcd, command);
|
|
|
delay(2);
|
|
|
- pthread_mutex_unlock(&mutex);
|
|
|
}
|
|
|
|
|
|
static void put4Command(const struct lcdDataStruct *lcd,
|
|
|
unsigned char command) {
|
|
|
- register unsigned char myCommand = command;
|
|
|
- register unsigned char i;
|
|
|
|
|
|
digitalWrite(lcd->rsPin, 0);
|
|
|
shift_data(command & 0x0F);
|
|
@@ -242,7 +238,9 @@ void lcdPosition(const int fd, int x, int y) {
|
|
|
if ((y > lcd->rows) || (y < 0))
|
|
|
return;
|
|
|
|
|
|
+ pthread_mutex_lock(&mutex);
|
|
|
putCommand(lcd, x + (LCD_DGRAM | rowOff[y]));
|
|
|
+ pthread_mutex_unlock(&mutex);
|
|
|
|
|
|
lcd->cx = x;
|
|
|
lcd->cy = y;
|
|
@@ -274,6 +272,7 @@ void lcdCharDef(const int fd, int index, unsigned char data[8]) {
|
|
|
|
|
|
void lcdPutchar(const int fd, unsigned char data) {
|
|
|
struct lcdDataStruct *lcd = lcds[fd];
|
|
|
+ pthread_mutex_lock(&mutex);
|
|
|
|
|
|
digitalWrite(lcd->rsPin, 1);
|
|
|
sendDataCmd(lcd, data);
|
|
@@ -285,6 +284,7 @@ void lcdPutchar(const int fd, unsigned char data) {
|
|
|
|
|
|
putCommand(lcd, lcd->cx + (LCD_DGRAM | rowOff[lcd->cy]));
|
|
|
}
|
|
|
+ pthread_mutex_unlock(&mutex);
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -308,9 +308,9 @@ void lcdPrintf(const int fd, const char *message, ...) {
|
|
|
va_list argp;
|
|
|
char buffer[1024];
|
|
|
|
|
|
- va_start (argp, message);
|
|
|
+ va_start(argp, message);
|
|
|
vsnprintf(buffer, 1023, message, argp);
|
|
|
- va_end (argp);
|
|
|
+ va_end(argp);
|
|
|
|
|
|
lcdPuts(fd, buffer);
|
|
|
}
|