ECE3872 HW/SW Project Code
Dependencies: mbed Servo mbed-rtos 4DGL-uLCD-SE PinDetect X_NUCLEO_53L0A1
Diff: main.cpp
- Revision:
- 22:fd48dd707e4f
- Parent:
- 21:a279bb16a37b
- Child:
- 23:34aed77d5b2c
diff -r a279bb16a37b -r fd48dd707e4f main.cpp --- a/main.cpp Wed Apr 08 21:28:53 2020 +0000 +++ b/main.cpp Sat Apr 11 16:40:50 2020 +0000 @@ -1,21 +1,25 @@ #include "mbed.h" #include <iostream> -#include "audio_out.h" +#include "Speakerout2.h" #include "PinDetect.h" #include "uLCD_4DGL.h" -#include "motor_ctl.h" DigitalOut myled1(LED1); -DigitalOut myled2(LED2); -DigitalOut myled3(LED3); -DigitalOut myled4(LED4); - +DigitalOut myled2(LED1); +DigitalOut myled3(LED1); +DigitalOut myled4(LED1); +// LCD init +uLCD_4DGL guLCD(p28, p27, p29); // serial tx, serial rx, reset pin; // Push buttons init PinDetect pb1(p16); PinDetect pb2(p17); PinDetect pb3(p18); PinDetect pb4(p19); // States - +#define sRESET 1 +#define sSTOP 2 +#define sRECORD 3 +#define sPLAY 4 +#define sERASE 5 // State Machine control global variables bool X; //reset bool P; //play @@ -23,7 +27,7 @@ bool R; //record bool E; //erase -enum sm_state {sRESET, sSTOP, sRECORD, sPLAY, sERASE}; + void reset(){ @@ -46,7 +50,7 @@ 3. Mute all audio */ } -void record(){ +//void record(){ /* record state: Initiated by rotary switch 1. Cease all motion @@ -55,7 +59,7 @@ 4. Append to list of frequencies 5. */ -} +//} void play(){ /* play state: Initiated by rotary switch @@ -71,49 +75,8 @@ */ } - - -void pb1_hit_callback (void) -{ - myled1 = !myled1; - //guLCD.printf("REEST"); -} - -void pb2_hit_callback (void) -{ - myled2 = !myled2; - //guLCD.printf("STOP"); -} - -void pb3_hit_callback (void) -{ - myled3 = !myled3; - //guLCD.printf("RECORD"); -} - -void pb4_hit_callback (void) -{ - myled4 = !myled4; - //guLCD.printf("PLAY"); -} -void hardware_init(){ - // Push buttons init - pb1.mode(PullUp); - pb2.mode(PullUp); - pb3.mode(PullUp); - pb4.mode(PullUp); - pb1.attach_deasserted(&pb1_hit_callback); - pb2.attach_deasserted(&pb2_hit_callback); - pb3.attach_deasserted(&pb3_hit_callback); - pb4.attach_deasserted(&pb4_hit_callback); - pb1.setSampleFrequency(); - pb2.setSampleFrequency(); - pb3.setSampleFrequency(); - pb4.setSampleFrequency(); -} - void state_machine_mgr(){ - sm_state curr_state = sRESET; + int curr_state = sRESET; while(1) { switch(curr_state){ case sRESET: @@ -154,10 +117,8 @@ } } - int main() { - myled1 = 1; //hardware_init(); //state_machine_mgr(); - move_motors(); + record(); }