increase ada callback queue size from 20 to 40

- fox adacallback queue overflow with large image
- fix issue with tft draw bitmap
This commit is contained in:
hathach committed 2019-08-26 23:55:58 +07:00
1 parent dee231e9bd
commit d81599d619
4 files changed
+25 -20

No files matched your search

+4 -4
View File
@@ -47,9 +47,6 @@ void adafruit_callback_task(void* arg)
ada_callback_t* cb_data;
if ( xQueueReceive(_cb_queue, (void*) &cb_data, portMAX_DELAY) )
{
// PRINT_HEX(cb_data);
// PRINT_HEX(cb_data->malloced_data);
const void* func = cb_data->callback_func;
uint32_t* args = cb_data->arguments;
@@ -85,7 +82,10 @@ void ada_callback_queue(ada_callback_t* cb_item)
xQueueSendFromISR(_cb_queue, (void*) &cb_item, NULL);
}else
{
xQueueSend(_cb_queue, (void*) &cb_item, CFG_CALLBACK_TIMEOUT);
if ( !xQueueSend(_cb_queue, (void*) &cb_item, CFG_CALLBACK_TIMEOUT) )
{
LOG_LV1("MEMORY", "AdaCallback run out of queue item, increase CFG_CALLBACK_QUEUE_LENGTH");
}
}
}
+1 -1
View File
@@ -43,7 +43,7 @@
#endif
#ifndef CFG_CALLBACK_QUEUE_LENGTH
#define CFG_CALLBACK_QUEUE_LENGTH 20
#define CFG_CALLBACK_QUEUE_LENGTH 40
#endif
#ifndef CFG_CALLBACK_TIMEOUT
@@ -68,8 +68,6 @@ BLEUart bleuart(1024*10);
uint16_t imageWidth = 0;
uint16_t imageHeight = 0;
uint16_t imageX = 0;
uint16_t imageY = 0;
uint32_t totalPixel = 0; // received pixel
@@ -172,6 +170,19 @@ void loop()
// Chop pixel number to multiple of image width
pixelNum = (pixelNum / imageWidth) * imageWidth;
#if 0
static uint32_t last_available = 0;
if ( last_available != bleuart.available() )
{
last_available = bleuart.available();
PRINT_INT(totalPixel);
PRINT_INT(last_available);
PRINT_INT(pixelNum);
Serial.println();
}
#endif
if ( pixelNum )
{
for ( uint16_t i=0; i < pixelNum; i++)
@@ -183,12 +194,8 @@ void loop()
color_buf[i] = ((red & 0xF8) << 8) | ((green & 0xFC) << 3) | ( blue >> 3);
}
tft.drawRGBBitmap(imageX, imageY, color_buf, imageWidth, imageHeight - imageY);
tft.drawRGBBitmap(0, totalPixel/imageWidth, color_buf, imageWidth, pixelNum/imageWidth);
totalPixel += pixelNum;
imageX = totalPixel % imageWidth;
imageY = totalPixel / imageWidth;
}
}
@@ -265,7 +272,6 @@ void bleuart_rx_callback(uint16_t conn_hdl)
tft.fillScreen(COLOR_BLACK);
tft.setCursor(0, 0);
imageX = imageY = 0;
}
}
@@ -468,12 +468,11 @@ void BLECharacteristic::_eventHandler(ble_evt_t* event)
{
ble_gatts_evt_write_t* request = &event->evt.gatts_evt.params.write;
LOG_LV2_BUFFER(NULL, request->data, request->len);
// Value write
if (request->handle == _handles.value_handle)
{
LOG_LV2("GATTS", "attr's value, uuid = 0x%04X", request->uuid.uuid);
LOG_LV2("GATTS", "attr's value, uuid = 0x%04X, len = %d", request->uuid.uuid, request->len);
LOG_LV2_BUFFER(NULL, request->data, request->len);
if (_wr_cb)
{
@@ -490,13 +489,13 @@ void BLECharacteristic::_eventHandler(ble_evt_t* event)
// CCCD write
if ( request->handle == _handles.cccd_handle )
{
LOG_LV2("GATTS", "attr's cccd");
uint16_t value;
memcpy(&value, request->data, 2);
LOG_LV1("GATTS", "attr's cccd = 0x%04X", value);
if (_cccd_wr_cb)
{
uint16_t value;
memcpy(&value, request->data, 2);
if ( _use_ada_cb.cccd_write )
{
ada_callback(NULL, 0, _cccd_wr_cb, conn_hdl, this, value);