31 #if defined(CONFIG_VGA_AVAILABLE) && defined(CONFIG_VGA_ENABLE) && defined(__AVR_ATmega328P__) 33 extern uint16_t ssd1306_color;
46 static uint8_t s_mode = 0x01;
47 static uint8_t s_vga_command = 0xFF;
48 static uint8_t s_vga_arg = 0;
49 static uint8_t s_column = 0;
50 static uint8_t s_column_end = 0;
51 static uint8_t s_cursor_x = 0;
52 static uint8_t s_cursor_y = 0;
53 volatile uint8_t s_vga_frames;
55 static void vga_controller_init(
void)
60 static void vga_controller_stop(
void)
65 static void vga_controller_close(
void)
72 static inline void vga_controller_put_pixels(uint8_t x, uint8_t y, uint8_t pixels)
74 uint16_t addr = (x >> 3) + (uint16_t)(y * 16);
75 uint8_t offset = x & 0x07;
76 uint8_t mask = 1 << offset;
81 for (uint8_t i=8; i>0; i--)
83 if (pixels & 0x01) __vga_buffer[addr] |= mask;
84 else __vga_buffer[addr] &= ~mask;
90 static void vga_controller_send_byte(uint8_t data)
92 if (s_vga_command == 0xFF)
97 if (s_vga_command == 0x40)
99 vga_controller_put_pixels(s_cursor_x, s_cursor_y, data);
101 if (s_cursor_x > s_column_end)
103 s_cursor_x = s_column;
111 s_vga_command = data;
120 s_cursor_x = s_column;
123 if (s_vga_arg == 3) { s_cursor_y = (data << 3); }
124 if (s_vga_arg == 4) { s_vga_command = 0; }
128 if (s_vga_arg == 1) { s_mode = data; s_vga_command = 0; }
133 static void vga_controller_send_bytes(
const uint8_t *buffer, uint16_t len)
142 static inline void init_vga_crt_driver(uint8_t enable_jitter_fix)
145 if (enable_jitter_fix)
158 TIMSK0 &= ~(1<<TOIE0);
162 pinMode (V_SYNC_PIN, OUTPUT);
163 TCCR1A=(1<<WGM10) | (1<<WGM11) | (1<<COM1B1);
164 TCCR1B=(1<<WGM12) | (1<<WGM13) | (1<<CS12) | (1<<CS10);
171 pinMode (H_SYNC_PIN, OUTPUT);
172 TCCR2A=(1<<WGM20) | (1<<WGM21) | (1<<COM2B1);
173 TCCR2B=(1<<WGM22) | (1<<CS21);
179 TIMSK2 = (1<<OCIE2B);
197 void ssd1306_vga_controller_128x64_init_no_output(
void)
207 void ssd1306_vga_controller_128x64_init_enable_output(
void)
209 ssd1306_vga_controller_128x64_init_no_output();
210 init_vga_crt_driver(1);
213 void ssd1306_vga_controller_128x64_init_enable_output_no_jitter_fix(
void)
215 ssd1306_vga_controller_128x64_init_no_output();
216 init_vga_crt_driver(0);
220 void ssd1306_debug_print_vga_buffer_128x64(
void (*func)(uint8_t))
226 uint8_t color = __vga_buffer[(x >> 3) + y * 16] & (1<< (x&0x07));
void(* send)(uint8_t data)
void(* close)(void)
deinitializes internal resources, allocated for interface.
ssd1306_lcd_t ssd1306_lcd
ssd1306_interface_t ssd1306_intf
void(* send_buffer)(const uint8_t *buffer, uint16_t size)
Sends bytes to SSD1306 device.