From 8f76a228139a3919ccf9e29be5096388a7e34484 Mon Sep 17 00:00:00 2001 From: chris007de Date: Mon, 22 Jan 2024 21:08:16 +0100 Subject: [PATCH 01/12] Add ayab-esp32 Build environment --- platformio.ini | 10 +++++++--- src/ayab/board.h | 36 ++++++++++++++++++++++++++---------- src/ayab/main.cpp | 14 +++++++------- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/platformio.ini b/platformio.ini index cf5bd9d53..25d4ee999 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,13 +9,17 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -default_envs = uno +default_envs = uno, ayab-esp32 [env] framework = arduino -extra_scripts = - pre:scripts/preBuild.py +extra_scripts = + pre:scripts/preBuild.py [env:uno] platform = atmelavr board = uno + +[env:ayab-esp32] +platform = espressif32 +board = esp32-s3-devkitm-1 diff --git a/src/ayab/board.h b/src/ayab/board.h index 6b3f79512..4cc2edc8c 100644 --- a/src/ayab/board.h +++ b/src/ayab/board.h @@ -26,6 +26,19 @@ #include +#ifdef DBG_NOMACHINE // Turn on to use DBG_BTN_PIN as EOL Trigger +constexpr uint8_t DBG_BTN_PIN = 7; // DEBUG BUTTON +#endif + +constexpr uint8_t I2Caddr_sol1_8 = 0x0U; ///< I2C Address of solenoids 1 - 8 +constexpr uint8_t I2Caddr_sol9_16 = 0x1U; ///< I2C Address of solenoids 9 - 16 + +// TODO(Who?): Optimize Delay for various Arduino Models +constexpr uint16_t START_KNITTING_DELAY = 2000U; // ms + +// Determine board type +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +// Arduino Uno // Pin Assignments constexpr uint8_t EOL_PIN_R = A0; // Analog constexpr uint8_t EOL_PIN_L = A1; // Analog @@ -39,20 +52,23 @@ constexpr uint8_t LED_PIN_A = 5; // green LED constexpr uint8_t LED_PIN_B = 6; // yellow LED constexpr uint8_t PIEZO_PIN = 9; +#elif defined(CONFIG_IDF_TARGET_ESP32S3) +// ESP32-S3 (AYAB-ESP32) +// Pin Assignments -#ifdef DBG_NOMACHINE // Turn on to use DBG_BTN_PIN as EOL Trigger -constexpr uint8_t DBG_BTN_PIN = 7; // DEBUG BUTTON -#endif +// TODO: FILL WITH ACTUAL VALUES OF AYAB-ESP32 BOARD +constexpr uint8_t EOL_PIN_R = 0; // Analog +constexpr uint8_t EOL_PIN_L = 0; // Analog -constexpr uint8_t I2Caddr_sol1_8 = 0x0U; ///< I2C Address of solenoids 1 - 8 -constexpr uint8_t I2Caddr_sol9_16 = 0x1U; ///< I2C Address of solenoids 9 - 16 +constexpr uint8_t ENC_PIN_A = 0; +constexpr uint8_t ENC_PIN_B = 0; -// TODO(Who?): Optimize Delay for various Arduino Models -constexpr uint16_t START_KNITTING_DELAY = 2000U; // ms +constexpr uint8_t ENC_PIN_C = 0; -// Determine board type -#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) -// Arduino Uno +constexpr uint8_t LED_PIN_A = 0; // green LED +constexpr uint8_t LED_PIN_B = 0; // yellow LED + +constexpr uint8_t PIEZO_PIN = 0; #else #error "untested board" #endif diff --git a/src/ayab/main.cpp b/src/ayab/main.cpp index 3da59d969..c92fc1d38 100644 --- a/src/ayab/main.cpp +++ b/src/ayab/main.cpp @@ -35,13 +35,13 @@ // Global definitions: references elsewhere must use `extern`. // Each of the following is a pointer to a singleton class // containing static methods. -constexpr GlobalBeeper *beeper; -constexpr GlobalCom *com; -constexpr GlobalEncoders *encoders; -constexpr GlobalFsm *fsm; -constexpr GlobalKnitter *knitter; -constexpr GlobalSolenoids *solenoids; -constexpr GlobalTester *tester; +constexpr GlobalBeeper *beeper = 0; +constexpr GlobalCom *com = 0; +constexpr GlobalEncoders *encoders = 0; +constexpr GlobalFsm *fsm = 0; +constexpr GlobalKnitter *knitter = 0; +constexpr GlobalSolenoids *solenoids = 0; +constexpr GlobalTester *tester = 0; // Initialize static members. // Each singleton class contains a pointer to a static instance From 754f4ea3a42a9ed8738a2a20e68d756fc55e987b Mon Sep 17 00:00:00 2001 From: matei jordache Date: Thu, 1 Feb 2024 17:40:55 -0500 Subject: [PATCH 02/12] Match hardware pins with firmware names --- src/ayab/board.h | 55 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/src/ayab/board.h b/src/ayab/board.h index 4cc2edc8c..22f7a44ba 100644 --- a/src/ayab/board.h +++ b/src/ayab/board.h @@ -52,23 +52,54 @@ constexpr uint8_t LED_PIN_A = 5; // green LED constexpr uint8_t LED_PIN_B = 6; // yellow LED constexpr uint8_t PIEZO_PIN = 9; -#elif defined(CONFIG_IDF_TARGET_ESP32S3) -// ESP32-S3 (AYAB-ESP32) -// Pin Assignments +#elif defined(CONFIG_IDF_TARGET_ESP32S3)// ESP32-S3 (AYAB-ESP32) + +// Knitting machine control +constexpr uint8_t EOL_PIN_R_N = 3; // Right EOL marker, each polarity. +constexpr uint8_t EOL_PIN_R_S = 4; + +constexpr uint8_t EOL_PIN_L_N = 1; // Left EOL marker, each polarity. +constexpr uint8_t EOL_PIN_L_S = 2; + +constexpr uint8_t ENC_PIN_A = 5; // Carriage movement A +constexpr uint8_t ENC_PIN_B = 6; // Carriage movement B +constexpr uint8_t ENC_PIN_C = 7; // Carriage belt phase alignment. + +constexpr uint8_t MCP_SDA_PIN = 8; // Internal I2C bus with MCP GPIO expander. +constexpr uint8_t MCP_SCL_PIN = 9; // I2C0 + +// Communication buses +constexpr uint8_t SPI_PIN_COPI = 12; // Internal SPI bus for future display. +constexpr uint8_t SPI_PIN_CIPO = 11; // SPI0 +constexpr uint8_t SPI_PIN_SCK = 13; +constexpr uint8_t SPI_PIN_CS = 10; + +constexpr uint8_t UART_PIN_TX = 43; // External bus for debugging and/or user. +constexpr uint8_t UART_PIN_RX = 44; // UART0 + +constexpr uint8_t I2C_PIN_SDA = 15; // External bus for user applications. +constexpr uint8_t I2C_PIN_SCL = 16; // I2C1 + +// Misc I/O +constexpr uint8_t LED_PIN_R = 33; +constexpr uint8_t LED_PIN_G = 34; +constexpr uint8_t LED_PIN_B = 35; -// TODO: FILL WITH ACTUAL VALUES OF AYAB-ESP32 BOARD -constexpr uint8_t EOL_PIN_R = 0; // Analog -constexpr uint8_t EOL_PIN_L = 0; // Analog +constexpr uint8_t PIEZO_PIN = 38; -constexpr uint8_t ENC_PIN_A = 0; -constexpr uint8_t ENC_PIN_B = 0; +// User I/O +constexpr uint8_t USER_BUTTON = 36; -constexpr uint8_t ENC_PIN_C = 0; +constexpr uint8_t USER_PIN_14 = 14; // Should these actually be like USER_0... etc? +constexpr uint8_t USER_PIN_17 = 17; // And then on the silk/ enclosure we put friendly numbers (0..8) instead of GPIO name? +constexpr uint8_t USER_PIN_18 = 18; +constexpr uint8_t USER_PIN_21 = 21; -constexpr uint8_t LED_PIN_A = 0; // green LED -constexpr uint8_t LED_PIN_B = 0; // yellow LED +constexpr uint8_t USER_PIN_39 = 39; +constexpr uint8_t USER_PIN_40 = 40; +constexpr uint8_t USER_PIN_41 = 41; +constexpr uint8_t USER_PIN_42 = 42; -constexpr uint8_t PIEZO_PIN = 0; #else #error "untested board" #endif From 9d1b1fb81519b1c82e074de48a8850a5a52a3116 Mon Sep 17 00:00:00 2001 From: matei jordache Date: Thu, 1 Feb 2024 20:31:37 -0500 Subject: [PATCH 03/12] Add board definition --- boards/ayab-esp32.json | 57 ++++++++++++++++++++++++++++++++++++++++++ platformio.ini | 2 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 boards/ayab-esp32.json diff --git a/boards/ayab-esp32.json b/boards/ayab-esp32.json new file mode 100644 index 000000000..3518a571b --- /dev/null +++ b/boards/ayab-esp32.json @@ -0,0 +1,57 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32s3_out.ld", + "partitions": "partitions-4MB-tinyuf2.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DBOARD_HAS_PSRAM" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x239A", + "0x811B" + ], + [ + "0x239A", + "0x011B" + ], + [ + "0x239A", + "0x811C" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "AYAB-ESP32", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://ayab-knitting.com", + "vendor": "AllYarnsAreBeautiful" + } \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 25d4ee999..9d5adb81d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -22,4 +22,4 @@ board = uno [env:ayab-esp32] platform = espressif32 -board = esp32-s3-devkitm-1 +board = ayab-esp32 From bd93e8f8d1530fdaab29b8ea44a5f4c3d17ba26a Mon Sep 17 00:00:00 2001 From: matei jordache Date: Thu, 1 Feb 2024 20:34:11 -0500 Subject: [PATCH 04/12] Add aliases for LED_PIN_A, LED_PIN_B --- src/ayab/board.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ayab/board.h b/src/ayab/board.h index 22f7a44ba..b2027d4e4 100644 --- a/src/ayab/board.h +++ b/src/ayab/board.h @@ -81,6 +81,9 @@ constexpr uint8_t I2C_PIN_SDA = 15; // External bus for user applications. constexpr uint8_t I2C_PIN_SCL = 16; // I2C1 // Misc I/O +#define LED_PIN_A LED_PIN_G +#define LED_PIN_B LED_PIN_R + constexpr uint8_t LED_PIN_R = 33; constexpr uint8_t LED_PIN_G = 34; constexpr uint8_t LED_PIN_B = 35; From 6cacd76a2258780a0b198681f0c16d32e1b49a96 Mon Sep 17 00:00:00 2001 From: matei jordache Date: Thu, 1 Feb 2024 21:34:56 -0500 Subject: [PATCH 05/12] Add libraries as PIO dependencies --- .gitmodules | 6 ------ platformio.ini | 10 ++++++++-- 2 files changed, 8 insertions(+), 8 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 879382468..000000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "libraries/PacketSerial"] - path = lib/PacketSerial - url = https://github.com/bakercp/PacketSerial.git -[submodule "libraries/Adafruit_MCP23008"] - url = https://github.com/adafruit/Adafruit-MCP23008-library.git - path = lib/Adafruit_MCP23008 diff --git a/platformio.ini b/platformio.ini index 9d5adb81d..d5443ede5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,13 +13,19 @@ default_envs = uno, ayab-esp32 [env] framework = arduino -extra_scripts = - pre:scripts/preBuild.py +extra_scripts = + pre:scripts/preBuild.py [env:uno] platform = atmelavr board = uno +lib_deps = + adafruit/Adafruit MCP23017 Arduino Library@^2.3.2 + bakercp/PacketSerial@^1.4.0 [env:ayab-esp32] platform = espressif32 board = ayab-esp32 +lib_deps = + adafruit/Adafruit MCP23017 Arduino Library@^2.3.2 + bakercp/PacketSerial@^1.4.0 From 815e3c953ea5e46045803741ea19ac9b83d80d2e Mon Sep 17 00:00:00 2001 From: matei jordache Date: Sun, 4 Feb 2024 21:52:59 -0500 Subject: [PATCH 06/12] Implement MCP23017 expander --- src/ayab/board.h | 9 +++++---- src/ayab/encoders.cpp | 3 +-- src/ayab/solenoids.cpp | 29 +++++++++++++++++++++++++++++ src/ayab/solenoids.h | 5 +++++ 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/ayab/board.h b/src/ayab/board.h index b2027d4e4..9228543b1 100644 --- a/src/ayab/board.h +++ b/src/ayab/board.h @@ -32,12 +32,14 @@ constexpr uint8_t DBG_BTN_PIN = 7; // DEBUG BUTTON constexpr uint8_t I2Caddr_sol1_8 = 0x0U; ///< I2C Address of solenoids 1 - 8 constexpr uint8_t I2Caddr_sol9_16 = 0x1U; ///< I2C Address of solenoids 9 - 16 +constexpr uint8_t MCP23017_ADDR_0 = 0x0U; // I2C address of expander on ayab-esp32 (16-wide) -// TODO(Who?): Optimize Delay for various Arduino Models +// TODO(Who?): Optimize Delay for various Arduino Models (does ESP32 need this? Probably no?) constexpr uint16_t START_KNITTING_DELAY = 2000U; // ms // Determine board type #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#define HAS_MCP23008 // Arduino Uno // Pin Assignments constexpr uint8_t EOL_PIN_R = A0; // Analog @@ -54,6 +56,8 @@ constexpr uint8_t LED_PIN_B = 6; // yellow LED constexpr uint8_t PIEZO_PIN = 9; #elif defined(CONFIG_IDF_TARGET_ESP32S3)// ESP32-S3 (AYAB-ESP32) +#define HAS_MCP23017 + // Knitting machine control constexpr uint8_t EOL_PIN_R_N = 3; // Right EOL marker, each polarity. constexpr uint8_t EOL_PIN_R_S = 4; @@ -81,9 +85,6 @@ constexpr uint8_t I2C_PIN_SDA = 15; // External bus for user applications. constexpr uint8_t I2C_PIN_SCL = 16; // I2C1 // Misc I/O -#define LED_PIN_A LED_PIN_G -#define LED_PIN_B LED_PIN_R - constexpr uint8_t LED_PIN_R = 33; constexpr uint8_t LED_PIN_G = 34; constexpr uint8_t LED_PIN_B = 35; diff --git a/src/ayab/encoders.cpp b/src/ayab/encoders.cpp index 89ec47d9c..8094f41cb 100644 --- a/src/ayab/encoders.cpp +++ b/src/ayab/encoders.cpp @@ -23,9 +23,8 @@ * http://ayab-knitting.com */ -#include "board.h" #include - +#include "board.h" #include "encoders.h" diff --git a/src/ayab/solenoids.cpp b/src/ayab/solenoids.cpp index b74c8124c..92df7b46e 100644 --- a/src/ayab/solenoids.cpp +++ b/src/ayab/solenoids.cpp @@ -29,6 +29,7 @@ * \brief Initialize I2C connection for solenoids. */ void Solenoids::init() { + #ifdef HAS_MCP23008 mcp_0.begin(I2Caddr_sol1_8); mcp_1.begin(I2Caddr_sol9_16); @@ -36,6 +37,15 @@ void Solenoids::init() { mcp_0.pinMode(i, OUTPUT); mcp_1.pinMode(i, OUTPUT); } + + #elif HAS_MCP23017 + mcp.begin_I2C(MCP23017_ADDR_0); + + for (uint8_t i = 0; i < SOLENOID_BUFFER_SIZE; i++){ + mcp.pinMode(i, OUTPUT); + } + + #endif solenoidState = 0x0000U; } @@ -95,7 +105,26 @@ void Solenoids::setSolenoids(uint16_t state) { // GCOVR_EXCL_START void Solenoids::write(uint16_t newState) { (void)newState; + #if defined(HAS_MCP23008) mcp_0.writeGPIO(lowByte(newState)); mcp_1.writeGPIO(highByte(newState)); + + #elif defined(HAS_MCP23017) + // We need to shuffle the bits around due to hardware layout. + // GPA0..8 => solenoid 8-F + // GPB0..8 => solenoid 7-0 + // Adafruit mapping: GPA0...8, GPB0..8 => 0..15 + newState = (newState << 8); + + uint8_t reversedByte = 0; + for(uint8_t i = 0; i < 8; i++){ + reversedByte[i] = (highByte(newState) >> (7-i)) & 0x01; + } + + newState = newState & reversedByte; + + mcp.writeGPIOAB(newState); + + #endif } // GCOVR_EXCL_STOP diff --git a/src/ayab/solenoids.h b/src/ayab/solenoids.h index f5c895806..5a8aa062e 100644 --- a/src/ayab/solenoids.h +++ b/src/ayab/solenoids.h @@ -28,6 +28,7 @@ #include "encoders.h" #include #include +#include #include // Different machines have a different number of solenoids. @@ -84,8 +85,12 @@ class Solenoids : public SolenoidsInterface { uint16_t solenoidState = 0x0000U; void write(uint16_t state); + #if defined(HAS_MCP23008) Adafruit_MCP23008 mcp_0 = Adafruit_MCP23008(); Adafruit_MCP23008 mcp_1 = Adafruit_MCP23008(); + #elif defined(HAS_MCP23017) + Adafruit_MCP23X17 mcp = Adafruit_MCP23X17(); + #endif }; #endif // SOLENOIDS_H_ From 1e2ee83aba9b7abc049b4cc32a660c86a5c4110d Mon Sep 17 00:00:00 2001 From: matei jordache Date: Mon, 5 Feb 2024 11:40:15 -0500 Subject: [PATCH 07/12] Clean up messy code and fix bug --- src/ayab/solenoids.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ayab/solenoids.cpp b/src/ayab/solenoids.cpp index 92df7b46e..cbc7b0ec1 100644 --- a/src/ayab/solenoids.cpp +++ b/src/ayab/solenoids.cpp @@ -114,16 +114,15 @@ void Solenoids::write(uint16_t newState) { // GPA0..8 => solenoid 8-F // GPB0..8 => solenoid 7-0 // Adafruit mapping: GPA0...8, GPB0..8 => 0..15 - newState = (newState << 8); + uint16_t bankA = (newState >> 8); // map solenoids 8..F to 0..7 GPIO A - uint8_t reversedByte = 0; + uint16_t bankB = 0; for(uint8_t i = 0; i < 8; i++){ - reversedByte[i] = (highByte(newState) >> (7-i)) & 0x01; + // Need to reverse the bits of the upper byte (which is located in the lower byte) + bankB[i+8] = (newState >> (7-i)) & 0x01; } - newState = newState & reversedByte; - - mcp.writeGPIOAB(newState); + mcp.writeGPIOAB(bankA & bankB); #endif } From e5b2d07c42f6f03b99b725aae913642de7a5c66a Mon Sep 17 00:00:00 2001 From: dl1com <1631996+dl1com@users.noreply.github.com> Date: Mon, 5 Feb 2024 20:55:27 +0100 Subject: [PATCH 08/12] Move lib_deps to [env] section --- platformio.ini | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index d5443ede5..dae64b6d5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,17 +15,14 @@ default_envs = uno, ayab-esp32 framework = arduino extra_scripts = pre:scripts/preBuild.py +lib_deps = + adafruit/Adafruit MCP23017 Arduino Library@^2.3.2 + bakercp/PacketSerial@^1.4.0 [env:uno] platform = atmelavr board = uno -lib_deps = - adafruit/Adafruit MCP23017 Arduino Library@^2.3.2 - bakercp/PacketSerial@^1.4.0 [env:ayab-esp32] platform = espressif32 board = ayab-esp32 -lib_deps = - adafruit/Adafruit MCP23017 Arduino Library@^2.3.2 - bakercp/PacketSerial@^1.4.0 From 71a11dae07c9579c7a6b9b4d7798031b3f86342c Mon Sep 17 00:00:00 2001 From: dl1com <1631996+dl1com@users.noreply.github.com> Date: Mon, 5 Feb 2024 20:57:33 +0100 Subject: [PATCH 09/12] Move I2C address definitions into respective platform sections --- src/ayab/board.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ayab/board.h b/src/ayab/board.h index 9228543b1..59d434211 100644 --- a/src/ayab/board.h +++ b/src/ayab/board.h @@ -30,17 +30,17 @@ constexpr uint8_t DBG_BTN_PIN = 7; // DEBUG BUTTON #endif -constexpr uint8_t I2Caddr_sol1_8 = 0x0U; ///< I2C Address of solenoids 1 - 8 -constexpr uint8_t I2Caddr_sol9_16 = 0x1U; ///< I2C Address of solenoids 9 - 16 -constexpr uint8_t MCP23017_ADDR_0 = 0x0U; // I2C address of expander on ayab-esp32 (16-wide) - // TODO(Who?): Optimize Delay for various Arduino Models (does ESP32 need this? Probably no?) constexpr uint16_t START_KNITTING_DELAY = 2000U; // ms // Determine board type #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) -#define HAS_MCP23008 // Arduino Uno + +#define HAS_MCP23008 +constexpr uint8_t I2Caddr_sol1_8 = 0x0U; ///< I2C Address of solenoids 1 - 8 +constexpr uint8_t I2Caddr_sol9_16 = 0x1U; ///< I2C Address of solenoids 9 - 16 + // Pin Assignments constexpr uint8_t EOL_PIN_R = A0; // Analog constexpr uint8_t EOL_PIN_L = A1; // Analog @@ -57,6 +57,7 @@ constexpr uint8_t PIEZO_PIN = 9; #elif defined(CONFIG_IDF_TARGET_ESP32S3)// ESP32-S3 (AYAB-ESP32) #define HAS_MCP23017 +constexpr uint8_t MCP23017_ADDR_0 = 0x0U; // I2C address of expander on ayab-esp32 (16-wide) // Knitting machine control constexpr uint8_t EOL_PIN_R_N = 3; // Right EOL marker, each polarity. @@ -72,7 +73,7 @@ constexpr uint8_t ENC_PIN_C = 7; // Carriage belt phase alignment. constexpr uint8_t MCP_SDA_PIN = 8; // Internal I2C bus with MCP GPIO expander. constexpr uint8_t MCP_SCL_PIN = 9; // I2C0 -// Communication buses +// Communication busses constexpr uint8_t SPI_PIN_COPI = 12; // Internal SPI bus for future display. constexpr uint8_t SPI_PIN_CIPO = 11; // SPI0 constexpr uint8_t SPI_PIN_SCK = 13; From 0b5d4ca4025819bff8b9fc54132a0121a34045c6 Mon Sep 17 00:00:00 2001 From: matei jordache Date: Mon, 5 Feb 2024 17:33:10 -0500 Subject: [PATCH 10/12] Try to fix submodule issues --- lib/Adafruit_MCP23008 | 1 - lib/PacketSerial | 1 - 2 files changed, 2 deletions(-) delete mode 160000 lib/Adafruit_MCP23008 delete mode 160000 lib/PacketSerial diff --git a/lib/Adafruit_MCP23008 b/lib/Adafruit_MCP23008 deleted file mode 160000 index 05fc9b8f6..000000000 --- a/lib/Adafruit_MCP23008 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 05fc9b8f68dd7e9f391aa80d4de1f0e5d396cbcb diff --git a/lib/PacketSerial b/lib/PacketSerial deleted file mode 160000 index 44c5b019a..000000000 --- a/lib/PacketSerial +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 44c5b019a17241015286d0f8766f102154d02b51 From 03e2a6da2899b9f370d7daf4405d430e9ccb9dd5 Mon Sep 17 00:00:00 2001 From: matei jordache Date: Mon, 5 Feb 2024 17:42:13 -0500 Subject: [PATCH 11/12] Update MCP23X08 to not use old lib --- src/ayab/solenoids.cpp | 4 ++-- src/ayab/solenoids.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ayab/solenoids.cpp b/src/ayab/solenoids.cpp index cbc7b0ec1..b7bb7f314 100644 --- a/src/ayab/solenoids.cpp +++ b/src/ayab/solenoids.cpp @@ -30,8 +30,8 @@ */ void Solenoids::init() { #ifdef HAS_MCP23008 - mcp_0.begin(I2Caddr_sol1_8); - mcp_1.begin(I2Caddr_sol9_16); + mcp_0.begin_I2C(I2Caddr_sol1_8); + mcp_1.begin_I2C(I2Caddr_sol9_16); for (uint8_t i = 0; i < SOLENOID_BUFFER_SIZE / 2; i++) { mcp_0.pinMode(i, OUTPUT); diff --git a/src/ayab/solenoids.h b/src/ayab/solenoids.h index 5a8aa062e..74c148c7a 100644 --- a/src/ayab/solenoids.h +++ b/src/ayab/solenoids.h @@ -27,7 +27,7 @@ #include "board.h" #include "encoders.h" #include -#include +#include #include #include @@ -86,8 +86,8 @@ class Solenoids : public SolenoidsInterface { void write(uint16_t state); #if defined(HAS_MCP23008) - Adafruit_MCP23008 mcp_0 = Adafruit_MCP23008(); - Adafruit_MCP23008 mcp_1 = Adafruit_MCP23008(); + Adafruit_MCP23X08 mcp_0 = Adafruit_MCP23X08(); + Adafruit_MCP23X08 mcp_1 = Adafruit_MCP23X08(); #elif defined(HAS_MCP23017) Adafruit_MCP23X17 mcp = Adafruit_MCP23X17(); #endif From 4eb13fefae7d0a88b35449e353772331bbd8641b Mon Sep 17 00:00:00 2001 From: matei jordache Date: Mon, 5 Feb 2024 17:49:46 -0500 Subject: [PATCH 12/12] Remove old libs from static analysis --- static_analysis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static_analysis.sh b/static_analysis.sh index d1cfd1e91..8cca2b5a5 100755 --- a/static_analysis.sh +++ b/static_analysis.sh @@ -1,2 +1,2 @@ #!/bin/bash -clang-tidy src/ayab/$1.cpp --fix -- -isystem /usr/share/arduino/hardware/arduino/cores/arduino/ -isystem /usr/lib/avr/include/ -isystem /usr/share/arduino/hardware/arduino/variants/standard -isystem libraries/Adafruit_MCP23008/ -isystem /usr/share/arduino/libraries/Wire/ -isystem libraries/PacketSerial/src/ -DCLANG_TIDY "${@:2}" +clang-tidy src/ayab/$1.cpp --fix -- -isystem /usr/share/arduino/hardware/arduino/cores/arduino/ -isystem /usr/lib/avr/include/ -isystem /usr/share/arduino/hardware/arduino/variants/standard -isystem /usr/share/arduino/libraries/Wire/ -DCLANG_TIDY "${@:2}"