123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- /*
- * Copyright (C) 2021 Alibaba Group Holding Limited
- * Author: LuChongzhi <chongzhi.lcz@alibaba-inc.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <curses.h>
- #define LOG_LEVEL 3
- #define LOG_PREFIX "dlg_prop_enum"
- #include <syslog.h>
- #include <camera_manager.h>
- #include <camera_app_spec.h>
- #include <csi_camera_platform_spec.h>
- #include <camera_string.h>
- #include "param.h"
- #include "app_dialogs.h"
- extern cams_t *cam_session;
- static int add_event_actions(camera_event_action_union_t *event_action)
- {
- int count = 0;
- const camera_app_bitmasks_t *bitmasks =
- camera_app_get_bitmask_array(CAMERA_APP_BITMAKS_CAMERA_EVENT_ACTION);
- LOG_D("bitmasks->count=%d\n", bitmasks->count);
- if (bitmasks == NULL) {
- LOG_E("Can't get camera's action support list\n");
- return count;
- }
- LOG_D("camera.action=0x%08x\n", event_action->camera.action);
- switch (event_action->camera.event) {
- case CSI_CAMERA_EVENT_WARNING:
- case CSI_CAMERA_EVENT_ERROR:
- case CSI_CAMERA_EVENT_SENSOR_FIRST_IMAGE_ARRIVE:
- case CSI_CAMERA_EVENT_ISP_3A_ADJUST_READY:
- for (int i = 0; i < bitmasks->count; i++) {
- csi_camera_event_id_e loop_action = bitmasks->bitmask[i];
- bool action_set = (event_action->camera.action & loop_action) != 0;
- const char *item_name = camera_string_camera_action(loop_action);
- item_make("\t%-16s(0x%08x)", item_name, loop_action);
- LOG_D("\t%-16s(0x%08x)\n", item_name, loop_action);
- item_set_tag(action_set ? '*' : ' ');
- item_set_int(loop_action);
- }
- break;
- }
- }
- int dialog_event_subscribe_action_camera(camera_event_action_union_t *event_action)
- {
- int ret_key = KEY_ESC;
- if (event_action == NULL) {
- LOG_W("event_action is NULL\n");
- return KEY_ESC;
- }
- char *title = "Set Camera Event Action(s)";
- char *prompt = "Select the Camera event then config the action(s)";
- int item_pos = 0;
- int list_count = 0;
- again:
- item_reset();
- item_make("%-32s","Subscribe");
- if (event_action->camera.subscribed == false) {
- item_set_tag(' ');
- } else {
- item_set_tag('*');
- list_count = add_event_actions(event_action);
- }
- int list_height = MIN(list_count + 8, 24);
- ret_key = dialog_checkbox(
- title, prompt,
- CHECKLIST_HEIGTH_MIN + list_height + 2,
- WIN_COLS - CHECKLIST_WIDTH_MIN - 32,
- list_height, item_pos);
- LOG_D("dialog_checkbox() ret_key=%d\n", ret_key);
- if (ret_key == KEY_ESC) {
- return KEY_ESC;
- } else if (ret_key == 0) {/* select */
- item_pos = item_n();
- LOG_D("item_pos=%d\n", item_pos);
- if (item_pos == 0) { // 1st item, which indicate whether register actions
- if (item_tag() == ' ') {
- event_action->camera.subscribed = true;
- goto again;
- } else {
- event_action->camera.subscribed = false;
- goto again;
- }
- } else { // other item, which indicate whether register actions
- camera_action_e cur_action = item_int();
- if (item_tag() == ' ') {
- event_action->camera.action |= cur_action;
- item_set_tag('*');
- } else {
- event_action->camera.action &= ~cur_action;
- item_set_tag(' ');
- }
- LOG_D("camera.action=0x%08x\n", event_action->camera.action);
- }
- goto again;
- return ret_key;
- } else if (ret_key == 1) {/* Return */
- return ret_key;
- } else if (ret_key == 2) {/* Help */
- LOG_W("Help does not support yet\n");
- return ret_key;
- } else {
- LOG_E("Unknown return value: %d\n", ret_key);
- return KEY_ESC;
- }
- }
|