Created
November 5, 2012 00:03
-
-
Save stravant/4014458 to your computer and use it in GitHub Desktop.
Large map draw function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// x, y, w, h specify what region of the screen to update. | |
// mZoom specifies the zoom level to draw the map at (1 = 1:1, 2 = only every other pixel is shown, etc) | |
// mOriginX/Y specifies what position on the map is currently at the screen's top right corner. | |
void draw(int32_t x, int32_t y, int32_t w, int32_t h) { | |
tft.setAddrWindow(x, y, x+w-1, y+h-1); | |
// | |
x *= mZoom; | |
y *= mZoom; | |
x += mOriginX; | |
y += mOriginY; | |
w *= mZoom; | |
h *= mZoom; | |
// | |
File file = SD.open("yeg-big.lcd"); | |
int32_t ImWidth = 2048; | |
int32_t ImHeight = 2048; | |
// | |
for (int32_t row = y; row < y+h; row += mZoom) { | |
uint16_t pixels[w*mZoom]; | |
file.seek((ImWidth*2)*row + 2*x); | |
file.read((uint8_t*)pixels, 2*w*mZoom); | |
for (int i = 0; i < w; i += mZoom) | |
tft.pushColor((pixels[i] >> 8) | (pixels[i] << 8)); | |
} | |
// | |
file.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment