Thanks for your feedback. I decided to pursue my idea because I didn't want to lose all the infrastructure (WiFi, MQTT, etc) that is baked into this app, and actually, I think I found a pretty easy way to do what I wanted. I defined a new device type (WEMOS_STEPPER) and 5 new pin designations:
// support for stepper motor
GPIO_MSTP, //#define stp 2 - move
GPIO_MDIR, //#define dir 3 - direction
GPIO_MMS1, //#define MS1 4 - step size
GPIO_MMS2, // #define MS2 5 - step size
GPIO_MEN, // #define EN 6 - enable
...
{ "WeMos Stepper", // WeMos stepper motor definition
GPIO_USER, // GPIO00 D3
GPIO_USER, // GPIO01 TX Serial RXD
GPIO_USER, // GPIO02 D4 Wemos DHT Shield *
GPIO_USER, // GPIO03 RX Serial TXD and Optional sensor
GPIO_MDIR, // GPIO04 D2 Motor Direction *
GPIO_MSTP, // GPIO05 D1 step size 1 *
0, 0, 0, 0, 0, 0, // Flash connection
GPIO_MMS1, // GPIO12 D6 stepsize 1
GPIO_MMS2, // GPIO13 D7 stepsize 1
GPIO_USER, // GPIO14 D5 *
GPIO_USER, // GPIO15 D8
GPIO_MEN, // GPIO16 D0 Wemos Wake Motor Enable *
GPIO_ADC0 // ADC0 A0 Analog input
}
if (!strcmp(type,"BLIND")) {
if ((data_len == 0) || (payload > 4)) payload = 9;
do_cmnd_blind(index, payload);
return;
}
void do_cmnd_blind(byte device, byte state)
{
pinMode(pin[GPIO_MSTP],OUTPUT);
pinMode(pin[GPIO_MDIR],OUTPUT);
pinMode(pin[GPIO_MMS1],OUTPUT);
pinMode(pin[GPIO_MMS2],OUTPUT);
pinMode(pin[GPIO_MEN],OUTPUT);
resetEDPins();
digitalWrite(pin[GPIO_MEN], HIGH); // enable the driver
if (state)
digitalWrite(pin[GPIO_MDIR], LOW); //Pull direction pin low to move "forward"
else
digitalWrite(pin[GPIO_MDIR], HIGH); //Pull direction pin high to move "backward"
int x;
for(x= 1; x < 1000; x++) //Loop stepping enough times for motion to be visible
{
digitalWrite(pin[GPIO_MSTP],HIGH); //Trigger one step forward
delay(1);
digitalWrite(pin[GPIO_MSTP],LOW); //Pull step pin low so it can be triggered again
delay(1);
}
resetEDPins();
}
//Reset Easy Driver pins to default states
void resetEDPins()
{
digitalWrite(pin[GPIO_MSTP], LOW);
digitalWrite(pin[GPIO_MDIR], LOW);
digitalWrite(pin[GPIO_MMS1], LOW);
digitalWrite(pin[GPIO_MMS2], LOW);
digitalWrite(pin[GPIO_MEN], LOW);
}
Exception (28):
epc1=0x4000bf0e epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
ctx: cont
sp: 3fff23a0 end: 3fff2680 offset: 01a0
>>>stack>>>
3fff2540: 3fff455c 3fff3cb0 3fff2570 3ffe96dc
3fff2550: 3fff455c 3fff3cb0 3fff257c 40220b3a
3fff2560: 3fff455c 3fff3cb0 3fff3c8c 4021d2f8
3fff2570: 00000000 00000000 00000000 3fff7f34
3fff2580: 0000001f 0000000d 3fff3034 0000000f
3fff2590: 0000000a 3fffdad0 3fff1658 00000030
3fff25a0: 3fff301c 0000000f 00000000 3fff7fec
3fff25b0: 0000000f 00000004 3fff7fd4 0000000f
3fff25c0: 00000003 3fff3aa4 0000000f 00000003
3fff25d0: 3fffbf4c 0000008f 0000008c 4021908c
3fff25e0: 3fff3ccc 00000000 3fff1660 00000000
3fff25f0: 00000000 4021b110 0000000a 3fff1660
3fff2600: 00000000 00000000 3fff3c8c 3fff1658
3fff2610: 00000139 3fff3cb0 3fff3c8c 4021c0b3
3fff2620: 3ffe98f0 00000000 3fff1660 00000000
3fff2630: 3fffdad0 3fff1658 40221640 3fff1660
3fff2640: 3fffdad0 00000000 3fff1650 402049d6
3fff2650: 00000000 00000000 00000001 40217106
3fff2660: 3fffdad0 00000000 3fff1650 4022168c
3fff2670: feefeffe feefeffe 3fff1660 40100718
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09826c6d
~ld
ø