From 43c85541c8bd9256868bcc4cf5003043e907f0f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20T=C3=A1mara?= Date: Fri, 3 May 2019 23:36:01 -0500 Subject: [PATCH 1/4] Examples adapted in order to run flawlessly with Platformio --- examples/LearningKit/Circuit1/Circuit1.ino | 24 +- examples/LearningKit/Circuit8/Circuit8.ino | 63 +++-- examples/LearningKit/Circuit9/Circuit9.ino | 42 +-- .../MicroViewAnalogClock.ino | 75 ++--- examples/MicroViewCube/MicroViewCube.ino | 14 +- examples/MicroViewDemo/MicroViewDemo.ino | 14 +- examples/MicroViewPong/MicroViewPong.ino | 84 +++--- .../MicroViewSineWave/MicroViewSineWave.ino | 2 +- .../MicroViewWidgetDemo.ino | 261 +++++++++--------- 9 files changed, 299 insertions(+), 280 deletions(-) diff --git a/examples/LearningKit/Circuit1/Circuit1.ino b/examples/LearningKit/Circuit1/Circuit1.ino index b31ecf4..e97f6ac 100644 --- a/examples/LearningKit/Circuit1/Circuit1.ino +++ b/examples/LearningKit/Circuit1/Circuit1.ino @@ -1,14 +1,26 @@ -int LED = A3; // declare LED as pin A3 of MicroView +#include // 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() { - pinMode(LED, OUTPUT); // set LED pin as OUTPUT + 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() { - 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 + 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 } diff --git a/examples/LearningKit/Circuit8/Circuit8.ino b/examples/LearningKit/Circuit8/Circuit8.ino index a1db256..710d81d 100644 --- a/examples/LearningKit/Circuit8/Circuit8.ino +++ b/examples/LearningKit/Circuit8/Circuit8.ino @@ -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 @@ -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. -} \ No newline at end of file +} + +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 +} diff --git a/examples/LearningKit/Circuit9/Circuit9.ino b/examples/LearningKit/Circuit9/Circuit9.ino index e93a247..38a41a5 100644 --- a/examples/LearningKit/Circuit9/Circuit9.ino +++ b/examples/LearningKit/Circuit9/Circuit9.ino @@ -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) { @@ -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) { @@ -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; } -} \ No newline at end of file +} + +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 + } +} diff --git a/examples/MicroViewAnalogClock/MicroViewAnalogClock.ino b/examples/MicroViewAnalogClock/MicroViewAnalogClock.ino index 7fad138..c887299 100644 --- a/examples/MicroViewAnalogClock/MicroViewAnalogClock.ino +++ b/examples/MicroViewAnalogClock/MicroViewAnalogClock.ino @@ -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 @@ -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 @@ -54,11 +83,6 @@ void setup() drawFace(); } -void loop() -{ - drawTime(); -} - void drawTime() { static boolean firstDraw = false; @@ -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(); } diff --git a/examples/MicroViewCube/MicroViewCube.ino b/examples/MicroViewCube/MicroViewCube.ino index f0e9a6b..058a27d 100644 --- a/examples/MicroViewCube/MicroViewCube.ino +++ b/examples/MicroViewCube/MicroViewCube.ino @@ -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 @@ -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(); -} \ No newline at end of file +} + +void loop() +{ + drawCube(); + delay(ROTATION_SPEED); +} diff --git a/examples/MicroViewDemo/MicroViewDemo.ino b/examples/MicroViewDemo/MicroViewDemo.ino index bef5cec..c7ae7ce 100644 --- a/examples/MicroViewDemo/MicroViewDemo.ino +++ b/examples/MicroViewDemo/MicroViewDemo.ino @@ -15,6 +15,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + +/*********************************************************** +* If you are using Platformio, install the Time library with +* pio lib install "Time" +************************************************************/ + #include #include @@ -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); @@ -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); @@ -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); @@ -617,5 +623,3 @@ void loop() { displayEnd(); uView.clear(PAGE); } - - diff --git a/examples/MicroViewPong/MicroViewPong.ino b/examples/MicroViewPong/MicroViewPong.ino index f033e67..a6d74ad 100644 --- a/examples/MicroViewPong/MicroViewPong.ino +++ b/examples/MicroViewPong/MicroViewPong.ino @@ -62,13 +62,6 @@ float ballPosY = LCDHEIGHT / 2.0; float ballVelX = -1.0 * ballSpeedX; float ballVelY = 0; -void setup() -{ - initializeGraphics(); - initializeInput(); - displayGameStart(); -} - void resetGame() { player2Score = 0; @@ -94,6 +87,12 @@ void initializeInput() pinMode(player2Pin, INPUT); } +void renderString(int x, int y, String string) +{ + uView.setCursor(x, y); + uView.print(string); +} + void displayGameStart() { uView.clear(PAGE); @@ -103,26 +102,11 @@ void displayGameStart() delay(startDelay); } -void loop() -{ - updateGame(); - renderGame(); - - if (player1Score >= scoreToWin) - { - gameOver(true); - } - else if (player2Score >= scoreToWin) - { - gameOver(false); - } -} - -void updateGame() +void setup() { - updatePlayer1(); - updatePlayer2(); - updateBall(); + initializeGraphics(); + initializeInput(); + displayGameStart(); } float clampPaddlePosY(float paddlePosY) @@ -220,23 +204,18 @@ void updateBall() } } -void renderGame() +void updateGame() { - uView.clear(PAGE); - - renderScores(player1Score, player2Score); - renderPaddle(player1PosX, player1PosY); - renderPaddle(player2PosX, player2PosY); - renderBall(ballPosX, ballPosY); - - uView.display(); - delay(renderDelay); + updatePlayer1(); + updatePlayer2(); + updateBall(); } -void renderString(int x, int y, String string) + +void renderScores(int firstScore, int secondScore) { - uView.setCursor(x, y); - uView.print(string); + renderString(10, 0, String(firstScore)); + renderString(LCDWIDTH - 14, 0, String(secondScore)); } void renderPaddle(int x, int y) @@ -253,10 +232,17 @@ void renderBall(int x, int y) uView.circle(x, y, 2); } -void renderScores(int firstScore, int secondScore) +void renderGame() { - renderString(10, 0, String(firstScore)); - renderString(LCDWIDTH - 14, 0, String(secondScore)); + uView.clear(PAGE); + + renderScores(player1Score, player2Score); + renderPaddle(player1PosX, player1PosY); + renderPaddle(player2PosX, player2PosY); + renderBall(ballPosX, ballPosY); + + uView.display(); + delay(renderDelay); } void gameOver(bool didWin) @@ -290,3 +276,17 @@ void gameOver(bool didWin) displayGameStart(); } +void loop() +{ + updateGame(); + renderGame(); + + if (player1Score >= scoreToWin) + { + gameOver(true); + } + else if (player2Score >= scoreToWin) + { + gameOver(false); + } +} diff --git a/examples/MicroViewSineWave/MicroViewSineWave.ino b/examples/MicroViewSineWave/MicroViewSineWave.ino index 6309bc6..4f8cc01 100644 --- a/examples/MicroViewSineWave/MicroViewSineWave.ino +++ b/examples/MicroViewSineWave/MicroViewSineWave.ino @@ -24,7 +24,7 @@ void setup() { void loop () { int i; - float rad,srad, x,y; + float x,y; int amp=20; int nPhase=360; diff --git a/examples/MicroViewWidgetDemo/MicroViewWidgetDemo.ino b/examples/MicroViewWidgetDemo/MicroViewWidgetDemo.ino index 1eb5b78..e809376 100644 --- a/examples/MicroViewWidgetDemo/MicroViewWidgetDemo.ino +++ b/examples/MicroViewWidgetDemo/MicroViewWidgetDemo.ino @@ -32,6 +32,136 @@ void setup() { uView.begin(); } +// Function to update widget1 +void update1widget(int16_t val) { + widget1->setValue(val); +} + +// Function to update widget1 and widget2 +void update2widgets(int16_t val) { + widget1->setValue(val); + widget2->setValue(val); +} + +// Update function for Demo 8 +void customSlider0(int16_t val) { + widget1->setValue(val); + uView.setCursor(widget1->getX() + 34, widget1->getY() + 1); + uView.print("0x"); + if (val < 0x10) { // add leading 0 if necessary. Only 2 digits supported. + uView.print('0'); + } + uView.print(val, HEX); +} + +// Update function for Demo 9 +void customSlider1(int16_t val) { + widget1->setValue(val); + uint8_t offsetY = widget1->getY() - 10; + uint8_t offsetX = widget1->getX() + 14; + uView.setCursor(offsetX, offsetY); + uView.print(" "); // erase the previous value in case it's longer + // calculate the offset to centre the value + offsetX += ((widget1->getMaxValLen() - widget1->getValLen()) * 3); + uView.setCursor(offsetX, offsetY); + uView.print(val); +} + +// Update function for Demo 10 +void customSlider2(int16_t val) { + uView.setCursor(widget1->getX() + 1, widget1->getY() + 24); + widget1->drawNumValue(val); + // calculate to reverse the pointer direction + widget1->setValue((int16_t) ((int32_t) widget1->getMaxValue() + + (int32_t) widget1->getMinValue() - + (int32_t) val)); +} + +// Update function for Demo 11 +void customSlider3(int16_t val) { + int16_t maxVal = widget1->getMaxValue(); + uint16_t range = (uint16_t) (maxVal - widget1->getMinValue()); + uint8_t offsetX = widget1->getX() + 9; + + // erase previous value. + // pointer position is calculated the same way as the widget code. + uint8_t offsetY = (float)(uint16_t)(maxVal - prevVal) / (float)range * 40; + uView.setCursor(offsetX, offsetY); + uView.print(" "); // This is being lazy. Should calculate width for value. + + // draw new value + offsetY = (float)(uint16_t)(maxVal - val) / (float)range * 40; + uView.setCursor(offsetX, offsetY); + widget1->drawNumValue(val); + + widget1->setValue(val); +} + +// Update function for Demo 12 +void customGauge0(int16_t val) { + widget1->setValue(val); + + uView.setCursor(widget1->getX() - 17, widget1->getY() + 19); + uView.setFontType(1); + // add leading space if necessary, to right justify. + // only 2 digit (plus decimal) numbers are supported. + if (val < 100) { + uView.print(' '); + } + uView.print((float)val / 10, 1); + uView.setFontType(0); +} + +// Update function for Demo 13 +void customGauge1(int16_t val) { + widget1->setValue(val); + uView.setCursor(widget1->getX() - 2, widget1->getY() + 9); + uView.print((char)(val + 'A' - 1)); +} + +// Clear the screen buffer and draw the demo number in the corner +void demoNumber(int num) { + uView.clear(PAGE); + uView.setCursor(0, 0); + uView.print(num); + uView.print(":"); +} + +// Spin up, then down, through the values. +// +// For each value, call the update function and display the new screen. +void spin(int16_t lowVal, int16_t highVal, int16_t stepSize, + unsigned long stepDelay, void (*drawFunction)(int16_t val)) { + drawFunction(lowVal); + uView.display(); + prevVal = lowVal; + delay(1500); + + for (int16_t i = lowVal + stepSize; i <= highVal; i += stepSize) { + drawFunction(i); + uView.display(); + prevVal = i; + delay(stepDelay); + if ((i == 0) && (lowVal != 0)) { // pause briefly for a value of 0 + delay(750); + } + } + + delay(1500); + + for (int16_t i = highVal; i >= lowVal; i -= stepSize) { + drawFunction(i); + uView.display(); + prevVal = i; + delay(stepDelay); + if ((i == 0) && (lowVal != 0)) { // pause briefly for a value of 0 + delay(750); + } + } + + delay(1500); +} + void loop() { /* ==================== Demo 1 ==================== Horizontal slider style 0, with and without numeric value. @@ -221,134 +351,3 @@ void loop() { /* ================== end of loop() ================== */ } - -// Function to update widget1 -void update1widget(int16_t val) { - widget1->setValue(val); -} - -// Function to update widget1 and widget2 -void update2widgets(int16_t val) { - widget1->setValue(val); - widget2->setValue(val); -} - -// Update function for Demo 8 -void customSlider0(int16_t val) { - widget1->setValue(val); - uView.setCursor(widget1->getX() + 34, widget1->getY() + 1); - uView.print("0x"); - if (val < 0x10) { // add leading 0 if necessary. Only 2 digits supported. - uView.print('0'); - } - uView.print(val, HEX); -} - -// Update function for Demo 9 -void customSlider1(int16_t val) { - widget1->setValue(val); - uint8_t offsetY = widget1->getY() - 10; - uint8_t offsetX = widget1->getX() + 14; - uView.setCursor(offsetX, offsetY); - uView.print(" "); // erase the previous value in case it's longer - // calculate the offset to centre the value - offsetX += ((widget1->getMaxValLen() - widget1->getValLen()) * 3); - uView.setCursor(offsetX, offsetY); - uView.print(val); -} - -// Update function for Demo 10 -void customSlider2(int16_t val) { - uView.setCursor(widget1->getX() + 1, widget1->getY() + 24); - widget1->drawNumValue(val); - // calculate to reverse the pointer direction - widget1->setValue((int16_t) ((int32_t) widget1->getMaxValue() + - (int32_t) widget1->getMinValue() - - (int32_t) val)); -} - -// Update function for Demo 11 -void customSlider3(int16_t val) { - int16_t maxVal = widget1->getMaxValue(); - uint16_t range = (uint16_t) (maxVal - widget1->getMinValue()); - uint8_t offsetX = widget1->getX() + 9; - - // erase previous value. - // pointer position is calculated the same way as the widget code. - uint8_t offsetY = (float)(uint16_t)(maxVal - prevVal) / (float)range * 40; - uView.setCursor(offsetX, offsetY); - uView.print(" "); // This is being lazy. Should calculate width for value. - - // draw new value - offsetY = (float)(uint16_t)(maxVal - val) / (float)range * 40; - uView.setCursor(offsetX, offsetY); - widget1->drawNumValue(val); - - widget1->setValue(val); -} - -// Update function for Demo 12 -void customGauge0(int16_t val) { - widget1->setValue(val); - - uView.setCursor(widget1->getX() - 17, widget1->getY() + 19); - uView.setFontType(1); - // add leading space if necessary, to right justify. - // only 2 digit (plus decimal) numbers are supported. - if (val < 100) { - uView.print(' '); - } - uView.print((float)val / 10, 1); - uView.setFontType(0); -} - -// Update function for Demo 13 -void customGauge1(int16_t val) { - widget1->setValue(val); - uView.setCursor(widget1->getX() - 2, widget1->getY() + 9); - uView.print((char)(val + 'A' - 1)); -} - -// Clear the screen buffer and draw the demo number in the corner -void demoNumber(int num) { - uView.clear(PAGE); - uView.setCursor(0, 0); - uView.print(num); - uView.print(":"); -} - -// Spin up, then down, through the values. -// -// For each value, call the update function and display the new screen. -void spin(int16_t lowVal, int16_t highVal, int16_t stepSize, - unsigned long stepDelay, void (*drawFunction)(int16_t val)) { - drawFunction(lowVal); - uView.display(); - prevVal = lowVal; - delay(1500); - - for (int16_t i = lowVal + stepSize; i <= highVal; i += stepSize) { - drawFunction(i); - uView.display(); - prevVal = i; - delay(stepDelay); - if ((i == 0) && (lowVal != 0)) { // pause briefly for a value of 0 - delay(750); - } - } - - delay(1500); - - for (int16_t i = highVal; i >= lowVal; i -= stepSize) { - drawFunction(i); - uView.display(); - prevVal = i; - delay(stepDelay); - if ((i == 0) && (lowVal != 0)) { // pause briefly for a value of 0 - delay(750); - } - } - - delay(1500); -} - From 95586d5b0caaf08498e212ef3f290a5610ee345e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20T=C3=A1mara?= Date: Fri, 3 May 2019 23:57:59 -0500 Subject: [PATCH 2/4] Documentation referral to Platform and doc links update --- README.md | 4 +++- examples/LearningKit/Blink/Blink.ino | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c257279..885e941 100644 --- a/README.md +++ b/README.md @@ -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 --------------------------------- diff --git a/examples/LearningKit/Blink/Blink.ino b/examples/LearningKit/Blink/Blink.ino index ada6296..4998c83 100644 --- a/examples/LearningKit/Blink/Blink.ino +++ b/examples/LearningKit/Blink/Blink.ino @@ -1,4 +1,4 @@ -#include +#include /* MicroView Blink Draw a circle for one second, then off for one second, repeatedly. From 624dd9998cee49ffede446cad94d4c94cb0eb80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20T=C3=A1mara?= Date: Sat, 4 May 2019 00:04:52 -0500 Subject: [PATCH 3/4] Added needed Arduino Library with Platformio --- examples/LearningKit/Blink/Blink.ino | 2 +- examples/LearningKit/Circuit1/Circuit1.ino | 27 +++++++--------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/examples/LearningKit/Blink/Blink.ino b/examples/LearningKit/Blink/Blink.ino index 4998c83..d9a8f84 100644 --- a/examples/LearningKit/Blink/Blink.ino +++ b/examples/LearningKit/Blink/Blink.ino @@ -1,4 +1,4 @@ -#include +#include /* MicroView Blink Draw a circle for one second, then off for one second, repeatedly. diff --git a/examples/LearningKit/Circuit1/Circuit1.ino b/examples/LearningKit/Circuit1/Circuit1.ino index e97f6ac..b16372d 100644 --- a/examples/LearningKit/Circuit1/Circuit1.ino +++ b/examples/LearningKit/Circuit1/Circuit1.ino @@ -1,26 +1,15 @@ -#include // 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 +#include +int LED = A3; // declare LED as pin A3 of MicroView 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 + pinMode(LED, OUTPUT); // set LED pin as OUTPUT } 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 -} + 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 +} \ No newline at end of file From dc9db6790a49a32614833ac07211835df9c3fc40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20T=C3=A1mara?= Date: Sat, 4 May 2019 00:08:10 -0500 Subject: [PATCH 4/4] Fixed library import --- examples/LearningKit/Blink/Blink.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/LearningKit/Blink/Blink.ino b/examples/LearningKit/Blink/Blink.ino index d9a8f84..ada6296 100644 --- a/examples/LearningKit/Blink/Blink.ino +++ b/examples/LearningKit/Blink/Blink.ino @@ -1,4 +1,4 @@ -#include +#include /* MicroView Blink Draw a circle for one second, then off for one second, repeatedly.