====== 피에조 부저 제어 ======
ComfilePi는 내장된 피에조 부저가 있습니다. 화면을 터치 할 때 기본적으로 울립니다.
=====터치음 no/off=====
터치음을 해제(off)하려면 다음 명령을 실행합니다
sudo systemctl stop touch-beep.service
sudo systemctl disable touch-beep.service
터치음을 활성화(on)하려면 다음 명령을 실행합니다 :
sudo systemctl enable touch-beep.service
sudo systemctl start touch-beep.service
=====피에조 부저 프로그래밍=====
피에조 부저는 GPIO 30Pin에 연결되어있습니다. 피에조 제어 프로그램시 [[http://abyz.co.uk/rpi/pigpio/|pigpio 라이브러리]]를 참조하여 프로그램을 작성할 수 있습니다.
#include
#include
using namespace std;
#define PIN 30 // CPi-A & CPi-B
//#define PIN 27 // CPi-C
void play_beep()
{
auto instance = pigpio_start(NULL, NULL);
// We actually can't achieve 2700Hz due to the sampling
// rate, but it will do the best it can
set_PWM_frequency(instance, PIN, 2700);
// 128/255 = 50% duty
set_PWM_dutycycle(instance, PIN, 128);
// play beep for 100 milliseconds
this_thread::sleep_for(chrono::milliseconds(100));
// turn off beep
set_PWM_dutycycle(instance, PIN, 0);
pigpio_stop(instance);
}
[[comfilepi:index#추가설명|상위 페이지로 이동]]