Skip to content
Snippets Groups Projects
Commit b55aafe7 authored by ft-Demo's avatar ft-Demo
Browse files

commit by robo pro coding

parent 8fd37e56
Branches master
No related tags found
No related merge requests found
<xml xmlns="https://developers.google.com/blockly/xml" version="9"> <xml xmlns="https://developers.google.com/blockly/xml" version="11">
<block type="txt4_controller" id="alz77~oN0~@9+5#nF!cL" x="29" y="57"> <block type="txt4_controller" id="alz77~oN0~@9+5#nF!cL" x="29" y="57">
<mutation> <mutation>
<arg type="Input" name="Input-0" value="-"/> <arg type="Input" name="Input-0" value="-"/>
......
import fischertechnik.factories as txt_factory import fischertechnik.factories as txt_factory
txt_factory.init()
txt_factory.init_controller_factory()
txt_factory.init_i2c_factory() txt_factory.init_i2c_factory()
TXT = txt_factory.controller_factory.create_graphical_controller() TXT = txt_factory.controller_factory.create_graphical_controller()
TXT_I2C_1_environment_sensor = txt_factory.i2c_factory.create_environment_sensor(TXT, 1) TXT_I2C_1_environment_sensor = txt_factory.i2c_factory.create_environment_sensor(TXT, 1)
txt_factory.initialized()
\ No newline at end of file
...@@ -14,60 +14,60 @@ TXTWindow { ...@@ -14,60 +14,60 @@ TXTWindow {
TXTLabel { TXTLabel {
id: txt_label_t id: txt_label_t
text: "t" text: "t"
font.pixelSize: 24 font.pixelSize: 16
elide: Text.ElideRight elide: Text.ElideRight
x: 60 x: 40
y: 60 y: 60
width: 100 width: 180
height: 20 height: 40
} }
TXTLabel { TXTLabel {
id: txt_label_h id: txt_label_h
text: "h" text: "h"
font.pixelSize: 24 font.pixelSize: 16
elide: Text.ElideRight elide: Text.ElideRight
x: 60 x: 40
y: 90 y: 100
width: 100 width: 180
height: 20 height: 40
} }
TXTLabel { TXTLabel {
id: txt_label_p id: txt_label_p
text: "p" text: "p"
font.pixelSize: 24 font.pixelSize: 16
elide: Text.ElideRight elide: Text.ElideRight
x: 60 x: 40
y: 120 y: 140
width: 100 width: 180
height: 20 height: 40
} }
TXTLabel { TXTLabel {
id: txt_label_iaq id: txt_label_iaq
text: "iaq" text: "iaq"
font.pixelSize: 24 font.pixelSize: 16
elide: Text.ElideRight elide: Text.ElideRight
x: 60 x: 40
y: 150 y: 180
width: 100 width: 180
height: 20 height: 40
} }
StatusIndicator { StatusIndicator {
id: txt_status_indicator id: txt_status_indicator
color: "#ff0000" color: "#00FF6C"
active: false active: false
x: 30 x: 39
y: 10 y: 20
width: 20 width: 41
height: 20 height: 39
} }
TXTLabel { TXTLabel {
id: txt_label id: txt_label
text: "BME680 calibrated" text: "calibration"
font.pixelSize: 24 font.pixelSize: 16
elide: Text.ElideRight elide: Text.ElideRight
x: 60 x: 100
y: 10 y: 30
width: 100 width: 120
height: 20 height: 20
} }
} }
<xml type="display" version="2"><item id="2" class="TXTLabel"><name>txt_label_t</name><text>t</text><geometry><x>60</x><y>60</y><width>100</width><height>20</height></geometry></item><item id="3" class="TXTLabel"><name>txt_label_h</name><text>h</text><geometry><x>60</x><y>90</y><width>100</width><height>20</height></geometry></item><item id="4" class="TXTLabel"><name>txt_label_p</name><text>p</text><geometry><x>60</x><y>120</y><width>100</width><height>20</height></geometry></item><item id="5" class="TXTLabel"><name>txt_label_iaq</name><text>iaq</text><geometry><x>60</x><y>150</y><width>100</width><height>20</height></geometry></item><item id="6" class="StatusIndicator"><name>txt_status_indicator</name><color>#ff0000</color><active>false</active><geometry><x>30</x><y>10</y><width>20</width><height>20</height></geometry></item><item id="7" class="TXTLabel"><name>txt_label</name><text>BME680 calibrated</text><geometry><x>60</x><y>10</y><width>100</width><height>20</height></geometry></item></xml> <xml type="display" version="2"><item id="2" class="TXTLabel"><name>txt_label_t</name><text>t</text><geometry><x>40</x><y>60</y><width>180</width><height>40</height></geometry></item><item id="3" class="TXTLabel"><name>txt_label_h</name><text>h</text><geometry><x>40</x><y>100</y><width>180</width><height>40</height></geometry></item><item id="4" class="TXTLabel"><name>txt_label_p</name><text>p</text><geometry><x>40</x><y>140</y><width>180</width><height>40</height></geometry></item><item id="5" class="TXTLabel"><name>txt_label_iaq</name><text>iaq</text><geometry><x>40</x><y>180</y><width>180</width><height>40</height></geometry></item><item id="6" class="StatusIndicator"><name>txt_status_indicator</name><color>#00FF6C</color><active>false</active><geometry><x>39</x><y>20</y><width>41</width><height>39</height></geometry></item><item id="7" class="TXTLabel"><name>txt_label</name><text>calibration</text><geometry><x>100</x><y>30</y><width>120</width><height>20</height></geometry></item></xml>
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
import time
from lib.controller import * from lib.controller import *
from lib.display import * from lib.display import *
import math
import time
t = None t = None
iaq = None aq = None
h = None h = None
iaq = None
p = None p = None
...@@ -14,17 +15,19 @@ if TXT_I2C_1_environment_sensor.needs_calibration(): ...@@ -14,17 +15,19 @@ if TXT_I2C_1_environment_sensor.needs_calibration():
TXT_I2C_1_environment_sensor.calibrate() TXT_I2C_1_environment_sensor.calibrate()
while True: while True:
if TXT_I2C_1_environment_sensor.needs_calibration(): if TXT_I2C_1_environment_sensor.needs_calibration():
display.exec_script("txt_status_indicator.active=" + str(False).lower()) display.set_attr("txt_status_indicator.active", str(False).lower())
aq = '-'
iaq = 0 iaq = 0
else: else:
display.exec_script("txt_status_indicator.active=" + str(True).lower()) display.set_attr("txt_status_indicator.active", str(True).lower())
iaq = round(TXT_I2C_1_environment_sensor.get_indoor_air_quality_as_number()) aq = TXT_I2C_1_environment_sensor.get_indoor_air_quality_as_text()
t = round(TXT_I2C_1_environment_sensor.get_temperature(), 1) iaq = TXT_I2C_1_environment_sensor.get_indoor_air_quality_as_number()
h = round(TXT_I2C_1_environment_sensor.get_humidity(), 1) t = TXT_I2C_1_environment_sensor.get_temperature()
p = round(TXT_I2C_1_environment_sensor.get_pressure(), 1) h = TXT_I2C_1_environment_sensor.get_humidity()
display.exec_script("txt_label_t.text='%s'" % str(''.join([str(x) for x in ['t: ', t, ' °C']]))) p = TXT_I2C_1_environment_sensor.get_pressure()
display.exec_script("txt_label_h.text='%s'" % str(''.join([str(x2) for x2 in [' h: ', h, ' %rH']]))) display.set_attr("txt_label_t.text", str('Temperature {:.1f} °C'.format(t)))
display.exec_script("txt_label_p.text='%s'" % str(''.join([str(x3) for x3 in [' p: ', p, ' hPa']]))) display.set_attr("txt_label_h.text", str('Air humidity {:.1f} %rH'.format(h)))
display.exec_script("txt_label_iaq.text='%s'" % str(' iaq: ' + str(iaq))) display.set_attr("txt_label_p.text", str('Air pressure {:.1f} hPa'.format(p)))
print(''.join([str(x4) for x4 in ['t: ', t, ' °C', ' h: ', h, ' %rH', ' p: ', p, ' hPa', ' iaq: ', iaq]])) display.set_attr("txt_label_iaq.text", str('Air quality {} ({:.0f})'.format(aq, iaq)))
print('T {:.1f} °C, H {:.1f} %rH, p {:.1f} hPa, iaq {} ({:.0f})'.format(t, h, p, aq, iaq))
time.sleep(3) time.sleep(3)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment