diff --git a/BUILDS.md b/BUILDS.md index aa1834061..88ee58cd0 100644 --- a/BUILDS.md +++ b/BUILDS.md @@ -62,6 +62,7 @@ | USE_DDS2382 | - | - | - | - | x | - | - | | USE_DDSU666 | - | - | - | - | x | - | - | | USE_SOLAX_X1 | - | - | - | - | - | - | - | +| USE_LE01MR | - | - | - | - | - | - | - | | | | | | | | | | | USE_ADC_VCC | x | x | - | - | - | - | - | | USE_COUNTER | - | - | x | x | x | x | x | @@ -109,6 +110,8 @@ | USE_HIH6 | - | - | - | - | x | - | - | | USE_DHT12 | - | - | - | - | x | - | - | | USE_DS1624 | - | - | - | - | x | - | - | +| USE_AHT1x | - | - | - | - | - | - | - | +| USE_WEMOS_MOTOR_V1 | - | - | - | - | x | - | - | | | | | | | | | | | Feature or Sensor | minimal | lite | tasmota | knx | sensors | ir | display | Remarks | USE_SPI | - | - | - | - | - | - | x | @@ -124,6 +127,10 @@ | USE_RDM6300 | - | - | - | - | x | - | - | | USE_IBEACON | - | - | - | - | x | - | - | | USE_GPS | - | - | - | - | - | - | - | +| USE_HM10 | - | - | - | - | x | - | - | +| | | | | | | | | +| USE_NRF24 | - | - | - | - | - | - | - | +| USE_MIBLE | - | - | - | - | - | - | - | | USE_ZIGBEE | - | - | - | - | - | - | - | | | | | | | | | | | USE_IR_REMOTE | - | - | x | x | x | x | x | diff --git a/RELEASENOTES.md b/RELEASENOTES.md index dba7abeed..e5e08674c 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -103,4 +103,5 @@ The following binary downloads have been compiled with ESP8266/Arduino library c - Add support for FiF LE-01MR energy meter by saper-2 (#7584) - Add new DHT driver. The old driver can still be used using define USE_DHT_OLD (#7468) - Add another new DHT driver based on ESPEasy. The old driver can still be used using define USE_DHT_OLD. The previous new driver can be used with define USE_DHT_V2 (#7717) -- Add initial support for Sensors AHT10 and AHT15 by Martin Wagner (#7596) \ No newline at end of file +- Add initial support for Sensors AHT10 and AHT15 by Martin Wagner (#7596) +- Add support for Wemos Motor Shield V1 by Denis Sborets (#7764) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 2689a7222..465bcde8f 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -4,6 +4,7 @@ - Revert most wifi connectivity changes introduced in 8.1.0.5 (#7746, #7602, #7621) - Add initial support for Sensors AHT10 and AHT15 by Martin Wagner (#7596) +- Add support for Wemos Motor Shield V1 by Denis Sborets (#7764) ### 8.1.0.8 20200212 diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 8bf359605..c2cf75fe0 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -487,6 +487,9 @@ // #define USE_DHT12 // [I2cDriver41] Enable DHT12 humidity and temperature sensor (I2C address 0x5C) (+0k7 code) // #define USE_DS1624 // [I2cDriver42] Enable DS1624, DS1621 temperature sensor (I2C addresses 0x48 - 0x4F) (+1k2 code) // #define USE_AHT1x // [I2cDriver43] Enable AHT10/15 humidity and temperature sensor (I2C address 0x38) (+0k8 code) +// #define USE_WEMOS_MOTOR_V1 // [I2cDriver44] Enable Wemos motor driver V1 (I2C addresses 0x2D - 0x30) (+0k7 code) +// #define WEMOS_MOTOR_V1_ADDR 0x30 // Default I2C address 0x30 +// #define WEMOS_MOTOR_V1_FREQ 1000 // Default frequency // #define USE_DISPLAY // Add I2C Display Support (+2k code) #define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0 @@ -502,9 +505,6 @@ #define MTX_ADDRESS7 0x00 // [DisplayAddress7] I2C address of seventh 8x8 matrix module #define MTX_ADDRESS8 0x00 // [DisplayAddress8] I2C address of eigth 8x8 matrix module // #define USE_DISPLAY_SH1106 // [DisplayModel 7] [I2cDriver6] Enable SH1106 Oled 128x64 display (I2C addresses 0x3C and 0x3D) -// #define USE_WEMOS_MOTOR_V1 - #define USE_WEMOS_MOTOR_V1_ADDR 0x30 - #define USE_WEMOS_MOTOR_V1_FREQ 1000 #endif // USE_I2C // -- SPI sensors --------------------------------- diff --git a/tasmota/tasmota_post.h b/tasmota/tasmota_post.h index a126ff6fc..a2b49e677 100644 --- a/tasmota/tasmota_post.h +++ b/tasmota/tasmota_post.h @@ -165,6 +165,9 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack //#define USE_PCF8574 // Enable PCF8574 I/O Expander (I2C addresses 0x20 - 0x26 and 0x39 - 0x3F) (+1k9 code) #define USE_HIH6 // Enable Honywell HIH Humidity and Temperature sensor (I2C address 0x27) (+0k6) //#define USE_AHT1x // Enable AHT10/15 humidity and temperature sensor (I2C address 0x38) (+0k8 code) +#define USE_WEMOS_MOTOR_V1 // Enable Wemos motor driver V1 (I2C addresses 0x2D - 0x30) (+0k7 code) + #define WEMOS_MOTOR_V1_ADDR 0x30 // Default I2C address 0x30 + #define WEMOS_MOTOR_V1_FREQ 1000 // Default frequency #define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k code) #define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code) @@ -223,9 +226,6 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack //#define USE_ARDUINO_SLAVE // Add support for Arduino Uno/Pro Mini via serial interface including flashing (+2k3 code, 44 mem) #undef DEBUG_THEO // Disable debug code #undef USE_DEBUG_DRIVER // Disable debug code -#define USE_WEMOS_MOTOR_V1 - #define USE_WEMOS_MOTOR_V1_ADDR 0x30 - #define USE_WEMOS_MOTOR_V1_FREQ 1000 #endif // FIRMWARE_SENSORS /*********************************************************************************************\ diff --git a/tasmota/xdrv_34_wemos_motor_v1.ino b/tasmota/xdrv_34_wemos_motor_v1.ino index 5f744a914..9e6c0a967 100644 --- a/tasmota/xdrv_34_wemos_motor_v1.ino +++ b/tasmota/xdrv_34_wemos_motor_v1.ino @@ -1,7 +1,7 @@ /* xdrv_34_wemos_motor_v1.ino - Support for I2C WEMOS motor shield (6612FNG) - Copyright (C) 2020 Andre Thomas and Theo Arends + Copyright (C) 2020 Denis Sborets and Theo Arends This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ * WEMOS_MOTOR_V1 - DC motor driver shield (6612FNG) v 1.0.0 * * I2C Address: 0x30 + * * Command format: * driver44 ,,{,} * command: @@ -41,8 +42,15 @@ * 0 - 100% (100% by default) \*********************************************************************************************/ -#define XDRV_34 34 -#define XI2C_44 44 // See I2CDEVICES.md +#define XDRV_34 34 +#define XI2C_44 44 // See I2CDEVICES.md + +#ifndef WEMOS_MOTOR_V1_ADDR +#define WEMOS_MOTOR_V1_ADDR 0x30 // Default I2C address 0x30 +#endif +#ifndef WEMOS_MOTOR_V1_FREQ +#define WEMOS_MOTOR_V1_FREQ 1000 // Default frequency +#endif #define MOTOR_A 0 #define MOTOR_B 1 @@ -53,80 +61,69 @@ #define STOP 3 #define STANDBY 4 -bool wemos_driver_detected = false; +struct WMOTORV1 { + bool detected = false; + uint8_t motor; +} WMotorV1; -uint8_t _motor; - -void Wemos_Driver_Detect(void) +void WMotorV1Detect(void) { - if (!I2cActive(USE_WEMOS_MOTOR_V1_ADDR)) - { - I2cSetActiveFound(USE_WEMOS_MOTOR_V1_ADDR, "WEMOS_MOTOR_V1"); - wemos_driver_detected = true; - Motor_Reset(); - return; + if (I2cSetDevice(WEMOS_MOTOR_V1_ADDR)) { + WMotorV1.detected = true; + I2cSetActiveFound(WEMOS_MOTOR_V1_ADDR, "WEMOS_MOTOR_V1"); + WMotorV1Reset(); } } -void Motor_Reset(void) +void WMotorV1Reset(void) { - Wire.begin(); - Motor_SetFreq(USE_WEMOS_MOTOR_V1_FREQ); - Response_P(PSTR("{\"WEMOS_MOTOR_V1\":{\"RESET\":\"OK\"}}")); +// Wire.begin(); + WMotorV1SetFrequency(WEMOS_MOTOR_V1_FREQ); } -void Motor_SetFreq(uint32_t freq) +void WMotorV1SetFrequency(uint32_t freq) { - Wire.beginTransmission(USE_WEMOS_MOTOR_V1_ADDR); + Wire.beginTransmission(WEMOS_MOTOR_V1_ADDR); Wire.write(((byte)(freq >> 16)) & (byte)0x0f); Wire.write((byte)(freq >> 16)); Wire.write((byte)(freq >> 8)); Wire.write((byte)freq); Wire.endTransmission(); // stop transmitting - delay(100); +// delay(100); } -void Motor_SetMotor(uint8_t motor, uint8_t dir, float pwm_val) +void WMotorV1SetMotor(uint8_t motor, uint8_t dir, float pwm_val) { - uint16_t _pwm_val; - Wire.beginTransmission(USE_WEMOS_MOTOR_V1_ADDR); + Wire.beginTransmission(WEMOS_MOTOR_V1_ADDR); Wire.write(motor | (byte)0x10); Wire.write(dir); - _pwm_val = uint16_t(pwm_val * 100); - - if (_pwm_val > 10000) + uint16_t _pwm_val = uint16_t(pwm_val * 100); + if (_pwm_val > 10000) { _pwm_val = 10000; + } Wire.write((byte)(_pwm_val >> 8)); Wire.write((byte)_pwm_val); Wire.endTransmission(); - - delay(100); - - Response_P(PSTR("{\"WEMOS_MOTOR_V1\":{\"SETMOTOR\":\"OK\"}}")); +// delay(100); } -bool Motor_Command(void) +bool WMotorV1Command(void) { uint8_t args_count = 0; - if (XdrvMailbox.data_len > 0) - { + + if (XdrvMailbox.data_len > 0) { args_count = 1; - } - else - { + } else { return false; } - for (uint32_t idx = 0; idx < XdrvMailbox.data_len; idx++) - { - if (' ' == XdrvMailbox.data[idx]) - { + for (uint32_t idx = 0; idx < XdrvMailbox.data_len; idx++) { + if (' ' == XdrvMailbox.data[idx]) { XdrvMailbox.data[idx] = ','; } - if (',' == XdrvMailbox.data[idx]) - { + if (',' == XdrvMailbox.data[idx]) { args_count++; } } @@ -134,51 +131,50 @@ bool Motor_Command(void) char *command = strtok(XdrvMailbox.data, ","); - if (strcmp(command, "RESET") == 0) - { - Motor_Reset(); + if (strcmp(command, "RESET") == 0) { + WMotorV1Reset(); + Response_P(PSTR("{\"WEMOS_MOTOR_V1\":{\"RESET\":\"OK\"}}")); return true; } - if (strcmp(command, "SETMOTOR") == 0) - { - if (args_count >= 3) - { + if (strcmp(command, "SETMOTOR") == 0) { + if (args_count >= 3) { int motor = atoi(strtok(NULL, ",")); int dir = atoi(strtok(NULL, ",")); int duty = 100; - - if (args_count == 4) - { + if (args_count == 4) { duty = atoi(strtok(NULL, ",")); } - Motor_SetMotor(motor, dir, duty); - + WMotorV1SetMotor(motor, dir, duty); + Response_P(PSTR("{\"WEMOS_MOTOR_V1\":{\"SETMOTOR\":\"OK\"}}")); return true; } } return false; } +/*********************************************************************************************\ + * Interface +\*********************************************************************************************/ + bool Xdrv34(uint8_t function) { - if (!I2cEnabled(XI2C_44)) - { - return false; - } + if (!I2cEnabled(XI2C_44)) { return false; } + bool result = false; - if (FUNC_INIT == function) - { - Wemos_Driver_Detect(); - result = wemos_driver_detected; + + if (FUNC_INIT == function) { + WMotorV1Detect(); } - else if (wemos_driver_detected) - { - if (FUNC_COMMAND_DRIVER == function && XI2C_44 == XdrvMailbox.index) - { - result = Motor_Command(); + else if (WMotorV1.detected) { + switch (function) { + case FUNC_COMMAND_DRIVER: + if (XI2C_44 == XdrvMailbox.index) { + result = WMotorV1Command(); + } + break; } } return result; diff --git a/tools/decode-status.py b/tools/decode-status.py index 210175de8..3838d8faf 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -193,7 +193,7 @@ a_features = [[ "USE_ARDUINO_SLAVE","USE_HIH6","USE_HPMA","USE_TSL2591", "USE_DHT12","USE_DS1624","USE_GPS","USE_HOTPLUG", "USE_NRF24","USE_MIBLE","USE_HM10","USE_LE01MR", - "USE_AHT1x","","","" + "USE_AHT1x","USE_WEMOS_MOTOR_V1","","" ],[ "","","","", "","","","", @@ -236,7 +236,7 @@ else: obj = json.load(fp) def StartDecode(): - print ("\n*** decode-status.py v20200220 by Theo Arends and Jacek Ziolkowski ***") + print ("\n*** decode-status.py v20200222 by Theo Arends and Jacek Ziolkowski ***") # print("Decoding\n{}".format(obj))