Skip to content

Commit 9ee0b95

Browse files
committed
changed SS,RESET,DC to use weak pull-up
1 parent fb8b9c4 commit 9ee0b95

File tree

3 files changed

+44
-21
lines changed

3 files changed

+44
-21
lines changed

Diff for: MicroView.cpp

+30-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <avr/pgmspace.h>
2-
#include <SPI.h>
2+
//#include <SPI.h>
33
#include <MicroView.h>
44

55
// This fixed ugly GCC warning "only initialized variables can be placed into program memory area"
@@ -95,19 +95,19 @@ void MicroView::begin() {
9595
// Setting up SPI pins
9696
pinMode(MOSI, OUTPUT);
9797
pinMode(SCK, OUTPUT);
98-
pinMode(DC, OUTPUT);
98+
99+
//pinMode(DC, OUTPUT);
99100
pinMode(RESET, OUTPUT);
100-
pinMode(SS, OUTPUT);
101+
pinMode(SS, INPUT);
101102
digitalWrite(SS, HIGH);
102103

103-
sckport = portOutputRegister(digitalPinToPort(SCK));
104-
sckpinmask = digitalPinToBitMask(SCK);
105-
mosiport = portOutputRegister(digitalPinToPort(MOSI));
106-
mosipinmask = digitalPinToBitMask(MOSI);
107-
ssport = portOutputRegister(digitalPinToPort(SS));
108-
sspinmask = digitalPinToBitMask(SS);
109-
dcport = portOutputRegister(digitalPinToPort(DC));
110-
dcpinmask = digitalPinToBitMask(DC);
104+
ssport = portOutputRegister(digitalPinToPort(SS));
105+
sspinmask = digitalPinToBitMask(SS);
106+
ssreg = portModeRegister(digitalPinToPort(SS));
107+
108+
dcport = portOutputRegister(digitalPinToPort(DC));
109+
dcpinmask = digitalPinToBitMask(DC);
110+
dcreg = portModeRegister(digitalPinToPort(DC));
111111

112112
digitalWrite(RESET, HIGH);
113113
// VDD (3.3V) goes high at start, lets just chill for 5 ms
@@ -122,7 +122,8 @@ void MicroView::begin() {
122122
// wait 10ms
123123
delay(10);
124124
// bring out of reset
125-
digitalWrite(RESET, HIGH);
125+
pinMode(RESET,INPUT_PULLUP);
126+
//digitalWrite(RESET, HIGH);
126127

127128
// Init sequence for 64x48 OLED module
128129
command(DISPLAYOFF); // 0xAE
@@ -166,20 +167,33 @@ void MicroView::begin() {
166167

167168
void MicroView::command(uint8_t c) {
168169
// Hardware SPI
169-
*ssport |= sspinmask; // SS HIGH
170-
*dcport &= ~dcpinmask; // DC LOW
171-
*ssport &= ~sspinmask; // SS LOW
170+
*dcreg |= dcpinmask; // Set DC pin to OUTPUT
171+
*dcport &= ~dcpinmask; // DC pin LOW
172+
173+
*ssreg |= sspinmask; // Set SS pin to OUTPUT
174+
*ssport &= ~sspinmask; // SS LOW
175+
172176
MVSPI.transfer(c);
177+
173178
*ssport |= sspinmask; // SS HIGH
179+
*ssreg &= ~sspinmask; // Set SS pin to INPUT
180+
181+
*dcreg &= ~dcpinmask; // Set DC to INPUT to avoid high voltage over driving the OLED logic
174182
}
175183

176184
void MicroView::data(uint8_t c) {
177185
// Hardware SPI
178-
*ssport |= sspinmask; // SS HIGH
179186
*dcport |= dcpinmask; // DC HIGH
187+
188+
*ssreg |= sspinmask; // Set SS pin to OUTPUT
180189
*ssport &= ~sspinmask; // SS LOW
190+
181191
MVSPI.transfer(c);
192+
182193
*ssport |= sspinmask; // SS HIGH
194+
*ssreg &= ~sspinmask; // Set SS pin to INPUT
195+
196+
*dcreg &= ~dcpinmask; // Set DC to INPUT to avoid high voltage over driving the OLED logic
183197
}
184198

185199
void MicroView::setPageAddress(uint8_t add) {

Diff for: MicroView.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
#define DC 8
1111
#define RESET 12
12-
// SS, SCK, MOSI already defined by original SPI.h
12+
13+
// SS, SCK, MOSI already defined by original pins_arduino.h
1314
//#define CS 10
1415
//#define SCK 13
1516
//#define MOSI 11
@@ -158,7 +159,8 @@ class MicroView : public Print{
158159

159160
private:
160161
//uint8_t cs;
161-
volatile uint8_t *mosiport, *sckport, *ssport, *dcport; // use volatile because these are fixed location port address
162+
//volatile uint8_t *mosiport, *sckport;
163+
volatile uint8_t *ssport, *dcport, *ssreg, *dcreg; // use volatile because these are fixed location port address
162164
uint8_t mosipinmask, sckpinmask, sspinmask, dcpinmask;
163165
uint8_t foreColor,drawMode,fontWidth, fontHeight, fontType, fontStartChar, fontTotalChar, cursorX, cursorY;
164166
uint16_t fontMapWidth;

Diff for: README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ Arduino library for MicroView.
1212

1313
## Installation
1414

15-
1. Extract / Check out to Arduino's libraries folder.
16-
2. Start Arduino IDE.
17-
3. MicroView example is located at, File--->Example--->MicroView--->MicroViewDemo
15+
1. Change directory to Arduino's main directory
16+
2. cd libraries
17+
3. mkdir MicroView
18+
4. cd MicroView
19+
5. git clone [email protected]:geekammo/microview.git .
20+
6. Start Arduino IDE.
21+
7. MicroView example is located at, File--->Example--->MicroView--->MicroViewDemo
1822

1923
### Example 1 - Hello World!
2024
<pre><code>
@@ -87,6 +91,9 @@ void loop() {
8791
</code></pre>
8892

8993
## History
94+
**v1.10b: 22th April 2014 by JP Liew**
95+
* changed SS, RESET, DC pins to use weak internal pull-up resistors
96+
9097
**v1.09b: 17th April 2014 by JP Liew**
9198
* changed verticalFlip() to flipVertical() and horizontalFlip() to flipHorizontal() for consistency
9299
* added debug messages for doCmd()

0 commit comments

Comments
 (0)