5 #include "../hubolib.h"
26 void CycleTickCallback (
unsigned long* pADChannelValues,
unsigned char* pDigitalInputValues,
unsigned char* pDigitalOutputValues);
34 printf (
"Error: Initialize\n");
48 for (
int i=0; i<10; i++)
50 printf (
"Main thread waiting...\n");
63 void CycleTickCallback (
unsigned long* pADChannelValues,
unsigned char* pDigitalInputValues,
unsigned char* pDigitalOutputValues)
69 printf (
"CycleTickCallback called.\n");
72 unsigned short value = 0;
75 printf (
"Failed to retrieve analog value from MCP3x08.\n");
82 printf (
"Rough value = %lf\n", currentVolt);
86 if (currentVolt < 1.4 || currentVolt > 1.6)
91 unsigned long currentValue = 0;
97 for (
int i=0; i<1000; i++)
100 currentValue += value;
103 printf (
"Failed to retrieve analog value from MCP3x08.\n");
110 printf (
"Precise value = %lf duration = %lfms (at 1000 samples).\n",
DigitToVolt(currentValue)/1000.0, (stopTime-startTime)/1000.0);
121 return (((
double)digit)*
Get_VRef()/4096.0);
bool Initialize()
Initializes the library.
bool Set_Cycle_Time(long cycleTime)
Sets the backgrounds threads polling interval in ms.
bool Unregister_CycleTickCallback(T_pfn_CycleTickCallback pFnCycleTickCallback)
Unregister a callback previouly registered by a call to Register_CycleTickCallback().
void Uninitialize()
Releases any resources bound to the library.
unsigned long long GetTime_MicroSeconds()
Returns the number of micro seconds.
bool Register_CycleTickCallback(T_pfn_CycleTickCallback pFnCycleTickCallback)
Registers a callback function called on every cycle tick.