#include <stdio.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include <fcntl.h>
#include "picotk.h"
#include "framebuffer.h"
#include <tll_config.h>
#include "../src/lq035q1dh02.h"
Include dependency graph for picotk.c:
Defines | |
#define | ABS(x) ((x<0) ? (-x):(x)) |
Functions | |
static int | picotk_DrawTextRaw (picotk_Font *font, unsigned short color, int x, int y, char *txt) |
static void | picotk_DrawPointRaw (unsigned short color, int x, int y) |
Unprotected point draw for internal use. | |
static void | picotk_DrawLineRaw (unsigned short color, int x1, int y1, int x2, int y2) |
static unsigned int | picotk_ColorTargetGet (picotk_Color *color) |
int | picotk_Init (isrDisp_t *isrDisp) |
Initializes picoTK and the display with the given ISR dispatcher. | |
void | picotk_Show () |
Show the contents of the latest framebuffer onto the display. | |
void | picotk_ShowNB () |
Begins to show the display, but does not block. | |
void | picotk_ReadyToDraw () |
If picotk_ShowNB() was previously calls, waits until the display has finished refreshing. | |
void | picotk_DestSet (picotk_Buffer destination) |
Sets the destination buffer to destination . | |
void | picotk_DrawPoint (picotk_Color *color, int x, int y) |
Draws a point at the given coordinates. | |
void | picotk_DrawLine (picotk_Color *color, int x1, int y1, int x2, int y2) |
Draws a one pixel wide line between (x1, y1) and (x2,y2) using the provided color. | |
void | picotk_PixmapInit (picotk_Pixmap *pixmap, int width, int height, picotk_PixmapType type, const unsigned short *data) |
Given a pointer to a newly-allocated picotk_Pixmap, initializes its contents with the provided pixmap data. | |
void | picotk_PixmapDraw (picotk_Pixmap *pixmap, int x, int y) |
Draws a pixmap at the given coordinates (upper left corner of rectangle around pixmap). | |
int | picotk_DrawText (picotk_Font *font, picotk_Color *color, int x, int y, char *txt) |
Draws text starting at x, y (upper left corner of rectangle around text) with the provided font and color. | |
int | picotk_TextWidth (picotk_Font *font, char *txt) |
Calculates the text's width in pixels, given a font and the text. | |
int | picotk_TextHeight (picotk_Font *font, char *txt) |
Calculates the text's height in pixels, given a font and the text. | |
int | picotk_DrawTextCentered (picotk_Font *font, picotk_Color *color, int x, int y, char *txt) |
Similar to picotk_DrawText() but centered around x position, i.e. | |
void | picotk_DrawRect (picotk_Color *color, int x, int y, int w, int h) |
Draws a rectangle with an lower left corner at (x,y) and upper right corner at (x+w-1,y+h-1). | |
void | picotk_FillRect (picotk_Color *color, int x, int y, int w, int h) |
Draws a filled rectangle with the top left corner at (x,y) and the lower right corner at (x+w-1,y+h-1). | |
void | picotk_DrawCircle (picotk_Color *color, int x, int y, int r) |
Draws a circle (outline, not filled). | |
void | picotk_FillCircle (picotk_Color *color, int x, int y, int r) |
Draws a filled circle. | |
void | picotk_TerminalInit (picotk_Terminal *term, int wc, int hc, picotk_Font *font, picotk_Color *fgColor, picotk_Color *bgColor) |
void | picotk_TerminalPutc (picotk_Terminal *term, int ch) |
Types a single character into given terminal. | |
void | picotk_TerminalPrintf (picotk_Terminal *term, char *fmt,...) |
Types characters into the terminal according to the format string and the following parameters. | |
void | picotk_TerminalDraw (picotk_Terminal *term, int x, int y) |
int | picotk_slackGet (void) |
Returns the nanosecs until the pending image switch is executed, or 0 if no switch is pending. | |
void | picotk_plotSlackBar (picotk_Color *color, int x, int y, unsigned char horizontal, unsigned short maxLen) |
Plots slack on a 1 pixel wide bar graph. | |
int | picotk_statsGet (unsigned int *nrUpdates, unsigned int *nrSame) |
Gathers display statistics. | |
Variables | |
static fb_t | state |
static picotk_Buffer | dBuffer |
static picotk_Terminal * | dTerminal |
#define ABS | ( | x | ) | ((x<0) ? (-x):(x)) |
unsigned int picotk_ColorTargetGet | ( | picotk_Color * | color | ) | [static] |
void picotk_DestSet | ( | picotk_Buffer | destination | ) |
Sets the destination buffer to destination
.
destination | The destination buffer |
void picotk_DrawCircle | ( | picotk_Color * | color, | |
int | x, | |||
int | y, | |||
int | r | |||
) |
Draws a circle (outline, not filled).
color | The color of the circle | |
x | The x-coordinate of the center of the circle | |
y | The y-coordinate of the center of the circle | |
r | The radius of the circle |
void picotk_DrawLine | ( | picotk_Color * | color, | |
int | x1, | |||
int | y1, | |||
int | x2, | |||
int | y2 | |||
) |
Draws a one pixel wide line between (x1, y1) and (x2,y2) using the provided color.
color | ||
x1 | ||
y1 | ||
x2 | ||
y2 |
static void picotk_DrawLineRaw | ( | unsigned short | color, | |
int | x1, | |||
int | y1, | |||
int | x2, | |||
int | y2 | |||
) | [static] |
void picotk_DrawPoint | ( | picotk_Color * | color, | |
int | x, | |||
int | y | |||
) |
Draws a point at the given coordinates.
color | The color of the point | |
x | The x position of the point | |
y | The y position of the point |
static void picotk_DrawPointRaw | ( | unsigned short | color, | |
int | x, | |||
int | y | |||
) | [static] |
Unprotected point draw for internal use.
Note:
no safety check going off boundaries causes mem corruption
void picotk_DrawRect | ( | picotk_Color * | color, | |
int | x, | |||
int | y, | |||
int | w, | |||
int | h | |||
) |
Draws a rectangle with an lower left corner at (x,y) and upper right corner at
(x+w-1,y+h-1).
color | pointer to picotk_Color struct | |
x,y | top left coordinates of rectangle | |
w,h | width and height of rectangle |
int picotk_DrawText | ( | picotk_Font * | font, | |
picotk_Color * | color, | |||
int | x, | |||
int | y, | |||
char * | txt | |||
) |
Draws text starting at x, y (upper left corner of rectangle around text) with the provided font and color.
font | ||
color | ||
x | ||
y | ||
txt |
int picotk_DrawTextCentered | ( | picotk_Font * | font, | |
picotk_Color * | color, | |||
int | x, | |||
int | y, | |||
char * | text | |||
) |
Similar to picotk_DrawText() but centered around x position, i.e.
text extends to left and right of x to the same amount.
font | ||
color | ||
x | ||
y | ||
text |
static int picotk_DrawTextRaw | ( | picotk_Font * | font, | |
unsigned short | color, | |||
int | x, | |||
int | y, | |||
char * | txt | |||
) | [static] |
void picotk_FillCircle | ( | picotk_Color * | color, | |
int | x, | |||
int | y, | |||
int | r | |||
) |
Draws a filled circle.
color | The color of the circle | |
x | The x-coordinate of the center of the circle | |
y | The y-coordinate of the center of the circle | |
r | The radius of the circle |
void picotk_FillRect | ( | picotk_Color * | color, | |
int | x, | |||
int | y, | |||
int | w, | |||
int | h | |||
) |
Draws a filled rectangle with the top left corner at (x,y) and the lower right corner at (x+w-1,y+h-1).
int picotk_Init | ( | isrDisp_t * | isrDisp | ) |
Initializes picoTK and the display with the given ISR dispatcher.
Clears (color=0) the display canvas. picoTK uses a canvas with an origin in the upper left corner. One LSB in the coordinate system equals a single pixel.
void picotk_PixmapDraw | ( | picotk_Pixmap * | pixmap, | |
int | x, | |||
int | y | |||
) |
Draws a pixmap at the given coordinates (upper left corner of rectangle around pixmap).
pixmap | ||
x | ||
y |
void picotk_PixmapInit | ( | picotk_Pixmap * | pixmap, | |
int | width, | |||
int | height, | |||
picotk_PixmapType | type, | |||
const unsigned short * | data | |||
) |
Given a pointer to a newly-allocated picotk_Pixmap, initializes its contents with the provided pixmap data.
This function only needs to be called once; you will still have to call picotk_DrawPixmap() to actually draw the pixmap onto a framebuffer.
pixmap | The pixmap struct to initialize | |
height | ||
width | ||
type | ||
data | A pointer to the contents of the pixmap; this depends on the pixma's type |
void picotk_plotSlackBar | ( | picotk_Color * | color, | |
int | x, | |||
int | y, | |||
unsigned char | horizontal, | |||
unsigned short | maxLen | |||
) |
Plots slack on a 1 pixel wide bar graph.
Assumption: frame rate 30Hz
void picotk_ReadyToDraw | ( | ) |
If picotk_ShowNB() was previously calls, waits until the display has finished refreshing.
If you do not call this function, the display may not be fully updated by the time you call picotk_ShowNB() again.
void picotk_Show | ( | ) |
Show the contents of the latest framebuffer onto the display.
Note that this function blocks until the frame has been committed and the next one prepared. If you intend to do some processing in between frames, call picotk_ShowNB(), perform your calculations, and then call picotk_ReadyToDraw().
void picotk_ShowNB | ( | ) |
Begins to show the display, but does not block.
Note that this function does not block; you can perform other calculations, but still need to draw picotk_ReadyToDraw() to ensure the frame syncing is done correctly
int picotk_slackGet | ( | void | ) |
Returns the nanosecs until the pending image switch is executed, or 0 if no switch is pending.
Returns nanoSec until pending image switch is executed, 0 if no switch is pending.
Pre-conditions:
Post condtions:
Parameters:
state | address of LCD state variable |
int picotk_statsGet | ( | unsigned int * | nrUpdates, | |
unsigned int * | nrSame | |||
) |
Gathers display statistics.
gathers display statistics nrUpdates number of images updated nrSame number of identical images displayed
Pre-conditions:
Post condtions:
Parameters:
state | address of LCD state variable |
void picotk_TerminalDraw | ( | picotk_Terminal * | term, | |
int | x, | |||
int | y | |||
) |
void picotk_TerminalInit | ( | picotk_Terminal * | term, | |
int | wc, | |||
int | hc, | |||
picotk_Font * | font, | |||
picotk_Color * | fgColor, | |||
picotk_Color * | bgColor | |||
) |
void picotk_TerminalPrintf | ( | picotk_Terminal * | term, | |
char * | fmt, | |||
... | ||||
) |
Types characters into the terminal according to the format string and the following parameters.
It is compatible to how POSIX printf() handles its format string. Special character are interpreted by the terminal just as with picotk_TerminalPutc().
void picotk_TerminalPutc | ( | picotk_Terminal * | term, | |
int | ch | |||
) |
Types a single character into given terminal.
The terminal handles some special ASCII characters as such, including \r (ADE 13) \n (ADE 10).
int picotk_TextHeight | ( | picotk_Font * | font, | |
char * | txt | |||
) |
Calculates the text's height in pixels, given a font and the text.
font | ||
txt |
int picotk_TextWidth | ( | picotk_Font * | font, | |
char * | txt | |||
) |
Calculates the text's width in pixels, given a font and the text.
font | ||
txt |
picotk_Buffer dBuffer [static] |
picotk_Terminal* dTerminal [static] |