-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from arendst/development
Update
- Loading branch information
Showing
423 changed files
with
11,274 additions
and
3,105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM python:2 | ||
|
||
LABEL author="Eduard Angold" | ||
|
||
# Install platformio. To be able to build tasmota <=v6.6.0 (and later) | ||
# we have to use version 3.6.7 of platformio. | ||
RUN pip install --upgrade pip &&\ | ||
pip install -U platformio==3.6.7 | ||
|
||
# Init project | ||
COPY init_pio_tasmota /init_pio_tasmota | ||
|
||
# Install project dependencies using a init project. | ||
RUN cd /init_pio_tasmota &&\ | ||
pio run &&\ | ||
cd ../ &&\ | ||
rm -fr init_pio_tasmota &&\ | ||
cp -r /root/.platformio / &&\ | ||
chmod -R 777 /.platformio | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Docker container for tasmota builds | ||
This Container will setup a proper build environment for [Sonoff-Tasmota](https://github.com/arendst/Sonoff-Tasmota) | ||
|
||
## Create container | ||
`docker build -t mytasmota:latest .` | ||
|
||
## Use a ready container from docker hub | ||
Use instead of the container `mytasmota:latest` the published container `eddyhub/docker-tasmota:latest` from docker hub. | ||
|
||
## Build all development binaries | ||
`git clone https://github.com/arendst/Sonoff-Tasmota.git` | ||
`docker run -ti --rm -v $(pwd)/Sonoff-Tasmota:/tasmota -u $UID:$GID mytasmota:latest` | ||
|
||
## Build a specific binary with custom options | ||
Checkout Sonoff-Tasmota: `git clone https://github.com/arendst/Sonoff-Tasmota.git` | ||
Mount the source as volume in `/tasmota`. **Prefix** any parameter available in `Sonoff-Tasmota/sonoff/my_user_config.h` with `TASMOTA_` as a environment variable for the container. **Also don't forget to escape what needs to be escaped in your shell.** **Strings** should be in **double quotes**. My config example: | ||
`docker run -ti --rm -v $(pwd)/Sonoff-Tasmota:/tasmota -e TASMOTA_STA_SSID1='"my-wifi"' -e TASMOTA_STA_PASS1='"my-wifi-password"' -e TASMOTA_MQTT_HOST='my-mqtt-host' -e TASMOTA_MQTT_USER='"my-mqtt-user"' -e TASMOTA_MQTT_PASS='"my-mqtt-password"' -e TASMOTA_WEB_PASSWORD='"my-web-password"' -u $UID:$GID mytasmota:latest --environment sonoff-DE | ||
|
||
Now you should have the file Sonoff-Tasmota/.pioenvs/sonoff-DE/firmware.bin which can be flashed on your device. | ||
|
||
## Build a specific version of tasmota | ||
Checkout out the needed version before using the build instructions above: | ||
- `git clone https://github.com/arendst/Sonoff-Tasmota.git` | ||
- `git -C Sonoff-Tasmota checkout v6.6.0` | ||
Build it: | ||
- `docker run -ti --rm -v $(pwd)/Sonoff-Tasmota:/tasmota -u $UID:$GID mytasmota:latest` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# configure build via environment | ||
#!/bin/bash | ||
|
||
TASMOTA_VOLUME='/tasmota' | ||
USER_CONFIG_OVERRIDE="${TASMOTA_VOLUME}/sonoff/user_config_override.h" | ||
|
||
if [ -d $TASMOTA_VOLUME ]; then | ||
cd $TASMOTA_VOLUME | ||
if [ -n "$(env | grep ^TASMOTA_)" ]; then | ||
echo "Removing $USER_CONFIG_OVERRIDE and creating a new one." | ||
rm "$USER_CONFIG_OVERRIDE" | ||
#export PLATFORMIO_BUILD_FLAGS='-DUSE_CONFIG_OVERRIDE' | ||
sed -i 's/^; *-DUSE_CONFIG_OVERRIDE/ -DUSE_CONFIG_OVERRIDE/' platformio.ini | ||
echo '#ifndef _USER_CONFIG_OVERRIDE_H_' >> $USER_CONFIG_OVERRIDE | ||
echo '#define _USER_CONFIG_OVERRIDE_H_' >> $USER_CONFIG_OVERRIDE | ||
echo '#warning **** user_config_override.h: Using Settings from this File ****' >> $USER_CONFIG_OVERRIDE | ||
echo '#undef CFG_HOLDER' >> $USER_CONFIG_OVERRIDE | ||
echo '#define CFG_HOLDER 1' >> $USER_CONFIG_OVERRIDE | ||
for i in $(env | grep ^TASMOTA_); do | ||
config=${i#TASMOTA_} | ||
key=$(echo $config | cut -d '=' -f 1) | ||
value=$(echo $config | cut -d '=' -f 2) | ||
echo "#undef ${key}" >> $USER_CONFIG_OVERRIDE | ||
echo "#define ${key} ${value}" >> $USER_CONFIG_OVERRIDE | ||
done | ||
echo '#endif' >> $USER_CONFIG_OVERRIDE | ||
fi | ||
echo "Compiling..." | ||
#pio run -t clean | ||
pio run $@ | ||
echo "Everything done you find your builds in .pioenvs/<build-flavour>/firmware.bin" | ||
else | ||
echo ">>> NO TASMOTA VOLUME MOUNTED --> EXITING" | ||
exit 0; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[env:core_2_3_0] | ||
; *** Esp8266 core for Arduino version 2.3.0 | ||
platform = espressif8266@1.5.0 | ||
framework = arduino | ||
board = esp01_1m | ||
|
||
[env:core_2_4_2] | ||
; *** Esp8266 core for Arduino version 2.4.2 | ||
platform = espressif8266@1.8.0 | ||
framework = arduino | ||
board = esp01_1m | ||
|
||
[env:core_2_5_2] | ||
; *** Esp8266 core for Arduino version 2.5.2 | ||
platform = espressif8266@~2.2.2 | ||
framework = arduino | ||
board = esp01_1m | ||
|
||
[env:core_stage] | ||
; *** Esp8266 core for Arduino version latest beta | ||
platform = https://github.com/platformio/platform-espressif8266.git#feature/stage | ||
framework = arduino | ||
board = esp01_1m | ||
|
||
[env:core_pre] | ||
; *** Arduino Esp8266 core pre 2.6.x for Tasmota (mqtt reconnects fixed) | ||
platform = https://github.com/Jason2866/platform-espressif8266.git#Tasmota | ||
framework = arduino | ||
board = esp01_1m | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include <Arduino.h> | ||
void setup() {} | ||
void loop() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Stepper Library for Tasmota | ||
|
||
This Class allows you to control bipolar stepper motors. To use it you will need an A4988-StepperDriverCircuit, connected at least with 2 GPIO's (direction and step) and of cause a stepper motor. | ||
|
||
== License == | ||
|
||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
|
||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
####################################### | ||
# Syntax Coloring Map For Test | ||
####################################### | ||
|
||
####################################### | ||
# Datatypes (KEYWORD1) | ||
####################################### | ||
|
||
A4988_Stepper KEYWORD1 A4988_Stepper | ||
|
||
####################################### | ||
# Methods and Functions (KEYWORD2) | ||
####################################### | ||
|
||
doMove KEYWORD2 | ||
doRotate KEYWORD2 | ||
setRPM KEYWORD2 | ||
setSPR KEYWORD2 | ||
setMIS KEYWORD2 | ||
version KEYWORD2 | ||
|
||
####################################### | ||
# Constants (LITERAL1) | ||
####################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name=A4988_Stepper | ||
version=0.0.1 | ||
author=Tim Leuschner | ||
maintainer=Tim Leuschner <tim@feuer.land> | ||
sentence=Allows Tasmota to control stepper motors, connected to A4988-StepperDriverCircuit. | ||
paragraph=This library allows you to control bipolar stepper motors, controlled by A4988-stepperDriverCircuit. | ||
category=Device Control | ||
url= | ||
architectures=* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
/* | ||
This library is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
Drives a bipolar motor, controlled by A4988 stepper driver circuit | ||
*/ | ||
// | ||
#include "Arduino.h" | ||
#include "A4988_Stepper.h" | ||
A4988_Stepper::A4988_Stepper( int m_spr | ||
, int m_rpm | ||
, short m_mis | ||
, short m_dir_pin | ||
, short m_stp_pin | ||
, short m_ena_pin | ||
, short m_ms1_pin | ||
, short m_ms2_pin | ||
, short m_ms3_pin ) { | ||
last_time = 0; // time stamp in us of the last step taken | ||
motor_SPR = m_spr; // StepsPerRevolution | ||
motor_RPM = m_rpm; // RoundsPerMinute | ||
motor_MIS = m_mis; // Microsteps w/o effect if MS1-MS3 not connected - then full steps anyway | ||
motor_dir_pin = m_dir_pin; | ||
motor_stp_pin = m_stp_pin; | ||
motor_ena_pin = m_ena_pin; | ||
motor_ms1_pin = m_ms1_pin; | ||
motor_ms2_pin = m_ms2_pin; | ||
motor_ms3_pin = m_ms3_pin; | ||
|
||
adjustDelay(); | ||
adjustPins(); | ||
adjustMicrosteps(); | ||
} | ||
|
||
void A4988_Stepper::adjustPins(void) { | ||
// setup the pins on the microcontroller: | ||
pinMode(motor_dir_pin, OUTPUT); | ||
pinMode(motor_stp_pin, OUTPUT); | ||
if (motor_ena_pin <99) { | ||
pinMode(motor_ena_pin, OUTPUT); | ||
digitalWrite(motor_ena_pin, HIGH); | ||
} | ||
|
||
if ((motor_ms1_pin<99)&&(motor_ms2_pin<99)&&(motor_ms3_pin<99)) { | ||
pinMode(motor_ms1_pin, OUTPUT); | ||
pinMode(motor_ms2_pin, OUTPUT); | ||
pinMode(motor_ms3_pin, OUTPUT); | ||
} | ||
} | ||
|
||
void A4988_Stepper::adjustMicrosteps() { | ||
if ((motor_ms1_pin<99)&&(motor_ms2_pin<99)&&(motor_ms3_pin<99)) { | ||
unsigned short i = 0; | ||
while (i < 5){ | ||
if (motor_MIS & (1<<i)){ | ||
unsigned short mask = MIS_TABLE[i]; | ||
digitalWrite(motor_ms1_pin, 1&mask?HIGH:LOW); | ||
digitalWrite(motor_ms2_pin, 2&mask?HIGH:LOW); | ||
digitalWrite(motor_ms3_pin, 4&mask?HIGH:LOW); | ||
break; | ||
} | ||
i++; | ||
} | ||
} else { | ||
motor_MIS = 1; | ||
} | ||
} | ||
|
||
void A4988_Stepper::adjustDelay(void) { | ||
motor_delay = 60L * 1000L * 1000L / motor_SPR / motor_RPM / motor_MIS/2; | ||
} | ||
|
||
void A4988_Stepper::setMIS(short oneToSixteen) { | ||
motor_MIS = oneToSixteen; | ||
adjustMicrosteps(); | ||
adjustDelay(); | ||
} | ||
|
||
short A4988_Stepper::getMIS(void) { | ||
return motor_MIS; | ||
} | ||
|
||
void A4988_Stepper::setRPM(int howManyRounds) { | ||
motor_RPM = howManyRounds; | ||
adjustDelay(); | ||
} | ||
|
||
int A4988_Stepper::getRPM(void) { | ||
return motor_RPM; | ||
} | ||
|
||
void A4988_Stepper::setSPR(int howManySteps){ | ||
motor_SPR = howManySteps; | ||
adjustDelay(); | ||
} | ||
|
||
int A4988_Stepper::getSPR(void) { | ||
return motor_SPR; | ||
} | ||
|
||
void A4988_Stepper::enable(){ | ||
if (motor_ena_pin < 99) {digitalWrite(motor_ena_pin, LOW);} | ||
} | ||
|
||
void A4988_Stepper::disable(){ | ||
if (motor_ena_pin < 99) {digitalWrite(motor_ena_pin, HIGH);} | ||
} | ||
|
||
void A4988_Stepper::doMove(long howManySteps) | ||
{ | ||
long steps_togo = abs(howManySteps); // how many steps to take | ||
bool lastStepWasHigh = false; | ||
digitalWrite(motor_dir_pin, howManySteps>0?LOW:HIGH); | ||
enable(); | ||
while (steps_togo > 0) { | ||
delay(0); // don't get watchdoged in loop | ||
unsigned long now = micros(); | ||
// move if delay has passed: | ||
if (now - last_time >= motor_delay) { | ||
digitalWrite(motor_stp_pin, lastStepWasHigh?LOW:HIGH); | ||
lastStepWasHigh = !lastStepWasHigh; | ||
// remeber step-time | ||
last_time = now; | ||
if (!lastStepWasHigh) steps_togo--; // same here - only HIGH moves, if pulled LOW step is completed... | ||
} | ||
} | ||
disable(); | ||
} | ||
|
||
void A4988_Stepper::doRotate(long howManyDegrees) | ||
{ long lSteps = 0; | ||
lSteps = motor_SPR*motor_MIS*howManyDegrees/360; | ||
doMove(lSteps); | ||
} | ||
|
||
void A4988_Stepper::doTurn(float howManyTimes) | ||
{ long lSteps = 0; | ||
lSteps = howManyTimes*motor_SPR; | ||
doMove(lSteps); | ||
} | ||
|
||
int A4988_Stepper::version(void) | ||
{ | ||
return 1; | ||
} |
Oops, something went wrong.