Added sanity check to CO2 (must be more that 0 :D)
This commit is contained in:
parent
a87afdf6fa
commit
78c8104a58
@ -111,6 +111,7 @@ config_t sensor_config;
|
||||
uint8_t sensor_config_pending_write = 0;
|
||||
uint8_t baudrate_changed = 0;
|
||||
uint8_t modbus_address_changed = 0;
|
||||
uint8_t co2_valid = 0;
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
@ -179,7 +180,7 @@ int main(void)
|
||||
|
||||
/* Turn on MAGENTA LED to signal startup state */
|
||||
LL_GPIO_ResetOutputPin(LED_R_GPIO_Port, LED_R_Pin);
|
||||
LL_GPIO_SetOutputPin(LED_G_GPIO_Port, LED_G_Pin);
|
||||
LL_GPIO_ResetOutputPin(LED_G_GPIO_Port, LED_G_Pin);
|
||||
LL_GPIO_ResetOutputPin(LED_B_GPIO_Port, LED_B_Pin);
|
||||
|
||||
/* Enable I2C for sensors */
|
||||
@ -297,6 +298,11 @@ int main(void)
|
||||
scd4x_read_measurement(&CO2,
|
||||
&T_SCD4x,
|
||||
&RH_SCD4x);
|
||||
if (CO2 > 0) {
|
||||
co2_valid = 1;
|
||||
} else {
|
||||
co2_valid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read SPS30 data (if connected) */
|
||||
@ -312,6 +318,7 @@ int main(void)
|
||||
}
|
||||
/* TEST END */
|
||||
if (sensor_config.led_on) {
|
||||
if (co2_valid == 1) {
|
||||
if (CO2 <= sensor_config.led_co2_alert_limit1) {
|
||||
/* CO2 is OK -> GREEN */
|
||||
LL_GPIO_SetOutputPin(LED_R_GPIO_Port, LED_R_Pin);
|
||||
@ -331,10 +338,17 @@ int main(void)
|
||||
LL_GPIO_SetOutputPin(LED_B_GPIO_Port, LED_B_Pin);
|
||||
}
|
||||
} else {
|
||||
LL_GPIO_SetOutputPin(LED_R_GPIO_Port, LED_R_Pin);
|
||||
|
||||
LL_GPIO_ResetOutputPin(LED_R_GPIO_Port, LED_R_Pin);
|
||||
LL_GPIO_SetOutputPin(LED_G_GPIO_Port, LED_G_Pin);
|
||||
LL_GPIO_SetOutputPin(LED_B_GPIO_Port, LED_B_Pin);
|
||||
LL_GPIO_ResetOutputPin(LED_B_GPIO_Port, LED_B_Pin);
|
||||
}
|
||||
|
||||
} else {
|
||||
LL_GPIO_SetOutputPin(LED_R_GPIO_Port, LED_R_Pin);
|
||||
LL_GPIO_SetOutputPin(LED_G_GPIO_Port, LED_G_Pin);
|
||||
LL_GPIO_SetOutputPin(LED_B_GPIO_Port, LED_B_Pin);
|
||||
}
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
|
@ -68,6 +68,6 @@
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="reserved-for-future-use"> <gdbmemoryBlockExpression address="134742016" label="0x08080000"/> <gdbmemoryBlockExpression address="134742020" label="0x08080004"/> </memoryBlockExpressionList> "/>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><memoryBlockExpressionList context="reserved-for-future-use"><gdbmemoryBlockExpression address="134742016" label="0x08080000"/><gdbmemoryBlockExpression address="134742020" label="0x08080004"/><gdbmemoryBlockExpression address="134742016" label="0x08080000"/></memoryBlockExpressionList>"/>
|
||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
|
@ -5,7 +5,7 @@ import minimalmodbus
|
||||
import serial
|
||||
|
||||
slave_address = 254
|
||||
instrument = minimalmodbus.Instrument('/dev/ttyUSB0', slave_address, close_port_after_each_call=True) # port name, slave address (in decimal)
|
||||
instrument = minimalmodbus.Instrument('/dev/rs485', slave_address, close_port_after_each_call=True) # port name, slave address (in decimal)
|
||||
|
||||
instrument.serial.baudrate = 19200
|
||||
instrument.serial.bytesize = 8
|
||||
|
Loading…
Reference in New Issue
Block a user