#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 600
#End Region
'Ctrl+Click to open the C code folder: ide://run?File=%WINDIR%\System32\explorer.exe&Args=%PROJECT%\Objects\Src
Sub Process_Globals
Public Serial1 As Serial
Private astream As AsyncStreams
Private n1, n2 As Int
End Sub
Private Sub AppStart
Serial1.Initialize(115200) ' (256000)
Log("AppStart")
astream.Initialize(Serial1.Stream, "Astream_NewData", "Astream_Error")
RunNative("Setup", Null)
Do While True
n1=250
n2=n1
RunNative("Plot", Null)
n1=120
n2=n1
RunNative("Plot", Null)
n1=50
n2=n1
RunNative("Plot", Null)
Loop
End Sub
Sub Astream_NewData (Buffer() As Byte)
Log("Received: ", Buffer)
End Sub
Sub AStream_Error
Log("error")
End Sub
#if C
#include <driver/dac.h>
void Setup(B4R::Object* o)
{
dac_output_enable(DAC_CHANNEL_1);
dac_output_enable(DAC_CHANNEL_2);
}
void Plot(B4R::Object* o)
{
//lower case variables
dac_output_voltage(DAC_CHANNEL_1, b4r_main::_n1);
dac_output_voltage(DAC_CHANNEL_2, b4r_main::_n2);
}
#End if