lcddrv.txt - HOW TO WRITE AN LCD DRIVER FOR DAMP ================================================ The LCD support in DAMP is driver-based. The drivers are written in separate files, which look very much like a C program, but have the .sc extension. This document describes how to go about writing an LCD driver for DAMP. Note that although the reason these drivers originally came into being was in order to drive LCD displays, the overall structure should be treated as an "output" driver, rather than an LCD driver, as theoretically you could output to all kinds of weird and wonderful devices by using this system. First of all, it is important to note that attempting to write a driver without knowing what you're doing could result in damage to your LCD. I hereby claim no responsibility for any loss as a result of you attempting to write an LCD driver. Secondly, someone may have already written a driver for the particular LCD you have, so check the DAMP web page at http://www.damp-mp3.co.uk/ for any driver updates. Also note that you may tweak the parameters to values which you know to be correct, and DAMP still won't work with your LCD. In which case you need to send as much information as you can about your display and the chip it uses to drivers@damp-mp3.co.uk - NOTE: I WILL NOT WRITE DRIVERS FOR YOU! I will only make use of the info you send me if the reason it doesn't work is due to a problem which cannot be solved by setting the driver parameters to the correct values. The drivers that come with DAMP as standard, "LCDWIRE1.sc" and "LCDWIRE2.sc", are for two different wiring schemes of the HD44780 chip, and this document may use them as an example, in order to guide you through the driver creation process. Oh, and one last thing before we get started: If you manage to write a working driver, please send it to drivers@damp-mp3.co.uk so it can be included with future releases of DAMP, and/or made available from the DAMP web page. You should also send a small (less than 10Kb) 2-colour .GIF image, showing a wiring diagram for your LCD. CREATING A NEW DRIVER ===================== First of all, if you don't know how to program in C, you may not be very successful, depending upon how much of an existing driver needs altering. (eg: if you just need to alter a couple of numbers, I'm sure you'll do alright). DAMP LCD drivers are written in C, and are compiled at runtime by DAMP thanks to the excellent SeeR scripting library by Przemyslaw Podsiadly. I would really suggest you go and download the SeeR package from his homepage as it has full instructions on what will and wont work when writing a script. The SeeR homepage address can be found in the DAMP documentation. I would suggest basing your driver on an existing one, so make a copy of it and rename it to whatever you want to call your driver. Also be sure to alter the "driver" setting in the [lcd] section of DAMP.ini to the name you have chosen. However, the drivers that come with DAMP as standard are for a parallel port LCD. Writing a driver for a serial port LCD will be a slightly different process, although it is certainly possible. Now edit your .sc file. You will notice that the first thing this does is #include "damplcd.sh". This is a header file that contains all the necessary functions and variables for writing a driver. Here is a list of what they are: Variables --------- char lcd_surround_symbol - The ascii code of the "Surround sound" symbol char lcd_play_symbol - The ascii code of the "Play" symbol char lcd_random_symbol - The ascii code of the "Random" symbol char lcd_rew_symbol - The ascii code of the "Rewind" symbol char lcd_continuous_symbol - The ascii code of the "Continuous play" symbol char lcd_driver_name[256] - The name of your driver char lcd_driver_author[256] - Your name char lcd_driver_author_email[256] - Your email address char lcd_driver_description[256] - A short description of your driver float lcd_driver_version - The version number of your driver int lcd_display_width - The width of the displa, as specified in DAMP.INI unsigned char lcd_line[2][41] - To be used by lcd_printf() int damp_vu - Contains the current vu-meter level, from 0 to 63. int damp_random_play - Non-zero if random play is enabled int damp_surround - Non-zero if surround sound is enabled int damp_paused - Non-zero if track is paused int damp_volume - Volume level 0-255 char damp_status[10] - eg: PLAY> PAUSE FFWD>> <