Revision history for OptrexDisplay


Revision [12190]

Last edited on 2011-07-15 23:07:32 by ToBo
Additions:
{{image url="images/optrex1.jpg"}}
Deletions:
{{image url="elektronik/optrex/optrex1.jpg"}}


Revision [12189]

Edited on 2011-07-15 23:06:50 by ToBo
Additions:
=====Optrex-Display=====
June, 10 th 2004
Software for optrex DMF50151AA LC-Display for Linux
Display type: DMF50151AA LC-Display with Toshiba T6369 Displaycontroller
{{image url="elektronik/optrex/optrex1.jpg"}}
How to use this software?
1. Connect your Optrex Display to LPT1 as shown in your Optrex manual.
2. Copy the optrex binary to /sbin/ (Note, you can use this program only as root)
3. Just use pipes to forward character streams of command-line-based programs to you display.
Example:
%%(bash)linux> echo Hello World! | optrex%%
An example to this picture above:
%%(bash)linux> df -h | awk '{print $1, $4}' | optrex%%
But use this program with care. You should know, what you're doing.
This is a dangerous piece of code using low-level access to the memory. No guaranty for anything!
Sourcecode for Linux gcc
%%(c)
/*********************************************************
* Optrex DMF50151AA LC-Display-Testprogram *
* for Toshiba T6369 Displaycontroller *
* Copyright (c) Andreas Tobola *
* http://www.root0.com *
* 10.06.2004 *
* Sourcecode for Linux gcc *
*********************************************************/
#include <asm/io.h>
#include <unistd.h>
#include <stdio.h>
#define GRAPH_RES_X 160
#define GRAPH_RES_Y 128
#define TEXT_RES_X 20
#define TEXT_RES_Y 16
#define FONT_WIDTH 8
#define BUF 4096
//8192
const int dport = 888;
//#define cDispType 'DMF50151AA'
/**
* Verzögerung
*/
void delay_sw() {
long i;
for(i=0; i<10; i++){
/*i++;
i--;*/
}
/*Nothing */;
}
/**
* Write data to display data register
*/
void WriteData(int d) {
delay_sw(); //Instead of WaitDispRdy;
outb(d,dport);
outb(0,dport+2); // C/D = L (Data)
outb(2,dport+2); // CE
outb(3,dport+2); // CE+WR
outb(2,dport+2); // CE
outb(0,dport+2);
}
/**
* Write data to display control register
*/
void WriteCtrl(int d) {
delay_sw(); //Instead of WaitDispRdy;
outb(d,dport);
outb(4,dport+2); // C/D = H (ctrl)
outb(4+2,dport+2); // CE
outb(4+3,dport+2); // CE+WR
outb(4+2,dport+2); // CE
outb(0,dport+2);
}
/**
* Display initialization
*/
void display_init() {
int i=0;
WriteData(0);
WriteData(0);
WriteCtrl(0x40); // Text Home @ 0000h
WriteData(TEXT_RES_X);
WriteData(0);
WriteCtrl(0x41); // Text Area
WriteData(0);
WriteData(2);
WriteCtrl(0x42); // Graph Home @ 0200h
WriteData(TEXT_RES_X);
WriteData(0);
WriteCtrl(0x43); // Gr Area
WriteCtrl(0x80); // OR Mode
WriteCtrl(0x9F);
WriteData(2);
WriteData(0);
WriteCtrl(0x22); // CG RAM Start ab Adresse 4096 = 1000h
}
/**
* Clear display screen
*/
void display_clear() {
int i;
// Clear text
WriteData(0);
WriteData(0);
WriteCtrl(0x24);
for (i=0; i<=((TEXT_RES_Y*TEXT_RES_X)-1); i++) {
WriteData(0);
WriteCtrl(0xC0);
}
// Clear graphic
WriteData(0);
WriteData(2);
WriteCtrl(0x24);
for (i=0; i<=((GRAPH_RES_Y*((GRAPH_RES_X+(FONT_WIDTH-1))/FONT_WIDTH))-1); i++) {
WriteData(0);
WriteCtrl(0xC0);
}
}
/**
* Set cursor position
*/
void setCursor(int line, int row) {
if (line>TEXT_RES_Y)
line = TEXT_RES_Y;
if (row>TEXT_RES_X)
row = TEXT_RES_X;
WriteData(line);
WriteData(row);
WriteCtrl(0x21);
}
/**
* Write string
*/
void writeString(char txt[]) {
int z;
int row;
char sameChar;
sameChar = '\0';
WriteData(0);
WriteData(0);
WriteCtrl(0x24);
row=0;
for (z=0; z<strlen(txt); z++) {
while (txt[z]==sameChar) {
z++;
}
sameChar = '\0';
//Write line feeds
if (txt[z]=='\n') {
while (row<TEXT_RES_X) {
row++;
WriteData(' '-32);
WriteCtrl(0xC0);
}
sameChar = '\n';
row--;
} else {
// Write other chars
WriteData(txt[z]-32);
WriteCtrl(0xC0);
if (txt[z]==' ')
sameChar=' ';
}
//printf("%i\n",txt[z]);
row++;
row=row % TEXT_RES_X;
}
}
/**
* Main method
*/
main(int argc, char* argv[]) {
char puffer[BUF];
char inhalt[BUF];
if (ioperm(dport,3,1) < 0) {
perror("Cannot access the parallel port\n");
exit(1);
}
display_init();
display_clear();
setCursor(0,0);
inhalt[0]='\0';
while(fgets(puffer,BUF,stdin) != NULL){
strcat(inhalt,puffer);
}
//writeString(argv[1]);
writeString(inhalt);
ioperm(dport,3,0);
exit(0);
}
%%
Deletions:
=====Titel=====


Revision [12187]

The oldest known version of this page was created on 2011-07-15 22:59:59 by ToBo
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki