mirror of
https://github.com/geekammo/MicroView-Arduino-Library.git
synced 2026-02-20 11:31:24 +01:00
Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c86b454924 | ||
|
|
ad46711f11 | ||
|
|
34de240739 | ||
|
|
6333d7c561 | ||
|
|
a5ed62704a | ||
|
|
9573e7d6cc | ||
|
|
86784fe2a4 | ||
|
|
cf97ba6c23 | ||
|
|
dfe47be3c8 | ||
|
|
db155041ff | ||
|
|
ba0b779740 | ||
|
|
8eab806dec | ||
|
|
9873dc728a | ||
|
|
72fdeeb77b | ||
|
|
4a8583e2a6 | ||
|
|
b0e4a9600f | ||
|
|
9dba039aa5 | ||
|
|
e5e5ecb037 | ||
|
|
e203d3b7cd | ||
|
|
c07b86476a | ||
|
|
db2904c64e | ||
|
|
b91baf75f8 | ||
|
|
6208dcd106 | ||
|
|
1349942310 | ||
|
|
95626610e1 | ||
|
|
0b56edc962 | ||
|
|
4bbfea3cf2 | ||
|
|
0eeb47d20a | ||
|
|
fa93b3e21e | ||
|
|
78e7abeafa | ||
|
|
0d06e90e3d | ||
|
|
cc1d78384a | ||
|
|
77928f1b74 | ||
|
|
00a80911de | ||
|
|
b64d5e4417 |
241
MicroView.cpp
241
MicroView.cpp
@@ -591,7 +591,6 @@ void MicroView::circle(uint8_t x0, uint8_t y0, uint8_t radius, uint8_t color, ui
|
||||
pixel(x0 - y, y0 + x, color, mode);
|
||||
pixel(x0 + y, y0 - x, color, mode);
|
||||
pixel(x0 - y, y0 - x, color, mode);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,38 +607,44 @@ void MicroView::circleFill(uint8_t x0, uint8_t y0, uint8_t radius) {
|
||||
Draw filled circle with radius using color and mode at x,y of the screen buffer.
|
||||
*/
|
||||
void MicroView::circleFill(uint8_t x0, uint8_t y0, uint8_t radius, uint8_t color, uint8_t mode) {
|
||||
// TODO - - find a way to check for no overlapping of pixels so that XOR draw mode will work perfectly
|
||||
int8_t f = 1 - radius;
|
||||
int8_t ddF_x = 1;
|
||||
int8_t ddF_y = -2 * radius;
|
||||
int8_t x = 0;
|
||||
int8_t y = radius;
|
||||
|
||||
// Temporary disable fill circle for XOR mode.
|
||||
if (mode==XOR) return;
|
||||
|
||||
for (uint8_t i=y0-radius; i<=y0+radius; i++) {
|
||||
pixel(x0, i, color, mode);
|
||||
// Don't bother trying to draw something totally offscreen
|
||||
if (x0 - radius >= LCDWIDTH || y0 - radius >= LCDHEIGHT) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (x<y) {
|
||||
if (f >= 0) {
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
// High-level algorithm overview:
|
||||
// Scan horizontally from left to right, then top to bottom, checking if each pixel
|
||||
// is within the circle. We use uint16_t's because even the small screen squares beyond 8 bits.
|
||||
uint16_t radiusSq = radius * radius;
|
||||
|
||||
for (uint8_t i=y0-y; i<=y0+y; i++) {
|
||||
pixel(x0+x, i, color, mode);
|
||||
pixel(x0-x, i, color, mode);
|
||||
}
|
||||
for (uint8_t i=y0-x; i<=y0+x; i++) {
|
||||
pixel(x0+y, i, color, mode);
|
||||
pixel(x0-y, i, color, mode);
|
||||
}
|
||||
// Optimization: define the start and end onscreen
|
||||
uint16_t xStart = max(0, x0-radius);
|
||||
uint16_t xEnd = min(LCDWIDTH-1, x0+radius);
|
||||
uint16_t yStart = max(0, y0-radius);
|
||||
uint16_t yEnd = min(LCDHEIGHT-1, y0+radius);
|
||||
|
||||
// scan horizontally...
|
||||
for (uint16_t x = xStart; x <= xEnd; ++x) {
|
||||
// Optimization: Record where if we have intersected the circle on this vertical
|
||||
// scan. Once we have intersected, then don't intersect anymore, don't bother
|
||||
// drawing; we've exited the circle.
|
||||
bool intersected = false;
|
||||
|
||||
// Optimization: relative x squared only changes with the outer loop/the horizontal scan.
|
||||
int16_t rx2 = (x-x0) * (x-x0);
|
||||
|
||||
// Scan vertically...
|
||||
for (uint16_t y = yStart; y <= yEnd; ++y) {
|
||||
int16_t ry2 = (y-y0) * (y-y0);
|
||||
if (rx2 + ry2 <= radiusSq) {
|
||||
pixel(x, y, color, mode);
|
||||
intersected = true;
|
||||
}
|
||||
else if (intersected) {
|
||||
// We've left the circle. Move on to the next horizontal scan line.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -858,13 +863,26 @@ void MicroView::scrollStop(void){
|
||||
*/
|
||||
void MicroView::scrollRight(uint8_t start, uint8_t stop){
|
||||
if (stop<start) // stop must be larger or equal to start
|
||||
return;
|
||||
return;
|
||||
scrollStop(); // need to disable scrolling before starting to avoid memory corrupt
|
||||
command(RIGHTHORIZONTALSCROLL, 0);
|
||||
command(start, 0x7, stop); // scroll speed frames , TODO
|
||||
command(0x00, 0xFF, ACTIVATESCROLL);
|
||||
}
|
||||
|
||||
/** \brief Left scrolling.
|
||||
|
||||
Set row start to row stop on the OLED to scroll left. Refer to http://learn.microview.io/intro/general-overview-of-microview.html for explanation of the rows.
|
||||
*/
|
||||
void MicroView::scrollLeft(uint8_t start, uint8_t stop){
|
||||
if (stop<start) // stop must be larger or equal to start
|
||||
return;
|
||||
scrollStop(); // need to disable scrolling before starting to avoid memory corrupt
|
||||
command(LEFTHORIZONTALSCROLL, 0);
|
||||
command(start, 0x7, stop); // scroll speed frames , TODO
|
||||
command(0x00, 0xFF, ACTIVATESCROLL);
|
||||
}
|
||||
|
||||
/** \brief Vertical flip.
|
||||
|
||||
Flip the graphics on the OLED vertically.
|
||||
@@ -891,6 +909,14 @@ void MicroView::flipHorizontal(boolean flip) {
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Get pointer to screen buffer
|
||||
|
||||
Return a pointer to the start of the RAM screen buffer for direct access.
|
||||
*/
|
||||
uint8_t *MicroView::getScreenBuffer(void) {
|
||||
return screenmemory;
|
||||
}
|
||||
|
||||
/** \brief Parse command.
|
||||
|
||||
Command stored in serCmd array will be parsed to performed draw functions.
|
||||
@@ -1385,6 +1411,18 @@ void MicroViewWidget::setMinValue(int16_t min) { minValue=min; }
|
||||
*/
|
||||
void MicroViewWidget::setMaxValue(int16_t max) { maxValue=max; }
|
||||
|
||||
/** \brief Get the maximum possible print lenth of the value
|
||||
|
||||
Return the maximum number of characters that would be printed using printf("%d", value) for the current value range.
|
||||
*/
|
||||
uint8_t MicroViewWidget::getMaxValLen() {
|
||||
uint8_t minLen, maxLen;
|
||||
|
||||
maxLen = getInt16PrintLen(maxValue);
|
||||
minLen = getInt16PrintLen(minValue);
|
||||
return maxLen >= minLen ? maxLen : minLen;
|
||||
}
|
||||
|
||||
/** \brief Set current value.
|
||||
|
||||
The current value of the widget is set to the variable passed in.
|
||||
@@ -1432,11 +1470,7 @@ MicroViewSlider::MicroViewSlider(uint8_t newx, uint8_t newy, int16_t min, int16_
|
||||
Initialise the MicroViewSlider widget with style WIDGETSTYLE0 or WIDGETSTYLE1 or WIDGETSTYLE2 (like 0, but vertical) or WIDGETSTYLE3 (like 1, but vertical). If this list gets any longer, it might be better as a switch/case statement.
|
||||
*/
|
||||
MicroViewSlider::MicroViewSlider(uint8_t newx, uint8_t newy, int16_t min, int16_t max, uint8_t sty):MicroViewWidget(newx, newy, min, max) {
|
||||
if (sty==WIDGETSTYLE0) {
|
||||
style=0;
|
||||
totalTicks=30;
|
||||
}
|
||||
else if (sty==WIDGETSTYLE1) {
|
||||
if (sty==WIDGETSTYLE1) {
|
||||
style=1;
|
||||
totalTicks=60;
|
||||
}
|
||||
@@ -1448,7 +1482,7 @@ MicroViewSlider::MicroViewSlider(uint8_t newx, uint8_t newy, int16_t min, int16_
|
||||
style=3;
|
||||
totalTicks=40;
|
||||
}
|
||||
else { //unrecognized style, so use default
|
||||
else { // Use style 0 if specified or invalid
|
||||
style=0;
|
||||
totalTicks=30;
|
||||
}
|
||||
@@ -1464,71 +1498,32 @@ MicroViewSlider::MicroViewSlider(uint8_t newx, uint8_t newy, int16_t min, int16_
|
||||
Draw image/diagram representing the widget's face.
|
||||
*/
|
||||
void MicroViewSlider::drawFace() {
|
||||
uint8_t offsetX, offsetY, majorLine;
|
||||
uint8_t offsetX, offsetY, endOffset;
|
||||
offsetX=getX();
|
||||
offsetY=getY();
|
||||
|
||||
if(style==0)
|
||||
majorLine=4;
|
||||
else if (style==1)
|
||||
majorLine=7;
|
||||
else if (style==2)
|
||||
majorLine=3;
|
||||
else if (style==3)
|
||||
majorLine=5;
|
||||
|
||||
//Horizontal styles, style 0 or 1
|
||||
|
||||
if (style==0 || style==1) {
|
||||
// Draw major tickers
|
||||
for (uint8_t i=0; i<majorLine;i++) {
|
||||
uView.lineV(offsetX+1+(i*10), offsetY+3, 5);
|
||||
endOffset = offsetX + totalTicks + 2;
|
||||
// Draw minor ticks
|
||||
for (uint8_t i=offsetX+1; i<endOffset; i+=2) {
|
||||
uView.lineV(i, offsetY+5, 3);
|
||||
}
|
||||
// Draw minor tickers
|
||||
for (uint8_t i=0; i<4;i++) {
|
||||
uView.lineV(offsetX+3+(i*2), offsetY+5, 3);
|
||||
}
|
||||
for (uint8_t i=0; i<4;i++) {
|
||||
uView.lineV(offsetX+13+(i*2), offsetY+5, 3);
|
||||
}
|
||||
for (uint8_t i=0; i<4;i++) {
|
||||
uView.lineV(offsetX+23+(i*2), offsetY+5, 3);
|
||||
}
|
||||
|
||||
if(style==1) { //Longer line, more minor ticks
|
||||
for (uint8_t i=0; i<4;i++) {
|
||||
uView.lineV(offsetX+33+(i*2), offsetY+5, 3);
|
||||
}
|
||||
for (uint8_t i=0; i<4;i++) {
|
||||
uView.lineV(offsetX+43+(i*2), offsetY+5, 3);
|
||||
}
|
||||
for (uint8_t i=0; i<4;i++) {
|
||||
uView.lineV(offsetX+53+(i*2), offsetY+5, 3);
|
||||
}
|
||||
// Draw extensions for major ticks
|
||||
for (uint8_t i=offsetX+1; i<endOffset; i+=10) {
|
||||
uView.lineV(i, offsetY+3, 2);
|
||||
}
|
||||
}
|
||||
//Vertical styles, style 2 or 3
|
||||
else {
|
||||
// Draw major tickers
|
||||
for (uint8_t i=0; i<majorLine;i++) {
|
||||
uView.lineH(offsetX, offsetY+1+(i*10), 5);
|
||||
endOffset = offsetY + totalTicks + 2;
|
||||
// Draw minor ticks
|
||||
for (uint8_t i=offsetY+1; i<=endOffset; i+=2) {
|
||||
uView.lineH(offsetX, i, 3);
|
||||
}
|
||||
// Draw minor tickers
|
||||
for (uint8_t i=0; i<4;i++) {
|
||||
uView.lineH(offsetX, offsetY+3+(i*2), 3);
|
||||
}
|
||||
for (uint8_t i=0; i<4;i++) {
|
||||
uView.lineH(offsetX, offsetY+13+(i*2), 3);
|
||||
}
|
||||
|
||||
if(style==3) { //Explicit test for style
|
||||
for (uint8_t i=0; i<4;i++) {
|
||||
uView.lineH(offsetX, offsetY+23+(i*2), 3);
|
||||
}
|
||||
for (uint8_t i=0; i<4;i++) {
|
||||
uView.lineH(offsetX, offsetY+33+(i*2), 3);
|
||||
}
|
||||
|
||||
// Draw extensions for major ticks
|
||||
for (uint8_t i=offsetY+1; i<=endOffset; i+=10) {
|
||||
uView.lineH(offsetX+3, i, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1540,60 +1535,67 @@ void MicroViewSlider::drawFace() {
|
||||
void MicroViewSlider::draw() {
|
||||
uint8_t offsetX, offsetY;
|
||||
uint8_t tickPosition=0;
|
||||
char strBuffer[5];
|
||||
char strBuffer[7];
|
||||
char formatStr[] = "%1d";
|
||||
|
||||
formatStr[1] = '0' + getMaxValLen(); // Set the field width for the value range
|
||||
|
||||
offsetX=getX();
|
||||
offsetY=getY();
|
||||
|
||||
if (needFirstDraw) {
|
||||
tickPosition= (((float)(prevValue-getMinValue())/(float)(getMaxValue()-getMinValue()))*totalTicks);
|
||||
if (style==0 || style==1){ //Horizontal
|
||||
tickPosition = ((float)(uint16_t)(prevValue-getMinValue())/(float)(uint16_t)(getMaxValue()-getMinValue()))*totalTicks;
|
||||
uView.lineH(offsetX+tickPosition,offsetY, 3, WHITE, XOR);
|
||||
uView.pixel(offsetX+1+tickPosition,offsetY+1, WHITE, XOR);
|
||||
}
|
||||
else { //Vertical
|
||||
tickPosition = ((float)(uint16_t)(getMaxValue()-prevValue)/(float)(uint16_t)(getMaxValue()-getMinValue()))*totalTicks;
|
||||
uView.lineV(offsetX+7, offsetY+tickPosition, 3, WHITE, XOR);
|
||||
uView.pixel(offsetX+6, offsetY+1+tickPosition, WHITE, XOR);
|
||||
}
|
||||
|
||||
sprintf(strBuffer,"%4d", prevValue); // we need to force 4 digit so that blank space will cover larger value
|
||||
sprintf(strBuffer, formatStr, prevValue); // print with fixed width so that blank space will cover larger value
|
||||
needFirstDraw=false;
|
||||
}
|
||||
else {
|
||||
// Draw previous pointer in XOR mode to erase it
|
||||
tickPosition= (((float)(prevValue-getMinValue())/(float)(getMaxValue()-getMinValue()))*totalTicks);
|
||||
if (style==0 || style==1){ //Horizontal
|
||||
tickPosition = ((float)(uint16_t)(prevValue-getMinValue())/(float)(uint16_t)(getMaxValue()-getMinValue()))*totalTicks;
|
||||
uView.lineH(offsetX+tickPosition,offsetY, 3, WHITE, XOR);
|
||||
uView.pixel(offsetX+1+tickPosition,offsetY+1, WHITE, XOR);
|
||||
}
|
||||
else { //Vertical
|
||||
tickPosition = ((float)(uint16_t)(getMaxValue()-prevValue)/(float)(uint16_t)(getMaxValue()-getMinValue()))*totalTicks;
|
||||
uView.lineV(offsetX+7, offsetY+tickPosition, 3, WHITE, XOR);
|
||||
uView.pixel(offsetX+6, offsetY+1+tickPosition, WHITE, XOR);
|
||||
}
|
||||
|
||||
// Draw current pointer
|
||||
tickPosition= (((float)(getValue()-getMinValue())/(float)(getMaxValue()-getMinValue()))*totalTicks);
|
||||
if (style==0 || style==1){ //Horizontal
|
||||
tickPosition = ((float)(uint16_t)(getValue()-getMinValue())/(float)(uint16_t)(getMaxValue()-getMinValue()))*totalTicks;
|
||||
uView.lineH(offsetX+tickPosition,offsetY, 3, WHITE, XOR);
|
||||
uView.pixel(offsetX+1+tickPosition,offsetY+1, WHITE, XOR);
|
||||
}
|
||||
else { //Vertical
|
||||
tickPosition = ((float)(uint16_t)(getMaxValue()-getValue())/(float)(uint16_t)(getMaxValue()-getMinValue()))*totalTicks;
|
||||
uView.lineV(offsetX+7, offsetY+tickPosition, 3, WHITE, XOR);
|
||||
uView.pixel(offsetX+6, offsetY+1+tickPosition, WHITE, XOR);
|
||||
}
|
||||
|
||||
sprintf(strBuffer,"%4d", getValue()); // we need to force 4 digit so that blank space will cover larger value
|
||||
sprintf(strBuffer, formatStr, getValue()); // print with fixed width so that blank space will cover larger value
|
||||
prevValue=getValue();
|
||||
}
|
||||
|
||||
// Draw value
|
||||
if(style==0)
|
||||
uView.setCursor(offsetX+34,offsetY+1);
|
||||
else if (style==1)
|
||||
uView.setCursor(offsetX,offsetY+10);
|
||||
if (style==0)
|
||||
uView.setCursor(offsetX+totalTicks+4, offsetY+1);
|
||||
else if (style==1)
|
||||
uView.setCursor(offsetX, offsetY+10);
|
||||
else if (style==2)
|
||||
uView.setCursor(offsetX+1,offsetY+24);
|
||||
uView.setCursor(offsetX+1, offsetY+totalTicks+4);
|
||||
else //style==3
|
||||
uView.setCursor(offsetX+9,offsetY);
|
||||
uView.setCursor(offsetX+9, offsetY);
|
||||
|
||||
uView.print(strBuffer);
|
||||
}
|
||||
@@ -1677,45 +1679,51 @@ void MicroViewGauge::drawFace() {
|
||||
*/
|
||||
void MicroViewGauge::draw() {
|
||||
uint8_t offsetX, offsetY;
|
||||
uint8_t maxValLen, valOffset;
|
||||
float degreeSec, toSecX, toSecY;
|
||||
char strBuffer[7];
|
||||
char formatStr[] = "%1d"; // The 1 will be replaced later by the proper length
|
||||
|
||||
maxValLen = getMaxValLen();
|
||||
formatStr[1] = '0' + maxValLen; // Set the field width for the value range
|
||||
valOffset = maxValLen * 3 - 1; // Offset left of centre to print the value
|
||||
|
||||
char strBuffer[5];
|
||||
offsetX=getX();
|
||||
offsetY=getY();
|
||||
|
||||
if (needFirstDraw) {
|
||||
degreeSec = (((float)(prevValue-getMinValue())/(float)(getMaxValue()-getMinValue()))*240); // total 240 degree in the widget
|
||||
degreeSec = ((float)(uint16_t)(prevValue-getMinValue())/(float)(uint16_t)(getMaxValue()-getMinValue()))*240; // total 240 degree in the widget
|
||||
degreeSec = (degreeSec+150) * (PI/180); // 150 degree starting point
|
||||
toSecX = cos(degreeSec) * (radius / 1.2);
|
||||
toSecY = sin(degreeSec) * (radius / 1.2);
|
||||
uView.line(offsetX,offsetY,1+offsetX+toSecX,1+offsetY+toSecY, WHITE,XOR);
|
||||
sprintf(strBuffer,"%4d", prevValue); // we need to force 4 digit so that blank space will cover larger value
|
||||
sprintf(strBuffer, formatStr, prevValue); // print with fixed width so that blank space will cover larger value
|
||||
needFirstDraw=false;
|
||||
}
|
||||
else {
|
||||
// Draw previous pointer in XOR mode to erase it
|
||||
degreeSec = (((float)(prevValue-getMinValue())/(float)(getMaxValue()-getMinValue()))*240); // total 240 degree in the widget
|
||||
degreeSec = ((float)(uint16_t)(prevValue-getMinValue())/(float)(uint16_t)(getMaxValue()-getMinValue()))*240; // total 240 degree in the widget
|
||||
degreeSec = (degreeSec+150) * (PI/180);
|
||||
toSecX = cos(degreeSec) * (radius / 1.2);
|
||||
toSecY = sin(degreeSec) * (radius / 1.2);
|
||||
uView.line(offsetX,offsetY,1+offsetX+toSecX,1+offsetY+toSecY, WHITE,XOR);
|
||||
|
||||
// draw current pointer
|
||||
degreeSec = (((float)(getValue()-getMinValue())/(float)(getMaxValue()-getMinValue()))*240); // total 240 degree in the widget
|
||||
degreeSec = ((float)(uint16_t)(getValue()-getMinValue())/(float)(uint16_t)(getMaxValue()-getMinValue()))*240; // total 240 degree in the widget
|
||||
degreeSec = (degreeSec+150) * (PI/180); // 150 degree starting point
|
||||
toSecX = cos(degreeSec) * (radius / 1.2);
|
||||
toSecY = sin(degreeSec) * (radius / 1.2);
|
||||
uView.line(offsetX,offsetY,1+offsetX+toSecX,1+offsetY+toSecY, WHITE,XOR);
|
||||
|
||||
sprintf(strBuffer,"%4d", getValue()); // we need to force 4 digit so that blank space will cover larger value
|
||||
sprintf(strBuffer, formatStr, getValue()); // print with fixed width so that blank space will cover larger value
|
||||
prevValue=getValue();
|
||||
}
|
||||
|
||||
// Draw value
|
||||
if(style>0)
|
||||
uView.setCursor(offsetX-10,offsetY+10);
|
||||
if (style>0)
|
||||
uView.setCursor(offsetX-valOffset, offsetY+10);
|
||||
else
|
||||
uView.setCursor(offsetX-11,offsetY+11);
|
||||
uView.setCursor(offsetX-valOffset, offsetY+11);
|
||||
|
||||
uView.print(strBuffer);
|
||||
}
|
||||
@@ -1831,4 +1839,13 @@ void MVSPIClass::setClockDivider(uint8_t rate)
|
||||
MVSPIClass MVSPI;
|
||||
MicroView uView;
|
||||
|
||||
/** \brief Get the number of characters for a 16 bit signed value.
|
||||
|
||||
Return the number of characters that would be printed using printf("%d", x) for x being a signed 16 bit integer.
|
||||
*/
|
||||
uint8_t getInt16PrintLen(int16_t val) {
|
||||
char sbuf[7];
|
||||
|
||||
return sprintf(sbuf, "%d", val);
|
||||
}
|
||||
|
||||
|
||||
10
MicroView.h
10
MicroView.h
@@ -114,7 +114,7 @@
|
||||
#define DEACTIVATESCROLL 0x2E
|
||||
#define SETVERTICALSCROLLAREA 0xA3
|
||||
#define RIGHTHORIZONTALSCROLL 0x26
|
||||
#define LEFT_HORIZONTALSCROLL 0x27
|
||||
#define LEFTHORIZONTALSCROLL 0x27
|
||||
#define VERTICALRIGHTHORIZONTALSCROLL 0x29
|
||||
#define VERTICALLEFTHORIZONTALSCROLL 0x2A
|
||||
|
||||
@@ -192,6 +192,7 @@ public:
|
||||
uint8_t getLCDHeight(void);
|
||||
void setColor(uint8_t color);
|
||||
void setDrawMode(uint8_t mode);
|
||||
uint8_t *getScreenBuffer(void);
|
||||
|
||||
// Font functions
|
||||
uint8_t getFontWidth(void);
|
||||
@@ -239,6 +240,7 @@ public:
|
||||
void setMaxValue(int16_t max);
|
||||
void setMinValue(int16_t max);
|
||||
void setValue(int16_t val);
|
||||
uint8_t getMaxValLen();
|
||||
/** \brief Draw widget value overridden by child class. */
|
||||
virtual void draw(){};
|
||||
/** \brief Draw widget face overridden by child class. */
|
||||
@@ -259,7 +261,6 @@ public:
|
||||
MicroViewSlider(uint8_t newx, uint8_t newy, int16_t min, int16_t max, uint8_t sty);
|
||||
void draw();
|
||||
void drawFace();
|
||||
void reDraw();
|
||||
private:
|
||||
uint8_t totalTicks, style;
|
||||
int16_t prevValue;
|
||||
@@ -271,7 +272,6 @@ public:
|
||||
MicroViewGauge(uint8_t newx, uint8_t newy, int16_t min, int16_t max, uint8_t sty);
|
||||
void draw();
|
||||
void drawFace();
|
||||
void reDraw();
|
||||
private:
|
||||
uint8_t radius, style;
|
||||
int16_t prevValue;
|
||||
@@ -342,4 +342,8 @@ void MVSPIClass::detachInterrupt() {
|
||||
}
|
||||
|
||||
extern MicroView uView;
|
||||
|
||||
/** \brief Get the number of print characters for a 16 bit signed value. */
|
||||
uint8_t getInt16PrintLen(int16_t val);
|
||||
|
||||
#endif
|
||||
|
||||
18
README.md
18
README.md
@@ -92,6 +92,22 @@ void loop() {
|
||||
</code></pre>
|
||||
|
||||
## History
|
||||
**v1.20b: 27th August 2014 by Scott Allen, Emil Ong**
|
||||
* added Flashing Heart Example - JP
|
||||
* added getScreenBuffer() for access to screen RAM - Scott
|
||||
* added keywords for existing functions - Scott
|
||||
* fixed circleFill() - Emil
|
||||
|
||||
**v1.19b: 19th August 2014 by Scott Allen**
|
||||
* added uView.scrollLeft() function
|
||||
* simplified Silder Widget drawFace() function
|
||||
* added full signed 16 bit ranges for widgets
|
||||
* improved drawing for minor and major ticks
|
||||
|
||||
**v1.18b: 5th August 2014 by Scott Allen**
|
||||
* fixed compiler warning in MicroViewSlider
|
||||
* changed vertical slider direction.
|
||||
|
||||
**v1.17b: 4th August 2014 by JP Liew**
|
||||
* added reDraw() for MicroViewWidget class
|
||||
* removed Serial.begin() from uView.begin() so that user can have control
|
||||
@@ -104,7 +120,7 @@ void loop() {
|
||||
* improved lots of low level routines, Fast SPI
|
||||
* fixed some compilation warnings
|
||||
* reduced overdriving display inputs
|
||||
* added uVuew.end() to power off the display
|
||||
* added uView.end() to power off the display
|
||||
* improved speed of display() and clear() functions
|
||||
* fixed positionning of "3" on clock face
|
||||
|
||||
|
||||
101
examples/MicroViewFlashingHeart/MicroViewFlashingHeart.ino
Normal file
101
examples/MicroViewFlashingHeart/MicroViewFlashingHeart.ino
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
MicroView Arduino Flashing Heart Demo
|
||||
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>
|
||||
|
||||
const unsigned char logo [] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
||||
0xFF, 0xFF, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xFF, 0xFF,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0x00, 0x00,
|
||||
0x00, 0x00, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
|
||||
const unsigned char logo2 [] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
||||
0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8,
|
||||
0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F,
|
||||
0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
|
||||
void setup() {
|
||||
uView.begin();
|
||||
uView.clear(PAGE);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
unsigned char i,j;
|
||||
for (i=0; i<6; i++) {
|
||||
uView.setPageAddress(i);
|
||||
uView.setColumnAddress(0);
|
||||
for (j=0;j<0x40;j++) {
|
||||
uView.data(logo[i*0x40+j]);
|
||||
}
|
||||
}
|
||||
|
||||
delay(800);
|
||||
|
||||
for (i=0; i<6; i++) {
|
||||
uView.setPageAddress(i);
|
||||
uView.setColumnAddress(0);
|
||||
for (j=0;j<0x40;j++) {
|
||||
uView.data(logo2[i*0x40+j]);
|
||||
}
|
||||
}
|
||||
delay(150);
|
||||
}
|
||||
@@ -17,7 +17,6 @@ MicroViewGauge KEYWORD1
|
||||
#######################################
|
||||
|
||||
begin KEYWORD2
|
||||
invert KEYWORD2
|
||||
clear KEYWORD2
|
||||
invert KEYWORD2
|
||||
contrast KEYWORD2
|
||||
@@ -50,6 +49,10 @@ scrollVertLeft KEYWORD2
|
||||
scrollStop KEYWORD2
|
||||
flipVertical KEYWORD2
|
||||
flipHorizontal KEYWORD2
|
||||
setColumnAddress KEYWORD2
|
||||
setPageAddress KEYWORD2
|
||||
data KEYWORD2
|
||||
getScreenBuffer KEYWORD2
|
||||
|
||||
getX KEYWORD2
|
||||
getY KEYWORD2
|
||||
@@ -61,6 +64,7 @@ setMaxValue KEYWORD2
|
||||
setMinValue KEYWORD2
|
||||
setValue KEYWORD2
|
||||
draw KEYWORD2
|
||||
reDraw KEYWORD2
|
||||
drawFace KEYWORD2
|
||||
checkComm KEYWORD2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user