Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Documentation

* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
* **[Product Repository](https://github.com/sparkfun/MicroView/tree/v10)** - Main repository (including hardware files) for the MicroView.
* **[Learn Microview](http://learn.microview.io/)** - Beginners tutorial for the MicroView.
* **[Microview Hookup Guide](https://learn.sparkfun.com/tutorials/microview-hookup-guide/all)** - Beginners tutorial for the MicroView.
* **[Microview Inventor kit](https://learn.sparkfun.com/tutorials/sparkfun-inventors-kit-for-microview/all#experiment-1-blinking-an-led)** - Plugin some hardware to the MicroView.
* **[Microview in Platformio](https://platformio.org/lib/show/260/SparkFun_MicroView)** - How to use Platformio with the MicroView.

Products that use this Library
---------------------------------
Expand Down
3 changes: 2 additions & 1 deletion examples/LearningKit/Circuit1/Circuit1.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <Arduino.h>
int LED = A3; // declare LED as pin A3 of MicroView

void setup()
Expand All @@ -11,4 +12,4 @@ void loop()
delay(1000); // delay 1000 ms
digitalWrite(LED, LOW); // set LED pin LOW voltage, LED will be off
delay(1000); // delay 1000 ms
}
}
63 changes: 31 additions & 32 deletions examples/LearningKit/Circuit8/Circuit8.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,6 @@ void setup()
pinMode(buzzerPin, OUTPUT);
}

void loop()
{
int i, duration;

for (i = 0; i < songLength; i++) // step through the song arrays
{
duration = beats[i] * tempo; // length of note/rest in ms

if (notes[i] == ' ') // is this a rest?
{
uView.print(" ");
uView.display();
delay(duration); // then pause for a moment
}
else // otherwise, play the note
{
uView.print(notes[i]);
uView.display();
tone(buzzerPin, frequency(notes[i]), duration);
delay(duration); // wait for tone to finish
}
delay(tempo/10); // brief pause between notes
}

// We only want to play the song once, so we'll pause forever:
while(true){}
// If you'd like your song to play over and over,
// remove the above statement
}


int frequency(char note)
{
// This function takes a note character (a-g), and returns the
Expand Down Expand Up @@ -79,4 +48,34 @@ int frequency(char note)
}
return(0); // We looked through everything and didn't find it,
// but we still need to return a value, so return 0.
}
}

void loop()
{
int i, duration;

for (i = 0; i < songLength; i++) // step through the song arrays
{
duration = beats[i] * tempo; // length of note/rest in ms

if (notes[i] == ' ') // is this a rest?
{
uView.print(" ");
uView.display();
delay(duration); // then pause for a moment
}
else // otherwise, play the note
{
uView.print(notes[i]);
uView.display();
tone(buzzerPin, frequency(notes[i]), duration);
delay(duration); // wait for tone to finish
}
delay(tempo/10); // brief pause between notes
}

// We only want to play the song once, so we'll pause forever:
while(true){}
// If you'd like your song to play over and over,
// remove the above statement
}
42 changes: 21 additions & 21 deletions examples/LearningKit/Circuit9/Circuit9.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,6 @@
int motorPIN = 3; // set motor control pin
MicroViewWidget *widget; // declare widget pointer

void setup() {
uView.begin(); // start MicroView
uView.clear(PAGE); // clear page
pinMode(motorPIN, OUTPUT); // initialize the digital pin as an output.
widget = new MicroViewGauge(32,24,90,255,WIDGETSTYLE1); // set widget as gauge STYLE1
setPwmFrequency(motorPIN,1); // set PWM frequency to about 31K
}

void loop() {
for (int i=90;i<255;i+=10) { // step i from 90 to 255 by step of 10
widget->setValue(i); // set i value to gauge
uView.display(); // display gauge
analogWrite(motorPIN, i); // set the DUTY cycle of the motorPIN
delay(500); // delay 500 ms
}
}

// function to set the frequency of the PWM pin
// adapted from http://playground.arduino.cc/Code/PwmFrequency
void setPwmFrequency(int pin, int divisor) {
Expand All @@ -34,9 +17,9 @@ void setPwmFrequency(int pin, int divisor) {
default: return;
}
if(pin == 5 || pin == 6) {
TCCR0B = TCCR0B & 0b11111000 | mode;
TCCR0B = (TCCR0B & 0b11111000) | mode;
} else {
TCCR1B = TCCR1B & 0b11111000 | mode;
TCCR1B = (TCCR1B & 0b11111000) | mode;
}
} else if(pin == 3 || pin == 11) {
switch(divisor) {
Expand All @@ -49,6 +32,23 @@ void setPwmFrequency(int pin, int divisor) {
case 1024: mode = 0x7; break;
default: return;
}
TCCR2B = TCCR2B & 0b11111000 | mode;
TCCR2B = (TCCR2B & 0b11111000) | mode;
}
}
}

void setup() {
uView.begin(); // start MicroView
uView.clear(PAGE); // clear page
pinMode(motorPIN, OUTPUT); // initialize the digital pin as an output.
widget = new MicroViewGauge(32,24,90,255,WIDGETSTYLE1); // set widget as gauge STYLE1
setPwmFrequency(motorPIN,1); // set PWM frequency to about 31K
}

void loop() {
for (int i=90;i<255;i+=10) { // step i from 90 to 255 by step of 10
widget->setValue(i); // set i value to gauge
uView.display(); // display gauge
analogWrite(motorPIN, i); // set the DUTY cycle of the motorPIN
delay(500); // delay 500 ms
}
}
75 changes: 40 additions & 35 deletions examples/MicroViewAnalogClock/MicroViewAnalogClock.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Turn your MicroView into an analog clock!
This sketch requires the Arduino time library. Get it from
here: http://playground.arduino.cc/Code/Time

