#define DEBUG_LOG_MODULE_NAME "POSAPP"
#ifdef DEBUG_POSLIB_LOG_MAX_LEVEL
#define DEBUG_LOG_MAX_LEVEL DEBUG_POSLIB_LOG_MAX_LEVEL
#else
#define DEBUG_LOG_MAX_LEVEL LVL_NOLOG
#endif
#include "posapp_settings.h"
#include "board.h"
#include "gpio.h"
#ifdef MOTION_SUPPORTED
#include "motion.h"
#endif
#ifdef CONF_USE_PERSISTENT_MEMORY
#endif
#ifdef CONF_USE_LED_NOTIFICATION
#define LED_ON true
#define LED_OFF false
#define LED_ID 0
#endif
#ifdef BUTTON_ENABLED
static void button_pressed_cb(uint8_t pin, gpio_event_e event)
{
LOG(
LVL_DEBUG,
"Start oneshot. Button event %u button pin %u", event, pin);
}
static void enable_button(void)
{
gpio_res_e res;
#define DEBOUNCE_MS 100 //FixME: move to general definitions
#define BUTTON_ID 0 //FixME: move to general definitions
res = GPIO_register_for_event(buttons_pins[BUTTON_ID],
pull,
event,
DEBOUNCE_MS,
button_pressed_cb);
if (res == GPIO_RES_OK)
{
LOG(
LVL_INFO,
"Oneshot request active on button %u", BUTTON_ID);
}
else
{
LOG(
LVL_ERROR,
"Registration for button id: %u failed.", BUTTON_ID)
}
}
#else
static void enable_button(void) {}
#endif
#ifdef CONF_USE_PERSISTENT_MEMORY
static uint32_t App_persistent_data_write(void)
{
PosApp_Settings_store(&settings);
}
#endif
#ifdef MOTION_SUPPORTED
{
}
{
{
posapp_motion_ret_e res_mon;
posapp_motion_mon_settings_t motion_cfg = {
.cb = motion_cb
};
res_mon = PosAppMotion_startMonitoring(&motion_cfg);
if (res_mon != POSAPP_MOTION_RET_OK)
{
LOG(
LVL_ERROR,
"Cannot activate motion monitoring! res: %u", res_mon);
return false;
}
}
else
{
PosAppMotion_stopMonitoring();
}
return true;
}
#endif
{
{
#ifdef MOTION_SUPPORTED
update_motion(&settings.
motion);
#endif
#ifdef CONF_USE_PERSISTENT_MEMORY
#endif
}
}
{
#ifdef CONF_USE_LED_NOTIFICATION
{
}
#endif
}
{
#ifdef CONF_USE_LED_NOTIFICATION
{
}
#endif
}
{
PosApp_Settings_get(&settings);
{
return res;
}
{
LOG(
LVL_ERROR,
"PosLib cannot register event %u failed. res: %d", event, res);
return res;
}
{
LOG(
LVL_ERROR,
"PosLib cannot register event %u failed. res: %d", event, res);
return res;
}
{
LOG(
LVL_ERROR,
"PosLib cannot register event %u failed. res: %d", event, res);
return res;
}
#ifdef MOTION_SUPPORTED
update_motion(&settings.
motion);
#endif
{
LOG(
LVL_ERROR,
"PosLib start periodic failed. res: %d", res);
}
return res;
}
{
PosApp_Settings_configureNode();
enable_button();
#ifdef CONF_USE_LED_NOTIFICATION
#endif
#ifdef MOTION_SUPPORTED
PosAppMotion_init();
#endif
#ifdef CONF_VOLTAGE_REPORT
#endif
lib_state->startStack();
App_start_positioning();
}