/*
 * LEIGH:plc
 * Copyright 2022 Alex Leigh
 * Copyright 2022 Brian Hair
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <stdio.h>
#include <string.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <esp_log.h>
#include <sdkconfig.h>

#include "mecha.h"
#include "sacn.h"
#include "lcd.h"
#include "eth.h"
#include "qrencode.h"
#include "zero.h"
#include "emon.h"
#include "esp.h"
#include "dmx.h"

/**
 * @brief LEIGH:plc entry point
 *
 * Main entry point for the LEIGH:plc. The PLC is intended to run on ESP32 and Ethernet
 * will always be present.
 */
void app_main()
{
    // Enable/Disable the tasks you want here, until ZERO is fully working

    // Order matters here. LCD task must be initialized for ETH to work.
    lcdFinit();
    ethFinit();
    sacnFinit();

    // zeroFinit();
    // espFinit();
    // emonFinit();

    xTaskCreate(sacnFtask, "SACN", 4000, NULL, 1, NULL);
    xTaskCreate(sacnF_watchdog_task, "SACN", 4000, NULL, 1, NULL);
    xTaskCreate(lcdFtask, "LCD", 4000, NULL, 2, NULL);
    // xTaskCreate(zeroFtask, "ZERO", 4000, NULL, 3, NULL);
    // xTaskCreate(emonFtask, "EMON", 4000, NULL, 4, NULL);
     
    dmxFinit();
}