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:
- 25:896dbc85907e
- Parent:
- 23:3da1d39c1ae9
- Child:
- 28:a07b27cc6d13
--- a/main.cpp Tue Mar 20 15:58:58 2018 +0000
+++ b/main.cpp Thu Mar 22 15:29:58 2018 +0000
@@ -23,9 +23,12 @@
SPI wag_spi(MOSI, MISO, SCLK);
Serial pc(USBTX, USBRX);
-DigitalIn jog_cw(PF_14);
-DigitalIn jog_ccw(PE_13);
+DigitalIn jog_cw(UI_JOG_RIGHT_BUTTON);
+DigitalIn jog_ccw(UI_JOG_LEFT_BUTTON);
DigitalIn my_button(USER_BUTTON);
+DigitalIn start_button(UI_START_BUTTON);
+DigitalIn cal_button(UI_CAL_BUTTON);
+DigitalIn station_select(UI_STATION_SELECT);
struct spi_cfg as1107{
SPI_AS1107_ID,
@@ -42,49 +45,20 @@
char input;
int display_number;
- pc.printf("Enter 1 for display test, 2 for stepper test\n");
- input = getchar();
- while (input < 49 or input > 50) { //ask for input until 0-9 is selected
- pc.printf("Enter 1 for display test, 2 for stepper test\n");
- input = getchar();
+ //set all digits to zero
+ spi_send(as1107 0x0100);
+ spi_send(as1107 0x0200);
+ spi_send(as1107 0x0300);
+ spi_send(as1107 0x0400);
+
+ jog_cw.mode(PullUp);
+ jog_ccw.mode(PullUp);
+ while(1) {
+ if (jog_ccw == 0) {
+ stp_step(STP_CCW);
+ }
+ if (jog_cw == 0) {
+ stp_step(STP_CW);
+ }
}
-
- if (input == 49) {
- while(1) { //clears bcd array
- for (int i = 0; i < 4; i++)
- bcd[i] = 0;
- display_number = 0;
- pc.printf("Select a digit between 0 and 9999:\n");
- pc.scanf("%d", &display_number);
-
- while (display_number < 0 or display_number > 9999) { //ask for input until 0-9999 is selected
- pc.printf("You entered a number out of range\n");
- pc.printf("Select a digit between 0 and 9999:\n");
- display_number = 0;
- pc.scanf("%d", &display_number);
- }
-
-
- printf("you entered: %d\n", display_number);
- bin2bcd_array(display_number, bcd);
-
- send_command_to_display(bcd);
- }
- }
- else {
- jog_cw.mode(PullUp);
- jog_ccw.mode(PullUp);
- stp_step(1);
- pc.printf("Press a pushbutton to turn step motor\n");
- while(1) {
- if (jog_ccw == 0) {
- //pc.printf("turning CCW\n");
- stp_step(STP_CCW);
- }
- if (jog_cw == 0) {
- //pc.printf("turning CW\n");
- stp_step(STP_CW);
- }
- }
- }
-}
\ No newline at end of file
+}
\ No newline at end of file
