Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/interrupt.h>
- #include <glcd.h>
- //----------------------------------------------------------------------
- // GLCD Function - Implementation
- //----------------------------------------------------------------------
- // to initialise the LCD
- void GlcdInit( void )
- {
- // This function must be provided by the user.
- GlcdInitPort();
- // send different controlcommand to the LCD (datasheet for details)
- // internal Reset
- GlcdSendCmd( 0xE2 );
- // ADC select
- GlcdSendCmd( 0xA0 ) ;
- // COM output scan direction = revers
- GlcdSendCmd( 0xC8 );
- // LCD drive voltage bias ratio
- GlcdSendCmd( 0xA2 );
- // no idea
- GlcdSendCmd( 0x2F );
- // no idea
- GlcdSendCmd( 0x26 );
- // select booster ratio
- GlcdSendCmd( 0xF8 );
- // no idea
- GlcdSendCmd( 0x00 );
- // set output voltage
- GlcdSendCmd( 0x81 );
- // no idea
- GlcdSendCmd( 0x09 );
- // read-modify-write
- GlcdSendCmd( 0xE0 );
- // display on
- GlcdSendCmd( 0xAF );
- return;
- }
- //--------------------
- // Set the position for the next output, for text e. g.
- // the y-value is round down to a 8like value (0,8,16,24...56)
- // parameter: x = x-coordinate 0...127; y = y-coordinate 0...63
- void GlcdSetPos( uint8_t x, uint8_t y )
- {
- // x-coordinate
- GlcdSendCmd( 0x10 | ( ( x >> 4 ) & 0x0F ) );
- GlcdSendCmd( 0x00 | ( ( x & 0x0F ) ) );
- // y-coordinate
- GlcdSendCmd( 0b10110000 | ( ( y >> 3 ) & 0x0F ) );
- return;
- }
- //--------------------
- // move to the inputline to the actual line on the LCD (srcolleffect)
- // parameter: Line = number of the line to goto
- void GlcdGotoLine( uint8_t line )
- {
- // initial display line
- GlcdSendCmd( 0x40 | ( line & 0x3F ) );
- return;
- }
- //--------------------
- // clears all data on the LCD
- void GlcdClear( void )
- {
- uint8_t y;
- uint8_t x;
- // the Display consists of 128 * 8 Bytes, which are placed vertical
- // in each byte are bit0 up and bit7 down
- // y-loop (vertical); 8 times, 64 pixels are 8 bytes * 8 bits
- for( y = 0; y < 8; y++ )
- {
- // goto linebegin
- GlcdSetPos( 0, y * 8 );
- // x-Schleife (waagerecht); 128 Pixel sind 128
- for( x = 0; x < 128; x++ )
- {
- // set byte to 0
- GlcdSendData( 0 );
- }
- }
- // set actual position to leftupper corner ( 0, 0 )
- GlcdSetPos( 0, 0 );
- return;
- }
- //--------------------
- // inverse display (dark at bright backround/ bright at dark backround)
- // parameter: on = off/on 0/1; 0 = normal (dark at blight backround); 1 = inverse (blight at dark backround)
- void GlcdSendCmdReverse( uint8_t bit0 )
- {
- // display normal/reverse
- GlcdSendCmd( 0b10100110 + ( bit0 & 0x01 ) );
- return;
- }
- //--------------------
- // turn the display on/off
- // parameter: on = on/off 0/1; 0 = display on; 1 = display off (complete dark)
- void GlcdSendCmdOn( uint8_t bit0 )
- {
- // all pixels on /off
- GlcdSendCmd( 0b10100100 + ( bit0 & 0x01 ) );
- return;
- }
- //--------------------
- // set a Pixel on position x,y at the LCD
- // parameter: x = x-coordinate 0...127; y = y-coordinate 0...63
- void GlcdSetPixel( uint8_t x, uint8_t y )
- {
- uint8_t data;
- // goto position
- GlcdSetPos( x, y );
- // bitmask for the bit (pixel) in the byte
- data = 1 << ( y & 0b00000111 );
- // read the byte, set the bit, write the byte
- GlcdSendData( GlcdReadData() | data );
- return;
- }
- //--------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement