Code-Basis für Programm zum Taster-Entprellen
Fork of Laser-Distance by
Diff: main.cpp
- Revision:
- 8:0f74264cc38a
- Parent:
- 5:1fca2683ae6f
- Child:
- 9:a4a4f8cc4019
--- a/main.cpp Thu Jan 11 12:30:55 2018 +0000 +++ b/main.cpp Tue May 01 19:16:01 2018 +0000 @@ -1,13 +1,15 @@ #include "mbed.h" -#include "C12832.h" +#include "SB1602E.h" #include "vl53l0x_api.h" #include "vl53l0x_platform.h" #include "vl53l0x_i2c_platform.h" #define USE_I2C_2V8 -/* Sets up LCD and prints sensor data value of Indoor Air Quality sensor to LCD */ -C12832 lcd(PE_14, PE_12, PD_12, PD_11, PE_9); //LCD: MOSI, SCK, RESET, A0, nCS +DigitalOut myled(P0_7); // 7=rot, 8=gruen + +I2C i2c_disp(P0_5, P0_4); // SDA, SCL auf NXP U24 +SB1602E lcd( i2c_disp ); VL53L0X_Error WaitMeasurementDataReady(VL53L0X_DEV Dev) { VL53L0X_Error Status = VL53L0X_ERROR_NONE; @@ -60,7 +62,6 @@ int main() { - lcd.cls(); //Setup laser int var=1, measure=0; @@ -87,16 +88,26 @@ VL53L0X_PerformRefSpadManagement(pMyDevice, &refSpadCount, &isApertureSpads); // Device Initialization VL53L0X_PerformRefCalibration(pMyDevice, &VhvSettings, &PhaseCal); // Device Initialization VL53L0X_SetDeviceMode(pMyDevice, VL53L0X_DEVICEMODE_CONTINUOUS_RANGING); // Setup in single ranging mode + //VL53L0X_SetLimitCheckValue(pMyDevice, VL53L0X_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE, (FixPoint1616_t)(0.1*65536)); //Long Range modus + //VL53L0X_SetLimitCheckValue(pMyDevice, VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE, (FixPoint1616_t)(60*65536)); // Long Range + //VL53L0X_SetMeasurementTimingBudgetMicroSeconds(pMyDevice, 33000); // Long Range + //VL53L0X_SetVcselPulsePeriod(pMyDevice, VL53L0X_VCSEL_PERIOD_PRE_RANGE, 18); // Long Range + //VL53L0X_SetVcselPulsePeriod(pMyDevice, VL53L0X_VCSEL_PERIOD_FINAL_RANGE, 14); // Long Range + VL53L0X_SetLimitCheckValue(pMyDevice, VL53L0X_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE, (FixPoint1616_t)(0.25*65536)); //High Accuracy mode, see API PDF VL53L0X_SetLimitCheckValue(pMyDevice, VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE, (FixPoint1616_t)(18*65536)); //High Accuracy mode, see API PDF VL53L0X_SetMeasurementTimingBudgetMicroSeconds(pMyDevice, 200000); //High Accuracy mode, see API PDF VL53L0X_StartMeasurement(pMyDevice); while(1) { - lcd.cls(); - lcd.locate(0,3); - lcd.printf("[DISTANCE]"); - while(var<=10){ + //lcd.cls(); + //lcd.locate(0,3); + //lcd.printf("[DISTANCE]"); + + lcd.printf( 0, "Laser-Messung:\r" ); // line# (0 or 1), string + + myled = !myled; + while(var<=5){ WaitMeasurementDataReady(pMyDevice); VL53L0X_GetRangingMeasurementData(pMyDevice, pRangingMeasurementData); measure=pRangingMeasurementData->RangeMilliMeter; @@ -108,8 +119,10 @@ ave=sum/var; var=1; sum=0; - lcd.locate(0,15); - lcd.printf("%dmm", ave); // Print to LCD values - wait(1); + //lcd.locate(0,15); + //lcd.printf("%dmm", ave); // Print to LCD values + lcd.printf( 1,1, " "); + lcd.printf( 1,1, "%dmm", ave); // line# (0 or 1), string + wait(0.2); } } \ No newline at end of file