WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
LedBlinker.h
/******************************************************************************
* Copyright (c) ATTX INC 2025. All Rights Reserved. 
*
* This software and associated documentation (the "Software") are the 
* proprietary and confidential information of ATTX, INC. The Software is 
* furnished under a license agreement between ATTX and the user organization 
* and may be used or copied only in accordance with the terms of the agreement.
* Refer to 'license/attx_license.adoc' for standard license terms.
*
* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION 
* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or 
* transmitted in any form or by any means, for any purpose, without the express 
* written permission of ATTX, INC.
******************************************************************************/
/*
LED Blinker header file

Author: Alex  Reynolds
*/
#ifndef APPS_LED_BLINKER_H
#define APPS_LED_BLINKER_H

#include "flight/App.h"
#include "flight/FlightExecutive.h"

#include "telemetry/tlm_LedBlinker.h"
#include "command/cmd_LedBlinker.h"

namespace warpos {
    
    /**
     * @brief LED Blinker example app
     * 
     * The LED blinker is a simple example app which blinks an app at a pre-defined
     * frequency and implements all elements of the app.
     */
    class LedBlinker : public App {
    public:
        START_PARAMS
            /** The frequency of blinking as one every N runs... default is always 1*/
            SIGNAL(frequency,                   uint8,                      1)
            /** The bank on which the LED should be actuated */
            SIGNAL(bank,                        uint8,                      0)
            /** The pin to write LED blinking output to */
            SIGNAL(pin,                         uint32,                     0)
        END_PARAMS

        START_OUTPUTS
            /** The current status of the LED (on/off) */
            SIGNAL(status,                      bool,                       0)
            /** The total number of LED on/off toggles */
            SIGNAL(blink_count,                 uint32,                     0)
        END_OUTPUTS

        LedBlinker(FlightExecutive &executive);

        virtual ~LedBlinker() {};
    
        /// @brief Activate the app. The app will step when active.
        /// @return Flag indicating success/failure
        int16 activate() override;

        /// @brief Deactivate the app. The app will not step when deactivated
        /// @return Flag indicating success/failure
        int16 deactivate() override;

        /// @brief Process commands issued to the app
        /// @param apid The APID of the command sent
        /// @param buffer Pointer to the location of the buffer holding the command
        /// @param size The size of the command being sent
        /// @return Flag indicating success/failure
        int16 command(uint16 apid, uint8* buffer, uint16 size) override;
    protected:
        int16 start() override;
        int16 execute() override;

        /// @brief The frequency at which the LED blinker should blink
        uint8 _freq = 0;

        /// @brief The current LED blinker counter which resets when frequency achieved
        uint8 _count = 0;

        /// @brief Packet to hold LED blink count
        tlm_led_blinker_count _tlm_count;
    };
}

#endif