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

#ifdef __cplusplus
extern "C" {
#endif

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

/* Includes ------------------------------------------------------------------*/
#include "app.h"
#include "resources.h"

/* Defines -------------------------------------------------------------------*/
#define GFX_BLACK           0x0000
#define GFX_WHITE           0xffff
#define GFX_RED             0x001f
#define GFX_GREEN           0x0060
#define GFX_BLUE            0xf800
#define GFX_YELLOW          (GFX_RED + GFX_GREEN)
#define GFX_CYAN            (GFX_GREEN + GFX_BLUE)
#define GFX_MAGENTA         (GFX_BLUE + GFX_RED)

/* Typedefs & Enumerations ---------------------------------------------------*/

/* Public Functions Declarations ---------------------------------------------*/
/**  Initialised the graphics system, sets the initial background and foreground
 * colours 
 * @param bg_colour       background colour
 * @param fg_colour       foreground colour
 * @param blt             backlight level (0 to 31)
 */
void gfx_init(uint16_t bg_colour, uint16_t fg_colour, uint8_t blt);

void gfx_screen_off();
void gfx_screen_on();

/** Set background colour 
 * @param bg_colour       background colour
 */
void gfx_set_bg_colour( uint16_t colour);

/** Set foreground colour 
 * @param fg_colour       foreground colour
 */
void gfx_set_fg_colour( uint16_t colour);

uint16_t gfx_get_fg_colour(void);
uint16_t gfx_get_bg_colour(void);

/** Draw an image
 * Uses foreground and background colours already specified
 * @param x               x-coordinate of top left hand corner of image
 * @param y               y-coordinate of top left hand corner of image
 * @param image           pointer to image data in 2bpp alpha format 
 */
void gfx_draw_image(uint16_t x, uint16_t y, const res_image_t * image);

/** Draw an image centered horizontally on screen
 * Uses foreground and background colours already specified
 * @param y               y-coordinate of top of image
 * @param image           pointer to image data in 2bpp alpha format 
 */
void gfx_draw_image_centred(uint16_t y, const res_image_t * image);

/** Draw a solid block of colour
 * @param x               x-coordinate of top left hand corner of image
 * @param y               y-coordinate of top left hand corner of image
 * @param w               width of image
 * @param h               height of image
* @param colour           block colour
 */
void gfx_draw_block(uint16_t x, uint16_t y,uint16_t w, uint16_t h, uint16_t colour);

/** Draw text
 * Uses foreground and background colours already specified
 * @param string          null-terminated text string
 * @param x               x-coordinate of start of text
 * @param y               y-coordinate of text baseline
 * @param font            pointer to 2bpp font 2bpp 
 */
void gfx_draw_text(char* string, uint16_t x, uint16_t y, res_font_t * font);

/** Draw text centered horizontally on screen
 * Uses foreground and background colours already specified
 * @param string          null-terminated text string
 * @param y               y-coordinate of text baseline
 * @param font            pointer to 2bpp font 2bpp 
 */
void gfx_draw_text_centred(char* string, uint16_t y, res_font_t * font);

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

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

#ifdef __cplusplus
}
#endif

#endif

/* End graphics */