hackathon-dev #1
|
@ -3,7 +3,7 @@ RESOURCES=../resources
|
|||
SPLASHSCREEN=splash-vmwcblk.png
|
||||
|
||||
OBJS=main.o sysinput.o ep_init.o ep_upiwin.o ep_backlight.o ep_msg.o ep_upiwin_tmp.o ep_util.o \
|
||||
fbinit.o rect.o fontengine.o fbprimitive.o \
|
||||
fbinit.o rect.o gfxobj.o devctxt.o dc_screen.o fontengine.o fbprimitive.o \
|
||||
log.o gpio.o msg_queue.o time_func.o config.o splash.o
|
||||
LIBS=-lpython3.7m -lcrypt -lfreetype -lbcm2835 -lpthread -ldl -lutil -lm
|
||||
CFLAGS=-I/usr/include/python3.7m -I/usr/include/freetype2 -I/usr/include/libpng16 \
|
||||
|
|
5
src/dc_screen.c
Executable file
5
src/dc_screen.c
Executable file
|
@ -0,0 +1,5 @@
|
|||
#include "dc_screen.h"
|
||||
|
||||
static COLORREF screen_set_pixel(PVOID privdata, INT32 x, INT32 y, COLORREF color, INT32 op)
|
||||
{
|
||||
}
|
12
src/dc_screen.h
Executable file
12
src/dc_screen.h
Executable file
|
@ -0,0 +1,12 @@
|
|||
#ifndef __DC_SCREEN_H_INCLUDED
|
||||
#define __DC_SCREEN_H_INCLUDED
|
||||
|
||||
#include "wintype.h"
|
||||
#include "gfxtype.h"
|
||||
|
||||
typedef struct tagSCREENPRIVDATA {
|
||||
UINT32 pix_per_row;
|
||||
UINT16 *pdata;
|
||||
} SCREENPRIVDATA, *PSCREENPRIVDATA;
|
||||
|
||||
#endif /* __DC_SCREEN_H_INCLUDED */
|
9
src/devctxt.c
Executable file
9
src/devctxt.c
Executable file
|
@ -0,0 +1,9 @@
|
|||
#include "gfxtype.h"
|
||||
#include "devctxt.h"
|
||||
|
||||
COLORREF DC_SetPixel(PDCTXT pdctxt, INT32 x, INT32 y, COLORREF color)
|
||||
{
|
||||
if (!G_coords_in_rect(&(pdctxt->cliprect), x, y))
|
||||
return (COLORREF)(-1);
|
||||
return (*(pdctxt->funcs->set_pixel))(pdctxt->privdata, xm, y, colorref, pdctxt->rop2);
|
||||
}
|
48
src/devctxt.h
Executable file
48
src/devctxt.h
Executable file
|
@ -0,0 +1,48 @@
|
|||
#ifndef __DEVCTXT_H_INCLUDED
|
||||
#define __DEVCTXT_H_INCLUDED
|
||||
|
||||
#include "wintype.h"
|
||||
#include "gfxtype.h"
|
||||
#include "gfxobj.h"
|
||||
|
||||
#define DCTXT_SIG_WORD 0x78744344 /* "DCtx */
|
||||
|
||||
/* Raster operation codes */
|
||||
#define R2_BLACK 1
|
||||
#define R2_NOTMERGEPEN 2
|
||||
#define R2_MASKNOTPEN 3
|
||||
#define R2_NOTCOPYPEN 4
|
||||
#define R2_MASKPENNOT 5
|
||||
#define R2_NOT 6
|
||||
#define R2_XORPEN 7
|
||||
#define R2_NOTMASKPEN 8
|
||||
#define R2_MASKPEN 9
|
||||
#define R2_NOTXORPEN 10
|
||||
#define R2_NOP 11
|
||||
#define R2_MERGENOTPEN 12
|
||||
#define R2_COPYPEN 13
|
||||
#define R2_MERGEPENNOT 14
|
||||
#define R2_MERGEPEN 15
|
||||
#define R2_WHITE 16
|
||||
|
||||
typedef COLORREF (*DCtx_SetPixel)(PVOID privdata, INT32 x, INT32 y, COLORREF color, INT32 op);
|
||||
|
||||
typedef struct tagDCFUNTABLE {
|
||||
DCtx_SetPixel set_pixel; /* sets a single pixel on the display */
|
||||
} DCFUNTABLE;
|
||||
|
||||
typedef const DCFUNTABLE *PDCFUNTABLE;
|
||||
|
||||
typedef struct tagDCTXT {
|
||||
GFXOBJECT hdr; /* the header of all objects */
|
||||
PDCFUNTABLE funcs; /* device context functions */
|
||||
PVOID privdata; /* private data for the type of DC */
|
||||
RECT cliprect; /* clipping rectangle */
|
||||
POINT pos; /* current position */
|
||||
UINT32 rop2; /* current raster operation */
|
||||
COLORREF color; /* current drawing color (XXX replace with pens later) */
|
||||
} DCTXT, *PDCTXT;
|
||||
|
||||
extern COLORREF DC_SetPixel(PDCTXT pdctxt, INT32 x, INT32 y, COLORREF color);
|
||||
|
||||
#endif /* __DEVCTXT_H_INCLUDED */
|
|
@ -24,7 +24,6 @@ PyObject *Epython_set_backlight(PyObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "p", &new_state))
|
||||
return NULL;
|
||||
pstate = (PUPIWIN_STATE)PyModule_GetState(UPIWIN_module);
|
||||
Log(LDEBUG, "set_backlight: old=%d, new=%d (level=%u)", pstate->backlight_on, new_state, pstate->backlight_level);
|
||||
if (new_state && !(pstate->backlight_on))
|
||||
Gpio_set_backlight(pstate->backlight_level);
|
||||
else if (!new_state && pstate->backlight_on)
|
||||
|
|
|
@ -68,3 +68,4 @@ PyObject *Epython_post_quit_message(PyObject *self, PyObject *args)
|
|||
Mq_post1(Sys_Queue, 0, WM_QUIT, exitcode);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
|
30
src/gfxobj.c
Executable file
30
src/gfxobj.c
Executable file
|
@ -0,0 +1,30 @@
|
|||
#include <stdlib.h>
|
||||
#include "gfxobj.h"
|
||||
|
||||
void Go_unchain(PGFXOBJECT obj)
|
||||
{
|
||||
if (!(obj->next || obj->prev))
|
||||
return;
|
||||
if (obj->next)
|
||||
obj->next->prev = obj->prev;
|
||||
if (obj->prev)
|
||||
obj->prev->next = obj->next;
|
||||
obj->prev = obj->next = NULL;
|
||||
}
|
||||
|
||||
INT32 Go_addref(PGFXOBJECT obj)
|
||||
{
|
||||
return ++(obj->refcnt);
|
||||
}
|
||||
|
||||
INT32 Go_release(PGFXOBJECT obj)
|
||||
{
|
||||
int rc = --(obj->refcnt);
|
||||
if (rc == 0)
|
||||
{
|
||||
if (obj->dtor)
|
||||
(*(obj->dtor))(obj);
|
||||
free(obj);
|
||||
}
|
||||
return rc;
|
||||
}
|
23
src/gfxobj.h
Executable file
23
src/gfxobj.h
Executable file
|
@ -0,0 +1,23 @@
|
|||
#ifndef __GFXOBJ_H_INCLUDED
|
||||
#define __GFXOBJ_H_INCLUDED
|
||||
|
||||
#include "wintype.h"
|
||||
|
||||
/* type definition for a graphics destructor */
|
||||
typedef void (*GFX_DTOR)(PVOID obj);
|
||||
|
||||
/* A graphics object in memory always starts with this. */
|
||||
typedef struct tagGFXOBJECT {
|
||||
UINT32 sig; /* signature so we know what something is */
|
||||
UINT32 size; /* size of total allocated memory in block */
|
||||
INT32 refcnt; /* reference count */
|
||||
GFX_DTOR dtor; /* destructor function called when we're no longer needed */
|
||||
struct tagGFXOBJECT *next; /* support double linked lists of obejcts */
|
||||
struct tagGFXOBJECT *prev;
|
||||
} GFXOBJECT, *PGFXOBJECT;
|
||||
|
||||
extern void Go_unchain(PGFXOBJECT obj);
|
||||
extern INT32 Go_addref(PGFXOBJECT obj);
|
||||
extern INT32 Go_release(PGFXOBJECT obj);
|
||||
|
||||
#endif /* __GFXOBJ_H_INCLUDED */
|
|
@ -18,14 +18,23 @@ typedef struct tagRECT {
|
|||
typedef const POINT *PCPOINT;
|
||||
typedef const RECT *PCRECT;
|
||||
|
||||
typedef UINT32 COLORREF;
|
||||
typedef PUINT32 PCOLORREF;
|
||||
|
||||
extern BOOL G_set_rect(PRECT rect, int left, int top, int right, int bottom);
|
||||
extern BOOL G_set_rect_empty(PRECT rect);
|
||||
extern BOOL G_inflate_rect(PRECT rect, int dx, int dy);
|
||||
extern BOOL G_offset_rect(PRECT rect, int dx, int dy);
|
||||
extern BOOL G_is_rect_empty(PCRECT rect);
|
||||
extern BOOL G_coords_in_rect(PCRECT rect, INT32 x, INT32 y);
|
||||
extern BOOL G_point_in_rect(PCRECT rect, PCPOINT pt);
|
||||
extern BOOL G_rect_equal(PCRECT rect1, PCRECT rect2);
|
||||
extern BOOL G_rect_intersect(PRECT dest, PCRECT src1, PCRECT src2);
|
||||
extern BOOL G_rect_union(PRECT dest, PCRECT src1, PCRECT src2);
|
||||
|
||||
#define RGB(r, g, b) ((((UINT32)(r)) & 0xFF) | ((((UINT32)(g)) & 0xFF) << 8) | ((((UINT32)(b)) & 0xFF) << 16))
|
||||
#define GetRValue(cr) ((UINT32)((cr) & 0xFF))
|
||||
#define GetGValue(cr) ((UINT32)(((cr) >> 8) & 0xFF))
|
||||
#define GetBValue(cr) ((UINT32)(((cr) >> 16) & 0xFF))
|
||||
|
||||
#endif /* __GFXTYPE_H_INCLUDED */
|
||||
|
|
|
@ -40,9 +40,14 @@ BOOL G_is_rect_empty(PCRECT rect)
|
|||
return (rect->right <= rect->left) || (rect->bottom <= rect->top);
|
||||
}
|
||||
|
||||
BOOL G_coords_in_rect(PCRECT rect, INT32 x, INT32 y)
|
||||
{
|
||||
return (rect->left <= x) && (x < rect->right) && (rect->top <= y) && (y < rect->bottom);
|
||||
}
|
||||
|
||||
BOOL G_point_in_rect(PCRECT rect, PCPOINT pt)
|
||||
{
|
||||
return (rect->left <= pt->x) && (pt->x < rect->right) && (rect->top <= pt->y) && (pt->y < rect->bottom);
|
||||
return G_coords_in_rect(rect, pt->x, pt->y);
|
||||
}
|
||||
|
||||
BOOL G_rect_equal(PCRECT rect1, PCRECT rect2)
|
||||
|
|
Loading…
Reference in New Issue
Block a user