#install( TARGETS ${PROJECT_NAME} LIBRARY DESTINATION /app/lib )
#install( TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION /app/lib )
-install(FILES ${PROJECT_SOURCE_DIR}/test/als_test DESTINATION /app/test/ )
+#install(FILES ${PROJECT_SOURCE_DIR}/test/als_test DESTINATION /app/test/ )
install(FILES ${PROJECT_SOURCE_DIR}/test/als_test.txt DESTINATION /app/test/ )
+
+add_executable( als_test test/als_test.c )
+target_link_libraries(
+ als_test
+ PUBLIC
+ mg_als
+ mg_log
+ log4c
+ pthread
+)
+
+install( TARGETS als_test RUNTIME DESTINATION /app/test )
\ No newline at end of file
--- /dev/null
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <zlib.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "als.h"
+
+//als测试程序
+static mg_als_t* als = NULL;
+
+int main(int argc , char* argv[])
+{
+ int i;
+ als_info_t* als_info;
+ als = mg_als_open();
+ if( als == NULL ){
+ printf( "open als failed \n");
+ return -1;
+ }
+ if(argc == 1){
+ mg_als_cfg(als,1000,400);
+ }
+ else if(argc == 3){
+ mg_als_cfg(als,atoi(argv[1]),atoi(argv[2]));
+ }
+
+ while(1){
+ als_info = mg_als_read(als);
+ if(als_info != NULL){
+ if(als_info->status == BRIGHT){
+ printf("1、亮 = %d ad_value = %d\n",als_info->status,als_info->ad_value);
+ }
+ else if(als_info->status == DARK){
+ printf("2、灭 status = %d ad_value = %d\n",als_info->status,als_info->ad_value);
+ }
+ printf("set als high = %d\n",als_info->threshold_high);
+ printf("set als low = %d\n",als_info->threshold_low);
+ usleep(100*1000);
+ }
+ }
+ mg_als_close(als);
+ als_info = NULL;
+ return 0;
+}
+
1-采用默认阈值
./als_test_app
2-重新设置阈值(上限阈值:500 下限阈值:200)
- ./als_test_app 500 200
+ ./als_test_app 500 200
\ No newline at end of file
#install( TARGETS ${PROJECT_NAME} LIBRARY DESTINATION /app/lib )
#install( TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION /app/lib )
-install(FILES ${PROJECT_SOURCE_DIR}/test/buzzer_test DESTINATION /app/test/ )
+#install(FILES ${PROJECT_SOURCE_DIR}/test/buzzer_test DESTINATION /app/test/ )
install(FILES ${PROJECT_SOURCE_DIR}/test/buzzer_test.txt DESTINATION /app/test/ )
+
+add_executable( buzzer_test test/buzzer_test.c )
+target_link_libraries(
+ buzzer_test
+ PUBLIC
+ mg_buzzer
+ mg_log
+ log4c
+ rt
+ pthread
+)
+
+install( TARGETS buzzer_test RUNTIME DESTINATION /app/test )
--- /dev/null
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <zlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "buzzer.h"
+
+
+static mg_buzzer_t* buzzer = NULL;
+
+
+int main(int argc, char *argv[])
+{
+ int32_t duty_cycle,timer_ms;
+ float period, c;
+ int a ,b, e;
+ if(argc == 1)
+ {
+ period = 200;
+ duty_cycle = 50;
+ timer_ms = 1000;
+ }
+ else if(argc == 4)
+ {
+ period = atof(argv[1]);
+ duty_cycle = atoi(argv[2]);
+ timer_ms = atoi(argv[3]);
+ }
+
+ if(period > 10000)
+ period = 10000;
+
+ buzzer = mg_buzzer_open();
+ if( buzzer == NULL ){
+ printf( "open buzzer failed \n");
+ return -1;
+ }
+
+ mg_buzzer_start(buzzer, period ,duty_cycle , timer_ms);
+ mg_buzzer_get(buzzer,&c,&a,&b,&e);
+ printf( "1-------main get hz = %f du = %d time = %dms enable = %d\r\n",c,a,b,e);
+ sleep(10);
+ mg_buzzer_close(buzzer);
+ return 0;
+}
\ No newline at end of file
adb push buzzer_test_app /app/
chmod a+x buzzer_test_app
-#测试程序只会运行10s,10s之后就会退出
+#测试程序只会运行10s,10s之后就会退出;
+#频率范围:1-10000HZ 占空比范围:0-100
#使用示例:
- 200:频率hz 50:占空比% 1000:播放时间ms
- ./buzzer_test_app 200 50 1000
+ 1-采用默认参数运行
+ (默认参数: 频率:200HZ 占空比:50% 播放时间:1000ms)
+ ./buzzer_test_app
+
+ 2-重新传入参数
+ 100:频率HZ 40:占空比% 1000:播放时间ms
+ ./buzzer_test_app 100 40 1000
\ No newline at end of file
#install( TARGETS ${PROJECT_NAME} LIBRARY DESTINATION /app/lib )
#install( TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION /app/lib )
-install(FILES ${PROJECT_SOURCE_DIR}/test/tof_test DESTINATION /app/test/ )
+#install(FILES ${PROJECT_SOURCE_DIR}/test/tof_test DESTINATION /app/test/ )
install(FILES ${PROJECT_SOURCE_DIR}/test/tof_test.txt DESTINATION /app/test/ )
+
+add_executable( tof_test test/tof_test.c )
+target_link_libraries(
+ tof_test
+ PUBLIC
+ mg_tof
+ pthread
+)
+
+install( TARGETS tof_test RUNTIME DESTINATION /app/test )
--- /dev/null
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <zlib.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "tof.h"
+
+mg_tof_t* main_ctl;
+
+void cb_test(tof_info_t* info)
+{
+ if(info->status == TOF_ANYBODY)
+ printf("== 在 %d mm处有人存在 ==\n",info->distance);
+ else if(info->status == TOF_NOBODY)
+ printf("== 在测量距离 %d mm内无人 ==\n",main_ctl->default_range);
+ else
+ printf("== 在 %d mm处存在障碍物 ==\n",info->distance);
+}
+
+int main()
+{
+ main_ctl = mg_tof_open(1000);
+ mg_tof_event_register(main_ctl,cb_test);
+
+ sleep(90);
+ printf("===== 测量距离已修改为 1500 mm =====\n");
+ Distance_parameter_correction(main_ctl,1500);
+
+
+ while(1)
+ {
+ sleep(120);
+ break;
+ }
+ printf("===== TOF已关闭 =====\n");
+ mg_tof_close(main_ctl);
+ return 0;
+}
#将tof中间件测试程序push进板子
-
- adb push TOF_test /app
- chmod 777 tof_test
./tof_test
-#运行后90s会将测量距离修改为1500mm,修改距离120s后会关闭整个测试程序。
+#运行后90s会将测量距离修改为1500mm,修改距离120s后会关闭整个测试程序。
\ No newline at end of file