]>
git.defcon.no Git - avrfbosd/blob - fbosd.c
2 #include <avr/interrupt.h>
3 #include <util/delay.h>
5 #include <avr/pgmspace.h>
7 #include "video_properties.h"
12 #include "testimage.h"
14 void (*line_handler
)( void );
16 const int vres_scale
= ( SCREEN_LINES
/ VRES
-1 );
17 const int hres_bytes
= HRES
/ 8;
19 volatile uint8_t* screen_buffer
;
22 volatile int buffer_position
;
24 void Delay_ms(int cnt
)
26 while(cnt
-->0) _delay_ms(1);
29 void set_busy ( uint8_t busy
)
36 // TODO: Disable SPI communication here...
41 PORTB
&= ~(uint8_t)(1 << PB1
);
43 // TODO: Enable SPI communication here...
47 void active_lines ( void )
53 // Set Busy signal. Line rendering is time-critical.
60 if ( buffer_position
< ((VRES
*hres_bytes
)) )
61 buffer_position
+= hres_bytes
;
68 void blank_lines ( void )
70 // Do nothing on the "lead-in" lines
71 if ( line
< FIRST_LINE
)
74 // Clear Frame Ready signal
75 PORTD
&= ~(uint8_t)(1 << PD5
);
78 line_handler
= active_lines
;
89 line_handler
= &blank_lines
;
90 EIMSK
&= ~(uint8_t)(1<<INT1
);
92 // Set Frame Ready signal
100 // VSync is getting close to done.
101 // Set line-handler to blank-handler to count-up the undesired lines,
102 // and enable HSync interrupts.
104 line_handler
= &blank_lines
;
113 // Note: PB0 is used as CLKO outputting 20MHz clock to ATtiny
115 // Set PB2 as Output for BUSY signal
118 // Set PD5 as Output for FR signal
119 // Set PD6 as Output for Status LED
120 // Using pin 7 on PD to clock out pixels \o/
121 DDRD
= (1<<PD5
)|(1<<PD6
)|(1<<PD7
);
123 // Clear PORTB and PORTD
127 // Allocate the framebuffer :D
128 screen_buffer
= (uint8_t*) malloc( hres_bytes
* VRES
* sizeof(uint8_t) );
129 // And make sure it's cleared
132 /* LM1881 pins are connected to:
133 INT0 / PCINT18 / PD2 <- VSYNC
134 INT1 / PCINT19 / PD3 <- CSYNC
135 PCINT20 / PD4 <- ODD/EVEN
137 EICRA
|= (1<<ISC01
)|(1<<ISC00
); // Select Rising-edge interrupt for VSync
138 EICRA
|= (1<<ISC11
)|(1<<ISC10
); // Select Rising-edge interrupt for HSync
139 EIMSK
|= (1<<INT0
); // Enable VSync-interrupts
141 // Enable interrupts globally.
146 // Do some static drawing :P
148 set_pixel(92, 82, 1);
151 set_pixel(28, 82, 1);
153 draw_line(0, 0, 128, 92, c_WHITE
);
154 draw_line(128, 0, 0, 92, c_WHITE
);
156 draw_rect( 0, 1, 127, 91, c_WHITE
);
158 draw_rect( 34, 21, 60, 50, c_WHITE
);
159 _draw_rect( 24, 11, 80, 70, 1, c_NONE
);
160 draw_rect( 34, 21, 60, 50, c_WHITE
);
162 fill_circle( 64,46, 45, c_WHITE
);
163 fill_circle( 64,46, 40, c_BLACK
);
165 _draw_circle( 64,46, 35, 1, c_NONE
);
166 draw_circle( 64,46, 30, c_WHITE
);
167 fill_rect( 38, 25, 52, 42, c_WHITE
);
168 fill_rect( 41, 28, 46, 36, c_BLACK
);
170 for (counter
= 0; counter
< 3; counter
++)
173 PORTD
^= (uint8_t)(1 << PD6
);
175 for ( int j
= 0; j
< 92; j
++ )
177 draw_line(0,0,128,j
, c_INVERT
);
178 draw_line(128,0,0,j
, c_INVERT
);
179 draw_line(0,92,128,92-j
, c_INVERT
);
180 draw_line(128,92,0,92-j
, c_INVERT
);
185 for ( int j
= 0; j
< 92; j
++ )
187 draw_line(0,0,128,j
, c_INVERT
);
188 draw_line(128,0,0,j
, c_INVERT
);
189 draw_line(0,92,128,92-j
, c_INVERT
);
190 draw_line(128,92,0,92-j
, c_INVERT
);
202 for (counter
= 0; counter
< 100; counter
++)
207 if ( hp
> 125 ) hp
= 10;
208 if ( vp
> VRES
) vp
= 10;
210 pgm_draw_8bpp_bitmap(hp
, vp
, testimage_width
, testimage_height
, testimage
);
212 fill_rect(hp
, vp
, testimage_width
, testimage_height
, 0);