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 QEI HIDScope biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 6:354a6509405f
- Parent:
- 5:aa8b5d5e632f
- Child:
- 7:78bc59c7753c
--- a/main.cpp Thu Oct 03 10:53:17 2019 +0000
+++ b/main.cpp Thu Oct 03 11:02:02 2019 +0000
@@ -28,28 +28,29 @@
void measure_signals() {return;}
void do_nothing() {
- if (button_pressed) {
+ if (button_pressed) { //this moves the program from the idle to cw state
current_state = cw;
- state_changed = true;
+ state_changed = true; //to show next state it can initialize
pc.printf("Changed state from idle to cw\r\n");
- button_pressed = false;
+ button_pressed = false; //reset button
}
}
void rotate_cw() {
if (state_changed) {
pc.printf("State changed to CW\r\n");
- state_changed = false;
+ state_changed = false; //reset this so it wont print next loop
}
- motor.dir2 = 1;
+ motor.dir2 = 1; //todo: check if this is actually clockwise
motor.pwm2 = 0.5f;
- if (!state_changed && button_pressed) { //state niet veranderd, button gepressd -> state verandert
+ if (!state_changed && button_pressed) { //state wasnt just changed, button has been pressed -> change state
current_state = ccw;
state_changed = true;
- button_pressed = false;
+ button_pressed = false; //reset this
}
}
void rotate_ccw() {
+ //similar to rotate_cw()
if (state_changed) {
pc.printf("State changed to CCW\r\n");
state_changed = false;
@@ -110,11 +111,4 @@
loop_ticker.attach(&main_loop, 0.001f); //main loop at 1kHz
while (true) {}
- //while (true) {
- // enc_count = encoder.getPulses(); //kijkt op welke stand hij nu staat
- // pc.printf("%f\r\n", float(enc_count-prev_count)*360/(8400*0.025)); //verschil met vorige stap in graden per stap gedeeld door tijd = snelheid
- // prev_count = enc_count;
- // wait_ms(25);
- //}
-}
-
\ No newline at end of file
+}
\ No newline at end of file