Robot that currently does nothing
Dependencies: 4DGL-uLCD-SE SDFileSystem ShiftBrite mbed-rtos mbed wave_player Motor
Revision 0:ada50658d850, committed 2017-03-15
- Comitter:
- jplager3
- Date:
- Wed Mar 15 04:39:15 2017 +0000
- Child:
- 1:4eeea974ff65
- Commit message:
- Roomba robot program. Currently displays on LCD and plays sounds.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/4DGL-uLCD-SE.lib Wed Mar 15 04:39:15 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/4180_1/code/4DGL-uLCD-SE/#2cb1845d7681
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Wed Mar 15 04:39:15 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ShiftBrite.lib Wed Mar 15 04:39:15 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/jwaters9/code/ShiftBrite/#466ea48e852a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Mar 15 04:39:15 2017 +0000
@@ -0,0 +1,63 @@
+#include "mbed.h"
+#include "rtos.h"
+#include "uLCD_4DGL.h"
+//#include "ShiftBrite.h"
+#include "SDFileSystem.h"
+#include "wave_player.h"
+
+Mutex mutex; //
+Mutex mutex2; //
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+Thread thread1;
+Thread thread2;
+Thread thread3;
+Thread thread4;
+//DigitalOut latch(p15);
+//DigitalOut enable(p16);
+SPI spi(p11, p12, p13);
+//uLCD_4DGL uLCD(p28,p27,p29); //(p27, p28, p30); //tx, rx, rst
+uLCD_4DGL uLCD(p28, p27, p30);
+//ShiftBrite myBrite(p15,p16,spi); //latch, enable, spi
+SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
+AnalogOut DACout(p18); //must be p18
+//RawSerial BT(p9, p10); //bluetooth pinout
+FILE *wave_file = NULL; //global bc its gotta be changed by Main while running in child thread
+wave_player waver(&DACout); //create wave_player object for speaker
+
+void LCD_thread1() {
+ while(1){
+ mutex.lock();
+ uLCD.filled_circle(64, 64, 12, 0xFF0000);
+ mutex.unlock();
+ wait(.5);
+ mutex.lock();
+ uLCD.filled_circle(64, 64, 12, 0x0000FF);
+ mutex.unlock();
+ wait(.5);
+ }
+}
+void sound_thread(){
+ //FILE *wave_file;
+ wave_file=fopen("/sd/Police_Siren.wav","r");
+ if (wave_file == NULL){
+ led1=led2=led3=led4 = 1; // if file read error, all LEDs ON
+ }
+ waver.play(wave_file);
+ fclose(wave_file);
+}
+int main() {
+ //thread1.start(IR_thread); // read in IR data
+ thread2.start(LCD_thread1);
+ //thread3.start(Motor_thread);
+ thread4.start(sound_thread);
+
+ while(1){ // poor coding practice, I know
+
+ }
+ // use mutex to lock getc(), printf(), scanf()
+ // don't unlock until you've checked that it's readable()
+
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Wed Mar 15 04:39:15 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed-rtos/#58563e6cba1e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Mar 15 04:39:15 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/ef9c61f8c49f \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wave_player.lib Wed Mar 15 04:39:15 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/sravet/code/wave_player/#acc3e18e77ad