2023-10-11 14:04:59 +08:00
|
|
|
/**
|
|
|
|
|
* @file va_meter_firmware.cpp
|
|
|
|
|
* @author Forairaaaaa
|
2024-04-10 10:05:11 +08:00
|
|
|
* @brief
|
2023-10-11 14:04:59 +08:00
|
|
|
* @version 0.1
|
|
|
|
|
* @date 2023-07-07
|
2024-04-10 10:05:11 +08:00
|
|
|
*
|
2023-10-11 14:04:59 +08:00
|
|
|
* @copyright Copyright (c) 2023
|
2024-04-10 10:05:11 +08:00
|
|
|
*
|
2023-10-11 14:04:59 +08:00
|
|
|
*/
|
|
|
|
|
#include "hal/hal.h"
|
|
|
|
|
#include <freertos/FreeRTOS.h>
|
|
|
|
|
#include <freertos/task.h>
|
|
|
|
|
|
|
|
|
|
#include "apps/app.h"
|
|
|
|
|
#include "apps/launcher/launcher.h"
|
|
|
|
|
#include "apps/app_factory_test/app_factory_test.h"
|
|
|
|
|
|
|
|
|
|
#define delay(ms) vTaskDelay(pdMS_TO_TICKS(ms))
|
|
|
|
|
|
|
|
|
|
extern "C" void app_main(void)
|
|
|
|
|
{
|
|
|
|
|
HAL::HAL hal;
|
|
|
|
|
|
|
|
|
|
/* Hardware init */
|
|
|
|
|
hal.init();
|
|
|
|
|
// HAL::encoder_test(hal);
|
|
|
|
|
// HAL::tp_test(hal);
|
|
|
|
|
// HAL::rtc_test(hal);
|
|
|
|
|
|
2024-04-10 10:05:11 +08:00
|
|
|
/* Check factory test mode */
|
|
|
|
|
#ifdef ENABLE_FACTORY_TEST
|
2023-10-11 14:04:59 +08:00
|
|
|
bool factory_test_mode = false;
|
|
|
|
|
|
|
|
|
|
if (!hal.encoder.btn.read())
|
2024-04-10 10:05:11 +08:00
|
|
|
{
|
2023-10-11 14:04:59 +08:00
|
|
|
uint16_t time_count = 0;
|
|
|
|
|
while (!hal.encoder.btn.read())
|
|
|
|
|
{
|
|
|
|
|
delay(10);
|
|
|
|
|
time_count++;
|
|
|
|
|
if ((time_count * 10) > 1000)
|
|
|
|
|
{
|
|
|
|
|
factory_test_mode = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// factory_test_mode = true;
|
|
|
|
|
if (factory_test_mode)
|
|
|
|
|
{
|
|
|
|
|
hal.buzz.tone(4000, 30);
|
|
|
|
|
delay(50);
|
|
|
|
|
hal.buzz.tone(4000, 30);
|
|
|
|
|
|
|
|
|
|
MOONCAKE::USER_APP::FactoryTest factory_test;
|
|
|
|
|
factory_test.setUserData((void*)&hal);
|
|
|
|
|
factory_test.onSetup();
|
|
|
|
|
factory_test.onCreate();
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
factory_test.onRunning();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-10 10:05:11 +08:00
|
|
|
#endif
|
2023-10-11 14:04:59 +08:00
|
|
|
|
|
|
|
|
/* Start launcher */
|
|
|
|
|
MOONCAKE::USER_APP::Launcher app_launcher;
|
|
|
|
|
app_launcher.setUserData((void*)&hal);
|
|
|
|
|
app_launcher.onSetup();
|
|
|
|
|
app_launcher.onCreate();
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
app_launcher.onRunning();
|
|
|
|
|
}
|
|
|
|
|
}
|