Sound update
Dependencies: 4DGL-uLCD-SE Physac-MBED PinDetect SDFileSystem mbed-rtos mbed
Revision 16:6cf744b2623a, committed 20 months ago
- Comitter:
- jstephens78
- Date:
- Wed Nov 30 21:43:44 2022 +0000
- Parent:
- 12:5d913b57da7c
- Child:
- 17:3517251daf96
- Commit message:
- Add NavSwitch input for player 2 in hockey
Changed in this revision
--- a/globals.h Wed Nov 30 21:20:21 2022 +0000 +++ b/globals.h Wed Nov 30 21:43:44 2022 +0000 @@ -14,13 +14,17 @@ extern uLCD_4DGL uLCD; extern Mutex uLCD_mutex; + extern BluefruitController blue; -//extern SDFileSystem sd; -//extern DigitalOut myled; +extern BusIn navSwitch; + +extern SDFileSystem sd; +extern DigitalOut myled; +extern PwmOut Rgb; +extern PwmOut rGb; +extern PwmOut rgB; +extern PwmOut PWMout; + //extern AnalogOut DACout; -//extern PwmOut Rgb; -//extern PwmOut rGb; -//extern PwmOut rgB; -//extern PwmOut PWMout; //extern wave_player waver;
--- a/hockey/hockey.cpp Wed Nov 30 21:20:21 2022 +0000
+++ b/hockey/hockey.cpp Wed Nov 30 21:43:44 2022 +0000
@@ -281,12 +281,10 @@
runGameLogic();
}
- float phys_time = timer.read() * 1000;
// Render the game
drawDynamicObjects();
- float render_time = timer.read()*1000 - phys_time;
-
+
// Process input from the game
blue.parseMessage();
if (blue.button[BUTTON_UP]) {
@@ -313,8 +311,25 @@
SetPhysicsBodyRotation(paddle_a, paddle_a->orient + dt * input_sensitivity * 0.05);
printf("CCW\r\n");
}
-
- float input_time = timer.read()*1000 - render_time - phys_time;
+
+ // Player 2 Input
+ if (!(navSwitch & 0b00001)) { // Up
+ paddle_b->position.y -= dt * input_sensitivity;
+ }
+ if (!(navSwitch & 0b01000)) { // down
+ paddle_b->position.y += dt * input_sensitivity;
+ }
+ if (!(navSwitch & 0b00100)) { // left
+ paddle_b->position.x -= dt * input_sensitivity;
+ }
+ if (!(navSwitch & 0b10000)) { // right
+ paddle_b->position.x += dt * input_sensitivity;
+ }
+ if (!(navSwitch & 0b00010)) { // rotate
+ SetPhysicsBodyRotation(paddle_b, paddle_b->orient + 3.14159 / 4);
+ }
+
+ Thread::yield();
}
ClosePhysics(); // Unitialize physics
--- a/main.cpp Wed Nov 30 21:20:21 2022 +0000
+++ b/main.cpp Wed Nov 30 21:43:44 2022 +0000
@@ -8,19 +8,20 @@
#include "SDFileSystem.h"
#include "uLCD_4DGL.h"
-//SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
+uLCD_4DGL uLCD(p9,p10,p30);
+BluefruitController blue(p13,p14);
+BusIn navSwitch(p15, p16, p17, p18, p19);
+
+SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
DigitalOut myled(LED1);
//AnalogOut DACout(p20);
-//PwmOut Rgb(p23);
-//PwmOut rGb(p24);
-//PwmOut rgB(p25);
-//PwmOut PWMout(p21);
+PwmOut Rgb(p23);
+PwmOut rGb(p24);
+PwmOut rgB(p25);
+PwmOut PWMout(p21);
//wave_player waver(&DACout);
-uLCD_4DGL uLCD(p9,p10,p30);
-BluefruitController blue(p13,p14);
-
volatile bool game1 = false;
volatile bool game2 = false;
@@ -45,9 +46,11 @@
fclose(wave_file);
}
}
+*/
void thread4(void const *argument)
{
+ /*
float x = 0.0;
while(1) {
//get a new random number for PWM
@@ -68,17 +71,17 @@
Thread::wait(4000.0 * rand() / float(RAND_MAX));
}
}
+ */
}
-*/
+
int main()
{
printf("Starting thread 2\r\n");
game2 = true;
Thread thread2(hockeyGame);
//Thread thread3(thread3);
- //Thread thread4(thread4);
-
- printf("Blinking LED:\r\n");
+// Thread thread4(thread4);
+
while (true) {
myled = 1;
Thread::wait(500);