mirror of
https://github.com/geekammo/MicroView-Arduino-Library.git
synced 2026-02-20 03:21:30 +01:00
Compare commits
90 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfc8b5cb68 | ||
|
|
a4a45b7e6d | ||
|
|
601881997d | ||
|
|
2a7b01cfbc | ||
|
|
b35e3f2e01 | ||
|
|
66405a0972 | ||
|
|
82f3863036 | ||
|
|
301bd6acf5 | ||
|
|
80a0c70c34 | ||
|
|
c75d14abff | ||
|
|
1aa32fb0c2 | ||
|
|
5e24583c31 | ||
|
|
b05451f4c6 | ||
|
|
0d8545d6f8 | ||
|
|
8ae691c4c2 | ||
|
|
12a9c5c2ac | ||
|
|
68f0c20fd5 | ||
|
|
38be4163c0 | ||
|
|
8957ed4f66 | ||
|
|
3bd6befa70 | ||
|
|
85f51dcdba | ||
|
|
26d95ecfb4 | ||
|
|
da7579a6e8 | ||
|
|
e9584301ab | ||
|
|
4b7b544fa4 | ||
|
|
810a0928cb | ||
|
|
13390ca758 | ||
|
|
df383d88f2 | ||
|
|
04ed26e2b8 | ||
|
|
23d05f13ee | ||
|
|
88116856d4 | ||
|
|
cc6a702712 | ||
|
|
c5cf9692ad | ||
|
|
63e3228d83 | ||
|
|
c86b454924 | ||
|
|
ad46711f11 | ||
|
|
34de240739 | ||
|
|
6333d7c561 | ||
|
|
a5ed62704a | ||
|
|
9573e7d6cc | ||
|
|
86784fe2a4 | ||
|
|
cf97ba6c23 | ||
|
|
dfe47be3c8 | ||
|
|
db155041ff | ||
|
|
ba0b779740 | ||
|
|
8eab806dec | ||
|
|
9873dc728a | ||
|
|
72fdeeb77b | ||
|
|
4a8583e2a6 | ||
|
|
b0e4a9600f | ||
|
|
9dba039aa5 | ||
|
|
e5e5ecb037 | ||
|
|
e203d3b7cd | ||
|
|
c07b86476a | ||
|
|
db2904c64e | ||
|
|
b91baf75f8 | ||
|
|
6208dcd106 | ||
|
|
1349942310 | ||
|
|
95626610e1 | ||
|
|
0b56edc962 | ||
|
|
4bbfea3cf2 | ||
|
|
0eeb47d20a | ||
|
|
fa93b3e21e | ||
|
|
78e7abeafa | ||
|
|
0d06e90e3d | ||
|
|
cc1d78384a | ||
|
|
77928f1b74 | ||
|
|
00a80911de | ||
|
|
b64d5e4417 | ||
|
|
87e118eb44 | ||
|
|
94fc7e6437 | ||
|
|
7c3ec25d70 | ||
|
|
dce58d7069 | ||
|
|
82d55a8201 | ||
|
|
d28428ce35 | ||
|
|
77faa7d583 | ||
|
|
eb9edb19d6 | ||
|
|
21fa22bec2 | ||
|
|
5afff4bff7 | ||
|
|
8d2802f6c1 | ||
|
|
c67593e321 | ||
|
|
f398624f85 | ||
|
|
9c5568418a | ||
|
|
a32fd2c499 | ||
|
|
499594d9de | ||
|
|
fa09bdd7aa | ||
|
|
b109908d28 | ||
|
|
b5462c5bcb | ||
|
|
7b66741f79 | ||
|
|
c1e8756c4e |
2528
MicroView.cpp
2528
MicroView.cpp
File diff suppressed because it is too large
Load Diff
122
MicroView.h
122
MicroView.h
@@ -24,13 +24,35 @@
|
||||
|
||||
#define swap(a, b) { uint8_t t = a; a = b; b = t; }
|
||||
|
||||
#define DC 8
|
||||
#define RESET 7
|
||||
#define OLEDPWR 4
|
||||
#define OLEDPWR 4 // 3.3V regulator enable
|
||||
|
||||
// SS, SCK, MOSI already defined by original pins_arduino.h
|
||||
//#define CS 10
|
||||
//#define SCK 13
|
||||
// Port and bit mappings for DC, RESET, SS
|
||||
// ** These are CPU dependent **
|
||||
#define DCPORT PORTB
|
||||
#define DCDDR DDRB
|
||||
#define DCBIT 0
|
||||
|
||||
#define RESETPORT PORTD
|
||||
#define RESETDDR DDRD
|
||||
#define RESETBIT 7
|
||||
|
||||
#define SSPORT PORTB
|
||||
#define SSDDR DDRB
|
||||
#define SSBIT 2
|
||||
|
||||
// Macros to quickly set DC, RESET, SS
|
||||
// A HIGH sets the signal to input mode with the internal pullup enabled
|
||||
#define DCHIGH ((DCPORT |= _BV(DCBIT)), (DCDDR &= ~_BV(DCBIT)))
|
||||
#define DCLOW ((DCPORT &= ~_BV(DCBIT)), (DCDDR |= _BV(DCBIT)))
|
||||
|
||||
#define RESETHIGH ((RESETPORT |= _BV(RESETBIT)), (RESETDDR &= ~_BV(RESETBIT)))
|
||||
#define RESETLOW ((RESETPORT &= ~_BV(RESETBIT)), (RESETDDR |= _BV(RESETBIT)))
|
||||
|
||||
#define SSHIGH ((SSPORT |= _BV(SSBIT)), (SSDDR &= ~_BV(SSBIT)))
|
||||
#define SSLOW ((SSPORT &= ~_BV(SSBIT)), (SSDDR |= _BV(SSBIT)))
|
||||
|
||||
// SCK, MOSI already defined by original pins_arduino.h
|
||||
//#define SCK 13
|
||||
//#define MOSI 11
|
||||
|
||||
#define BLACK 0
|
||||
@@ -38,6 +60,13 @@
|
||||
|
||||
#define LCDWIDTH 64
|
||||
#define LCDHEIGHT 48
|
||||
#define LCDPAGES (LCDHEIGHT / 8)
|
||||
#define LCDCOLUMNOFFSET 32 // Visible start column within SSD1306 controller memory
|
||||
|
||||
#define LCDTOTALWIDTH 128 // Full width of SSD1306 controller memory
|
||||
#define LCDTOTALHEIGHT 64 // Full height of SSD1306 controller memory
|
||||
#define LCDTOTALPAGES (LCDTOTALHEIGHT / 8)
|
||||
|
||||
#define FONTHEADERSIZE 6
|
||||
|
||||
#define NORM 0
|
||||
@@ -48,7 +77,12 @@
|
||||
|
||||
#define WIDGETSTYLE0 0
|
||||
#define WIDGETSTYLE1 1
|
||||
// Added for Vertical slider styles
|
||||
#define WIDGETSTYLE2 2
|
||||
#define WIDGETSTYLE3 3
|
||||
|
||||
// Flag to be added to widget style to indicate no numeric value display
|
||||
#define WIDGETNOVALUE 0x80
|
||||
|
||||
#define SETCONTRAST 0x81
|
||||
#define DISPLAYALLONRESUME 0xA4
|
||||
@@ -65,6 +99,10 @@
|
||||
#define SETMULTIPLEX 0xA8
|
||||
#define SETLOWCOLUMN 0x00
|
||||
#define SETHIGHCOLUMN 0x10
|
||||
#define SETPAGE 0xB0
|
||||
#define SETADDRESSMODE 0x20
|
||||
#define SETCOLUMNBOUNDS 0x21
|
||||
#define SETPAGEBOUNDS 0x22
|
||||
#define SETSTARTLINE 0x40
|
||||
#define MEMORYMODE 0x20
|
||||
#define COMSCANINC 0xC0
|
||||
@@ -79,7 +117,7 @@
|
||||
#define DEACTIVATESCROLL 0x2E
|
||||
#define SETVERTICALSCROLLAREA 0xA3
|
||||
#define RIGHTHORIZONTALSCROLL 0x26
|
||||
#define LEFT_HORIZONTALSCROLL 0x27
|
||||
#define LEFTHORIZONTALSCROLL 0x27
|
||||
#define VERTICALRIGHTHORIZONTALSCROLL 0x29
|
||||
#define VERTICALLEFTHORIZONTALSCROLL 0x2A
|
||||
|
||||
@@ -109,6 +147,7 @@ class MicroView : public Print{
|
||||
public:
|
||||
MicroView(void) {};
|
||||
void begin(void);
|
||||
void end(void);
|
||||
|
||||
//#if ARDUINO >= 100
|
||||
|
||||
@@ -120,6 +159,8 @@ public:
|
||||
|
||||
// RAW LCD functions
|
||||
void command(uint8_t c);
|
||||
void command(uint8_t c1, uint8_t c2);
|
||||
void command(uint8_t c1, uint8_t c2, uint8_t c3);
|
||||
void data(uint8_t c);
|
||||
void setColumnAddress(uint8_t add);
|
||||
void setPageAddress(uint8_t add);
|
||||
@@ -154,6 +195,7 @@ public:
|
||||
uint8_t getLCDHeight(void);
|
||||
void setColor(uint8_t color);
|
||||
void setDrawMode(uint8_t mode);
|
||||
uint8_t *getScreenBuffer(void);
|
||||
|
||||
// Font functions
|
||||
uint8_t getFontWidth(void);
|
||||
@@ -178,10 +220,6 @@ public:
|
||||
void doCmd(uint8_t index);
|
||||
|
||||
private:
|
||||
//uint8_t cs;
|
||||
//volatile uint8_t *mosiport, *sckport;
|
||||
volatile uint8_t *ssport, *dcport, *ssreg, *dcreg; // use volatile because these are fixed location port address
|
||||
uint8_t mosipinmask, sckpinmask, sspinmask, dcpinmask;
|
||||
uint8_t foreColor,drawMode,fontWidth, fontHeight, fontType, fontStartChar, fontTotalChar, cursorX, cursorY;
|
||||
uint16_t fontMapWidth;
|
||||
//unsigned char *fontsPointer[TOTALFONTS];
|
||||
@@ -197,24 +235,34 @@ public:
|
||||
uint8_t getY();
|
||||
void setX(uint8_t newx);
|
||||
void setY(uint8_t newy);
|
||||
|
||||
int16_t getMinValue();
|
||||
int16_t getMaxValue();
|
||||
int16_t getValue();
|
||||
void setMinValue(int16_t min);
|
||||
void setMaxValue(int16_t max);
|
||||
void setMinValue(int16_t max);
|
||||
void setValue(int16_t val);
|
||||
void setValue(int16_t val, boolean doDraw);
|
||||
uint8_t getValLen();
|
||||
uint8_t getMaxValLen();
|
||||
/** \brief Draw widget value overridden by child class. */
|
||||
virtual void draw(){};
|
||||
/** \brief Draw widget face overridden by child class. */
|
||||
virtual void draw(){};
|
||||
/** \brief Draw widget face overridden by child class. */
|
||||
virtual void drawFace(){};
|
||||
|
||||
private:
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
int16_t maxValue;
|
||||
void reDraw();
|
||||
void drawNumValue(int16_t value);
|
||||
virtual ~MicroViewWidget(){};
|
||||
protected:
|
||||
uint8_t posX;
|
||||
uint8_t posY;
|
||||
int16_t minValue;
|
||||
int16_t maxValue;
|
||||
int16_t value;
|
||||
uint8_t valLen;
|
||||
uint8_t maxValLen;
|
||||
private:
|
||||
/** \brief Draw or erase the widget pointer. Overridden by child class. */
|
||||
virtual void drawPointer(){};
|
||||
void setMaxValLen();
|
||||
};
|
||||
|
||||
class MicroViewSlider: public MicroViewWidget{
|
||||
@@ -224,8 +272,9 @@ public:
|
||||
void draw();
|
||||
void drawFace();
|
||||
private:
|
||||
uint8_t totalTicks, style;
|
||||
bool needFirstDraw;
|
||||
void drawPointer();
|
||||
uint8_t style, totalTicks;
|
||||
boolean noValDraw;
|
||||
int16_t prevValue;
|
||||
};
|
||||
|
||||
@@ -236,8 +285,9 @@ public:
|
||||
void draw();
|
||||
void drawFace();
|
||||
private:
|
||||
uint8_t radius, style;
|
||||
bool needFirstDraw;
|
||||
void drawPointer();
|
||||
uint8_t style, radius;
|
||||
boolean noValDraw;
|
||||
int16_t prevValue;
|
||||
};
|
||||
|
||||
@@ -261,8 +311,17 @@ private:
|
||||
|
||||
class MVSPIClass {
|
||||
public:
|
||||
/** \brief Wait for SPI serial transfer complete. */
|
||||
inline static void wait();
|
||||
|
||||
/** \brief Transfer data byte via SPI port. */
|
||||
inline static byte transfer(byte _data);
|
||||
inline static void transfer(byte _data);
|
||||
|
||||
/** \brief Set up to begin a SPI packet transmit */
|
||||
static void packetBegin();
|
||||
|
||||
/** \brief End a SPI packet transmit */
|
||||
static void packetEnd();
|
||||
|
||||
// SPI Configuration methods
|
||||
|
||||
@@ -279,11 +338,13 @@ public:
|
||||
|
||||
extern MVSPIClass MVSPI;
|
||||
|
||||
byte MVSPIClass::transfer(byte _data) {
|
||||
SPDR = _data;
|
||||
void MVSPIClass::wait() {
|
||||
while (!(SPSR & _BV(SPIF)))
|
||||
;
|
||||
return SPDR;
|
||||
}
|
||||
|
||||
void MVSPIClass::transfer(byte _data) {
|
||||
SPDR = _data;
|
||||
}
|
||||
|
||||
void MVSPIClass::attachInterrupt() {
|
||||
@@ -294,6 +355,9 @@ void MVSPIClass::detachInterrupt() {
|
||||
SPCR &= ~_BV(SPIE);
|
||||
}
|
||||
|
||||
|
||||
extern MicroView uView;
|
||||
|
||||
/** \brief Get the number of print characters for a 16 bit signed value. */
|
||||
uint8_t getInt16PrintLen(int16_t val);
|
||||
|
||||
#endif
|
||||
|
||||
56
README.md
56
README.md
@@ -83,6 +83,7 @@ void loop() {
|
||||
void setup() {
|
||||
uView.begin();
|
||||
uView.clear(PAGE);
|
||||
Serial.begin(115200); // user decide the baud rate
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -91,7 +92,58 @@ void loop() {
|
||||
</code></pre>
|
||||
|
||||
## History
|
||||
**v1.14b: 26th July 2014 by JP Liew
|
||||
**v1.23b: 29th March 2015 by Scott Allen**
|
||||
* added overloaded setValue() function to add a boolean argument doDraw which controls whether the display buffer is updated.
|
||||
|
||||
**v1.22b: 4th October 2014 by Scott Allen and Ben Lewis**
|
||||
* replaced circleFill() with a faster algorithm, better looking circle - Ben Lewis
|
||||
* replaced sprintf with dedicated code, reduced program size - Scott Allen
|
||||
* added getValLen method for widgets to return length of current value - Scott Allen
|
||||
* initialised widget with minimum value instead of 0 - Scott Allen
|
||||
* added getValLen and getMaxValLen keywords
|
||||
* modified MicroViewDemo example to use getValLen method - Scott Allen
|
||||
|
||||
**v1.21b: 22nd September 2014 by Esmit Pérez and Scott Allen**
|
||||
* re-factored code if/else with switch - Esmit Pérez
|
||||
* simplified draw() to remove redundant code - Esmit Pérez
|
||||
* added WIDGETNOVALUE to widgets - Scott
|
||||
* fixed compiler warning - Scott
|
||||
* improved gauge minor ticks - Scott
|
||||
* added destructor for MicroViewWidget base class - Scott
|
||||
|
||||
**v1.20b: 27th August 2014 by Scott Allen, Emil Ong**
|
||||
* added Flashing Heart Example - JP
|
||||
* added getScreenBuffer() for access to screen RAM - Scott
|
||||
* added keywords for existing functions - Scott
|
||||
* fixed circleFill() - Emil
|
||||
|
||||
**v1.19b: 19th August 2014 by Scott Allen**
|
||||
* added uView.scrollLeft() function
|
||||
* simplified Silder Widget drawFace() function
|
||||
* added full signed 16 bit ranges for widgets
|
||||
* improved drawing for minor and major ticks
|
||||
|
||||
**v1.18b: 5th August 2014 by Scott Allen**
|
||||
* fixed compiler warning in MicroViewSlider
|
||||
* changed vertical slider direction.
|
||||
|
||||
**v1.17b: 4th August 2014 by JP Liew**
|
||||
* added reDraw() for MicroViewWidget class
|
||||
* removed Serial.begin() from uView.begin() so that user can have control
|
||||
* added MicroViewWidgetRedraw example
|
||||
|
||||
**v1.16b: 3rd August 2014 by czetie**
|
||||
* added vertical slider widget
|
||||
|
||||
**v1.15b: 3rd August 2014 by Scott Allen**
|
||||
* improved lots of low level routines, Fast SPI
|
||||
* fixed some compilation warnings
|
||||
* reduced overdriving display inputs
|
||||
* added uView.end() to power off the display
|
||||
* improved speed of display() and clear() functions
|
||||
* fixed positionning of "3" on clock face
|
||||
|
||||
**v1.14b: 26th July 2014 by JP Liew**
|
||||
* added Learning Kit Circuit Sketch
|
||||
|
||||
**v1.13b: 13th June 2014 by JP Liew**
|
||||
@@ -132,7 +184,7 @@ void loop() {
|
||||
|
||||
**v1.05b: 6th February 2014 by JP Liew**
|
||||
* changed MICROVIEW class name to MicroView
|
||||
* created MICROVIEWWIDGET class
|
||||
* created MicroViewWidget class
|
||||
* added routines to draw widget
|
||||
* added slider widget
|
||||
* merged MicroViewWidget into MicroView
|
||||
|
||||
@@ -373,7 +373,7 @@ void loop() {
|
||||
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.setCursor(uView.getLCDWidth()-uView.getFontWidth(),uView.getLCDHeight()/2-(uView.getFontHeight()/2));
|
||||
uView.print(3);
|
||||
uView.display(); // display the memory buffer drawn
|
||||
|
||||
@@ -618,4 +618,4 @@ void loop() {
|
||||
uView.clear(PAGE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
101
examples/MicroViewFlashingHeart/MicroViewFlashingHeart.ino
Normal file
101
examples/MicroViewFlashingHeart/MicroViewFlashingHeart.ino
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
MicroView Arduino Flashing Heart Demo
|
||||
Copyright (C) 2014 GeekAmmo
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <MicroView.h>
|
||||
|
||||
const unsigned char logo [] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
||||
0xFF, 0xFF, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xFF, 0xFF,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0x00, 0x00,
|
||||
0x00, 0x00, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
|
||||
const unsigned char logo2 [] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
||||
0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8,
|
||||
0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F,
|
||||
0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
|
||||
void setup() {
|
||||
uView.begin();
|
||||
uView.clear(PAGE);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
unsigned char i,j;
|
||||
for (i=0; i<6; i++) {
|
||||
uView.setPageAddress(i);
|
||||
uView.setColumnAddress(0);
|
||||
for (j=0;j<0x40;j++) {
|
||||
uView.data(logo[i*0x40+j]);
|
||||
}
|
||||
}
|
||||
|
||||
delay(800);
|
||||
|
||||
for (i=0; i<6; i++) {
|
||||
uView.setPageAddress(i);
|
||||
uView.setColumnAddress(0);
|
||||
for (j=0;j<0x40;j++) {
|
||||
uView.data(logo2[i*0x40+j]);
|
||||
}
|
||||
}
|
||||
delay(150);
|
||||
}
|
||||
43
examples/MicroViewVSlider/MicroViewVSlider.ino
Normal file
43
examples/MicroViewVSlider/MicroViewVSlider.ino
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
MicroView Arduino Library
|
||||
Copyright (C) 2014 GeekAmmo
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <MicroView.h>
|
||||
|
||||
MicroViewWidget *vWidget1, *vWidget2;
|
||||
|
||||
void setup() {
|
||||
uView.begin();
|
||||
uView.clear(PAGE);
|
||||
|
||||
vWidget1 = new MicroViewSlider(0, 0, 0, 255, WIDGETSTYLE2);
|
||||
vWidget2 = new MicroViewSlider(31, 0, 0, 255, WIDGETSTYLE3);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for (int i=0;i<=255;i++) {
|
||||
vWidget1->setValue(i);
|
||||
vWidget2->setValue(255-i);
|
||||
uView.display();
|
||||
}
|
||||
|
||||
for(int i=255; i>=0;i--) {
|
||||
vWidget1->setValue(i);
|
||||
vWidget2->setValue(255-i);
|
||||
uView.display();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
MicroView Arduino Library
|
||||
Copyright (C) 2015 GeekAmmo
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
An example of using the optional second argument of the widget
|
||||
setVal() function to update a widget without drawing the changes
|
||||
to the screen buffer.
|
||||
|
||||
This, along with the widget reDraw() function, allows widgets to be
|
||||
maintained in the "background" while other things are being displayed.
|
||||
|
||||
In this example,
|
||||
a guage and a slider are both continually updated with the same
|
||||
incrementing value. The widgets are alternately switched between the
|
||||
"background" and being displayed, at random intervals.
|
||||
*/
|
||||
|
||||
#include <MicroView.h>
|
||||
|
||||
const int highVal = 100; // high value for widget range
|
||||
|
||||
int wValue = 0; // value for widgets
|
||||
|
||||
MicroViewWidget *guage1, *slider1;
|
||||
boolean guage1On, slider1On; // true if widget is being displayed
|
||||
|
||||
void setup() {
|
||||
uView.begin();
|
||||
|
||||
guage1 = new MicroViewGauge(32, 20, 0, highVal);
|
||||
guage1On = false; // begin with guage1 off screen
|
||||
uView.clear(PAGE);
|
||||
|
||||
slider1 = new MicroViewSlider(8, 16, 0, highVal);
|
||||
slider1On = true; // begin with slider1 on screen
|
||||
|
||||
// Init the random number generator using an
|
||||
// unconnected analog pin.
|
||||
randomSeed(analogRead(A0));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Display a widget for a random number of value increments
|
||||
for (int c = random(5, 16); c > 0; c--) {
|
||||
uView.display();
|
||||
delay(500);
|
||||
|
||||
wValue++;
|
||||
if (wValue > highVal) {
|
||||
wValue = 0;
|
||||
}
|
||||
|
||||
// If the second setValue() argument is false, then
|
||||
// the display buffer is not updated.
|
||||
//
|
||||
// In a practical application, the widgets would be set with
|
||||
// the values that are being monitored.
|
||||
guage1->setValue(wValue, guage1On);
|
||||
slider1->setValue(wValue, slider1On);
|
||||
}
|
||||
|
||||
// Switch which widget is being displayed
|
||||
uView.clear(PAGE);
|
||||
|
||||
guage1On = !guage1On;
|
||||
slider1On = !slider1On;
|
||||
|
||||
if (guage1On) {
|
||||
guage1->reDraw();
|
||||
}
|
||||
|
||||
if (slider1On) {
|
||||
slider1->reDraw();
|
||||
}
|
||||
}
|
||||
354
examples/MicroViewWidgetDemo/MicroViewWidgetDemo.ino
Normal file
354
examples/MicroViewWidgetDemo/MicroViewWidgetDemo.ino
Normal file
@@ -0,0 +1,354 @@
|
||||
/*
|
||||
MicroView Arduino Library
|
||||
Copyright (C) 2014 GeekAmmo
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <MicroView.h>
|
||||
|
||||
// The Arduino build process doesn't create a prototype for the spin function,
|
||||
// (probably because it has a function pointer as a parameter)
|
||||
// so it's added here.
|
||||
void spin(int16_t lowVal, int16_t highVal, int16_t stepSize,
|
||||
unsigned long stepDelay, void (*drawFunction)(int16_t val));
|
||||
|
||||
MicroViewWidget *widget1, *widget2;
|
||||
|
||||
int16_t prevVal; // previous widget value
|
||||
|
||||
void setup() {
|
||||
uView.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
/* ==================== Demo 1 ====================
|
||||
Horizontal slider style 0, with and without numeric value.
|
||||
Range 0 to 100.
|
||||
================================================ */
|
||||
demoNumber(1);
|
||||
|
||||
widget1 = new MicroViewSlider(4, 16, 0, 100);
|
||||
widget2 = new MicroViewSlider(4, 32, 0, 100, WIDGETSTYLE0 + WIDGETNOVALUE);
|
||||
|
||||
spin(0, 100, 5, 100, update2widgets);
|
||||
|
||||
delete widget1;
|
||||
delete widget2;
|
||||
|
||||
/* ==================== Demo 2 ====================
|
||||
Horizontal slider style 1, with and without numeric value.
|
||||
Range 100 to 200.
|
||||
================================================ */
|
||||
demoNumber(2);
|
||||
|
||||
widget1 = new MicroViewSlider(0, 10, 100, 200, WIDGETSTYLE1);
|
||||
widget2 = new MicroViewSlider(0, 32, 100, 200, WIDGETSTYLE1 + WIDGETNOVALUE);
|
||||
|
||||
spin(100, 200, 5, 100, update2widgets);
|
||||
|
||||
delete widget1;
|
||||
delete widget2;
|
||||
|
||||
/* ==================== Demo 3 ====================
|
||||
Vertical slider style 2, with and without numeric value.
|
||||
Range 0 to 5000.
|
||||
================================================ */
|
||||
demoNumber(3);
|
||||
|
||||
widget1 = new MicroViewSlider(10, 12, 0, 5000, WIDGETSTYLE2);
|
||||
widget2 = new MicroViewSlider(48, 12, 0, 5000, WIDGETSTYLE2 + WIDGETNOVALUE);
|
||||
|
||||
spin(0, 5000, 250, 100, update2widgets);
|
||||
|
||||
delete widget1;
|
||||
delete widget2;
|
||||
|
||||
/* ==================== Demo 4 ====================
|
||||
Vertical slider style 3, with and without numeric value.
|
||||
Range -20 to 20.
|
||||
================================================ */
|
||||
demoNumber(4);
|
||||
|
||||
widget1 = new MicroViewSlider(16, 4, -20, 20, WIDGETSTYLE3);
|
||||
widget2 = new MicroViewSlider(54, 4, -20, 20, WIDGETSTYLE3 + WIDGETNOVALUE);
|
||||
|
||||
spin(-20, 20, 2, 100, update2widgets);
|
||||
|
||||
delete widget1;
|
||||
delete widget2;
|
||||
|
||||
/* ==================== Demo 5 ====================
|
||||
Gauge style 0, with and without numeric value.
|
||||
Range 0 to 200.
|
||||
================================================ */
|
||||
demoNumber(5);
|
||||
|
||||
widget1 = new MicroViewGauge(15, 24, 0, 200, WIDGETSTYLE0);
|
||||
widget2 = new MicroViewGauge(48, 24, 0, 200, WIDGETSTYLE0 + WIDGETNOVALUE);
|
||||
|
||||
spin(0, 200, 10, 100, update2widgets);
|
||||
|
||||
delete widget1;
|
||||
delete widget2;
|
||||
|
||||
/* ==================== Demo 6 ====================
|
||||
Gauge style 1, with numeric value.
|
||||
Range -10 to 150.
|
||||
================================================ */
|
||||
demoNumber(6);
|
||||
|
||||
widget1 = new MicroViewGauge(32, 24, -10, 150, WIDGETSTYLE1);
|
||||
|
||||
spin(-10, 150, 8, 100, update1widget);
|
||||
|
||||
delete widget1;
|
||||
|
||||
/* ==================== Demo 7 ====================
|
||||
Gauge style 1, with no numeric value.
|
||||
Range 0 to 240.
|
||||
================================================ */
|
||||
demoNumber(7);
|
||||
|
||||
widget1 = new MicroViewGauge(32, 24, 0, 240, WIDGETSTYLE1 + WIDGETNOVALUE);
|
||||
|
||||
spin(0, 240, 4, 33, update1widget);
|
||||
|
||||
delete widget1;
|
||||
|
||||
/* ==================== Demo 8 ====================
|
||||
Slider style 0, with no numeric value.
|
||||
Value manually displayed in hexadecimal.
|
||||
Range 0 to 0xff.
|
||||
================================================ */
|
||||
demoNumber(8);
|
||||
|
||||
widget1 = new MicroViewSlider(4, 16, 0, 0xff, WIDGETSTYLE0 + WIDGETNOVALUE);
|
||||
|
||||
spin(0, 0xff, 5, 39, customSlider0);
|
||||
|
||||
delete widget1;
|
||||
|
||||
/* ==================== Demo 9 ====================
|
||||
Slider style 1, with no numeric value.
|
||||
Value manually displayed, centred above the slider.
|
||||
Range -30000 to 30000.
|
||||
================================================ */
|
||||
demoNumber(9);
|
||||
|
||||
widget1 = new MicroViewSlider(2, 24, -30000, 30000, WIDGETSTYLE1 + WIDGETNOVALUE);
|
||||
|
||||
spin(-30000, 30000, 1500, 50, customSlider1);
|
||||
|
||||
delete widget1;
|
||||
|
||||
/* ==================== Demo 10 ====================
|
||||
Slider style 2, with no numeric value.
|
||||
Value manually displayed.
|
||||
Pointer moves from low at the top to high at the bottom.
|
||||
Range 0 to 600.
|
||||
Note: The widget getValue() method will return a wrong
|
||||
value. It is changed to reverse the pointer direction.
|
||||
================================================ */
|
||||
demoNumber(10);
|
||||
|
||||
widget1 = new MicroViewSlider(20, 10, 0, 600, WIDGETSTYLE2 + WIDGETNOVALUE);
|
||||
|
||||
spin(0, 600, 30, 100, customSlider2);
|
||||
|
||||
delete widget1;
|
||||
|
||||
/* ==================== Demo 11 ====================
|
||||
Slider style 3, with no numeric value.
|
||||
Value manually displayed, beside the pointer.
|
||||
Range 0 to 11.
|
||||
"These go to eleven!" - Nigel Tufnel of Spinal Tap.
|
||||
================================================ */
|
||||
demoNumber(11);
|
||||
|
||||
widget1 = new MicroViewSlider(24, 2, 0, 11, WIDGETSTYLE3 + WIDGETNOVALUE);
|
||||
prevVal = widget1->getValue();
|
||||
|
||||
spin(0, 11, 1, 250, customSlider3);
|
||||
|
||||
delete widget1;
|
||||
|
||||
/* ==================== Demo 12 ====================
|
||||
Gauge style 0, with no numeric value.
|
||||
Value manually displayed beneath, with a decimal point,
|
||||
in a larger font.
|
||||
"km/h" added to the bottom of the gauge.
|
||||
For simplicity, the range and values are actually
|
||||
10 times what is to be displayed, so they can be set,
|
||||
stored and manipulated as integers.
|
||||
Range 0.0 to 20.0 (actually 0 to 200).
|
||||
================================================ */
|
||||
demoNumber(12);
|
||||
|
||||
widget1 = new MicroViewGauge(35, 17, 0, 200, WIDGETSTYLE0 + WIDGETNOVALUE);
|
||||
|
||||
// draw the fixed "km/h" text
|
||||
uView.setCursor(widget1->getX() - 11, widget1->getY() + 11);
|
||||
uView.print("km/h");
|
||||
|
||||
spin(0, 200, 1, 40, customGauge0);
|
||||
|
||||
delete widget1;
|
||||
|
||||
/* ==================== Demo 13 ====================
|
||||
Gauge style 1, with no numeric value.
|
||||
Value manually displayed as a letter.
|
||||
Range 1 to 26 (A to Z).
|
||||
================================================ */
|
||||
demoNumber(13);
|
||||
|
||||
widget1 = new MicroViewGauge(36, 24, 1, 26, WIDGETSTYLE1 + WIDGETNOVALUE);
|
||||
|
||||
spin( 1, 26, 1, 200, customGauge1);
|
||||
|
||||
delete widget1;
|
||||
|
||||
/* ================== end of loop() ================== */
|
||||
}
|
||||
|
||||
// Function to update widget1
|
||||
void update1widget(int16_t val) {
|
||||
widget1->setValue(val);
|
||||
}
|
||||
|
||||
// Function to update widget1 and widget2
|
||||
void update2widgets(int16_t val) {
|
||||
widget1->setValue(val);
|
||||
widget2->setValue(val);
|
||||
}
|
||||
|
||||
// Update function for Demo 8
|
||||
void customSlider0(int16_t val) {
|
||||
widget1->setValue(val);
|
||||
uView.setCursor(widget1->getX() + 34, widget1->getY() + 1);
|
||||
uView.print("0x");
|
||||
if (val < 0x10) { // add leading 0 if necessary. Only 2 digits supported.
|
||||
uView.print('0');
|
||||
}
|
||||
uView.print(val, HEX);
|
||||
}
|
||||
|
||||
// Update function for Demo 9
|
||||
void customSlider1(int16_t val) {
|
||||
widget1->setValue(val);
|
||||
uint8_t offsetY = widget1->getY() - 10;
|
||||
uint8_t offsetX = widget1->getX() + 14;
|
||||
uView.setCursor(offsetX, offsetY);
|
||||
uView.print(" "); // erase the previous value in case it's longer
|
||||
// calculate the offset to centre the value
|
||||
offsetX += ((widget1->getMaxValLen() - widget1->getValLen()) * 3);
|
||||
uView.setCursor(offsetX, offsetY);
|
||||
uView.print(val);
|
||||
}
|
||||
|
||||
// Update function for Demo 10
|
||||
void customSlider2(int16_t val) {
|
||||
uView.setCursor(widget1->getX() + 1, widget1->getY() + 24);
|
||||
widget1->drawNumValue(val);
|
||||
// calculate to reverse the pointer direction
|
||||
widget1->setValue((int16_t) ((int32_t) widget1->getMaxValue() +
|
||||
(int32_t) widget1->getMinValue() -
|
||||
(int32_t) val));
|
||||
}
|
||||
|
||||
// Update function for Demo 11
|
||||
void customSlider3(int16_t val) {
|
||||
int16_t maxVal = widget1->getMaxValue();
|
||||
uint16_t range = (uint16_t) (maxVal - widget1->getMinValue());
|
||||
uint8_t offsetX = widget1->getX() + 9;
|
||||
|
||||
// erase previous value.
|
||||
// pointer position is calculated the same way as the widget code.
|
||||
uint8_t offsetY = (float)(uint16_t)(maxVal - prevVal) / (float)range * 40;
|
||||
uView.setCursor(offsetX, offsetY);
|
||||
uView.print(" "); // This is being lazy. Should calculate width for value.
|
||||
|
||||
// draw new value
|
||||
offsetY = (float)(uint16_t)(maxVal - val) / (float)range * 40;
|
||||
uView.setCursor(offsetX, offsetY);
|
||||
widget1->drawNumValue(val);
|
||||
|
||||
widget1->setValue(val);
|
||||
}
|
||||
|
||||
// Update function for Demo 12
|
||||
void customGauge0(int16_t val) {
|
||||
widget1->setValue(val);
|
||||
|
||||
uView.setCursor(widget1->getX() - 17, widget1->getY() + 19);
|
||||
uView.setFontType(1);
|
||||
// add leading space if necessary, to right justify.
|
||||
// only 2 digit (plus decimal) numbers are supported.
|
||||
if (val < 100) {
|
||||
uView.print(' ');
|
||||
}
|
||||
uView.print((float)val / 10, 1);
|
||||
uView.setFontType(0);
|
||||
}
|
||||
|
||||
// Update function for Demo 13
|
||||
void customGauge1(int16_t val) {
|
||||
widget1->setValue(val);
|
||||
uView.setCursor(widget1->getX() - 2, widget1->getY() + 9);
|
||||
uView.print((char)(val + 'A' - 1));
|
||||
}
|
||||
|
||||
// Clear the screen buffer and draw the demo number in the corner
|
||||
void demoNumber(int num) {
|
||||
uView.clear(PAGE);
|
||||
uView.setCursor(0, 0);
|
||||
uView.print(num);
|
||||
uView.print(":");
|
||||
}
|
||||
|
||||
// Spin up, then down, through the values.
|
||||
//
|
||||
// For each value, call the update function and display the new screen.
|
||||
void spin(int16_t lowVal, int16_t highVal, int16_t stepSize,
|
||||
unsigned long stepDelay, void (*drawFunction)(int16_t val)) {
|
||||
drawFunction(lowVal);
|
||||
uView.display();
|
||||
prevVal = lowVal;
|
||||
delay(1500);
|
||||
|
||||
for (int16_t i = lowVal + stepSize; i <= highVal; i += stepSize) {
|
||||
drawFunction(i);
|
||||
uView.display();
|
||||
prevVal = i;
|
||||
delay(stepDelay);
|
||||
if ((i == 0) && (lowVal != 0)) { // pause briefly for a value of 0
|
||||
delay(750);
|
||||
}
|
||||
}
|
||||
|
||||
delay(1500);
|
||||
|
||||
for (int16_t i = highVal; i >= lowVal; i -= stepSize) {
|
||||
drawFunction(i);
|
||||
uView.display();
|
||||
prevVal = i;
|
||||
delay(stepDelay);
|
||||
if ((i == 0) && (lowVal != 0)) { // pause briefly for a value of 0
|
||||
delay(750);
|
||||
}
|
||||
}
|
||||
|
||||
delay(1500);
|
||||
}
|
||||
|
||||
48
examples/MicroViewWidgetRedraw/MicroViewWidgetRedraw.ino
Normal file
48
examples/MicroViewWidgetRedraw/MicroViewWidgetRedraw.ino
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
MicroView Arduino Library
|
||||
Copyright (C) 2014 GeekAmmo
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <MicroView.h>
|
||||
|
||||
MicroViewWidget *widget[2]; // declaring an array of 4 MicroViewWidget
|
||||
|
||||
void setup() {
|
||||
uView.begin(); // init and start MicroView
|
||||
widget[0] = new MicroViewSlider(0,0,0,255); // declare widget0 as a Slider at x=0, y=0, min=0, max=100
|
||||
widget[1] = new MicroViewGauge(32,24,0,255,WIDGETSTYLE0); // declare widget0 as a Slider at x=0, y=10, min=0, max=150
|
||||
uView.clear(PAGE); // erase the memory buffer, when next uView.display() is called, the OLED will be cleared.
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
widget[0]->reDraw();
|
||||
for (int i=0;i<=255;i++) {
|
||||
widget[0]->setValue(i); // set value i to widget0
|
||||
uView.display();
|
||||
}
|
||||
|
||||
delay(500);
|
||||
uView.clear(PAGE);
|
||||
|
||||
widget[1]->reDraw();
|
||||
for (int i=0;i<=255;i++) {
|
||||
widget[1]->setValue(i); // set value i to widget0
|
||||
uView.display();
|
||||
}
|
||||
|
||||
delay(500);
|
||||
uView.clear(PAGE);
|
||||
}
|
||||
12
keywords.txt
12
keywords.txt
@@ -17,7 +17,6 @@ MicroViewGauge KEYWORD1
|
||||
#######################################
|
||||
|
||||
begin KEYWORD2
|
||||
invert KEYWORD2
|
||||
clear KEYWORD2
|
||||
invert KEYWORD2
|
||||
contrast KEYWORD2
|
||||
@@ -50,6 +49,10 @@ scrollVertLeft KEYWORD2
|
||||
scrollStop KEYWORD2
|
||||
flipVertical KEYWORD2
|
||||
flipHorizontal KEYWORD2
|
||||
setColumnAddress KEYWORD2
|
||||
setPageAddress KEYWORD2
|
||||
data KEYWORD2
|
||||
getScreenBuffer KEYWORD2
|
||||
|
||||
getX KEYWORD2
|
||||
getY KEYWORD2
|
||||
@@ -60,8 +63,12 @@ getMaxValue KEYWORD2
|
||||
setMaxValue KEYWORD2
|
||||
setMinValue KEYWORD2
|
||||
setValue KEYWORD2
|
||||
getValLen KEYWORD2
|
||||
getMaxValLen KEYWORD2
|
||||
draw KEYWORD2
|
||||
reDraw KEYWORD2
|
||||
drawFace KEYWORD2
|
||||
drawNumValue KEYWORD2
|
||||
checkComm KEYWORD2
|
||||
|
||||
#######################################
|
||||
@@ -77,5 +84,6 @@ ALL LITERAL1
|
||||
WIDGETSTYLE0 LITERAL1
|
||||
WIDGETSTYLE1 LITERAL1
|
||||
WIDGETSTYLE2 LITERAL1
|
||||
|
||||
WIDGETSTYLE3 LITERAL1
|
||||
WIDGETNOVALUE LITERAL1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user