ESP_IOT v2.5
IOT ESP Coding
BuzzerSensorClass.cpp
Go to the documentation of this file.
1//
2// BuzzerSensorClass.cpp
3//
4//
5// Created by Scott Moody on 5/14/25.
6//
7
8#include "BuzzerSensorClass.h"
9
10
11#include "../../Defines.h"
12
13#include "BuzzerSensorClass.h"
14
15
17{
18
19 printf("BuzzerSensorClass init %s\n", config);
20}
21
22
23//!@see https://www.w3schools.com/cpp/cpp_class_methods.asp
25{
26
27}
28
29
31{
32 SerialDebug.printf("BuzzerSensorClass::setup(%d,%d)\n",_pin1, _pin2);
33
34 if (_pin1 == 0)
35 {
36 //! default to 21,33
37 //! BuzzerSensorClass,23,33
38 _pin1 = 23;
39 _pin2 = 33;
40 }
41
42 //https://www.reddit.com/r/arduino/comments/1g89dlo/esp32_crashing_due_to_pinmode_and_fastled/
43 pinMode(_pin1, OUTPUT);
44 pinMode(_pin2, OUTPUT);
45
46 registerPinUse_mainModule(_pin1,"Pin1","BuzzerSensorClass",false);
47 registerPinUse_mainModule(_pin2,"Pin2","BuzzerSensorClass",false);
48
49 //! turn off..
50 digitalWrite(_pin1, LOW);
51 digitalWrite(_pin2, LOW);
52
53 SerialDebug.println("DONE BuzzerSensorClass::setup");
54}
55
56/**
57 ** PIN_USE: Pin2 = 22, module=BuzzerSensorClass
58 ** PIN_USE: RX = 22, module=ATOMQRCodeModule
59 ** PIN_USE: TX = 19, module=ATOMQRCodeModule
60 ** PIN_USE: DATA_PIN = 27, module=LED_DisPlay::begin
61 ** PIN_USE: KEY_PIN = 32, module=KeyUnitSensorClass
62 ** PIN_USE: DATA_PIN = 26, module=KeyUnitSensorClass
63 ** PIN_USE: FastLED = 26, module=KeyUnitSensorClass
64 ** PIN_USE: IN1_PIN = 21, module=L9110S_DCStepperClass
65 ** PIN_USE: IN2_PIN = 25, module=L9110S_DCStepperClass
66 */
67
68//! local code
69//! if using the GROVE, the right 2 pins would be 26, 32
70void BuzzerSensorClass::performBuzzer()
71{
72 SerialDebug.printf("BuzzerSensorClass::performBuzzer(pin1=%d,pin2=%d)\n",_pin1, _pin2);
73 digitalWrite(_pin1, HIGH);
74 digitalWrite(_pin2, LOW);
75 delay(100);
76 digitalWrite(_pin1, LOW);
77 digitalWrite(_pin2, LOW);
78}
79
80//! 5.15.25 try a special command local to this class
82{
83 SerialDebug.printf("BuzzerSensorClass::messageLocal_SensorClassType(%s)\n", message);
84 if (strcmp(message,"click")==0)
85 {
86 SerialDebug.println("BuzzerSensorClass.click");
87 performBuzzer();
88 }
89}
90#ifdef NOT_DEFINED
91
92
93//! adding the messages as well
94//! 5.14.25 (Laura/Paul flying). 5.14.74 great Dead
95//! 8.28.23 Adding a way for others to get informed on messages that arrive
96//! for the set,val
97//! 12.27.23 support setName == "socket"
98//! 1.10.24 if deviceNameSpecified then this matches this device, otherwise for all.
99//! It's up to the receiver to decide if it has to be specified
100void BuzzerSensorClass::messageSetVal_SensorClassType(char *setName, char* valValue, boolean deviceNameSpecified)
101{
102
103}
104
105//! 12.28.23, 8.28.23 Adding a way for others to get informed on messages that arrive
106//! for the send -
108{
109
110}
111
112//! 12.28.23, 8.28.23 Adding a way for others to get informed on messages that arrive
113//! for the cmd
115{
116
117}
118#endif //NOT_DEFINED
void registerPinUse_mainModule(long pin, String pinName, String moduleName, boolean isI2C)
void messageLocal_SensorClassType(char *message)
these are not initialized...
void setup()
Pure Virtual Function.
void loop()
Pure Virtual Function.
BuzzerSensorClass(char *config)
constructor
virtual void messageCmd_SensorClassType(char *cmdValue)
virtual void messageSend_SensorClassType(char *sendValue)
virtual void messageSetVal_SensorClassType(char *setName, char *valValue, boolean deviceNameSpecified)