]>
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"
11 #include "testimage.h"
13 void (*line_handler
)( void );
15 const int vres_scale
= ( SCREEN_LINES
/ VRES
-1 );
16 const int hres_bytes
= HRES
/ 8;
18 volatile uint8_t* screen_buffer
;
21 volatile int buffer_position
;
23 void Delay_ms(int cnt
)
25 while(cnt
-->0) _delay_ms(1);
28 void set_busy ( uint8_t busy
)
35 // TODO: Disable SPI communication here...
40 PORTB
&= ~(uint8_t)(1 << PB1
);
42 // TODO: Enable SPI communication here...
46 void active_lines ( void )
52 // Set Busy signal. Line rendering is time-critical.
59 if ( buffer_position
< ((VRES
*hres_bytes
)) )
60 buffer_position
+= hres_bytes
;
67 void blank_lines ( void )
69 // Do nothing on the "lead-in" lines
70 if ( line
< FIRST_LINE
)
73 // Clear Frame Ready signal
74 PORTD
&= ~(uint8_t)(1 << PD5
);
77 line_handler
= active_lines
;
88 line_handler
= &blank_lines
;
89 EIMSK
&= ~(uint8_t)(1<<INT1
);
91 // Set Frame Ready signal
99 // VSync is getting close to done.
100 // Set line-handler to blank-handler to count-up the undesired lines,
101 // and enable HSync interrupts.
103 line_handler
= &blank_lines
;
112 // Note: PB0 is used as CLKO outputting 20MHz clock to ATtiny
114 // Set PB2 as Output for BUSY signal
117 // Set PD5 as Output for FR signal
118 // Set PD6 as Output for Status LED
119 // Using pin 7 on PD to clock out pixels \o/
120 DDRD
= (1<<PD5
)|(1<<PD6
)|(1<<PD7
);
122 // Clear PORTB and PORTD
126 // Allocate the framebuffer :D
127 screen_buffer
= (uint8_t*) malloc( hres_bytes
* VRES
* sizeof(uint8_t) );
128 // And make sure it's cleared
131 /* LM1881 pins are connected to:
132 INT0 / PCINT18 / PD2 <- VSYNC
133 INT1 / PCINT19 / PD3 <- CSYNC
134 PCINT20 / PD4 <- ODD/EVEN
136 EICRA
|= (1<<ISC01
)|(1<<ISC00
); // Select Rising-edge interrupt for VSync
137 EICRA
|= (1<<ISC11
)|(1<<ISC10
); // Select Rising-edge interrupt for HSync
138 EIMSK
|= (1<<INT0
); // Enable VSync-interrupts
140 // Enable interrupts globally.
143 // Switch ON status LED
144 PORTD
|= (uint8_t)(1 << PD6
);
151 draw_string( 2, 2, "!\"#$%&'()*+-./");
152 draw_string( 2, 10, "01234567890");
153 draw_string( 2, 18, ":;<=>?@");
154 draw_string( 2, 26, "ABCDEFGHIJKLM");
155 draw_string( 2, 34, "NOPQRSTUVWXYZ");
156 draw_string( 2, 42, "[\\]^_`");
157 draw_string( 2, 50, "ABCDEFGHIJKLM");
158 draw_string( 2, 58, "NOPQRSTUVWXYZ");
159 draw_string( 2, 66, "{|}~");
161 draw_char( 10, 80, 127);
162 draw_char( 20, 80, 128);
163 draw_char( 30, 80, 129);
164 draw_char( 40, 80, 130);
169 // Do some static drawing :P
171 set_pixel(92, 82, 1);
174 set_pixel(28, 82, 1);
176 draw_line(0, 0, 128, 92, c_WHITE
);
177 draw_line(128, 0, 0, 92, c_WHITE
);
179 draw_rect( 0, 1, 127, 91, c_WHITE
);
181 draw_rect( 34, 21, 60, 50, c_WHITE
);
182 _draw_rect( 24, 11, 80, 70, 1, c_NONE
);
183 draw_rect( 34, 21, 60, 50, c_WHITE
);
185 fill_circle( 64,46, 45, c_WHITE
);
186 fill_circle( 64,46, 40, c_BLACK
);
188 _draw_circle( 64,46, 35, 1, c_NONE
);
189 draw_circle( 64,46, 30, c_WHITE
);
190 fill_rect( 38, 25, 52, 42, c_WHITE
);
191 fill_rect( 41, 28, 46, 36, c_BLACK
);
193 for ( int j
= 0; j
< 92; j
++ )
195 draw_line(0,0,128,j
, c_INVERT
);
196 draw_line(128,0,0,j
, c_INVERT
);
197 draw_line(0,92,128,92-j
, c_INVERT
);
198 draw_line(128,92,0,92-j
, c_INVERT
);
203 for ( int j
= 0; j
< 92; j
++ )
205 draw_line(0,0,128,j
, c_INVERT
);
206 draw_line(128,0,0,j
, c_INVERT
);
207 draw_line(0,92,128,92-j
, c_INVERT
);
208 draw_line(128,92,0,92-j
, c_INVERT
);
220 for (counter
= 0; counter
< 60; counter
++)
225 if ( hp
> 125 ) hp
= 10;
226 if ( vp
> VRES
) vp
= 10;
228 pgm_draw_8bpp_bitmap(hp
, vp
, testimage_width
, testimage_height
, testimage
);
230 fill_rect(hp
, vp
, testimage_width
, testimage_height
, 0);