void draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t c)
{
- if (x0 > hres_bytes*8 || y0 > VRES || x1 > hres_bytes*8 || y1 > VRES)
+ if (x0 > hres_bytes*8 || y0 > VRES) // || x1 > hres_bytes*8 || y1 > VRES)
return;
int dx, dy, sx, sy, err, p;
{
sp(x0, y0, c);
if ( ( x0 == x1 ) && ( y0 == y1 ) ) return;
+ if ( x0 > hres_bytes*8 || y0 > VRES ) return;
+
p = 2 * err;
if ( p > -dy )
{
_draw_circle(x0, y0, radius, c, c);
}
+void draw_8bpp_bitmap( uint8_t pos_x, uint8_t pos_y, uint8_t width, uint8_t height, const uint8_t* image )
+{
+ for ( int v = 0; v < height; v++ )
+ {
+ for ( int h = 0; h < width; h++ )
+ {
+ uint8_t t = image[v*width+h];
+ set_pixel( pos_x + h, pos_y + v, t);
+ }
+ }
+}
+
+void pgm_draw_8bpp_bitmap( uint8_t pos_x, uint8_t pos_y, uint8_t width, uint8_t height, const uint8_t* image )
+{
+ for ( int v = 0; v < height; v++ )
+ {
+ for ( int h = 0; h < width; h++ )
+ {
+ uint8_t t = pgm_read_byte(&(image[v*width+h]));
+ set_pixel( pos_x + h, pos_y + v, t);
+ }
+ }
+}
#define DRAW_H
#include <stdint.h>
+#include <avr/pgmspace.h>
#include "video_properties.h"
#define c_BLACK 0
// TODO: WILL need void draw_bitmap(uint8_t x, uint8_t y, const unsigned char * bmp, uint16_t i = 0, uint8_t width = 0, uint8_t lines = 0);
// TODO draw_bitmap() will be useful for printing text, as printing text
// TODO is drawing font elements, and font elements are ... bitmaps.
+void draw_8bpp_bitmap( uint8_t pos_x, uint8_t pos_y, uint8_t width, uint8_t height, const uint8_t* image );
+void pgm_draw_8bpp_bitmap( uint8_t pos_x, uint8_t pos_y, uint8_t width, uint8_t height, const uint8_t* image );
#endif
#include "video_properties.h"
#include "render.h"
#include "draw.h"
-#include "font.h"
+
+//#include "font.h"
+#include "testimage.h"
void (*line_handler)( void );
// Enable interrupts globally.
sei();
-/*
+ int counter;
+
// Do some static drawing :P
set_pixel(28, 8, 1);
set_pixel(92, 82, 1);
set_pixel(92, 8, 1);
set_pixel(28, 82, 1);
- draw_line(0, 0, 128, 92, 1);
- draw_line(128, 0, 0, 92, 1);
+ draw_line(0, 0, 128, 92, c_WHITE);
+ draw_line(128, 0, 0, 92, c_WHITE);
- draw_rect( 0, 1, 127, 91, 1);
+ draw_rect( 0, 1, 127, 91, c_WHITE);
- draw_rect( 34, 21, 60, 50, 1);
- _draw_rect( 24, 11, 80, 70, 1, -1);
- draw_rect( 34, 21, 60, 50, 1);
+ draw_rect( 34, 21, 60, 50, c_WHITE);
+ _draw_rect( 24, 11, 80, 70, 1, c_NONE);
+ draw_rect( 34, 21, 60, 50, c_WHITE);
- fill_circle( 64,46, 45, 1 );
- fill_circle( 64,46, 40, 0 );
+ fill_circle( 64,46, 45, c_WHITE );
+ fill_circle( 64,46, 40, c_BLACK );
- _draw_circle( 64,46, 35, 1, -1 );
- draw_circle( 64,46, 30, 1 );
- fill_rect( 38, 25, 52, 42, 1);
- fill_rect( 41, 28, 46, 36, 0);
+ _draw_circle( 64,46, 35, 1, c_NONE );
+ draw_circle( 64,46, 30, c_WHITE );
+ fill_rect( 38, 25, 52, 42, c_WHITE);
+ fill_rect( 41, 28, 46, 36, c_BLACK);
- for (;;)
+ for (counter = 0; counter < 3; counter++)
{
// Toggle status LED
PORTD ^= (uint8_t)(1 << PD6);
for ( int j = 0; j < 92; j++ )
{
- draw_line(0,0,128,j, 2);
- draw_line(128,0,0,j, 2);
- draw_line(0,92,128,92-j, 2);
- draw_line(128,92,0,92-j, 2);
+ draw_line(0,0,128,j, c_INVERT);
+ draw_line(128,0,0,j, c_INVERT);
+ draw_line(0,92,128,92-j, c_INVERT);
+ draw_line(128,92,0,92-j, c_INVERT);
Delay_ms(2);
}
for ( int j = 0; j < 92; j++ )
{
- draw_line(0,0,128,j, 2);
- draw_line(128,0,0,j, 2);
- draw_line(0,92,128,92-j, 2);
- draw_line(128,92,0,92-j, 2);
+ draw_line(0,0,128,j, c_INVERT);
+ draw_line(128,0,0,j, c_INVERT);
+ draw_line(0,92,128,92-j, c_INVERT);
+ draw_line(128,92,0,92-j, c_INVERT);
Delay_ms(2);
}
Delay_ms(250);
}
-*/
+ fill(c_BLACK);
+ int8_t hp = 10;
+ int8_t vp = 10;
+
+ for (counter = 0; counter < 100; counter++)
+ {
+ hp += 2;
+ vp += 1;
+
+ if ( hp > 125 ) hp = 10;
+ if ( vp > VRES ) vp = 10;
+
+ pgm_draw_8bpp_bitmap(hp, vp, testimage_width, testimage_height, testimage);
+ Delay_ms(10);
+ fill_rect(hp, vp, testimage_width, testimage_height, 0);
+ }
for (;;)
{
-
}
+
}
-
-
-image_widtdh = 23; // pixels
-image_height = 9; // rows
+const uint8_t testimage_width = 23; // pixels
+const uint8_t testimage_height = 9; // rows
-uint8_t image[] = {
- 0b00001111, 0b00000001, 0b11100000, 0b00100001, 0b00000100, 0b00100000
- 0b10011001, 0b00010011, 0b00100010, 0b01001001, 0b01001001, 0b00101001
- 0b00001001, 0b00100001, 0b00101001, 0b00100101, 0b00100100, 0b10001001
- 0b10010001, 0b00110010, 0b00001000, 0b01000001, 0b00001000, 0b00001111
- 0b00000001,
- 0b11100000 // Note, last byte padded to fill one byte by adding a 0 at the end..
+const uint8_t testimage[] PROGMEM = {
+ 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1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