Last, but not least, here comes the patches for congruity
and concordance to utilize libIRremotes for reading Pronto
codes.
Patches are against congruity8 resp. CVS concordance plus
patch for new IR learning (from previous messages).

Regards, Andreas Schulz
diff -prc congruity8/Changelog congruity8.1/Changelog
*** congruity8/Changelog	2008-06-05 09:00:15.000000000 +0200
--- congruity8.1/Changelog	2008-06-05 08:58:55.000000000 +0200
***************
*** 1,3 ****
--- 1,7 ----
+ * 2008-06-05 Andreas Schulz <[EMAIL PROTECTED]> - congruity-8.1
+ - Added support for learning IR codes from Philips Pronto hex codes,
+   using libIRremotes.
+ 
  * 2008-06-05 Andreas Schulz <[EMAIL PROTECTED]> - congruity-8
  - Added retrieval of remote information, shown as tooltip for the
    remote image.
diff -prc congruity8/congruity congruity8.1/congruity
*** congruity8/congruity	2008-06-05 23:46:27.000000000 +0200
--- congruity8.1/congruity	2008-06-05 23:46:27.000000000 +0200
*************** import wx
*** 33,44 ****
  import wx.lib.dialogs
  
  import libconcord
  
! version = "8"
  
  # global:
  need_deinit = False
  
  #-------------------------------------------------
  # added for development debug output a.schulz:
  import pdb         # debugger a.schulz
--- 33,51 ----
  import wx.lib.dialogs
  
  import libconcord
+ import libIRremotes
  
! version = "8.1"
  
  # global:
  need_deinit = False
  
+ # Times to add a potential Repeat part of a Pronto HEX code
+ # to the transmitted IR pulse stream. Trying:
+ nRepeat = 2
+ # so the Logitech database might recognize the repetition.
+ # might be worth to be changeable by the user at runtime?
+ 
  #-------------------------------------------------
  # added for development debug output a.schulz:
  import pdb         # debugger a.schulz
*************** iwh = (iw, ih)
*** 59,64 ****
--- 66,72 ----
  
  #-- pass verbose flag to imported libraries:
  libconcord.set_verbose(verbose)
+ libIRremotes.set_verbose(verbose)
  
  #-- shortcut to produce verbose output:
  def vprint(message):
*************** class LearnIRPanel_Start(LearnIRPanel):
*** 1160,1166 ****
              self.resources.default_action = "Learn"
          else:
              disconnect_Harmony()
!             self.resources.default_action = "Skip"
          self.parent.ReenableNext()
  
  # -------------------------------------------------------------------
--- 1168,1174 ----
              self.resources.default_action = "Learn"
          else:
              disconnect_Harmony()
!             self.resources.default_action = "Pronto"
          self.parent.ReenableNext()
  
  # -------------------------------------------------------------------
*************** class LearnIRPanel_Key(LearnIRPanel):
*** 1173,1193 ****
          self.bmp_code_source_select = wx.StaticBitmap(self, -1, 
                  self.resources.icon_unstarted, None, iwh)
          self.text_code_source_select = wx.StaticText(self, 
!                 -1, "Select action for this key :")
          self.code_source_select = wx.RadioBox( self, -1, "", 
                  wx.DefaultPosition, wx.DefaultSize,
!                 ['Learn', 'Skip'], 2, wx.RA_SPECIFY_COLS | wx.NO_BORDER)
          sizer.Add(self.bmp_code_source_select,   (vpos, 0), (1, 1), ALIGN_LC, 5)
          sizer.Add(self.text_code_source_select,  (vpos, 1), (1, 1), ALIGN_LC, 5)
          sizer.Add(self.code_source_select,       (vpos, 2), (1, 1), ALIGN_CC, 5)
          self.Bind(wx.EVT_RADIOBOX, self.on_ir_radio_box, self.code_source_select)
          return vpos + 1
  
      # -- construct panel items, called by __init__
      def fill_panel(self, vpos, sizer):
          vpos = self.add_keyname_row(vpos, sizer)
          vpos = self.add_source_select_row(vpos, sizer)
          vpos = self.add_text_action_row(vpos, sizer)
          return vpos
  
      # -------------------------------------------------------------------
