Add @property decorator to some method of Data class
This commit is contained in:
parent
60e4b9f12d
commit
66abc780f8
@ -115,7 +115,7 @@ class Data:
|
|||||||
if not self.data[source] == None:
|
if not self.data[source] == None:
|
||||||
for d in self.data[source].items():
|
for d in self.data[source].items():
|
||||||
print("\t{0}: {1}".format(d[0], d[1]))
|
print("\t{0}: {1}".format(d[0], d[1]))
|
||||||
|
@property
|
||||||
def json(self):
|
def json(self):
|
||||||
"""Serialize data to json-formatted string"""
|
"""Serialize data to json-formatted string"""
|
||||||
output = '{'
|
output = '{'
|
||||||
@ -141,7 +141,8 @@ class Data:
|
|||||||
output = output + '}'
|
output = output + '}'
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def atmo2rgb(self):
|
@property
|
||||||
|
def rgb(self):
|
||||||
"""Convert atmospheric data from BME280 sensor into NeoPixel color
|
"""Convert atmospheric data from BME280 sensor into NeoPixel color
|
||||||
* RED => temperature : max = 35degC, min =10degC (range 25°C)
|
* RED => temperature : max = 35degC, min =10degC (range 25°C)
|
||||||
* BLUE => humidity : max= 100%, mini=0%
|
* BLUE => humidity : max= 100%, mini=0%
|
||||||
@ -299,11 +300,11 @@ while True:
|
|||||||
if print_data:
|
if print_data:
|
||||||
data.show()
|
data.show()
|
||||||
if send_json_data:
|
if send_json_data:
|
||||||
rpi_uart.write(data.json())
|
rpi_uart.write(data.json)
|
||||||
if backup_data:
|
if backup_data:
|
||||||
data.write_on_flash()
|
data.write_on_flash()
|
||||||
if data_to_neopixel:
|
if data_to_neopixel:
|
||||||
pixel[0] = data.atmo2rgb()
|
pixel[0] = data.rgb
|
||||||
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
# micropython.mem_info(1)
|
# micropython.mem_info(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user