From ea33b9c5dba80cc2a729ad3adb23a4c0736c0474 Mon Sep 17 00:00:00 2001 From: Bryan Poteryko Date: Thu, 2 May 2019 20:08:39 -0700 Subject: [PATCH] Updated version numbers, quick bugfix Updated version from 0.4 to 0.5 in both files, as well as removed the unused functions in arduino.py. Also fixed a mistakenly-commented-out line introduced in the previous commit, which broke temperature readings. --- Arduino/arduino.py | 57 ++------------------------------ sketches/prototype/prototype.ino | 8 ++--- 2 files changed, 6 insertions(+), 59 deletions(-) diff --git a/Arduino/arduino.py b/Arduino/arduino.py index 3bcc0fb..663a2cb 100755 --- a/Arduino/arduino.py +++ b/Arduino/arduino.py @@ -12,7 +12,7 @@ else: import glob -libraryVersion = 'V0.4' +libraryVersion = 'V0.5' log = logging.getLogger(__name__) @@ -496,60 +496,7 @@ def dht(self, pin, module = 0): except: return None - # Bryan's attempt at extending this package's functionality to include the ability to write text to the Arduino screen. - # I will ignore drawing anything fancy, and just focus on displaying text. If fancy drawings are seen to be useful, they can be added later. - - # There will be several functions. One to clear and reset the display, - # one to set up the display to draw things, and one to actually draw the text (the most resource-intensive, so should be called at the end) - - - # Let's do this. - - def setupDisplay(self): - """ - Sets up a I2C-connected SSD1306 display to receive data. This sends - the command 'scs' to the Arduino (SCreen Setup). - - - Inputs: (TODO) - width: width of the display, in pixels. - height: height of the display, in pixels. - - """ - - width = 128 - height = 32 - - cmd_str = build_cmd_str("scs", (width, height)) - try: - self.sr.write(str.encode(cmd_str)) - self.sr.flush() - except: - pass - # not sure what this does - # rd = self.sr.readline().decode("utf-8").replace("\r\n", "") - # try: - # return int(rd) - # except: - # return 0 - - - def clearDisplay(self): - """ - Clears the connected display from its previously-set values. Should - be called before writing anything new to the display. - - This sends the command 'scc' to the Arduino (SCreen Clear). - """ - - cmd_str = build_cmd_str("scc") - try: - self.sr.write(str.encode(cmd_str)) - self.sr.flush() - except: - pass - - + def displayText(self, text, fontsize=1): """ Sets a string of text to be displayed on the connected SSD1306 diff --git a/sketches/prototype/prototype.ino b/sketches/prototype/prototype.ino index 870b443..492377a 100644 --- a/sketches/prototype/prototype.ino +++ b/sketches/prototype/prototype.ino @@ -9,7 +9,7 @@ #include void Version(){ - Serial.println(F("V0.4")); + Serial.println(F("V0.5")); } @@ -328,13 +328,13 @@ DHT dhtSensor(dhtSensorPin, DHT11); void dht(String data) { String sdata[2]; + split(sdata, 2, data, '%'); int dataPin = sdata[0].toInt(); int sensorNumber = sdata[1].toInt(); int sensorType = DHT11; // assume DHT11 as default if (sensorNumber == 1) { - // split(sdata, 2, data, '%'); - sensorType = DHT12; + sensorType = DHT12; } else if (sensorNumber == 2) { sensorType = DHT21; } else if (sensorNumber == 2) { @@ -400,7 +400,7 @@ void displayText(String data) { // Prints the above to the display. Relatively resource-intensive. display.display(); - delay(50); + delay(100); } // TODO: try a switch statement, might save memory.