ECE3872 HW/SW Project Code

Dependencies:   mbed Servo mbed-rtos 4DGL-uLCD-SE PinDetect X_NUCLEO_53L0A1

Files at this revision

API Documentation at this revision

Comitter:
nnguyen99
Date:
Sat Apr 04 23:49:24 2020 +0000
Parent:
4:1790aa9234a3
Child:
6:6c3ccc04f07e
Child:
7:f5f265b139fe
Commit message:
Various hardware additions

Changed in this revision

4DGL-uLCD-SE.lib Show annotated file Show diff for this revision Revisions of this file
PinDetect.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/4DGL-uLCD-SE.lib	Sat Apr 04 23:49:24 2020 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/4180_1/code/4DGL-uLCD-SE/#e39a44de229a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PinDetect.lib	Sat Apr 04 23:49:24 2020 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/AjK/code/PinDetect/#cb3afc45028b
--- a/main.cpp	Tue Mar 31 20:03:55 2020 +0000
+++ b/main.cpp	Sat Apr 04 23:49:24 2020 +0000
@@ -1,13 +1,22 @@
 #include "mbed.h"
+#include <iostream>
 #include "audio_out.h"
-
+#include "PinDetect.h"
+#include "uLCD_4DGL.h"
 DigitalOut myled(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 RESET 1
-#define STOP 2
-#define RECORD 3
-#define PLAY 4
-#define ERASE 5
+#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
@@ -15,7 +24,7 @@
 bool R;     //record
 bool E;     //erase
 
-enum sm_state {sRESET,sSTOP,sRECORD,sPLAY,sERASE};
+enum sm_state {sRESET, sSTOP, sRECORD, sPLAY, sERASE};
 
 
 void reset(){ 
@@ -63,6 +72,46 @@
     */
 }
 
+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 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 state_machine_mgr(){
     sm_state curr_state =  sRESET;
     while(1) {
@@ -106,5 +155,6 @@
 }
 
 int main() {
+    hardware_init();
     state_machine_mgr();
 }