In SX Microcontrollers, SX/B Compiler and SX-Key Tool, ALTITUDEAP wrote: sorry here is the code that i found /****************************************************************************** Driver routines for [b]MAX6953[/b] 5x7 cathode-row LED display drivers. Written for the CCS PCM cross-compiler version 3.185 Originally written by Stuart Hunter, Technical Director, ViziMatic Ltd. ******************************************************************************/ #ifndef DISPLAY_SDA //The pin definitions are set for a PIC16F819 SSP module. If they are //redefined elsewhere before this file is included then your own definitions //will override these. #define DISPLAY_SDA PIN_B1 #define DISPLAY_SCL PIN_B4 #endif //Miscellaneous defines #define SLOW 0 //Use for setting blink rate #define FAST 1 #define PLANE0 0x20 //Use for setting data start address #define PLANE1 0x40 #define BOTHPLANES 0x60 #define WRITE_NOW 1 //Used in operations affecting the CONFIG #define WRITE_LATER 0 //register. //Add FORCE_HW to the end of the line below if you want or need //to use a hardware I2C implementation (ie your PIC has the MSSP module). //Remove the line if you've already defined the I2C pins!!! #use i2c(master, sda=DISPLAY_SDA, scl=DISPLAY_SCL ) //,FORCE_HW int config_byte; int device_address; // Initialise the I2C bus and config register void init_display() { output_float(DISPLAY_SCL); output_float(DISPLAY_SDA); config_byte = 0; } void set_device_address( int addr ) { addr+= 0x50; //[b]MAX6953[/b] addresses take the form 101xxxx device_address = addr; //where xxxx is the user-selected address 0-15. } // This function is mainly for internal use, but you can use it to // set the CONFIG register directly if you don't want to use the // individual functions provided for this purpose. void write_config_register( int config_byte ) { i2c_start(); i2c_write( (device_address<<1) & 0xFE ); i2c_write( 0x04 ); i2c_write( config_byte ); i2c_stop(); } // This function sets the display interval for each display plane. // With a 4MHz clock, FAST is 0.5s and SLOW is 1.0s. void set_blink_speed( int speed, short wrt ) { if( speed == SLOW ) config_byte &= 0xFB; else config_byte |= 0x04; if( wrt ) write_config_register( config_byte ); } // This function enables or disables plane switching ( blinking ) void blink_enable( short state, short wrt ) { if( state ) config_byte |= 8; else config_byte &= 0xF7; if( wrt ) write_config_register( config_byte ); } // This function is used for blink time synchronisation across multiple devices. // call it once for each device, in sequence. Nonpersistent. void blink_sync( void ) { write_config_register( config_byte |= 0x10 ); } // Clear the plane data in the chip. Nonpersistent. void clear_digits( void ) { write_config_register( config_byte | 0x20 ); } // Put the display into low power shutdown mode void shutdown( short state, short wrt ) { if( !state ) config_byte |= 0x01; else config_byte &= 0xFE; if( wrt ) write_config_register( config_byte ); } // Put the display in test mode. Will illuminate all LEDs if state=TRUE. // Does not affect plane data - original display is restored when set FALSE. void display_test( short state ) { i2c_start(); i2c_write( (device_address<<1) & 0xFE ); i2c_write( 0x07 ); if (state ) { i2c_write( 1 ); } else { i2c_write( 0 ); } i2c_stop(); } // Set the display intensity from 0-15. This routine sets all digits to // the same value, if you want to set 'em individually then you need to // implement your own function - I don't need that ability! void set_intensity( int intens ) { int tempd; tempd = intens<<4; //set the most significant nybble intens |= tempd; i2c_start(); i2c_write( (device_address<<1) &0xFE ); i2c_write( 0x01 ); //first intensity register i2c_write( intens ); i2c_write( intens ); //register addr autoincrements, so write second reg. i2c_stop(); } // Sets the number of digits to be displayed ( 2 or 4 ). Included just for // the hell of it - I don't use this in my app. void set_scan_limit( short state ) { i2c_start(); i2c_write( (device_address<<1) &0xFE ); i2c_write( 0x03 ); if (state ) { i2c_write( 1 ); } else { i2c_write( 0 ); } i2c_stop(); } // Set the plane data for display. Normal characters should be written to // PLANE0. See the Maxim datasheet for an explanation of the data planing // system. void write_display_character( int start, int length, char* string ) { int n; i2c_start(); i2c_write( (device_address<<1) &0xFE ); i2c_write( start ); //start address of write operation for( n=0; n<length; n++ ) { i2c_write( string[n] ); //write noninverted string, address } //will autoincrement. i2c_stop(); } // As above, but displays an inverted ( background lit, char off ) character. void write_inverted_display_character( int start, int length, char* string ) { int n; i2c_start(); i2c_write( (device_address<<1) &0xFE ); i2c_write( start ); //start address of write operation for( n=0; n<length; n++ ) { i2c_write( string[n] |= 0x80 ); //write inverted string, address } //will autoincrement. i2c_stop(); } ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=101896#m101897 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)