Serial OLED & IRR.

shamu

Member
Hi all, happy New Year.

I am trying to run an OLED, AXE131Y, as a clock using a DS1307 RTC from a 28M2 with the ability to change the time via an IR remote.
The project works fine as a clock until I include the irin C.1, infravalue ; read input C.1 into infravalue line, then the program hangs there waiting for an IR input, the code is updated when it receives one.

I expect the irin command to be ignored and the display updated if the there is no input but appears to not be happening.

Any help would be much appreciated.



Code:
#no_data
#no_table

let dirsB = %11111111

let dirsC = %00000000



symbol seconds = b0
symbol mins = b1
symbol hours = b2
symbol day = b3
symbol date = b4
symbol month = b5
symbol year = b6
symbol control = b7

symbol infravalue = b8 ' Define an infrared variable. 

symbol n = b9

HI2CSETUP i2cmaster, %11010000, i2cslow,i2cbyte
'The last bit of the a DS1307 is 0 for write and 1 for read.

  let n = 0


main:

  let seconds = %01010001
  let mins = %01011001
  let hours = %00100011
  let day = %00000111 'Day of week. 1-7.
  
  let date = %00110000 'Day of month. 1-31.
  
  let month = %00010001 ' Month N?. 1-12.

  let year = %00010011
  let control = %10010000
  
  writei2c $0,(seconds,mins,hours,day,date,month,year,control)
     
   init: 
   pause 500  
   serout C.0,n2400,(254,1)  ' Clear screen.
   pause 3000

  HI2CSETUP i2cmaster, %11010000, i2cslow,i2cbyte

  'This block reads & displays the time.
  do
   
    ' Clear screen, first time only.
    if n = 0 then
      serout C.0,n2400,(254,1) 
	let n = 1
    endif 
    
    
    irin C.1, infravalue ; read input C.1 into infravalue
    
    
	   
    readi2c $0,(seconds,mins,hours,day,date,month,year,control)
    
    seconds = BcdToBin seconds
    mins = BcdToBin mins
    hours = BcdToBin hours
    day = BcdToBin day
    date = BcdToBin date
    month = BcdToBin month
    

   serout c.0,n2400,(254,128)	    
   serout c.0,n2400,(#infravalue,"   ",#hours,":",#mins,":",#seconds,"       ")
   'pause 1000
      ' serout c.0,n2400,(254,1) pause 30	    
	    
    'let outpinsB = month
           
  loop

goto main
 

sghioto

Senior Member
Need to use the "time out" feature of the command if it will work with your program.
IRIN [timeout, address], pin, variable
Timeout - is a variable/constant which sets the timeout period in milliseconds
Address - is a label which specifies where to go if a timeout occurs

Steve G
 

westaust55

Moderator
... from a 28M2 with the ability ...
Can you confirm whether you are using an 08M2, a 20M2, a 20X2 or a 28X2.

An option may be to use the SETINT to monitor the IR input pin for activity and only branch to the IRIN command if a signal is detected. Whether that is feasible will depend on where the project is located and what IR noise may be present from other light sources. Would still want the IRIN timeout in case IR “noise” caused a false interrupt.
 
Last edited:

shamu

Member
Need to use the "time out" feature of the command if it will work with your program.
IRIN [timeout, address], pin, variable
Timeout - is a variable/constant which sets the timeout period in milliseconds
Address - is a label which specifies where to go if a timeout occurs

Steve G
Thanks Steve, that appears to work a treat!
 
Top