 static uint8_t qspPayloadLength = 0;
 static uint8_t qspFrameToSend = 0;
 
-uint8_t getPacketId() {
+uint8_t qspGetPacketId() {
     return packetId++;
 }
 
-void clearQspPayload() {
+void qspClearPayload() {
     for (uint8_t i = 0; i < QSP_PAYLOAD_LENGTH; i++) {
         qspPayload[i] = 0;
     }
     qspPayloadLength = 0;
 }
 
-void decodeIncomingQspFrame(uint8_t incomingByte) {
+int ppmOutput[PPM_CHANNEL_COUNT] = {0};
+
+void qspDecodeRcDataFrame() {
+    //TODO fix it, baby :)
+
+    ppmOutput[0] = (uint16_t) (((uint16_t) qspPayload[0] << 2) & 0x3fc) | ((qspPayload[1] >> 6) & 0x03);
+    ppmOutput[1] = (uint16_t) (((uint16_t) qspPayload[1] << 4) & 0x3f0) | ((qspPayload[2] >> 4) & 0x0F);
+    ppmOutput[2] = (uint16_t) (((uint16_t) qspPayload[2] << 6) & 0x3c0) | ((qspPayload[3] >> 2) & 0x3F);
+    ppmOutput[3] = (uint16_t) (((uint16_t) qspPayload[3] << 8) & 0x300) | ((qspPayload[4] >> 2) & 0xFF);
+    ppmOutput[4] = qspPayload[5];
+    ppmOutput[5] = qspPayload[6];
+    ppmOutput[6] = (qspPayload[7] >> 4) & 0b00001111;
+    ppmOutput[7] = qspPayload[7] & 0b00001111;
+    ppmOutput[8] = (qspPayload[8] >> 4) & 0b00001111;
+    ppmOutput[9] = qspPayload[8] & 0b00001111;
+
+    //10bit channels
+    ppmOutput[0] = map(ppmOutput[0], 0, 1000, 1000, 2000);
+    ppmOutput[1] = map(ppmOutput[1], 0, 1000, 1000, 2000);
+    ppmOutput[2] = map(ppmOutput[2], 0, 1000, 1000, 2000);
+    ppmOutput[3] = map(ppmOutput[3], 0, 1000, 1000, 2000);
+
+    //8bit channels
+    ppmOutput[4] = map(ppmOutput[4], 0, 0xff, 1000, 2000);
+    ppmOutput[5] = map(ppmOutput[5], 0, 0xff, 1000, 2000);
+
+    //4bit channels
+    ppmOutput[6] = map(ppmOutput[6], 0, 0x0f, 1000, 2000);
+    ppmOutput[7] = map(ppmOutput[7], 0, 0x0f, 1000, 2000);
+    ppmOutput[8] = map(ppmOutput[8], 0, 0x0f, 1000, 2000);
+    ppmOutput[9] = map(ppmOutput[9], 0, 0x0f, 1000, 2000);
+}
+
+void qspDecodeIncomingFrame(uint8_t incomingByte) {
     static uint8_t frameId;
     static uint8_t payloadLength;
     static uint8_t receivedPayload;

#include "variables.h"

#define DEVICE_MODE_TX
// #define DEVICE_MODE_RX

/*
 * Main defines for device working in TX mode

    writeToRadio(data);

    //Write packet ID
    writeToRadio(qspGetPacketId());

    //Write payload
    for (uint8_t i = 0; i < length; i++) {
