static void select_click_handler(ClickRecognizerRef recognizer, void *context) {  
  if (!is_connected) {
    return;
  }
  // Start dictation UI
  #if defined(PBL_MICROPHONE)
  if (s_dictation_session == NULL) {
    s_dictation_session = dictation_session_create(sizeof(dictated_message), dictation_session_callback, NULL);
    if (s_dictation_session != NULL) {
      dictation_session_enable_confirmation(s_dictation_session, false);
    }
  }
  if (s_state == BEGINNING_STATE) {
    dictation_session_start(s_dictation_session);
  }

  if (s_state == CREATING_FINAL_MESSAGE_STATE) {
    dictation_session_start(s_dictation_session);
  }
  #endif
  if (s_state == CONFIRMING_FINAL_MESSAGE_STATE) {
    change_state(SENDING_FINAL_MESSAGE_STATE);
    send_final_message();

    action_bar_layer_set_icon(s_actionbar, BUTTON_ID_UP, NULL);
    action_bar_layer_set_icon(s_actionbar, BUTTON_ID_SELECT, NULL);
    action_bar_layer_set_icon(s_actionbar, BUTTON_ID_DOWN, NULL);
  }
}
Example #2
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  APP_LOG(APP_LOG_LEVEL_INFO, "message received");

  Tuple *start_immediately = dict_find(iterator, KEY_START_IMMEDIATELY);
  if (start_immediately) {
    APP_LOG(APP_LOG_LEVEL_INFO, "remember KEY_START_IMMEDIATELY=%d", start_immediately->value->uint8);
    persist_write_bool(KEY_START_IMMEDIATELY, start_immediately->value->uint8);
  }

  Tuple *enable_confirmation_dialog = dict_find(iterator, KEY_ENABLE_CONFIRMATION_DIALOG);
  if (enable_confirmation_dialog) {
    APP_LOG(APP_LOG_LEVEL_INFO, "remember KEY_ENABLE_CONFIRMATION_DIALOG=%d", enable_confirmation_dialog->value->uint8);
    persist_write_bool(KEY_ENABLE_CONFIRMATION_DIALOG, enable_confirmation_dialog->value->uint8);
    dictation_session_enable_confirmation(s_dictation_session, persist_read_bool(KEY_ENABLE_CONFIRMATION_DIALOG));
  }

  Tuple *enable_error_dialog = dict_find(iterator, KEY_ENABLE_ERROR_DIALOG);
  if (enable_error_dialog) {
    APP_LOG(APP_LOG_LEVEL_INFO, "remember KEY_ENABLE_ERROR_DIALOG=%d", enable_error_dialog->value->uint8);
    persist_write_bool(KEY_ENABLE_ERROR_DIALOG, enable_error_dialog->value->uint8);
    dictation_session_enable_error_dialogs(s_dictation_session, persist_read_bool(KEY_ENABLE_ERROR_DIALOG));
  }

  Tuple *status = dict_find(iterator, KEY_STATUS);
  Tuple *text = dict_find(iterator, KEY_TEXT);
  if (status) {
    if (status->value->uint8 == 255) { // configuration was opened, disable auto exit
      auto_exit_enable = false;
    } else if (status->value->uint8 == 0) {
      if (text) {
        show_text(text->value->cstring, GColorFromHEX(0x000000), GColorFromHEX(0x00ff00));
      } else {
        show_text("OK", GColorFromHEX(0x000000), GColorFromHEX(0x00ff00));
      }
    } else {
      if (text) {
        show_text(text->value->cstring, GColorFromHEX(0xffffff), GColorFromHEX(0xff0000));
      } else {
        show_text("ERROR", GColorFromHEX(0xffffff), GColorFromHEX(0xff0000));
      }
    }
    timeout_timer = app_timer_register(EXIT_TIMEOUT, exit_timeout, NULL);
  }
}
Example #3
0
/*
 * Start voice control
 */
EXTFN void voice_control() {
  
  voice_system_active = true;
  if (ds == NULL) {
    ds = dictation_session_create(PHRASE_BUFFER_LEN, voice_callback, NULL);
    #ifndef TESTING_BUILD
      dictation_session_enable_confirmation(ds, false);
    #endif
    dictation_session_enable_error_dialogs(ds, false);
  }
  if (ds != NULL) {
    dictation_session_start(ds);
  } else {
    voice_system_active = false;
    respond_with_vibe(false);
    show_notice(RESOURCE_ID_NOTICE_VOICE_UNAVAILABLE);
  }
  
}
Example #4
0
static void handle_voice_start_packet(Simply *simply, Packet *data) {
  #ifdef PBL_SDK_2
  // send an immediate reply if we don't support voice
  // Status 65 = NoMicrophone
  send_voice_data(65, "");
  #else

  // Send an immediate response if there's already a dictation session in progress
  // Status 64 = SessionAlreadyInProgress
  if (s_voice->in_progress) {
    send_voice_data(64, "");
    return;
  }

  // Otherwise, start the timer as soon as possible
  // (we start a timer so we can return true as quickly as possible)
  s_voice->in_progress = true;

  VoiceStartPacket *packet = (VoiceStartPacket*) data;
  dictation_session_enable_confirmation(s_voice->session, packet->enable_confirmation);
  s_voice->timer = app_timer_register(0, timer_callback_start_dictation, NULL);
  #endif
}
Example #5
0
static void start_dictation(){
  session = dictation_session_create(0, dictation_session_callback, NULL);
  dictation_session_enable_confirmation(session, true);
  dictation_session_enable_error_dialogs(session, true);
  dictation_session_start(session);	
}