Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: doggy.cpp
- Revision:
- 4:545e25d4c3d8
- Parent:
- 3:f5146bf55b5d
- Child:
- 5:1c78c0b4f513
--- a/doggy.cpp Wed Jan 05 22:35:52 2011 +0000 +++ b/doggy.cpp Sat Jan 08 16:27:12 2011 +0000 @@ -2,7 +2,7 @@ DogMLCD::DogMLCD( SPI& spi, PinName cs, PinName a0 ) : spi_(spi), cs_(cs), a0_(a0) { - b_ = (char*)calloc( 1024, 1 ); + //b_ = (char*)calloc( 1024, 1 ); XFont = xfont_8; const unsigned char c[] = { @@ -21,20 +21,27 @@ spi_.format( 8, 0 ); spi_.frequency( 1000000 ); cs_ = 0; - a0_ = 0; + a0_ = 0; wait_us( DOGMLCD_TIME ); for( int i = 0 ; i < sizeof( c ); i++ ) spi_.write( c[i] ); cs_ = 1; } -DogMLCD::~DogMLCD() + +void DogMLCD::AttachScreen( char* screen ) { - free( b_ ); + b_ = screen; +} + +void DogMLCD::DetachScreen() +{ + b_ = w_; } #define FASTPOKE( x, y ) b_[ ( ( y & 56 ) << 4 ) + ( x & 127 ) ] |= DOGMLCD_on[ y & 7 ]; #define FASTWIPE( x, y ) b_[ ( ( y & 56 ) << 4 ) + ( x & 127 ) ] &= DOGMLCD_off[ y & 7 ]; #define FASTINV( x, y ) b_[ ( ( y & 56 ) << 4 ) + ( x & 127 ) ] ^= DOGMLCD_on[ y & 7 ]; + void DogMLCD::Poke( int x, int y ) { if( ( x & 0xFF80 ) == 0 && ( y & 0xFFC0 ) == 0 ) @@ -62,17 +69,16 @@ char* p = b_; spi_.format( 8, 0 ); spi_.frequency( DOGMLCD_MHZ ); + cs_ = 0; for( int page = 0xB0 ; page < 0xB8 ; page++ ) { - cs_ = 0; - a0_ = 0; + a0_ = 0; wait_us( DOGMLCD_TIME ); spi_.write( page ); spi_.write( 0x10 ); spi_.write( 0x00 ); - a0_ = 1; + a0_ = 1; wait_us( DOGMLCD_TIME ); int i = 128; while( i-- ) spi_.write( *p++ ); - a0_ = 0; } cs_ = 1; } @@ -86,14 +92,13 @@ spi_.format( 8, 0 ); spi_.frequency( DOGMLCD_MHZ ); cs_ = 0; - a0_ = 0; + a0_ = 0; wait_us( DOGMLCD_TIME ); spi_.write( 0xB0 + page ); spi_.write( 0x10 ); spi_.write( 0x00 ); - a0_ = 1; + a0_ = 1; wait_us( DOGMLCD_TIME ); int i = x1 - x0 + 1; while( i-- ) spi_.write( *p++ ); - a0_ = 0; cs_ = 1; } void DogMLCD::Page( unsigned char page0, unsigned char page1 ) @@ -108,17 +113,29 @@ char* p = b_ + ( page0 << 7 ); spi_.format( 8, 0 ); spi_.frequency( DOGMLCD_MHZ ); + cs_ = 0; for( int page = 0xB0 + page0 ; page <= ( 0xB0 + page1 ) ; page++ ) { - cs_ = 0; - a0_ = 0; + a0_ = 0; wait_us( DOGMLCD_TIME ); spi_.write( page ); spi_.write( 0x10 ); spi_.write( 0x00 ); - a0_ = 1; + a0_ = 1; wait_us( DOGMLCD_TIME ); int i = 128; while( i-- ) spi_.write( *p++ ); - a0_ = 0; } cs_ = 1; } +void DogMLCD::Paste( char* screen, doggy_op op ) +{ + int i = 1024; + char* p = b_; + char* q = screen; + + if( op == poke ) while( i-- ) *p++ |= *q++; + else if( op == wipe ) while( i-- ) *p++ &= ~(*q++); + else while( i-- ) *p++ ^= *q++; +} + + +