You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/04/27 00:18:29 UTC

[GitHub] ccollins476ad commented on a change in pull request #1054: hw/util/button: allow to specify eventq

ccollins476ad commented on a change in pull request #1054: hw/util/button: allow to specify eventq
URL: https://github.com/apache/mynewt-core/pull/1054#discussion_r184564632
 
 

 ##########
 File path: hw/util/button/src/button.c
 ##########
 @@ -486,17 +499,40 @@ button_fsm_callout(struct os_event *ev)
 void
 button_init(button_t *buttons, unsigned int count, button_callback_t cb)
 {
-    button_callback = cb;
+#if MYNEWT_VAL(BUTTON_USE_DOUBLE) ||				\
+    MYNEWT_VAL(BUTTON_USE_LONG  ) ||				\
+    MYNEWT_VAL(BUTTON_USE_REPEAT) ||				\
+    MYNEWT_VAL(BUTTON_USE_PER_BUTTON_CALLBACK_EVENTQ) > 0
+    unsigned int i;
+#endif
     
+    if (button_internal_evq == NULL) {
+	button_internal_evq = os_eventq_dflt_get();
+    }
+    if (button_callback_default_evq == NULL) {
+	button_callback_default_evq = os_eventq_dflt_get();
+    }
+    
+    button_callback = cb;
+
 #if MYNEWT_VAL(BUTTON_USE_DOUBLE) || \
     MYNEWT_VAL(BUTTON_USE_LONG  ) || \
     MYNEWT_VAL(BUTTON_USE_REPEAT)
-    for (unsigned int i = 0 ; i < count ; i++) {
+    for (i = 0 ; i < count ; i++) {
 	button_t *button = &buttons[i];
-	os_callout_init(&button->callout, os_eventq_dflt_get(),
+	os_callout_init(&button->callout, button_internal_evq,
 			button_fsm_callout, button);
     }
 #endif
+
+#if MYNEWT_VAL(BUTTON_USE_PER_BUTTON_CALLBACK_EVENTQ) > 0
+    for (unsigned int i = 0 ; i < count ; i++) {
 
 Review comment:
   Can this loop use the `i` already declared at the top of the function?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services