Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Lab_6_WaG by
Diff: main.cpp
- Revision:
- 58:69f9a4607a16
- Parent:
- 57:aef01bd9b3be
- Child:
- 61:778e7e30e370
--- a/main.cpp Thu Apr 12 15:09:50 2018 +0000
+++ b/main.cpp Thu Apr 12 16:12:28 2018 +0000
@@ -40,6 +40,7 @@
int cal_status = NOT_CALIBRATED;
float sensor_values[TGT_SENSOR_QUAN * 2];
int stp_sensor_pos[TGT_SENSOR_QUAN];
+int
struct spi_cfg as1107{
SPI_AS1107_ID,
@@ -60,46 +61,29 @@
spi_send(as1107, 0x0400);
- pc.printf("Press user button to test.\n");
+ pc.printf("Press user button to calibrate.\n");
// determine if the wag is connected to station A or station B
station = station_select.read();
pc.printf("station in main: %d\n", station);
- /** Part 9: calibration test **/
- pc.printf("Part 9: calibration test begin.\n");
+ //calibration test
stp_calibrate(station, sensor_values, &cal_status);
- pc.printf("Part 9: calibration test done.\n");
-
-
- // turn on laser
- lzr_on();
+ if (cal_status == NOT_CALIBRATED) {
+ pc.printf("Critical error: station not calibrated.");
+ while(1);
+ }
- /** Part 10: repeatibility test **/
- pc.printf("Part 10: press user button to begin the test.\n");
- while (uti_chk_ubutton() == 0);
- while (uti_chk_ubutton() == 0) {
- int sensor_no = 8;
- if (station == STATION_B) sensor_no = 0;
-
- // move to the left most sensor
- repeatability_test(0, cal_status);
-
- // read sensor value
- ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2);
-
- // print value
- pc.printf("Sensor %d: %f\n", sensor_no, sensor_values[sensor_no] * 3.3f);
-
- // move to the right most sensor
- repeatability_test(TGT_SENSOR_QUAN - 1, cal_status);
-
- // read sensor value
- ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2);
-
- // print value
- pc.printf("Sensor %d: %f\n", sensor_no + TGT_SENSOR_QUAN - 1, sensor_values[sensor_no + TGT_SENSOR_QUAN - 1] * 3.3f);
+ if (station == STATION_A) {
+ gnoll();
+ whack();
}
- pc.printf("Part 10: repeatibility test done.\n");
+ else if (station == STATION_B) {
+ whack();
+ gnoll();
+ }
+ else {
+ pc.print("Critical error: no station detected.");
+ }
}
\ No newline at end of file
