Permalink
Browse files

added getpixel

  • Loading branch information...
ladyada committed Jan 12, 2011
1 parent 14dcd23 commit fa79812e2349653278adb49a58d5cd90362a10f2
Showing with 15 additions and 5 deletions.
  1. +14 −5 ST7565/ST7565.cpp
  2. +1 −0 ST7565/ST7565.h
View
@@ -142,7 +142,7 @@ void ST7565::drawstring(uint8_t x, uint8_t line, char *c) {
void ST7565::drawchar(uint8_t x, uint8_t line, char c) {
for (uint8_t i =0; i<5; i++ ) {
- buffer[x + (line*128) ] = pgm_read_byte(font+(c*5)+i);
+ st7565_buffer[x + (line*128) ] = pgm_read_byte(font+(c*5)+i);
x++;
}
}
@@ -291,9 +291,18 @@ void ST7565::setpixel(uint8_t x, uint8_t y, uint8_t color) {
// x is which column
if (color)
- buffer[x+ (y/8)*128] |= _BV(7-(y%8));
+ st7565_buffer[x+ (y/8)*128] |= _BV(7-(y%8));
else
- buffer[x+ (y/8)*128] &= ~_BV(7-(y%8));
+ st7565_buffer[x+ (y/8)*128] &= ~_BV(7-(y%8));
+}
+
+
+// the most basic function, get a single pixel
+uint8_t ST7565::getpixel(uint8_t x, uint8_t y) {
+ if ((x >= LCDWIDTH) || (y >= LCDHEIGHT))
+ return 0;
+
+ return (st7565_buffer[x+ (y/8)*128] >> (7-(y%8))) & 0x1;
}
@@ -461,14 +470,14 @@ void ST7565::display(void) {
for(c = 0; c < 128; c++) {
//uart_putw_dec(c);
//uart_putchar(' ');
- st7565_data(buffer[(128*p)+c]);
+ st7565_data(st7565_buffer[(128*p)+c]);
}
}
}
// clear everything
void ST7565::clear(void) {
- memset(buffer, 0, 1024);
+ memset(st7565_buffer, 0, 1024);
}
View
@@ -86,6 +86,7 @@ class ST7565 {
void display();
void setpixel(uint8_t x, uint8_t y, uint8_t color);
+ uint8_t getpixel(uint8_t x, uint8_t y);
void fillcircle(uint8_t x0, uint8_t y0, uint8_t r,
uint8_t color);
void drawcircle(uint8_t x0, uint8_t y0, uint8_t r,

0 comments on commit fa79812

Please sign in to comment.