mirror of
https://github.com/geekammo/MicroView-Arduino-Library.git
synced 2026-03-03 16:54:05 +01:00
* changed MICROVIEW class name to MicroView
* created MICROVIEWWIDGET class * added routines to draw widget * added slider widget * merged MicroViewWidget into MicroView * merged SPI.h into MicroView
This commit is contained in:
@@ -1,48 +1,45 @@
|
||||
#include <MicroView.h>
|
||||
#include <SPI.h>
|
||||
#include <Time.h>
|
||||
|
||||
#define PI 3.141592654
|
||||
//#define PI 3.141592654
|
||||
#define clocksize 24
|
||||
|
||||
MICROVIEW mv;
|
||||
|
||||
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.
|
||||
uint8_t onDelay=5; // This is the on delay in milliseconds, if there is no on delay, the erase will be too fast to clean up the screen.
|
||||
|
||||
void setup() {
|
||||
mv.begin(); // Begin of MicroView
|
||||
mv.clear(ALL); // Erase hardware memory inside the OLED controller
|
||||
mv.display(); // Display the content in the buffer memory, by default it is the MicroView logo
|
||||
uView.begin(); // Begin of MicroView
|
||||
uView.clear(ALL); // Erase hardware memory inside the OLED controller
|
||||
uView.display(); // Display the content in the buffer memory, by default it is the MicroView logo
|
||||
setTime(10,10,01,17,1,2014);
|
||||
delay(500);
|
||||
mv.clear(PAGE); // Erase the memory buffer, when next mv.display() is called, the OLED will be cleared.
|
||||
uView.clear(PAGE); // Erase the memory buffer, when next uView.display() is called, the OLED will be cleared.
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int i;
|
||||
static long counter=99999;
|
||||
static long mSec=millis()+1000;
|
||||
static double counter=99999;
|
||||
static unsigned long mSec=millis()+1000;
|
||||
static uint8_t x0,y0,x1,y1;
|
||||
static float degresshour,degressmin,degresssec,hourx,houry,minx,miny,secx,secy;
|
||||
static boolean drawnFirst=false;
|
||||
|
||||
mv.setFontType(0); // set font type 0, please see declaration in MicroView.cpp
|
||||
mv.setCursor(27,0); // points cursor to x=27 y=0
|
||||
mv.print(12);
|
||||
mv.setCursor(30,mv.getLCDHeight()-mv.getFontHeight());
|
||||
mv.print(6);
|
||||
mv.setCursor(0,mv.getLCDHeight() /2-(mv.getFontHeight()/2));
|
||||
mv.print(9);
|
||||
mv.setCursor(mv.getLCDWidth()-mv.getFontWidth(),mv.getLCDWidth()/2-(mv.getFontHeight()/2));
|
||||
mv.print(3);
|
||||
mv.display(); // display the memory buffer drawn
|
||||
uView.setFontType(0); // set font type 0, please see declaration in MicroView.cpp
|
||||
uView.setCursor(27,0); // points cursor to x=27 y=0
|
||||
uView.print(12);
|
||||
uView.setCursor(30,uView.getLCDHeight()-uView.getFontHeight());
|
||||
uView.print(6);
|
||||
uView.setCursor(0,uView.getLCDHeight() /2-(uView.getFontHeight()/2));
|
||||
uView.print(9);
|
||||
uView.setCursor(uView.getLCDWidth()-uView.getFontWidth(),uView.getLCDWidth()/2-(uView.getFontHeight()/2));
|
||||
uView.print(3);
|
||||
uView.display(); // display the memory buffer drawn
|
||||
|
||||
while ((second() % 10 )!=0) {
|
||||
if (mSec!=second()) {
|
||||
while ((second() % 11 )!=0) {
|
||||
if (mSec!=(unsigned long)second()) {
|
||||
if (drawnFirst) {
|
||||
mv.line(32,24,32+hourx,24+houry,WHITE,XOR);
|
||||
mv.line(32,24,32+minx,24+miny,WHITE,XOR);
|
||||
mv.line(32,24,32+secx,24+secy,WHITE,XOR);
|
||||
uView.line(32,24,32+hourx,24+houry,WHITE,XOR);
|
||||
uView.line(32,24,32+minx,24+miny,WHITE,XOR);
|
||||
uView.line(32,24,32+secx,24+secy,WHITE,XOR);
|
||||
}
|
||||
|
||||
degresshour = (((hour() * 360) / 12) + 270) * (PI / 180);
|
||||
@@ -59,103 +56,103 @@ void loop() {
|
||||
secy = sin(degresssec) * (clocksize / 1.1);
|
||||
|
||||
|
||||
mv.line(32,24,32+hourx,24+houry,WHITE,XOR);
|
||||
mv.line(32,24,32+minx,24+miny,WHITE,XOR);
|
||||
mv.line(32,24,32+secx,24+secy,WHITE,XOR);
|
||||
uView.line(32,24,32+hourx,24+houry,WHITE,XOR);
|
||||
uView.line(32,24,32+minx,24+miny,WHITE,XOR);
|
||||
uView.line(32,24,32+secx,24+secy,WHITE,XOR);
|
||||
drawnFirst=true;
|
||||
mv.display();
|
||||
uView.display();
|
||||
|
||||
mSec=second();
|
||||
}
|
||||
}
|
||||
drawnFirst=false;
|
||||
mv.clear(PAGE);
|
||||
uView.clear(PAGE);
|
||||
|
||||
int maxX=40;
|
||||
onDelay=30;
|
||||
mv.setFontType(0);
|
||||
mv.setCursor(0,40);
|
||||
mv.print(" SPRITE ");
|
||||
uView.setFontType(0);
|
||||
uView.setCursor(0,40);
|
||||
uView.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);
|
||||
uView.setFontType(4);
|
||||
uView.drawChar(x,0,48,WHITE, XOR);
|
||||
uView.setFontType(5);
|
||||
uView.drawChar(maxX-x,10,48,WHITE,XOR);
|
||||
|
||||
mv.setFontType(5);
|
||||
mv.drawChar(x,32,48,WHITE,XOR);
|
||||
uView.setFontType(6);
|
||||
uView.drawChar(x,32,48,WHITE,XOR);
|
||||
|
||||
mv.display();
|
||||
uView.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);
|
||||
uView.setFontType(4);
|
||||
uView.drawChar(x,0,48,WHITE, XOR);
|
||||
uView.setFontType(5);
|
||||
uView.drawChar(maxX-x,10,48,WHITE,XOR);
|
||||
uView.setFontType(6);
|
||||
uView.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);
|
||||
uView.display();
|
||||
uView.setFontType(4);
|
||||
uView.drawChar(x,0,49,WHITE, XOR);
|
||||
uView.setFontType(5);
|
||||
uView.drawChar(maxX-x,10,49,WHITE,XOR);
|
||||
uView.setFontType(6);
|
||||
uView.drawChar(x,32,49,WHITE,XOR);
|
||||
|
||||
mv.display();
|
||||
uView.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();
|
||||
uView.setFontType(4);
|
||||
uView.drawChar(x,0,49,WHITE, XOR);
|
||||
uView.setFontType(5);
|
||||
uView.drawChar(maxX-x,10,49,WHITE,XOR);
|
||||
uView.setFontType(6);
|
||||
uView.drawChar(x,32,49,WHITE,XOR);
|
||||
uView.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);
|
||||
uView.setFontType(4);
|
||||
uView.drawChar(x,10,48,WHITE, XOR);
|
||||
uView.setFontType(5);
|
||||
uView.drawChar(40-x,0,48,WHITE,XOR);
|
||||
uView.setFontType(6);
|
||||
uView.drawChar(x,32,48,WHITE,XOR);
|
||||
|
||||
mv.display();
|
||||
uView.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);
|
||||
uView.setFontType(4);
|
||||
uView.drawChar(x,10,48,WHITE, XOR);
|
||||
uView.setFontType(5);
|
||||
uView.drawChar(40-x,0,48,WHITE,XOR);
|
||||
uView.setFontType(6);
|
||||
uView.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);
|
||||
uView.display();
|
||||
uView.setFontType(4);
|
||||
uView.drawChar(x,10,49,WHITE, XOR);
|
||||
uView.setFontType(5);
|
||||
uView.drawChar(40-x,0,49,WHITE,XOR);
|
||||
uView.setFontType(6);
|
||||
uView.drawChar(x,32,49,WHITE,XOR);
|
||||
|
||||
mv.display();
|
||||
uView.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);
|
||||
uView.setFontType(4);
|
||||
uView.drawChar(x,10,49,WHITE, XOR);
|
||||
uView.setFontType(5);
|
||||
uView.drawChar(40-x,0,49,WHITE,XOR);
|
||||
uView.setFontType(6);
|
||||
uView.drawChar(x,32,49,WHITE,XOR);
|
||||
|
||||
mv.display();
|
||||
uView.display();
|
||||
}
|
||||
|
||||
|
||||
onDelay=5;
|
||||
mv.setFontType(0);
|
||||
mv.setCursor(0,40);
|
||||
mv.print(" LINE ");
|
||||
mv.display();
|
||||
uView.setFontType(0);
|
||||
uView.setCursor(0,40);
|
||||
uView.print(" LINE ");
|
||||
uView.display();
|
||||
delay(500);
|
||||
|
||||
for (i=0; i<150;i++) {
|
||||
@@ -164,84 +161,108 @@ void loop() {
|
||||
y0=random(48);
|
||||
y1=random(48);
|
||||
|
||||
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();
|
||||
uView.line(x0,y0,x1,y1, WHITE, XOR); // draw line from x0,y0 to x1,y1 using WHITE color and XOR draw mode
|
||||
uView.display();
|
||||
delay(onDelay);
|
||||
mv.line(x0,y0,x1,y1, WHITE,XOR);
|
||||
mv.display();
|
||||
uView.line(x0,y0,x1,y1, WHITE,XOR);
|
||||
uView.display();
|
||||
}
|
||||
|
||||
mv.setCursor(0,40);
|
||||
mv.print("RECTANGLE ");
|
||||
mv.display();
|
||||
uView.setCursor(0,40);
|
||||
uView.print("RECTANGLE ");
|
||||
uView.display();
|
||||
delay(500);
|
||||
|
||||
x0=0;y0=0;x1=0;y1=0;
|
||||
for (i=1; i<64;i++) {
|
||||
y1=i;
|
||||
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();
|
||||
uView.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
|
||||
uView.display();
|
||||
delay(onDelay);
|
||||
mv.rect(x0,y0,i,y1,WHITE,XOR);
|
||||
mv.display();
|
||||
uView.rect(x0,y0,i,y1,WHITE,XOR);
|
||||
uView.display();
|
||||
}
|
||||
|
||||
mv.setCursor(0,40);
|
||||
mv.print(" CIRCLE ");
|
||||
mv.display();
|
||||
uView.setCursor(0,40);
|
||||
uView.print(" CIRCLE ");
|
||||
uView.display();
|
||||
delay(500);
|
||||
|
||||
x0=32;y0=24;
|
||||
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();
|
||||
uView.circle(x0,y0,i,WHITE,XOR); // draw circle at x0,y0 with radius of i using WHITE color and XOR draw mode
|
||||
uView.display();
|
||||
delay(onDelay);
|
||||
mv.circle(x0,y0,i,WHITE,XOR);
|
||||
mv.display();
|
||||
uView.circle(x0,y0,i,WHITE,XOR);
|
||||
uView.display();
|
||||
delay(onDelay);
|
||||
|
||||
}
|
||||
delay(500);
|
||||
|
||||
mv.clear(PAGE);
|
||||
mv.setCursor(0,40);
|
||||
mv.print(" Font 0 ");
|
||||
mv.display();
|
||||
uView.clear(PAGE);
|
||||
uView.setCursor(0,40);
|
||||
uView.print(" Font 0 ");
|
||||
uView.display();
|
||||
|
||||
mv.setFontType(0);
|
||||
mv.setCursor(0,0);
|
||||
mv.print("01234567890ABCDabcd01234567890ABCDabcd");
|
||||
mv.display();
|
||||
uView.setFontType(0);
|
||||
uView.setCursor(0,0);
|
||||
uView.print("01234567890ABCDabcd01234567890ABCDabcd");
|
||||
uView.display();
|
||||
delay(1500);
|
||||
|
||||
mv.clear(PAGE);
|
||||
mv.setCursor(0,40);
|
||||
mv.print(" Font 1 ");
|
||||
mv.display();
|
||||
uView.clear(PAGE);
|
||||
uView.setCursor(0,40);
|
||||
uView.print(" Font 1 ");
|
||||
uView.display();
|
||||
|
||||
mv.setFontType(1);
|
||||
mv.setCursor(0,0);
|
||||
mv.print("0123ABCDabcd");
|
||||
mv.display();
|
||||
uView.setFontType(1);
|
||||
uView.setCursor(0,0);
|
||||
uView.print("0123ABCDabcd");
|
||||
uView.display();
|
||||
delay(1500);
|
||||
mv.clear(PAGE);
|
||||
uView.clear(PAGE);
|
||||
|
||||
counter=99999;
|
||||
while (counter>99970) {
|
||||
|
||||
if (millis()>=mSec) {
|
||||
|
||||
mv.setFontType(2);
|
||||
mv.setCursor(0,0);
|
||||
mv.print(counter);
|
||||
uView.setFontType(3);
|
||||
uView.setCursor(0,0);
|
||||
uView.print(counter);
|
||||
|
||||
counter--;
|
||||
mv.display();
|
||||
uView.display();
|
||||
mSec=millis()+100;
|
||||
}
|
||||
}
|
||||
mv.clear(PAGE);
|
||||
uView.clear(PAGE);
|
||||
|
||||
counter=19.99;
|
||||
while (counter<20.2) {
|
||||
|
||||
if (millis()>=mSec) {
|
||||
|
||||
uView.setFontType(2);
|
||||
uView.setCursor(0,0);
|
||||
uView.print(counter + ((int)(counter*100)%20));
|
||||
|
||||
uView.setCursor(0,uView.getFontHeight());
|
||||
uView.print(50-counter);
|
||||
|
||||
uView.setCursor(0,(uView.getFontHeight()*2));
|
||||
uView.print(75+counter+0.02);
|
||||
|
||||
counter+=0.01;
|
||||
uView.display();
|
||||
mSec=millis()+100;
|
||||
}
|
||||
}
|
||||
uView.clear(PAGE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user