#define VL_GPIO01_PIN 6
#define VL_XSHUT_PIN 7
#define START_DISTANCE 500
#define EXG_DISTANCE 150
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
bool EXG_Mode = false;
int last_range_measurement = -1;
int VL_x_offset = 118;
int VL_y_offset = 0;
int VL_x_width = 10;
int VL_y_height = 74;
bool setup_VL()
{
return(lox.begin(0x29));
}
void VL_Reset()
{
last_range_measurement = -1;
}
void range_display(int range_measurement)
{
int box_top = VL_y_offset;
int box_bottom = box_top + VL_y_height;
int box_left = VL_x_offset;
int box_right = box_left + VL_x_width;
int box_width = VL_x_width;
int box_height = VL_y_height;
int bar_top = box_top + 1;
int bar_bottom = box_bottom - 1;
int bar_left = box_left + 1;
int bar_right = box_right -1;
int bar_width = VL_x_width - 2;
int bar_height = VL_y_height - 2;
int bar_measure;
if (last_range_measurement == -1)
{
DrawScreenCompartment(box_left,box_top,box_width,box_height,COMMON_BLACK,COMMON_YELLOW);
// Draw Box
}
if (last_range_measurement != range_measurement)
{
DrawScreenBlock(bar_left,bar_top,bar_width,bar_height, COMMON_BLACK);
if (range_measurement > START_DISTANCE)
{
DrawScreenBlock(bar_left,bar_top,bar_width,bar_height, COMMON_RED);
}
else
{
if (range_measurement < EXG_DISTANCE)
{
bar_measure = ((float)range_measurement / (float)START_DISTANCE) * bar_height;
DrawScreenBlock(bar_left, bar_bottom - bar_measure, bar_width, bar_measure, COMMON_BLUE);
}
else
{
bar_measure = ((float)range_measurement / (float)START_DISTANCE) * bar_height;
DrawScreenBlock(bar_left, bar_bottom - bar_measure, bar_width, bar_measure, COMMON_GREEN);
}
}
}
last_range_measurement = range_measurement;
}
int VL_Reading()
{
int range_measure;
VL53L0X_RangingMeasurementData_t measure;
lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!
if (measure.RangeStatus != 4)
{ // phase failures have incorrect data
range_measure = measure.RangeMilliMeter;
}
else
{
range_measure = 9999;
}
if (range_measure < EXG_DISTANCE)
EXG_Mode = true;
else
EXG_Mode = false;
return(range_measure);
}
void VL_Frame()
{
int range_measure;
range_measure = VL_Reading();
range_display(range_measure);
}
Pseudo-Medical_Monitor_Code#Custom_Includes