-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVirtualButton.h
More file actions
66 lines (56 loc) · 1.92 KB
/
VirtualButton.h
File metadata and controls
66 lines (56 loc) · 1.92 KB
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
/**
* VirtualButton.h - Library for reading from a virtual button aka the keyboard
* Created by Jarrett on July 21, 2022
*/
#ifndef VirtualButton_h
#define VirtualButton_h
#include "Arduino.h"
class VirtualButton {
public:
/**
* This is a constructor for VirtualButton which takes a for toggleSwitchesON array.
*
* @param toggleSwitchesON The reference to the array storing toggleSwitches that are ON
*/
VirtualButton(bool toggleSwitchesON[]);
/**
* This is a constructor for VirtualButton which takes no arguments.
* NOTE: Use this when you only need access to digitalRead()
*/
VirtualButton();
/**
* This method switches the toggleSwitchesON value and returns it
*
* @param switchNum The value of the assigned switch in the array
* @return Returns the new value of the switch in the array
*/
bool toggleSwitch(int switchNum);
/**
* This method is used to simulate digitalRead() by reading the input byte
* from the user and checks if the value is a configured button.
*
* @return Returns HIGH if the above is true, otherwise, it returns LOW.
*/
int virtualDigitalRead(byte buttonPin);
/**
* This method is used to monitor the input from the user in the
* Serial Monitor for the virtualDigitalRead() method.
*/
void virtualDigitalReadHelper();
/**
* This method is used to read and process the incoming byte from the Serial Monitor. It does this by building
* a char array which is determined by a new line (Ex: 123 then enter). It then tries to convert the
* value to a byte. It only accepts values from 1 to 255, otherwise it will display an error and
* setfinalByte to 0.
*/
void serialReadByte();
/**
* This is a helper function to convert a char array to a byte
*/
void convertToByte(const char fullInput[], const unsigned int inputPosition);
private:
byte _userButtonVal;
bool _helperRanOnce;
bool *_toggleSwitchesON;
};
#endif