Browse Source

Change ESP32 pin layout once again, tweak N64Esp32.cpp, still doesn't work quite right

master
Travis Burtrum 2 years ago
parent
commit
966f1c7e36
  1. 4
      readme.md
  2. 55
      src/N64Esp32.cpp
  3. 13
      src/pins.h

4
readme.md

@ -25,7 +25,7 @@ Wiring @@ -25,7 +25,7 @@ Wiring
| DB-25 Pins | Arduino Pro Micro GPIO | ESP32 GPIO | Radio | SNES | PSX | N64 | Gamecube | Genesis |
|---------------|------------------------|------------|----------|--------|--------|----------|----------|-------------|
| 1 TX | 1 | 1 | - | LATCH | - | - | - | P1-1 |
| 1 TX | 1 | 19 | - | LATCH | - | - | - | P1-1 |
| 2 SDA | 2 | 21 | - | CLOCK | DATA | DATA1 | DATA1 | P1-3 |
| 3 SCL | 3 | 22 | - | DATA1 | CMD | - | - | P1-4 |
| 4 Analog | 4 | 15 | - | DATA2 | ATT | - | - | P1-6 |
@ -35,7 +35,7 @@ Wiring @@ -35,7 +35,7 @@ Wiring
| 8 Analog | 8 | 4 | CSN | - | - | - | - | - |
| 9 Analog | 9 > 1k Ω | 35 > 1k Ω | - | 330 Ω | 100 Ω | 220 Ω | 680 Ω | 470 Ω |
| 10 Analog | 10 | 32 | - | - | - | - | - | - |
| 11 RX | 0 | 3 | - | - | - | - | - | P1-2 |
| 11 RX | 0 | 18 | - | - | - | - | - | P1-2 |
| 12 - | - | - | - | - | - | - | - | - |
| 13 - | - | - | - | - | - | - | - | - |
| 14 MISO | 14 | 12 | MISO | - | - | - | - | P2-6* |

55
src/N64Esp32.cpp

@ -12,11 +12,14 @@ PIN # USAGE @@ -12,11 +12,14 @@ PIN # USAGE
VCC +3.3V ONLY
*/
#define DATA_PIN 13
#include "Arduino.h"
//#define PRINT_Y_AXIS_VALUES 1
//#define PRINT_X_AXIS_VALUES 1
#include "pins.h"
#define DATA_PIN OR_PIN_2
#define PRINT_Y_AXIS_VALUES 1
#define PRINT_X_AXIS_VALUES 1
//#define PLOT_CONSOLE_POLLING 1
#define DEBUG
@ -80,14 +83,7 @@ int bitResolution; @@ -80,14 +83,7 @@ int bitResolution;
* Must be run from RAM to defy timing differences introduced from
* reading Code from ESP32's SPI Flash Chip.
*/
//#ifdef ARDUINO_ARCH_ESP32
#if defined(CONFIG_BT_ENABLED)
void IRAM_ATTR sendCommand(byte command)
#else
// todo: what should be done here??
void sendCommand(byte command)
#endif
{
void IRAM_ATTR sendCommand(byte command) {
// the current bit to write
bool bit;
@ -200,21 +196,30 @@ void populateControllerStruct(ControllerData *data) { @@ -200,21 +196,30 @@ void populateControllerStruct(ControllerData *data) {
for (int i = 0; i < 8; i++) {
data->xAxis += (data->xAxisRaw[i] * (0x80 >> (i)));
data->yAxis += (data->yAxisRaw[i] * (0x80 >> (i)));
}
// print y axis values
#ifdef PRINT_Y_AXIS_VALUES
Serial.printf(
"yRaw: %i %i %i %i %i %i %i %i\n", data->yAxisRaw[0], data->yAxisRaw[1], data->yAxisRaw[2], data->yAxisRaw[3], data->yAxisRaw[4], data->yAxisRaw[5], data->yAxisRaw[6], data->yAxisRaw[7]);
Serial.printf("yAxis: %i \n", data->yAxis);
#endif
// print x axis values
#ifdef PRINT_X_AXIS_VALUES
Serial.printf(
"xRaw: %i %i %i %i %i %i %i %i\n", data->xAxisRaw[0], data->xAxisRaw[1], data->xAxisRaw[2], data->xAxisRaw[3], data->xAxisRaw[4], data->xAxisRaw[5], data->xAxisRaw[6], data->xAxisRaw[7]);
Serial.printf("xAxis: %i \n", data->xAxis);
// print axis values
#ifdef DEBUG
Serial.printf("yRaw: %i %i %i %i %i %i %i %i xRaw: %i %i %i %i %i %i %i %i yAxis: %03i xAxis: %03i",
data->yAxisRaw[0],
data->yAxisRaw[1],
data->yAxisRaw[2],
data->yAxisRaw[3],
data->yAxisRaw[4],
data->yAxisRaw[5],
data->yAxisRaw[6],
data->yAxisRaw[7],
data->xAxisRaw[0],
data->xAxisRaw[1],
data->xAxisRaw[2],
data->xAxisRaw[3],
data->xAxisRaw[4],
data->xAxisRaw[5],
data->xAxisRaw[6],
data->xAxisRaw[7],
data->yAxis,
data->xAxis);
#endif
}
// decode xAxis two's complement
if (data->xAxis & 0x80) {
@ -350,7 +355,7 @@ void loop() { @@ -350,7 +355,7 @@ void loop() {
//checkUpdateCombo(&controller);
#ifdef DEBUG
Serial.print("buttons: ");
Serial.print(" buttons: ");
Serial.print(controller.buttonA ? "A" : "-");
Serial.print(controller.buttonB ? "B" : "-");
Serial.print(controller.buttonZ ? "Z" : "-");

13
src/pins.h

@ -6,24 +6,25 @@ @@ -6,24 +6,25 @@
#if defined(ARDUINO_ARCH_ESP32)
// esp32
#define OR_PIN_1 1
#define OR_PIN_1 19
#define OR_PIN_2 21
#define OR_PIN_3 22
#define OR_PIN_4 15
#define OR_PIN_4 15 // pwm at boot
#define OR_PIN_5 16
#define OR_PIN_6 2
#define OR_PIN_6 2 // connected to led
#define OR_PIN_7 17
#define OR_PIN_8 4
#define OR_PIN_9 35
#define OR_PIN_10 32
#define OR_PIN_11 3
#define OR_PIN_14 12
#define OR_PIN_15 14
#define OR_PIN_11 18
#define OR_PIN_14 12 // boot fail if pulled high
#define OR_PIN_15 14 // pwm at boot
#define OR_PIN_16 13
#define OR_PIN_18 27
#define OR_PIN_19 26
#define OR_PIN_20 25
#define OR_PIN_21 33
// 23
#else
// micro
#define OR_PIN_1 1

Loading…
Cancel
Save