From 8a43bc252f618c8b6150c04569088513c4d74a61 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 15 Jun 2025 17:46:06 +0200 Subject: [PATCH] tcrt1000: decreased limit from 170 to 100 --- avr/modules/tcrt1000/main2.asm | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/avr/modules/tcrt1000/main2.asm b/avr/modules/tcrt1000/main2.asm index ae6adbc..9f3090c 100644 --- a/avr/modules/tcrt1000/main2.asm +++ b/avr/modules/tcrt1000/main2.asm @@ -10,7 +10,8 @@ .equ TCRT1K_INTERVAL = 7 -.equ TCRT1K_LIMIT = 170 +;.equ TCRT1K_LIMIT = 170 +.equ TCRT1K_LIMIT = 100 .equ TCRT1K_FLAGS_VALID_BIT = 7 .equ TCRT1K_FLAGS_VALUE_BIT = 0 @@ -24,6 +25,7 @@ tcrt1kDataBegin: tcrt1kTimer: .byte 1 tcrt1kFlags: .byte 1 + tcrt1kLastValue: .byte 1 tcrt1kDataEnd: @@ -96,24 +98,25 @@ TCRT1K_Every100ms_ledOn: sbi TCRT1K_LED_PORT, TCRT1K_LED_PIN ; LED on ret TCRT1K_Every100ms_startMeasure: - sbi ADCSRA, ADSC ; start conversion + sbi ADCSRA, ADSC ; start conversion ret TCRT1K_Every100ms_readValue: sbic ADCSRA, ADSC ret ; return if bit still set, leave tcrt1kTimer at "1" ; conversion complete, read value - ldi r16, TCRT1K_INTERVAL ; restart timer + ldi r16, TCRT1K_INTERVAL ; restart timer sts tcrt1kTimer, r16 - in r16, ADCH ; read value from ADC - cbi TCRT1K_LED_PORT, TCRT1K_LED_PIN ; LED off + in r16, ADCH ; read value from ADC + sts tcrt1kLastValue, r16 + cbi TCRT1K_LED_PORT, TCRT1K_LED_PIN ; LED off ; convert to 1/0 lds r17, tcrt1kFlags - cbr r17, (1<