/** * @file include/di_fw/cloudlight.h * @brief Cloudlight header file * @copyright 2015 Dual Inventive Technology Centre B.V. */ #ifndef INCLUDE_DI_FW_CLOUDLIGHT_H_ #define INCLUDE_DI_FW_CLOUDLIGHT_H_ enum di_fw_cloudlight_state { DI_FW_CLOUDLIGHT_STATE_ONLINE = 0, DI_FW_CLOUDLIGHT_STATE_ONLINE_ERROR = 1, DI_FW_CLOUDLIGHT_STATE_OFFLINE = 2, DI_FW_CLOUDLIGHT_STATE_OFFLINE_ERROR = 3, DI_FW_CLOUDLIGHT_STATE_POWERSAVE = 4, DI_FW_CLOUDLIGHT_STATE_BUTTON = 5, DI_FW_CLOUDLIGHT_STATE_SPECIAL = 6 }; enum di_fw_cloudlight_color { DI_FW_CLOUDLIGHT_COLOR_DEFAULT = 0, DI_FW_CLOUDLIGHT_COLOR_GREEN = 1, DI_FW_CLOUDLIGHT_COLOR_BLUE = 2, DI_FW_CLOUDLIGHT_COLOR_RED = 3 }; // Infinite cloudlight on time for the special state #define DI_FW_CLOUDLIGHT_TIME_INFINITE -1 // Wakeup time from powersafe on button press for cloudlight #define DI_FW_CLOUDLIGHT_POWERSAFE_WAKEUP_TIME_MS 100 // Connection state update interval timeout (DNCM CAN-bus leader sends every 3000ms) #define DI_FW_CLOUDLIGHT_CONNSTATE_UPDATE_TIMEOUT_MS 5000 /** * Cloudlight connection state transition callback * @param is_connected Online or offline connection state */ typedef void (*di_fw_cloudlight_connection_cb_t)(const bool is_connected); /** * initiation of user interface */ void di_fw_cloudlight_init(void); /** * Set the DI-Net RPC tcp-connection state for the cloudlight * @note This needs to be called periodicly before DI_FW_CLOUDLIGHT_CONNSTATE_UPDATE_TIMEOUT_MS * is exceeded. * @param connnected the connection state that needs to be set */ void di_fw_cloudlight_set_connected(const bool connected); /** * Get the cloudlight has the DI-Net RPC tcp connection state */ bool di_fw_cloudlight_is_connected(void); /** * Set application callback for observing the cloudlight connection state */ void di_fw_cloudlight_set_connection_callback(di_fw_cloudlight_connection_cb_t cb); /** * Set the special state to activate * @param period_hz The speed in witch the lights needs to blink * @param time_sec The duration in seconds that the light needs to be on, * or DI_FW_CLOUDLIGHT_TIME_INFINITE for infinite duration. * @param color The color that the lights needs to have, can be blue green or red * @note When parameter period_hz or time_sec is zero the special state is disabled */ void di_fw_cloudlight_special_state(const uint8_t period_hz, const int32_t time_sec, const enum di_fw_cloudlight_color color); /** * returns the Cloudlight state * @return The current state */ enum di_fw_cloudlight_state di_fw_cloudlight_get_state(void); /** * as soon as we change our role to leader, the cloudlight thread starts pulling PWM's * When the Cloudlight Init has not been called yet, the PWM's are not started yet and * Chibi signals a fault. We need a mechanism to temporary hold the thread during * the interval we change from follower to leader * * @param allow */ void di_fw_cloudlight_allow_thread(bool allow); #endif /* INCLUDE_DI_FW_CLOUDLIGHT_H_ */