示例#1
0
static inline QString toString(double value, bool sign, int n = 1) {
	if (n <= 0)
		return toString(qRound(value), sign);
	QString ret;
	if (sign && value >= 0)
		ret = (value > 0 ? _LS("+") : _U8("±"));
	QByteArray fmt("%.");	fmt.reserve(10);
	fmt.append(QByteArray::number(n)).append("f");
	return ret += QString().sprintf(fmt.data(), value);
}
示例#2
0
static inline QString toString(int value, bool sign) {
	if (!sign || value < 0) return QString::number(value);
	return (value > 0 ? _LS("+") : _U8("±")) += QString::number(value);
}
示例#3
0
static inline QString msecToString(qint64 ms, const QString &fmt = _LS("hh:mm:ss")) {return msecToTime(ms).toString(fmt);}
示例#4
0
static inline QString secToString(int s, const QString &fmt = _LS("hh:mm:ss")) {return secToTime(s).toString(fmt);}
示例#5
0
void TASK_Bluetooth( void *pvParameters )
{
    UNUSED( pvParameters );
        
    static char rxBuffer[BLUETOOTH_MAX_RX_LEN];
    static char *Rx = rxBuffer;
    char Tx[BLUETOOTH_TX_BUFFER_LEN];
        
    /* Create a semaphore */
    rxSemaphoreBluetooth = xSemaphoreCreateBinary();
        
    /* Ensure that semaphore is valid */
    Assert( rxSemaphoreBluetooth );
        
    /* Create a queue */
    xBluetoothTxQueue = xQueueCreate( 3, BLUETOOTH_TX_BUFFER_LEN * sizeof( char ) );
    xBluetoothRxQueue = xQueueCreate( BLUETOOTH_MAX_RX_LEN, sizeof( uint16_t ) );
        
    /* Ensure that the queue is valid */
    Assert( xBluetoothTxQueue );
    Assert( xBluetoothRxQueue );

    /* Start reading */
    dma_start_transfer_job( &zDMA_BluetoothResourceRx );

    for(;;)
    {
        if( xQueueReceive( xBluetoothTxQueue, Tx, ( TickType_t ) 0 ) == pdTRUE )
        {
            strncpy((char *)Bluetooth_TxBuffer, Tx, sizeof(FTDI_TxBuffer));
            dma_start_transfer_job(&zDMA_BluetoothResourceTx);
            while( !( DMA_Status & _LS(BLUETOOTH_TX_DONE) ) )
            {
                taskYIELD();
            }
            DMA_Status &= !(_LS(BLUETOOTH_TX_DONE));
        }
            
        /* Block task until DMA read complete */
        if( xSemaphoreTake( rxSemaphoreBluetooth, 5 ) == pdTRUE )
        {
            if( xBluetoothTxQueue != 0)
            {
                xQueueSend( xBluetoothTxQueue, Bluetooth_RxBuffer, ( TickType_t ) 0 );
            }
            /* Look for backspace character */
            if( *Bluetooth_RxBuffer == 127 )
            {
                if( Rx != rxBuffer )
                {
                    Rx--;
                    *Rx = 0;
                }
            }
            else if( *Bluetooth_RxBuffer == 13 ) // Carriage return
            {
                memcpy( Rx, "\0", sizeof( char ) );
                /* Pass command to the main parser */
                if( xParserQueue != 0 )
                {
                    xQueueSend( xParserQueue, rxBuffer, ( TickType_t ) 10 );
                }
                Rx = rxBuffer;
            }
            else if( !strcmp( ( const char * ) Bluetooth_RxBuffer, "\027[D" ) ) // Left arrow ANSI
            {
                /* Move pointer around */
            }
            else if( !strcmp( ( const char * ) Bluetooth_RxBuffer, "\027[C" ) ) // Right arrow ANSI
            {
                /* Move pointer around */
            }
            else if( !strcmp( ( const char * ) Bluetooth_RxBuffer, "\027[A" ) ) // Up arrow ANSI
            {
                /* Previous command */
            }
            else if( !strcmp( ( const char * ) Bluetooth_RxBuffer, "\027[B" ) ) // Down arrow ANSI
            {
                /* Next command, if available */
            }
            else
            {
                /* Copy byte into buffer */
                *Rx = ( char ) *Bluetooth_RxBuffer;
                    
                /* Reset buffer pointer on overflow */
                if( Rx == &rxBuffer[BLUETOOTH_MAX_RX_LEN-1] )
                {
                    Rx = rxBuffer;
                }
                else
                {
                    Rx++;
                }
            }
            dma_start_transfer_job( &zDMA_BluetoothResourceRx );
        }

        taskYIELD();
    }
}