From 85e5857a154866a090da7538608dbce458d3cccb Mon Sep 17 00:00:00 2001 From: nimeissn Date: Wed, 16 Feb 2022 19:34:30 +0100 Subject: [PATCH] Feld gedreht --- .../Matrix/Ping Pong/.vscode/extensions.json | 17 +++--- VSCode/Matrix/Ping Pong/platformio.ini | 3 +- VSCode/Matrix/Ping Pong/src/main.cpp | 4 +- VSCode/Pong/.vscode/extensions.json | 17 +++--- VSCode/Pong/platformio.ini | 5 +- VSCode/Pong/src/main.cpp | 59 ++++++++++--------- 6 files changed, 58 insertions(+), 47 deletions(-) diff --git a/VSCode/Matrix/Ping Pong/.vscode/extensions.json b/VSCode/Matrix/Ping Pong/.vscode/extensions.json index 0f0d740..080e70d 100755 --- a/VSCode/Matrix/Ping Pong/.vscode/extensions.json +++ b/VSCode/Matrix/Ping Pong/.vscode/extensions.json @@ -1,7 +1,10 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ] -} +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/VSCode/Matrix/Ping Pong/platformio.ini b/VSCode/Matrix/Ping Pong/platformio.ini index 0877fc4..2cbf1ec 100755 --- a/VSCode/Matrix/Ping Pong/platformio.ini +++ b/VSCode/Matrix/Ping Pong/platformio.ini @@ -9,8 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [env:nanoatmega328new] -platform = atmelavr -board = nanoatmega328 +board = esp32dev framework = arduino lib_deps = adafruit/Adafruit NeoMatrix@^1.2.0 diff --git a/VSCode/Matrix/Ping Pong/src/main.cpp b/VSCode/Matrix/Ping Pong/src/main.cpp index 2442aee..5f6ef37 100755 --- a/VSCode/Matrix/Ping Pong/src/main.cpp +++ b/VSCode/Matrix/Ping Pong/src/main.cpp @@ -33,8 +33,8 @@ Example sketch for driving Adafruit WS2801 pixels! // Can be any valid output pins. // The colors of the wires may be totally different so // BE SURE TO CHECK YOUR PIXELS TO SEE WHICH WIRES TO USE! -uint8_t dataPin = 6; // Yellow wire on Adafruit Pixels -uint8_t clockPin = 3; // Green wire on Adafruit Pixels +uint8_t dataPin = 2; // Yellow wire on Adafruit Pixels +uint8_t clockPin = 4; // Green wire on Adafruit Pixels // Don't forget to connect the ground wire to Arduino ground, // and the +5V wire to a +5V supply diff --git a/VSCode/Pong/.vscode/extensions.json b/VSCode/Pong/.vscode/extensions.json index 0f0d740..080e70d 100755 --- a/VSCode/Pong/.vscode/extensions.json +++ b/VSCode/Pong/.vscode/extensions.json @@ -1,7 +1,10 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ] -} +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/VSCode/Pong/platformio.ini b/VSCode/Pong/platformio.ini index 4087342..ebc2324 100755 --- a/VSCode/Pong/platformio.ini +++ b/VSCode/Pong/platformio.ini @@ -9,9 +9,10 @@ ; https://docs.platformio.org/page/projectconf.html [env:uno] -platform = atmelavr -board = nanoatmega328 +board = esp32dev framework = arduino lib_deps = adafruit/Adafruit NeoPixel@^1.10.4 adafruit/Adafruit WS2801 Library@^1.1.1 + lbernstone/Tone32@^1.0.0 +platform = espressif32 diff --git a/VSCode/Pong/src/main.cpp b/VSCode/Pong/src/main.cpp index 3a0454d..a6fb9fc 100755 --- a/VSCode/Pong/src/main.cpp +++ b/VSCode/Pong/src/main.cpp @@ -1,5 +1,6 @@ #include #include +#include /** * Player 1: x = 0 @@ -7,14 +8,16 @@ */ #define PIN_LED_MATRIX 2 -#define PIN_JOYSTICK_1_BUTTON 6 -#define PIN_JOYSTICK_2_BUTTON 7 -#define PIN_PIEZO 11 -#define PIN_JOYSTICK_1_Y A0 -#define PIN_JOYSTICK_2_Y A1 +#define PIN_JOYSTICK_1_BUTTON 12 +#define PIN_JOYSTICK_2_BUTTON 26 +#define PIN_PIEZO 17 +#define PIN_JOYSTICK_1_Y 13 +#define PIN_JOYSTICK_2_Y 27 +#define PIN_JOYSTICK_1_X 14 +#define PIN_JOYSTICK_2_X 25 #define JOYSTICK_OFFSET_MIN 200 -#define JOYSTICK_OFFSET_MAX 700 +#define JOYSTICK_OFFSET_MAX 3500 #define DEBOUNCE_TIME 300 // in ms @@ -50,8 +53,8 @@ #define GAME_STATE_INIT 3 #include -uint8_t dataPin = 6; -uint8_t clockPin = 3; +uint8_t dataPin = 2; +uint8_t clockPin = 4; struct Coords { byte x; @@ -123,7 +126,9 @@ void setup() pinMode(PIN_JOYSTICK_2_BUTTON, INPUT_PULLUP); pixels.begin(); resetLEDs(); + gameState = GAME_STATE_END; + } void loop() @@ -150,17 +155,17 @@ void initGame() resetLEDs(); lastButtonClick = millis(); - ball.x = 1; - ball.y = (Y_MAX/2) - (PADDLE_WIDTH/2) + 1; - ballMovement[0] = 1; - ballMovement[1] = -1; + ball.y = 1; + ball.x = (X_MAX/2) - (PADDLE_WIDTH/2) + 1; + ballMovement[0] = -1; + ballMovement[1] = 1; ballDelay = BALL_DELAY_MAX; for(byte i=0; i= X_MAX-1) { + if (ball.y <=0 || ball.y >= Y_MAX-1) { endGame(); return; } - if (ball.y <= 0 || ball.y >= Y_MAX-1) { - ballMovement[1] *= -1; + if (ball.x <= 0 || ball.x >= X_MAX-1) { + ballMovement[0] *= -1; playTone(TONE_WALL); } @@ -245,14 +250,14 @@ void updateGame() // move paddles for(byte p=0; p 0) { + if (movement == PADDLE_MOVE_DOWN && paddles[p][0].x > 0) { for(byte i=0; i