Fixed some bugs when receiving large data.
This commit is contained in:
@@ -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,23 +171,40 @@ 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));
|
||||||
|
|
||||||
uint16_t* line = decodedimage;
|
if(decodedimage==NULL) { //not enough free space to decode image in memory
|
||||||
for (y=1; y<height-1; y++)
|
//decode & render image pixel by pixel
|
||||||
{
|
uint16_t* line = decodedimage;
|
||||||
//line = (unsigned int *)img.scanLine(y-1);
|
for (y=1; y<height-1; y++)
|
||||||
frame++;
|
|
||||||
for (x=1; x<width-1; x++, frame++)
|
|
||||||
{
|
{
|
||||||
interpolateBayer(width, x, y, frame, &r, &g, &b);
|
frame++;
|
||||||
//*line++ = (0xff<<24) | (r<<16) | (g<<8) | (b<<0);
|
for (x=1; x<width-1; x++, frame++)
|
||||||
*line++ = RGB(r,g,b);
|
{
|
||||||
}
|
interpolateBayer(width, x, y, frame, &r, &g, &b);
|
||||||
frame++;
|
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);
|
tft_draw_bitmap_unscaled(0,0,width-2,height-2,decodedimage);
|
||||||
|
|
||||||
|
free(decodedimage);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,3 +17,6 @@ void ll_system_process() {
|
|||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ll_system_toggle_led() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user