00001
00039 #ifndef GFX_H_INCLUDED
00040 #define GFX_H_INCLUDED
00041
00042 #include <assert.h>
00043 #include <hugemem.h>
00044 #include <progmem.h>
00045
00056 #ifdef CONFIG_GFX_HX8347A
00057 # include <gfx/gfx_hx8347a.h>
00058 # include <gfx/gfx_generic.h>
00059 #endif
00060
00096
00097
00098
00126
00128
00129
00131 #define GFX_OCTANT0 (1 << 0)
00132
00133 #define GFX_OCTANT1 (1 << 1)
00134
00135 #define GFX_OCTANT2 (1 << 2)
00136
00137 #define GFX_OCTANT3 (1 << 3)
00138
00139 #define GFX_OCTANT4 (1 << 4)
00140
00141 #define GFX_OCTANT5 (1 << 5)
00142
00143 #define GFX_OCTANT6 (1 << 6)
00144
00145 #define GFX_OCTANT7 (1 << 7)
00146
00148 #define GFX_QUADRANT0 (GFX_OCTANT0 | GFX_OCTANT1)
00149
00150 #define GFX_QUADRANT1 (GFX_OCTANT2 | GFX_OCTANT3)
00151
00152 #define GFX_QUADRANT2 (GFX_OCTANT4 | GFX_OCTANT5)
00153
00154 #define GFX_QUADRANT3 (GFX_OCTANT6 | GFX_OCTANT7)
00155
00157 #define GFX_LEFTHALF (GFX_QUADRANT3 | GFX_QUADRANT0)
00158
00159 #define GFX_TOPHALF (GFX_QUADRANT0 | GFX_QUADRANT1)
00160
00161 #define GFX_RIGHTHALF (GFX_QUADRANT1 | GFX_QUADRANT2)
00162
00163 #define GFX_BOTTOMHALF (GFX_QUADRANT2 | GFX_QUADRANT3)
00164
00166 #define GFX_WHOLE 0xFF
00167
00169
00171
00172
00173 #define GFX_FLIP_X 1
00174
00175 #define GFX_FLIP_Y 2
00176
00177 #define GFX_SWITCH_XY 4
00178
00179
00190
00191 #if defined(CONFIG_GFX_USE_CLIPPING) || defined(__DOXYGEN__)
00192 extern gfx_coord_t gfx_min_x;
00193 extern gfx_coord_t gfx_min_y;
00194 extern gfx_coord_t gfx_max_x;
00195 extern gfx_coord_t gfx_max_y;
00196 #endif
00197
00198 extern gfx_coord_t gfx_width;
00199 extern gfx_coord_t gfx_height;
00200
00201
00206 enum font_data_type{
00208 FONT_LOC_PROGMEM,
00210 FONT_LOC_HUGEMEM,
00211 };
00212
00214 struct font {
00216 enum font_data_type type;
00217 union {
00222 hugemem_ptr_t hugemem;
00223 const uint8_t __progmem_arg *progmem;
00224 } data;
00226 uint8_t width;
00228 uint8_t height;
00230 uint8_t scale;
00232 uint8_t first_char;
00234 uint8_t last_char;
00235 };
00236
00242 static inline uint_fast8_t gfx_font_get_height(struct font *font)
00243 {
00244 return (font->height * font->scale);
00245 }
00246
00252 static inline uint_fast8_t gfx_font_get_width(struct font *font)
00253 {
00254 return (font->width * font->scale);
00255 }
00256
00261
00265 enum gfx_bitmap_type {
00267 BITMAP_SOLID,
00269 BITMAP_RAM,
00271 BITMAP_PROGMEM,
00272 #ifdef CONFIG_HUGEMEM
00273
00274 BITMAP_HUGEMEM,
00275 #endif
00276 };
00277
00281 struct gfx_bitmap {
00283 gfx_coord_t width;
00285 gfx_coord_t height;
00287 enum gfx_bitmap_type type;
00288 union {
00290 gfx_color_t color;
00292 gfx_color_t *pixmap;
00294 const gfx_color_t __progmem_arg *progmem;
00295 #ifdef CONFIG_HUGEMEM
00296
00297 hugemem_ptr_t hugemem;
00298 #endif
00299 } data;
00300 };
00301
00302 void gfx_draw_bitmap(const struct gfx_bitmap *bmp, gfx_coord_t x,
00303 gfx_coord_t y);
00304
00305 void gfx_draw_bitmap_tiled(const struct gfx_bitmap *bmp, gfx_coord_t x1,
00306 gfx_coord_t y1, gfx_coord_t x2, gfx_coord_t y2,
00307 gfx_coord_t tile_origin_x, gfx_coord_t tile_origin_y);
00308
00309 void gfx_put_bitmap(const struct gfx_bitmap *bmp, gfx_coord_t map_x,
00310 gfx_coord_t map_y, gfx_coord_t x, gfx_coord_t y, gfx_coord_t width,
00311 gfx_coord_t height);
00312
00314
00315
00317
00318
00324 void gfx_init(void);
00325
00339 void gfx_sync(void);
00340
00342
00344
00345
00362 void gfx_set_orientation(uint8_t flags);
00363
00372 gfx_coord_t gfx_get_width(void);
00373
00382 gfx_coord_t gfx_get_height(void);
00383
00412
00425 void gfx_set_clipping(gfx_coord_t min_x, gfx_coord_t min_y,
00426 gfx_coord_t max_x, gfx_coord_t max_y);
00427
00437 void gfx_set_top_left_limit(gfx_coord_t x, gfx_coord_t y);
00438
00448 void gfx_set_bottom_right_limit(gfx_coord_t x, gfx_coord_t y);
00449
00461 void gfx_set_limits(gfx_coord_t x1, gfx_coord_t y1,
00462 gfx_coord_t x2, gfx_coord_t y2);
00463
00465
00467
00468
00484 gfx_color_t gfx_color(uint8_t r, uint8_t g, uint8_t b);
00485
00496 void gfx_draw_pixel(gfx_coord_t x, gfx_coord_t y, gfx_color_t color);
00497
00509 void gfx_draw_line_pixel(gfx_coord_t x, gfx_coord_t y, gfx_color_t color);
00510
00520 gfx_color_t gfx_get_pixel(gfx_coord_t x, gfx_coord_t y);
00521
00531 void gfx_duplicate_pixel(gfx_color_t color, uint32_t count);
00532
00541 void gfx_copy_pixels_to_screen(const gfx_color_t *pixels, uint32_t count);
00542
00553 void gfx_copy_progmem_pixels_to_screen(const gfx_color_t __progmem_arg *pixels,
00554 uint32_t count);
00555
00566 void gfx_copy_hugemem_pixels_to_screen(const hugemem_ptr_t pixels,
00567 uint32_t count);
00568
00577 void gfx_copy_pixels_from_screen(gfx_color_t *pixels, uint32_t count);
00578
00580
00582
00583
00739 void gfx_draw_char(char c, gfx_coord_t x, gfx_coord_t y, struct font* font,
00740 gfx_color_t color, gfx_color_t background_color);
00741
00755 void gfx_draw_string(char* str, gfx_coord_t x, gfx_coord_t y, struct font* font,
00756 gfx_color_t color, gfx_color_t background_color);
00757
00771 void gfx_draw_progmem_string(const char __progmem_arg *str, gfx_coord_t x,
00772 gfx_coord_t y, struct font *font, gfx_color_t color,
00773 gfx_color_t background_color);
00774
00786 void gfx_get_string_bounding_box(char const *str, struct font* font,
00787 gfx_coord_t *width, gfx_coord_t *height);
00788
00800 void gfx_get_progmem_string_bounding_box(const char __progmem_arg *str,
00801 struct font *font, gfx_coord_t *width, gfx_coord_t *height);
00802
00804
00806
00807 #endif