Phil,
I'd like to propose the attached patch, which adds callback parameters
to learn_from_remote.
Whilst it's not that useful in the current implementation (the progress
values aren't that meaningful), I'd argue it makes sense to make this
change before the next libconcord release, so that we can implement the
actual calling of the callback whenever we want, without needlessly
breaking binary compatibility of this API between releases.
Checkin comment:
libconcord/libconcord.h:
libconcord/libconcord.cpp:
libconcord/bindings/python/libconcord.py:
Add callback parameters to learn_from_remote
libconcord/remote.h:
libconcord/remote.cpp:
libconcord/remote_z.cpp:
Add callback parameters to LearnIR
concordance/concordance.c:
Pass new callback parameters to learn_from_remote
Remove redundant percentage printing; the callback does it now.
? concordance/.concordance.c.swp
? concordance/.deps
? concordance/.libs
? concordance/Makefile
? concordance/Makefile.in
? concordance/aclocal.m4
? concordance/autom4te.cache
? concordance/concordance
? concordance/config.guess
? concordance/config.h
? concordance/config.h.in
? concordance/config.log
? concordance/config.status
? concordance/config.sub
? concordance/configure
? concordance/depcomp
? concordance/install-sh
? concordance/libtool
? concordance/ltmain.sh
? concordance/missing
? concordance/stamp-h1
? libconcord/.deps
? libconcord/.libconcord.cpp.swp
? libconcord/.libconcord.h.swp
? libconcord/.libs
? libconcord/.remote.cpp.swp
? libconcord/.remote.h.swp
? libconcord/.remote_z.cpp.swp
? libconcord/Makefile
? libconcord/Makefile.in
? libconcord/aclocal.m4
? libconcord/autom4te.cache
? libconcord/binaryfile.lo
? libconcord/config.guess
? libconcord/config.h
? libconcord/config.h.in
? libconcord/config.log
? libconcord/config.status
? libconcord/config.sub
? libconcord/configure
? libconcord/depcomp
? libconcord/install-sh
? libconcord/libconcord.la
? libconcord/libconcord.lo
? libconcord/libtool
? libconcord/libusbhid.lo
? libconcord/ltmain.sh
? libconcord/missing
? libconcord/remote.lo
? libconcord/remote_z.lo
? libconcord/stamp-h1
? libconcord/usblan.lo
? libconcord/web.lo
? libconcord/bindings/python/.libconcord.py.swp
? libconcord/bindings/python/libconcord.pyc
Index: concordance/concordance.c
===
RCS file: /cvsroot/concordance/concordance/concordance/concordance.c,v
retrieving revision 1.33
diff -u -p -r1.33 concordance.c
--- concordance/concordance.c 12 Oct 2008 22:35:26 - 1.33
+++ concordance/concordance.c 14 Oct 2008 03:42:34 -
@@ -284,11 +284,10 @@ int learn_ir_commands(uint8_t *data, uin
printf("press corresponding key ");
printf("on original remote within 5 sec:\n");
printf("Learning IR signal: ");
-cb_print_percent_status(0, 0, 1, NULL);
err = learn_from_remote(&carrier_clock,
- &ir_signal, &ir_signal_length);
+ &ir_signal, &ir_signal_length,
+ cb_print_percent_status, NULL);
if (err == 0) {
- cb_print_percent_status(1, 1, 1, NULL);
printf(" done\n");
}
break;
Index: libconcord/libconcord.cpp
===
RCS file: /cvsroot/concordance/concordance/libconcord/libconcord.cpp,v
retrieving revision 1.37
diff -u -p -r1.37 libconcord.cpp
--- libconcord/libconcord.cpp 12 Oct 2008 22:35:26 - 1.37
+++ libconcord/libconcord.cpp 14 Oct 2008 03:42:34 -
@@ -1342,7 +1342,8 @@ void delete_key_names(char **key_names,
* Returns 0 for success, error code for failure.
*/
int learn_from_remote(uint32_t *carrier_clock,
- uint32_t **ir_signal, uint32_t *ir_signal_length)
+ uint32_t **ir_signal, uint32_t *ir_signal_length,
+ lc_callback cb, void *cb_arg)
{
if (rmt == NULL){
return LC_ERROR_CONNECT;
@@ -1354,7 +1355,8 @@ int learn_from_remote(uint32_t *carrier_
}
/* try to learn code via Harmony from original remote: */
- return rmt->LearnIR(carrier_clock, ir_signal, ir_signal_length);
+ return rmt->LearnIR(carrier_clock, ir_signal, ir_signal_length, cb,
+ cb_arg);
}
/*
Index: libconcord/libconcord.h
===
RCS file: /cvsroot/concordance/concordance/libconcord/libconcord.h,v
retrieving revision 1.20
diff -u -p -r1.20 libconcord.h
--- libconcord/libconcord.h 12 Oct 2008 22:35:26 - 1.20
+++ libconcord/libconcord.h 14 Oct 2008 03:42:34 -
@@ -431,7 +431,8 @@ void delete_key_names(char **key_names,
* via delete_ir_signal() when not needed any longer.
*/
int learn_from_remote(uint32_t *carrier_clock,
- uint32_t **ir_signal, uint32_t *ir_signal_length);
+ uint32_t **ir_signal, uint32_t *ir_signal_length,
+ lc_callback cb, void *cb_arg);
void delete_ir_signal(uint32_t *ir_signal);
Index: libconcord/remote.cpp
===
RCS file: /cvsroot/concordance/concordance/libconcord/remote.cpp,v
retrieving revision 1.35