mirror of
https://github.com/geekammo/MicroView-Arduino-Library.git
synced 2026-03-03 00:34:06 +01:00
added invert function, contrast function, changed scrollStop to scrollStop for consistency
This commit is contained in:
@@ -233,6 +233,18 @@ void MicroView::clear(uint8_t mode, uint8_t c) {
|
||||
}
|
||||
}
|
||||
|
||||
void MicroView::invert(boolean inv) {
|
||||
if (inv)
|
||||
command(INVERTDISPLAY);
|
||||
else
|
||||
command(NORMALDISPLAY);
|
||||
}
|
||||
|
||||
void MicroView::contrast(uint8_t contrast) {
|
||||
command(SETCONTRAST); // 0x81
|
||||
command(contrast);
|
||||
}
|
||||
|
||||
// This routine is to transfer the page buffer to the LCD controller's memory.
|
||||
void MicroView::display(void) {
|
||||
uint8_t i, j;
|
||||
@@ -633,14 +645,14 @@ size_t MicroView::write(uint8_t c) {
|
||||
|
||||
}
|
||||
|
||||
void MicroView::stopScroll(void){
|
||||
void MicroView::scrollStop(void){
|
||||
command(DEACTIVATESCROLL);
|
||||
}
|
||||
|
||||
void MicroView::scrollRight(uint8_t start, uint8_t stop){
|
||||
if (stop<start) // stop must be larger or equal to start
|
||||
return;
|
||||
stopScroll(); // need to disable scrolling before starting to avoid memory corrupt
|
||||
scrollStop(); // need to disable scrolling before starting to avoid memory corrupt
|
||||
command(RIGHTHORIZONTALSCROLL);
|
||||
command(0x00);
|
||||
command(start);
|
||||
@@ -679,8 +691,9 @@ size_t MicroView::write(uint8_t c) {
|
||||
|
||||
void MicroViewWidget::setMinValue(int16_t min) { minValue=min; }
|
||||
void MicroViewWidget::setMaxValue(int16_t max) { maxValue=max; }
|
||||
|
||||
void MicroViewWidget::setValue(int16_t val) {
|
||||
if (val<=maxValue) {
|
||||
if ((val<=maxValue) && (val>=minValue)){
|
||||
value=val;
|
||||
this->draw();
|
||||
}
|
||||
|
||||
@@ -64,6 +64,10 @@
|
||||
#define VERTICALRIGHTHORIZONTALSCROLL 0x29
|
||||
#define VERTICALLEFTHORIZONTALSCROLL 0x2A
|
||||
|
||||
typedef enum CMD {CMD_CLEAR,CMD_INVERT,CMD_CONTRAST,CMD_DISPLAY,CMD_SETCURSOR,CMD_PIXEL,CMD_LINE,
|
||||
CMD_LINEH,CMD_LINEV,CMD_RECT, CMD_RECTFILL, CMD_CIRCLE,CMD_CIRCLEFILL, CMD_DRAWCHAR, CMD_DRAWBITMAP,
|
||||
CMD_GETLCDWIDTH, CMD_GETLCDHEIGHT,CMD_SETCOLOR, CMD_SETDRAWMODE} commCommand_t;
|
||||
|
||||
class MicroView : public Print{
|
||||
public:
|
||||
MicroView(void) {};
|
||||
@@ -84,7 +88,8 @@ public:
|
||||
// LCD Draw functions
|
||||
void clear(uint8_t mode);
|
||||
void clear(uint8_t mode, uint8_t c);
|
||||
void invert(uint8_t i);
|
||||
void invert(boolean inv);
|
||||
void contrast(uint8_t contrast);
|
||||
void display(void);
|
||||
void setCursor(uint8_t x, uint8_t y);
|
||||
void pixel(uint8_t x, uint8_t y);
|
||||
@@ -125,7 +130,7 @@ public:
|
||||
void scrollLeft(uint8_t start, uint8_t stop);
|
||||
void scrollVertRight(uint8_t start, uint8_t stop);
|
||||
void scrollVertLeft(uint8_t start, uint8_t stop);
|
||||
void stopScroll(void);
|
||||
void scrollStop(void);
|
||||
|
||||
private:
|
||||
//uint8_t cs;
|
||||
|
||||
14
README.md
14
README.md
@@ -16,7 +16,7 @@ Arduino library for MicroView.
|
||||
2. Start Arduino IDE.
|
||||
3. MicroView example is located at, File--->Example--->MicroView--->MicroViewDemo
|
||||
|
||||
### Example 1
|
||||
### Example 1 - Hello World!
|
||||
<pre><code>
|
||||
#include <MicroView.h>
|
||||
|
||||
@@ -30,7 +30,7 @@ void loop() {
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
### Example 2
|
||||
### Example 2 - Basic Drawing
|
||||
<pre><code>
|
||||
#include <MicroView.h>
|
||||
|
||||
@@ -50,7 +50,7 @@ void loop() {
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
### Example 3
|
||||
### Example 3 - Widgets
|
||||
<pre><code>
|
||||
#include <MicroView.h>
|
||||
|
||||
@@ -73,7 +73,13 @@ void loop() {
|
||||
</code></pre>
|
||||
|
||||
## History
|
||||
**v1.06b: by JP Liew**
|
||||
**v1.07b: 10th February by JP Liew**
|
||||
* changed function name stopScroll to scrollStop for consistency
|
||||
* added contrast function
|
||||
* added invert function
|
||||
* added KEYWORD to keywords.txt
|
||||
|
||||
**v1.06b: 9th February by JP Liew**
|
||||
* fixed Slider negative value not working
|
||||
* added round Gauge widget
|
||||
* changed Example 3 to show round Gauge
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
#include <MicroView.h>
|
||||
#include <Time.h>
|
||||
|
||||
//#define PI 3.141592654
|
||||
#define clocksize 24
|
||||
|
||||
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.
|
||||
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() {
|
||||
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
|
||||
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);
|
||||
uView.clear(PAGE); // Erase the memory buffer, when next uView.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() {
|
||||
@@ -261,8 +260,6 @@ void loop() {
|
||||
}
|
||||
}
|
||||
uView.clear(PAGE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,39 +1,30 @@
|
||||
#include <SPI.h>
|
||||
#include <MicroView.h>
|
||||
|
||||
MicroViewWidget *widget[4];
|
||||
|
||||
void setup() {
|
||||
|
||||
widget[0] = new MicroViewSlider(0,0,0,100);
|
||||
widget[1] = new MicroViewSlider(0,10,0,150);
|
||||
widget[2] = new MicroViewSlider(0,20,0,50);
|
||||
widget[3] = new MicroViewSlider(0,30,0,200);
|
||||
Serial.begin(115200);
|
||||
Serial.println("start");
|
||||
uView.begin();
|
||||
uView.clear(PAGE);
|
||||
widget[0]->draw();
|
||||
widget[1]->draw();
|
||||
widget[2]->draw();
|
||||
widget[3]->draw();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for (int i=0;i<101;i++) {
|
||||
widget[0]->setValue(i);
|
||||
widget[1]->setValue(100-i);
|
||||
widget[2]->setValue(i);
|
||||
widget[3]->setValue(100-i);
|
||||
uView.display();
|
||||
}
|
||||
|
||||
for(int i=100; i>-1;i--) {
|
||||
widget[0]->setValue(i);
|
||||
widget[1]->setValue(100-i);
|
||||
widget[2]->setValue(i);
|
||||
widget[3]->setValue(100-i);
|
||||
uView.display();
|
||||
}
|
||||
|
||||
#include <MicroView.h>
|
||||
|
||||
MicroViewWidget *widget[4]; // declaring an array of 4 MicroViewWidget
|
||||
|
||||
void setup() {
|
||||
uView.begin(); // init and start MicroView
|
||||
uView.clear(PAGE); // erase the memory buffer, when next uView.display() is called, the OLED will be cleared.
|
||||
widget[0] = new MicroViewSlider(0,0,0,100); // declare widget0 as a Slider at x=0, y=0, min=0, max=100
|
||||
widget[1] = new MicroViewSlider(0,10,0,150); // declare widget0 as a Slider at x=0, y=10, min=0, max=150
|
||||
widget[2] = new MicroViewSlider(0,20,0,50); // declare widget0 as a Slider at x=0, y=20, min=0, max=50
|
||||
widget[3] = new MicroViewSlider(0,30,0,200); // declare widget0 as a Slider at x=0, y=30, min=0, max=200
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for (int i=0;i<=100;i++) {
|
||||
widget[0]->setValue(i); // set value i to widget0
|
||||
widget[1]->setValue(100-i);
|
||||
widget[2]->setValue(i);
|
||||
widget[3]->setValue(100-i);
|
||||
uView.display();
|
||||
}
|
||||
|
||||
for(int i=100; i>=0;i--) {
|
||||
widget[0]->setValue(i);
|
||||
widget[1]->setValue(100-i);
|
||||
widget[2]->setValue(i);
|
||||
widget[3]->setValue(100-i);
|
||||
uView.display();
|
||||
}
|
||||
}
|
||||
|
||||
56
keywords.txt
56
keywords.txt
@@ -7,18 +7,72 @@
|
||||
#######################################
|
||||
|
||||
MICROVIEW KEYWORD1
|
||||
uView KEYWORD1
|
||||
MicroViewWidget KEYWORD1
|
||||
MicroViewSlider KEYWORD1
|
||||
MicroViewGauge KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
begin KEYWORD2
|
||||
invert KEYWORD2
|
||||
clear KEYWORD2
|
||||
home KEYWORD2
|
||||
invert KEYWORD2
|
||||
contrast KEYWORD2
|
||||
display KEYWORD2
|
||||
setCursor KEYWORD2
|
||||
pixel KEYWORD2
|
||||
line KEYWORD2
|
||||
lineH KEYWORD2
|
||||
lineV KEYWORD2
|
||||
rect KEYWORD2
|
||||
rectFill KEYWORD2
|
||||
circle KEYWORD2
|
||||
circleFill KEYWORD2
|
||||
drawChar KEYWORD2
|
||||
getLCDWidth KEYWORD2
|
||||
getLCDHeight KEYWORD2
|
||||
setColor KEYWORD2
|
||||
setDrawMode KEYWORD2
|
||||
getFontWidth KEYWORD2
|
||||
getFontHeight KEYWORD2
|
||||
getTotalFonts KEYWORD2
|
||||
getFontType KEYWORD2
|
||||
setFontType KEYWORD2
|
||||
getFontStartChar KEYWORD2
|
||||
getFontTotalChar KEYWORD2
|
||||
scrollRight KEYWORD2
|
||||
scrollLeft KEYWORD2
|
||||
scrollVertRight KEYWORD2
|
||||
scrollVertLeft KEYWORD2
|
||||
scrollStop KEYWORD2
|
||||
|
||||
getX KEYWORD2
|
||||
getY KEYWORD2
|
||||
setX KEYWORD2
|
||||
setY KEYWORD2
|
||||
getMinValue KEYWORD2
|
||||
getMaxValue KEYWORD2
|
||||
setMaxValue KEYWORD2
|
||||
setMinValue KEYWORD2
|
||||
setValue KEYWORD2
|
||||
draw KEYWORD2
|
||||
drawFace KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
||||
BLACK LITERAL1
|
||||
WHITE LITERAL1
|
||||
NORM LITERAL1
|
||||
XOR LITERAL1
|
||||
PAGE LITERAL1
|
||||
ALL LITERAL1
|
||||
WIDGETSTYLE0 LITERAL1
|
||||
WIDGETSTYLE1 LITERAL1
|
||||
WIDGETSTYLE2 LITERAL1
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user