Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement to the PWM output driver to use a "home" position when a servo output is set to zero. #550

Merged
merged 8 commits into from
Jul 28, 2022
Merged
2 changes: 2 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ jobs:
# M5Stack Atom
- target: "m5stack_atom"
chip: "esp32"
- target: "esp3deuxquatro_dmx"
chip: "esp32"

runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions ESPixelStick/src/GPIO_Defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ typedef enum
# include "platformDefinitions/GPIO_Defs_ESP8266_ESP01S.hpp"
#elif defined (BOARD_ESPS_V3)
# include "platformDefinitions/GPIO_Defs_ESP8266_ESPS_V3.hpp"
#elif defined (BOARD_ESPS_ESP3DEUXQUATRO_DMX)
# include "platformDefinitions/GPIO_Defs_ESP32_ESP3DEUXQuattro_DMX.hpp"
#elif defined (ARDUINO_ARCH_ESP32)
# include "platformDefinitions/GPIO_Defs_ESP32_generic.hpp"
#elif defined (ARDUINO_ARCH_ESP8266)
Expand Down
6 changes: 6 additions & 0 deletions ESPixelStick/src/output/OutputMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,12 @@ void c_OutputMgr::SetConfig(ArduinoJson::JsonDocument & ConfigData)
void c_OutputMgr::Render()
{
// DEBUG_START;

#ifdef LED_FLASH_GPIO
pinMode (LED_FLASH_GPIO, OUTPUT);
digitalWrite (LED_FLASH_GPIO, LED_FLASH_OFF);
#endif // def LED_FLASH_GPIO

// do we need to save the current config?
if (true == ConfigLoadNeeded)
{
Expand Down
9 changes: 8 additions & 1 deletion ESPixelStick/src/output/OutputServoPCA9685.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void c_OutputServoPCA9685::Begin ()
// DEBUG_END;
} // Begin

#ifdef UseCustomClearBuffer
//-----------------------------------------------------------------------------
void c_OutputServoPCA9685::ClearBuffer ()
{
Expand All @@ -99,6 +100,7 @@ void c_OutputServoPCA9685::ClearBuffer ()

// DEBUG_END;
} // ClearBuffer
#endif // def UseCustomClearBuffer

//----------------------------------------------------------------------------
bool c_OutputServoPCA9685::validate ()
Expand Down Expand Up @@ -272,7 +274,12 @@ void c_OutputServoPCA9685::Render ()
uint16_t MaxScaledValue = 255;
uint16_t MinScaledValue = 0;
uint16_t newOutputValue = pOutputBuffer[OutputDataIndex];


if(0 == newOutputValue)
{
newOutputValue = currentServoPCA9685.HomeValue;
}

if (currentServoPCA9685.Is16Bit)
{
// DEBUG_V ("16 Bit Mode");
Expand Down
2 changes: 1 addition & 1 deletion ESPixelStick/src/output/OutputServoPCA9685.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class c_OutputServoPCA9685 : public c_OutputCommon
void GetDriverName (String& sDriverName);
void GetStatus (ArduinoJson::JsonObject & jsonStatus) { c_OutputCommon::GetStatus (jsonStatus); }
size_t GetNumChannelsNeeded () { return Num_Channels; }
void ClearBuffer();
// void ClearBuffer();

private:
# define OM_SERVO_PCA9685_CHANNEL_LIMIT 16
Expand Down
22 changes: 6 additions & 16 deletions ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_CAM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,19 @@
#define DEFAULT_RMT_1_GPIO gpio_num_t::GPIO_NUM_16
#define RMT_LAST OutputChannelId_RMT_1

#define LED_FLASH_GPIO gpio_num_t::GPIO_NUM_33
#define LED_FLASH_OFF HIGH
#define LED_FLASH_GPIO gpio_num_t::GPIO_NUM_4
#define LED_FLASH_OFF LOW

// #define DEFAULT_I2C_SDA gpio_num_t::GPIO_NUM_21
// #define DEFAULT_I2C_SCL gpio_num_t::GPIO_NUM_22

// File Manager
// #define USE_MISO_PULLUP
// #define SUPPORT_SD_MMC
#define SUPPORT_SD
#ifdef SUPPORT_SD_MMC
# define SD_CARD_CMD gpio_num_t::GPIO_NUM_15
# define SD_CARD_CLK gpio_num_t::GPIO_NUM_14
# define SD_CARD_DATA_0 gpio_num_t::GPIO_NUM_2
# define SD_CARD_DATA_1 gpio_num_t::GPIO_NUM_4
# define SD_CARD_DATA_2 gpio_num_t::GPIO_NUM_12
# define SD_CARD_DATA_3 gpio_num_t::GPIO_NUM_13
#else // SUPPORT_SD
# define SD_CARD_MISO_PIN gpio_num_t::GPIO_NUM_2
# define SD_CARD_MOSI_PIN gpio_num_t::GPIO_NUM_15
# define SD_CARD_CLK_PIN gpio_num_t::GPIO_NUM_14
# define SD_CARD_CS_PIN gpio_num_t::GPIO_NUM_13
#endif // SUPPORT SD
#define SD_CARD_MISO_PIN gpio_num_t::GPIO_NUM_2
#define SD_CARD_MOSI_PIN gpio_num_t::GPIO_NUM_15
#define SD_CARD_CLK_PIN gpio_num_t::GPIO_NUM_14
#define SD_CARD_CS_PIN gpio_num_t::GPIO_NUM_13

// Output Types
// Not Finished - #define SUPPORT_OutputType_TLS3001
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#pragma once
/*
* GPIO_Defs_ESP32_ESP3DEUXQuattro_DMX.hpp - Output Management class
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
* Copyright (c) 2021 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
* subject to the laws and regulations where you are using it. Due diligence
* is strongly suggested before using this code. Please give credit where due.
*
* The Author makes no warranty of any kind, express or implied, with regard
* to this program or the documentation contained in this document. The
* Author shall not be liable in any event for incidental or consequential
* damages in connection with, or arising out of, the furnishing, performance
* or use of these programs.
*
* BOARD_ESPS_ESP3DEUXQUATRO_DMX
*/

//Output Manager
#define SUPPORT_UART_OUTPUT
#define DEFAULT_UART_1_GPIO gpio_num_t::GPIO_NUM_16
#define DEFAULT_UART_2_GPIO gpio_num_t::GPIO_NUM_32
#define UART_LAST OutputChannelId_UART_2

#define SUPPORT_RMT_OUTPUT
#define DEFAULT_RMT_0_GPIO gpio_num_t::GPIO_NUM_33
#define DEFAULT_RMT_1_GPIO gpio_num_t::GPIO_NUM_4
#define DEFAULT_RMT_2_GPIO gpio_num_t::GPIO_NUM_12
#define DEFAULT_RMT_3_GPIO gpio_num_t::GPIO_NUM_2
#define RMT_LAST OutputChannelId_RMT_4

// File Manager - Defnitions must be present even if SD is not supported
// #define SUPPORT_SD
#define SD_CARD_MISO_PIN gpio_num_t::GPIO_NUM_19
#define SD_CARD_MOSI_PIN gpio_num_t::GPIO_NUM_23
#define SD_CARD_CLK_PIN gpio_num_t::GPIO_NUM_18
#define SD_CARD_CS_PIN gpio_num_t::GPIO_NUM_5

#include <ETH.h>
#define SUPPORT_ETHERNET
/*
* ETH_CLOCK_GPIO0_IN - default: external clock from crystal oscillator
* ETH_CLOCK_GPIO0_OUT - 50MHz clock from internal APLL output on GPIO0 - possibly an inverter is needed for LAN8720
* ETH_CLOCK_GPIO16_OUT - 50MHz clock from internal APLL output on GPIO16 - possibly an inverter is needed for LAN8720
* ETH_CLOCK_GPIO17_OUT - 50MHz clock from internal APLL inverted output on GPIO17 - tested with LAN8720
*/
#define DEFAULT_ETH_CLK_MODE eth_clock_mode_t::ETH_CLOCK_GPIO17_OUT

// Pin# of the enable signal for the external crystal oscillator (-1 to disable for internal APLL source)
#define DEFAULT_ETH_POWER_PIN gpio_num_t(-1)
#define DEFAULT_ETH_POWER_PIN_ACTIVE HIGH

// Type of the Ethernet PHY (LAN8720 or TLK110)
#define DEFAULT_ETH_TYPE eth_phy_type_t::ETH_PHY_LAN8720

// I2C-address of Ethernet PHY (0 or 1 for LAN8720, 31 for TLK110)
// #define ETH_ADDR_PHY_LAN8720 0
#define ETH_ADDR_PHY_LAN8720 1
//#define ETH_ADDR_PHY_TLK110 31
#define DEFAULT_ETH_ADDR ETH_ADDR_PHY_LAN8720
#define DEFAULT_ETH_TXEN gpio_num_t::GPIO_NUM_21
#define DEFAULT_ETH_TXD0 gpio_num_t::GPIO_NUM_19
#define DEFAULT_ETH_TXD1 gpio_num_t::GPIO_NUM_22
#define DEFAULT_ETH_CRSDV gpio_num_t::GPIO_NUM_27
#define DEFAULT_ETH_RXD0 gpio_num_t::GPIO_NUM_25
#define DEFAULT_ETH_RXD1 gpio_num_t::GPIO_NUM_26
#define DEFAULT_ETH_MDC_PIN gpio_num_t::GPIO_NUM_23
#define DEFAULT_ETH_MDIO_PIN gpio_num_t::GPIO_NUM_18


// Output Types
// Not Finished - #define SUPPORT_OutputType_TLS3001
// #define SUPPORT_OutputType_APA102 // SPI
#define SUPPORT_OutputType_DMX // UART / RMT
#define SUPPORT_OutputType_GECE // UART / RMT
#define SUPPORT_OutputType_GS8208 // UART / RMT
#define SUPPORT_OutputType_Renard // UART / RMT
#define SUPPORT_OutputType_Serial // UART / RMT
#define SUPPORT_OutputType_TM1814 // UART / RMT
#define SUPPORT_OutputType_UCS1903 // UART / RMT
#define SUPPORT_OutputType_UCS8903 // UART / RMT
// #define SUPPORT_OutputType_WS2801 // SPI
#define SUPPORT_OutputType_WS2811 // UART / RMT
// #define SUPPORT_OutputType_Relay // GPIO
// #define SUPPORT_OutputType_Servo_PCA9685 // I2C (default pins)
1 change: 1 addition & 0 deletions html/apa102.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<option value="rbg">RBG</option>
<option value="gbr">GBR</option>
<option value="bgr">BGR</option>
<option value="wrgb">WRGB</option>
<option value="rgbw">RGBW</option>
<option value="grbw">GRBW</option>
<option value="brgw">BRGW</option>
Expand Down
1 change: 1 addition & 0 deletions html/gs8208.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<option value="rbg">RBG</option>
<option value="gbr">GBR</option>
<option value="bgr">BGR</option>
<option value="wrgb">WRGB</option>
<option value="rgbw">RGBW</option>
<option value="grbw">GRBW</option>
<option value="brgw">BRGW</option>
Expand Down
1 change: 1 addition & 0 deletions html/tls3001.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<option value="rbg">RBG</option>
<option value="gbr">GBR</option>
<option value="bgr">BGR</option>
<option value="wrgb">WRGB</option>
<option value="rgbw">RGBW</option>
<option value="grbw">GRBW</option>
<option value="brgw">BRGW</option>
Expand Down
1 change: 1 addition & 0 deletions html/tm1814.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<option value="rbg">RBG</option>
<option value="gbr">GBR</option>
<option value="bgr">BGR</option>
<option value="wrgb">WRGB</option>
<option value="rgbw">RGBW</option>
<option value="grbw">GRBW</option>
<option value="brgw">BRGW</option>
Expand Down
1 change: 1 addition & 0 deletions html/ucs1903.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<option value="rbg">RBG</option>
<option value="gbr">GBR</option>
<option value="bgr">BGR</option>
<option value="wrgb">WRGB</option>
<option value="rgbw">RGBW</option>
<option value="grbw">GRBW</option>
<option value="brgw">BRGW</option>
Expand Down
1 change: 1 addition & 0 deletions html/ucs8903.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<option value="rbg">RBG</option>
<option value="gbr">GBR</option>
<option value="bgr">BGR</option>
<option value="wrgb">WRGB</option>
<option value="rgbw">RGBW</option>
<option value="grbw">GRBW</option>
<option value="brgw">BRGW</option>
Expand Down
1 change: 1 addition & 0 deletions html/ws2801.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<option value="rbg">RBG</option>
<option value="gbr">GBR</option>
<option value="bgr">BGR</option>
<option value="wrgb">WRGB</option>
<option value="rgbw">RGBW</option>
<option value="grbw">GRBW</option>
<option value="brgw">BRGW</option>
Expand Down
1 change: 1 addition & 0 deletions html/ws2811.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<option value="rbg">RBG</option>
<option value="gbr">GBR</option>
<option value="bgr">BGR</option>
<option value="wrgb">WRGB</option>
<option value="rgbw">RGBW</option>
<option value="grbw">GRBW</option>
<option value="brgw">BRGW</option>
Expand Down
10 changes: 9 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
; Local configuration should be done in platformio_user.ini

[platformio]
default_envs = espsv3, d1_mini, d32_pro, d32_pro_eth, esp32_cam, esp32_ttgo_t8, d1_mini32, d1_mini32_eth, esp32_wt32eth01, esp32_quinled_quad, esp32_quinled_quad_ae_plus, esp32_quinled_quad_eth, esp32_quinled_uno, esp32_quinled_uno_ae_plus, esp32_quinled_uno_eth, esp32_quinled_dig_octa, esp01s, d1_mini_mhetesp32minikit, d1_mini_twilightlord, d1_mini_twilightlord_eth, esp32_devkitc, esp32_quinled_uno_eth_espsv3, m5stack_atom
default_envs = espsv3, d1_mini, d32_pro, d32_pro_eth, esp32_cam, esp32_ttgo_t8, d1_mini32, d1_mini32_eth, esp32_wt32eth01, esp32_quinled_quad, esp32_quinled_quad_ae_plus, esp32_quinled_quad_eth, esp32_quinled_uno, esp32_quinled_uno_ae_plus, esp32_quinled_uno_eth, esp32_quinled_dig_octa, esp01s, d1_mini_mhetesp32minikit, d1_mini_twilightlord, d1_mini_twilightlord_eth, esp32_devkitc, esp32_quinled_uno_eth_espsv3, m5stack_atom, esp3deuxquatro_dmx
src_dir = ./ESPixelStick
data_dir = ./ESPixelStick/data
build_cache_dir = ./.pio/.buildcache
Expand Down Expand Up @@ -335,3 +335,11 @@ board = m5stack-atom
build_flags =
${esp32git.build_flags}
-D BOARD_ESP32_M5STACK_ATOM

;Quatro from CanadaPixelsCoro.ca
[env:esp3deuxquatro_dmx]
extends = esp32git
board = wemos_d1_mini32
build_flags =
${esp32git.build_flags}
-D BOARD_ESPS_ESP3DEUXQUATRO_DMX