--- 1181,1217 ----
          self.bmp_code_source_select = wx.StaticBitmap(self, -1, 
                  self.resources.icon_unstarted, None, iwh)
          self.text_code_source_select = wx.StaticText(self, 
!                 -1, "IR code source for this key :")
          self.code_source_select = wx.RadioBox( self, -1, "", 
                  wx.DefaultPosition, wx.DefaultSize,
!                 ['Learn', 'Pronto', 'Skip'], 3, wx.RA_SPECIFY_COLS | wx.NO_BORDER)
          sizer.Add(self.bmp_code_source_select,   (vpos, 0), (1, 1), ALIGN_LC, 5)
          sizer.Add(self.text_code_source_select,  (vpos, 1), (1, 1), ALIGN_LC, 5)
          sizer.Add(self.code_source_select,       (vpos, 2), (1, 1), ALIGN_CC, 5)
          self.Bind(wx.EVT_RADIOBOX, self.on_ir_radio_box, self.code_source_select)
          return vpos + 1
  
+     def add_pronto_hex_row(self, vpos, sizer):
+         self.bmp_prontohex = wx.StaticBitmap(self, -1, 
+                 self.resources.icon_unstarted, None, iwh)
+         self.text_prontohex = wx.StaticText(self, -1, "Pronto Hex Code:")
+         self.value_prontohex = wx.TextCtrl(self, -1, "", size=(250, ih), 
+                 style=wx.TE_PROCESS_ENTER | wx.HSCROLL)
+         self.Bind(wx.EVT_TEXT_ENTER, self.on_prontohex_enter, self.value_prontohex)
+         self.value_prontohex.Disable()
+         self.text_prontohex.Hide()
+         self.value_prontohex.Hide()
+         sizer.Add(self.bmp_prontohex,   (vpos, 0), (1, 1), ALIGN_LC, 5)
+         sizer.Add(self.text_prontohex,  (vpos, 1), (1, 1), ALIGN_LC, 5)
+         sizer.Add(self.value_prontohex, (vpos, 2), (1, 1), ALIGN_RC, 5)
+         return vpos + 1
+ 
      # -- construct panel items, called by __init__
      def fill_panel(self, vpos, sizer):
          vpos = self.add_keyname_row(vpos, sizer)
          vpos = self.add_source_select_row(vpos, sizer)
          vpos = self.add_text_action_row(vpos, sizer)
+         vpos = self.add_pronto_hex_row(vpos, sizer)
          return vpos
  
      # -------------------------------------------------------------------
*************** class LearnIRPanel_Key(LearnIRPanel):
*** 1195,1200 ****
--- 1219,1227 ----
  
      def do_code_source_select(self, this):
          self.resources.next_action = this
+         self.value_prontohex.Disable()
+         self.text_prontohex.Hide()
+         self.value_prontohex.Hide()
          # self.set_bitmaps(['3ph'], self.resources.icon_unstarted)
          if self.resources.next_action == 'Learn':
          # Learn : call libconcord function to read code from remote,
*************** class LearnIRPanel_Key(LearnIRPanel):
*** 1204,1209 ****
--- 1231,1247 ----
                      "Press next, then corresponding key on original remote to learn key:")
              self.parent.btn_next.SetFocus()
              # self.set_bitmaps(['5ci'], self.resources.icon_unstarted)
+         elif self.resources.next_action == 'Pronto':
+         # Pronto : read Pronto hex code from input field and convert,
+         #          then post/skip/retry as requested
+             self.resources.default_action = self.resources.next_action
+             self.value_prontohex.Enable()
+             # self.set_bitmaps(['3ph'], self.resources.icon_in_progress)
+             self.text_action.SetValue("Enter Pronto hex code for key, then press Next to check:")
+             self.text_prontohex.Show()
+             self.value_prontohex.Show()
+             self.value_prontohex.SetSelection(1, self.value_prontohex.GetLastPosition())
+             self.value_prontohex.SetFocus()
          elif self.resources.next_action == 'Skip':
          # Skip : proceed to next key; skipping post panel:
              # self.set_bitmaps(['5ci'], self.resources.icon_unstarted)
*************** class LearnIRPanel_Key(LearnIRPanel):
*** 1218,1226 ****
--- 1256,1273 ----
          self.do_code_source_select(self.code_source_select.GetStringSelection())
          # self.set_bitmaps(['2css'], self.resources.icon_complete)
  
+     # -------------------------------------------------------------------
+     # -- handler for 'enter' key event in Pronto Hex field of next_key panel:
+ 
+     def on_prontohex_enter(self, event):
+         wx.CallAfter(self.parent._OnNext, event)
+ 
      # -- Key panel exit: get selected action and Pronto code if requested:
      def _exit_handler(self):
          self.resources.next_action = self.code_source_select.GetStringSelection()
