diff --git a/esp32/examples/ttgo_demo/main/app_screen.cpp b/esp32/examples/ttgo_demo/main/app_screen.cpp index 48de093..edcb8d8 100644 --- a/esp32/examples/ttgo_demo/main/app_screen.cpp +++ b/esp32/examples/ttgo_demo/main/app_screen.cpp @@ -237,10 +237,8 @@ static UINT tjd_output( } } - // ESP_LOGI(TAG, "x1:%d y1:%d x2:%d y2:%d\n", dleft, dtop, dright, dbottom); - tft->transmitCmdData(LCD_CASET, MAKEWORD(dleft >> 8, dleft & 0xFF, dright >> 8, dright & 0xFF)); - tft->transmitCmdData(LCD_PASET, MAKEWORD(dtop >> 8, dtop & 0xFF, dbottom >> 8, dbottom & 0xFF)); - tft->transmitCmd(LCD_RAMWR); // write to RAM + //ESP_LOGI(TAG, "x1:%d x2:%d y1:%d y2:%d\n", dleft, dright, dtop, dbottom); + tft->setAddrWindow(dleft, dtop, dright, dbottom); uint16_t *p = (uint16_t *)malloc(sizeof(uint16_t) * len); if (!p) { @@ -250,7 +248,7 @@ static UINT tjd_output( for (uint32_t i = 0; i < len; i++) { p[i] = tft->color565(dev->linbuf[dev->linbuf_idx][i].r, dev->linbuf[dev->linbuf_idx][i].g, dev->linbuf[dev->linbuf_idx][i].b); } - tft->_fastSendBuf(p, len); + tft->_fastSendBuf(p, len, true); // TODO: Swapping bytes directly in the camera register could enhance display free(p); dev->linbuf_idx = ((dev->linbuf_idx + 1) & 1); @@ -450,7 +448,7 @@ void lvgl_lcd_hal_init() /*screen initialize*/ tft->invertDisplay(true); - tft->setRotation(0); + tft->setRotation(2); // rotation needed if camera is on the back of the device tft->fillScreen(COLOR_BLACK); lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ diff --git a/esp32/examples/ttgo_demo/main/main.cpp b/esp32/examples/ttgo_demo/main/main.cpp index 16f0754..fcb5acc 100644 --- a/esp32/examples/ttgo_demo/main/main.cpp +++ b/esp32/examples/ttgo_demo/main/main.cpp @@ -41,17 +41,20 @@ void demo_task(void *arg) { disp_infos(); while(true) { + auto start = esp_timer_get_time(); camera_fb_t *fb = esp_camera_fb_get(); if (!fb) { ESP_LOGE(TAG, "Camera capture failed"); } else { - TFT_jpg_image(CENTER, 0, 0, -1, NULL, fb->buf, fb->len); + TFT_jpg_image(CENTER, CENTER, 0, -1, NULL, fb->buf, fb->len); esp_camera_fb_return(fb); fb = NULL; } + ESP_LOGI(TAG, "time taken: %lld ms", (esp_timer_get_time() - start) / 1000); + #if 0 // TODO: next step.. Mat inputImage(fb->height, fb->width, CV_8UC2, fb->buf); // rgb565 is 2 channels of 8-bit unsigned Mat outputImage; @@ -103,6 +106,8 @@ void app_main() /* Display memory infos */ disp_infos(); + ESP_LOGI(TAG, "Display width = %d, height = %d", tft->width(), tft->height()); + /* Start the tasks */ xTaskCreatePinnedToCore(demo_task, "demo", 1024 * 9, nullptr, 24, nullptr, 0); } \ No newline at end of file