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
9
10// from Dispense it calls getFeederType_mainModule()
11#include "StepperModule.h"
12
13//#include "TimerDelayClass.h"
14//! create instance of the timer class
16
17//! default .. this could be set via Preferences (TODO)
19
20/******************stepper declarations******************************/
21
23{
24 SerialDebug.printf("L9110S_DCStepperClass init %s\n", config);
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
32const int IN1_PIN = 21; //IN1 on the ULN2003 Board, BLUE end of the Blue/Yellow motor coil
33const 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
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
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
60}
61
63
64//! These are called from StepperModule
65//!Prepare motor controller
67{
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
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
102{
103 SerialDebug.println("L9110S_DCStepperClass::start_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
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.
129
130 //! start the delay.. (which at .5 might not be needed...)
132
133 SerialDebug.println("**************** L9110S_DCStepperStepper::Ending L9110S_DCStepper *************");
134}
135
136
137//!loop the PTStepper (so timer can run)
139{
140 //!user timer class instance
142 {
143 SerialDebug.println("L9110S_DCStepperClass::delayFinished");
144
145 this->stop_MotorStepper();
146 }
147
148}
const int IN1_PIN
float _delaySeconds_L9110S_DCStepper_setting
default .. this could be set via Preferences (TODO)
boolean _isSetup_L9110S_DCStepper
TimerDelayClass * _timerDelayClass_L9110S_DCStepperClass
L9110S_DCStepperStepperClass
const int IN2_PIN
void main_dispatchSyncCommand(int syncCallCommand)
the main sync command (no parameters yet)
void registerPinUse_mainModule(long pin, String pinName, String moduleName, boolean isI2C)
#define SYNC_CLICK_SOUND
Definition: MainModule.h:262
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...
#define PREFERENCE_STEPPER_ANGLE_FLOAT_SETTING
void loop_MotorStepper()
loop the PTStepper (so timer can run)
void start_MotorStepper()
starts the PTStepper
void stop_MotorStepper()
stops motor
void setup_MotorStepper()
setup the PTStepper
L9110S_DCStepperClass(char *config)
constructor
An mostly virtual class.
boolean isClockwiseDirection()
returns if clockwise
An concrete class.
void startDelay(float delayAmountSeconds)
starts delay calculation
boolean delayFinished()
whether the currently delay is finished, false if not running at all
void stopDelay()
stops delay