+         if self.resources.next_action != 'Skip':
+             if self.resources.next_action == 'Pronto':
+                 self.resources.pronto_hex = self.value_prontohex.GetValue()
  
      def _worker_function(self):
          self.Hide()
*************** class LearnIRPanel_Key(LearnIRPanel):
*** 1245,1251 ****
          self.parent.ReenableNext()
  
  # -------------------------------------------------------------------
! # ----------- 3 : Read from Harmony
  
  class LearnIRPanel_Learn(LearnIRPanel):
      # -------------------------------------------------------------------
--- 1292,1298 ----
          self.parent.ReenableNext()
  
  # -------------------------------------------------------------------
! # ----------- 3 : Read from Harmony resp. from entered Pronto HEX:
  
  class LearnIRPanel_Learn(LearnIRPanel):
      # -------------------------------------------------------------------
*************** class LearnIRPanel_Learn(LearnIRPanel):
*** 1327,1332 ****
--- 1374,1394 ----
              self.text_action.SetValue('Failed to read code, skip key or try again...')
              return False
  
+     def process_pronto_code(self):
+         try:
+             Pronto_Code = libIRremotes.pronto_hex()
+             libIRremotes.sscanf_pronto_hex(str(self.resources.pronto_hex), byref(Pronto_Code))
+             # sget_pronto_hex may raise an exception on failure
+             libIRremotes.pronto_to_pulses(Pronto_Code, byref(self.resources.carrier_clock),
+                                         nRepeat, byref(self.resources.pulse_count),
+                                         byref(self.resources.pulses))
+             # self.set_bitmaps(['3ph'], self.resources.icon_complete)
+             return True
+         except:
+             # self.set_bitmaps(['3ph'], self.resources.icon_failed)
+             self.text_action.SetValue('Bad Pronto Hex code, skip or try again...')
+             return False
+ 
      def enable_upload(self, do_enable):
          if do_enable:
              self.code_action_select.SetStringSelection('Upload')
*************** class LearnIRPanel_Learn(LearnIRPanel):
*** 1372,1377 ****
--- 1434,1443 ----
                  Have_Code = self.learn_from_original_remote()
                  self.timeout_bar.gauge.SetValue(self.timeout_bar.gauge.GetRange())
                  # self.set_bitmaps(['5ci'], self.resources.icon_unstarted)
+             elif self.resources.next_action == 'Pronto':
+                 # convert Pronto hex code read from input field,
+                 self.text_action.SetValue("Processing received Pronto Hex code...")
+                 Have_Code = self.process_pronto_code()
              if Have_Code:
                  self.show_new_code()
              self.enable_upload(Have_Code)
*************** class LearnIRPanel_Post(LearnIRPanel):
*** 1417,1423 ****
              self.on_web_notify_final(False, 0)
              self.value_keyname.SetValue(string_at(self.resources.key_name))
              # self.set_bitmaps(['6cas'], self.resources.icon_in_progress)
!             # we have valid code : display result and POST
              post_code = libconcord.encode_for_posting(self.resources.carrier_clock, 
                  self.resources.pulses, self.resources.pulse_count)
              if post_code != None:
--- 1483,1489 ----
              self.on_web_notify_final(False, 0)
              self.value_keyname.SetValue(string_at(self.resources.key_name))
              # self.set_bitmaps(['6cas'], self.resources.icon_in_progress)
!             # we have valid code, either Pronto or learned : display result and POST
              post_code = libconcord.encode_for_posting(self.resources.carrier_clock, 
                  self.resources.pulses, self.resources.pulse_count)
              if post_code != None:
*************** class Wizard(wx.Dialog):
*** 1523,1528 ****
--- 1589,1595 ----
          verbose = self.chk_verbose.GetValue()
          print "verbose <= "+str(verbose)
          libconcord.set_verbose(verbose)
+         libIRremotes.set_verbose(verbose)
  
      def SetPages(self, pages):
          def tuple_max(a, b):
diff -prc concordance.nopronto/concordance.1 concordance/concordance.1
*** concordance.nopronto/concordance.1	2008-06-05 08:16:05.000000000 +0200
--- concordance/concordance.1	2008-06-05 08:15:07.000000000 +0200
*************** Enable verbose output.
*** 90,95 ****
--- 90,98 ----
  .TP
  .B \-w, \-\-no\-web
  Do not attempt to talk to the website. This is useful for re-programming the remote from a saved file, or for debugging.
