Skip to content

Commit

Permalink
added getpixel
Browse files Browse the repository at this point in the history
  • Loading branch information
ladyada committed Jan 12, 2011
1 parent 14dcd23 commit fa79812
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 14 additions & 5 deletions ST7565/ST7565.cpp
Expand Up @@ -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++;
}
}
Expand Down Expand Up @@ -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;
}


Expand Down Expand Up @@ -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);
}


Expand Down
1 change: 1 addition & 0 deletions ST7565/ST7565.h
Expand Up @@ -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,
Expand Down

0 comments on commit fa79812

Please sign in to comment.