mirror of
https://github.com/geekammo/MicroView-Arduino-Library.git
synced 2026-02-20 19:41:22 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abacd6b7bc | ||
|
|
b577e9e538 | ||
|
|
ff388744a6 | ||
|
|
a7e091c2f9 | ||
|
|
91f965f1eb | ||
|
|
3c5c44fe31 | ||
|
|
90f8e8d606 | ||
|
|
73cf96e723 |
1717
MicroView.cpp
1717
MicroView.cpp
File diff suppressed because it is too large
Load Diff
17
MicroView.h
17
MicroView.h
@@ -110,11 +110,13 @@ public:
|
||||
MicroView(void) {};
|
||||
void begin(void);
|
||||
|
||||
#if ARDUINO >= 100
|
||||
//#if ARDUINO >= 100
|
||||
|
||||
virtual size_t write(uint8_t);
|
||||
#else
|
||||
virtual void write(uint8_t);
|
||||
#endif
|
||||
|
||||
//#else
|
||||
// virtual void write(uint8_t);
|
||||
//#endif
|
||||
|
||||
// RAW LCD functions
|
||||
void command(uint8_t c);
|
||||
@@ -202,7 +204,9 @@ public:
|
||||
void setMaxValue(int16_t max);
|
||||
void setMinValue(int16_t max);
|
||||
void setValue(int16_t val);
|
||||
virtual void draw(){};
|
||||
/** \brief Draw widget value overridden by child class. */
|
||||
virtual void draw(){};
|
||||
/** \brief Draw widget face overridden by child class. */
|
||||
virtual void drawFace(){};
|
||||
|
||||
private:
|
||||
@@ -257,6 +261,7 @@ private:
|
||||
|
||||
class MVSPIClass {
|
||||
public:
|
||||
/** \brief Transfer data byte via SPI port. */
|
||||
inline static byte transfer(byte _data);
|
||||
|
||||
// SPI Configuration methods
|
||||
@@ -291,4 +296,4 @@ void MVSPIClass::detachInterrupt() {
|
||||
|
||||
|
||||
extern MicroView uView;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
65
README.md
65
README.md
@@ -16,7 +16,7 @@ Arduino library for MicroView.
|
||||
2. cd libraries
|
||||
3. mkdir MicroView
|
||||
4. cd MicroView
|
||||
5. git clone git@github.com:geekammo/microview.git .
|
||||
5. git clone https://github.com/geekammo/MicroView-Arduino-Library.git .
|
||||
6. Start Arduino IDE.
|
||||
7. MicroView example is located at, File--->Example--->MicroView--->MicroViewDemo
|
||||
|
||||
@@ -25,12 +25,12 @@ Arduino library for MicroView.
|
||||
#include <MicroView.h>
|
||||
|
||||
void setup() {
|
||||
uView.begin();
|
||||
uView.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
uView.print("HelloWorld");
|
||||
uView.display(); // display current page buffer
|
||||
uView.print("HelloWorld");
|
||||
uView.display(); // display current page buffer
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
@@ -39,18 +39,18 @@ void loop() {
|
||||
#include <MicroView.h>
|
||||
|
||||
void setup() {
|
||||
uView.begin();
|
||||
uView.clear(PAGE); // clear the page buffer
|
||||
uView.begin();
|
||||
uView.clear(PAGE); // clear the page buffer
|
||||
}
|
||||
|
||||
void loop() {
|
||||
uView.line(0,0,64,48);
|
||||
uView.circle(32,24,10);
|
||||
uView.rect(10,10,20,20);
|
||||
uView.pixel(50,5);
|
||||
uView.setCursor(0,40);
|
||||
uView.print(" MicroView");
|
||||
uView.display(); // display current page buffer
|
||||
uView.line(0,0,64,48);
|
||||
uView.circle(32,24,10);
|
||||
uView.rect(10,10,20,20);
|
||||
uView.pixel(50,5);
|
||||
uView.setCursor(0,40);
|
||||
uView.print(" MicroView");
|
||||
uView.display(); // display current page buffer
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
@@ -61,18 +61,18 @@ void loop() {
|
||||
MicroViewWidget *widget,*widget2;
|
||||
|
||||
void setup() {
|
||||
uView.begin();
|
||||
uView.clear(PAGE);
|
||||
widget= new MicroViewGauge(32,30,0,100); // draw Gauge widget at x=32,y=30,min=0, max=100
|
||||
widget2= new MicroViewSlider(0,0,0,100); // draw Slider widget at x=0,y=0,min=0, max=100
|
||||
uView.begin();
|
||||
uView.clear(PAGE);
|
||||
widget= new MicroViewGauge(32,30,0,100); // draw Gauge widget at x=32,y=30,min=0, max=100
|
||||
widget2= new MicroViewSlider(0,0,0,100); // draw Slider widget at x=0,y=0,min=0, max=100
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for(int i=0; i<=100;i++) {
|
||||
widget->setValue(i); // give a value to widget
|
||||
widget2->setValue(i);
|
||||
uView.display(); // display current page buffer
|
||||
}
|
||||
for(int i=0; i<=100;i++) {
|
||||
widget->setValue(i); // give a value to widget
|
||||
widget2->setValue(i);
|
||||
uView.display(); // display current page buffer
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
@@ -81,19 +81,32 @@ void loop() {
|
||||
#include <MicroView.h>
|
||||
|
||||
void setup() {
|
||||
uView.begin();
|
||||
uView.clear(PAGE);
|
||||
uView.begin();
|
||||
uView.clear(PAGE);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
uView.checkComm();
|
||||
uView.checkComm();
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
## History
|
||||
**v1.14b: 26th July 2014 by JP Liew
|
||||
* added Learning Kit Circuit Sketch
|
||||
|
||||
**v1.13b: 13th June 2014 by JP Liew**
|
||||
* added Sine Wave Example
|
||||
* inserted license to example code
|
||||
|
||||
**v1.12b: 11th June 2014 by JP Liew**
|
||||
* added comments for SparkFun Logo
|
||||
* added Rotating Cube example by Jim Lindblom @ SparkFun Electronics
|
||||
* changed git clone instruction to use https
|
||||
|
||||
**v1.11b: 9th June 2014 by JP Liew**
|
||||
* added simple tutorials for production sketch
|
||||
* modified OLED RESET pin to 7
|
||||
* added SparkFun Logo
|
||||
|
||||
**v1.10b: 22th April 2014 by JP Liew**
|
||||
* changed SS, RESET, DC pins to use weak internal pull-up resistors
|
||||
@@ -159,4 +172,4 @@ void loop() {
|
||||
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/>.
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
24
examples/LearningKit/Blink/Blink.ino
Normal file
24
examples/LearningKit/Blink/Blink.ino
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <MicroView.h>
|
||||
/*
|
||||
MicroView Blink
|
||||
Draw a circle for one second, then off for one second, repeatedly.
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
// the setup routine runs once when you press reset:
|
||||
void setup() {
|
||||
uView.begin();
|
||||
uView.clear(PAGE);
|
||||
}
|
||||
|
||||
// the loop routine runs over and over again forever:
|
||||
void loop() {
|
||||
uView.circleFill(32,24,10,WHITE,NORM);
|
||||
uView.display();
|
||||
delay(1000); // wait for a second
|
||||
|
||||
uView.circleFill(32,24,10,BLACK,NORM);
|
||||
uView.display();
|
||||
delay(1000); // wait for a second
|
||||
}
|
||||
14
examples/LearningKit/Circuit1/Circuit1.ino
Normal file
14
examples/LearningKit/Circuit1/Circuit1.ino
Normal file
@@ -0,0 +1,14 @@
|
||||
int LED = A3; // declare LED as pin A3 of MicroView
|
||||
|
||||
void setup()
|
||||
{
|
||||
pinMode(LED, OUTPUT); // set LED pin as OUTPUT
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
digitalWrite(LED, HIGH); // set LED pin HIGH voltage, LED will be on
|
||||
delay(1000); // delay 1000 ms
|
||||
digitalWrite(LED, LOW); // set LED pin LOW voltage, LED will be off
|
||||
delay(1000); // delay 1000 ms
|
||||
}
|
||||
23
examples/LearningKit/Circuit10/Circuit10.ino
Normal file
23
examples/LearningKit/Circuit10/Circuit10.ino
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <MicroView.h> // include MicroView library
|
||||
|
||||
int relayPin = 2; // set relayPin as pin 2 of Arduino
|
||||
|
||||
void setup() {
|
||||
uView.begin(); // start MicroView
|
||||
uView.clear(PAGE); // clear page
|
||||
pinMode(relayPin, OUTPUT); // initialize the digital pin as an output.
|
||||
}
|
||||
|
||||
void loop() {
|
||||
uView.setCursor(0,0); // set cursor at 0,0
|
||||
uView.print("YELLOW"); // print YELLOW text
|
||||
uView.display(); // display
|
||||
digitalWrite(relayPin, HIGH); // turn the RELAY ON (HIGH is the voltage level)
|
||||
delay(1000); // wait for a second
|
||||
|
||||
uView.setCursor(0,0);
|
||||
uView.print("RED ");
|
||||
uView.display();
|
||||
digitalWrite(relayPin, LOW); // turn the RELAY off by making the voltage LOW
|
||||
delay(1000); // wait for a second
|
||||
}
|
||||
20
examples/LearningKit/Circuit11/Circuit11.ino
Normal file
20
examples/LearningKit/Circuit11/Circuit11.ino
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <MicroView.h> // include MicroView library
|
||||
|
||||
MicroViewWidget *widget; // declare widget pointer
|
||||
|
||||
int sensorValue; // declare variable to store sensor value
|
||||
int sensorPin=A0; // declare sensor pin as A0 of Arduino
|
||||
|
||||
void setup() {
|
||||
uView.begin(); // start MicroView
|
||||
uView.clear(PAGE); // clear page
|
||||
widget = new MicroViewSlider(0,0,0,1024, WIDGETSTYLE1); // declare widget as slider
|
||||
pinMode(sensorPin, INPUT); // set sensor pin as INPUT
|
||||
}
|
||||
|
||||
void loop () {
|
||||
sensorValue=analogRead(sensorPin); // read and store sensor value
|
||||
widget->setValue(sensorValue); // set sensor value to widget
|
||||
uView.display(); // display widget
|
||||
delay(20); // delay 20 ms
|
||||
}
|
||||
26
examples/LearningKit/Circuit2/Circuit2.ino
Normal file
26
examples/LearningKit/Circuit2/Circuit2.ino
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <MicroView.h> // include MicroView library
|
||||
|
||||
MicroViewWidget *widget; // create widget pointer
|
||||
MicroViewWidget *widget2; // create widget pointer
|
||||
|
||||
int sensorPin = A1; // select the input pin for the potentiometer
|
||||
int sensorValue = 0; // variable to store the value coming from the sensor
|
||||
|
||||
void setup()
|
||||
{
|
||||
digitalWrite(sensorPin, HIGH); // Internal Pull-up
|
||||
pinMode(sensorPin, INPUT); // make pin as INPUT
|
||||
uView.begin(); // start MicroView
|
||||
uView.clear(PAGE); // clear page
|
||||
widget = new MicroViewSlider(0, 0, 0, 1024); // make widget as Slider
|
||||
widget2 = new MicroViewSlider(0, 20, 0, 1024, WIDGETSTYLE1); // make widget as Silder STYLE1
|
||||
uView.display(); // display the content in the screen buffer
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
sensorValue = analogRead(sensorPin); // read sensorPin
|
||||
widget->setValue(sensorValue); // set value of sensorPin to widget
|
||||
widget2->setValue(sensorValue); // set value of sensorPin to widget
|
||||
uView.display(); // display the content in the screen buffer
|
||||
}
|
||||
71
examples/LearningKit/Circuit3/Circuit3.ino
Normal file
71
examples/LearningKit/Circuit3/Circuit3.ino
Normal file
@@ -0,0 +1,71 @@
|
||||
#include <MicroView.h> // include MicroView library
|
||||
|
||||
MicroViewWidget *redWidget, *greenWidget, *blueWidget; // declare 3 widget pointers
|
||||
|
||||
int RED = 6; // declare RED LED pin 6
|
||||
int GREEN = 5; // declare GREEN LED pin 5
|
||||
int BLUE = 3; // declare BLUE LED pin 3
|
||||
int fadeStep = 10; // declare fading steps
|
||||
int dly=20; // declare delay
|
||||
|
||||
void setup()
|
||||
{
|
||||
uView.begin(); // start MicroView
|
||||
uView.clear(PAGE); // clear page
|
||||
redWidget = new MicroViewSlider(0,0,0,255); // declare RED widget as slider
|
||||
greenWidget = new MicroViewSlider(0,10,0,255); // declare GREEN widget as slider
|
||||
blueWidget = new MicroViewSlider(0,20,0,255); // declare BLUE widget as slider
|
||||
|
||||
pinMode(RED, OUTPUT); // set RED LED pin as OUTPUT
|
||||
pinMode(GREEN, OUTPUT); // set GREEN LED pin as OUTPUT
|
||||
pinMode(BLUE, OUTPUT); // set BLUE LED pin as OUTPUT
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
int i; // init i variable for general use
|
||||
// brightening
|
||||
for (i=0;i<=255;i+=fadeStep) { // step i from 0 to 255 by fadeSteps
|
||||
redWidget->setValue(i); // set brightness value for RED LED to widget
|
||||
uView.display(); // display the content of the screen buffer
|
||||
analogWrite(RED,i); // set brightness value for RED LED to the pin
|
||||
delay(dly);
|
||||
}
|
||||
// dimming
|
||||
for (i=255;i>=0;i-=fadeStep) { // step i from 255 to 0 by fadeSteps
|
||||
redWidget->setValue(i);
|
||||
uView.display();
|
||||
analogWrite(RED,i);
|
||||
delay(dly);
|
||||
}
|
||||
|
||||
// brightening
|
||||
for (i=0;i<=255;i+=fadeStep) {
|
||||
greenWidget->setValue(i);
|
||||
uView.display();
|
||||
analogWrite(GREEN,i);
|
||||
delay(dly);
|
||||
}
|
||||
// dimming
|
||||
for (i=255;i>=0;i-=fadeStep) {
|
||||
greenWidget->setValue(i);
|
||||
uView.display();
|
||||
analogWrite(GREEN,i);
|
||||
delay(dly);
|
||||
}
|
||||
|
||||
// brightening
|
||||
for (i=0;i<256;i+=fadeStep) {
|
||||
blueWidget->setValue(i);
|
||||
uView.display();
|
||||
analogWrite(BLUE,i);
|
||||
delay(dly);
|
||||
}
|
||||
// dimming
|
||||
for (i=255;i>=0;i-=fadeStep) {
|
||||
blueWidget->setValue(i);
|
||||
uView.display();
|
||||
analogWrite(BLUE,i);
|
||||
delay(dly);
|
||||
}
|
||||
}
|
||||
29
examples/LearningKit/Circuit4/Circuit4.ino
Normal file
29
examples/LearningKit/Circuit4/Circuit4.ino
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <MicroView.h> // include MicroView library
|
||||
|
||||
int buttonPin = A0; // push button pin
|
||||
int buttonState = 0; // variable to store the pushbutton status
|
||||
|
||||
void setup() {
|
||||
uView.begin(); // start MicroView
|
||||
uView.clear(PAGE); // clear page
|
||||
|
||||
pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input
|
||||
digitalWrite(buttonPin,HIGH); // set Internal pull-up
|
||||
}
|
||||
|
||||
void loop() {
|
||||
buttonState = digitalRead(buttonPin); // read the state of the pushbutton value
|
||||
|
||||
// check if the pushbutton is pressed.
|
||||
// if it is not pressed, the buttonState is HIGH:
|
||||
if (buttonState == HIGH) {
|
||||
uView.setCursor(0,0); // set cursor at 0,0
|
||||
uView.print("OFF"); // print OFF
|
||||
uView.display();
|
||||
}
|
||||
else {
|
||||
uView.setCursor(0,0);
|
||||
uView.print("ON ");
|
||||
uView.display();
|
||||
}
|
||||
}
|
||||
20
examples/LearningKit/Circuit5/Circuit5.ino
Normal file
20
examples/LearningKit/Circuit5/Circuit5.ino
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <MicroView.h> // include MicroView library
|
||||
|
||||
MicroViewWidget *widget; // declare widget pointer
|
||||
|
||||
int sensorPin = A2; // select the input pin for the photo resistor
|
||||
int sensorValue = 0; // variable to store the value coming from the sensor
|
||||
|
||||
void setup() {
|
||||
pinMode(sensorPin,INPUT); // set sensor pin as INPUT
|
||||
digitalWrite(sensorPin,HIGH); // set Internal pull-up
|
||||
uView.begin(); // start MicrView
|
||||
uView.clear(PAGE); // clear page
|
||||
widget = new MicroViewGauge(32,24,0,1023,WIDGETSTYLE1); // set widget as gauge STYLE1
|
||||
}
|
||||
|
||||
void loop() {
|
||||
sensorValue= analogRead(sensorPin); // read value from sensorPin
|
||||
widget->setValue(sensorValue); // set the sensorValue to the gauge widget
|
||||
uView.display(); // display the widget
|
||||
}
|
||||
23
examples/LearningKit/Circuit6/Circuit6.ino
Normal file
23
examples/LearningKit/Circuit6/Circuit6.ino
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <MicroView.h> // include MicroView library
|
||||
|
||||
MicroViewWidget *widget; // declare widget pointer
|
||||
|
||||
int sensorPin = A0; // select the input pin for the temperature sensor
|
||||
int sensorValue = 0; // variable to store the value coming from the sensor
|
||||
|
||||
void setup() {
|
||||
pinMode(sensorPin,INPUT); // set sensor pin as INPUT
|
||||
uView.begin(); // start MicroView
|
||||
uView.clear(PAGE); // clear page
|
||||
widget = new MicroViewGauge(32,24,0,255,WIDGETSTYLE1); // declare as gauge widget
|
||||
uView.drawChar(47,33,67); // Character C is ASCII code 67
|
||||
}
|
||||
|
||||
void loop() {
|
||||
sensorValue= analogRead(sensorPin); // read sensor pin value
|
||||
float voltage = sensorValue * 5.0; // voltage at pin in volt
|
||||
voltage /= 1024.0; // voltage = sensorValue x (5/1024)
|
||||
float temperatureC = (voltage - 0.5) * 100 ; // C = (voltage - 0.5) x 100
|
||||
widget->setValue(temperatureC); // set temperature value to the gauge
|
||||
uView.display(); // display gauge tick
|
||||
}
|
||||
38
examples/LearningKit/Circuit7/Circuit7.ino
Normal file
38
examples/LearningKit/Circuit7/Circuit7.ino
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <MicroView.h> // include MicroView library
|
||||
#include <Servo.h> // include Servo library
|
||||
|
||||
Servo servo; // declare servo object
|
||||
|
||||
void setup()
|
||||
{
|
||||
uView.begin(); // start MicroView
|
||||
uView.clear(PAGE); // clear page
|
||||
servo.attach(6); // servo control pin at D6
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
uView.setCursor(0,0); // set cursor to 0,0
|
||||
uView.print("Mid "); // display Mid
|
||||
uView.display();
|
||||
servo.write(90); // about 90 degree
|
||||
delay(2000); // delay 2 seconds
|
||||
|
||||
uView.setCursor(0,0);
|
||||
uView.print("Left ");
|
||||
uView.display();
|
||||
servo.write(20); // about 20 degree
|
||||
delay(2000);
|
||||
|
||||
uView.setCursor(0,0);
|
||||
uView.print("Mid ");
|
||||
uView.display();
|
||||
servo.write(90); // about 90 degree
|
||||
delay(2000);
|
||||
|
||||
uView.setCursor(0,0);
|
||||
uView.print("Right");
|
||||
uView.display();
|
||||
servo.write(160); // about 160 degree
|
||||
delay(2000);
|
||||
}
|
||||
82
examples/LearningKit/Circuit8/Circuit8.ino
Normal file
82
examples/LearningKit/Circuit8/Circuit8.ino
Normal file
@@ -0,0 +1,82 @@
|
||||
#include <MicroView.h>
|
||||
// adapted from SparkFun Inventor Kit https://www.sparkfun.com/products/12001
|
||||
// Please download the original source code for detail comment of the source code
|
||||
// http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Kits/SIK%20Guide%20Code.zip
|
||||
|
||||
const int buzzerPin = A0;
|
||||
const int songLength = 18;
|
||||
char notes[] = "cdfda ag cdfdg gf "; // a space represents a rest
|
||||
int beats[] = {1,1,1,1,1,1,4,4,2,1,1,1,1,1,1,4,4,2};
|
||||
|
||||
int tempo = 150;
|
||||
|
||||
void setup()
|
||||
{
|
||||
uView.begin();
|
||||
uView.clear(PAGE);
|
||||
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
|
||||
// corresponding frequency in Hz for the tone() function.
|
||||
|
||||
int i;
|
||||
const int numNotes = 8; // number of notes we're storing
|
||||
|
||||
// The following arrays hold the note characters and their
|
||||
// corresponding frequencies. The last "C" note is uppercase
|
||||
// to separate it from the first lowercase "c". If you want to
|
||||
// add more notes, you'll need to use unique characters.
|
||||
|
||||
// For the "char" (character) type, we put single characters
|
||||
// in single quotes.
|
||||
|
||||
char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
|
||||
int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523};
|
||||
|
||||
// Now we'll search through the letters in the array, and if
|
||||
// we find it, we'll return the frequency for that note.
|
||||
|
||||
for (i = 0; i < numNotes; i++) // Step through the notes
|
||||
{
|
||||
if (names[i] == note) // Is this the one?
|
||||
{
|
||||
return(frequencies[i]); // Yes! Return the frequency
|
||||
}
|
||||
}
|
||||
return(0); // We looked through everything and didn't find it,
|
||||
// but we still need to return a value, so return 0.
|
||||
}
|
||||
54
examples/LearningKit/Circuit9/Circuit9.ino
Normal file
54
examples/LearningKit/Circuit9/Circuit9.ino
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <MicroView.h> // include MicroView library
|
||||
|
||||
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) {
|
||||
byte mode;
|
||||
if(pin == 5 || pin == 6 || pin == 9 || pin == 10) {
|
||||
switch(divisor) {
|
||||
case 1: mode = 0x01; break;
|
||||
case 8: mode = 0x02; break;
|
||||
case 64: mode = 0x03; break;
|
||||
case 256: mode = 0x04; break;
|
||||
case 1024: mode = 0x05; break;
|
||||
default: return;
|
||||
}
|
||||
if(pin == 5 || pin == 6) {
|
||||
TCCR0B = TCCR0B & 0b11111000 | mode;
|
||||
} else {
|
||||
TCCR1B = TCCR1B & 0b11111000 | mode;
|
||||
}
|
||||
} else if(pin == 3 || pin == 11) {
|
||||
switch(divisor) {
|
||||
case 1: mode = 0x01; break;
|
||||
case 8: mode = 0x02; break;
|
||||
case 32: mode = 0x03; break;
|
||||
case 64: mode = 0x04; break;
|
||||
case 128: mode = 0x05; break;
|
||||
case 256: mode = 0x06; break;
|
||||
case 1024: mode = 0x7; break;
|
||||
default: return;
|
||||
}
|
||||
TCCR2B = TCCR2B & 0b11111000 | mode;
|
||||
}
|
||||
}
|
||||
10
examples/LearningKit/HelloWorld/HelloWorld.ino
Normal file
10
examples/LearningKit/HelloWorld/HelloWorld.ino
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <MicroView.h>
|
||||
|
||||
void setup() {
|
||||
uView.begin(); // start MicroView
|
||||
uView.clear(PAGE); // clear page
|
||||
uView.print("HelloWorld"); // display HelloWorld
|
||||
uView.display();
|
||||
}
|
||||
|
||||
void loop () {}
|
||||
88
examples/MicroViewCube/MicroViewCube.ino
Normal file
88
examples/MicroViewCube/MicroViewCube.ino
Normal file
@@ -0,0 +1,88 @@
|
||||
/******************************************************************************
|
||||
MicroViewCube.ino
|
||||
Rotating a 3-D Cube on the MicroView Display
|
||||
Jim Lindblom @ SparkFun Electronics
|
||||
Original Creation Date: June 9, 2014
|
||||
|
||||
This sketch uses the MicroView library to draw a 3-D projected
|
||||
cube, and rotate it along all three axes.
|
||||
|
||||
Development environment specifics:
|
||||
IDE: Arduino 1.0.5
|
||||
Hardware Platform: MicroView
|
||||
|
||||
This code is beerware; if you see me (or any other SparkFun employee) at the
|
||||
local, and you've found our code helpful, please buy us a round!
|
||||
|
||||
Distributed as-is; no warranty is given.
|
||||
******************************************************************************/
|
||||
#include <MicroView.h>
|
||||
|
||||
#define SHAPE_SIZE 600
|
||||
#define ROTATION_SPEED 0 // ms delay between cube draws
|
||||
|
||||
int SCREEN_WIDTH = uView.getLCDWidth();
|
||||
int SCREEN_HEIGHT = uView.getLCDHeight();
|
||||
|
||||
float d = 3;
|
||||
float px[] = { -d, d, d, -d, -d, d, d, -d };
|
||||
float py[] = { -d, -d, d, d, -d, -d, d, d };
|
||||
float pz[] = { -d, -d, -d, -d, d, d, d, d };
|
||||
|
||||
float p2x[] = {0,0,0,0,0,0,0,0};
|
||||
float p2y[] = {0,0,0,0,0,0,0,0};
|
||||
|
||||
float r[] = {0,0,0};
|
||||
|
||||
void setup()
|
||||
{
|
||||
uView.begin();
|
||||
uView.clear(ALL);
|
||||
uView.display();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
drawCube();
|
||||
delay(ROTATION_SPEED);
|
||||
}
|
||||
|
||||
void drawCube()
|
||||
{
|
||||
r[0]=r[0]+PI/180.0; // Add a degree
|
||||
r[1]=r[1]+PI/180.0; // Add a degree
|
||||
r[2]=r[2]+PI/180.0; // Add a degree
|
||||
if (r[0] >= 360.0*PI/180.0) r[0] = 0;
|
||||
if (r[1] >= 360.0*PI/180.0) r[1] = 0;
|
||||
if (r[2] >= 360.0*PI/180.0) r[2] = 0;
|
||||
|
||||
for (int i=0;i<8;i++)
|
||||
{
|
||||
float px2 = px[i];
|
||||
float py2 = cos(r[0])*py[i] - sin(r[0])*pz[i];
|
||||
float pz2 = sin(r[0])*py[i] + cos(r[0])*pz[i];
|
||||
|
||||
float px3 = cos(r[1])*px2 + sin(r[1])*pz2;
|
||||
float py3 = py2;
|
||||
float pz3 = -sin(r[1])*px2 + cos(r[1])*pz2;
|
||||
|
||||
float ax = cos(r[2])*px3 - sin(r[2])*py3;
|
||||
float ay = sin(r[2])*px3 + cos(r[2])*py3;
|
||||
float az = pz3-150;
|
||||
|
||||
p2x[i] = SCREEN_WIDTH/2+ax*SHAPE_SIZE/az;
|
||||
p2y[i] = SCREEN_HEIGHT/2+ay*SHAPE_SIZE/az;
|
||||
}
|
||||
|
||||
uView.clear(PAGE);
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
uView.line(p2x[i],p2y[i],p2x[i+1],p2y[i+1]);
|
||||
uView.line(p2x[i+4],p2y[i+4],p2x[i+5],p2y[i+5]);
|
||||
uView.line(p2x[i],p2y[i],p2x[i+4],p2y[i+4]);
|
||||
}
|
||||
uView.line(p2x[3],p2y[3],p2x[0],p2y[0]);
|
||||
uView.line(p2x[7],p2y[7],p2x[4],p2y[4]);
|
||||
uView.line(p2x[3],p2y[3],p2x[7],p2y[7]);
|
||||
uView.display();
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
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>
|
||||
#include <Time.h>
|
||||
|
||||
@@ -10,7 +27,7 @@ void setup() {
|
||||
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);
|
||||
delay(700);
|
||||
uView.clear(PAGE); // erase the memory buffer, when next uView.display() is called, the OLED will be cleared.
|
||||
}
|
||||
|
||||
@@ -341,7 +358,6 @@ void displayEnd() {
|
||||
delay(onDelay);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
int i;
|
||||
static double counter=99999;
|
||||
@@ -474,7 +490,6 @@ void loop() {
|
||||
uView.display();
|
||||
}
|
||||
|
||||
|
||||
onDelay=5;
|
||||
uView.setFontType(0);
|
||||
uView.setCursor(0,40);
|
||||
@@ -563,7 +578,7 @@ void loop() {
|
||||
counter--;
|
||||
uView.display();
|
||||
mSec=millis()+100;
|
||||
}ggggg
|
||||
}
|
||||
}
|
||||
uView.clear(PAGE);
|
||||
|
||||
|
||||
60
examples/MicroViewSineWave/MicroViewSineWave.ino
Normal file
60
examples/MicroViewSineWave/MicroViewSineWave.ino
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
MicroView Sine Wave Example
|
||||
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>
|
||||
|
||||
void setup() {
|
||||
uView.begin();
|
||||
uView.clear(PAGE);
|
||||
}
|
||||
|
||||
void loop () {
|
||||
int i;
|
||||
float rad,srad, x,y;
|
||||
int amp=20;
|
||||
int nPhase=360;
|
||||
|
||||
for(i=0; i<nPhase;i++) {
|
||||
x=i;
|
||||
x=x*0.017453;
|
||||
y= sin(x);
|
||||
y=y*amp; // amplitude
|
||||
y=y+24;
|
||||
x=(double)64/(double)nPhase;
|
||||
x=x*i;
|
||||
uView.pixel(x, y);
|
||||
uView.display();
|
||||
}
|
||||
|
||||
amp=10;
|
||||
nPhase=3*360;
|
||||
|
||||
for(i=0; i<nPhase;i++) {
|
||||
x=i;
|
||||
x=x*0.017453;
|
||||
y= cos(x);
|
||||
y=y*amp; // amplitude
|
||||
y=y+24;
|
||||
x=(double)64/(double)nPhase;
|
||||
x=x*i;
|
||||
uView.pixel(x, y);
|
||||
}
|
||||
|
||||
uView.display();
|
||||
delay(1500);
|
||||
uView.clear(PAGE);
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
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[4]; // declaring an array of 4 MicroViewWidget
|
||||
|
||||
Reference in New Issue
Block a user