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