analog backlight and contrast for LCD's

I'm now using the stand-alone package and lcd-proc.

Source

main.c

file: http://darcs.erazor-zone.de/x9c10x/main.c

#define _GNU_SOURCE
 
#include <stdlib.h>
#include <stdio.h>
#include <getopt.h>
#include <unistd.h>
#include <sys/io.h>
 
#include "main.h"
#include "x9c10x.c"
 
 
int main(void) {
    iopl(3);
    reset_disp_cst();
    set_disp_cst(50);
    return 1;
}

main.h

file: http://darcs.erazor-zone.de/x9c10x/main.h

#define PIN_1_ON                0x00                                            
#define PIN_1_OFF               0x01
 
#define PIN_17_ON               0x00                                            
#define PIN_17_OFF              0x08                                            
 
#define E2_ON                   0x00                                            
#define E2_OFF                  0x00
 
//io                                                                            
#define CST_UP          0x00                                                    
#define CST_DOWN        0x08                                            
#define CST_INC_ON      0x00                                            
#define CST_INC_OFF     0x04                                                    
 
#define BKL_UP          0x02                                                    
#define BKL_DOWN        0x00                                            
#define BKL_INC_ON      0x00                                            
#define BKL_INC_OFF     0x01                                                    
 
#define CST_CS_ON               PIN_17_OFF | PIN_1_OFF                             
#define CST_CS_OFF              PIN_17_ON | PIN_1_OFF                              
#define BKL_CS_ON               CST_CS_ON                                       
#define BKL_CS_OFF              CST_CS_OFF

x9c10x.c

file: http://darcs.erazor-zone.de/x9c10x/x9c10x.c

/*11.04.2003 Alexander 'E-Razor' Krause admin@erazor-zone.de*/
 
/* x9c10x.h
 
 */
 
#define X9C10X_INC_DELAY 1
#define X9C10X_CS_DELAY 2
 
unsigned short int port=0x378;
unsigned char disp_cst;
unsigned char disp_bkl;
 
void reset_disp_cst(void) {
	unsigned char ac;	
 
	outb(CST_INC_OFF | BKL_INC_OFF, port);
	outb(CST_CS_ON, port+2);
	for (ac=0; ac<101; ac++) {
		usleep(X9C10X_INC_DELAY);
		outb(CST_DOWN | CST_INC_ON | BKL_INC_OFF, port);
		usleep(X9C10X_INC_DELAY);
		outb(CST_DOWN | CST_INC_OFF | BKL_INC_OFF, port);		
	}
	usleep(X9C10X_CS_DELAY);
	outb(CST_CS_OFF, port+2);
	disp_cst=0;
}
 
void reset_disp_bkl(void) {
	unsigned char ac;
 
	outb(BKL_INC_OFF | CST_INC_OFF, port);
	outb(BKL_CS_ON, port+2);
	for (ac=0; ac<101; ac++) {
		usleep(X9C10X_INC_DELAY);
		outb(BKL_DOWN | BKL_INC_ON | CST_INC_OFF, port);
		usleep(X9C10X_INC_DELAY);
		outb(BKL_DOWN | BKL_INC_OFF | CST_INC_OFF, port);		
	}
	usleep(X9C10X_CS_DELAY);
	outb(BKL_CS_OFF, port+2);
	disp_bkl=0;
}
 
 
void set_disp_cst(unsigned char new_value) {
	unsigned char ac;	
 
	outb(CST_INC_OFF | BKL_INC_OFF, port);
	outb(CST_CS_ON, port+2);
	for (ac=0; ac<abs(new_value-disp_cst); ac++) {
        	usleep(X9C10X_INC_DELAY);
		outb( (new_value>disp_cst?CST_UP:CST_DOWN) | CST_INC_ON | BKL_INC_OFF, port);
		usleep(X9C10X_INC_DELAY);
		outb( (new_value>disp_cst?CST_UP:CST_DOWN) | CST_INC_OFF | BKL_INC_OFF, port);		
	}
 
	usleep(X9C10X_CS_DELAY);
	outb(CST_CS_OFF, port+2);
	disp_cst=new_value;
 
}
 
void set_disp_bkl(unsigned char new_value) {
	unsigned char ac;	
 
	outb(BKL_INC_OFF | CST_INC_OFF, port);
	outb(BKL_CS_ON, port+2);
	for (ac=0; ac<abs(new_value-disp_cst); ac++) {
		usleep(X9C10X_INC_DELAY);
		outb( (new_value>disp_bkl?BKL_UP:BKL_DOWN) | BKL_INC_ON | CST_INC_OFF, port);
		usleep(X9C10X_INC_DELAY);
		outb( (new_value>disp_bkl?BKL_UP:BKL_DOWN) | BKL_INC_OFF | CST_INC_OFF, port);		
	}
	usleep(X9C10X_CS_DELAY);
	outb(BKL_CS_OFF, port+2);
	disp_bkl=new_value;
}

Pictures

 
wiki/projects/linux/x9c10x.txt · Last modified: 2005/08/25 17:24 by e-razor
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki