removed my changes to platformio&my_user_config, removed the unnessesary digitalwrites in adjustMicrosteps()

This commit is contained in:
Tim Leuschner 2019-09-08 17:30:17 +02:00
parent 4533039c9f
commit fafb837120
5 changed files with 22 additions and 39 deletions

View File

@ -14,7 +14,7 @@
Drives a bipolar motor, controlled by A4988 stepper driver circuit
*/
//
#include "Arduino.h"
#include "A4988_Stepper.h"
A4988_Stepper::A4988_Stepper( int m_spr
@ -60,35 +60,16 @@ void A4988_Stepper::adjustPins(void) {
void A4988_Stepper::adjustMicrosteps() {
if ((motor_ms1_pin<99)&&(motor_ms2_pin<99)&&(motor_ms3_pin<99)) {
switch (motor_MIS){
case 1:
digitalWrite(motor_ms1_pin, LOW);
digitalWrite(motor_ms2_pin, LOW);
digitalWrite(motor_ms3_pin, LOW);
break;
case 2:
digitalWrite(motor_ms1_pin, HIGH);
digitalWrite(motor_ms2_pin, LOW);
digitalWrite(motor_ms3_pin, LOW);
break;
digitalWrite(motor_ms1_pin, LOW);
digitalWrite(motor_ms2_pin, HIGH);
digitalWrite(motor_ms3_pin, LOW);
case 4:
digitalWrite(motor_ms1_pin, HIGH);
digitalWrite(motor_ms2_pin, HIGH);
digitalWrite(motor_ms3_pin, LOW);
break;
case 8:
digitalWrite(motor_ms1_pin, LOW);
digitalWrite(motor_ms2_pin, LOW);
digitalWrite(motor_ms3_pin, HIGH);
break;
case 16:
digitalWrite(motor_ms1_pin, HIGH);
digitalWrite(motor_ms2_pin, HIGH);
digitalWrite(motor_ms3_pin, HIGH);
break;
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;
@ -102,6 +83,7 @@ void A4988_Stepper::adjustMicrosteps() {
void A4988_Stepper::setMIS(short oneToSixteen) {
motor_MIS = oneToSixteen;
adjustMicrosteps();
adjustDelay();
}
short A4988_Stepper::getMIS(void) {

View File

@ -48,6 +48,7 @@ class A4988_Stepper {
void disable (void );
int version (void );
const unsigned short MIS_TABLE[5] = {0b000,0b001,0b010,0b011,0b111};
private:
void adjustDelay(void);

View File

@ -25,7 +25,7 @@ build_dir = .pioenvs
;default_envs = sonoff-BR
;default_envs = sonoff-CN
;default_envs = sonoff-CZ
default_envs = sonoff-DE
;default_envs = sonoff-DE
;default_envs = sonoff-ES
;default_envs = sonoff-FR
;default_envs = sonoff-GR
@ -218,8 +218,7 @@ upload_speed = 115200
upload_resetmethod = nodemcu
; *** Upload Serial reset method for Wemos and NodeMCU
; upload_port = COM5
upload_port = /dev/cu.wchusbserial1410
upload_port = COM5
extra_scripts = pio/strip-floats.py
; *** Upload file to OTA server using SCP

View File

@ -57,10 +57,10 @@
#define BOOT_LOOP_OFFSET 1 // [SetOption36] Number of boot loops before starting restoring defaults (0 = disable, 1..200 = boot loops offset)
// -- Wifi ----------------------------------------
#define WIFI_IP_ADDRESS "" // [IpAddress1] Set to 0.0.0.0 for using DHCP or enter a static IP address
#define WIFI_GATEWAY "" // [IpAddress2] If not using DHCP set Gateway IP address
#define WIFI_SUBNETMASK "" // [IpAddress3] If not using DHCP set Network mask
#define WIFI_DNS "" // [IpAddress4] If not using DHCP set DNS IP address (might be equal to WIFI_GATEWAY)
#define WIFI_IP_ADDRESS "0.0.0.0" // [IpAddress1] Set to 0.0.0.0 for using DHCP or enter a static IP address
#define WIFI_GATEWAY "192.168.1.1" // [IpAddress2] If not using DHCP set Gateway IP address
#define WIFI_SUBNETMASK "255.255.255.0" // [IpAddress3] If not using DHCP set Network mask
#define WIFI_DNS "192.168.1.1" // [IpAddress4] If not using DHCP set DNS IP address (might be equal to WIFI_GATEWAY)
#define STA_SSID1 "" // [Ssid1] Wifi SSID
#define STA_PASS1 "" // [Password1] Wifi password
@ -341,6 +341,7 @@
// #define USE_ADS1115 // Enable ADS1115 16 bit A/D converter (I2C address 0x48, 0x49, 0x4A or 0x4B) based on Adafruit ADS1x15 library (no library needed) (+0k7 code)
// #define USE_ADS1115_I2CDEV // Enable ADS1115 16 bit A/D converter (I2C address 0x48, 0x49, 0x4A or 0x4B) using library i2cdevlib-Core and i2cdevlib-ADS1115 (+2k code)
// #define USE_INA219 // Enable INA219 (I2C address 0x40, 0x41 0x44 or 0x45) Low voltage and current sensor (+1k code)
// #define USE_INA226 // Enable INA226 (I2C address 0x40, 0x41 0x44 or 0x45) Low voltage and current sensor (+2k3 code)
#define USE_SHT3X // Enable SHT3x (I2C address 0x44 or 0x45) or SHTC3 (I2C address 0x70) sensor (+0k7 code)
// #define USE_TSL2561 // Enable TSL2561 sensor (I2C address 0x29, 0x39 or 0x49) using library Joba_Tsl2561 (+2k3 code)
// #define USE_MGS // Enable Xadow and Grove Mutichannel Gas sensor using library Multichannel_Gas_Sensor (+10k code)
@ -527,7 +528,7 @@
#define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code)
//#define USE_HRE // Add support for Badger HR-E Water Meter (+1k4 code)
#define USE_A4988_Stepper // Add support for A4988 Stepper-Motors-Driver-circuit (+10k4 code)
//#define USE_A4988_Stepper // Add support for A4988 stepper-motor-driver-circuit (+10k5 code)
/*********************************************************************************************\
* Debug features

View File

@ -133,7 +133,7 @@ void CmndMOTOR(void){
void A4988CmndResponse(uint32_t error){
switch (error) {
case A4988_NO_JSON_COMMAND:
ResponseCmndChar(PSTR("Kein Commando!"));
ResponseCmndChar(PSTR("No command!"));
break;
case A4988_MOVE:
ResponseCmndChar(PSTR("Stepping!"));