Explorar o código

made LCD library threadsafe

Philipp Hinz %!s(int64=8) %!d(string=hai) anos
pai
achega
fa0e109122
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      CoffeeCode/lcd.cpp

+ 3 - 0
CoffeeCode/lcd.cpp

@@ -32,6 +32,7 @@
 
 #include "spi.h"
 #include "lcd.h"
+#include "global.h"
 
 #ifndef	TRUE
 #  define	TRUE	(1==1)
@@ -130,9 +131,11 @@ 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,