Sub Process_Globals
Public Serial1 As Serial
Public pixels(64) As Float
Dim tim As Timer
Public AVG As Float
End Sub
Private Sub AppStart
Serial1.Initialize(256000)
Log(CRLF + "AppStart")
tim.Initialize("tim_Tick", 1000)
tim.Enabled = True
End Sub
Sub tim_tick
RunNative("getPixels", Null)
Dim av As Float, count As Int
For i = 0 To pixels.Length - 1
av = av + pixels(i)
count = count + 1
Next
AVG = av / count
Log("AVG temperature = ", AVG)
End Sub
#if C
#include <Wire.h>
#include <Adafruit_AMG88xx.h>
Adafruit_AMG88xx amg;
float pixels[AMG88xx_PIXEL_ARRAY_SIZE];
void getPixels(B4R::Object* u) {
amg.begin();
delay(100); // let sensor boot up
//read all the pixels
amg.readPixels((float*)b4r_main::_pixels->data);
//delay a second
delay(1000);
}
#End If