projects
/
moodlight.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6dc7afb
)
now also supporting "repeat" codes for selected keys.
author
simimeie
<simimeie>
Wed, 30 Jun 2010 19:38:28 +0000
(19:38 +0000)
committer
simimeie
<simimeie>
Wed, 30 Jun 2010 19:38:28 +0000
(19:38 +0000)
ircontrol.c
patch
|
blob
|
blame
|
history
ircontrol.h
patch
|
blob
|
blame
|
history
diff --git
a/ircontrol.c
b/ircontrol.c
index e0e5317927a36c722d96a00738e68feab63242dc..4a8e46f92e0212fd30611e7369aa07fcaf15c252 100644
(file)
--- a/
ircontrol.c
+++ b/
ircontrol.c
@@
-1,4
+1,4
@@
-/* $Id: ircontrol.c,v 1.
4 2010/06/27 23:05:55
simimeie Exp $
+/* $Id: ircontrol.c,v 1.
5 2010/06/30 19:38:28
simimeie Exp $
* Functions for the infrared receiver
*
* The infrared receiver is connected to PB0 / PCINT0.
* Functions for the infrared receiver
*
* The infrared receiver is connected to PB0 / PCINT0.
@@
-24,10
+24,13
@@
/* For NEC, we start with a 9000 us pulse, then 4500 us silence.
* Then the bits follow:
/* For NEC, we start with a 9000 us pulse, then 4500 us silence.
* Then the bits follow:
- * a 1 is a 560 us pulse followed by 1690 us of silence.
- * a 0 is a 560 us pulse followed by 560 us of silence.
+ * a 1 is a 560 us pulse followed by 1690 us of silence
(=2250 us total)
.
+ * a 0 is a 560 us pulse followed by 560 us of silence
(=1120 us total)
.
* These values equal the following cpu cycle counts:
* 9000 us = 72000 cc, 4500 us = 36000 cc, 560 us = 4480, 1690 us = 13520 cc
* These values equal the following cpu cycle counts:
* 9000 us = 72000 cc, 4500 us = 36000 cc, 560 us = 4480, 1690 us = 13520 cc
+ * When the key stays pressed, it is not resubmitted, but instead a special
+ * "repeat" code is sent. That is: 9000 us pulse, 2250 us silence, 560 us
+ * pulse.
*/
#define NECSTARTLEN1 ((CPUFREQ * 9UL) / 1000UL)
#define NECSTARTLEN2 ((CPUFREQ * 45UL) / 10000UL)
*/
#define NECSTARTLEN1 ((CPUFREQ * 9UL) / 1000UL)
#define NECSTARTLEN2 ((CPUFREQ * 45UL) / 10000UL)
@@
-44,9
+47,14
@@
static struct timestamp last0irqts;
static struct timestamp last1irqts;
static struct timestamp last0irqts;
static struct timestamp last1irqts;
-static uint8_t lastpin = 0;
+static uint8_t lastpin = 0
xff
;
static uint8_t codebytes[4];
static uint8_t curcodebit = 0xff;
static uint8_t codebytes[4];
static uint8_t curcodebit = 0xff;
+static uint8_t lastcommand = 0xff;
+static uint8_t repeatcommand = 0xff;
+static uint16_t repeatticks = 0;
+/* Repeat after this many ticks (70 = 0.5s) */
+#define REPEATAFTERTICKS 100
/* some example codes
root@moodlight# !NSB! 11111111 00001000 11011111 00100000 (r)
/* some example codes
root@moodlight# !NSB! 11111111 00001000 11011111 00100000 (r)
@@
-90,6
+98,9
@@
ISR(PCINT0_vect) {
console_printpgm_P(PSTR("!CRC!"));
} else {
/* Successful decode! */
console_printpgm_P(PSTR("!CRC!"));
} else {
/* Successful decode! */
+ lastcommand = codebytes[2];
+ repeatcommand = codebytes[2];
+ repeatticks = curirqts.ticks;
console_printpgm_P(PSTR(" DEC>"));
console_printhex8(codebytes[0]);
console_printhex8(codebytes[1]);
console_printpgm_P(PSTR(" DEC>"));
console_printhex8(codebytes[0]);
console_printhex8(codebytes[1]);
@@
-125,6
+136,12
@@
ISR(PCINT0_vect) {
&& (ts0diff <= ((12 * NECREPEATLEN) / 10))) {
if (curcodebit == 0xfe) {
console_printpgm_P(PSTR(".REP."));
&& (ts0diff <= ((12 * NECREPEATLEN) / 10))) {
if (curcodebit == 0xfe) {
console_printpgm_P(PSTR(".REP."));
+ if ((curirqts.ticks - repeatticks) > REPEATAFTERTICKS) {
+ if ((repeatcommand == 0x00) || (repeatcommand == 0x01)) {
+ /* Only the up/down arrows are allowed to be repeated */
+ lastcommand = repeatcommand;
+ }
+ }
}
}
last1irqts = curirqts;
}
}
last1irqts = curirqts;
@@
-173,3
+190,11
@@
void ircontrol_init(void)
/* Enable pin change interrupt 0 (=PB0) in pcint0 */
PCMSK0 |= _BV(PCINT0);
}
/* Enable pin change interrupt 0 (=PB0) in pcint0 */
PCMSK0 |= _BV(PCINT0);
}
+
+uint8_t ircontrol_getlastcommand(void)
+{
+ uint8_t res;
+ res = lastcommand;
+ lastcommand = 0xff;
+ return res;
+}
diff --git
a/ircontrol.h
b/ircontrol.h
index b1a42efe3c389f3c2926e44a52f03f573d949a17..f12a9e5f87a1bb973f1b03e89e7c702b35a7c46b 100644
(file)
--- a/
ircontrol.h
+++ b/
ircontrol.h
@@
-1,4
+1,4
@@
-/* $Id: ircontrol.h,v 1.
1 2010/06/26 19:08:1
8 simimeie Exp $
+/* $Id: ircontrol.h,v 1.
2 2010/06/30 19:38:2
8 simimeie Exp $
* Functions for the infrared receiver
*/
* Functions for the infrared receiver
*/
@@
-8,4
+8,7
@@
/* Init infrared receiver (pins) */
void ircontrol_init(void);
/* Init infrared receiver (pins) */
void ircontrol_init(void);
+/* Get received code */
+uint8_t ircontrol_getlastcommand(void);
+
#endif /* _IRCONTROL_H_ */
#endif /* _IRCONTROL_H_ */
This page took
0.053671 seconds
and
4
git commands to generate.