/* ****************************************************************************
 * File:      resources
 * Date:      23 Mar 2026
 * Author:    Andrew Levido
 *
 * Copyright 2026 Imbrius Pty Ltd - All Rights Reserved
 *
 *****************************************************************************/
#ifndef _resources_H
#define _resources_H

#ifdef __cplusplus
extern "C" {
#endif

/* Description ---------------------------------------------------------------*/

/* Includes ------------------------------------------------------------------*/
#include "app.h"
#include <stdbool.h>
/* Defines -------------------------------------------------------------------*/

/* Typedefs & Enumerations ---------------------------------------------------*/
typedef struct {
  uint16_t w;
  uint16_t h;
  uint32_t data_size;
  const uint8_t * map;
} res_image_t;

/** Glyph descript */
typedef struct {
    uint32_t bitmap_index;          /* Start index of the bitmap. */
    uint32_t adv_w;                 /* Draw the next glyph after this width (value x 16) */
    uint8_t box_w;                  /* Width of the glyph's bounding box */
    uint8_t box_h;                  /* Height of the glyph's bounding box */
    int8_t ofs_x;                   /* x offset of the bounding box */
    int8_t ofs_y;                   /* y offset from the baseline of the bounding box */
} res_glyph_data_t;

/* For non-sparse lists (glyph_index_list_sparse == false) - 
 *    If the glyph index list is NULL
 *        glyph_index = (ascii - range start) + glyph_index_start
 *    Otherwise 
 *        glyph_index = glyph_index_list[ (ascii - range start)] + glyph_index_start
 * 
 * If sparse - 
 *        glyph_index = search{ glyph_index_list[ ], (ascii - range start) } + glyph_index_start
 */

/* Character map */
typedef struct {
    
    uint8_t range_start;                  // First ascii char 
    uint8_t range_length;                 // Number of ascii chars in the range
    uint16_t glyph_index_start;           // index into glyph_desc for this range
    const uint8_t * glyph_index_list;     // pointer to offsets list 
    uint16_t list_length;                 // length of offsets list
    bool glyph_index_list_sparse;         // flag if list is sparse
} res_font_cmap_t;

/* Font description */
typedef struct {
   int8_t line_height;                    // Line height (include ascender & descender)
   int8_t base_line;                      // baseline for text
   const uint8_t * glyph_bitmap;          // pointer to bitmap array
   const res_glyph_data_t * glyph_data;  // pointer to glyph data array
   const res_font_cmap_t * cmaps;             // pointer to charater map array
   uint8_t n_maps;                        // number of char maps in array
} res_font_t;


extern const res_image_t bjt_npn_image;
extern const res_image_t bjt_npn_diode_image;
extern const res_image_t bjt_pnp_image;
extern const res_image_t bjt_pnp_diode_image;
extern const res_image_t blue_term_image;
extern const res_image_t clock_image;
extern const res_image_t diode_pair_aa_image;
extern const res_image_t diode_pair_ak_image;
extern const res_image_t diode_pair_kk_image;
extern const res_image_t diode_image;
extern const res_image_t diode_b2b_image;
extern const res_image_t exclaimation_image;
extern const res_image_t green_term_image;
extern const res_image_t hands_image;
extern const res_image_t igbt_diode_image;
extern const res_image_t igbt_image;
extern const res_image_t led_b2b_image;
extern const res_image_t diode_b2b_image;
extern const res_image_t led_image;
extern const res_image_t led_pair_aa_image;
extern const res_image_t led_pair_kk_image;
extern const res_image_t mosfet_nch_image;
extern const res_image_t mosfet_pch_image;
extern const res_image_t mosfet_depletion_nch_image;
extern const res_image_t jfet_nch_image;
extern const res_image_t jfet_pch_image;
extern const res_image_t red_term_image;
extern const res_image_t schottky_image;
extern const res_image_t schottky_pair_aa_image;
extern const res_image_t schottky_pair_kk_image;
extern const res_image_t schottky_pair_ak_image;
extern const res_image_t warning_image;
extern const res_image_t zener_image;
extern const res_image_t darlington_pnp_image;
extern const res_image_t darlington_npn_image;
extern const res_image_t darlington_pnp_diode_image;
extern const res_image_t darlington_npn_diode_image;
extern const res_image_t thyristor_image;
extern const res_image_t triac_image;
extern const res_image_t logo_1_image;
extern const res_image_t logo_2_image;

extern  res_font_t roboto_bold_20;

/* Public Functions Declarations ---------------------------------------------*/

/* Task Function -------------------------------------------------------------*/

/* Interrupt Service Routine Declarations ------------------------------------*/

#ifdef __cplusplus
}
#endif

#endif

/* End resources */