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
16
BuzzerSensorClass::BuzzerSensorClass
(
char
*config) :
SensorClassType
(config)
17
{
18
19
printf(
"BuzzerSensorClass init %s\n"
, config);
20
}
21
22
23
//!@see https://www.w3schools.com/cpp/cpp_class_methods.asp
24
void
BuzzerSensorClass::loop
()
25
{
26
27
}
28
29
30
void
BuzzerSensorClass::setup
()
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
70
void
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
81
void
BuzzerSensorClass::messageLocal_SensorClassType
(
char
*message)
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
100
void
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 -
107
void
BuzzerSensorClass::messageSend_SensorClassType
(
char
*sendValue)
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
114
void
BuzzerSensorClass::messageCmd_SensorClassType
(
char
*cmdValue)
115
{
116
117
}
118
#endif
//NOT_DEFINED
BuzzerSensorClass.h
registerPinUse_mainModule
void registerPinUse_mainModule(long pin, String pinName, String moduleName, boolean isI2C)
Definition:
MainModule.cpp:3370
BuzzerSensorClass::messageLocal_SensorClassType
void messageLocal_SensorClassType(char *message)
these are not initialized...
Definition:
BuzzerSensorClass.cpp:81
BuzzerSensorClass::setup
void setup()
Pure Virtual Function.
Definition:
BuzzerSensorClass.cpp:30
BuzzerSensorClass::loop
void loop()
Pure Virtual Function.
Definition:
BuzzerSensorClass.cpp:24
BuzzerSensorClass::BuzzerSensorClass
BuzzerSensorClass(char *config)
constructor
Definition:
BuzzerSensorClass.cpp:16
SensorClassType
Definition:
SensorClassType.h:24
SensorClassType::messageCmd_SensorClassType
virtual void messageCmd_SensorClassType(char *cmdValue)
Definition:
SensorClassType.h:92
SensorClassType::_pin1
int _pin1
Definition:
SensorClassType.h:99
SensorClassType::_pin2
int _pin2
pin2
Definition:
SensorClassType.h:101
SensorClassType::messageSend_SensorClassType
virtual void messageSend_SensorClassType(char *sendValue)
Definition:
SensorClassType.h:88
SensorClassType::messageSetVal_SensorClassType
virtual void messageSetVal_SensorClassType(char *setName, char *valValue, boolean deviceNameSpecified)
Definition:
SensorClassType.h:84
src
SensorClass
BuzzerSensorClass.cpp
Generated on Tue Aug 19 2025 13:00:31 for ESP_IOT by
1.9.5