#ifndef TYPEDEF_H
#define TYPEDEF_H
#include "include.h"


    typedef struct __attribute__((aligned(4))){
        uint64_t l; // 14tmp 8brg 8r 8g 8b 4type 2mode 
    } RGB_LED;


    typedef struct{
        RGB_LED** leds;
        unsigned int n;
    } LED_STRIP;

    typedef enum{
        CMD_MAIN,
        CMD_LOGIC,
        CMD_EDIT,
        CMD_LED,

        CMD_GRP_COUNT
    }CMD_GRP_ENUM;

    typedef enum{
        CMD_MAIN_CREATE,
        CMD_MAIN_INPUT,
        CMD_MAIN_DEL,
        CMD_MAIN_SHOW,
        CMD_MAIN_LOGIC,
        CMD_MAIN_EDIT,
        CMD_MAIN_RAND,
        CMD_MAIN_COPY,
        CMD_MAIN_EXIT,
        CMD_MAIN_TEST,

        CMD_MAIN_COUNT
    }CMD_MAIN_ENUM;

#define MASK_EXTRACT(start, bits) (((1ULL << (bits)) - 1) << (start))

    typedef enum{
        LED_PADD_TEMP   =   50,
        LED_SIZE_TEMP   =   14,
        LED_MASK_TEMP   =   ~MASK_EXTRACT(LED_PADD_TEMP,LED_SIZE_TEMP),

        LED_PADD_BR     =   42,
        LED_SIZE_BR     =   8,
        LED_MASK_BR     =   ~MASK_EXTRACT(LED_PADD_BR,LED_SIZE_BR),
        
        LED_PADD_R      =   34,
        LED_SIZE_R      =   8,
        LED_MASK_R      =   ~MASK_EXTRACT(LED_PADD_R,LED_SIZE_R),
        
        LED_PADD_G      =   26,
        LED_SIZE_G      =   8,
        LED_MASK_G      =   ~MASK_EXTRACT(LED_PADD_G,LED_SIZE_G),
        
        LED_PADD_B      =   18,
        LED_SIZE_B      =   8,
        LED_MASK_B      =   ~MASK_EXTRACT(LED_PADD_B,LED_SIZE_B),
        
        LED_PADD_TYPE   =   14,
        LED_SIZE_TYPE   =   8,
        LED_MASK_TYPE   =   ~MASK_EXTRACT(LED_PADD_TYPE,LED_SIZE_TYPE), // тип контроллера?
        
        LED_PADD_MODE   =   10,
        LED_SIZE_MODE   =   4,
        LED_MASK_MODE   =   ~MASK_EXTRACT(LED_PADD_MODE,LED_SIZE_MODE), // 16 режимов
        
        LED_PADD_SPEED  =   2,
        LED_SIZE_SPEED  =   8,
        LED_MASK_SPEED  =   ~MASK_EXTRACT(LED_PADD_SPEED,LED_SIZE_SPEED), // Скорость анимации режима
        
        LED_PADD_SSCALE =   0,
        LED_SIZE_SSCALE =   2,
        LED_MASK_SSCALE =   ~MASK_EXTRACT(LED_PADD_SSCALE,LED_SIZE_SSCALE)  // множитель скорости ч.м.с
    }LED_INFO;
    
    typedef enum{
        LED_TEMP,
        LED_BR,
        LED_R,LED_G,LED_B,
        LED_TYPE,
        LED_MODE,
        LED_SPEED,LED_SSCALE
    }LED_WICH;

    typedef struct{
        unsigned int n;
        char** str;
    }CMD_LIST;
    
    typedef struct{
        CMD_LIST* list[CMD_GRP_COUNT];
    }CMD_GRP_LIST;

    typedef struct {
        int rows;
        int cols;
            RGB_LED*** led;
    } MATRIX;

    typedef struct{
        unsigned int n;
        MATRIX** list;
    }MATRIX_LIST;

#endif
