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: wag.cpp
- Revision:
- 73:e8f7ee59d3e5
- Parent:
- 72:aec869655869
- Child:
- 74:8881f4aeb174
--- a/wag.cpp Mon Apr 23 21:21:29 2018 +0000
+++ b/wag.cpp Mon Apr 23 21:41:15 2018 +0000
@@ -135,9 +135,11 @@
// scan all gnoll sensors
for (int i = 0; i < TGT_SENSOR_QUAN; i++) {
// detect which gnoll sensor get lasered on
- if (sensor_values[i + gnoll_no] * 3.3f > PTTHRESH)
+ if (sensor_values[i + gnoll_no] * 3.3f > PTTHRESH) {
sensor_registered = true;
- gnoll_sensor_indicator = i;
+ gnoll_sensor_indicator = i;
+ pc.printf("gnoll_sensor_indicator: %d\n", gnoll_sensor_indicator);
+ }
}
// if (reading sensor timer expired) display error and freeze
@@ -149,24 +151,26 @@
}
// point whack’s laser to the corresponding sensor on whack target array
- turn_to_target(stp_sensor_pos[sensor_no]);
+ turn_to_target(stp_sensor_pos[gnoll_no + gnoll_sensor_indicator ]);
// turn on whacker's laser
lzr_on();
- // scan all 16 sensors into sensor_values array
- ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2);
-
t.start();
sensor_registered = false;
+
+ // sense which sensor the whack laser point to and turn it on
+ while (!sensor_registered) {
+ // scan all 16 sensors into sensor_values array
+ ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2);
- while (!sensor_registered) {
- // scan all whack sensors
for (int i = 0; i < TGT_SENSOR_QUAN; i++) {
// detect which gnoll sensor get lasered on
- if (sensor_values[i + sensor_no] * 3.3f > PTTHRESH)
+ if (sensor_values[i + sensor_no] * 3.3f > PTTHRESH) {
sensor_registered = true;
- whack_sensor_indicator = i;
+ whack_sensor_indicator = i;
+ pc.printf("gnoll_sensor_indicator: %d\n", gnoll_sensor_indicator);
+ }
}
// if timer expire display error and freeze
@@ -189,6 +193,10 @@
// turn off laer gnoll
lzr_off();
+
+ // turn off LED display
+ spi_send(as1107, 0x0500);
+
}
void update_score(int hit, int miss)
