21 Commits

Author SHA1 Message Date
JP
87e118eb44 moved reDraw() to parent 2014-08-04 11:00:49 +10:00
JP
94fc7e6437 moved reDraw() to parent 2014-08-04 11:00:08 +10:00
JP
7c3ec25d70 added reDraw() 2014-08-04 10:36:33 +10:00
JP
dce58d7069 added reDraw() for MicroViewWidget class 2014-08-04 10:22:47 +10:00
JP
82d55a8201 merged czetie vertical slider 2014-08-03 16:16:00 +10:00
JP
d28428ce35 Merge branch 'czetie-vertical-slider' 2014-08-03 16:08:24 +10:00
JP
77faa7d583 added Vertical Slider example 2014-08-03 16:07:44 +10:00
JP
eb9edb19d6 moved example to example folder 2014-08-03 16:07:09 +10:00
JP
21fa22bec2 Merge branch 'vertical-slider' of https://github.com/czetie/MicroView-Arduino-Library into czetie-vertical-slider 2014-08-03 16:02:51 +10:00
JP
5afff4bff7 added v1.15b history 2014-08-03 15:59:04 +10:00
JP
8d2802f6c1 Merge branch 'MLXXXp-master' 2014-08-03 15:48:14 +10:00
Scott Allen
c67593e321 Fix positioning of "3" on clock face. 2014-08-01 15:33:49 -04:00
Scott Allen
f398624f85 Merge branch 'master' of https://github.com/geekammo/MicroView-Arduino-Library 2014-08-01 14:28:30 -04:00
Scott Allen
9c5568418a Improve speed of display() and clear() functions
by using horizontal addressing mode.
2014-08-01 14:10:11 -04:00
Scott Allen
a32fd2c499 Added uView.end() to power off the display.
In uView.begin() don't send commands that default to desired values.
2014-08-01 14:09:58 -04:00
Scott Allen
499594d9de Help further reduce overdriving display inputs
(and fixed a few spelling errors in comments)
- Use fast pin change macros for RESET, SS and DC.
- Implement MVSPI.packetBegin() and MVSPI.packetEnd() to allow sending
  multiple byte "packets" while SS remains enabled.
- Add 2 and 3 byte command() functions to send multiple command bytes in
  one packet.
- Modify clear() and display() functions to send commands and data in
  packets.
- Do the "wait for SPI transfer complete" just before sending the next
  byte (plus after the last or only byte) in a packet, so code can be
  executed while bytes are being sent.
- Disable SPI mode when not transmitting, so MOSI (and SCK) will go low.
- Keep DC low except when sending data bytes.
- Change MVSPI.transfer() to void since nothing can be received from
  the display.
2014-07-30 19:28:39 -04:00
Scott Allen
fa09bdd7aa Eliminate compiler warnings
- Fixed use of = instead of == in "if" statment.
- Fixed uninitialised count variable in "for" loop.
- Removed unused variables.
- Replaced line splice characters (backslash) at end of comments.
2014-07-29 21:27:10 -04:00
Scott Allen
b109908d28 Fast SPI pin changes
- added defines to map ports and bits for RESET, DC and SS.
- added macros to quickly control RESET, DC and SS using
  the internal weak pullup for high.
2014-07-29 21:26:07 -04:00
Carl Zetie
b5462c5bcb Many bugs fixed
OK, this version is actually worth looking at. Previous had more bugs
than you could shake a stick at.

vert_slider_test.ino illustrates the two slider styles, vertical
versions of the two existing styles
2014-07-14 18:39:13 -04:00
Carl Zetie
7b66741f79 Fixed my typo in MicroView.cpp
Fixed my typo in MicroView.cpp
2014-07-14 07:48:20 -04:00
Carl Zetie
c1e8756c4e Added Vertical Slider styles to Slider widget
Added WIDGETSTYLE2 (like 0, but vertical) and WIDGETSTYLE3 (like 1, but
vertical). NOTE: I don't have a build environment, so I can't even
promise this will compile! So if it's crap, just treat it as a concept
for an enhancement request!
2014-07-13 14:42:34 -04:00
7 changed files with 1449 additions and 1178 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -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
@@ -49,6 +78,8 @@
#define WIDGETSTYLE0 0
#define WIDGETSTYLE1 1
#define WIDGETSTYLE2 2
//Added for Vertical slider styles
#define WIDGETSTYLE3 3
#define SETCONTRAST 0x81
#define DISPLAYALLONRESUME 0xA4
@@ -65,6 +96,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
@@ -109,6 +144,7 @@ class MicroView : public Print{
public:
MicroView(void) {};
void begin(void);
void end(void);
//#if ARDUINO >= 100
@@ -120,6 +156,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);
@@ -178,10 +216,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];
@@ -192,6 +226,7 @@ private:
class MicroViewWidget {
public:
bool needFirstDraw;
MicroViewWidget(uint8_t newx, uint8_t newy, int16_t min, int16_t max);
uint8_t getX();
uint8_t getY();
@@ -208,6 +243,7 @@ public:
virtual void draw(){};
/** \brief Draw widget face overridden by child class. */
virtual void drawFace(){};
void reDraw();
private:
uint8_t x;
@@ -223,9 +259,9 @@ public:
MicroViewSlider(uint8_t newx, uint8_t newy, int16_t min, int16_t max, uint8_t sty);
void draw();
void drawFace();
void reDraw();
private:
uint8_t totalTicks, style;
bool needFirstDraw;
int16_t prevValue;
};
@@ -235,9 +271,9 @@ public:
MicroViewGauge(uint8_t newx, uint8_t newy, int16_t min, int16_t max, uint8_t sty);
void draw();
void drawFace();
void reDraw();
private:
uint8_t radius, style;
bool needFirstDraw;
int16_t prevValue;
};
@@ -261,8 +297,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 +324,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 +341,5 @@ void MVSPIClass::detachInterrupt() {
SPCR &= ~_BV(SPIE);
}
extern MicroView uView;
#endif

View File

@@ -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,23 @@ void loop() {
</code></pre>
## History
**v1.14b: 26th July 2014 by JP Liew
**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 uVuew.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 +149,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

View File

@@ -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);
}

View 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();
}
}

View 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);
}

View File

@@ -77,5 +77,6 @@ ALL LITERAL1
WIDGETSTYLE0 LITERAL1
WIDGETSTYLE1 LITERAL1
WIDGETSTYLE2 LITERAL1
WIDGETSTYLE3 LITERAL1