Fixed some bugs when receiving large data.

This commit is contained in:
t-moe
2015-04-25 14:05:44 +02:00
parent 3d1e4b2ef2
commit 0858b0d2cb
8 changed files with 55 additions and 19 deletions

View File

@@ -3,7 +3,7 @@
#include "system.h"
#include "pixy.h"
#include <stdio.h>
#include <stdlib.h>
bool pixy_connected = false;
@@ -113,10 +113,10 @@ int pixy_frame_test() {
&videodata, // pointer to mem address for returned frame
END_IN_ARGS);
if(return_value==0) {
return_value = renderBA81(renderflags,xwidth,ywidth,size,videodata);
}
return return_value;
}
@@ -171,24 +171,41 @@ int renderBA81(uint8_t renderFlags, uint16_t width, uint16_t height, uint32_t fr
// don't render top and bottom rows, and left and rightmost columns because of color
// interpolation
//uint32_t decodedimage[(width-2)*(height-2)];
uint16_t decodedimage[(width-2)*(height-2)];
uint16_t* line = decodedimage;
for (y=1; y<height-1; y++)
{
//line = (unsigned int *)img.scanLine(y-1);
frame++;
for (x=1; x<width-1; x++, frame++)
{
interpolateBayer(width, x, y, frame, &r, &g, &b);
//*line++ = (0xff<<24) | (r<<16) | (g<<8) | (b<<0);
*line++ = RGB(r,g,b);
}
frame++;
}
tft_draw_bitmap_unscaled(0,0,width-2,height-2,decodedimage);
uint16_t* decodedimage = malloc(sizeof(uint16_t)*(width-2)*(height-2));
if(decodedimage==NULL) { //not enough free space to decode image in memory
//decode & render image pixel by pixel
uint16_t* line = decodedimage;
for (y=1; y<height-1; y++)
{
frame++;
for (x=1; x<width-1; x++, frame++)
{
interpolateBayer(width, x, y, frame, &r, &g, &b);
tft_draw_pixel(x-1,y-1,RGB(r,g,b));
}
frame++;
}
} else { //enough space
uint16_t* line = decodedimage;
for (y=1; y<height-1; y++)
{
//line = (unsigned int *)img.scanLine(y-1);
frame++;
for (x=1; x<width-1; x++, frame++)
{
interpolateBayer(width, x, y, frame, &r, &g, &b);
//*line++ = (0xff<<24) | (r<<16) | (g<<8) | (b<<0);
*line++ = RGB(r,g,b);
}
frame++;
}
tft_draw_bitmap_unscaled(0,0,width-2,height-2,decodedimage);
free(decodedimage);
}
return 0;
}

View File

@@ -4,3 +4,4 @@
bool ll_system_init();
void ll_system_delay(uint32_t msec);
void ll_system_process();
void ll_system_toggle_led();

View File

@@ -13,3 +13,7 @@ void system_delay(uint32_t msec) {
void system_process() {
ll_system_process();
}
void system_toggle_led() {
ll_system_toggle_led();
}

View File

@@ -4,3 +4,4 @@
bool system_init();
void system_delay(uint32_t msec);
void system_process();
void system_toggle_led();