This Library for DOGS-102 Graphic LCD module. Based on Igor Skochinsky's "DOGLCDDemo" program.
Dependents: DOGS102_Example1 DOGS102_Example2
Fork of DOGLCDDemo by
Revision 1:2145a74df666, committed 2014-05-03
- Comitter:
- ban4jp
- Date:
- Sat May 03 16:04:16 2014 +0000
- Parent:
- 0:2a5dccfd318f
- Commit message:
- Change to library, and Support DOGS-102 Graphic LCD module.
Changed in this revision
diff -r 2a5dccfd318f -r 2145a74df666 LCD/DogLCD.cpp --- a/LCD/DogLCD.cpp Thu Jan 14 00:49:39 2010 +0000 +++ b/LCD/DogLCD.cpp Sat May 03 16:04:16 2014 +0000 @@ -6,8 +6,10 @@ void DogLCD::_send_commands(const unsigned char* buf, size_t size) { // for commands, A0 is low +#ifdef READJUST_SPI_FREQUENCY _spi.format(8,0); _spi.frequency(10000000); +#endif _cs = 0; _a0 = 0; while ( size-- > 0 ) @@ -18,8 +20,10 @@ void DogLCD::_send_data(const unsigned char* buf, size_t size) { // for data, A0 is high +#ifdef READJUST_SPI_FREQUENCY _spi.format(8,0); _spi.frequency(10000000); +#endif _cs = 0; _a0 = 1; while ( size-- > 0 ) @@ -36,8 +40,8 @@ CLAMP(y, 0, LCDPAGES-1); unsigned char cmd[3]; cmd[0] = 0xB0 | (y&0xF); - cmd[1] = 0x10 | (x&0xF); - cmd[2] = (x>>4)&0xF; + cmd[1] = (x&0xF); + cmd[2] = 0x10 | ((x>>4)&0xF); _send_commands(cmd, 3); } @@ -55,19 +59,27 @@ 0x00, 0x27, //Contrast set 0x81, - 0x16, + 0x09, 0xac, //No indicator 0x00, 0xaf, //Display on }; +#ifndef READJUST_SPI_FREQUENCY + _spi.format(8,0); + _spi.frequency(10000000); +#endif //printf("Reset=L\n"); _reset = 0; + _cs = 1; + wait_ms(1); +#ifdef ENABLE_DOGLCD_POWERCTL //printf("Power=H\n"); _power = 1; //wait_ms(1); +#endif //printf("Reset=H\n"); _reset = 1; - //wait(5); + wait_ms(5); //printf("Sending init commands\n"); _send_commands(init_seq, sizeof(init_seq)); }
diff -r 2a5dccfd318f -r 2145a74df666 LCD/DogLCD.h --- a/LCD/DogLCD.h Thu Jan 14 00:49:39 2010 +0000 +++ b/LCD/DogLCD.h Sat May 03 16:04:16 2014 +0000 @@ -8,10 +8,13 @@ * Should be compatible with other modules using ST7565 controller ***********/ -#define LCDWIDTH 128 +#define LCDWIDTH 102 #define LCDHEIGHT 64 #define LCDPAGES (LCDHEIGHT+7)/8 +//#define ENABLE_DOGLCD_POWERCTL +//#define READJUST_SPI_FREQUENCY + /* Each page is 8 lines, one byte per column @@ -39,17 +42,28 @@ class DogLCD: public AbstractLCD { SPI& _spi; +#ifdef ENABLE_DOGLCD_POWERCTL DigitalOut _cs, _a0, _reset, _power; +#else + DigitalOut _cs, _a0, _reset; +#endif int _updating; void _send_commands(const unsigned char* buf, size_t size); void _send_data(const unsigned char* buf, size_t size); void _set_xy(int x, int y); unsigned char _framebuffer[LCDWIDTH*LCDPAGES]; public: - DogLCD(SPI& spi, PinName power, PinName cs, PinName a0, PinName reset): +#ifdef ENABLE_DOGLCD_POWERCTL + DogLCD(SPI& spi, PinName cs, PinName a0, PinName reset, PinName power): _spi(spi), _cs(cs), _a0(a0), _reset(reset), _power(power), _updating(0) { } +#else + DogLCD(SPI& spi, PinName cs, PinName a0, PinName reset): + _spi(spi), _cs(cs), _a0(a0), _reset(reset), _updating(0) + { + } +#endif // initialize and turn on the display void init(); // send a 128x64 picture for the whole screen
diff -r 2a5dccfd318f -r 2145a74df666 TieFighter.h --- a/TieFighter.h Thu Jan 14 00:49:39 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,134 +0,0 @@ -#ifndef MBED_TIEFIGHTER_H -#define MBED_TIEFIGHTER_H - - - -int tie_fighter_vertices[48][3] = { - // Left wing - v0 - {0, 0, 17}, - {10, -15, 15}, - {-10, -15, 15}, - {-15, 0, 15}, - {-10, 15, 15}, - {-10, 15, 15}, - {10, 15, 15}, - {15, 0, 15}, - - // Left inner wing connector - v8 - {0, 0, 17}, - {4, -4, 15}, - {-4, -4, 15}, - {-4, 0, 15}, - {-4, 4, 15}, - {-4, 4, 15}, - {4, 4, 15}, - {4, 0, 15}, - - // Right wing - v16 - {0, 0, -17}, - {10, -15, -15}, - {-10, -15, -15}, - {-15, 0, -15}, - {-10, 15, -15}, - {-10, 15, -15}, - {10, 15, -15}, - {15, 0, -15}, - - // Right inner wing connector - v24 - {0, 0, -17}, - {4, -4, -15}, - {-4, -4, -15}, - {-4, 0, -15}, - {-4, 4, -15}, - {-4, 4, -15}, - {4, 4, -15}, - {4, 0, -15}, - - // Body - v32 - {8, 8, -8}, - {-8, 8, -8}, - {8, 8, 8}, - {-8, 8, 8}, - - {8, -8, -8}, - {-8, -8, -8}, - {8, -8, 8}, - {-8, -8, 8}, - - // Left wing <-> body connection - {-2, -2, 15}, - {-2, -2, 8}, - {2, 2, 15}, - {2, 2, 8}, - - // Right wing <-> body connection - {-2, -2, -15}, - {-2, -2, -8}, - {2, 2, -15}, - {2, 2, -8}, -}; - -#define TIE_FIGHTER_NUM_FACES 32 -int tie_fighter_faces[TIE_FIGHTER_NUM_FACES][3] = { - // Left wing - {0, 1, 2}, - {0, 2, 3}, - {0, 3, 4}, - {0, 4, 5}, - {0, 5, 6}, - {0, 6, 7}, - {0, 7, 1}, - - // Left inner wing connector -/* {8, 9, 10}, - {8, 10, 11}, - {8, 11, 12}, - {8, 12, 13}, - {8, 13, 14}, - {8, 14, 15}, - {8, 15, 9}, */ - - // Right wing - {16, 17, 18}, - {16, 18, 19}, - {16, 19, 20}, - {16, 20, 21}, - {16, 21, 22}, - {16, 22, 23}, - {16, 23, 17}, - - // Right inner wing connector -/* {24, 25, 26}, - {24, 26, 27}, - {24, 27, 28}, - {24, 28, 29}, - {24, 29, 30}, - {24, 30, 31}, - {24, 31, 25}, */ - - // Body - {32, 33, 33}, // Hack to just draw some straight lines so the body doesn't look too cluttered with triangles - {33, 35, 35}, - {35, 34, 34}, - {32, 34, 34}, - - {36, 37, 37}, - {37, 39, 39}, - {39, 38, 38}, - {36, 38, 38}, - - {36, 32, 32}, - {37, 33, 33}, - {39, 35, 35}, - {38, 34, 34}, - - // Left wing <-> body connection - {40, 41, 41}, - {42, 43, 43}, - - // Right wing <-> body connection - {44, 45, 45}, - {46, 47, 47}, -}; - -#endif
diff -r 2a5dccfd318f -r 2145a74df666 hellombed.h --- a/hellombed.h Thu Jan 14 00:49:39 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -unsigned char pic_hellombed [] = -{ -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x00, -0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0xC0, 0xC0, 0x00, 0x00, 0x00, -0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, -0x60, 0x60, 0x60, 0x60, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xE0, 0xE0, 0xC0, 0xC0, 0x60, 0x60, 0x60, 0xE0, 0xC0, 0x80, 0xC0, 0xC0, 0x60, 0x60, 0x60, -0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xC0, 0xC0, 0x60, 0x60, 0x60, 0x60, 0xC0, -0xC0, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0xC0, 0xC0, 0x00, 0x00, -0x00, 0x00, 0x80, 0xC0, 0xE0, 0x60, 0x60, 0x60, 0xC0, 0xC0, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xFF, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0x00, -0x00, 0x00, 0x00, 0x7E, 0xFF, 0xCC, 0x8C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x8F, 0x8F, 0x00, 0x00, -0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x7E, 0xFF, 0xC1, 0x80, -0x00, 0x00, 0x00, 0x00, 0x80, 0xC1, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, -0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xC1, 0x80, 0x00, 0x00, 0x00, 0x80, 0xC1, -0xFF, 0x7F, 0x00, 0x00, 0x7E, 0xFF, 0xCC, 0x8C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x8F, 0x8F, 0x00, -0x00, 0x7F, 0xFF, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC1, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, -0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, -0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, -0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -};
diff -r 2a5dccfd318f -r 2145a74df666 main.cpp --- a/main.cpp Thu Jan 14 00:49:39 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -#include "mbed.h" -#include "Graphics.h" -#include "Cuboid.h" -#include "TrimeshObject.h" -#include "TieFighter.h" -#include "DogLCD.h" -#include "hellombed.h" - -SPI spi(p5, NC, p7); -DogLCD dog(spi, p17, p18, p20, p19); // spi, power, cs, a0, reset -Graphics g(&dog); -TrimeshObject tf(tie_fighter_vertices, tie_fighter_faces, TIE_FIGHTER_NUM_FACES); -Cuboid cube; - -int main() -{ - dog.init(); - // draw "hello mbed" - dog.send_pic(pic_hellombed); - wait(5); - // draw rectangle around the screen - g.line(0, 0, dog.width()-1, 0, 0xFFFFFF); - wait(2); - g.line(dog.width()-1, 0, dog.width()-1, dog.height()-1, 0xFFFFFF); - wait(2); - g.line(dog.width()-1, dog.height()-1, 0, dog.height()-1, 0xFFFFFF); - wait(2); - g.line(0, dog.height()-1, 0, 0, 0xFFFFFF); - wait(5); - - dog.clear_screen(); - float rotx = 0, roty = 0, rotz = 0; - - Timer timer; - timer.start(); - int frameno = 0; - const int pollcount = 10; - // shift 1/4th of screen to the left - tf.position(-dog.width() / 4, 0, 0); - tf.colour(0xffffff); - // shift 1/4th of screen to the right - cube.position(+dog.width() / 4, 0, 0); - cube.colour(0xffffff); - while (1) - { - rotx += 0.1; - roty += 0.08; - rotz += 0.05; - - // set rotation angles - tf.rotate(rotx, roty, rotz); - cube.rotate(rotx, roty, rotz); - // lock update - dog.beginupdate(); - dog.clear_screen(); - // render TieFighter - tf.render(g); - // and the cube - cube.render(g); - // unlock update (and draw framebuffer) - dog.endupdate(); - if ( ++frameno == pollcount ) - { - // output fps to serial - int end = timer.read_ms(); - float fps = pollcount*1000.0/end; - printf("\r%d frames, %d ms, FPS: %f", pollcount, end, fps); - frameno = 0; - timer.reset(); - } - //dog.fill(40, 40, 52, 52, 0x000000); - } -}
diff -r 2a5dccfd318f -r 2145a74df666 mbed.bld --- a/mbed.bld Thu Jan 14 00:49:39 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0