1 Commits

Author SHA1 Message Date
JP
84a1f697fc added SPRITE demo. 2014-01-31 21:06:18 +11:00
6 changed files with 151 additions and 16 deletions

View File

@@ -2,13 +2,19 @@
#include <MicroView.h>
#include <SPI.h>
// Change to add fonts
// Add header of the fonts here
#include <font5x7.h>
#include <font8x16.h>
#include <fontlargenumber.h>
#define TOTALFONTS 3
const unsigned char *MICROVIEW::fontsPointer[]={font5x7,font8x16,fontlargenumber};
// Change to add fonts
#include <space01.h>
#include <space02.h>
#include <space03.h>
// 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};
/*

View File

@@ -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
------------------

View File

@@ -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; x<maxX;x+=2) {
mv.setFontType(3);
mv.drawChar(x,0,48,WHITE, XOR);
mv.setFontType(4);
mv.drawChar(maxX-x,10,48,WHITE,XOR);
mv.setFontType(5);
mv.drawChar(x,32,48,WHITE,XOR);
mv.display();
delay(onDelay);
mv.setFontType(3);
mv.drawChar(x,0,48,WHITE, XOR);
mv.setFontType(4);
mv.drawChar(maxX-x,10,48,WHITE,XOR);
mv.setFontType(5);
mv.drawChar(x,32,48,WHITE,XOR);
mv.display();
mv.setFontType(3);
mv.drawChar(x,0,49,WHITE, XOR);
mv.setFontType(4);
mv.drawChar(maxX-x,10,49,WHITE,XOR);
mv.setFontType(5);
mv.drawChar(x,32,49,WHITE,XOR);
mv.display();
delay(onDelay);
mv.setFontType(3);
mv.drawChar(x,0,49,WHITE, XOR);
mv.setFontType(4);
mv.drawChar(maxX-x,10,49,WHITE,XOR);
mv.setFontType(5);
mv.drawChar(x,32,49,WHITE,XOR);
mv.display();
}
for (int x=maxX; x>0;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 ");

16
space01.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef SPACE01_H
#define SPACE01_H
#include <avr/pgmspace.h>
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

16
space02.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef SPACE02_H
#define SPACE02_H
#include <avr/pgmspace.h>
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

14
space03.h Normal file
View File

@@ -0,0 +1,14 @@
#ifndef SPACE03_H
#define SPACE03_H
#include <avr/pgmspace.h>
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