From 66abc780f81eea1e9fdde3d8cddef3cabf783aa8 Mon Sep 17 00:00:00 2001 From: Pierrick C Date: Fri, 3 Aug 2018 23:10:40 +0200 Subject: [PATCH] Add @property decorator to some method of Data class --- circuitpython/code/main.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/circuitpython/code/main.py b/circuitpython/code/main.py index 854f708..0f61e0a 100644 --- a/circuitpython/code/main.py +++ b/circuitpython/code/main.py @@ -115,7 +115,7 @@ class Data: if not self.data[source] == None: for d in self.data[source].items(): print("\t{0}: {1}".format(d[0], d[1])) - + @property def json(self): """Serialize data to json-formatted string""" output = '{' @@ -141,7 +141,8 @@ class Data: output = output + '}' return output - def atmo2rgb(self): + @property + def rgb(self): """Convert atmospheric data from BME280 sensor into NeoPixel color * RED => temperature : max = 35degC, min =10degC (range 25°C) * BLUE => humidity : max= 100%, mini=0% @@ -299,11 +300,11 @@ while True: if print_data: data.show() if send_json_data: - rpi_uart.write(data.json()) + rpi_uart.write(data.json) if backup_data: data.write_on_flash() if data_to_neopixel: - pixel[0] = data.atmo2rgb() + pixel[0] = data.rgb gc.collect() # micropython.mem_info(1)