Prvni ulozeni z chegewara githubu
This commit is contained in:
0
libraries/USB/examples/SystemControl/.skip.esp32
Normal file
0
libraries/USB/examples/SystemControl/.skip.esp32
Normal file
0
libraries/USB/examples/SystemControl/.skip.esp32c3
Normal file
0
libraries/USB/examples/SystemControl/.skip.esp32c3
Normal file
27
libraries/USB/examples/SystemControl/SystemControl.ino
Normal file
27
libraries/USB/examples/SystemControl/SystemControl.ino
Normal file
@ -0,0 +1,27 @@
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
#include "USB.h"
|
||||
#include "USBHIDSystemControl.h"
|
||||
USBHIDSystemControl SystemControl;
|
||||
|
||||
const int buttonPin = 0;
|
||||
int previousButtonState = HIGH;
|
||||
|
||||
void setup() {
|
||||
pinMode(buttonPin, INPUT_PULLUP);
|
||||
SystemControl.begin();
|
||||
USB.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int buttonState = digitalRead(buttonPin);
|
||||
if ((buttonState != previousButtonState) && (buttonState == LOW)) {
|
||||
SystemControl.press(SYSTEM_CONTROL_POWER_OFF);
|
||||
SystemControl.release();
|
||||
}
|
||||
previousButtonState = buttonState;
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
Reference in New Issue
Block a user