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

This commit is contained in:
Travis Burtrum 2020-12-30 01:34:03 -05:00
parent a4cb9d52c4
commit 966f1c7e36
3 changed files with 40 additions and 34 deletions

View File

@ -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
| 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* |

View File

@ -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;
* 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,22 +196,31 @@ 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);
#endif
}
// 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) {
data->xAxis = -1 * (0xff - data->xAxis);
@ -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" : "-");

View File

@ -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