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
36//https://randomnerdtutorials.com/esp32-pwm-arduino-ide/
37
38/************* Set all motor pins off which turns off the motor ************************************************/
39
40//! stop the motor
42{
43 SerialDebug.println("L9110S_DCStepperClass::stop_MotorStepper");
44 //! 7.9.25 if the pin was set use it otherwise use the hard coded values
45 //! LOW is off
46 digitalWrite(_pin1, LOW);
47 digitalWrite(_pin2, LOW);
48
49 //!user timer class instance
51}
52
54
55//! These are called from StepperModule
56//!Prepare motor controller
58{
60 return;
61
62 SerialDebug.println("L9110S_DCStepperClass::setup_MotorStepper");
63 SerialDebug.printf("PINS = %d, %d\n", _pin1, _pin2);
64 //! 7.9.25 if the pin was set use it otherwise use the hard coded values
65 if (_pin1 == 0)
66 {
67 _pin1 = IN1_PIN;
68 _pin2 = IN2_PIN;
69 SerialDebug.printf("NULL PINS setting to = %d, %d\n", _pin1, _pin2);
70 }
71
72 //! set output pins
73 pinMode(_pin1, OUTPUT);
74 pinMode(_pin2, OUTPUT);
75
76 //! stop the motor (or something) THis seems to be working.. the LOW worked sometimes..
77 for (int i=0; i< 3; i++)
78 {
79 digitalWrite(_pin1, LOW);
80 digitalWrite(_pin2, LOW);
81 }
82
83 //! 5.3.25 trying to figure out the PIN use
84 registerPinUse_mainModule(_pin1, "IN1_PIN", "L9110S_DCStepperClass", false);
85 registerPinUse_mainModule(_pin2, "IN2_PIN", "L9110S_DCStepperClass", false);
86
88}
89
90//!This will advance the stepper clockwise once by the angle specified in SetupStepper. Example 16 pockets in UNO is 22.5 degrees
91//!This is the FEED message .. the comments mention the Stepper Motor .. which this isn't
93{
94 SerialDebug.println("L9110S_DCStepperClass::start_MotorStepper");
96
97 SerialDebug.println("***** L9110S_DCStepperStepper::Starting L9110S_DCStepper *********");
98
99 //! 5.15.25 try the async CLICK
100 //! click call 5.26.25 SYNC version
102
103#define NEW_CODE_HERE
104 //Set the four pins to their proper state for the current step in the sequence,
105 //and for the current direction
106
107 if (this->isClockwiseDirection())
108 {
109 digitalWrite(_pin1, LOW);
110 digitalWrite(_pin2, HIGH);
111 }
112 else
113 {
114 digitalWrite(_pin1, HIGH);
115 digitalWrite(_pin2, LOW);
116 }
117
118 //! grab this value.
120
121 //! start the delay.. (which at .5 might not be needed...)
123
124 SerialDebug.println("**************** L9110S_DCStepperStepper::Ending L9110S_DCStepper *************");
125}
126
127
128//!loop the PTStepper (so timer can run)
130{
131 //!user timer class instance
133 {
134 SerialDebug.println("L9110S_DCStepperClass::delayFinished");
135
136 this->stop_MotorStepper();
137 }
138
139}
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:258
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