; *************************************************************************** ; copyright : (C) 2025 by Martin Preuss ; email : martin@libchipcard.de ; ; *************************************************************************** ; * This file is part of the project "AqHome". * ; * Please see toplevel file COPYING of that project for license details. * ; *************************************************************************** ; *************************************************************************** ; defines .equ APP_REPORT_SENSORS_INTERVAL_SECS = 120 ; *************************************************************************** ; code .cseg ; --------------------------------------------------------------------------- ; @routine AppReportSensors_Init @global ; ; @clobbers r16 AppReportSensors_Init: clr r16 sts reportSensorTimer, r16 sec ret ; @end ; --------------------------------------------------------------------------- ; @routine AppReportSensors_Fini @global ; AppReportSensors_Fini: ; nothing to do ret ; @end ; --------------------------------------------------------------------------- ; @routine AppReportSensors_OnEverySecond @global ; AppReportSensors_OnEverySecond: push r15 in r15, SREG cli rcall AppReportSensors_OnEverySecond_noIrqs out SREG, r15 pop r15 ret AppReportSensors_OnEverySecond_noIrqs: lds r16, reportSensorTimer inc r16 cpi r16, APP_REPORT_SENSORS_INTERVAL_SECS brcs AppReportSensors_OnEverySecond_store clr r16 AppReportSensors_OnEverySecond_store: sts reportSensorTimer, r16 #ifdef MODULES_SGP30 ; push r16 ; rcall SGP30_Measure ; pop r16 #endif #ifdef MODULES_SI7021 cpi r16, 1 breq AppReportSensors_OnEverySecond_measureValue1 cpi r16, 11 breq AppReportSensors_OnEverySecond_measureValue2 cpi r16, 16 breq AppReportSensors_OnEverySecond_sendValue1 cpi r16, 21 breq AppReportSensors_OnEverySecond_sendValue2 #endif #ifdef MODULES_SGP40 cpi r16, 32 breq AppReportSensors_OnEverySecond_measureValue4 cpi r16, 42 breq AppReportSensors_OnEverySecond_sendValue4 #endif #ifdef MODULES_SGP30 cpi r16, 53 breq AppReportSensors_OnEverySecond_sendValue5 cpi r16, 63 breq AppReportSensors_OnEverySecond_sendValue6 #endif #ifdef MODULES_DS18B20 cpi r16, 84 breq AppReportSensors_OnEverySecond_sendValue3 #endif #ifdef MODULES_CCS811 cpi r16, 94 breq AppReportSensors_OnEverySecond_sendCCS811_TVOC cpi r16, 104 breq AppReportSensors_OnEverySecond_sendCCS811_CO2 #endif #ifdef MODULES_BRIGHTNESS cpi r16, 97 breq AppReportSensors_OnEverySecond_sendBrightness #endif ret #ifdef MODULES_SI7021 AppReportSensors_OnEverySecond_measureValue1: rjmp SI7021_MeasureTemp AppReportSensors_OnEverySecond_measureValue2: rjmp SI7021_MeasureHumidity AppReportSensors_OnEverySecond_sendValue1: rjmp SI7021_SendTemperature AppReportSensors_OnEverySecond_sendValue2: rjmp SI7021_SendHumidity #endif #ifdef MODULES_DS18B20 AppReportSensors_OnEverySecond_sendValue3: rjmp Ds18b20_SendTemperature #endif #ifdef MODULES_SGP40 AppReportSensors_OnEverySecond_measureValue4: rjmp SGP40_MeasureRawSignal AppReportSensors_OnEverySecond_sendValue4: rjmp SGP40_SendTVOC #endif #ifdef MODULES_SGP30 AppReportSensors_OnEverySecond_sendValue5: rjmp SGP30_SendTVOC ret AppReportSensors_OnEverySecond_sendValue6: rjmp SGP30_SendCO2 #endif #ifdef MODULES_CCS811 AppReportSensors_OnEverySecond_sendCCS811_TVOC: rjmp CCS811_SendTVOC AppReportSensors_OnEverySecond_sendCCS811_CO2: rjmp CCS811_SendCO2 #endif #ifdef MODULES_BRIGHTNESS AppReportSensors_OnEverySecond_sendBrightness: rjmp Brightness_Send #endif ; @end