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:
- 59:6b3a52d87465
- Parent:
- 57:aef01bd9b3be
- Child:
- 60:604c10531f58
--- a/wag.cpp Thu Apr 12 15:09:50 2018 +0000 +++ b/wag.cpp Tue Apr 17 12:36:25 2018 +0000 @@ -17,4 +17,53 @@ #include "wag.h" #include <stdlib.h> #include <stdio.h> -#include <string.h> \ No newline at end of file +#include <string.h> + +extern Timer t; + +void whack(int sensor_no, float * sensor_values) { + bool sensor_registered = false; + int sensor_no = // --> need to specify sensor_no + + // start timer for sensor reading + t.start(); + + // keep reading until one of the sensor get laser pointed in + while (!sensor_registered) { + // read value of all gnoll sensor + for (int i = 0; i < TGT_SENSOR_QUAN; i++) { + // scan all 16 sensors into sensor_values array + ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2); + } + + // detect which sensor get lasered on + for (int i = 0; i < TGT_SENSOR_QUAN + sensor_no; i++) { + if (sensor_values[i] > THRESHOLD_SIGNAL) + sensor_registered = true; + } + + // if (reading sensor timer expired) display error and freeze + t.stop(); + if (t.read() > EXPIRED_TIMER) { + pc.printf("Error: Reading timer expired. See whack() function.\n"); + while (1); + } + } + + // point whack’s laser to the corresponding sensor on it’s target array + + + + // activate whacker’s laser + + while (signal from corresponding sensor value > THRESHOLD_SIGNAL) { + if (finding sensor timer expired) display error and freeze + } + + activate corresponding indicator + + // waiting for gnoll laser to turn off to turn off + while (gnoll’s laser turned on) {} + // turn off laer gnoll + lzr_off(); +} \ No newline at end of file