' demo of HC-SR04 + RTC + OLED connected to Annex32
' a complete help of Annex32 can be found here
' https://cicciocb.com/annex32help/V1.442/
maxscroll.setup 8, 21
maxscroll.print "Annex & WOKWI"
maxscroll.next "A simple programming environment for a great simulator!!"
neo.setup 5, 16
neo.strip 0, 15, 0
i2c.setup 26,25, 400000
oled.init 0
oled.font 2
oled.refresh 0
timer0 50, scrollME
timer1 900, printtime
cnt = 0 : led = 0 : col = &hff0000 : col_p = 0
wait

scrollME:
  MAXSCROLL.SCROLL 5
  cnt = cnt + 1
  if (cnt > 3) then
    cnt = 0
    neo.strip 0, 15, col_p, 1
    neo.strip 0, led, col, 0
    led = led + 1
    if (led > 15) then
      led = 0
      col_p = col
      col = rnd(256 * 256 * 256)
    endif
  endif

return

printtime:
oled.cls
oled.print 0, 0,  "RTC:" +  RTC.DATE$
oled.print 0, 16, "RTC:" +  RTC.TIME$
oled.print 0, 32, "DIST:" + str$(DISTANCE(13,12), "%4.1f")
oled.print 0, 48, "ADC:" + str$(adc(34)) 
oled.refresh 0
return

GND5VSDASCLSQWRTCDS1307+