DVD UI HACK - the software

The purpose of the software is to retrieve the user commands from the different sources, translate them to the desired remote control messages and transmit them such that the DVD player thinks it was actually remote control messages.

Decoding the keyboard

The front panel buttons are electrically arranged in a 2x3 matrix, as exemplified in the picture below, though only 5 buttons are present. The principle implemented to scan the matrix works without needing any external components. By driving one of the X wires low, button presses are read by the PIN value of the Y wires. This works because the internal pullup resistors of their I/O ports are enabled.

Keyboard matrix buttons wiring

The keyboard decoding module drives the X wires low one at a time when the handler function is called. Debounce is implemented by waiting until, the state of the keyboard has been constant for a certain number of scans.

Decoding the IR signal

The analysis of the IR signals from the remotes has already been dealt with in the IR analyzer part. This IR decoder module is a little different from the code in IR analyzer. Only the decoded bits, not the raw timings, are recorded, and some prologue pulses of the message are discarded. The decoding is implemented in the ISR of an external interrupt and a timer is used for the timing. The module is capable of decoding at least the specific Denver and Technics remote controls I have.

Encoding the IR signal

The irsend module is able to produce remote control messages understandable by the Denver DVD player. The implementation relies on timer interrupts, meaning that the transmission does not block execution. In the timer compare match interrupt the output signal is toggled. To transmit each bit, the timer compare value is then set accordingly such that the correct pulse lengths are created.

Getting it all together

In ui_fix.c the main function is implemented as well as the message translation infrastructure. Defines for all of the remote control signal codes can be found in this file.

The heart of it all is the translation structs. With these structs the user interface is effectively defined, and they represents the very goal of it all, fixing the user interface:

/* Keyboard translation */
#define KMSG_TRANS 5

const struct {
  unsigned char kmsg;   // from: keyboard msg
  unsigned short dmsg;  // to:   denver ir msg
} kmsg_trans[KMSG_TRANS] PROGMEM = \
    {{KMSG_EJECT,      DMSG_EJECT},
     {KMSG_ARROWLEFT,  DMSG_STOP},
     {KMSG_LEFT,       DMSG_SKIPBACK},
     {KMSG_RIGHT,      DMSG_SKIPFWD},
     {KMSG_ARROWRIGHT, DMSG_PLAY}};

/* Technics IR translation */
#define TMSG_TRANS 19

const struct {
  unsigned long tmsg;   // from: technics msg
  unsigned short dmsg;  // to:   denver ir msg
} tmsg_trans[TMSG_TRANS] PROGMEM = \
    {{TMSG_CD_1        ,DMSG_1     },
     {TMSG_CD_2        ,DMSG_2     },
     {TMSG_CD_3        ,DMSG_3     },
     {TMSG_CD_4        ,DMSG_4     },
     {TMSG_CD_5        ,DMSG_5     },
     {TMSG_CD_6        ,DMSG_6     },
     {TMSG_CD_7        ,DMSG_7     },
     {TMSG_CD_8        ,DMSG_8     },
     {TMSG_CD_9        ,DMSG_9     },
     {TMSG_CD_0        ,DMSG_0     },
     {TMSG_CD_P10      ,DMSG_P10   },
     {TMSG_CD_DISC     ,DMSG_EJECT },
     {TMSG_CD_SKIPBACK ,DMSG_SKIPBACK },
     {TMSG_CD_SKIPFWD  ,DMSG_SKIPFWD  },
     {TMSG_CD_SCANBACK ,DMSG_LEFT  }, 
     {TMSG_CD_SCANFWD  ,DMSG_RIGHT }, 
     {TMSG_CD_PAUSE    ,DMSG_PAUSE }, 
     {TMSG_CD_STOP     ,DMSG_STOP  }, 
     {TMSG_CD_PLAY     ,DMSG_PLAY  }};

Take a look at the whole file:

16-bit LED PWM

To control the front panel led in a pleasing manner, the 16-bit timer of the AtMega was rigged to do some nice PWM. The result is a very smooth fade in and out, a bit like the typical Apple white led fading, but slower. When the flash function is called, the LED will flash powerfully and slowly fade out like a slow light bulb. The 16-bit resolution and the use of exponential functions makes the fading really smooth. The disadvantage is a rather "low" PWM frequency of 122 Hz with 8 MHz cpu clock.

The LED dynamics are implemented in the timer overflow interrupt. Note that the module spends 260+316 bytes of program memory for lookup tables alone.

In summary

The complete program spends 2324 bytes of flash and 36 bytes of ram. The software is configured for AtmegaX8 micros and expects an 8 MHz clock. All three hardware timers are in use.

Get the complete source and makefile with this zip:

This concludes the documentation for my DVD User Interface hack! Please don't hesitate if you have any comments.

By Lars Ole Pontoppidan

Last update: July 2006

 

Previous: The hardware  -  Next: Comments