Add @property decorator to some method of Data class

This commit is contained in:
Pierrick C 2018-08-03 23:10:40 +02:00
parent 60e4b9f12d
commit 66abc780f8

View File

@ -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)