From 84a1f697fc10c3a8828e45750893c9f7d0449890 Mon Sep 17 00:00:00 2001 From: JP Date: Fri, 31 Jan 2014 21:06:18 +1100 Subject: [PATCH] added SPRITE demo. --- MicroView.cpp | 14 ++-- README.md | 15 ++-- examples/MicroViewDemo/MicroViewDemo.ino | 92 ++++++++++++++++++++++-- space01.h | 16 +++++ space02.h | 16 +++++ space03.h | 14 ++++ 6 files changed, 151 insertions(+), 16 deletions(-) create mode 100644 space01.h create mode 100644 space02.h create mode 100644 space03.h diff --git a/MicroView.cpp b/MicroView.cpp index 77c63bc..8a7ea06 100644 --- a/MicroView.cpp +++ b/MicroView.cpp @@ -2,13 +2,19 @@ #include #include -// Change to add fonts +// Add header of the fonts here #include #include #include -#define TOTALFONTS 3 -const unsigned char *MICROVIEW::fontsPointer[]={font5x7,font8x16,fontlargenumber}; -// Change to add fonts +#include +#include +#include + +// Change the total fonts included +#define TOTALFONTS 6 + +// Add the font name as declared in the header file. +const unsigned char *MICROVIEW::fontsPointer[]={font5x7,font8x16,fontlargenumber, space01,space02,space03}; /* diff --git a/README.md b/README.md index 98fe34f..545b940 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ MicroView Arduino Library ================================ -Developed by [Geek Ammo Pty Ltd](http://www.geekammo.com) based on Arduino and other Open Source libraries. +Developed by [Geek Ammo Pty Ltd](http://www.geekammo.com) based on Arduino and other Open Source libraries. Author : JP Liew Description @@ -9,12 +9,15 @@ Arduino library for MicroView. History ------- -v1.01b: 30th January 2014 by JP Liew - - fixed font draw XOR mode bug. - - added analog clock demo. +**v1.02b: 31th January 2013 by JP Liew** + * added sprite animation demo. -v1.00b: 30th January 2014 by JP Liew - - Initial commit. Beta with minor bugs. +**v1.01b: 30th January 2014 by JP Liew** + * fixed font draw XOR mode bug. + * added analog clock demo. + +**v1.00b: 30th January 2014 by JP Liew** + * Initial commit. Beta with minor bugs. Required Libraries ------------------ diff --git a/examples/MicroViewDemo/MicroViewDemo.ino b/examples/MicroViewDemo/MicroViewDemo.ino index 9917474..b6c96b7 100644 --- a/examples/MicroViewDemo/MicroViewDemo.ino +++ b/examples/MicroViewDemo/MicroViewDemo.ino @@ -7,7 +7,7 @@ MICROVIEW mv; -uint8_t dly=5; // This is the erase delay in milliseconds, if there is no delay, the draw/erase will be too fast to be seen. +uint8_t onDelay=5; // This is the erase delay in milliseconds, if there is no delay, the draw/erase will be too fast to be seen. void setup() { mv.begin(); // Begin of MicroView @@ -71,6 +71,87 @@ void loop() { drawnFirst=false; mv.clear(PAGE); + int maxX=40; + onDelay=30; + mv.setFontType(0); + mv.setCursor(0,40); + mv.print(" SPRITE "); + for (int x=0; x0;x-=2) { + mv.setFontType(3); + mv.drawChar(x,10,48,WHITE, XOR); + mv.setFontType(4); + mv.drawChar(40-x,0,48,WHITE,XOR); + mv.setFontType(5); + mv.drawChar(x,32,48,WHITE,XOR); + + mv.display(); + delay(onDelay); + mv.setFontType(3); + mv.drawChar(x,10,48,WHITE, XOR); + mv.setFontType(4); + mv.drawChar(40-x,0,48,WHITE,XOR); + mv.setFontType(5); + mv.drawChar(x,32,48,WHITE,XOR); + + mv.display(); + mv.setFontType(3); + mv.drawChar(x,10,49,WHITE, XOR); + mv.setFontType(4); + mv.drawChar(40-x,0,49,WHITE,XOR); + mv.setFontType(5); + mv.drawChar(x,32,49,WHITE,XOR); + + mv.display(); + delay(onDelay); + mv.setFontType(3); + mv.drawChar(x,10,49,WHITE, XOR); + mv.setFontType(4); + mv.drawChar(40-x,0,49,WHITE,XOR); + mv.setFontType(5); + mv.drawChar(x,32,49,WHITE,XOR); + + mv.display(); + } + + + onDelay=5; mv.setFontType(0); mv.setCursor(0,40); mv.print(" LINE "); @@ -85,7 +166,7 @@ void loop() { mv.line(x0,y0,x1,y1, WHITE, XOR); // draw line from x0,y0 to x1,y1 using WHITE color and XOR draw mode mv.display(); - delay(dly); + delay(onDelay); mv.line(x0,y0,x1,y1, WHITE,XOR); mv.display(); } @@ -101,7 +182,7 @@ void loop() { if (y1>47) y1=47; mv.rect(x0,y0,i,y1,WHITE,XOR); // draw rectangle from x0,y0 with width of i and height of y1 using WHITE color and XOR draw mode mv.display(); - delay(dly); + delay(onDelay); mv.rect(x0,y0,i,y1,WHITE,XOR); mv.display(); } @@ -115,10 +196,10 @@ void loop() { for (i=0;i<32;i++) { mv.circle(x0,y0,i,WHITE,XOR); // draw circle at x0,y0 with radius of i using WHITE color and XOR draw mode mv.display(); - delay(dly); + delay(onDelay); mv.circle(x0,y0,i,WHITE,XOR); mv.display(); - delay(dly); + delay(onDelay); } delay(500); @@ -134,7 +215,6 @@ void loop() { mv.display(); delay(1500); - mv.clear(PAGE); mv.setCursor(0,40); mv.print(" Font 1 "); diff --git a/space01.h b/space01.h new file mode 100644 index 0000000..0f418e1 --- /dev/null +++ b/space01.h @@ -0,0 +1,16 @@ +#ifndef SPACE01_H +#define SPACE01_H + +#include + +static const unsigned char space01[] PROGMEM = { + // first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256) + 22,16,48,2,0,44, + 0xFC, 0xFC, 0xC0, 0xC0, 0xF3, 0xF3, 0x3C, 0x3C, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x3C, 0x3C, + 0xF3, 0xF3, 0xC0, 0xC0, 0xFC, 0xFC, 0x00, 0x00, 0xC0, 0xC0, 0xF3, 0xF3, 0x3C, 0x3C, 0xF0, 0xF0, + 0xF0, 0xF0, 0xF0, 0xF0, 0x3C, 0x3C, 0xF3, 0xF3, 0xC0, 0xC0, 0x00, 0x00, 0x03, 0x03, 0xCF, 0xCF, + 0x3F, 0x3F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x3F, 0x3F, 0xCF, 0xCF, + 0x03, 0x03, 0x3F, 0x3F, 0x03, 0x03, 0x3F, 0x3F, 0xCF, 0xCF, 0xCF, 0xCF, 0x0F, 0x0F, 0xCF, 0xCF, + 0xCF, 0xCF, 0x3F, 0x3F, 0x03, 0x03, 0x3F, 0x3F, +}; +#endif diff --git a/space02.h b/space02.h new file mode 100644 index 0000000..0d0da32 --- /dev/null +++ b/space02.h @@ -0,0 +1,16 @@ +#ifndef SPACE02_H +#define SPACE02_H + +#include + +static const unsigned char space02[] PROGMEM = { + // first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256) + 24,16,48,2,0,48, + 0xF0, 0xF0, 0xFC, 0xFC, 0xFC, 0xFC, 0x3C, 0x3C, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x3F, + 0x3C, 0x3C, 0xFC, 0xFC, 0xFC, 0xFC, 0xF0, 0xF0, 0xF0, 0xF0, 0xFC, 0xFC, 0xFC, 0xFC, 0x3C, 0x3C, + 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x3F, 0x3C, 0x3C, 0xFC, 0xFC, 0xFC, 0xFC, 0xF0, 0xF0, + 0xC3, 0xC3, 0xC3, 0xC3, 0x33, 0x33, 0x3F, 0x3F, 0x0F, 0x0F, 0x33, 0x33, 0x33, 0x33, 0x0F, 0x0F, + 0x3F, 0x3F, 0x33, 0x33, 0xC3, 0xC3, 0xC3, 0xC3, 0x03, 0x03, 0x33, 0x33, 0xFF, 0xFF, 0xCF, 0xCF, + 0x0F, 0x0F, 0x33, 0x33, 0x33, 0x33, 0x0F, 0x0F, 0xCF, 0xCF, 0xFF, 0xFF, 0x33, 0x33, 0x03, 0x03 +}; +#endif diff --git a/space03.h b/space03.h new file mode 100644 index 0000000..a5ee2c8 --- /dev/null +++ b/space03.h @@ -0,0 +1,14 @@ +#ifndef SPACE03_H +#define SPACE03_H + +#include + +static const unsigned char space03[] PROGMEM = { + // first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256) + 16,16,48,2,0,32, + 0xC0, 0xC0, 0xF0, 0xF0, 0x3C, 0x3C, 0xFF, 0xFF, 0xFF, 0xFF, 0x3C, 0x3C, 0xF0, 0xF0, 0xC0, 0xC0, + 0xC0, 0xC0, 0xF0, 0xF0, 0x3C, 0x3C, 0xFF, 0xFF, 0xFF, 0xFF, 0x3C, 0x3C, 0xF0, 0xF0, 0xC0, 0xC0, + 0xC3, 0xC3, 0x33, 0x33, 0xCF, 0xCF, 0x33, 0x33, 0x33, 0x33, 0xCF, 0xCF, 0x33, 0x33, 0xC3, 0xC3, + 0x33, 0x33, 0xCF, 0xCF, 0x03, 0x03, 0x0F, 0x0F, 0x0F, 0x0F, 0x03, 0x03, 0xCF, 0xCF, 0x33, 0x33 +}; +#endif