Skip to content

Commit 1bf9e77

Browse files
2 parents 92e0f2e + c2d6dbf commit 1bf9e77

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

PicoAirQuality.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def highPowerOff(self, pin):
109109
class KitronikDataLogger:
110110
# Function is called when the class is initialised - sets the maximum permissable filesize, the data separator and creates the log file with the entered filename
111111
# Separator options: ("comma", "semicolon", "tab")
112-
def __init__(self, file, separator):
112+
def __init__(self, file = "data_log.txt", separator = "semicolon"):
113113
self.MAX_FILE_SIZE = 500000 # This is approximately 10000 full entries
114114
if (separator == "comma"):
115115
self.SEPARATOR = ","
@@ -123,8 +123,9 @@ def __init__(self, file, separator):
123123
f.close()
124124
except OSError:
125125
print("File already exists")
126-
self.name = ""
127-
self.subject = ""
126+
self.line1 = ""
127+
self.line2 = ""
128+
self.line3 = ""
128129
self.dataHeadings = ""
129130
self.projectInfo = False
130131
self.headings = False
@@ -133,10 +134,13 @@ def __init__(self, file, separator):
133134
def writeProjectInfo(self, line1="", line2="", line3=""):
134135
if (line1 != ""):
135136
self.writeFile(self.FILENAME, line1 + "\r\n")
137+
self.line1 = line1
136138
if (line2 != ""):
137139
self.writeFile(self.FILENAME, line2 + "\r\n")
140+
self.line2 = line2
138141
if (line3 != ""):
139142
self.writeFile(self.FILENAME, line3 + "\r\n")
143+
self.line3 = line3
140144
self.projectInfo = True
141145

142146
# This writes whatever is passed to it to the file
@@ -224,9 +228,9 @@ def removeOneLine(self):
224228
if self.projectInfo: # If there is Project Info, skip over these lines and then write them to the temporary file
225229
for l in range(3):
226230
readFrom.readline()
227-
writeTo.write(self.LOG_HEADER)
228-
writeTo.write(self.name + "\r\n")
229-
writeTo.write(self.subject + "\r\n")
231+
writeTo.write(self.line1 + "\r\n")
232+
writeTo.write(self.line2 + "\r\n")
233+
writeTo.write(self.line3 + "\r\n")
230234
if self.headings:
231235
readFrom.readline() # If there are Headings, skip over this line and then write them to the temporary file
232236
writeTo.write(self.dataHeadings + "\r\n")
@@ -463,12 +467,13 @@ def readParameter(self, parameter):
463467
# Set an alarm for a specific hour and minute
464468
# Extra options to set a periodically repeating alarm (set alarmRepeat to True and then specifiy the hour and/or minute period between alarms)
465469
def setAlarm(self, hour, minute, alarmRepeat=False, hourPeriod=0, minutePeriod=0):
466-
self.alarmHour = hour
467-
self.alarmMinute = minute
470+
self.alarmHour = math.ceil(hour)
471+
self.alarmMinute = math.ceil(minute)
468472
self.alarmRepeat = alarmRepeat
473+
469474
if alarmRepeat:
470-
self.hourPeriod = hourPeriod
471-
self.minutePeriod = minutePeriod
475+
self.hourPeriod = math.ceil(hourPeriod)
476+
self.minutePeriod = math.ceil(minutePeriod)
472477
self.alarmSet = True
473478

474479
# Check whether the alarm conditions have been met and then trigger the alarm

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ There are three options for the data separator:
200200

201201
There are two functions which are used to setup the data log file with some extra information:
202202
```python
203-
log.writeProjectInfo(name, subject)
204-
log.setupDataFields(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10)
203+
log.writeProjectInfo(line1, line2, line3)
204+
log.nameColumnHeadings(field1, field2, field3, field4, field5, field6, field7, field8, field9, field10)
205205
```
206-
The first writes a standard header line to the file, and then allows two user-entered fields, designated here as 'name' and 'subject'.
206+
The first writesup to three user-entered free text fields (if only two arguments are given, only two lines will be written).
207207
The second allows the user to include up to 10 data field headings which can then need to be matched to the order of the data fields in the data entry (these headings will become column headings if the data is imported to a spreadsheet program).
208208
With these sections included, the start of a log file will look something like this:
209209
```
@@ -237,7 +237,7 @@ To register a servo ready to be used:
237237
```python
238238
output.registerServo()
239239
```
240-
This process sets the PIO PWM active on the servo pin.
240+
This process sets the PIO PWM active on the servo pin (**Note:** The servo is registered by default).
241241
To control the movement of a servo, turning it to a set angle (or controlling the speed/direction of a continuous rotation servo):
242242
```python
243243
output.servoToPosition(degrees)

0 commit comments

Comments
 (0)