/* Copyright 2025 by COG9 Enterprises LLC
 * All rights reserved.
 * Title: queue.h
 * Author: Jed Marti KI7NNP
 * Description: Read and write byte queues for the 3 currents.
 * Created: Wed Jan  7 14:17:43 2026
 * Revision History:
 */


#ifndef queue_h
#define queue_h

// 100 entries: must not be more than 255. More than 100 will make the graph look funny or destroy
// it completely.
#define queueSize 100
#define qnameSize 24

// Check sizes.
#if (queueSize < 10) || (queueSize > 255)
  #error queueSize is out of bounds for this implementation.
#endif
#if qnameSize < 2
  #error qnameSize is out of bounds. Must be >= 2.
#endif

typedef struct {
  char       qname[qnameSize];      // The name.
  uint16_t   v[queueSize];          // The values.
  uint8_t    qindex;
} Queue16;


typedef struct {
  char        qname[qnameSize];
  uint8_t     v[queueSize];
  uint8_t     qindex;
} Queue8;


typedef struct {
  char        qname[qnameSize];
  float       v[queueSize];
  uint8_t     qindex;
} QueueF;
  
  


void initQueue8(Queue8 *q, char *name);
void initQueue16(Queue16 *q, char *name);
void initQueueF(QueueF *q, char *name);

void add2Queue8(Queue8 *q, uint8_t v);
void add2Queue16(Queue16 *q, uint16_t v);
void add2QueueF(QueueF *q, float v);

uint8_t getQueue8(Queue8 *q, uint8_t index);
uint16_t getQueue16(Queue16 *q, uint8_t index);
float getQueueF(QueueF *q, uint8_t index);
#endif


