18 Commits

Author SHA1 Message Date
jpliew
c86b454924 Merge pull request #15 from MLXXXp/add_keywords
Add keywords for existing functions
2014-08-27 10:15:11 +10:00
JP
ad46711f11 added version history 2014-08-27 10:14:36 +10:00
JP
34de240739 Merge branch 'emilong-circle-fill' 2014-08-27 10:09:04 +10:00
Scott Allen
6333d7c561 Removed duplicate "invert" keyword 2014-08-26 12:42:07 -04:00
Scott Allen
a5ed62704a Added keywords for existing functions
Added missing setColumnAddress, setPageAddress and data keywords.
Moved getScreenBuffer keyword to a more appropriate location.
2014-08-26 10:49:09 -04:00
Emil Ong
9573e7d6cc Fix clipping issue for circleFill when top is offscreen.
Replaced circleFill algorithm with a scanning algorithm. Also fixes
problem with XOR draw mode for filled circles.
2014-08-24 14:28:33 -07:00
Scott Allen
86784fe2a4 Merge branch 'master' of https://github.com/geekammo/MicroView-Arduino-Library 2014-08-21 10:55:24 -04:00
JP
cf97ba6c23 added Flashing Heart Example 2014-08-21 13:47:36 +10:00
Scott Allen
dfe47be3c8 Merge branch 'user_screen_access'
Change name from uView.screenBuffer() to uView.getScreenBuffer()
2014-08-20 17:26:56 -04:00
jpliew
db155041ff Merge pull request #13 from MLXXXp/user_screen_access
Add uView.screenBuffer() for access to screen RAM.
2014-08-20 20:46:43 +10:00
Scott Allen
ba0b779740 Changed name from screenBuffer to getScreenBuffer 2014-08-20 06:24:57 -04:00
Scott Allen
8eab806dec Merge branch 'master' of https://github.com/MLXXXp/MicroView-Arduino-Library 2014-08-19 11:07:37 -04:00
Scott Allen
9873dc728a Merge branch 'user_screen_access'
Added screenBuffer keyword
2014-08-19 11:02:34 -04:00
Scott Allen
72fdeeb77b Added screenBuffer keyword 2014-08-19 10:57:31 -04:00
Scott Allen
4a8583e2a6 Merge branch 'user_screen_access'
Add function to get a pointer to the start of the RAM screen buffer
for direct write and read access.
2014-08-19 10:16:51 -04:00
Scott Allen
b0e4a9600f Add uView.screenBuffer() for access to screen RAM.
Returns a pointer to the start of the RAM screen buffer
for direct write and read access.
2014-08-19 10:01:51 -04:00
Scott Allen
e203d3b7cd Merge branch 'user_screen_access'
Allow users to gain direct write and read access to the RAM screen buffer.
2014-08-17 08:41:00 -04:00
Scott Allen
b91baf75f8 Add uView.screenBuffer() for access to screen RAM.
Returns a pointer the the start of the RAM screen buffer
for direct write and read access.
2014-08-16 21:56:47 -04:00
5 changed files with 155 additions and 31 deletions

View File

@@ -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;
}
}
}
}
@@ -904,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.

View File

@@ -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);

View File

@@ -92,6 +92,12 @@ 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

View 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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, 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);
}

View File

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