ESP_IOT
v2.5
IOT ESP Coding
L9110S_DCStepperClass.cpp
Go to the documentation of this file.
1
/// \link L9110S_DCStepperStepperClass
2
// L9110S_DCStepperClass.cpp
3
//
4
//
5
// Created by Scott Moody on 5/19/25.
6
//
7
8
#include "
L9110S_DCStepperClass.h
"
9
10
// from Dispense it calls getFeederType_mainModule()
11
#include "
StepperModule.h
"
12
13
//#include "TimerDelayClass.h"
14
//! create instance of the timer class
15
TimerDelayClass
*
_timerDelayClass_L9110S_DCStepperClass
;
16
17
//! default .. this could be set via Preferences (TODO)
18
float
_delaySeconds_L9110S_DCStepper_setting
= 0.5;
19
20
/******************stepper declarations******************************/
21
22
L9110S_DCStepperClass::L9110S_DCStepperClass
(
char
*config) :
MotorStepperClassType
(config)
23
{
24
SerialDebug.printf(
"L9110S_DCStepperClass init %s\n"
, config);
25
_timerDelayClass_L9110S_DCStepperClass
=
new
TimerDelayClass
(
_delaySeconds_L9110S_DCStepper_setting
);
26
}
27
28
//! This works with the ESP_M5
29
//! 7.9.25 after F1 movie (make Brad Pitt Great Again)
30
//! hard coded .. unless changed via Sensors message
31
//! overridded by _pin1 _pin2
32
const
int
IN1_PIN
= 21;
//IN1 on the ULN2003 Board, BLUE end of the Blue/Yellow motor coil
33
const
int
IN2_PIN
= 25;
//IN2 on the ULN2003 Board, PINK end of the Pink/Orange motor coil
34
35
#ifdef NOT_WORKING
36
//! 9.4.25
37
//! delay amount after a start_MotorStepper
38
//! defaults = 0
39
int
L9110S_DCStepperClass::delayAmountBetweenMotor
()
40
{
41
SerialDebug.println(
"L9110S_DCStepperClass::delayAmountBetweenMotor = 600"
);
42
return
600;
43
}
44
#endif
45
//https://randomnerdtutorials.com/esp32-pwm-arduino-ide/
46
47
/************* Set all motor pins off which turns off the motor ************************************************/
48
49
//! stop the motor
50
void
L9110S_DCStepperClass::stop_MotorStepper
()
51
{
52
SerialDebug.println(
"L9110S_DCStepperClass::stop_MotorStepper"
);
53
//! 7.9.25 if the pin was set use it otherwise use the hard coded values
54
//! LOW is off
55
digitalWrite(
_pin1
, LOW);
56
digitalWrite(
_pin2
, LOW);
57
58
//!user timer class instance
59
_timerDelayClass_L9110S_DCStepperClass
->
stopDelay
();
60
}
61
62
boolean
_isSetup_L9110S_DCStepper
=
false
;
63
64
//! These are called from StepperModule
65
//!Prepare motor controller
66
void
L9110S_DCStepperClass::setup_MotorStepper
()
67
{
68
if
(
_isSetup_L9110S_DCStepper
)
69
return
;
70
71
SerialDebug.println(
"L9110S_DCStepperClass::setup_MotorStepper"
);
72
SerialDebug.printf(
"PINS = %d, %d\n"
,
_pin1
,
_pin2
);
73
//! 7.9.25 if the pin was set use it otherwise use the hard coded values
74
if
(
_pin1
== 0)
75
{
76
_pin1
=
IN1_PIN
;
77
_pin2
=
IN2_PIN
;
78
SerialDebug.printf(
"NULL PINS setting to = %d, %d\n"
,
_pin1
,
_pin2
);
79
}
80
81
//! set output pins
82
pinMode(
_pin1
, OUTPUT);
83
pinMode(
_pin2
, OUTPUT);
84
85
//! stop the motor (or something) THis seems to be working.. the LOW worked sometimes..
86
for
(
int
i=0; i< 3; i++)
87
{
88
digitalWrite(
_pin1
, LOW);
89
digitalWrite(
_pin2
, LOW);
90
}
91
92
//! 5.3.25 trying to figure out the PIN use
93
registerPinUse_mainModule
(
_pin1
,
"IN1_PIN"
,
"L9110S_DCStepperClass"
,
false
);
94
registerPinUse_mainModule
(
_pin2
,
"IN2_PIN"
,
"L9110S_DCStepperClass"
,
false
);
95
96
_isSetup_L9110S_DCStepper
=
true
;
97
}
98
99
//!This will advance the stepper clockwise once by the angle specified in SetupStepper. Example 16 pockets in UNO is 22.5 degrees
100
//!This is the FEED message .. the comments mention the Stepper Motor .. which this isn't
101
void
L9110S_DCStepperClass::start_MotorStepper
()
102
{
103
SerialDebug.println(
"L9110S_DCStepperClass::start_MotorStepper"
);
104
L9110S_DCStepperClass::setup_MotorStepper
();
105
106
SerialDebug.println(
"***** L9110S_DCStepperStepper::Starting L9110S_DCStepper *********"
);
107
108
//! 5.15.25 try the async CLICK
109
//! click call 5.26.25 SYNC version
110
main_dispatchSyncCommand
(
SYNC_CLICK_SOUND
);
111
112
#define NEW_CODE_HERE
113
//Set the four pins to their proper state for the current step in the sequence,
114
//and for the current direction
115
116
if
(this->
isClockwiseDirection
())
117
{
118
digitalWrite(
_pin1
, LOW);
119
digitalWrite(
_pin2
, HIGH);
120
}
121
else
122
{
123
digitalWrite(
_pin1
, HIGH);
124
digitalWrite(
_pin2
, LOW);
125
}
126
127
//! grab this value.
128
_delaySeconds_L9110S_DCStepper_setting
=
getPreferenceFloat_mainModule
(
PREFERENCE_STEPPER_ANGLE_FLOAT_SETTING
);
129
130
//! start the delay.. (which at .5 might not be needed...)
131
_timerDelayClass_L9110S_DCStepperClass
->
startDelay
(
_delaySeconds_L9110S_DCStepper_setting
);
132
133
SerialDebug.println(
"**************** L9110S_DCStepperStepper::Ending L9110S_DCStepper *************"
);
134
}
135
136
137
//!loop the PTStepper (so timer can run)
138
void
L9110S_DCStepperClass::loop_MotorStepper
()
139
{
140
//!user timer class instance
141
if
(
_timerDelayClass_L9110S_DCStepperClass
->
delayFinished
())
142
{
143
SerialDebug.println(
"L9110S_DCStepperClass::delayFinished"
);
144
145
this->
stop_MotorStepper
();
146
}
147
148
}
IN1_PIN
const int IN1_PIN
Definition:
L9110S_DCStepperClass.cpp:32
_delaySeconds_L9110S_DCStepper_setting
float _delaySeconds_L9110S_DCStepper_setting
default .. this could be set via Preferences (TODO)
Definition:
L9110S_DCStepperClass.cpp:18
_isSetup_L9110S_DCStepper
boolean _isSetup_L9110S_DCStepper
Definition:
L9110S_DCStepperClass.cpp:62
_timerDelayClass_L9110S_DCStepperClass
TimerDelayClass * _timerDelayClass_L9110S_DCStepperClass
L9110S_DCStepperStepperClass
Definition:
L9110S_DCStepperClass.cpp:15
IN2_PIN
const int IN2_PIN
Definition:
L9110S_DCStepperClass.cpp:33
L9110S_DCStepperClass.h
main_dispatchSyncCommand
void main_dispatchSyncCommand(int syncCallCommand)
the main sync command (no parameters yet)
Definition:
MainModule.cpp:1358
registerPinUse_mainModule
void registerPinUse_mainModule(long pin, String pinName, String moduleName, boolean isI2C)
Definition:
MainModule.cpp:3980
SYNC_CLICK_SOUND
#define SYNC_CLICK_SOUND
Definition:
MainModule.h:262
getPreferenceFloat_mainModule
float getPreferenceFloat_mainModule(int preferenceID)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
Definition:
PreferencesController.cpp:507
PREFERENCE_STEPPER_ANGLE_FLOAT_SETTING
#define PREFERENCE_STEPPER_ANGLE_FLOAT_SETTING
Definition:
PreferencesController.h:22
StepperModule.h
L9110S_DCStepperClass::loop_MotorStepper
void loop_MotorStepper()
loop the PTStepper (so timer can run)
Definition:
L9110S_DCStepperClass.cpp:138
L9110S_DCStepperClass::start_MotorStepper
void start_MotorStepper()
starts the PTStepper
Definition:
L9110S_DCStepperClass.cpp:101
L9110S_DCStepperClass::stop_MotorStepper
void stop_MotorStepper()
stops motor
Definition:
L9110S_DCStepperClass.cpp:50
L9110S_DCStepperClass::setup_MotorStepper
void setup_MotorStepper()
setup the PTStepper
Definition:
L9110S_DCStepperClass.cpp:66
L9110S_DCStepperClass::L9110S_DCStepperClass
L9110S_DCStepperClass(char *config)
constructor
Definition:
L9110S_DCStepperClass.cpp:22
MotorStepperClassType
An mostly virtual class.
Definition:
MotorStepperClassType.h:15
MotorStepperClassType::isClockwiseDirection
boolean isClockwiseDirection()
returns if clockwise
Definition:
MotorStepperClassType.cpp:58
MotorStepperClassType::delayAmountBetweenMotor
virtual int delayAmountBetweenMotor()
Definition:
MotorStepperClassType.cpp:38
MotorStepperClassType::_pin2
int _pin2
pin2
Definition:
MotorStepperClassType.h:67
MotorStepperClassType::_pin1
int _pin1
Definition:
MotorStepperClassType.h:65
TimerDelayClass
An concrete class.
Definition:
TimerDelayClass.h:14
TimerDelayClass::startDelay
void startDelay(float delayAmountSeconds)
starts delay calculation
Definition:
TimerDelayClass.cpp:40
TimerDelayClass::delayFinished
boolean delayFinished()
whether the currently delay is finished, false if not running at all
Definition:
TimerDelayClass.cpp:28
TimerDelayClass::stopDelay
void stopDelay()
stops delay
Definition:
TimerDelayClass.cpp:19
src
StepperModule
L9110S_DCStepperClass.cpp
Generated on Fri Jan 30 2026 12:52:10 for ESP_IOT by
1.9.5