If you are using Platformio, install the Time library with
pio lib install "Time"

Development environment specifics:
IDE: Arduino 1.6.0
Expand All @@ -28,23 +30,50 @@ Distributed as-is; no warranty is given.
// This is the radius of the clock:
#define CLOCK_SIZE 23

// Use these defines to set the clock's begin time
#define HOUR 10
#define MINUTE 02
#define SECOND 00
#define DAY 28
#define MONTH 2
#define YEAR 2015

const uint8_t maxW = uView.getLCDWidth();
const uint8_t midW = maxW/2;
const uint8_t maxH = uView.getLCDHeight();
const uint8_t midH = maxH/2;

// Draw the clock face. That includes the circle outline and
// the 12, 3, 6, and 9 text.
void drawFace()
{
uView.setFontType(0); // set font type 0 (Smallest)

uint8_t fontW = uView.getFontWidth();
uint8_t fontH = uView.getFontHeight();

//uView.setCursor(27, 0); // points cursor to x=27 y=0
uView.setCursor(midW-fontW-1, midH-CLOCK_SIZE+1);
uView.print(12); // Print the "12"
uView.setCursor(midW-(fontW/2)-1, midH+CLOCK_SIZE-fontH-1);
uView.print(6); // Print the "6"
uView.setCursor(midW-CLOCK_SIZE+1, midH-fontH/2);
uView.print(9); // Print the "9"
uView.setCursor(midW+CLOCK_SIZE-fontW-2, midH-fontH/2);
uView.print(3); // Print the "3"
uView.circle(midW-1, midH-1, CLOCK_SIZE);

//Draw the clock
uView.display();
}

void setup()
{
int year, month, day, hour, minute, second;

// Random trick on Arduino from
// https://programmingelectronics.com/using-random-numbers-with-arduino/
randomSeed(analogRead(A0));
hour = random(12);
minute = random(60);
second = random(60);
day = random(1,32);
month = random(1,13);
year = random(2015,2066);
// Set the time in the time library:
setTime(HOUR, MINUTE, SECOND, DAY, MONTH, YEAR);
setTime(hour, minute, second, day, month, year);

uView.begin(); // set up the MicroView
uView.clear(PAGE);// erase hardware memory inside the OLED
Expand All @@ -54,11 +83,6 @@ void setup()
drawFace();
}

void loop()
{
drawTime();
}

void drawTime()
{
static boolean firstDraw = false;
Expand Down Expand Up @@ -105,26 +129,7 @@ void drawTime()
}
}

// Draw the clock face. That includes the circle outline and
// the 12, 3, 6, and 9 text.
void drawFace()
void loop()
{
uView.setFontType(0); // set font type 0 (Smallest)

uint8_t fontW = uView.getFontWidth();
uint8_t fontH = uView.getFontHeight();

//uView.setCursor(27, 0); // points cursor to x=27 y=0
uView.setCursor(midW-fontW-1, midH-CLOCK_SIZE+1);
uView.print(12); // Print the "12"
uView.setCursor(midW-(fontW/2)-1, midH+CLOCK_SIZE-fontH-1);
uView.print(6); // Print the "6"
uView.setCursor(midW-CLOCK_SIZE+1, midH-fontH/2);
uView.print(9); // Print the "9"
uView.setCursor(midW+CLOCK_SIZE-fontW-2, midH-fontH/2);
uView.print(3); // Print the "3"
uView.circle(midW-1, midH-1, CLOCK_SIZE);

//Draw the clock
uView.display();
drawTime();
}
14 changes: 7 additions & 7 deletions examples/MicroViewCube/MicroViewCube.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ void setup()
uView.display();
}

void loop()
{
drawCube();
delay(ROTATION_SPEED);
}

void drawCube()
{
r[0]=r[0]+PI/180.0; // Add a degree
Expand Down Expand Up @@ -85,4 +79,10 @@ void drawCube()
uView.line(p2x[7],p2y[7],p2x[4],p2y[4]);
uView.line(p2x[3],p2y[3],p2x[7],p2y[7]);
uView.display();
}
}

void loop()
{
drawCube();
delay(ROTATION_SPEED);
}
14 changes: 9 additions & 5 deletions examples/MicroViewDemo/MicroViewDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/***********************************************************
* If you are using Platformio, install the Time library with
* pio lib install "Time"
************************************************************/

#include <MicroView.h>
#include <Time.h>

Expand All @@ -31,7 +37,7 @@ void setup() {
uView.clear(PAGE); // erase the memory buffer, when next uView.display() is called, the OLED will be cleared.
}

void displayConnect(char * value, char * text) {
void displayConnect(const char * value, const char * text) {
int y=0;
uView.clear(PAGE);
uView.setCursor(0,y);
Expand All @@ -47,7 +53,7 @@ void displayConnect(char * value, char * text) {
uView.display();
}

void displayRemove(char * text) {
void displayRemove(const char * text) {
int y=0;
uView.clear(PAGE);
uView.setCursor(0,y);
Expand Down Expand Up @@ -127,7 +133,7 @@ void drawPin(int pin) {
}

void fromPinToPin(int pin1, int pin2) {
int x1,y1,x2,y2;
int x1, y1, x2;
x1=getXpos(pin1);
y1=getYpos(pin1);
x2=getXpos(pin2);
Expand Down Expand Up @@ -617,5 +623,3 @@ void loop() {
displayEnd();
uView.clear(PAGE);
}


Loading