Skip to content

Commit c4d8546

Browse files
author
Adafruit Adabot
committed
more resizability
1 parent a8ea278 commit c4d8546

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

M4_Eyes/file.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,13 @@ void loadConfig(char *filename) {
294294
// purpose, because displacement effect looks worst at its extremes...this
295295
// allows the pupil to move close to the edge of the display while keeping
296296
// a few pixels distance from the displacement limits.
297-
if(!eyeRadius) eyeRadius = 125;
297+
if(!eyeRadius) eyeRadius = DISPLAY_SIZE/2 + 5;
298298
else eyeRadius = abs(eyeRadius);
299299
eyeDiameter = eyeRadius * 2;
300300
eyelidIndex &= 0xFF; // From table: learn.adafruit.com/assets/61921
301301
eyelidColor = eyelidIndex * 0x0101; // Expand eyelidIndex to 16-bit RGB
302302

303-
if(!irisRadius) irisRadius = 60; // Size in screen pixels
303+
if(!irisRadius) irisRadius = DISPLAY_SIZE/4; // Size in screen pixels
304304
else irisRadius = abs(irisRadius);
305305
slitPupilRadius = abs(slitPupilRadius);
306306
if(slitPupilRadius > irisRadius) slitPupilRadius = irisRadius;
@@ -329,8 +329,8 @@ ImageReturnCode loadEyelid(char *filename,
329329
return IMAGE_ERR_FILE_NOT_FOUND;
330330
}
331331

332-
memset(minArray, init, 240); // Fill eyelid arrays with init value to
333-
memset(maxArray, init, 240); // mark 'no eyelid data for this column'
332+
memset(minArray, init, DISPLAY_SIZE); // Fill eyelid arrays with init value to
333+
memset(maxArray, init, DISPLAY_SIZE); // mark 'no eyelid data for this column'
334334

335335
// This is the "booster seat" described in m4eyes.ino
336336
if(reader->bmpDimensions(filename, &w, &h) == IMAGE_SUCCESS) {
@@ -353,16 +353,16 @@ ImageReturnCode loadEyelid(char *filename,
353353
uint8_t white = (!palette || (palette[1] > palette[0]));
354354
int x, y, ix, iy, sx1, sx2, sy1, sy2;
355355
// Center/clip eyelid image with respect to screen...
356-
sx1 = (240 - image.width()) / 2; // leftmost pixel, screen space
357-
sy1 = (240 - image.height()) / 2; // topmost pixel, screen space
356+
sx1 = (DISPLAY_SIZE - image.width()) / 2; // leftmost pixel, screen space
357+
sy1 = (DISPLAY_SIZE - image.height()) / 2; // topmost pixel, screen space
358358
sx2 = sx1 + image.width() - 1; // rightmost pixel, screen space
359359
sy2 = sy1 + image.height() - 1; // lowest pixel, screen space
360360
ix = -sx1; // leftmost pixel, image space
361361
iy = -sy1; // topmost pixel, image space
362362
if(sx1 < 0) sx1 = 0; // image wider than screen
363363
if(sy1 < 0) sy1 = 0; // image taller than screen
364-
if(sx2 > 239) sx2 = 239; // image wider than screen
365-
if(sy2 > 239) sy2 = 239; // image taller than screen
364+
if(sx2 > (DISPLAY_SIZE-1)) sx2 = DISPLAY_SIZE - 1; // image wider than screen
365+
if(sy2 > (DISPLAY_SIZE-1)) sy2 = DISPLAY_SIZE - 1; // image taller than screen
366366
if(ix < 0) ix = 0; // image narrower than screen
367367
if(iy < 0) iy = 0; // image shorter than screen
368368

@@ -384,8 +384,8 @@ ImageReturnCode loadEyelid(char *filename,
384384
if(miny != 255) {
385385
// Because of coordinate system used later (screen rotated),
386386
// min/max and Y coordinates are flipped before storing...
387-
maxArray[x] = 239 - miny;
388-
minArray[x] = 239 - maxy;
387+
maxArray[x] = DISPLAY_SIZE - 1 - miny;
388+
minArray[x] = DISPLAY_SIZE - 1 - maxy;
389389
}
390390
}
391391
} else {

0 commit comments

Comments
 (0)