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 "system.h"
#include "pixy.h" #include "pixy.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
bool pixy_connected = false; bool pixy_connected = false;
@@ -113,10 +113,10 @@ int pixy_frame_test() {
&videodata, // pointer to mem address for returned frame &videodata, // pointer to mem address for returned frame
END_IN_ARGS); END_IN_ARGS);
if(return_value==0) { if(return_value==0) {
return_value = renderBA81(renderflags,xwidth,ywidth,size,videodata); return_value = renderBA81(renderflags,xwidth,ywidth,size,videodata);
} }
return return_value; return return_value;
} }
@@ -171,8 +171,22 @@ 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 // don't render top and bottom rows, and left and rightmost columns because of color
// interpolation // interpolation
//uint32_t decodedimage[(width-2)*(height-2)]; //uint32_t decodedimage[(width-2)*(height-2)];
uint16_t decodedimage[(width-2)*(height-2)]; 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; uint16_t* line = decodedimage;
for (y=1; y<height-1; y++) for (y=1; y<height-1; y++)
{ {
@@ -189,6 +203,9 @@ int renderBA81(uint8_t renderFlags, uint16_t width, uint16_t height, uint32_t fr
tft_draw_bitmap_unscaled(0,0,width-2,height-2,decodedimage); tft_draw_bitmap_unscaled(0,0,width-2,height-2,decodedimage);
free(decodedimage);
}
return 0; return 0;
} }

View File

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

View File

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

View File

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

View File

@@ -856,6 +856,10 @@ int Chirp::realloc(uint32_t min)
min = m_bufSize+CRP_BUFSIZE; min = m_bufSize+CRP_BUFSIZE;
else else
min += CRP_BUFSIZE; min += CRP_BUFSIZE;
if(min==m_bufSize)
return CRP_RES_OK;
uint8_t *newbuf = new (std::nothrow) uint8_t[min]; uint8_t *newbuf = new (std::nothrow) uint8_t[min];
if (newbuf==NULL) if (newbuf==NULL)
return CRP_RES_ERROR_MEMORY; return CRP_RES_ERROR_MEMORY;

View File

@@ -64,3 +64,8 @@ void ll_system_process() {
void ll_system_delay(uint32_t msec) { void ll_system_delay(uint32_t msec) {
USB_OTG_BSP_mDelay(msec); USB_OTG_BSP_mDelay(msec);
} }
void ll_system_toggle_led() {
STM_EVAL_LEDToggle(LED6);
}

View File

@@ -111,6 +111,7 @@ usblink_open__close_and_exit:
usblink_open__exit: usblink_open__exit:
log("pixydebug: USBLink::open() returned %d\n", return_value); log("pixydebug: USBLink::open() returned %d\n", return_value);
usleep(100* 1000); //let pixy init pass
return return_value; return return_value;
} }

View File

@@ -17,3 +17,6 @@ void ll_system_process() {
QApplication::processEvents(); QApplication::processEvents();
} }
void ll_system_toggle_led() {
}