MicroView Hookup Guide

Pages
Contributors: Joel_E_B, Marcus Schappi
Favorited Favorite 8

Example 3 - Widgets

This example introduces one of the MicroView's most powerful programming tools: the widget. This sketch uses both the MicroViewSlider and the MicroViewGauge. These widgets are useful for displaying information from sensors, timers or other hardware, such as buttons or knobs.

Copy the following code, paste it into the Arduino IDE and click upload.

language:c
#include <MicroView.h>

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
}

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
    }
}

Once uploaded, you should see a slider widget and a gauge widget run through the values 0--100 in a repeated loop.

Check out the MicroView Class Reference page for more information on widgets.