/* flaneth - flash and ethernet
   Copyright (C) 2007-2012 Stefan Schuermans <stefan@schuermans.info>
   Copyleft: GNU public license V2 - http://www.gnu.org/copyleft/gpl.html
   a BlinkenArea project - http://www.blinkenarea.org/ */

#ifndef INC_app_bbm
#define INC_app_bbm

#include "dosfs.h"

/// internal state of BBM play application
typedef struct app_bbm_state {
  // initialize before calling init
  uint8_t (*sectorBuf)[SECTOR_SIZE]; ///< scratch buffer to store a sector
  VOLINFO *vi;                       ///< volume information structure
  uint8_t no;                        ///< number of BBM play application
  // internal stuff
  char           isInit;      ///< if successfully initialized
  unsigned long  nextActMs;   ///< when to do next action
  char           haveAddr;    ///< if destination address for MCUF is known
  unsigned char  addr[4];     ///< destination address for MCUF packets
  unsigned short port;        ///< destination port for MCUF packets
  char           ser115k2;    ///< if serial output 115200 8N1 is requested
  unsigned int   idxFile;     ///< index of file to open next
  char           haveFile;    ///< if a file is open
  FILEINFO       fi;          ///< information about open file
  uint16_t       height;      ///< height of current movie
  uint16_t       width;       ///< width of current movie
  uint16_t       channels;    ///< channels in current movie
  uint16_t       maxval;      ///< maxval of current movie
  uint16_t       dataSz;      ///< size of data in a frame
  uint16_t       thisFrameMs; /**< time the current frame has already been
                                   shown when next action triggers */
} AppBbmState;

/**
 * @brief initialize BBM play application
 * @param[in,out] state internal state of application
 *
 * state.sectorBuf, state.vi, state.no have to be initialized before calling
 */
extern void AppBbmInit(AppBbmState *state);

/**
 * @brief run BBM play application
 * @param[in,out] state internal state of application
 */
extern void AppBbmRun(AppBbmState *state);

#endif // #ifndef INC_app_bbm

