-
Notifications
You must be signed in to change notification settings - Fork 4
/
so_declare.h
75 lines (64 loc) · 1.69 KB
/
so_declare.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef DECLARE_H
#define DECLARE_H
#include "so_config.h"
#include <HX711_ADC.h>
#include <AceButton.h>
#include <StopWatch.h>
// #include <BluetoothSerial.h>
// BluetoothSerial SerialBT;
HX711_ADC scale(HX711_SDA, HX711_SCL); //HX711模数转换初始化
CoffeeData coffeeData;
StopWatch stopWatch;
using namespace ace_button;
ButtonConfig config1;
AceButton buttonSet(&config1);
AceButton buttonPlus(&config1);
AceButton buttonMinus(&config1);
AceButton buttonTare(&config1);
#ifdef FIVE_BUTTON
AceButton buttonPower(&config1);
#endif
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include <BLE2902.h>
BLEServer *pServer = NULL;
BLECharacteristic *pReadCharacteristic = NULL;
BLECharacteristic *pWriteCharacteristic = NULL;
bool deviceConnected = false;
// The model byte is always 03 for Decent scales
const byte modelByte = 0x03;
namespace so_buzzer {
class Buzzer {
public:
Buzzer(int buzzerPin, int buzzerLedPin) {
_buzzerPin = buzzerPin;
pinMode(_buzzerPin, OUTPUT);
_buzzerLedPin = buzzerLedPin;
pinMode(_buzzerLedPin, OUTPUT);
}
void beep(int times, int duration) {
if (b_f_beep) {
for (int i = 0; i < times; i++) {
digitalWrite(_buzzerPin, HIGH);
delay(duration);
digitalWrite(_buzzerPin, LOW);
delay(duration);
}
} else {
for (int i = 0; i < times; i++) {
digitalWrite(_buzzerLedPin, HIGH);
delay(duration);
digitalWrite(_buzzerLedPin, LOW);
delay(duration);
}
}
}
private:
int _buzzerPin;
int _buzzerLedPin;
};
}
using namespace so_buzzer;
Buzzer buzzer(BUZZER, BUZZER_LED);
#endif