-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbutton_demo.cpp
More file actions
44 lines (38 loc) · 1.44 KB
/
button_demo.cpp
File metadata and controls
44 lines (38 loc) · 1.44 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
#include <chrono>
#include <gpios.h>
#include <iostream>
#include <thread>
std::mutex gpioClientPtrLock;
std::shared_ptr<mandeye::GpioClient> gpioClientPtr;
using namespace hardware;
bool StopScan()
{
gpioClientPtr->setLed(LED::LED_GPIO_STOP_SCAN, true);
gpioClientPtr->setLed(LED::BUZZER, true);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
gpioClientPtr->setLed(LED::LED_GPIO_STOP_SCAN, false);
gpioClientPtr->setLed(LED::BUZZER, false);
return false;
}
bool Continous()
{
gpioClientPtr->setLed(LED::LED_GPIO_CONTINOUS_SCANNING, true);
gpioClientPtr->setLed(LED::BUZZER, true);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
gpioClientPtr->setLed(LED::LED_GPIO_CONTINOUS_SCANNING, false);
gpioClientPtr->setLed(LED::BUZZER, false);
return false;
}
int main(int arc, char* argv[])
{
std::cout << "button_demo" << std::endl;
gpioClientPtr = std::make_shared<mandeye::GpioClient>(0);
gpioClientPtr->setLed(LED::LED_GPIO_STOP_SCAN, false);
gpioClientPtr->setLed(LED::LED_GPIO_COPY_DATA, false);
gpioClientPtr->setLed(LED::LED_GPIO_CONTINOUS_SCANNING, false);
//gpioClientPtr->setLed(mandeye::GpioClient::LED::LED_GPIO_BLUE, true);
gpioClientPtr->addButtonCallback(BUTTON::BUTTON_STOP_SCAN, "LED_GPIO_STOP_SCAN", [&]() { StopScan(); });
gpioClientPtr->addButtonCallback(BUTTON::BUTTON_CONTINOUS_SCANNING, "STOP_SCAN", [&]() { Continous(); });
std::this_thread::sleep_for(std::chrono::milliseconds(100000));
return 0;
}