bt96040.c

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 19.10.2004 by                                           *
00003  *   Matthias Kranz (matthias.kranz@ifi.lmu.de)                            *
00004  *   Paul Holleis (paul.holleis@ifi.lmu.de)                                *
00005  *                                                                         *
00006  *   particle header file for barton 96040 i2c display.                    *
00007  *   Last modified: 17.11.2004                                             *
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  *   This program is distributed in the hope that it will be useful,       *
00015  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00016  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00017  *   GNU General Public License for more details.                          *
00018  *                                                                         *
00019  *   You should have received a copy of the GNU General Public License     *
00020  *   along with this program; if not, write to the                         *
00021  *   Free Software Foundation, Inc.,                                       *
00022  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00023  **************************************************************************/
00024                 #use i2c(master, sda=PIN_DISPLAY_2_I2C_SDA, scl=PIN_DISPLAY_1_I2C_SCL)
00025 
00031 void bt_write_long4(int row, int col, long long_val)
00032 {
00033         char str_long[5];
00034         sprintf(str_long, "%04li", long_val);
00035         bt_write_string(row, col, str_long);
00036 }       
00037 
00045 void bt_write_long4_display(int display_no, int row, int col, long long_val)
00046 {
00047         char str_long[5];
00048         sprintf(str_long, "%04li", long_val);
00049         bt_write_string_display(display_no, row, col, str_long);
00050 }       
00051  
00058 void bt_write_string(int row, int col, char * str)
00059 {
00060         int strpos;
00061         strpos = 0;
00062         
00063         // change commented lines against for loop...
00064         for (; *str != '\0'; str++)
00065         //while (*str != '\0')
00066         {               
00067                 bt_write_char(row, (col + (strpos * BT_CHARACTER_PIXEL_WIDTH)), *str);
00068                 strpos++;
00069                 //str++;
00070         }       
00071 }
00072 
00080 void bt_write_string_display(int display_no, int row, int col, char * str)
00081 {
00082         int strpos;
00083         strpos = 0;
00084         
00085         // change commented lines against for loop...
00086         for (; *str != '\0'; str++)
00087         //while (*str != '\0')
00088         {               
00089                 bt_write_char_display(display_no, row, (col + (strpos * BT_CHARACTER_PIXEL_WIDTH)), *str);
00090                 strpos++;
00091                 //str++;
00092         }
00093 }
00094 
00103 void bt_write_hcilab_display(int display_no, int row, int col)
00104 {
00105         char hcilab[11] = "HCILAB.ORG";
00106         bt_write_string_display(display_no, row, col, hcilab);
00107         /*
00108         int cur_pos = 0;
00109         cur_pos = BT_CHARACTER_PIXEL_WIDTH * col;
00110         bt_write_char_display(display_no, row,cur_pos, 'H'); cur_pos=cur_pos+BT_CHARACTER_PIXEL_WIDTH;
00111         bt_write_char_display(display_no, row,cur_pos,'C'); cur_pos=cur_pos+BT_CHARACTER_PIXEL_WIDTH;
00112         bt_write_char_display(display_no, row,cur_pos,'I'); cur_pos=cur_pos+BT_CHARACTER_PIXEL_WIDTH;
00113         bt_write_char_display(display_no, row,cur_pos,'L'); cur_pos=cur_pos+BT_CHARACTER_PIXEL_WIDTH;
00114         bt_write_char_display(display_no, row,cur_pos,'A'); cur_pos=cur_pos+BT_CHARACTER_PIXEL_WIDTH;
00115         bt_write_char_display(display_no, row,cur_pos,'B'); cur_pos=cur_pos+BT_CHARACTER_PIXEL_WIDTH;
00116         bt_write_char_display(display_no, row,cur_pos,'.'); cur_pos=cur_pos+BT_CHARACTER_PIXEL_WIDTH;
00117         bt_write_char_display(display_no, row,cur_pos,'O'); cur_pos=cur_pos+BT_CHARACTER_PIXEL_WIDTH;
00118         bt_write_char_display(display_no, row,cur_pos,'R'); cur_pos=cur_pos+BT_CHARACTER_PIXEL_WIDTH;
00119         bt_write_char_display(display_no, row,cur_pos,'G');
00120         */
00121 }
00122 
00129 void bt_write_line_display(int display_no, int row, int ch)
00130 {
00131         int i;
00132         if (display_no == 0) {
00133                 #use i2c(master, sda=PIN_DISPLAY_1_I2C_SDA, scl=PIN_DISPLAY_1_I2C_SCL)
00134 
00135                 i2c_start();
00136                 i2c_write(0x7A);                        // send address 0x7A
00137                 i2c_write(0b01100000+row);
00138                 i2c_write(0b00000000);
00139                 for(i=0;i<100;i++){
00140                         i2c_write(ch);
00141                 }
00142                 i2c_stop();             // end transfer
00143         }
00144 
00145         if (display_no == 1) {
00146                 #use i2c(master, sda=PIN_DISPLAY_2_I2C_SDA, scl=PIN_DISPLAY_1_I2C_SCL)
00147                 
00148                 i2c_start();
00149                 i2c_write(0x7A);                        // send address 0x7A
00150                 i2c_write(0b01100000+row);
00151                 i2c_write(0b00000000);
00152                 for(i=0;i<100;i++){
00153                         i2c_write(ch);
00154                 }
00155                 i2c_stop();             // end transfer
00156         }
00157 
00158         if (display_no == 2) {
00159                 #use i2c(master, sda=PIN_B2, scl=PIN_DISPLAY_1_I2C_SCL)
00160                 
00161                 i2c_start();
00162                 i2c_write(0x7A);                        // send address 0x7A
00163                 i2c_write(0b01100000+row);
00164                 i2c_write(0b00000000);
00165                 for(i=0;i<100;i++){
00166                         i2c_write(ch);
00167                 }
00168                 i2c_stop();             // end transfer
00169         }
00170 
00171         if (display_no == 3) {
00172                 #use i2c(master, sda=PIN_B3, scl=PIN_DISPLAY_1_I2C_SCL)
00173                 
00174                 i2c_start();
00175                 i2c_write(0x7A);                        // send address 0x7A
00176                 i2c_write(0b01100000+row);
00177                 i2c_write(0b00000000);
00178                 for(i=0;i<100;i++){
00179                         i2c_write(ch);
00180                 }
00181                 i2c_stop();             // end transfer
00182         }
00183 
00184         if (display_no == 4) {
00185                 #use i2c(master, sda=PIN_B4, scl=PIN_DISPLAY_1_I2C_SCL)
00186                 
00187                 i2c_start();
00188                 i2c_write(0x7A);                        // send address 0x7A
00189                 i2c_write(0b01100000+row);
00190                 i2c_write(0b00000000);
00191                 for(i=0;i<100;i++){
00192                         i2c_write(ch);
00193                 }
00194                 i2c_stop();             // end transfer
00195         }
00196 
00197         if (display_no == 5) {
00198                 #use i2c(master, sda=PIN_B5, scl=PIN_DISPLAY_1_I2C_SCL)
00199                 
00200                 i2c_start();
00201                 i2c_write(0x7A);                        // send address 0x7A
00202                 i2c_write(0b01100000+row);
00203                 i2c_write(0b00000000);
00204                 for(i=0;i<100;i++){
00205                         i2c_write(ch);
00206                 }
00207                 i2c_stop();             // end transfer
00208         }
00209 
00210 }
00211 
00219 // extract ascii from tables & write to LCD
00220 void bt_write_char_display(int display_no, int row, int col, BYTE ch)   
00221 {
00222         int tab_index;
00223         BYTE bt_char_bit_set;
00224         //int ch_pix_set;
00225         int i;
00226                 
00227         if (ch<0x20)return;
00228         if (ch>0x7f)return;
00229 
00230         for (i=0;i<5;i++) {
00231                 if (ch<0x50){
00232                         tab_index=(((ch&0xff)-0x20)*5);
00233                         bt_char_bit_set=table1[(tab_index+i)];
00234                 } else if (ch>0x4f){
00235                         tab_index=(((ch&0xff)-0x50)*5);
00236                         tab_index=(((ch&0xff)-0x50)*5);
00237                         tab_index=(((ch&0xff)-0x50)*5);
00238                         bt_char_bit_set=table2[(tab_index+i)];
00239                 }
00240                 bt_write_pix_set_display(display_no, row, col+i, bt_char_bit_set,1);            
00241         }       
00242         bt_write_pix_set_display(display_no, row, col+5, 0x00,1);               
00243         
00244 }
00245 
00254 void bt_write_pix_set_display(int display_no, int row, int col, int ch, int count)
00255 {
00256         int i;
00257 
00258         if (display_no == 0) {
00259                 #use i2c(master, sda=PIN_DISPLAY_1_I2C_SDA, scl=PIN_DISPLAY_1_I2C_SCL)
00260                 
00261                 i2c_start();
00262                 i2c_write(0x7A);                        // send address 0x7A
00263                 i2c_write(0b01100000+row);
00264                 i2c_write(0b00000000+col);
00265                 for(i=0;i<count;i++){
00266                         i2c_write(ch);
00267                 }
00268                 i2c_stop();             // end transfer
00269         }
00270 
00271         if (display_no == 1) {
00272                 #use i2c(master, sda=PIN_DISPLAY_2_I2C_SDA, scl=PIN_DISPLAY_1_I2C_SCL)
00273                 
00274 
00275                 i2c_start();
00276                 i2c_write(0x7A);                        // send address 0x7A
00277                 i2c_write(0b01100000+row);
00278                 i2c_write(0b00000000+col);
00279                 for(i=0;i<count;i++){
00280                         i2c_write(ch);
00281                 }
00282                 i2c_stop();             // end transfer
00283         }
00284 
00285         if (display_no == 2) {
00286                 #use i2c(master, sda=PIN_DISPLAY_3_I2C_SDA, scl=PIN_DISPLAY_1_I2C_SCL)
00287                 //#use i2c(master, sda=PIN_B2, scl=PIN_DISPLAY_1_I2C_SCL)
00288                 
00289 
00290                 i2c_start();
00291                 i2c_write(0x7A);                        // send address 0x7A
00292                 i2c_write(0b01100000+row);
00293                 i2c_write(0b00000000+col);
00294                 for(i=0;i<count;i++){
00295                         i2c_write(ch);
00296                 }
00297                 i2c_stop();             // end transfer
00298         }
00299 
00300         if (display_no == 3) {
00301                 #use i2c(master, sda=PIN_DISPLAY_4_I2C_SDA, scl=PIN_DISPLAY_1_I2C_SCL)
00302                 //#use i2c(master, sda=PIN_B3, scl=PIN_DISPLAY_1_I2C_SCL)
00303                 
00304 
00305                 i2c_start();
00306                 i2c_write(0x7A);                        // send address 0x7A
00307                 i2c_write(0b01100000+row);
00308                 i2c_write(0b00000000+col);
00309                 for(i=0;i<count;i++){
00310                         i2c_write(ch);
00311                 }
00312                 i2c_stop();             // end transfer
00313         }
00314 
00315         if (display_no == 4) {
00316                 #use i2c(master, sda=PIN_DISPLAY_5_I2C_SDA, scl=PIN_DISPLAY_1_I2C_SCL)
00317                 //#use i2c(master, sda=PIN_B4, scl=PIN_DISPLAY_1_I2C_SCL)
00318                 
00319 
00320                 i2c_start();
00321                 i2c_write(0x7A);                        // send address 0x7A
00322                 i2c_write(0b01100000+row);
00323                 i2c_write(0b00000000+col);
00324                 for(i=0;i<count;i++){
00325                         i2c_write(ch);
00326                 }
00327                 i2c_stop();             // end transfer
00328         }
00329 
00330         if (display_no == 5) {
00331                 #use i2c(master, sda=PIN_DISPLAY_6_I2C_SDA, scl=PIN_DISPLAY_1_I2C_SCL)
00332                 //#use i2c(master, sda=PIN_B5, scl=PIN_DISPLAY_1_I2C_SCL)
00333                 
00334 
00335                 i2c_start();
00336                 i2c_write(0x7A);                        // send address 0x7A
00337                 i2c_write(0b01100000+row);
00338                 i2c_write(0b00000000+col);
00339                 for(i=0;i<count;i++){
00340                         i2c_write(ch);
00341                 }
00342                 i2c_stop();             // end transfer
00343         }
00344 
00345 
00346 }
00347 
00352 void bt_clear_display(int display_no)
00353 {
00354         bt_write_line_display(display_no, 0x00,0x00);
00355         bt_write_line_display(display_no, 0x01,0x00);
00356         bt_write_line_display(display_no, 0x02,0x00);
00357         bt_write_line_display(display_no, 0x03,0x00);
00358         bt_write_line_display(display_no, 0x04,0x00);
00359 }
00360 
00361 
00365 void bt_clear()//int display_no)
00366 {
00367         bt_write_line(0x00,0x00);
00368         bt_write_line(0x01,0x00);
00369         bt_write_line(0x02,0x00);
00370         bt_write_line(0x03,0x00);
00371         bt_write_line(0x04,0x00);
00372 }
00373 
00382 void bt_write_line(int row, int ch)
00383 {
00384         int i;
00385         i2c_start();
00386         // send address 0x7A
00387         i2c_write(0x7A);                        
00388         i2c_write(0b01100000+row);
00389         i2c_write(0b00000000);
00390         for(i=0;i<100;i++)
00391         {
00392                 i2c_write(ch);
00393         }
00394         // end transfer
00395         i2c_stop();             
00396 }
00397 
00405 void write_pix_set(int row, int col, int ch, int count)
00406 {
00407         int i;
00408         i2c_start();
00409         // send address 0x7A
00410         i2c_write(0x7A);                        
00411         i2c_write(0b01100000+row);
00412         i2c_write(0b00000000+col);
00413         for(i=0;i<count;i++)
00414         {
00415                 i2c_write(ch);
00416         }
00417         // end transfer
00418         i2c_stop();             
00419 }
00426 void bt_print_char_lcd(int row, int col, BYTE ch)
00427 {
00428         bt_write_char(row, col, ch);    
00429 }
00430 
00437 void bt_write_char(int row, int col, BYTE ch)   
00438 {
00439         int tab_index;
00440         BYTE bt_char_bit_set;
00441         //int ch_pix_set;
00442         int i;
00443                 
00444         if (ch<0x20)return;
00445         if (ch>0x7f)return;
00446 
00447         for (i=0;i<5;i++) 
00448         {
00449                 if (ch<0x50)
00450                 {
00451                         tab_index=(((ch&0xff)-0x20)*5);
00452                         bt_char_bit_set=table1[(tab_index+i)];
00453                 } 
00454                 else if (ch>0x4f)
00455                 {
00456                         tab_index=(((ch&0xff)-0x50)*5);
00457                         tab_index=(((ch&0xff)-0x50)*5);
00458                         tab_index=(((ch&0xff)-0x50)*5);
00459                         bt_char_bit_set=table2[(tab_index+i)];
00460                 }
00461                 write_pix_set(row, col+i, bt_char_bit_set,1);           
00462         }       
00463         write_pix_set(row, col+5, 0x00,1);                      
00464 }
00465 

Generated on Tue Nov 30 09:16:48 2004 for Smart-Its Headers by  doxygen 1.3.9.1