#
# randomDHR.py - generate random number and log
#
# this writes to a file: "gbFaAuto.csv"
# copy this file from my raspberrypi with hostname "rpiw"
#
#  scp pi@rpiw:~/gbFaAuto.csv .
#

from time import sleep, gmtime, strftime

from random import randint

p1 = 0
while True:
    p1 += randint(-1, 1)
    p2 = randint(-10, 10)
    #print("Random walk:", p1, " just random:", p2)
    #build up csv string, wrapped in gbfa( ', p1, p2 , ' )
    ts =  strftime("%Y-%m-%d %H:%M:%S", gmtime() )
    opStr = "gbFa( ' ,"+ ts + "," + str( p1 ) + "," + str( p2 ) + ", ' )\r\n"
    #Flush buffered readings to file
    with open("gbFaAuto.csv", "a") as f:
      #flush buffered rea
      f.write( opStr )
      f.close()
    #
    sleep(5)
    # end 


