ioioThermalTest.frink

Download or view ioioThermalTest.frink in plain text format


//ioio.waitForConnect[]

noParity = staticJava["ioio.lib.api.Uart$$Parity", "NONE"]
oneStopBit = staticJava["ioio.lib.api.Uart$$StopBits", "ONE"]
println[noParity]
println[oneStopBit]
uart = ioio.openUart[14, ioio.INVALID_PIN, 9600, noParity, oneStopBit]
for line = lines[uart.getInputStream[]]
   println[line]


g = new graphics
win = g.show[]
readings = new array

for line = lines["file:///dev/ttyUSB0"]
{
   if length[line] != 15
      next

   temperature = parseInt[substrLen[line,11,4]] * 10^-parseInt[substrLen[line,6,1]]
   if substrLen[line,1,1] == "1"
      temperature = -temperature

   scale = substrLen[line, 4, 2]
//   println[scale]
   
   if scale == "10"
      temperature = C[temperature]
   else
      if scale == "20"
         temperature = F[temperature]

   readings.push[temperature]
   count = 0
   p = new polyline      
   for r = readings
   {
      p.addPoint[count, -r]
      count = count + 1
   }
      
   println[format[F[temperature],1,1]]
   g = new graphics
   g.add[p]
   win.replaceGraphics[g]
}


Download or view ioioThermalTest.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20145 days, 12 hours, 3 minutes ago.