Re: µPhone, min mobiltelefon
Postat: 16 februari 2012, 12:38:45
Det blir ju helt klart lite svårt att "skriva" mail på den 

Svenskt forum för elektroniksnack.
https://elektronikforumet.com/forum/
Kod: Markera allt
//widthScaled is the width of the image on screen
//heightScaled is the height on the smallest side.
// |<wScale>|
// .-----,___ __
// | | ^ heightScaled
// | ___| __V
// '-----´
//
void putImageTransform(unsigned char xPos, unsigned char yPos, unsigned int widthScaled, unsigned int heightScaled, char *path, unsigned char direction) {
FIL imageFile;
unsigned char width, height, start, padding = 0, y, x;
unsigned short pixel_buff[98];
unsigned int tmp;
unsigned char pixelCntr = 0;
unsigned int scaleFactor = 0, scaleFactorX = 0, scaleFactorPixelIndex = 0, xReal, xRealStep;
if (!widthScaled)
return;
if (f_open(&imageFile, path, FA_READ))
return;
f_lseek(&imageFile, 0x12);
f_read(&imageFile, &width, 1, &tmp);
f_lseek(&imageFile, 0x16);
f_read(&imageFile, &height, 1, &tmp);
f_lseek(&imageFile, 0x0A);
f_read(&imageFile, &start, 1, &tmp);
f_lseek(&imageFile, start);
oledCommand(0xA0);
oledCommand(0x62);
oledCommand(0x15);
oledCommand(xPos);
oledCommand(xPos + widthScaled - 1);
oledCommand(0x75);
oledCommand(yPos);
oledCommand(yPos + height - 1);
oledCommand(0xA0);
oledCommand(0x63);
if (width & 1)
padding = 1;
OLED_CE = 0;
xReal = 0;
xRealStep = (widthScaled * 128) / (width);
scaleFactor = (128 - ((heightScaled * 128) / height)) / 2;
for (x = 0; x < width; x++) {
f_read(&imageFile, pixel_buff, (width + padding) * 2, &tmp);
xReal += xRealStep;
if (xReal >= 128) {
xReal -= 128;
if (direction)
scaleFactorX = scaleFactor * (width - x);
else
scaleFactorX = scaleFactor * x;
pixelCntr = 0;
scaleFactorPixelIndex = (width * 16384L) / (height * 128L - (scaleFactorX * 2));
for (y = 0; y < height; y++) {
if ((y * 128) < scaleFactorX)
oledData(0);
else if ((y * 128) < (height * 128 - scaleFactorX))
oledData(pixel_buff[(unsigned char) ((pixelCntr++ * scaleFactorPixelIndex) >> 7)]);
else
oledData(0);
}
}
}
OLED_CE = 1;
f_close(&imageFile);
oledCommand(0xA0);
oledCommand(0x62);
}
Kod: Markera allt
for (i = 0; i < 25; i++) {
oledLine(47, 0, 47, 48, 0);
putImageTransform(0, 0, (i * 2), (i * 2), "icons/pbook.bmp", 1);
putImageTransform((i * 2), 0, 48 - (i * 2), 48 - (i * 2), "icons/pbook.bmp", 0);
}