PeterBLITZ / m2tklib

Automatically exported from code.google.com/p/m2tklib
0 stars 0 forks source link

Enhancement request: IRremote event source for arduino #34

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Arduino's event source is good to start project but may be good idea to have 
some choice?

for instance I wrote this one, its work well but may be it is possible to use 
your library's pin-key mapping to develop common case:

--------------------------------------------------------------------
#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

uint8_t m2_es_arduino_ir(m2_p ep, uint8_t msg) {
  switch(msg)
  {
    case M2_ES_MSG_GET_KEY:
      if (irrecv.decode(&results)) {
        irrecv.resume(); // Receive the next value
        switch(results.value) {
          case 0xFFC23D:
            return M2_KEY_SELECT;
          case 0xFFB04F:
            return M2_KEY_EXIT;
          case 0xFF02FD:
            return M2_KEY_NEXT;
          case 0xFF22DD:
            return M2_KEY_PREV;
          case 0xFF0000:
            return M2_KEY_DATA_UP;
          case 0xFF0001:
            return M2_KEY_DATA_DOWN;
          default:
            return M2_KEY_NONE;
         }
      }
    default:
      return 0;
  }
} 
--------------------------------------------------------------------

BTW: I have disable key debouncing in library. Without that this event provider 
do not works properly.

Original issue reported on code.google.com by ser...@rapidfd.com on 26 Nov 2011 at 6:25

GoogleCodeExporter commented 8 years ago
thanks for sharing the code.
Have you tried to put M2_KEY_EVENT() around the returned key values?
This will also disable the debouncing (however it was not fully tested by me).
So, for example use
  return M2_KEY_EVENT(M2_KEY_SELECT);
for all keys except M2_KEY_NONE

Original comment by olikr...@gmail.com on 26 Nov 2011 at 8:10

GoogleCodeExporter commented 8 years ago
I assume this lib:
http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html

Original comment by olikr...@gmail.com on 26 Nov 2011 at 8:16

GoogleCodeExporter commented 8 years ago
Added your file here:
http://code.google.com/p/m2tklib/source/browse/dev/arduino/m2esarduinoir.c

please let me know, if the file works for you

Original comment by olikr...@gmail.com on 26 Nov 2011 at 8:38

GoogleCodeExporter commented 8 years ago
added web page
http://code.google.com/p/m2tklib/wiki/irremote

Original comment by olikr...@gmail.com on 26 Nov 2011 at 8:52

GoogleCodeExporter commented 8 years ago

Original comment by olikr...@gmail.com on 26 Nov 2011 at 8:53

GoogleCodeExporter commented 8 years ago
About M2_KEY_EVENT(): it should work instead of patching key provider. Thanks 
for pointing on this.

Will check m2esarduinoir.c as soon as reassembly my device, I hope its takes 
1-2 days.

Thanks!

Original comment by ser...@rapidfd.com on 27 Nov 2011 at 9:50

GoogleCodeExporter commented 8 years ago
Unfortunately m2esarduinoir.c cannot be compile:
----------------------------------------------------------------------------
In file included from 
C:\ssw\arduino-0023\libraries\M2tklib\utility\m2esarduinoir.c:17:
C:\ssw\arduino-0023\libraries\IRremote/IRremote.h:24: error: expected '=', ',', 
';', 'asm' or '__attribute__' before 'decode_results'
C:\ssw\arduino-0023\libraries\IRremote/IRremote.h:44: error: expected '=', ',', 
';', 'asm' or '__attribute__' before 'IRrecv'
C:\ssw\arduino-0023\libraries\IRremote/IRremote.h:69: error: expected '=', ',', 
';', 'asm' or '__attribute__' before 'IRsend'
C:\ssw\arduino-0023\libraries\M2tklib\utility\m2esarduinoir.c:21: error: 
expected '=', ',', ';', 'asm' or '__attribute__' before 'irrecv'

...  some more errors ...
----------------------------------------------------------------------------

Looks like IRremote.h cannot be included in that context correctly. I have no 
idea how arduino IDE call gcc, so I can't pass any options to the compiler.

But good new is: m2esarduinoir.c works well and may used by people as usefull 
example to create custom IR event source.

Original comment by ser...@rapidfd.com on 27 Nov 2011 at 3:38

GoogleCodeExporter commented 8 years ago
Thanks for the feedback, however, due to your compile problem, i reopend this 
issue again. 

Next step: Find reason for compiler problem. I will try to do this for the next 
release. But maybe you also have an idea.

Oliver

Original comment by olikr...@gmail.com on 27 Nov 2011 at 5:22

GoogleCodeExporter commented 8 years ago
moved the .c file to a subfolder (because all examples are broken  because of 
the missing .h file)

I will close this for now...

Original comment by olikr...@gmail.com on 10 Jan 2012 at 11:09

GoogleCodeExporter commented 8 years ago
I have put the content of m2esarduinoir.c into an M2tklib example file.
After finetuning it compiles (Visual Studio IDE) and works on my arduino mega 
2560 with my Emtec RC.

Original comment by kljosc on 15 Mar 2012 at 10:04

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for adding this example!

Original comment by olikr...@gmail.com on 15 Mar 2012 at 10:15