Something went wrong on our end
draw.h 5.66 KiB
/*******************************************************************
Header for draw.c
Method representing frame_buffer
authors: Pelech Ondrej, Pham Thi Thien Trang
date: Mai 2023
*******************************************************************/
#ifndef __DRAW_H__
#define __DRAW_H__
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L
#endif
#ifndef __SCREEN_DIMENSIONS__
#define __SCREEN_DIMENSIONS__
#define SCREEN_WIDTH 480
#define SCREEN_HEIGHT 320
#endif
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <unistd.h>
#include "mzapo_parlcd.h"
#include "mzapo_phys.h"
#include "mzapo_regs.h"
#include "serialize_lock.h"
#include "utils.h"
// F_BUFF errors
enum {ERROR_INIT = 101,ERROR_WRONG_INIT_INPUT, ERROR_ADDRESS_ACCESS, ERROR_BUFFER_NULL};
// F_BUFF errors
enum {ERROR_BUF_INIT = 201,ERROR_INVALID_VALUES};
#define FBUF_DTYPE uint16_t
#define FB_BLUE_MAX 0x1f
#define FB_GREEN_MAX 0x3f
#define FB_RED_MAX 0x1f
#define RGB(red, green, blue) (((red) & 0x1f) << 11 | ((green) & 0x3f) << 5 | ((blue) & 0x1f))
#define R(color) (((color) >> 11) & 0x1f)
#define G(color) (((color) >> 5) & 0x3f)
#define B(color) (((color) >> 0) & 0x1f)
#define FB_BLUE (RGB(0, 0, FB_BLUE_MAX))
#define FB_GREEN (RGB(0, FB_GREEN_MAX, 0))
#define FB_RED (RGB(FB_RED_MAX, 0, 0))
#define FB_BLACK (RGB(0,0,0))
#define DEFAULT_PICTURE_SIZE 16
#define INVERT_COLORS 0 // set to not 0
typedef struct frame_buffer{
FBUF_DTYPE *buffer;
uint32_t width, height;
uint32_t buffer_length;
uint32_t mem_size;
void* background_color;
volatile void *lcdBaseAddr;