/* === === === main.c === === === */

#include "include.h"
#include "matrixstruct.h"
#include "io.h"

LED_STRIP strip;
MATRIX_LIST matrix_l = {0};

int main(void) {
    declarete_cmd_main();

    char mode;

    do {
        char inbuff;
        char _buff[BUFF_MAX];
        unsigned char n1, n2;

        mode = buff_input(&inbuff, _buff);

        switch (mode) {
            case CMD_MAIN_CREATE:
                n1 = get_num();
                n2 = get_num();
                create_matrix(n1, n2);
                break;

            case CMD_MAIN_INPUT:
                n1 = get_matrix_num();
                n1 = is_Matrix_Exist(n1);
                input_matrix(n1);
                break;

            case CMD_MAIN_DEL:
                n1 = get_matrix_num();
                n1 = is_Matrix_Exist(n1);
                free_matrix(n1);
                break;

            case CMD_MAIN_SHOW:
                n1 = get_matrix_num();
                n1 = is_Matrix_Exist(n1);
                get_matrix(n1);
                break;

            case CMD_MAIN_LOGIC:
                n1 = get_matrix_num();
                n1 = is_Matrix_Exist(n1);
                n2 = get_matrix_num();
                n2 = is_Matrix_Exist(n2);
                logic_matrix(n1, n2);
                break;

            case CMD_MAIN_EDIT:
                n1 = get_matrix_num();
                n1 = is_Matrix_Exist(n1);
                edit_matrix(n1);
                break;

            case CMD_MAIN_RAND:
                n1 = get_matrix_num();
                n1 = is_Matrix_Exist(n1);
                rand_matrix(n1);
                break;

            case CMD_MAIN_COPY:
                n1 = get_matrix_num();
                n1 = is_Matrix_Exist(n1);
                n2 = get_matrix_num();
                n2 = is_Matrix_Exist(n2);
                copy_matrix(n1, n2);
                break;

            case CMD_MAIN_EXIT:
                mode = -1;
                break;

            case CMD_MAIN_TEST: {
                alignas(16)RGB_LED alignLed; 
                RGB_LED nalignLed; 
                printf("SizeOf aligned struct: %lu\nSizeOf notAligned struct: %lu",
                       alignof(alignLed), alignof(nalignLed));
                break;
            }

            case -1:
                return 0;
        }

    } while (mode >= 0);

    del_cmd_list(CMD_MAIN);

    return 0;
}

