このページでは

C

Qt Quick UltraliteのRTOSへの移植

Qt Quick UltraliteのRTOSプラットフォームへの移植は、本ガイドの他のセクションで紹介されているベアメタルプラットフォームと同様の手順に従います。以下のセクションでは、ベアメタルプラットフォームとの相違点の概要を説明します。

RTOS プラットフォーム上のQt Quick Ultralite アプリケーションは、Qul::Application::exec を使用して RTOS タスク/スレッドとして開始されます。この呼び出しは最終的にPlatformContext::exec につながり、そのプロセスのメインループとして動作します。これについては「 FreeRTOSQt Quick Ultralite を使用する」および「 ZephyrQt Quick Ultralite を使用する」のページで詳しく説明しています。

プラットフォーム移植ガイドで紹介されているプラットフォームAPIはすべて、プラットフォームが提供するサービスやAPIを使用するように適合させることができます。そのような適応の一例は、Qt Quick UltraliteのFreeRTOS ポートにおけるメモリ割り当てAPIで、OSによって提供されるAPIによって実装されるかもしれません。

extern void *pvPortMalloc(size_t xWantedSize);
void *qul_malloc(std::size_t size)
{
    return pvPortMalloc(size);
}

スレッドの降伏

RTOSが降伏をサポートしている場合、Qt Quick Ultralite RTOSスレッドを降伏させてコンピューティングリソースを解放することができます。降伏は以下の場所で呼び出すことができます:

  • メインループ内のexec() 関数内部
    void ExamplePlatform::exec()
    {
        while (true) {
            logFlush(); // Flush partially filled log buffer
            const uint64_t timestamp = this->update();
    
            if (timestamp > Platform::getPlatformInstance()->currentTimestamp()) {
                // The device may yield or go into sleep mode
            }
        }
    }
  • 降伏関数を呼び出すもう1つの適切な場所は、ディスプレイコントローラによってバックバッファが解放されるのを待つときです。
    static volatile bool waitingForBufferFlip = false;
    static uint32_t idleTimeWaitingForDisplay = 0;
    
    static void waitForBufferFlip()
    {
        // Has there already been a buffer flip?
        if (!waitingForBufferFlip)
            return;
        const uint64_t startTime = getPlatformInstance()->currentTimestamp();
        while (waitingForBufferFlip) {
            // The device may yield or go into sleep mode
        }
    
        idleTimeWaitingForDisplay = getPlatformInstance()->currentTimestamp() - startTime;
    }
    
    // Note: This line clearing waitingForBufferFlip will need to be moved to the
    // actual interrupt handler for the display available on the target platform.
    // It's needed to inform about when the buffer address used to scan out pixels
    // to the display has been updated, making the buffer free in order to start
    // drawing the next frame.
    void LCD_BufferFlipInterruptHandler()
    {
        waitingForBufferFlip = false;
    }

    また、次のリフレッシュ・インターバルがスケジュールされるまでに十分な時間がある場合に降伏させることも可能である。

    static void waitForRefreshInterval()
    {
        if (refreshCount < requestedRefreshInterval) {
            uint64_t startTime = getPlatformInstance()->currentTimestamp();
            while (refreshCount < requestedRefreshInterval) {
                // The device may yield or go into sleep mode
            }
            idleTimeWaitingForDisplay += getPlatformInstance()->currentTimestamp() - startTime;
        }
    
        refreshCount = 0;
    }

    waitForBufferFlip()waitForRefreshInterval() の詳細については、基本的なグラフィックスの実装のセクションを参照してください。

  • ハードウェア・プラットフォームがレイヤーをサポートしている場合、presentFrame() 関数で降伏させることができます。
    // This function has to replace your PlatformContext::presentFrame
    FrameStatistics presentFrame(const PlatformInterface::Screen *screen, const PlatformInterface::Rect &rect)
    {
        static unsigned int lastFrame = 0xffffffff;
        while (currentFrame == lastFrame) {
            // The device may yield or go into sleep mode
        }
        lastFrame = currentFrame;
    
        PlatformInterface::Rgba32 color = screen->backgroundColor();
        // HW_SetScreenBackgroundColor(color.red(), color.blue(), color.green());
    
        // No frame skip compensation implemented for layers
        return FrameStatistics();
    }

    詳細はこのセクションを参照してください。

FreeRTOS-特定の詳細

特定の詳細 app_commonフレームワークの使用を有効にするには、CMake コマンドラインオプションを使用してQUL_OS 変数を設定するか、プラットフォーム名に を含めます。 -DQUL_OS=FreeRTOSCMakeコマンドラインオプションを使用するか、プラットフォーム名にQUL_OS を含めてください:

<platform_name>-freertos

Zephyr-特定の詳細

Qt Quick Ultralite をZephyr を使ってプラットフォームに移植する方法の詳細については、 Zephyr ページでQt Quick Ultralite を使うを参照してください。

特定の Qt ライセンスの下で利用可能です。
詳細を確認してください。