+ .TP
+ .B \-o, \-\-ir\-from\-other
+ For Learn IR mode, do not learn the code from the orignal remote via you Harmony, but instead get prompted to enter an IR code in the Philips Pronto raw hex format, as can be found e.g. on www.remotecentral.com.
  .SH BUGS
  None known at time of release, but check the website.
  .SH BUG REPORTS
diff -prc concordance.nopronto/concordance.c concordance/concordance.c
*** concordance.nopronto/concordance.c	2008-06-06 08:29:42.000000000 +0200
--- concordance/concordance.c	2008-06-06 08:20:03.000000000 +0200
***************
*** 27,32 ****
--- 27,33 ----
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
+ #include <libIRremotes.h>
  
  #ifdef WIN32
  /* Windows includes*/
*************** struct options_t {
*** 83,88 ****
--- 84,90 ----
  	int noweb;
  	int direct;
  	int noreset;
+ 	int irfromother;
  };
  
  enum {
*************** void _dump_new_code(uint32_t carrier_clo
*** 187,192 ****
--- 189,220 ----
  	}
  }
  
+ int _read_pronto_code(uint32_t *carrier_clock, 
+ 	uint32_t **pulses, uint32_t *pulse_count)
+ {
+ 	struct pronto_hex code;
+ 	int err;
+ 
+ 	/*  read code from stdin: */
+ 	printf("Enter Pronto code:\n");
+ 	err = scanf_pronto_hex(NULL, &code);
+ 
+ 	if (err == 0) {
+ 		/*
+ 		 * If code has a repeat part, include it 2 times, so the
+ 		 * Logitech database might recognize it as repeat code:
+ 		 */
+ 		err = pronto_to_pulses(code, carrier_clock, 2,
+ 			pulse_count, pulses);
+ 	}
+ 
+ 	if (err != 0) {
+ 		printf("ERROR: invalid Pronto code!\n");
+ 	}
+ 	return err;
+ }
+ 
+ 
  int _learn_ir_commands(uint8_t *data, uint32_t size, struct options_t *options)
  {
  	int err = 0;
*************** int _learn_ir_commands(uint8_t *data, ui
*** 200,213 ****
  	while ((key_name = get_key_name(data, size, next_index++)) != NULL) {
  		printf("Next key : <%s> : ", key_name);
  		err = 1; /* have no code yet */
! 
! 		/* learn from remote: */
! 		printf("press <enter>, then related ");
! 		printf("key on original remote:");
! 		getchar();
! 		err = learn_from_remote(&carrier_clock, &pulses,
! 				&pulse_count);
! 
  		if ( err != 0 ) {
  			printf("Failed to get IR code, ");
  			printf("continue with next key...\n");
--- 228,245 ----
  	while ((key_name = get_key_name(data, size, next_index++)) != NULL) {
  		printf("Next key : <%s> : ", key_name);
  		err = 1; /* have no code yet */
! 		if ((*options).irfromother == 1) {
! 			/* requested to get Pronto (from stdin): */
! 			err = _read_pronto_code(&carrier_clock, &pulses,
! 					&pulse_count);
! 		} else {
! 			/* learn from remote: */
! 			printf("press <enter>, then related ");
! 			printf("key on original remote:");
! 			getchar();
! 			err = learn_from_remote(&carrier_clock, &pulses,
! 					&pulse_count);
! 		}
  		if ( err != 0 ) {
  			printf("Failed to get IR code, ");
  			printf("continue with next key...\n");
*************** void parse_options(struct options_t *opt
*** 592,597 ****
--- 624,630 ----
  		{"help", no_argument, 0, 'h'},
  		{"print-remote-info", no_argument, 0, 'i'},
  		{"learn-ir", required_argument, 0, 'l'},
+ 		{"ir-from-other", no_argument, 0, 'o'},
  		{"reset", no_argument, 0, 'r'},
  		{"no-reset", no_argument, 0, 'R'},
  		{"dump-safemode", optional_argument, 0, 's'},
*************** void parse_options(struct options_t *opt
*** 609,620 ****
  	(*options).noweb = 0;
  	(*options).direct = 0;
  	(*options).noreset = 0;
  
  	*mode = MODE_UNSET;
  
  	tmpint = 0;
  
! 	while ((tmpint = getopt_long(argc, argv, "bc::C:df::F:hil:rs::t:kKvVw",
  				long_options, NULL)) != EOF) {
  		switch (tmpint) {
  		case 0:
--- 642,654 ----
  	(*options).noweb = 0;
  	(*options).direct = 0;
  	(*options).noreset = 0;
+ 	(*options).irfromother = 0;
  
  	*mode = MODE_UNSET;
  
  	tmpint = 0;
  
! 	while ((tmpint = getopt_long(argc, argv, "bc::C:df::F:hil:ors::t:kKvVw",
  				long_options, NULL)) != EOF) {
  		switch (tmpint) {
  		case 0:
*************** void parse_options(struct options_t *opt
*** 670,675 ****
--- 704,712 ----
  			set_mode(mode, MODE_LEARN_IR);
  			*file_name = optarg;
  			break;
+ 		case 'o':
+ 			(*options).irfromother = 1;
+ 			break;
  		case 'r':
  			set_mode(mode, MODE_RESET);
  			break;
*************** void help()
*** 790,795 ****
--- 827,834 ----
  	printf("\t Set the remote's time clock\n\n");
  	printf("   -l, --learn-ir <filename>\n");
  	printf("\t Learn IR from other remotes. Use <filename>.\n\n");
+ 	printf("   -o, --ir-from-other\n");
+ 	printf("\t with -l : Learn IR from other source (file, input).\n\n");
  	printf("   -r, --reset\n");
  	printf("\tReset (power-cycle) the remote control\n\n");
  	printf("   -s, --dump-safemode [<filename>]\n");
diff -prc concordance.nopronto/Makefile concordance/Makefile
*** concordance.nopronto/Makefile	2008-06-06 08:30:04.000000000 +0200
--- concordance/Makefile	2008-06-05 21:37:06.000000000 +0200
*************** target_alias = 
*** 193,199 ****
  top_builddir = .
  top_srcdir = .
  concordance_SOURCES = concordance.c
! concordance_LDFLAGS = -lconcord
  # -Wall just makes good sense
  # -ansi and -pednatic errors are needed to ensure we're compatible with
  # crappy Microsoft compilers - phil
--- 193,199 ----
  top_builddir = .
  top_srcdir = .
  concordance_SOURCES = concordance.c
! concordance_LDFLAGS = -lconcord -lIRremotes
  # -Wall just makes good sense
  # -ansi and -pednatic errors are needed to ensure we're compatible with
  # crappy Microsoft compilers - phil
diff -prc concordance.nopronto/Makefile.am concordance/Makefile.am
*** concordance.nopronto/Makefile.am	2008-06-05 08:15:25.000000000 +0200
--- concordance/Makefile.am	2008-06-05 08:14:54.000000000 +0200
***************
*** 1,6 ****
  bin_PROGRAMS = concordance
  concordance_SOURCES = concordance.c
! concordance_LDFLAGS = -lconcord
  # -Wall just makes good sense
  # -ansi and -pednatic errors are needed to ensure we're compatible with
  # crappy Microsoft compilers - phil
--- 1,6 ----
  bin_PROGRAMS = concordance
  concordance_SOURCES = concordance.c
! concordance_LDFLAGS = -lconcord -lIRremotes
  # -Wall just makes good sense
  # -ansi and -pednatic errors are needed to ensure we're compatible with
  # crappy Microsoft compilers - phil
diff -prc concordance.nopronto/Makefile.in concordance/Makefile.in
*** concordance.nopronto/Makefile.in	2008-06-06 08:30:04.000000000 +0200
--- concordance/Makefile.in	2008-06-05 21:37:06.000000000 +0200
*************** target_alias = @target_alias@
*** 193,199 ****
  top_builddir = @top_builddir@
  top_srcdir = @top_srcdir@
  concordance_SOURCES = concordance.c
! concordance_LDFLAGS = -lconcord
  # -Wall just makes good sense
  # -ansi and -pednatic errors are needed to ensure we're compatible with
  # crappy Microsoft compilers - phil
--- 193,199 ----
  top_builddir = @top_builddir@
  top_srcdir = @top_srcdir@
  concordance_SOURCES = concordance.c
! concordance_LDFLAGS = -lconcord -lIRremotes
  # -Wall just makes good sense
  # -ansi and -pednatic errors are needed to ensure we're compatible with
  # crappy Microsoft compilers - phil
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
concordance-devel mailing list
concordance-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/concordance-devel

Reply via email to