diff --git a/Arduino/libraries/PS2Keyboard/PS2Keyboard.cpp b/Arduino/libraries/PS2Keyboard/PS2Keyboard.cpp new file mode 100644 index 0000000..730e7ef --- /dev/null +++ b/Arduino/libraries/PS2Keyboard/PS2Keyboard.cpp @@ -0,0 +1,545 @@ +/* + PS2Keyboard.cpp - PS2Keyboard library + Copyright (c) 2007 Free Software Foundation. All right reserved. + Written by Christian Weichel + + ** Mostly rewritten Paul Stoffregen 2010, 2011 + ** Modified for use beginning with Arduino 13 by L. Abraham Smith, * + ** Modified for easy interrup pin assignement on method begin(datapin,irq_pin). Cuningan ** + + for more information you can read the original wiki in arduino.cc + at http://www.arduino.cc/playground/Main/PS2Keyboard + or http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html + + Version 2.4 (March 2013) + - Support Teensy 3.0, Arduino Due, Arduino Leonardo & other boards + - French keyboard layout, David Chochoi, tchoyyfr at yahoo dot fr + + Version 2.3 (October 2011) + - Minor bugs fixed + + Version 2.2 (August 2011) + - Support non-US keyboards - thanks to Rainer Bruch for a German keyboard :) + + Version 2.1 (May 2011) + - timeout to recover from misaligned input + - compatibility with Arduino "new-extension" branch + - TODO: send function, proposed by Scott Penrose, scooterda at me dot com + + Version 2.0 (June 2010) + - Buffering added, many scan codes can be captured without data loss + if your sketch is busy doing other work + - Shift keys supported, completely rewritten scan code to ascii + - Slow linear search replaced with fast indexed table lookups + - Support for Teensy, Arduino Mega, and Sanguino added + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "PS2Keyboard.h" + +#define BUFFER_SIZE 45 +static volatile uint8_t buffer[BUFFER_SIZE]; +static volatile uint8_t head, tail; +static uint8_t DataPin; +static uint8_t CharBuffer=0; +static uint8_t UTF8next=0; +static const PS2Keymap_t *keymap=NULL; + +// The ISR for the external interrupt +void ps2interrupt(void) +{ + static uint8_t bitcount=0; + static uint8_t incoming=0; + static uint32_t prev_ms=0; + uint32_t now_ms; + uint8_t n, val; + + val = digitalRead(DataPin); + now_ms = millis(); + if (now_ms - prev_ms > 250) { + bitcount = 0; + incoming = 0; + } + prev_ms = now_ms; + n = bitcount - 1; + if (n <= 7) { + incoming |= (val << n); + } + bitcount++; + if (bitcount == 11) { + uint8_t i = head + 1; + if (i >= BUFFER_SIZE) i = 0; + if (i != tail) { + buffer[i] = incoming; + head = i; + } + bitcount = 0; + incoming = 0; + } +} + +static inline uint8_t get_scan_code(void) +{ + uint8_t c, i; + + i = tail; + if (i == head) return 0; + i++; + if (i >= BUFFER_SIZE) i = 0; + c = buffer[i]; + tail = i; + return c; +} + +// http://www.quadibloc.com/comp/scan.htm +// http://www.computer-engineering.org/ps2keyboard/scancodes2.html + +// These arrays provide a simple key map, to turn scan codes into ISO8859 +// output. If a non-US keyboard is used, these may need to be modified +// for the desired output. +// + +const PROGMEM PS2Keymap_t PS2Keymap_US = { + // without shift + {0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12, + 0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, '`', 0, + 0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'q', '1', 0, + 0, 0, 'z', 's', 'a', 'w', '2', 0, + 0, 'c', 'x', 'd', 'e', '4', '3', 0, + 0, ' ', 'v', 'f', 't', 'r', '5', 0, + 0, 'n', 'b', 'h', 'g', 'y', '6', 0, + 0, 0, 'm', 'j', 'u', '7', '8', 0, + 0, ',', 'k', 'i', 'o', '0', '9', 0, + 0, '.', '/', 'l', ';', 'p', '-', 0, + 0, 0, '\'', 0, '[', '=', 0, 0, + 0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, ']', 0, '\\', 0, 0, + 0, 0, 0, 0, 0, 0, PS2_BACKSPACE, 0, + 0, '1', 0, '4', '7', 0, 0, 0, + '0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/, + PS2_F11, '+', '3', '-', '*', '9', PS2_SCROLL, 0, + 0, 0, 0, PS2_F7 }, + // with shift + {0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12, + 0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, '~', 0, + 0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'Q', '!', 0, + 0, 0, 'Z', 'S', 'A', 'W', '@', 0, + 0, 'C', 'X', 'D', 'E', '$', '#', 0, + 0, ' ', 'V', 'F', 'T', 'R', '%', 0, + 0, 'N', 'B', 'H', 'G', 'Y', '^', 0, + 0, 0, 'M', 'J', 'U', '&', '*', 0, + 0, '<', 'K', 'I', 'O', ')', '(', 0, + 0, '>', '?', 'L', ':', 'P', '_', 0, + 0, 0, '"', 0, '{', '+', 0, 0, + 0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, '}', 0, '|', 0, 0, + 0, 0, 0, 0, 0, 0, PS2_BACKSPACE, 0, + 0, '1', 0, '4', '7', 0, 0, 0, + '0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/, + PS2_F11, '+', '3', '-', '*', '9', PS2_SCROLL, 0, + 0, 0, 0, PS2_F7 }, + 0 +}; + + +const PROGMEM PS2Keymap_t PS2Keymap_German = { + // without shift + {0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12, + 0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, '^', 0, + 0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'q', '1', 0, + 0, 0, 'y', 's', 'a', 'w', '2', 0, + 0, 'c', 'x', 'd', 'e', '4', '3', 0, + 0, ' ', 'v', 'f', 't', 'r', '5', 0, + 0, 'n', 'b', 'h', 'g', 'z', '6', 0, + 0, 0, 'm', 'j', 'u', '7', '8', 0, + 0, ',', 'k', 'i', 'o', '0', '9', 0, + 0, '.', '-', 'l', PS2_o_DIAERESIS, 'p', PS2_SHARP_S, 0, + 0, 0, PS2_a_DIAERESIS, 0, PS2_u_DIAERESIS, '\'', 0, 0, + 0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, '+', 0, '#', 0, 0, + 0, '<', 0, 0, 0, 0, PS2_BACKSPACE, 0, + 0, '1', 0, '4', '7', 0, 0, 0, + '0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/, + PS2_F11, '+', '3', '-', '*', '9', PS2_SCROLL, 0, + 0, 0, 0, PS2_F7 }, + // with shift + {0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12, + 0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, PS2_DEGREE_SIGN, 0, + 0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'Q', '!', 0, + 0, 0, 'Y', 'S', 'A', 'W', '"', 0, + 0, 'C', 'X', 'D', 'E', '$', PS2_SECTION_SIGN, 0, + 0, ' ', 'V', 'F', 'T', 'R', '%', 0, + 0, 'N', 'B', 'H', 'G', 'Z', '&', 0, + 0, 0, 'M', 'J', 'U', '/', '(', 0, + 0, ';', 'K', 'I', 'O', '=', ')', 0, + 0, ':', '_', 'L', PS2_O_DIAERESIS, 'P', '?', 0, + 0, 0, PS2_A_DIAERESIS, 0, PS2_U_DIAERESIS, '`', 0, 0, + 0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, '*', 0, '\'', 0, 0, + 0, '>', 0, 0, 0, 0, PS2_BACKSPACE, 0, + 0, '1', 0, '4', '7', 0, 0, 0, + '0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/, + PS2_F11, '+', '3', '-', '*', '9', PS2_SCROLL, 0, + 0, 0, 0, PS2_F7 }, + 1, + // with altgr + {0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12, + 0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, 0, 0, + 0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, '@', 0, 0, + 0, 0, 0, 0, 0, 0, PS2_SUPERSCRIPT_TWO, 0, + 0, 0, 0, 0, PS2_CURRENCY_SIGN, 0, PS2_SUPERSCRIPT_THREE, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, PS2_MICRO_SIGN, 0, 0, '{', '[', 0, + 0, 0, 0, 0, 0, '}', ']', 0, + 0, 0, 0, 0, 0, 0, '\\', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, '~', 0, '#', 0, 0, + 0, '|', 0, 0, 0, 0, PS2_BACKSPACE, 0, + 0, '1', 0, '4', '7', 0, 0, 0, + '0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/, + PS2_F11, '+', '3', '-', '*', '9', PS2_SCROLL, 0, + 0, 0, 0, PS2_F7 } +}; + + +const PROGMEM PS2Keymap_t PS2Keymap_French = { + // without shift + {0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12, + 0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, PS2_SUPERSCRIPT_TWO, 0, + 0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'a', '&', 0, + 0, 0, 'w', 's', 'q', 'z', PS2_e_ACUTE, 0, + 0, 'c', 'x', 'd', 'e', '\'', '"', 0, + 0, ' ', 'v', 'f', 't', 'r', '(', 0, + 0, 'n', 'b', 'h', 'g', 'y', '-', 0, + 0, 0, ',', 'j', 'u', PS2_e_GRAVE, '_', 0, + 0, ';', 'k', 'i', 'o', PS2_a_GRAVE, PS2_c_CEDILLA, 0, + 0, ':', '!', 'l', 'm', 'p', ')', 0, + 0, 0, PS2_u_GRAVE, 0, '^', '=', 0, 0, + 0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, '$', 0, '*', 0, 0, + 0, '<', 0, 0, 0, 0, PS2_BACKSPACE, 0, + 0, '1', 0, '4', '7', 0, 0, 0, + '0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/, + PS2_F11, '+', '3', '-', '*', '9', PS2_SCROLL, 0, + 0, 0, 0, PS2_F7 }, + // with shift + {0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12, + 0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, 0, 0, + 0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'A', '1', 0, + 0, 0, 'W', 'S', 'Q', 'Z', '2', 0, + 0, 'C', 'X', 'D', 'E', '4', '3', 0, + 0, ' ', 'V', 'F', 'T', 'R', '5', 0, + 0, 'N', 'B', 'H', 'G', 'Y', '6', 0, + 0, 0, '?', 'J', 'U', '7', '8', 0, + 0, '.', 'K', 'I', 'O', '0', '9', 0, + 0, '/', PS2_SECTION_SIGN, 'L', 'M', 'P', PS2_DEGREE_SIGN, 0, + 0, 0, '%', 0, PS2_DIAERESIS, '+', 0, 0, + 0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, PS2_POUND_SIGN, 0, PS2_MICRO_SIGN, 0, 0, + 0, '>', 0, 0, 0, 0, PS2_BACKSPACE, 0, + 0, '1', 0, '4', '7', 0, 0, 0, + '0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/, + PS2_F11, '+', '3', '-', '*', '9', PS2_SCROLL, 0, + 0, 0, 0, PS2_F7 }, + 1, + // with altgr + {0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12, + 0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, 0, 0, + 0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, '@', 0, 0, + 0, 0, 0, 0, 0, 0, '~', 0, + 0, 0, 0, 0, 0 /*PS2_EURO_SIGN*/, '{', '#', 0, + 0, 0, 0, 0, 0, 0, '[', 0, + 0, 0, 0, 0, 0, 0, '|', 0, + 0, 0, 0, 0, 0, '`', '\\', 0, + 0, 0, 0, 0, 0, '@', '^', 0, + 0, 0, 0, 0, 0, 0, ']', 0, + 0, 0, 0, 0, 0, 0, '}', 0, + 0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, '¤', 0, '#', 0, 0, + 0, '|', 0, 0, 0, 0, PS2_BACKSPACE, 0, + 0, '1', 0, '4', '7', 0, 0, 0, + '0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/, + PS2_F11, '+', '3', '-', '*', '9', PS2_SCROLL, 0, + 0, 0, 0, PS2_F7 } +}; + + +#define BREAK 0x01 +#define MODIFIER 0x02 +#define SHIFT_L 0x04 +#define SHIFT_R 0x08 +#define ALTGR 0x10 + +static char get_iso8859_code(void) +{ + static uint8_t state=0; + uint8_t s; + char c; + + while (1) { + s = get_scan_code(); + if (!s) return 0; + if (s == 0xF0) { + state |= BREAK; + } else if (s == 0xE0) { + state |= MODIFIER; + } else { + if (state & BREAK) { + if (s == 0x12) { + state &= ~SHIFT_L; + } else if (s == 0x59) { + state &= ~SHIFT_R; + } else if (s == 0x11 && (state & MODIFIER)) { + state &= ~ALTGR; + } + // CTRL, ALT & WIN keys could be added + // but is that really worth the overhead? + state &= ~(BREAK | MODIFIER); + continue; + } + if (s == 0x12) { + state |= SHIFT_L; + continue; + } else if (s == 0x59) { + state |= SHIFT_R; + continue; + } else if (s == 0x11 && (state & MODIFIER)) { + state |= ALTGR; + } + c = 0; + if (state & MODIFIER) { + switch (s) { + case 0x70: c = PS2_INSERT; break; + case 0x6C: c = PS2_HOME; break; + case 0x7D: c = PS2_PAGEUP; break; + case 0x71: c = PS2_DELETE; break; + case 0x69: c = PS2_END; break; + case 0x7A: c = PS2_PAGEDOWN; break; + case 0x75: c = PS2_UPARROW; break; + case 0x6B: c = PS2_LEFTARROW; break; + case 0x72: c = PS2_DOWNARROW; break; + case 0x74: c = PS2_RIGHTARROW; break; + case 0x4A: c = '/'; break; + case 0x5A: c = PS2_ENTER; break; + default: break; + } + } else if ((state & ALTGR) && keymap->uses_altgr) { + if (s < PS2_KEYMAP_SIZE) + c = pgm_read_byte(keymap->altgr + s); + } else if (state & (SHIFT_L | SHIFT_R)) { + if (s < PS2_KEYMAP_SIZE) + c = pgm_read_byte(keymap->shift + s); + } else { + if (s < PS2_KEYMAP_SIZE) + c = pgm_read_byte(keymap->noshift + s); + } + state &= ~(BREAK | MODIFIER); + if (c) return c; + } + } +} + +bool PS2Keyboard::available() { + if (CharBuffer || UTF8next) return true; + CharBuffer = get_iso8859_code(); + if (CharBuffer) return true; + return false; +} + +int PS2Keyboard::read() { + uint8_t result; + + result = UTF8next; + if (result) { + UTF8next = 0; + } else { + result = CharBuffer; + if (result) { + CharBuffer = 0; + } else { + result = get_iso8859_code(); + } + if (result >= 128) { + UTF8next = (result & 0x3F) | 0x80; + result = ((result >> 6) & 0x1F) | 0xC0; + } + } + if (!result) return -1; + return result; +} + +int PS2Keyboard::readUnicode() { + int result; + + result = CharBuffer; + if (!result) result = get_iso8859_code(); + if (!result) return -1; + UTF8next = 0; + CharBuffer = 0; + return result; +} + +PS2Keyboard::PS2Keyboard() { + // nothing to do here, begin() does it all +} + +void PS2Keyboard::begin(uint8_t data_pin, uint8_t irq_pin, const PS2Keymap_t &map) { + uint8_t irq_num=255; + + DataPin = data_pin; + keymap = ↦ + + // initialize the pins +#ifdef INPUT_PULLUP + pinMode(irq_pin, INPUT_PULLUP); + pinMode(data_pin, INPUT_PULLUP); +#else + pinMode(irq_pin, INPUT); + digitalWrite(irq_pin, HIGH); + pinMode(data_pin, INPUT); + digitalWrite(data_pin, HIGH); +#endif + +#ifdef CORE_INT_EVERY_PIN + irq_num = irq_pin; + +#else + switch(irq_pin) { + #ifdef CORE_INT0_PIN + case CORE_INT0_PIN: + irq_num = 0; + break; + #endif + #ifdef CORE_INT1_PIN + case CORE_INT1_PIN: + irq_num = 1; + break; + #endif + #ifdef CORE_INT2_PIN + case CORE_INT2_PIN: + irq_num = 2; + break; + #endif + #ifdef CORE_INT3_PIN + case CORE_INT3_PIN: + irq_num = 3; + break; + #endif + #ifdef CORE_INT4_PIN + case CORE_INT4_PIN: + irq_num = 4; + break; + #endif + #ifdef CORE_INT5_PIN + case CORE_INT5_PIN: + irq_num = 5; + break; + #endif + #ifdef CORE_INT6_PIN + case CORE_INT6_PIN: + irq_num = 6; + break; + #endif + #ifdef CORE_INT7_PIN + case CORE_INT7_PIN: + irq_num = 7; + break; + #endif + #ifdef CORE_INT8_PIN + case CORE_INT8_PIN: + irq_num = 8; + break; + #endif + #ifdef CORE_INT9_PIN + case CORE_INT9_PIN: + irq_num = 9; + break; + #endif + #ifdef CORE_INT10_PIN + case CORE_INT10_PIN: + irq_num = 10; + break; + #endif + #ifdef CORE_INT11_PIN + case CORE_INT11_PIN: + irq_num = 11; + break; + #endif + #ifdef CORE_INT12_PIN + case CORE_INT12_PIN: + irq_num = 12; + break; + #endif + #ifdef CORE_INT13_PIN + case CORE_INT13_PIN: + irq_num = 13; + break; + #endif + #ifdef CORE_INT14_PIN + case CORE_INT14_PIN: + irq_num = 14; + break; + #endif + #ifdef CORE_INT15_PIN + case CORE_INT15_PIN: + irq_num = 15; + break; + #endif + #ifdef CORE_INT16_PIN + case CORE_INT16_PIN: + irq_num = 16; + break; + #endif + #ifdef CORE_INT17_PIN + case CORE_INT17_PIN: + irq_num = 17; + break; + #endif + #ifdef CORE_INT18_PIN + case CORE_INT18_PIN: + irq_num = 18; + break; + #endif + #ifdef CORE_INT19_PIN + case CORE_INT19_PIN: + irq_num = 19; + break; + #endif + #ifdef CORE_INT20_PIN + case CORE_INT20_PIN: + irq_num = 20; + break; + #endif + #ifdef CORE_INT21_PIN + case CORE_INT21_PIN: + irq_num = 21; + break; + #endif + #ifdef CORE_INT22_PIN + case CORE_INT22_PIN: + irq_num = 22; + break; + #endif + #ifdef CORE_INT23_PIN + case CORE_INT23_PIN: + irq_num = 23; + break; + #endif + } +#endif + + head = 0; + tail = 0; + if (irq_num < 255) { + attachInterrupt(irq_num, ps2interrupt, FALLING); + } +} + + diff --git a/Arduino/libraries/PS2Keyboard/PS2Keyboard.h b/Arduino/libraries/PS2Keyboard/PS2Keyboard.h new file mode 100644 index 0000000..5f40aaf --- /dev/null +++ b/Arduino/libraries/PS2Keyboard/PS2Keyboard.h @@ -0,0 +1,212 @@ +/* + PS2Keyboard.h - PS2Keyboard library + Copyright (c) 2007 Free Software Foundation. All right reserved. + Written by Christian Weichel + + ** Mostly rewritten Paul Stoffregen , June 2010 + ** Modified for use with Arduino 13 by L. Abraham Smith, * + ** Modified for easy interrup pin assignement on method begin(datapin,irq_pin). Cuningan ** + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + + +#ifndef PS2Keyboard_h +#define PS2Keyboard_h + +#if defined(ARDUINO) && ARDUINO >= 100 +#include "Arduino.h" // for attachInterrupt, FALLING +#else +#include "WProgram.h" +#endif + +#include "utility/int_pins.h" + +// Every call to read() returns a single byte for each +// keystroke. These configure what byte will be returned +// for each "special" key. To ignore a key, use zero. +#define PS2_TAB 9 +#define PS2_ENTER 13 +#define PS2_BACKSPACE 127 +#define PS2_ESC 27 +#define PS2_INSERT 0 +#define PS2_DELETE 127 +#define PS2_HOME 0 +#define PS2_END 0 +#define PS2_PAGEUP 25 +#define PS2_PAGEDOWN 26 +#define PS2_UPARROW 11 +#define PS2_LEFTARROW 8 +#define PS2_DOWNARROW 10 +#define PS2_RIGHTARROW 21 +#define PS2_F1 0 +#define PS2_F2 0 +#define PS2_F3 0 +#define PS2_F4 0 +#define PS2_F5 0 +#define PS2_F6 0 +#define PS2_F7 0 +#define PS2_F8 0 +#define PS2_F9 0 +#define PS2_F10 0 +#define PS2_F11 0 +#define PS2_F12 0 +#define PS2_SCROLL 0 + +#define PS2_INVERTED_EXCLAMATION 161 // ¡ +#define PS2_CENT_SIGN 162 // ¢ +#define PS2_POUND_SIGN 163 // £ +#define PS2_CURRENCY_SIGN 164 // ¤ +#define PS2_YEN_SIGN 165 // ¥ +#define PS2_BROKEN_BAR 166 // ¦ +#define PS2_SECTION_SIGN 167 // § +#define PS2_DIAERESIS 168 // ¨ +#define PS2_COPYRIGHT_SIGN 169 // © +#define PS2_FEMININE_ORDINAL 170 // ª +#define PS2_LEFT_DOUBLE_ANGLE_QUOTE 171 // « +#define PS2_NOT_SIGN 172 // ¬ +#define PS2_HYPHEN 173 +#define PS2_REGISTERED_SIGN 174 // ® +#define PS2_MACRON 175 // ¯ +#define PS2_DEGREE_SIGN 176 // ° +#define PS2_PLUS_MINUS_SIGN 177 // ± +#define PS2_SUPERSCRIPT_TWO 178 // ² +#define PS2_SUPERSCRIPT_THREE 179 // ³ +#define PS2_ACUTE_ACCENT 180 // ´ +#define PS2_MICRO_SIGN 181 // µ +#define PS2_PILCROW_SIGN 182 // ¶ +#define PS2_MIDDLE_DOT 183 // · +#define PS2_CEDILLA 184 // ¸ +#define PS2_SUPERSCRIPT_ONE 185 // ¹ +#define PS2_MASCULINE_ORDINAL 186 // º +#define PS2_RIGHT_DOUBLE_ANGLE_QUOTE 187 // » +#define PS2_FRACTION_ONE_QUARTER 188 // ¼ +#define PS2_FRACTION_ONE_HALF 189 // ½ +#define PS2_FRACTION_THREE_QUARTERS 190 // ¾ +#define PS2_INVERTED_QUESTION MARK 191 // ¿ +#define PS2_A_GRAVE 192 // À +#define PS2_A_ACUTE 193 // Á +#define PS2_A_CIRCUMFLEX 194 // Â +#define PS2_A_TILDE 195 // Ã +#define PS2_A_DIAERESIS 196 // Ä +#define PS2_A_RING_ABOVE 197 // Å +#define PS2_AE 198 // Æ +#define PS2_C_CEDILLA 199 // Ç +#define PS2_E_GRAVE 200 // È +#define PS2_E_ACUTE 201 // É +#define PS2_E_CIRCUMFLEX 202 // Ê +#define PS2_E_DIAERESIS 203 // Ë +#define PS2_I_GRAVE 204 // Ì +#define PS2_I_ACUTE 205 // Í +#define PS2_I_CIRCUMFLEX 206 // Î +#define PS2_I_DIAERESIS 207 // Ï +#define PS2_ETH 208 // Ð +#define PS2_N_TILDE 209 // Ñ +#define PS2_O_GRAVE 210 // Ò +#define PS2_O_ACUTE 211 // Ó +#define PS2_O_CIRCUMFLEX 212 // Ô +#define PS2_O_TILDE 213 // Õ +#define PS2_O_DIAERESIS 214 // Ö +#define PS2_MULTIPLICATION 215 // × +#define PS2_O_STROKE 216 // Ø +#define PS2_U_GRAVE 217 // Ù +#define PS2_U_ACUTE 218 // Ú +#define PS2_U_CIRCUMFLEX 219 // Û +#define PS2_U_DIAERESIS 220 // Ü +#define PS2_Y_ACUTE 221 // Ý +#define PS2_THORN 222 // Þ +#define PS2_SHARP_S 223 // ß +#define PS2_a_GRAVE 224 // à +#define PS2_a_ACUTE 225 // á +#define PS2_a_CIRCUMFLEX 226 // â +#define PS2_a_TILDE 227 // ã +#define PS2_a_DIAERESIS 228 // ä +#define PS2_a_RING_ABOVE 229 // å +#define PS2_ae 230 // æ +#define PS2_c_CEDILLA 231 // ç +#define PS2_e_GRAVE 232 // è +#define PS2_e_ACUTE 233 // é +#define PS2_e_CIRCUMFLEX 234 // ê +#define PS2_e_DIAERESIS 235 // ë +#define PS2_i_GRAVE 236 // ì +#define PS2_i_ACUTE 237 // í +#define PS2_i_CIRCUMFLEX 238 // î +#define PS2_i_DIAERESIS 239 // ï +#define PS2_eth 240 // ð +#define PS2_n_TILDE 241 // ñ +#define PS2_o_GRAVE 242 // ò +#define PS2_o_ACUTE 243 // ó +#define PS2_o_CIRCUMFLEX 244 // ô +#define PS2_o_TILDE 245 // õ +#define PS2_o_DIAERESIS 246 // ö +#define PS2_DIVISION 247 // ÷ +#define PS2_o_STROKE 248 // ø +#define PS2_u_GRAVE 249 // ù +#define PS2_u_ACUTE 250 // ú +#define PS2_u_CIRCUMFLEX 251 // û +#define PS2_u_DIAERESIS 252 // ü +#define PS2_y_ACUTE 253 // ý +#define PS2_thorn 254 // þ +#define PS2_y_DIAERESIS 255 // ÿ + + +#define PS2_KEYMAP_SIZE 136 + +typedef struct { + uint8_t noshift[PS2_KEYMAP_SIZE]; + uint8_t shift[PS2_KEYMAP_SIZE]; + uint8_t uses_altgr; + uint8_t altgr[PS2_KEYMAP_SIZE]; +} PS2Keymap_t; + + +extern const PROGMEM PS2Keymap_t PS2Keymap_US; +extern const PROGMEM PS2Keymap_t PS2Keymap_German; +extern const PROGMEM PS2Keymap_t PS2Keymap_French; + + +/** + * Purpose: Provides an easy access to PS2 keyboards + * Author: Christian Weichel + */ +class PS2Keyboard { + public: + /** + * This constructor does basically nothing. Please call the begin(int,int) + * method before using any other method of this class. + */ + PS2Keyboard(); + + /** + * Starts the keyboard "service" by registering the external interrupt. + * setting the pin modes correctly and driving those needed to high. + * The propably best place to call this method is in the setup routine. + */ + static void begin(uint8_t dataPin, uint8_t irq_pin, const PS2Keymap_t &map = PS2Keymap_US); + + /** + * Returns true if there is a char to be read, false if not. + */ + static bool available(); + + /** + * Returns the char last read from the keyboard. + * If there is no char available, -1 is returned. + */ + static int read(); + static int readUnicode(); +}; + +#endif diff --git a/Arduino/libraries/PS2Keyboard/README.md b/Arduino/libraries/PS2Keyboard/README.md new file mode 100644 index 0000000..931f685 --- /dev/null +++ b/Arduino/libraries/PS2Keyboard/README.md @@ -0,0 +1,7 @@ +#PS/2 Keyboard Library# + +PS2Keyboard allows you to use a keyboard for user input. + +http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html + +![](http://www.pjrc.com/teensy/td_libs_PS2Keyboard.jpg) diff --git a/Arduino/libraries/PS2Keyboard/keywords.txt b/Arduino/libraries/PS2Keyboard/keywords.txt new file mode 100644 index 0000000..bd2c18a --- /dev/null +++ b/Arduino/libraries/PS2Keyboard/keywords.txt @@ -0,0 +1,26 @@ +####################################### +# Syntax Coloring Map For PS2Keyboard +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +PS2Keyboard KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +####################################### +# Constants (LITERAL1) +####################################### + +PS2_KC_BREAK LITERAL1 +PS2_KC_ENTER LITERAL1 +PS2_KC_ESC LITERAL1 +PS2_KC_KPLUS LITERAL1 +PS2_KC_KMINUS LITERAL1 +PS2_KC_KMULTI LITERAL1 +PS2_KC_NUM LITERAL1 +PS2_KC_BKSP LITERAL1 diff --git a/Arduino/libraries/PS2Keyboard/library.json b/Arduino/libraries/PS2Keyboard/library.json new file mode 100644 index 0000000..fc44c97 --- /dev/null +++ b/Arduino/libraries/PS2Keyboard/library.json @@ -0,0 +1,16 @@ +{ + "name": "PS2Keyboard", + "keywords": "keyboard, emulation", + "description": "PS2Keyboard (PS/2) allows you to use a keyboard for user input", + "repository": + { + "type": "git", + "url": "https://github.com/PaulStoffregen/PS2Keyboard.git" + }, + "frameworks": "arduino", + "platforms": + [ + "atmelavr", + "teensy" + ] +} diff --git a/Arduino/libraries/PS2Keyboard/library.properties b/Arduino/libraries/PS2Keyboard/library.properties new file mode 100644 index 0000000..340d0ba --- /dev/null +++ b/Arduino/libraries/PS2Keyboard/library.properties @@ -0,0 +1,10 @@ +name=PS2Keyboard +version=2.4 +author=Christian Weichel, Paul Stoffregen, L. Abraham Smith, Cuningan +maintainer=Paul Stoffregen +sentence=Use a PS/2 Keyboard for input +paragraph= +category=Signal Input/Output +url=https://github.com/PaulStoffregen/PS2Keyboard +architectures=* + diff --git a/Arduino/libraries/PS2Keyboard/utility/int_pins.h b/Arduino/libraries/PS2Keyboard/utility/int_pins.h new file mode 100644 index 0000000..8b48f66 --- /dev/null +++ b/Arduino/libraries/PS2Keyboard/utility/int_pins.h @@ -0,0 +1,65 @@ +// interrupt pins for known boards + +// Teensy and maybe others automatically define this info +#if !defined(CORE_INT0_PIN) && !defined(CORE_INT1_PIN) && !defined(CORE_INT2_PIN)&& !defined(CORE_INT3_PIN) + +// Arduino Mega +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) // Arduino Mega + #define CORE_INT0_PIN 2 + #define CORE_INT1_PIN 3 + #define CORE_INT2_PIN 21 + #define CORE_INT3_PIN 20 + #define CORE_INT4_PIN 19 + #define CORE_INT5_PIN 18 + +// Arduino Due (untested) +#elif defined(__SAM3X8E__) + #define CORE_INT_EVERY_PIN + #ifndef PROGMEM + #define PROGMEM + #endif + #ifndef pgm_read_byte + #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) + #endif + +// Arduino Leonardo (untested) +#elif defined(__AVR_ATmega32U4__) && !defined(CORE_TEENSY) + #define CORE_INT0_PIN 3 + #define CORE_INT1_PIN 2 + #define CORE_INT2_PIN 0 + #define CORE_INT3_PIN 1 + +// Sanguino (untested) +#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) // Sanguino + #define CORE_INT0_PIN 10 + #define CORE_INT1_PIN 11 + #define CORE_INT2_PIN 2 + +// Chipkit Uno32 (untested) +#elif defined(__PIC32MX__) && defined(_BOARD_UNO_) + #define CORE_INT0_PIN 38 + #define CORE_INT1_PIN 2 + #define CORE_INT2_PIN 7 + #define CORE_INT3_PIN 8 + #define CORE_INT4_PIN 35 + +// Chipkit Mega32 (untested) +#elif defined(__PIC32MX__) && defined(_BOARD_MEGA_) + #define CORE_INT0_PIN 3 + #define CORE_INT1_PIN 2 + #define CORE_INT2_PIN 7 + #define CORE_INT3_PIN 21 + #define CORE_INT4_PIN 20 + +// http://hlt.media.mit.edu/?p=1229 +#elif defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) + #define CORE_INT0_PIN 2 + +// Arduino Uno, Duemilanove, LilyPad, Mini, Fio, etc... +#else + #define CORE_INT0_PIN 2 + #define CORE_INT1_PIN 3 + +#endif +#endif + diff --git a/Arduino/libraries/TVout/README.md b/Arduino/libraries/TVout/README.md new file mode 100755 index 0000000..6179a0e --- /dev/null +++ b/Arduino/libraries/TVout/README.md @@ -0,0 +1,34 @@ +# Arduino-TVout + +# Hosted here to keep it available from Arduino IDE (and for simple download as the original Google Code has been archived). + +This is a library for generating composite video on an ATmega microcontroller. + +This branch of the TVout library has been patched to allow use with the Arduino Leonardo. The goal of this project is to create a simple interrupt driven library for generating composite video on a single AVR chip. + +Currently the output is NTSC or PAL at a resolution of 128x96 by default. The library currently works on ATmega168,328,1280,2560,644p,1284p,32U4,AT90USB1286 and more can be added by editing spec/hardware_setup.h. + +There are some timing issues with the m1284p, may be related to sanguino core. + +MCU | SYNC | VIDEO | AUDIO | Arduino | SYNC | VIDEO | AUDIO +---|---|---|---|---|---|---|--- +m168,m328 | B 1 | D 7 | B 3 | NG,Decimila,UNO | 9 | 7 | 11 +m1280,m2560 | B 5 | A 7 | B 4 | Mega | 11 | A7(D29) | 10 +m644,m1284p | D 5 | A 7 | D 7 | sanguino | 13 | A7(D24) | 8 +m32u4 | B 5 | B 4 | B 7 | Leonardo | 9 | 8 | 11 +AT90USB1286 | B 5 | F 7 | B 4 | -- | -- | -- | -- + +## Connections + +SYNC is on OCR1A and AUDIO is on OCR2A (except on the Arduino Leonardo, where AUDIO is on OCR0A) + +There are some timing issues with the m1284p, may be related to sanguino core. + +On NG, Decimila, UNO and Nano the sync is pin 9, video on 7 and audio on 11. On Mega2560 sync is pin 11, video is on A7(D29) and audio is on pin 10. + + +## Examples + +https://youtu.be/MEg_V4YZDh0 + +https://youtu.be/bHpFv_x_8Kk \ No newline at end of file diff --git a/Arduino/libraries/TVout/TVout.cpp b/Arduino/libraries/TVout/TVout.cpp new file mode 100755 index 0000000..377e475 --- /dev/null +++ b/Arduino/libraries/TVout/TVout.cpp @@ -0,0 +1,1099 @@ +/* +Copyright (c) 2010 Myles Metzer +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. +*/ +/* +This library provides a simple method for outputting data to a tv +from a frame buffer stored in sram. This implementation is done +completly by interupt and will return give as much cpu time to the +application as possible. +*/ + +#include "TVout.h" + +/* call this to start video output with the default resolution. + Arguments: + mode: The video standard to follow: + PAL = 1 = _PAL + NTSC = 0 = _NTSC + Returns: + 0 if no error. + 4 if there is not enough memory. +*/ + +uint8_t TVout::begin(uint8_t mode) { + return begin(mode, 128, 96); +} + + +/* call this to start video output with a specified resolution. + Arguments: + mode: The video standard to follow: + PAL = 1 = _PAL + NTSC = 0 = _NTSC + x: Horizonal resolution must be divisable by 8. + y: Vertical resolution. + Returns: + 0 if no error. + 1 if x is not divisable by 8. + 2 if y is to large (NTSC only cannot fill PAL vertical resolution by 8bit limit) + 4 if there is not enough memory for the frame buffer. +*/ + +uint8_t TVout::begin(uint8_t mode, uint8_t x, uint8_t y) { + // check if x is divisable by 8 + if (x % 8) { + return 1; + } + x = x / 8; + screen = (unsigned char*)malloc(x * y * sizeof(unsigned char)); + if (screen == NULL) { + return 4; + } + _cursorX = 0; + _cursorY = 0; + render_setup(mode, x, y, screen); + clearScreen(); + return 0; +} + +// stop video render and free the used memory + void TVout::end() { + TIMSK1 = 0; + free(screen); +} + + +/* Gets the Horizontal resolution of the screen + Returns: The horizonal resolution. +*/ +unsigned int TVout::hres() { + return display.hres * 8; +} + +/* Gets the Vertical resolution of the screen + Returns: The vertical resolution +*/ +unsigned int TVout::vres() { + return display.vres; +} + +/* Return the number of characters that will fit on a line + Returns: The number of characters that will fit on a text line starting from x = 0. + Will return -1 for dynamic width fonts as this cannot be determined. +*/ +char TVout::charLine() { + return ((display.hres * 8) / pgm_read_byte(font)); +} + +/* Delay for x ms + The resolution is 16ms for NTSC and 20ms for PAL + Arguments: + x: The number of ms this function should consume. +*/ +void TVout::delay(unsigned int x) { + unsigned long time = millis() + x; + while (millis() < time); +} + +/* Delay for x frames, exits at the end of the last display line. + delayFrame(1) is useful prior to drawing so there is little/no flicker. + Arguments: + x: The number of frames to delay for. + */ +void TVout::delayFrame(unsigned int x) { + int stop_line = (int)(display.start_render + (display.vres*(display.vscale_const + 1 ))) + 1; + while (x) { + while (display.scanLine != stop_line); + while (display.scanLine == stop_line); + x--; + } +} + + +/* Get the time in ms since begin was called. + The resolution is 16ms for NTSC and 20ms for PAL + Returns: The time in ms since video generation has started. +*/ +unsigned long TVout::millis() { + if (display.lines_frame == _NTSC_LINE_FRAME) { + return display.frames * _NTSC_TIME_SCANLINE * _NTSC_LINE_FRAME / 1000; + } + else { + return display.frames * _PAL_TIME_SCANLINE * _PAL_LINE_FRAME / 1000; + } +} + +void TVout::clearScreen() { + fill(0); +} + +void TVout::invert() { + fill(2); +} + +/* Fill the screen with some color. + Arguments: + color: The color to fill the screen with +*/ +void TVout::fill(uint8_t color) { + switch(color) { + case BLACK: + _cursorX = 0; + _cursorY = 0; + for (int i = 0; i < (display.hres)*display.vres; i++) + display.screen[i] = 0; + break; + case WHITE: + _cursorX = 0; + _cursorY = 0; + for (int i = 0; i < (display.hres)*display.vres; i++) + display.screen[i] = 0xFF; + break; + case INVERT: + for (int i = 0; i < display.hres*display.vres; i++) + display.screen[i] = ~display.screen[i]; + break; + } +} + +/* Set the color of a pixel + Arguments: + x: The x coordinate of the pixel. + y: The y coordinate of the pixel. + c: The color of the pixel + */ +void TVout::setPixel(uint8_t x, uint8_t y, char c) { + if (x >= display.hres * 8 || y >= display.vres) + return; + sp(x, y, c); +} + + +/* get the color of the pixel at x, y + Arguments: + x: The x coordinate of the pixel. + y: The y coordinate of the pixel. + Returns: + The color of the pixel +*/ +bool TVout::getPixel(uint8_t x, uint8_t y) { + if (x >= display.hres * 8 || y >= display.vres) + return false; + if (display.screen[x / 8 + y * display.hres] & (0x80 >> (x & 7))) + return true; + return false; +} + +/* Draw a line from one point to another + Arguments: + x0: The x coordinate of point 0. + y0: The y coordinate of point 0. + x1: The x coordinate of point 1. + y1: The y coordinate of point 1. + c: The color of the line. + */ +void TVout::drawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, char c) { + if (x0 > display.hres*8 || y0 > display.vres || x1 > display.hres*8 || y1 > display.vres) + return; + if (x0 == x1) + drawColumn(x0, y0, y1, c); + else if (y0 == y1) + drawRow(y0, x0, x1, c); + else { + int e; + int dx, dy, j, temp; + char s1, s2, xchange; + int x, y; + + x = x0; + y = y0; + + // take absolute value + if (x1 < x0) { + dx = x0 - x1; + s1 = -1; + } else if (x1 == x0) { + dx = 0; + s1 = 0; + } else { + dx = x1 - x0; + s1 = 1; + } + + if (y1 < y0) { + dy = y0 - y1; + s2 = -1; + } else if (y1 == y0) { + dy = 0; + s2 = 0; + } else { + dy = y1 - y0; + s2 = 1; + } + + xchange = 0; + + if (dy > dx) { + temp = dx; + dx = dy; + dy = temp; + xchange = 1; + } + + e = ((int)dy << 1) - dx; + + for (j = 0; j <= dx; j++) { + sp(x, y, c); + + if (e >= 0) { + if (xchange == 1) { + x = x + s1; + } else { + y = y + s2; + } + e = e - ((int)dx << 1); + } + if (xchange == 1) { + y = y + s2; + } else { + x = x + s1; + } + e = e + ((int)dy << 1); + } + } +} + + +/* Fill a row from one point to another + Argument: + line: The row that fill will be performed on. + x0: edge 0 of the fill. + x1: edge 1 of the fill. + c: the color of the fill. +*/ +void TVout::drawRow(uint8_t line, uint16_t x0, uint16_t x1, uint8_t c) { + uint8_t lbit, rbit; + + if (x0 == x1) { + setPixel(x0, line, c); + } else { + if (x0 > x1) { + lbit = x0; + x0 = x1; + x1 = lbit; + } + lbit = 0xff >> (x0 & 7); + x0 = x0 / 8 + display.hres * line; + rbit = ~(0xff >> (x1 & 7)); + x1 = x1 / 8 + display.hres * line; + if (x0 == x1) { + lbit = lbit & rbit; + rbit = 0; + } + if (c == WHITE) { + screen[x0++] |= lbit; + while (x0 < x1) { + screen[x0++] = 0xff; + } + screen[x0] |= rbit; + } else if (c == BLACK) { + screen[x0++] &= ~lbit; + while (x0 < x1) { + screen[x0++] = 0; + } + screen[x0] &= ~rbit; + } else if (c == INVERT) { + screen[x0++] ^= lbit; + while (x0 < x1) { + screen[x0++] ^= 0xff; + } + screen[x0] ^= rbit; + } + } +} + + +/* Fill a column from one point to another + Argument: + row: The row that fill will be performed on. + y0: edge 0 of the fill. + y1: edge 1 of the fill. + c: the color of the fill. +*/ +void TVout::drawColumn(uint8_t row, uint16_t y0, uint16_t y1, uint8_t c) { + unsigned char bit; + int byte; + + if (y0 == y1) { + setPixel(row, y0, c); + } else { + if (y1 < y0) { + bit = y0; + y0 = y1; + y1 = bit; + } + bit = 0x80 >> (row&7); + byte = row/8 + y0*display.hres; + if (c == WHITE) { + while (y0 <= y1) { + screen[byte] |= bit; + byte += display.hres; + y0++; + } + } else if (c == BLACK) { + while (y0 <= y1) { + screen[byte] &= ~bit; + byte += display.hres; + y0++; + } + } else if (c == INVERT) { + while ( y0 <= y1) { + screen[byte] ^= bit; + byte += display.hres; + y0++; + } + } + } +} + + +/* draw a rectangle at x,y with a specified width and height + Arguments: + x0: The x coordinate of upper left corner of the rectangle. + y0: The y coordinate of upper left corner of the rectangle. + w: The widht of the rectangle. + h: The height of the rectangle. + c: The color of the rectangle. + fc: The fill color of the rectangle. +*/ +void TVout::drawRect(uint8_t x0, uint8_t y0, uint8_t w, uint8_t h, char c, char fc) { + if (fc != -1) { + for (unsigned char i = y0; i < y0 + h; i++) { + drawRow(i, x0, x0 + w, fc); + } + } + drawLine(x0, y0, x0 + w, y0, c); + drawLine(x0, y0, x0, y0 + h, c); + drawLine(x0 + w, y0, x0 + w, y0 + h, c); + drawLine(x0, y0 + h, x0 + w, y0 + h, c); +} + + +/* draw a circle given a coordinate x,y and radius both filled and non filled. + Arguments: + x0: The x coordinate of the center of the circle. + y0: The y coordinate of the center of the circle. + radius: The radius of the circle. + c: The color of the circle. + fc: The color to fill the circle. + */ +void TVout::drawCircle(uint8_t x0, uint8_t y0, uint8_t radius, char c, char fc) { + int f = 1 - radius; + int ddF_x = 1; + int ddF_y = -2 * radius; + int x = 0; + int y = radius; + uint8_t pyy = y, pyx = x; + + // there is a fill color + if (fc != -1) { + drawRow(y0, x0 - radius, x0 + radius, fc); + } + + sp(x0, y0 + radius, c); + sp(x0, y0 - radius, c); + sp(x0 + radius, y0, c); + sp(x0 - radius, y0, c); + + while(x < y) { + if (f >= 0) { + y--; + ddF_y += 2; + f += ddF_y; + } + x++; + ddF_x += 2; + f += ddF_x; + + // there is a fill color + if (fc != -1) { + // prevent double draws on the same rows + if (pyy != y) { + drawRow(y0+y, x0 - x, x0 + x, fc); + drawRow(y0-y, x0 - x, x0 + x, fc); + } + if (pyx != x && x != y) { + drawRow(y0 + x, x0 - y, x0 + y, fc); + drawRow(y0 - x, x0 - y, x0 + y, fc); + } + pyy = y; + pyx = x; + } + sp(x0 + x, y0 + y,c); + sp(x0 - x, y0 + y,c); + sp(x0 + x, y0 - y,c); + sp(x0 - x, y0 - y,c); + sp(x0 + y, y0 + x,c); + sp(x0 - y, y0 + x,c); + sp(x0 + y, y0 - x,c); + sp(x0 - y, y0 - x,c); + } +} + + +/* place a bitmap at x,y where the bitmap is defined as {width,height,imagedata....} + Arguments: + x: The x coordinate of the upper left corner. + y: The y coordinate of the upper left corner. + bmp: The bitmap data to print. + i: The offset into the image data to start at. This is mainly used for fonts + default = 0 + width: Override the bitmap width. This is mainly used for fonts. + default = 0 (do not override) + height: Override the bitmap height. This is mainly used for fonts. + default = 0 (do not override) +*/ +void TVout::bitmap(uint8_t x, uint8_t y, const unsigned char * bmp, + uint16_t i, uint8_t width, uint8_t lines) { + uint8_t temp, lshift, rshift, save, xtra; + uint16_t si = 0; + + rshift = x & 7; + lshift = 8 - rshift; + if (width == 0) { + width = pgm_read_byte((uint32_t)(bmp) + i); + i++; + } + if (lines == 0) { + lines = pgm_read_byte((uint32_t)(bmp) + i); + i++; + } + + if (width & 7) { + xtra = width & 7; + width = width / 8; + width++; + } else { + xtra = 8; + width = width / 8; + } + + for (uint8_t l = 0; l < lines; l++) { + si = (y + l) * display.hres + x / 8; + if (width == 1) { + temp = 0xff >> rshift + xtra; + } else { + temp = 0; + } + save = screen[si]; + screen[si] &= ((0xff << lshift) | temp); + temp = pgm_read_byte((uint32_t)(bmp) + i++); + screen[si++] |= temp >> rshift; + for (uint16_t b = i + width - 1; i < b; i++) { + save = screen[si]; + screen[si] = temp << lshift; + temp = pgm_read_byte((uint32_t)(bmp) + i); + screen[si++] |= temp >> rshift; + } + if (rshift + xtra < 8) { + screen[si - 1] |= (save & (0xff >> rshift + xtra)); + } + if (rshift + xtra - 8 > 0) { + screen[si] &= (0xff >> rshift + xtra - 8); + } + screen[si] |= temp << lshift; + } +} + +/* shift the pixel buffer in any direction + This function will shift the screen in a direction by any distance. + Arguments: + distance: The distance to shift the screen + direction: The direction to shift the screen the direction and the integer values: + UP = 0 + DOWN = 1 + LEFT = 2 + RIGHT = 3 +*/ + +void TVout::shift(uint8_t distance, uint8_t direction) { + uint8_t * src; + uint8_t * dst; + uint8_t * end; + uint8_t shift; + uint8_t tmp; + switch (direction) { + case UP: + dst = display.screen; + src = display.screen + distance*display.hres; + end = display.screen + display.vres*display.hres; + while (src <= end) { + *dst = *src; + *src = 0; + dst++; + src++; + } + break; + case DOWN: + dst = display.screen + display.vres*display.hres; + src = dst - distance*display.hres; + end = display.screen; + while (src >= end) { + *dst = *src; + *src = 0; + dst--; + src--; + } + break; + case LEFT: + shift = distance & 7; + for (uint8_t line = 0; line < display.vres; line++) { + dst = display.screen + display.hres*line; + src = dst + distance/8; + end = dst + display.hres-2; + while (src <= end) { + tmp = 0; + tmp = *src << shift; + *src = 0; + src++; + tmp |= *src >> (8 - shift); + *dst = tmp; + dst++; + } + tmp = 0; + tmp = *src << shift; + *src = 0; + *dst = tmp; + } + break; + case RIGHT: + shift = distance & 7; + for (uint8_t line = 0; line < display.vres; line++) { + dst = display.screen + display.hres-1 + display.hres*line; + src = dst - distance/8; + end = dst - display.hres+2; + while (src >= end) { + tmp = 0; + tmp = *src >> shift; + *src = 0; + src--; + tmp |= *src << (8 - shift); + *dst = tmp; + dst--; + } + tmp = 0; + tmp = *src >> shift; + *src = 0; + *dst = tmp; + } + break; + } +} + +void TVout::printChar(uint8_t x, uint8_t y, unsigned char c) { + c -= pgm_read_byte(font + 2); + bitmap(x, y, font, (c * pgm_read_byte(font + 1)) + 3, pgm_read_byte(font), pgm_read_byte(font + 1)); +} + +void TVout::setCursor(uint8_t x, uint8_t y) { + _cursorX = x; + _cursorY = y; +} + +void TVout::selectFont(const unsigned char* f) { + font = f; +} + +void TVout::write(const char *str) { + while (*str) { + write(*str++); + } +} + +void TVout::write(const uint8_t *buffer, uint8_t size) { + while (size--) { + write(*buffer++); + } +} + +void TVout::write(uint8_t c) { + switch(c) { + // null + case '\0': + break; + // line feed + case '\n': + _cursorX = 0; + incTxtLine(); + break; + // backspace + case 8: + _cursorX -= pgm_read_byte(font); + printChar(_cursorX, _cursorY,' '); + break; + // carriage return + case 13: + _cursorX = 0; + break; + // form feed new page(clear screen) + case 14: + //clearScreen(); + break; + default: + if (_cursorX >= (display.hres * 8 - pgm_read_byte(font))) { + _cursorX = 0; + incTxtLine(); + printChar(_cursorX, _cursorY, c); + } else { + printChar(_cursorX, _cursorY, c); + } + _cursorX += pgm_read_byte(font); + } +} + +void TVout::print(const char str[]) { + write(str); +} + +void TVout::print(char c, int base) { + print((long) c, base); +} + +void TVout::print(unsigned char b, int base) { + print((unsigned long) b, base); +} + +void TVout::print(int n, int base) { + print((long) n, base); +} + +void TVout::print(unsigned int n, int base) { + print((unsigned long) n, base); +} + +void TVout::print(long n, int base) { + if (base == 0) { + write(n); + } else if (base == 10) { + if (n < 0) { + print('-'); + n = -n; + } + printNumber(n, 10); + } else { + printNumber(n, base); + } +} + +void TVout::print(unsigned long n, int base) { + if (base == 0) { + write(n); + } else { + printNumber(n, base); + } +} + +void TVout::print(float n, int digits) { + printFloat(n, digits); +} + +void TVout::println(void) { + print('\r'); + print('\n'); +} + +void TVout::println(const char c[]) { + print(c); + println(); +} + +void TVout::println(char c, int base) { + print(c, base); + println(); +} + +void TVout::println(unsigned char b, int base) { + print(b, base); + println(); +} + +void TVout::println(int n, int base) { + print(n, base); + println(); +} + +void TVout::println(unsigned int n, int base) { + print(n, base); + println(); +} + +void TVout::println(long n, int base) { + print(n, base); + println(); +} + +void TVout::println(unsigned long n, int base) { + print(n, base); + println(); +} + +void TVout::println(float n, int digits) { + print(n, digits); + println(); +} + +void TVout::printPGM(const char str[]) { + char c; + while ((c = pgm_read_byte(str))) { + str++; + write(c); + } +} + +void TVout::printPGM(uint8_t x, uint8_t y, const char str[]) { + char c; + _cursorX = x; + _cursorY = y; + while ((c = pgm_read_byte(str))) { + str++; + write(c); + } +} + +void TVout::print(uint8_t x, uint8_t y, const char str[]) { + _cursorX = x; + _cursorY = y; + write(str); + +} + +void TVout::print(uint8_t x, uint8_t y, char c, int base) { + _cursorX = x; + _cursorY = y; + print((long) c, base); +} + +void TVout::print(uint8_t x, uint8_t y, unsigned char b, int base) { + _cursorX = x; + _cursorY = y; + print((unsigned long) b, base); +} + +void TVout::print(uint8_t x, uint8_t y, int n, int base) { + _cursorX = x; + _cursorY = y; + print((long) n, base); +} + +void TVout::print(uint8_t x, uint8_t y, unsigned int n, int base) { + _cursorX = x; + _cursorY = y; + print((unsigned long) n, base); +} + +void TVout::print(uint8_t x, uint8_t y, long n, int base) { + _cursorX = x; + _cursorY = y; + print(n,base); +} + +void TVout::print(uint8_t x, uint8_t y, unsigned long n, int base) { + _cursorX = x; + _cursorY = y; + print(n,base); +} + +void TVout::print(uint8_t x, uint8_t y, float n, int digits) { + _cursorX = x; + _cursorY = y; + print(n,digits); +} + +void TVout::println(uint8_t x, uint8_t y, const char c[]) { + _cursorX = x; + _cursorY = y; + print(c); + println(); +} + +void TVout::println(uint8_t x, uint8_t y, char c, int base) { + _cursorX = x; + _cursorY = y; + print(c, base); + println(); +} + +void TVout::println(uint8_t x, uint8_t y, unsigned char b, int base) { + _cursorX = x; + _cursorY = y; + print(b, base); + println(); +} + +void TVout::println(uint8_t x, uint8_t y, int n, int base) { + _cursorX = x; + _cursorY = y; + print(n, base); + println(); +} + +void TVout::println(uint8_t x, uint8_t y, unsigned int n, int base) { + _cursorX = x; + _cursorY = y; + print(n, base); + println(); +} + +void TVout::println(uint8_t x, uint8_t y, long n, int base) { + _cursorX = x; + _cursorY = y; + print(n, base); + println(); +} + +void TVout::println(uint8_t x, uint8_t y, unsigned long n, int base) { + _cursorX = x; + _cursorY = y; + print(n, base); + println(); +} + +void TVout::println(uint8_t x, uint8_t y, float n, int digits) { + _cursorX = x; + _cursorY = y; + print(n, digits); + println(); +} + +void TVout::printNumber(unsigned long n, uint8_t base) { + unsigned char buf[8 * sizeof(long)]; + unsigned long i = 0; + if (n == 0) { + print('0'); + return; + } + + while (n > 0) { + buf[i++] = n % base; + n /= base; + } + + for (; i > 0; i--) { + print((char) (buf[i - 1] < 10 ? + '0' + buf[i - 1] : + 'A' + buf[i - 1] - 10)); + } +} + +void TVout::printFloat(float number, uint8_t digits) { + // Handle negative numbers + if (number < 0.0) { + print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + float rounding = 0.5; + for (uint8_t i = 0; i < digits; ++i) { + rounding /= 10.0; + } + number += rounding; + + // Extract the integer part of the number and print it + unsigned long int_part = (unsigned long)number; + float remainder = number - (float)int_part; + print(int_part); + + // Print the decimal point, but only if there are digits beyond + if (digits > 0) { + print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) { + remainder *= 10.0; + int toPrint = int(remainder); + print(toPrint); + remainder -= toPrint; + } +} + +/* Simple tone generation + Arguments: + frequency: the frequency of the tone courtesy of adamwwolf + */ +void TVout::tone(unsigned int frequency) { + tone(frequency, 0); +} + +/* Simple tone generation + Arguments: + frequency: the frequency of the tone + durationMS: the duration to play the tone in ms courtesy of adamwwolf +*/ +void TVout::tone(unsigned int frequency, unsigned long durationMS) { + if (frequency == 0) { + return; + } + + #define TIMER 2 + // this is init code + TCCR2A = 0; + TCCR2B = 0; + TCCR2A |= _BV(WGM21); + TCCR2B |= _BV(CS20); + // end init code + + // most of this is taken from Tone.cpp from Arduino + uint8_t prescalarbits = 0b001; + uint32_t ocr = 0; + + // set pb3 (digital pin 11) to output + DDR_SND |= _BV(SND_PIN); + + // we are using an 8 bit timer, scan through prescalars to find the best fit + ocr = F_CPU / frequency / 2 - 1; + // ck/1: same for both timers + prescalarbits = 0b001; + if (ocr > 255) { + ocr = F_CPU / frequency / 2 / 8 - 1; + // ck/8: same for both timers + prescalarbits = 0b010; + + if (ocr > 255) { + ocr = F_CPU / frequency / 2 / 32 - 1; + prescalarbits = 0b011; + } + + if (ocr > 255) { + ocr = F_CPU / frequency / 2 / 64 - 1; + prescalarbits = TIMER == 0 ? 0b011 : 0b100; + if (ocr > 255) { + ocr = F_CPU / frequency / 2 / 128 - 1; + prescalarbits = 0b101; + } + + if (ocr > 255) { + ocr = F_CPU / frequency / 2 / 256 - 1; + prescalarbits = TIMER == 0 ? 0b100 : 0b110; + if (ocr > 255) { + // can't do any better than / 1024 + ocr = F_CPU / frequency / 2 / 1024 - 1; + prescalarbits = TIMER == 0 ? 0b101 : 0b111; + } + } + } + } + + TCCR2B = prescalarbits; + + if (durationMS > 0) { + // 60 here represents the framerate + remainingToneVsyncs = durationMS * 60 / 1000; + } else { + remainingToneVsyncs = -1; + } + + // set the OCR for the given timer, + OCR2A = ocr; + // set it to toggle the pin by itself + // set COM2A1 to 0 + TCCR2A &= ~(_BV(COM2A1)); + TCCR2A |= _BV(COM2A0); +} + +/* stops tone generation +*/ +void TVout::noTone() { + TCCR2B = 0; + // set pin 11 to 0 + PORT_SND &= ~(_BV(SND_PIN)); +} + +/* set the vertical blank function call + The function passed to this function will be called one per frame. The function should be quickish. + Arguments: + func: The function to call +*/ +void TVout::setVBIHook(void (*func)()) { + vbi_hook = func; +} + + +/* set the horizonal blank function call + This function passed to this function will be called one per scan line. + The function MUST be VERY FAST(~2us max). + Arguments: + funct: The function to call +*/ +void TVout::setHBIHook(void (*func)()) { + hbi_hook = func; +} + + +/* force the number of times to display each line + Arguments: + sfactor: The scale number of times to repeate each line. +*/ +void TVout::forceVscale(char sfactor) { + delayFrame(1); + display.vscale_const = sfactor - 1; + display.vscale = sfactor - 1; +} + + +/* force the output start time of a scanline in micro seconds + Arguments: + time: The new output start time in micro seconds. +*/ +void TVout::forceOutStart(uint8_t time) { + delayFrame(1); + display.output_delay = ((time * _CYCLES_PER_US) - 1); +} + + +/* force the start line for active video + Arguments: + line: The new active video output start line +*/ +void TVout::forceLineStart(uint8_t line) { + delayFrame(1); + display.start_render = line; +} + +void TVout::incTxtLine() { + if (_cursorY >= (display.vres - pgm_read_byte(font + 1))) + shift(pgm_read_byte(font + 1), UP); + else + _cursorY += pgm_read_byte(font + 1); +} + +/* Inline version of setPixel that does not perform a bounds check +*/ +static void inline sp(uint8_t x, uint8_t y, char c) { + if (c == 1) { + display.screen[(x / 8) + (y * display.hres)] |= 0x80 >> (x & 7); + } else if (c == 0) { + display.screen[(x / 8) + (y * display.hres)] &= ~0x80 >> (x & 7); + } else { + display.screen[(x / 8) + (y * display.hres)] ^= 0x80 >> (x & 7); + } +} diff --git a/Arduino/libraries/TVout/TVout.h b/Arduino/libraries/TVout/TVout.h new file mode 100755 index 0000000..86f2f9c --- /dev/null +++ b/Arduino/libraries/TVout/TVout.h @@ -0,0 +1,156 @@ +/* + Copyright (c) 2010 Myles Metzer + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions: + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef TVOUT_H +#define TVOUT_H + +#include +#include "video_gen.h" +#include "fontALL.h" + +#define PAL 1 +#define NTSC 0 +#define _PAL 1 +#define _NTSC 0 + +#define WHITE 1 +#define BLACK 0 +#define INVERT 2 + +#define UP 0 +#define DOWN 1 +#define LEFT 2 +#define RIGHT 3 + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 +#define BYTE 0 + +class TVout { +public: + uint8_t* screen; + uint8_t begin(uint8_t mode); + uint8_t begin(uint8_t mode, uint8_t x, uint8_t y); + void end(); + + // accessor functions + unsigned int hres(); + unsigned int vres(); + char charLine(); + + // flow control functions + void delay(unsigned int x); + void delayFrame(unsigned int x); + unsigned long millis(); + + // basic rendering functions + void clearScreen(); + void invert(); + void fill(uint8_t color); + void setPixel(uint8_t x, uint8_t y, char c); + bool getPixel(uint8_t x, uint8_t y); + void drawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, char c); + void drawRow(uint8_t line, uint16_t x0, uint16_t x1, uint8_t c); + void drawColumn(uint8_t row, uint16_t y0, uint16_t y1, uint8_t c); + void drawRect(uint8_t x0, uint8_t y0, uint8_t w, uint8_t h, char c, char fc = -1); + void drawCircle(uint8_t x0, uint8_t y0, uint8_t radius, char c, char fc = -1); + void bitmap(uint8_t x, uint8_t y, const unsigned char* bmp, uint16_t i = 0, uint8_t width = 0, uint8_t lines = 0); + void shift(uint8_t distance, uint8_t direction); + + // printing functions + void printChar(uint8_t x, uint8_t y, unsigned char c); + void setCursor(uint8_t x, uint8_t y); + void selectFont(const unsigned char* f); + + void write(uint8_t); + void write(const char* str); + void write(const uint8_t* buffer, uint8_t size); + + void print(const char[]); + void print(char, int = BYTE); + void print(unsigned char, int = BYTE); + void print(int, int = DEC); + void print(unsigned int, int = DEC); + void print(long, int = DEC); + void print(unsigned long, int = DEC); + void print(float, int = 2); + + void print(uint8_t, uint8_t, const char[]); + void print(uint8_t, uint8_t, char, int = BYTE); + void print(uint8_t, uint8_t, unsigned char, int = BYTE); + void print(uint8_t, uint8_t, int, int = DEC); + void print(uint8_t, uint8_t, unsigned int, int = DEC); + void print(uint8_t, uint8_t, long, int = DEC); + void print(uint8_t, uint8_t, unsigned long, int = DEC); + void print(uint8_t, uint8_t, float, int = 2); + + void println(uint8_t, uint8_t, const char[]); + void println(uint8_t, uint8_t, char, int = BYTE); + void println(uint8_t, uint8_t, unsigned char, int = BYTE); + void println(uint8_t, uint8_t, int, int = DEC); + void println(uint8_t, uint8_t, unsigned int, int = DEC); + void println(uint8_t, uint8_t, long, int = DEC); + void println(uint8_t, uint8_t, unsigned long, int = DEC); + void println(uint8_t, uint8_t, float, int = 2); + void println(uint8_t, uint8_t); + + void println(const char[]); + void println(char, int = BYTE); + void println(unsigned char, int = BYTE); + void println(int, int = DEC); + void println(unsigned int, int = DEC); + void println(long, int = DEC); + void println(unsigned long, int = DEC); + void println(float, int = 2); + void println(void); + + void printPGM(const char[]); + void printPGM(uint8_t, uint8_t, const char[]); + + void printNumber(unsigned long, uint8_t); + void printFloat(float, uint8_t); + + // tone functions + void tone(unsigned int frequency, unsigned long durationMS); + void tone(unsigned int frequency); + void noTone(); + + +private: + // hook setup functions + void setVBIHook(void (*func)()); + void setHBIHook(void (*func)()); + + // override setup functions + void forceVscale(char sfactor); + void forceOutStart(uint8_t time); + void forceLineStart(uint8_t line); + void incTxtLine(); + + uint8_t _cursorX, _cursorY; + const unsigned char* font; +}; + +static void inline sp(uint8_t x, uint8_t y, char c); +#endif diff --git a/Arduino/libraries/TVout/font4x6.cpp b/Arduino/libraries/TVout/font4x6.cpp new file mode 100755 index 0000000..5fe7793 --- /dev/null +++ b/Arduino/libraries/TVout/font4x6.cpp @@ -0,0 +1,671 @@ +#include "font4x6.h" + +PROGMEM const unsigned char font4x6[] = { +4,6,32, +//space +0b00000000, +0b00000000, +0b00000000, +0b00000000, +0b00000000, +0b00000000, +//! +0b01000000, +0b01000000, +0b01000000, +0b00000000, +0b01000000, +0b00000000, +//" +0b10100000, +0b10100000, +0b00000000, +0b00000000, +0b00000000, +0b00000000, +//# +0b10100000, +0b11100000, +0b10100000, +0b11100000, +0b10100000, +0b00000000, +//$ +0b01000000, +0b01100000, +0b11000000, +0b01100000, +0b11000000, +0b00000000, +//% +0b10100000, +0b00100000, +0b01000000, +0b10000000, +0b10100000, +0b00000000, +//& +0b00100000, +0b01000000, +0b11000000, +0b10100000, +0b11100000, +0b00000000, +//' +0b10000000, +0b10000000, +0b00000000, +0b00000000, +0b00000000, +0b00000000, +//( +0b01000000, +0b10000000, +0b10000000, +0b10000000, +0b01000000, +0b00000000, +//) +0b10000000, +0b01000000, +0b01000000, +0b01000000, +0b10000000, +0b00000000, +//* +0b01000000, +0b10100000, +0b01000000, +0b00000000, +0b00000000, +0b00000000, +//+ +0b00000000, +0b01000000, +0b11100000, +0b01000000, +0b00000000, +0b00000000, +//, +0b00000000, +0b00000000, +0b00000000, +0b10000000, +0b10000000, +0b00000000, +//- +0b00000000, +0b00000000, +0b11100000, +0b00000000, +0b00000000, +0b00000000, +//. +0b00000000, +0b00000000, +0b00000000, +0b00000000, +0b10000000, +0b00000000, +// / +0b00100000, +0b00100000, +0b01000000, +0b10000000, +0b10000000, +0b00000000, +//0 +0b11100000, +0b10100000, +0b10100000, +0b10100000, +0b11100000, +0b00000000, +//1 +0b01000000, +0b11000000, +0b01000000, +0b01000000, +0b11100000, +0b00000000, +//2 +0b11100000, +0b00100000, +0b11100000, +0b10000000, +0b11100000, +0b00000000, +//3 +0b11100000, +0b00100000, +0b11100000, +0b00100000, +0b11100000, +0b00000000, +//4 +0b10100000, +0b10100000, +0b11100000, +0b00100000, +0b00100000, +0b00000000, +//5 +0b11100000, +0b10000000, +0b11100000, +0b00100000, +0b11000000, +0b00000000, +//6 +0b11000000, +0b10000000, +0b11100000, +0b10100000, +0b11100000, +0b00000000, +//7 +0b11100000, +0b00100000, +0b01000000, +0b10000000, +0b10000000, +0b00000000, +//8 +0b11100000, +0b10100000, +0b11100000, +0b10100000, +0b11100000, +0b00000000, +//9 +0b11100000, +0b10100000, +0b11100000, +0b00100000, +0b01100000, +0b00000000, +//: +0b00000000, +0b01000000, +0b00000000, +0b01000000, +0b00000000, +0b00000000, +//; +0b00000000, +0b01000000, +0b00000000, +0b01000000, +0b10000000, +0b00000000, +//< +0b00100000, +0b01000000, +0b10000000, +0b01000000, +0b00100000, +0b00000000, +//= +0b00000000, +0b11100000, +0b00000000, +0b11100000, +0b00000000, +0b00000000, +//> +0b10000000, +0b01000000, +0b00100000, +0b01000000, +0b10000000, +0b00000000, +//? +0b11000000, +0b00100000, +0b01000000, +0b00000000, +0b01000000, +0b00000000, +//@ +0b11100000, +0b10100000, +0b10100000, +0b11100000, +0b11100000, +0b00000000, +//A +0b11100000, +0b10100000, +0b11100000, +0b10100000, +0b10100000, +0b00000000, +//B +0b11000000, +0b10100000, +0b11100000, +0b10100000, +0b11000000, +0b00000000, +//C +0b11100000, +0b10000000, +0b10000000, +0b10000000, +0b11100000, +0b00000000, +//D +0b11000000, +0b10100000, +0b10100000, +0b10100000, +0b11000000, +0b00000000, +//E +0b11100000, +0b10000000, +0b11100000, +0b10000000, +0b11100000, +0b00000000, +//F +0b11100000, +0b10000000, +0b11100000, +0b10000000, +0b10000000, +0b00000000, +//G +0b11100000, +0b10000000, +0b10000000, +0b10100000, +0b11100000, +0b00000000, +//H +0b10100000, +0b10100000, +0b11100000, +0b10100000, +0b10100000, +0b00000000, +//I +0b11100000, +0b01000000, +0b01000000, +0b01000000, +0b11100000, +0b00000000, +//J +0b00100000, +0b00100000, +0b00100000, +0b10100000, +0b11100000, +0b00000000, +//K +0b10000000, +0b10100000, +0b11000000, +0b11000000, +0b10100000, +0b00000000, +//L +0b10000000, +0b10000000, +0b10000000, +0b10000000, +0b11100000, +0b00000000, +//M +0b10100000, +0b11100000, +0b11100000, +0b10100000, +0b10100000, +0b00000000, +//N +0b11000000, +0b10100000, +0b10100000, +0b10100000, +0b10100000, +0b00000000, +//O +0b01000000, +0b10100000, +0b10100000, +0b10100000, +0b01000000, +0b00000000, +//P +0b11100000, +0b10100000, +0b11100000, +0b10000000, +0b10000000, +0b00000000, +//Q +0b01000000, +0b10100000, +0b10100000, +0b11100000, +0b01100110, +0b00000000, +//R +0b11100000, +0b10100000, +0b11000000, +0b11100000, +0b10101010, +0b00000000, +//S +0b11100000, +0b10000000, +0b11100000, +0b00100000, +0b11100000, +0b00000000, +//T +0b11100000, +0b01000000, +0b01000000, +0b01000000, +0b01000000, +0b00000000, +//U +0b10100000, +0b10100000, +0b10100000, +0b10100000, +0b11100000, +0b00000000, +//V +0b10100000, +0b10100000, +0b10100000, +0b10100000, +0b01000000, +0b00000000, +//W +0b10100000, +0b10100000, +0b11100000, +0b11100000, +0b10100010, +0b00000000, +//X +0b10100000, +0b10100000, +0b01000000, +0b10100000, +0b10100000, +0b00000000, +//Y +0b10100000, +0b10100000, +0b01000000, +0b01000000, +0b01000000, +0b00000000, +//Z +0b11100000, +0b00100000, +0b01000000, +0b10000000, +0b11100000, +0b00000000, +//[ +0b11000000, +0b10000000, +0b10000000, +0b10000000, +0b11000000, +0b00000000, +0, //for the life of me I have no idea why this is needed.... +//\ +0b10000000, +0b10000000, +0b01000000, +0b00100000, +0b00100000, +0b00000000, +//] +0b11000000, +0b01000000, +0b01000000, +0b01000000, +0b11000000, +0b00000000, +//^ +0b01000000, +0b10100000, +0b00000000, +0b00000000, +0b00000000, +0b00000000, +//_ +0b00000000, +0b00000000, +0b00000000, +0b00000000, +0b11100000, +0b00000000, +//` +0b10000000, +0b01000000, +0b00000000, +0b00000000, +0b00000000, +0b00000000, +//a +0b00000000, +0b01100000, +0b10100000, +0b10100000, +0b01100000, +0b00000000, +//b +0b10000000, +0b10000000, +0b11000000, +0b10100000, +0b11000000, +0b00000000, +//c +0b00000000, +0b01100000, +0b10000000, +0b10000000, +0b01100000, +0b00000000, +//d +0b00100000, +0b00100000, +0b01100000, +0b10100000, +0b01100000, +0b00000000, +//e +0b01000000, +0b10100000, +0b11100000, +0b10000000, +0b01100000, +0b00000000, +//f +0b01100000, +0b01000000, +0b11100000, +0b01000000, +0b01000000, +0b00000000, +//g +0b01100000, +0b10100000, +0b01100000, +0b00100000, +0b11000000, +0b00000000, +//h +0b10000000, +0b10000000, +0b11000000, +0b10100000, +0b10100000, +0b00000000, +//i +0b01000000, +0b00000000, +0b01000000, +0b01000000, +0b01000000, +0b00000000, +//j +0b01000000, +0b00000000, +0b01000000, +0b01000000, +0b11000000, +0b00000000, +//k +0b10000000, +0b10000000, +0b10100000, +0b11000000, +0b10100000, +0b00000000, +//l +0b11000000, +0b01000000, +0b01000000, +0b01000000, +0b11100000, +0b00000000, +//m +0b00000000, +0b10100000, +0b11100000, +0b10100000, +0b10100000, +0b00000000, +//n +0b00000000, +0b11000000, +0b10100000, +0b10100000, +0b10100000, +0b00000000, +//o +0b00000000, +0b01000000, +0b10100000, +0b10100000, +0b01000000, +0b00000000, +//p +0b00000000, +0b11000000, +0b10100000, +0b11000000, +0b10000000, +0b00000000, +//q +0b00000000, +0b01100000, +0b10100000, +0b01100000, +0b00100000, +0b00000000, +//r +0b00000000, +0b11000000, +0b10100000, +0b10000000, +0b10000000, +0b00000000, +//s +0b00000000, +0b01100000, +0b01000000, +0b00100000, +0b01100000, +0b00000000, +//t +0b01000000, +0b11100000, +0b01000000, +0b01000000, +0b01000000, +0b00000000, +//u +0b00000000, +0b10100000, +0b10100000, +0b10100000, +0b01100000, +0b00000000, +//v +0b00000000, +0b10100000, +0b10100000, +0b10100000, +0b01000000, +0b00000000, +//w +0b00000000, +0b10100000, +0b10100000, +0b11100000, +0b10100000, +0b00000000, +//x +0b00000000, +0b10100000, +0b01000000, +0b01000000, +0b10100000, +0b00000000, +//y +0b00000000, +0b10100000, +0b11100000, +0b00100000, +0b01000000, +0b00000000, +//x +0b00000000, +0b11100000, +0b01000000, +0b10000000, +0b11100000, +0b00000000, +//{ +0b00100000, +0b01000000, +0b11000000, +0b01000000, +0b00100010, +0b00000000, +//| +0b01000000, +0b01000000, +0b00000000, +0b01000000, +0b01000000, +0b00000000, +//} +0b10000000, +0b01000000, +0b01100000, +0b01000000, +0b10000000, +0b00000000, +//~ +0b00000000, +0b10100000, +0b01000000, +0b00000000, +0b00000000, +0b00000000 +}; \ No newline at end of file diff --git a/Arduino/libraries/TVout/font4x6.h b/Arduino/libraries/TVout/font4x6.h new file mode 100755 index 0000000..02746e4 --- /dev/null +++ b/Arduino/libraries/TVout/font4x6.h @@ -0,0 +1,7 @@ +#ifndef FONT4X6_h +#define FONT4X6_h +#include + +extern const unsigned char font4x6[]; + +#endif \ No newline at end of file diff --git a/Arduino/libraries/TVout/font6x8.cpp b/Arduino/libraries/TVout/font6x8.cpp new file mode 100755 index 0000000..62668ee --- /dev/null +++ b/Arduino/libraries/TVout/font6x8.cpp @@ -0,0 +1,870 @@ +#include "font6x8.h" + +PROGMEM const unsigned char font6x8[] = { + + 6,8,32, + //32 Space + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + //33 Exclamation ! + 0b01000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b00000000, + 0b01000000, + 0b00000000, + //34 Quotes " + 0b01010000, + 0b01010000, + 0b01010000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + //35 Number # + 0b00000000, + 0b00000000, + 0b01010000, + 0b11111000, + 0b01010000, + 0b11111000, + 0b01010000, + 0b00000000, + //36 Dollars $ + 0b00100000, + 0b01110000, + 0b10100000, + 0b01110000, + 0b00101000, + 0b01110000, + 0b00100000, + 0b00000000, + //37 Percent % + 0b00000000, + 0b11001000, + 0b11010000, + 0b00100000, + 0b01011000, + 0b10011000, + 0b00000000, + 0b00000000, + //38 Ampersand & + 0b00100000, + 0b01010000, + 0b10000000, + 0b01000000, + 0b10101000, + 0b10010000, + 0b01101000, + 0b00000000, + //39 Single Quote ' + 0b01000000, + 0b01000000, + 0b01000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + //40 Left Parenthesis ( + 0b00010000, + 0b00100000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b00100000, + 0b00010000, + 0b00000000, + //41 Right Parenthesis ) + 0b01000000, + 0b00100000, + 0b00010000, + 0b00010000, + 0b00010000, + 0b00100000, + 0b01000000, + 0b00000000, + //42 Star * + 0b00010000, + 0b00111000, + 0b00010000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + //43 Plus + + 0b00000000, + 0b00100000, + 0b00100000, + 0b11111000, + 0b00100000, + 0b00100000, + 0b00000000, + 0b00000000, + //44 Comma , + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00010000, + 0b00010000, + 0b00000000, + //45 Minus - + 0b00000000, + 0b00000000, + 0b00000000, + 0b11111000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + //46 Period . + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00010000, + 0b00000000, + 0b00000000, + // 47 Backslash / + 0b00000000, + 0b00001000, + 0b00010000, + 0b00100000, + 0b01000000, + 0b10000000, + 0b00000000, + 0b00000000, + // 48 Zero + 0b01110000, + 0b10001000, + 0b10101000, + 0b10101000, + 0b10001000, + 0b01110000, + 0b00000000, + 0b00000000, + //49 One + 0b00100000, + 0b01100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b01110000, + 0b00000000, + 0b00000000, + //50 two + 0b01110000, + 0b10001000, + 0b00010000, + 0b00100000, + 0b01000000, + 0b11111000, + 0b00000000, + 0b00000000, + //51 Three + 0b11111000, + 0b00010000, + 0b00100000, + 0b00010000, + 0b10001000, + 0b01110000, + 0b00000000, + 0b00000000, + //52 Four + 0b10010000, + 0b10010000, + 0b10010000, + 0b11111000, + 0b00010000, + 0b00010000, + 0b00000000, + 0b00000000, + //53 Five + 0b11111000, + 0b10000000, + 0b11110000, + 0b00001000, + 0b10001000, + 0b01110000, + 0b00000000, + 0b00000000, + //54 Six + 0b01110000, + 0b10000000, + 0b11110000, + 0b10001000, + 0b10001000, + 0b01110000, + 0b00000000, + 0b00000000, + //55 Seven + 0b11111000, + 0b00001000, + 0b00010000, + 0b00100000, + 0b01000000, + 0b10000000, + 0b00000000, + 0b00000000, + //56 Eight + 0b01110000, + 0b10001000, + 0b01110000, + 0b10001000, + 0b10001000, + 0b01110000, + 0b00000000, + 0b00000000, + //57 Nine + 0b01110000, + 0b10001000, + 0b10001000, + 0b01111000, + 0b00001000, + 0b01110000, + 0b00000000, + 0b00000000, + //58 : + 0b00000000, + 0b00000000, + 0b00100000, + 0b00000000, + 0b00000000, + 0b00100000, + 0b00000000, + 0b00000000, + //59 ; + 0b00000000, + 0b00000000, + 0b00100000, + 0b00000000, + 0b00100000, + 0b00100000, + 0b01000000, + 0b00000000, + //60 < + 0b00000000, + 0b00011000, + 0b01100000, + 0b10000000, + 0b01100000, + 0b00011000, + 0b00000000, + 0b00000000, + //61 = + 0b00000000, + 0b00000000, + 0b01111000, + 0b00000000, + 0b01111000, + 0b00000000, + 0b00000000, + 0b00000000, + //62 > + 0b00000000, + 0b11000000, + 0b00110000, + 0b00001000, + 0b00110000, + 0b11000000, + 0b00000000, + 0b00000000, + //63 ? + 0b01100000, + 0b10010000, + 0b00100000, + 0b00100000, + 0b00000000, + 0b00100000, + 0b00000000, + 0b00000000, + //64 @ + 0b01110000, + 0b10001000, + 0b10011000, + 0b10101000, + 0b10010000, + 0b10001000, + 0b01110000, + 0b00000000, + //65 A + 0b00100000, + 0b01010000, + 0b10001000, + 0b11111000, + 0b10001000, + 0b10001000, + 0b00000000, + 0b00000000, + //B + 0b11110000, + 0b10001000, + 0b11110000, + 0b10001000, + 0b10001000, + 0b11110000, + 0b00000000, + 0b00000000, + //C + 0b01110000, + 0b10001000, + 0b10000000, + 0b10000000, + 0b10001000, + 0b01110000, + 0b00000000, + 0b00000000, + //D + 0b11110000, + 0b10001000, + 0b10001000, + 0b10001000, + 0b10001000, + 0b11110000, + 0b00000000, + 0b00000000, + //E + 0b11111000, + 0b10000000, + 0b11111000, + 0b10000000, + 0b10000000, + 0b11111000, + 0b00000000, + 0b00000000, + //F + 0b11111000, + 0b10000000, + 0b11110000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b00000000, + 0b00000000, + //G + 0b01110000, + 0b10001000, + 0b10000000, + 0b10011000, + 0b10001000, + 0b01110000, + 0b00000000, + 0b00000000, + //H + 0b10001000, + 0b10001000, + 0b11111000, + 0b10001000, + 0b10001000, + 0b10001000, + 0b00000000, + 0b00000000, + //I + 0b01110000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b01110000, + 0b00000000, + 0b00000000, + //J + 0b00111000, + 0b00010000, + 0b00010000, + 0b00010000, + 0b10010000, + 0b01100000, + 0b00000000, + 0b00000000, + //K + 0b10001000, + 0b10010000, + 0b11100000, + 0b10100000, + 0b10010000, + 0b10001000, + 0b00000000, + 0b00000000, + //L + 0b10000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b11111000, + 0b00000000, + 0b00000000, + //M + 0b10001000, + 0b11011000, + 0b10101000, + 0b10101000, + 0b10001000, + 0b10001000, + 0b00000000, + 0b00000000, + //N + 0b10001000, + 0b10001000, + 0b11001000, + 0b10101000, + 0b10011000, + 0b10001000, + 0b00000000, + 0b00000000, + //O + 0b01110000, + 0b10001000, + 0b10001000, + 0b10001000, + 0b10001000, + 0b01110000, + 0b00000000, + 0b00000000, + //P + 0b11110000, + 0b10001000, + 0b11110000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b00000000, + 0b00000000, + //Q + 0b01110000, + 0b10001000, + 0b10001000, + 0b10101000, + 0b10010000, + 0b01101000, + 0b00000000, + 0b00000000, + //R + 0b11110000, + 0b10001000, + 0b11110000, + 0b10100000, + 0b10010000, + 0b10001000, + 0b00000000, + 0b00000000, + //S + 0b01111000, + 0b10000000, + 0b01110000, + 0b00001000, + 0b00001000, + 0b11110000, + 0b00000000, + 0b00000000, + //T + 0b11111000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00000000, + 0b00000000, + //U + 0b10001000, + 0b10001000, + 0b10001000, + 0b10001000, + 0b10001000, + 0b01110000, + 0b00000000, + 0b00000000, + //V + 0b10001000, + 0b10001000, + 0b10001000, + 0b10001000, + 0b01010000, + 0b00100000, + 0b00000000, + 0b00000000, + //W + 0b10001000, + 0b10001000, + 0b10101000, + 0b10101000, + 0b10101000, + 0b01010000, + 0b00000000, + 0b00000000, + //X + 0b10001000, + 0b01010000, + 0b00100000, + 0b01010000, + 0b10001000, + 0b10001000, + 0b00000000, + 0b00000000, + //Y + 0b10001000, + 0b10001000, + 0b01010000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00000000, + 0b00000000, + //Z + 0b11111000, + 0b00001000, + 0b00010000, + 0b00100000, + 0b01000000, + 0b11111000, + 0b00000000, + 0b00000000, + //91 [ + 0b11100000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b11100000, + 0b00000000, + 0b00000000, + //92 (backslash) + 0b00000000, + 0b10000000, + 0b01000000, + 0b00100000, + 0b00010000, + 0b00001000, + 0b00000000, + 0b00000000, + //93 ] + 0b00111000, + 0b00001000, + 0b00001000, + 0b00001000, + 0b00001000, + 0b00111000, + 0b00000000, + 0b00000000, + //94 ^ + 0b00100000, + 0b01010000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + //95 _ + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b11111000, + 0b00000000, + //96 ` + 0b10000000, + 0b01000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + //97 a + 0b00000000, + 0b01100000, + 0b00010000, + 0b01110000, + 0b10010000, + 0b01100000, + 0b00000000, + 0b00000000, + //98 b + 0b10000000, + 0b10000000, + 0b11100000, + 0b10010000, + 0b10010000, + 0b11100000, + 0b00000000, + 0b00000000, + //99 c + 0b00000000, + 0b00000000, + 0b01110000, + 0b10000000, + 0b10000000, + 0b01110000, + 0b00000000, + 0b00000000, + // 100 d + 0b00010000, + 0b00010000, + 0b01110000, + 0b10010000, + 0b10010000, + 0b01110000, + 0b00000000, + 0b00000000, + //101 e + 0b00000000, + 0b01100000, + 0b10010000, + 0b11110000, + 0b10000000, + 0b01110000, + 0b00000000, + 0b00000000, + //102 f + 0b00110000, + 0b01000000, + 0b11100000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b00000000, + 0b00000000, + //103 g + 0b00000000, + 0b01100000, + 0b10010000, + 0b01110000, + 0b00010000, + 0b00010000, + 0b01100000, + 0b00000000, + //104 h + 0b10000000, + 0b10000000, + 0b11100000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b00000000, + 0b00000000, + //105 i + 0b00100000, + 0b00000000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b01110000, + 0b00000000, + 0b00000000, + //106 j + 0b00010000, + 0b00000000, + 0b00110000, + 0b00010000, + 0b00010000, + 0b00010000, + 0b01100000, + 0b00000000, + //107 k + 0b10000000, + 0b10010000, + 0b10100000, + 0b11000000, + 0b10100000, + 0b10010000, + 0b00000000, + 0b00000000, + //108 l + 0b01100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b01110000, + 0b00000000, + 0b00000000, + //109 m + 0b00000000, + 0b00000000, + 0b01010000, + 0b10101000, + 0b10101000, + 0b10101000, + 0b00000000, + 0b00000000, + //110 n + 0b00000000, + 0b00000000, + 0b11110000, + 0b10001000, + 0b10001000, + 0b10001000, + 0b00000000, + 0b00000000, + //111 o + 0b00000000, + 0b00000000, + 0b01100000, + 0b10010000, + 0b10010000, + 0b01100000, + 0b00000000, + 0b00000000, + //112 p + 0b00000000, + 0b00000000, + 0b01100000, + 0b10010000, + 0b11110000, + 0b10000000, + 0b10000000, + 0b00000000, + //113 q + 0b00000000, + 0b00000000, + 0b01100000, + 0b10010000, + 0b11110000, + 0b00010000, + 0b00010000, + 0b00000000, + //114 r + 0b00000000, + 0b00000000, + 0b10110000, + 0b01001000, + 0b01000000, + 0b01000000, + 0b00000000, + 0b00000000, + //115 s + 0b00000000, + 0b00110000, + 0b01000000, + 0b00100000, + 0b00010000, + 0b01100000, + 0b00000000, + 0b00000000, + //116 t + 0b01000000, + 0b01000000, + 0b11100000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b00000000, + 0b00000000, + // 117u + 0b00000000, + 0b00000000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b01100000, + 0b00000000, + 0b00000000, + //118 v + 0b00000000, + 0b00000000, + 0b10001000, + 0b10001000, + 0b01010000, + 0b00100000, + 0b00000000, + 0b00000000, + //119 w + 0b00000000, + 0b00000000, + 0b10001000, + 0b10101000, + 0b10101000, + 0b01010000, + 0b00000000, + 0b00000000, + //120 x + 0b00000000, + 0b10001000, + 0b01010000, + 0b00100000, + 0b01010000, + 0b10001000, + 0b00000000, + 0b00000000, + //121 y + 0b00000000, + 0b00000000, + 0b10010000, + 0b10010000, + 0b01100000, + 0b01000000, + 0b10000000, + 0b00000000, + //122 z + 0b00000000, + 0b00000000, + 0b11110000, + 0b00100000, + 0b01000000, + 0b11110000, + 0b00000000, + 0b00000000, + //123 { + 0b00100000, + 0b01000000, + 0b01000000, + 0b10000000, + 0b01000000, + 0b01000000, + 0b00100000, + 0b00000000, + //124 | + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00000000, + //125 } + 0b00100000, + 0b00010000, + 0b00010000, + 0b00001000, + 0b00010000, + 0b00010000, + 0b00100000, + 0b00000000, + //126 ~ + 0b01000000, + 0b10101000, + 0b00010000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + //127 DEL + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000 +}; \ No newline at end of file diff --git a/Arduino/libraries/TVout/font6x8.h b/Arduino/libraries/TVout/font6x8.h new file mode 100755 index 0000000..b0d9200 --- /dev/null +++ b/Arduino/libraries/TVout/font6x8.h @@ -0,0 +1,8 @@ +#ifndef FONT6X8_H +#define FONT6X8_H + +#include + +extern const unsigned char font6x8[]; + +#endif \ No newline at end of file diff --git a/Arduino/libraries/TVout/font8x8.cpp b/Arduino/libraries/TVout/font8x8.cpp new file mode 100755 index 0000000..337da90 --- /dev/null +++ b/Arduino/libraries/TVout/font8x8.cpp @@ -0,0 +1,133 @@ +#include "font8x8.h" + +PROGMEM const unsigned char font8x8[] = { +8,8,0, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x3E, 0x41, 0x55, 0x41, 0x55, 0x49, 0x3E, +0x00, 0x3E, 0x7F, 0x6B, 0x7F, 0x6B, 0x77, 0x3E, +0x00, 0x22, 0x77, 0x7F, 0x7F, 0x3E, 0x1C, 0x08, +0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x1C, 0x08, +0x00, 0x08, 0x1C, 0x2A, 0x7F, 0x2A, 0x08, 0x1C, +0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x08, 0x1C, +0x00, 0x00, 0x1C, 0x3E, 0x3E, 0x3E, 0x1C, 0x00, +0xFF, 0xFF, 0xE3, 0xC1, 0xC1, 0xC1, 0xE3, 0xFF, +0x00, 0x00, 0x1C, 0x22, 0x22, 0x22, 0x1C, 0x00, +0xFF, 0xFF, 0xE3, 0xDD, 0xDD, 0xDD, 0xE3, 0xFF, +0x00, 0x0F, 0x03, 0x05, 0x39, 0x48, 0x48, 0x30, +0x00, 0x08, 0x3E, 0x08, 0x1C, 0x22, 0x22, 0x1C, +0x00, 0x18, 0x14, 0x10, 0x10, 0x30, 0x70, 0x60, +0x00, 0x0F, 0x19, 0x11, 0x13, 0x37, 0x76, 0x60, +0x00, 0x08, 0x2A, 0x1C, 0x77, 0x1C, 0x2A, 0x08, +0x00, 0x60, 0x78, 0x7E, 0x7F, 0x7E, 0x78, 0x60, +0x00, 0x03, 0x0F, 0x3F, 0x7F, 0x3F, 0x0F, 0x03, +0x00, 0x08, 0x1C, 0x2A, 0x08, 0x2A, 0x1C, 0x08, +0x00, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, +0x00, 0x3F, 0x65, 0x65, 0x3D, 0x05, 0x05, 0x05, +0x00, 0x0C, 0x32, 0x48, 0x24, 0x12, 0x4C, 0x30, +0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, +0x00, 0x08, 0x1C, 0x2A, 0x08, 0x2A, 0x1C, 0x3E, +0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x1C, 0x1C, 0x1C, +0x00, 0x1C, 0x1C, 0x1C, 0x7F, 0x3E, 0x1C, 0x08, +0x00, 0x08, 0x0C, 0x7E, 0x7F, 0x7E, 0x0C, 0x08, +0x00, 0x08, 0x18, 0x3F, 0x7F, 0x3F, 0x18, 0x08, +0x00, 0x00, 0x00, 0x70, 0x70, 0x70, 0x7F, 0x7F, +0x00, 0x00, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, +0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x3E, 0x7F, 0x7F, +0x00, 0x7F, 0x7F, 0x3E, 0x3E, 0x1C, 0x1C, 0x08, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, +0x00, 0x36, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, +0x00, 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, +0x00, 0x08, 0x1E, 0x20, 0x1C, 0x02, 0x3C, 0x08, +0x00, 0x60, 0x66, 0x0C, 0x18, 0x30, 0x66, 0x06, +0x00, 0x3C, 0x66, 0x3C, 0x28, 0x65, 0x66, 0x3F, +0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, +0x00, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, +0x00, 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, +0x00, 0x00, 0x36, 0x1C, 0x7F, 0x1C, 0x36, 0x00, +0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, +0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x60, +0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, +0x00, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00, +0x00, 0x3C, 0x66, 0x6E, 0x76, 0x66, 0x66, 0x3C, +0x00, 0x18, 0x18, 0x38, 0x18, 0x18, 0x18, 0x7E, +0x00, 0x3C, 0x66, 0x06, 0x0C, 0x30, 0x60, 0x7E, +0x00, 0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C, +0x00, 0x0C, 0x1C, 0x2C, 0x4C, 0x7E, 0x0C, 0x0C, +0x00, 0x7E, 0x60, 0x7C, 0x06, 0x06, 0x66, 0x3C, +0x00, 0x3C, 0x66, 0x60, 0x7C, 0x66, 0x66, 0x3C, +0x00, 0x7E, 0x66, 0x0C, 0x0C, 0x18, 0x18, 0x18, +0x00, 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, +0x00, 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x66, 0x3C, +0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, +0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x30, +0x00, 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, +0x00, 0x00, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x00, +0x00, 0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, +0x00, 0x3C, 0x66, 0x06, 0x1C, 0x18, 0x00, 0x18, +0x00, 0x38, 0x44, 0x5C, 0x58, 0x42, 0x3C, 0x00, +0x00, 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, +0x00, 0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x7C, +0x00, 0x3C, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3C, +0x00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, +0x00, 0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x7E, +0x00, 0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x60, +0x00, 0x3C, 0x66, 0x60, 0x60, 0x6E, 0x66, 0x3C, +0x00, 0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, +0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, +0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x6C, 0x6C, 0x38, +0x00, 0x66, 0x6C, 0x78, 0x70, 0x78, 0x6C, 0x66, +0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7E, +0x00, 0x63, 0x77, 0x7F, 0x6B, 0x63, 0x63, 0x63, +0x00, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x63, 0x63, +0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, +0x00, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, +0x00, 0x3C, 0x66, 0x66, 0x66, 0x6E, 0x3C, 0x06, +0x00, 0x7C, 0x66, 0x66, 0x7C, 0x78, 0x6C, 0x66, +0x00, 0x3C, 0x66, 0x60, 0x3C, 0x06, 0x66, 0x3C, +0x00, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x18, +0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3E, +0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, +0x00, 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, +0x00, 0x63, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x63, +0x00, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, +0x00, 0x7E, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x7E, +0x00, 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, +0x00, 0x00, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x00, +0x00, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, +0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, +0x00, 0x0C, 0x0C, 0x06, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, +0x00, 0x60, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C, +0x00, 0x00, 0x00, 0x3C, 0x66, 0x60, 0x66, 0x3C, +0x00, 0x06, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3E, +0x00, 0x00, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C, +0x00, 0x1C, 0x36, 0x30, 0x30, 0x7C, 0x30, 0x30, +0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x3C, +0x00, 0x60, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, +0x00, 0x00, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3C, +0x00, 0x0C, 0x00, 0x0C, 0x0C, 0x6C, 0x6C, 0x38, +0x00, 0x60, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0x66, +0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, +0x00, 0x00, 0x00, 0x63, 0x77, 0x7F, 0x6B, 0x6B, +0x00, 0x00, 0x00, 0x7C, 0x7E, 0x66, 0x66, 0x66, +0x00, 0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, +0x00, 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60, +0x00, 0x00, 0x3C, 0x6C, 0x6C, 0x3C, 0x0D, 0x0F, +0x00, 0x00, 0x00, 0x7C, 0x66, 0x66, 0x60, 0x60, +0x00, 0x00, 0x00, 0x3E, 0x40, 0x3C, 0x02, 0x7C, +0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x18, +0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E, +0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3C, 0x18, +0x00, 0x00, 0x00, 0x63, 0x6B, 0x6B, 0x6B, 0x3E, +0x00, 0x00, 0x00, 0x66, 0x3C, 0x18, 0x3C, 0x66, +0x00, 0x00, 0x00, 0x66, 0x66, 0x3E, 0x06, 0x3C, +0x00, 0x00, 0x00, 0x3C, 0x0C, 0x18, 0x30, 0x3C, +0x00, 0x0E, 0x18, 0x18, 0x30, 0x18, 0x18, 0x0E, +0x00, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, +0x00, 0x70, 0x18, 0x18, 0x0C, 0x18, 0x18, 0x70, +0x00, 0x00, 0x00, 0x3A, 0x6C, 0x00, 0x00, 0x00, +0x00, 0x08, 0x1C, 0x36, 0x63, 0x41, 0x41, 0x7F +}; \ No newline at end of file diff --git a/Arduino/libraries/TVout/font8x8.h b/Arduino/libraries/TVout/font8x8.h new file mode 100755 index 0000000..1d1c88d --- /dev/null +++ b/Arduino/libraries/TVout/font8x8.h @@ -0,0 +1,7 @@ +#ifndef FONT8X8_H +#define FONT8X8_H + +#include +extern const unsigned char font8x8[]; + +#endif \ No newline at end of file diff --git a/Arduino/libraries/TVout/font8x8ext.cpp b/Arduino/libraries/TVout/font8x8ext.cpp new file mode 100755 index 0000000..f3815eb --- /dev/null +++ b/Arduino/libraries/TVout/font8x8ext.cpp @@ -0,0 +1,261 @@ +#include "font8x8ext.h" + +PROGMEM const unsigned char font8x8ext[] = { +8,8,0, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x7E, 0x81, 0xA5, 0x81, 0xBD, 0x99, 0x81, 0x7E, +0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E, +0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00, +0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00, +0x38, 0x7C, 0x38, 0xFE, 0xFE, 0xD6, 0x10, 0x38, +0x10, 0x38, 0x7C, 0xFE, 0xFE, 0x7C, 0x10, 0x38, +0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00, +0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF, +0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00, +0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF, +0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78, +0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, +0x3F, 0x33, 0x3F, 0x30, 0x30, 0x70, 0xF0, 0xE0, +0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0, +0x18, 0xDB, 0x3C, 0xE7, 0xE7, 0x3C, 0xDB, 0x18, +0x80, 0xE0, 0xF8, 0xFE, 0xF8, 0xE0, 0x80, 0x00, +0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00, +0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18, +0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, +0x7F, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00, +0x3E, 0x61, 0x3C, 0x66, 0x66, 0x3C, 0x86, 0x7C, +0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00, +0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF, +0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, +0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, +0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, +0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00, +0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00, +0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00, +0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00, +0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00, +0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, +0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00, +0x18, 0x3E, 0x60, 0x3C, 0x06, 0x7C, 0x18, 0x00, +0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00, +0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00, +0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, +0x0C, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00, +0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00, +0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, +0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, +0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, +0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, +0x7C, 0xC6, 0xCE, 0xD6, 0xE6, 0xC6, 0x7C, 0x00, +0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00, +0x7C, 0xC6, 0x06, 0x1C, 0x30, 0x66, 0xFE, 0x00, +0x7C, 0xC6, 0x06, 0x3C, 0x06, 0xC6, 0x7C, 0x00, +0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00, +0xFE, 0xC0, 0xC0, 0xFC, 0x06, 0xC6, 0x7C, 0x00, +0x38, 0x60, 0xC0, 0xFC, 0xC6, 0xC6, 0x7C, 0x00, +0xFE, 0xC6, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00, +0x7C, 0xC6, 0xC6, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, +0x7C, 0xC6, 0xC6, 0x7E, 0x06, 0x0C, 0x78, 0x00, +0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, +0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30, +0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00, +0x00, 0x00, 0x7E, 0x00, 0x00, 0x7E, 0x00, 0x00, +0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00, +0x7C, 0xC6, 0x0C, 0x18, 0x18, 0x00, 0x18, 0x00, +0x7C, 0xC6, 0xDE, 0xDE, 0xDE, 0xC0, 0x78, 0x00, +0x38, 0x6C, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0x00, +0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, +0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00, +0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, +0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00, +0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00, +0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3A, 0x00, +0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0x00, +0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, +0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00, +0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00, +0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00, +0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00, +0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00, +0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, +0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, +0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xCE, 0x7C, 0x0E, +0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00, +0x7C, 0xC6, 0x60, 0x38, 0x0C, 0xC6, 0x7C, 0x00, +0x7E, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x3C, 0x00, +0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, +0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00, +0xC6, 0xC6, 0xC6, 0xD6, 0xD6, 0xFE, 0x6C, 0x00, +0xC6, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0xC6, 0x00, +0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x3C, 0x00, +0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00, +0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, +0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00, +0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00, +0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, +0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, +0xE0, 0x60, 0x7C, 0x66, 0x66, 0x66, 0xDC, 0x00, +0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xC6, 0x7C, 0x00, +0x1C, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, +0x00, 0x00, 0x7C, 0xC6, 0xFE, 0xC0, 0x7C, 0x00, +0x3C, 0x66, 0x60, 0xF8, 0x60, 0x60, 0xF0, 0x00, +0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, +0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00, +0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3C, 0x00, +0x06, 0x00, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3C, +0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00, +0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, +0x00, 0x00, 0xEC, 0xFE, 0xD6, 0xD6, 0xD6, 0x00, +0x00, 0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x00, +0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, +0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0, +0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E, +0x00, 0x00, 0xDC, 0x76, 0x60, 0x60, 0xF0, 0x00, +0x00, 0x00, 0x7E, 0xC0, 0x7C, 0x06, 0xFC, 0x00, +0x30, 0x30, 0xFC, 0x30, 0x30, 0x36, 0x1C, 0x00, +0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, +0x00, 0x00, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00, +0x00, 0x00, 0xC6, 0xD6, 0xD6, 0xFE, 0x6C, 0x00, +0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00, +0x00, 0x00, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0xFC, +0x00, 0x00, 0x7E, 0x4C, 0x18, 0x32, 0x7E, 0x00, +0x0E, 0x18, 0x18, 0x70, 0x18, 0x18, 0x0E, 0x00, +0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, +0x70, 0x18, 0x18, 0x0E, 0x18, 0x18, 0x70, 0x00, +0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00, +0x60, 0xF0, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x0C, +0xFC, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x6C, 0x00, +0x1C, 0x10, 0x00, 0x7E, 0x60, 0x60, 0x60, 0x00, +0x38, 0x20, 0xFE, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, +0x6C, 0x00, 0x7C, 0xC6, 0xFE, 0xC0, 0x7C, 0x00, +0x6C, 0xFE, 0x62, 0x78, 0x60, 0x62, 0xFE, 0x00, +0x00, 0x00, 0x7C, 0xC6, 0xF0, 0xC6, 0x7C, 0x00, +0x3C, 0x66, 0xC0, 0xF8, 0xC0, 0x66, 0x3C, 0x00, +0x00, 0x00, 0x7E, 0xC0, 0x7C, 0x06, 0xFC, 0x00, +0x7C, 0xC6, 0x60, 0x38, 0x0C, 0xC6, 0x7C, 0x00, +0x30, 0x00, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, +0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, +0xCC, 0x00, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, +0x66, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, +0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x70, +0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0xCC, 0x78, 0x00, +0x00, 0x00, 0x70, 0x50, 0x5C, 0x52, 0xDC, 0x00, +0x70, 0x50, 0x5C, 0x52, 0x52, 0x52, 0xDC, 0x00, +0x00, 0x00, 0xA0, 0xA0, 0xFC, 0xA2, 0xBC, 0x00, +0xA0, 0xA0, 0xA0, 0xFC, 0xA2, 0xA2, 0xBC, 0x00, +0x60, 0xF0, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x00, +0xF8, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x00, +0x1C, 0x10, 0xC6, 0xD8, 0xF8, 0xCC, 0xC6, 0x00, +0x18, 0xD6, 0xCC, 0xF8, 0xF8, 0xCC, 0xC6, 0x00, +0x6C, 0x38, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x7C, +0x38, 0xC6, 0xC6, 0x7E, 0x06, 0xC6, 0x7C, 0x00, +0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xFE, 0x10, +0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xFE, 0x10, +0x00, 0x00, 0xDC, 0xD6, 0xF6, 0xD6, 0xDC, 0x00, +0xDC, 0xD6, 0xD6, 0xF6, 0xD6, 0xD6, 0xDC, 0x00, +0x00, 0x00, 0xF0, 0xB0, 0x3C, 0x36, 0x3C, 0x00, +0xF0, 0xF0, 0xB0, 0x3C, 0x36, 0x36, 0x3C, 0x00, +0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, +0x3E, 0x66, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0x00, +0x06, 0x7C, 0xC0, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, +0xFE, 0x66, 0x60, 0x7C, 0x66, 0x66, 0xFC, 0x00, +0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xFE, 0x06, +0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xFE, 0x06, +0x00, 0x00, 0x3C, 0x6C, 0x6C, 0x6C, 0xFE, 0xC6, +0x1E, 0x36, 0x66, 0x66, 0x66, 0x66, 0xFF, 0xC3, +0x00, 0x00, 0x7C, 0xC6, 0xFE, 0xC0, 0x7C, 0x00, +0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00, +0x00, 0x00, 0x7C, 0xD6, 0xD6, 0x7C, 0x10, 0x38, +0x7C, 0xD6, 0xD6, 0xD6, 0x7C, 0x10, 0x38, 0x00, +0x00, 0x00, 0xFE, 0x66, 0x60, 0x60, 0xF0, 0x00, +0xFE, 0x66, 0x60, 0x60, 0x60, 0x60, 0xF0, 0x00, +0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00, +0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00, +0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, +0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, +0xDB, 0x77, 0xDB, 0xEE, 0xDB, 0x77, 0xDB, 0xEE, +0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, +0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, +0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00, +0xC6, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0xC6, 0x00, +0x00, 0x00, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0x00, +0xC6, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0x00, +0x36, 0x36, 0xF6, 0x06, 0xF6, 0x36, 0x36, 0x36, +0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, +0x00, 0x00, 0xFE, 0x06, 0xF6, 0x36, 0x36, 0x36, +0x36, 0x36, 0xF6, 0x06, 0xFE, 0x00, 0x00, 0x00, +0x00, 0x38, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0x00, +0x38, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0x00, +0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18, +0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, +0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18, +0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18, +0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, +0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, +0x00, 0x00, 0xE6, 0x6C, 0x78, 0x6C, 0xE6, 0x00, +0xE6, 0x6C, 0x78, 0x78, 0x6C, 0x66, 0xE6, 0x00, +0x36, 0x36, 0x37, 0x30, 0x3F, 0x00, 0x00, 0x00, +0x00, 0x00, 0x3F, 0x30, 0x37, 0x36, 0x36, 0x36, +0x36, 0x36, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0x00, +0x00, 0x00, 0xFF, 0x00, 0xF7, 0x36, 0x36, 0x36, +0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, +0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, +0x36, 0x36, 0xF7, 0x00, 0xF7, 0x36, 0x36, 0x36, +0x00, 0xC6, 0x7C, 0xC6, 0xC6, 0x7C, 0xC6, 0x00, +0x00, 0x00, 0x3E, 0x66, 0x66, 0x66, 0xE6, 0x00, +0x1E, 0x36, 0x66, 0x66, 0x66, 0x66, 0xC6, 0x00, +0x00, 0x00, 0xC6, 0xFE, 0xFE, 0xD6, 0xC6, 0x00, +0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00, +0x00, 0x00, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0x00, +0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0x00, +0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, +0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, +0x00, 0x00, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, +0x18, 0x18, 0x18, 0x18, 0xF8, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, +0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, +0x00, 0x00, 0x7E, 0xC6, 0x7E, 0x66, 0xC6, 0x00, +0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, +0x7E, 0xC6, 0xC6, 0xC6, 0x7E, 0x66, 0xC6, 0x00, +0x00, 0x00, 0xFC, 0x66, 0x66, 0x7C, 0x60, 0xF0, +0xFC, 0x66, 0x66, 0x66, 0x7C, 0x60, 0xF0, 0x00, +0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xC6, 0x7C, 0x00, +0x7C, 0xC6, 0xC0, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, +0x00, 0x00, 0x7E, 0x5A, 0x18, 0x18, 0x3C, 0x00, +0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, +0x00, 0x00, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x7C, +0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0xC6, 0x7C, 0x00, +0x00, 0x00, 0xD6, 0x7C, 0x38, 0x7C, 0xD6, 0x00, +0xD6, 0xD6, 0x7C, 0x38, 0x7C, 0xD6, 0xD6, 0x00, +0x00, 0x00, 0xFC, 0x66, 0x7C, 0x66, 0xFC, 0x00, +0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, +0x00, 0x00, 0xF0, 0x60, 0x7C, 0x66, 0xFC, 0x00, +0xF0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C, 0x00, +0x8F, 0xCD, 0xEF, 0xFC, 0xDC, 0xCC, 0xCC, 0x00, +0x00, 0x00, 0x00, 0x7C, 0x7C, 0x00, 0x00, 0x00, +0x00, 0x00, 0xC6, 0xC6, 0xF6, 0xDE, 0xF6, 0x00, +0xC6, 0xC6, 0xC6, 0xF6, 0xDE, 0xDE, 0xF6, 0x00, +0x00, 0x00, 0x7C, 0xC6, 0x1C, 0xC6, 0x7C, 0x00, +0x7C, 0xC6, 0x06, 0x3C, 0x06, 0xC6, 0x7C, 0x00, +0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xFE, 0x00, +0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFE, 0x00, +0x00, 0x00, 0x7C, 0xC6, 0x1E, 0xC6, 0x7C, 0x00, +0x78, 0x8C, 0x06, 0x3E, 0x06, 0x8C, 0x78, 0x00, +0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xFF, 0x03, +0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFF, 0x03, +0x00, 0x00, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x00, +0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x06, 0x00, +0x3E, 0x61, 0x3C, 0x66, 0x66, 0x3C, 0x86, 0x7C, +0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; \ No newline at end of file diff --git a/Arduino/libraries/TVout/font8x8ext.h b/Arduino/libraries/TVout/font8x8ext.h new file mode 100755 index 0000000..8f888ca --- /dev/null +++ b/Arduino/libraries/TVout/font8x8ext.h @@ -0,0 +1,7 @@ +#ifndef FONT8X8EXT_H +#define FONT8X8EXT_H + +#include +extern const unsigned char font8x8ext[]; + +#endif \ No newline at end of file diff --git a/Arduino/libraries/TVout/fontALL.h b/Arduino/libraries/TVout/fontALL.h new file mode 100755 index 0000000..4362761 --- /dev/null +++ b/Arduino/libraries/TVout/fontALL.h @@ -0,0 +1,9 @@ +#ifndef FONTALL_H +#define FONTALL_H + +#include "font4x6.h" +#include "font6x8.h" +#include "font8x8.h" +#include "font8x8ext.h" + +#endif \ No newline at end of file diff --git a/Arduino/libraries/TVout/keywords.txt b/Arduino/libraries/TVout/keywords.txt new file mode 100755 index 0000000..34dbc56 --- /dev/null +++ b/Arduino/libraries/TVout/keywords.txt @@ -0,0 +1,54 @@ +NTSC LITERAL1 +PAL LITERAL1 +_NTSC LITERAL1 +_PAL LITERAL1 +WHITE LITERAL1 +BLACK LITERAL1 +INVERT LITERAL1 +UP LITERAL1 +DOWN LITERAL1 +LEFT LITERAL1 +RIGHT LITERAL1 + +TVout KEYWORD1 + +clearScreen KEYWORD2 +invert KEYWORD2 + +begin KEYWORD2 +end KEYWORD2 +force_vscale KEYWORD2 +force_outstart KEYWORD2 +force_linestart KEYWORD2 +hres KEYWORD2 +vres KEYWORD2 +charLine KEYWORD2 +fill KEYWORD2 +delay KEYWORD2 +delayFrame KEYWORD2 +millis KEYWORD2 +setPixel KEYWORD2 +getPixel KEYWORD2 +fill KEYWORD2 +shift KEYWORD2 +drawLine KEYWORD2 +drawRow KEYWORD2 +drawColumn KEYWORD2 +drawRect KEYWORD2 +drawCircle KEYWORD2 +bitmap KEYWORD2 +set_vbi_hook KEYWORD2 +set_hbi_hook KEYWORD2 +tone KEYWORD2 +noTone KEYWORD2 +printChar KEYWORD2 +setCursor KEYWORD2 +selectFont KEYWORD2 +print KEYWORD2 +println KEYWORD2 +printPGM KEYWORD2 + +font4x6 LITERAL1 +font6x8 LITERAL1 +font8x8 LITERAL1 +font8x8ext LITERAL1 diff --git a/Arduino/libraries/TVout/spec/asm_macros.h b/Arduino/libraries/TVout/spec/asm_macros.h new file mode 100755 index 0000000..55b1b26 --- /dev/null +++ b/Arduino/libraries/TVout/spec/asm_macros.h @@ -0,0 +1,119 @@ +#include "hardware_setup.h" + +#ifndef ASM_MACROS_H +#define ASM_MACROS_H + +// delay macros +__asm__ __volatile__ ( + // delay 1 clock cycle. + ".macro delay1\n\t" + "nop\n" + ".endm\n" + + // delay 2 clock cycles + ".macro delay2\n\t" + "nop\n\t" + "nop\n" + ".endm\n" + + // delay 3 clock cyles + ".macro delay3\n\t" + "nop\n\t" + "nop\n\t" + "nop\n" + ".endm\n" + + // delay 4 clock cylces + ".macro delay4\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n" + ".endm\n" + + // delay 5 clock cylces + ".macro delay5\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n" + ".endm\n" + + // delay 6 clock cylces + ".macro delay6\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n" + ".endm\n" + + // delay 7 clock cylces + ".macro delay7\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n" + ".endm\n" + + // delay 8 clock cylces + ".macro delay8\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n" + ".endm\n" + + // delay 9 clock cylces + ".macro delay9\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n" + ".endm\n" + + // delay 10 clock cylces + ".macro delay10\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n" + ".endm\n" +); + +// common output macros, specific output macros at top of file +__asm__ __volatile__ ( + + // save port 16 and clear the video bit + ".macro svprt p\n\t" + "in r16,\\p\n\t" + ANDI_HWS + ".endm\n" + + // ouput 1 bit port safe + ".macro o1bs p\n\t" + BLD_HWS + "out \\p,r16\n" + ".endm\n" +); +#endif \ No newline at end of file diff --git a/Arduino/libraries/TVout/spec/hardware_setup.h b/Arduino/libraries/TVout/spec/hardware_setup.h new file mode 100755 index 0000000..f0134c7 --- /dev/null +++ b/Arduino/libraries/TVout/spec/hardware_setup.h @@ -0,0 +1,146 @@ +// sound is output on OC2A +// sync output is on OC1A + +// ENABLE_FAST_OUTPUT chooses the highest bit of a port over the original output method +// comment out this line to switch back to the original output pins. +#define ENABLE_FAST_OUTPUT + +#ifndef HARDWARE_SETUP_H +#define HARDWARE_SETUP_H + +// device specific settings. +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) +#if defined(ENABLE_FAST_OUTPUT) +#define PORT_VID PORTA +#define DDR_VID DDRA +#define VID_PIN 7 +#else +//video +#define PORT_VID PORTB +#define DDR_VID DDRB +#define VID_PIN 6 +#endif +//sync +#define PORT_SYNC PORTB +#define DDR_SYNC DDRB +#define SYNC_PIN 5 +//sound +#define PORT_SND PORTB +#define DDR_SND DDRB +#define SND_PIN 4 + +#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) +//video +#if defined(ENABLE_FAST_OUTPUT) +#define PORT_VID PORTA +#define DDR_VID DDRA +#define VID_PIN 7 +#else +#define PORT_VID PORTD +#define DDR_VID DDRD +#define VID_PIN 4 +#endif +//sync +#define PORT_SYNC PORTD +#define DDR_SYNC DDRD +#define SYNC_PIN 5 +//sound +#define PORT_SND PORTD +#define DDR_SND DDRD +#define SND_PIN 7 + +// Arduino UNO +#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) +//video +#if defined(ENABLE_FAST_OUTPUT) +#define PORT_VID PORTD +#define DDR_VID DDRD +#define VID_PIN 7 +#else +#define PORT_VID PORTB +#define DDR_VID DDRB +#define VID_PIN 0 +#endif +//sync +#define PORT_SYNC PORTB +#define DDR_SYNC DDRB +#define SYNC_PIN 1 +//sound +#define PORT_SND PORTB +#define DDR_SND DDRB +#define SND_PIN 3 + +// Arduino DUE +#elif defined (__AVR_AT90USB1286__) +//video +#define PORT_VID PORTF +#define DDR_VID DDRF +#define VID_PIN 7 +//sync +#define PORT_SYNC PORTB +#define DDR_SYNC DDRB +#define SYNC_PIN 5 +//sound +#define PORT_SND PORTB +#define DDR_SND DDRB +#define SND_PIN 4 + +// Arduino Leonardo +#elif defined(__AVR_ATmega32U4__) +// video arduino pin 8 +#define PORT_VID PORTB +#define DDR_VID DDRB +#define VID_PIN 4 +// sync arduino pin 9 +#define PORT_SYNC PORTB +#define DDR_SYNC DDRB +#define SYNC_PIN 5 +// sound arduino pin 11 +#define PORT_SND PORTB +#define DDR_SND DDRB +#define SND_PIN 7 +#define TCCR2A TCCR0A +#define TCCR2B TCCR0B +#define OCR2A OCR0A +#define OCR2B OCR0B +#define COM2A0 COM0A0 +#define COM2A1 COM0A1 +#define CS20 CS00 +#define WGM21 WGM01 +#endif + +//automatic BST/BLD/ANDI macro definition +#if VID_PIN == 0 +#define BLD_HWS "bld r16,0\n\t" +#define BST_HWS "bst r16,0\n\t" +#define ANDI_HWS "andi r16,0xFE\n" +#elif VID_PIN == 1 +#define BLD_HWS "bld r16,1\n\t" +#define BST_HWS "bst r16,1\n\t" +#define ANDI_HWS "andi r16,0xFD\n" +#elif VID_PIN == 2 +#define BLD_HWS "bld r16,2\n\t" +#define BST_HWS "bst r16,2\n\t" +#define ANDI_HWS "andi r16,0xFB\n" +#elif VID_PIN == 3 +#define BLD_HWS "bld r16,3\n\t" +#define BST_HWS "bst r16,3\n\t" +#define ANDI_HWS "andi r16,0xF7\n" +#elif VID_PIN == 4 +#define BLD_HWS "bld r16,4\n\t" +#define BST_HWS "bst r16,4\n\t" +#define ANDI_HWS "andi r16,0xEF\n" +#elif VID_PIN == 5 +#define BLD_HWS "bld r16,5\n\t" +#define BST_HWS "bst r16,5\n\t" +#define ANDI_HWS "andi r16,0xDF\n" +#elif VID_PIN == 6 +#define BLD_HWS "bld r16,6\n\t" +#define BST_HWS "bst r16,6\n\t" +#define ANDI_HWS "andi r16,0xBF\n" +#elif VID_PIN == 7 +#define BLD_HWS "bld r16,7\n\t" +#define BST_HWS "bst r16,7\n\t" +#define ANDI_HWS "andi r16,0x7F\n" +#endif +#endif \ No newline at end of file diff --git a/Arduino/libraries/TVout/spec/video_properties.h b/Arduino/libraries/TVout/spec/video_properties.h new file mode 100755 index 0000000..7434906 --- /dev/null +++ b/Arduino/libraries/TVout/spec/video_properties.h @@ -0,0 +1,41 @@ +/* This File contains the timing definitions for the TVout AVR composite video + generation Library +*/ +#ifndef VIDEO_TIMING_H +#define VIDEO_TIMING_H + +#define _CYCLES_PER_US (F_CPU / 1000000) + +#define _TIME_HORZ_SYNC 4.7 +#define _TIME_VIRT_SYNC 58.85 +#define _TIME_ACTIVE 46 +#define _CYCLES_VIRT_SYNC ((_TIME_VIRT_SYNC * _CYCLES_PER_US) - 1) +#define _CYCLES_HORZ_SYNC ((_TIME_HORZ_SYNC * _CYCLES_PER_US) - 1) + +// Timing settings for NTSC +#define _NTSC_TIME_SCANLINE 63.55 +#define _NTSC_TIME_OUTPUT_START 12 + +#define _NTSC_LINE_FRAME 262 +#define _NTSC_LINE_START_VSYNC 0 +#define _NTSC_LINE_STOP_VSYNC 3 +#define _NTSC_LINE_DISPLAY 216 +#define _NTSC_LINE_MID ((_NTSC_LINE_FRAME - _NTSC_LINE_DISPLAY) / 2 + _NTSC_LINE_DISPLAY / 2) + +#define _NTSC_CYCLES_SCANLINE ((_NTSC_TIME_SCANLINE * _CYCLES_PER_US) - 1) +#define _NTSC_CYCLES_OUTPUT_START ((_NTSC_TIME_OUTPUT_START * _CYCLES_PER_US) - 1) + +// Timing settings for PAL +#define _PAL_TIME_SCANLINE 64 +#define _PAL_TIME_OUTPUT_START 12.5 + +#define _PAL_LINE_FRAME 312 +#define _PAL_LINE_START_VSYNC 0 +#define _PAL_LINE_STOP_VSYNC 7 +#define _PAL_LINE_DISPLAY 260 +#define _PAL_LINE_MID ((_PAL_LINE_FRAME - _PAL_LINE_DISPLAY) / 2 + _PAL_LINE_DISPLAY / 2) + +#define _PAL_CYCLES_SCANLINE ((_PAL_TIME_SCANLINE * _CYCLES_PER_US) - 1) +#define _PAL_CYCLES_OUTPUT_START ((_PAL_TIME_OUTPUT_START * _CYCLES_PER_US) - 1) + +#endif diff --git a/Arduino/libraries/TVout/video_gen.cpp b/Arduino/libraries/TVout/video_gen.cpp new file mode 100755 index 0000000..2a1bfb4 --- /dev/null +++ b/Arduino/libraries/TVout/video_gen.cpp @@ -0,0 +1,517 @@ +/* + Copyright (c) 2010 Myles Metzer + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions: + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "video_gen.h" +#include "spec/asm_macros.h" + +//#define REMOVE6C +//#define REMOVE5C +//#define REMOVE4C +//#define REMOVE3C + +int renderLine; +TVout_vid display; +void (*render_line)(); +void (*line_handler)(); +void (*hbi_hook)() = ∅ +void (*vbi_hook)() = ∅ + +// sound properties +volatile long remainingToneVsyncs; + +void empty() { + +} +// start timer +void render_setup(uint8_t mode, uint8_t x, uint8_t y, uint8_t *scrnptr) { + display.screen = scrnptr; + display.hres = x; + display.vres = y; + display.frames = 0; + + if (mode) { + display.vscale_const = _PAL_LINE_DISPLAY / display.vres - 1; + } else { + display.vscale_const = _NTSC_LINE_DISPLAY / display.vres - 1; + } + display.vscale = display.vscale_const; + + // selects the widest render method that fits in 46us + // as of 9/16/10 rendermode 3 will not work for resolutions lower than + // 192(display.hres lower than 24) + unsigned char rmethod = (_TIME_ACTIVE*_CYCLES_PER_US) / (display.hres * 8); + switch(rmethod) { + case 6: + render_line = &render_line6c; + break; + case 5: + render_line = &render_line5c; + break; + case 4: + render_line = &render_line4c; + break; + case 3: + render_line = &render_line3c; + break; + default: + if (rmethod > 6) { + render_line = &render_line6c; + } else { + render_line = &render_line3c; + } + } + + DDR_VID |= _BV(VID_PIN); + DDR_SYNC |= _BV(SYNC_PIN); + PORT_VID &= ~_BV(VID_PIN); + PORT_SYNC |= _BV(SYNC_PIN); + // for tone generation + DDR_SND |= _BV(SND_PIN); + + // inverted fast pwm mode on timer 1 + TCCR1A = _BV(COM1A1) | _BV(COM1A0) | _BV(WGM11); + TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); + + if (mode) { + display.start_render = _PAL_LINE_MID - ((display.vres * (display.vscale_const + 1)) / 2); + display.output_delay = _PAL_CYCLES_OUTPUT_START; + display.vsync_end = _PAL_LINE_STOP_VSYNC; + display.lines_frame = _PAL_LINE_FRAME; + ICR1 = _PAL_CYCLES_SCANLINE; + OCR1A = _CYCLES_HORZ_SYNC; + } else { + display.start_render = _NTSC_LINE_MID - ((display.vres * (display.vscale_const+1))/2) + 8; + display.output_delay = _NTSC_CYCLES_OUTPUT_START; + display.vsync_end = _NTSC_LINE_STOP_VSYNC; + display.lines_frame = _NTSC_LINE_FRAME; + ICR1 = _NTSC_CYCLES_SCANLINE; + OCR1A = _CYCLES_HORZ_SYNC; + } + display.scanLine = display.lines_frame + 1; + line_handler = &vsync_line; + TIMSK1 = _BV(TOIE1); + sei(); +} + +// render a line +ISR(TIMER1_OVF_vect) { + hbi_hook(); + line_handler(); +} + +// вызываем синхронизацию или прорисовку строки +void blank_line() { + if (display.scanLine == display.start_render) { + renderLine = 0; + display.vscale = display.vscale_const; + line_handler = &active_line; + } else if (display.scanLine == display.lines_frame) { + line_handler = &vsync_line; + vbi_hook(); + } + display.scanLine++; +} + + +void active_line() { + wait_until(display.output_delay); + render_line(); + if (!display.vscale) { + display.vscale = display.vscale_const; + renderLine += display.hres; + } else { + display.vscale--; + } + if ((display.scanLine + 1) == (int)(display.start_render + (display.vres * (display.vscale_const + 1)))) { + line_handler = &blank_line; + } + display.scanLine++; +} + +// генерируем синхроимпульс +void vsync_line() { + if (display.scanLine >= display.lines_frame) { + OCR1A = _CYCLES_VIRT_SYNC; + display.scanLine = 0; + display.frames++; + if (remainingToneVsyncs != 0) { + if (remainingToneVsyncs > 0) { + remainingToneVsyncs--; + } + } else { + // stop the tone + TCCR2B = 0; + PORTB &= ~(_BV(SND_PIN)); + } + } else if (display.scanLine == display.vsync_end) { + OCR1A = _CYCLES_HORZ_SYNC; + line_handler = &blank_line; + } + display.scanLine++; +} + + +static void inline wait_until(uint8_t time) { + __asm__ __volatile__ ( + "subi %[time], 10\n" + "sub %[time], %[tcnt1l]\n\t" + "100:\n\t" + "subi %[time], 3\n\t" + "brcc 100b\n\t" + "subi %[time], 0-3\n\t" + "breq 101f\n\t" + "dec %[time]\n\t" + "breq 102f\n\t" + "rjmp 102f\n" + "101:\n\t" + "nop\n" + "102:\n" + : + : [time] "a" (time), + [tcnt1l] "a" (TCNT1L) + ); +} + +void render_line6c() { + #ifndef REMOVE6C + __asm__ __volatile__ ( + "ADD r26,r28\n\t" + "ADC r27,r29\n\t" + // save PORTB + "svprt %[port]\n\t" + "rjmp enter6\n" + "loop6:\n\t" + // 8 + "bst __tmp_reg__,0\n\t" + "o1bs %[port]\n" + "enter6:\n\t" + // 1 + "LD __tmp_reg__,X+\n\t" + "delay1\n\t" + "bst __tmp_reg__,7\n\t" + "o1bs %[port]\n\t" + // 2 + "delay3\n\t" + "bst __tmp_reg__,6\n\t" + "o1bs %[port]\n\t" + // 3 + "delay3\n\t" + "bst __tmp_reg__,5\n\t" + "o1bs %[port]\n\t" + // 4 + "delay3\n\t" + "bst __tmp_reg__,4\n\t" + "o1bs %[port]\n\t" + // 5 + "delay3\n\t" + "bst __tmp_reg__,3\n\t" + "o1bs %[port]\n\t" + // 6 + "delay3\n\t" + "bst __tmp_reg__,2\n\t" + "o1bs %[port]\n\t" + // 7 + "delay3\n\t" + "bst __tmp_reg__,1\n\t" + "o1bs %[port]\n\t" + "dec %[hres]\n\t" + // go too loopsix + "brne loop6\n\t" + "delay2\n\t" + // 8 + "bst __tmp_reg__,0\n\t" + "o1bs %[port]\n" + "svprt %[port]\n\t" + BST_HWS + "o1bs %[port]\n\t" + : + : [port] "i" (_SFR_IO_ADDR(PORT_VID)), + "x" (display.screen), + "y" (renderLine), + [hres] "d" (display.hres) + : "r16" // try to remove this clobber later... + ); + #endif +} + +void render_line5c() { + #ifndef REMOVE5C + __asm__ __volatile__ ( + "ADD r26,r28\n\t" + "ADC r27,r29\n\t" + // save PORTB + "svprt %[port]\n\t" + "rjmp enter5\n" + "loop5:\n\t" + // 8 + "bst __tmp_reg__,0\n\t" + "o1bs %[port]\n" + "enter5:\n\t" + // 1 + "LD __tmp_reg__,X+\n\t" + "bst __tmp_reg__,7\n\t" + "o1bs %[port]\n\t" + // 2 + "delay2\n\t" + "bst __tmp_reg__,6\n\t" + "o1bs %[port]\n\t" + // 3 + "delay2\n\t" + "bst __tmp_reg__,5\n\t" + "o1bs %[port]\n\t" + // 4 + "delay2\n\t" + "bst __tmp_reg__,4\n\t" + "o1bs %[port]\n\t" + // 5 + "delay2\n\t" + "bst __tmp_reg__,3\n\t" + "o1bs %[port]\n\t" + // 6 + "delay2\n\t" + "bst __tmp_reg__,2\n\t" + "o1bs %[port]\n\t" + // 7 + "delay1\n\t" + "dec %[hres]\n\t" + "bst __tmp_reg__,1\n\t" + "o1bs %[port]\n\t" + // go too loop5 + "brne loop5\n\t" + "delay1\n\t" + // 8 + "bst __tmp_reg__,0\n\t" + "o1bs %[port]\n" + "svprt %[port]\n\t" + BST_HWS + "o1bs %[port]\n\t" + : + : [port] "i" (_SFR_IO_ADDR(PORT_VID)), + "x" (display.screen), + "y" (renderLine), + [hres] "d" (display.hres) + : "r16" // try to remove this clobber later... + ); + #endif +} + +void render_line4c() { + #ifndef REMOVE4C + __asm__ __volatile__ ( + "ADD r26,r28\n\t" + "ADC r27,r29\n\t" + "rjmp enter4\n" + "loop4:\n\t" + // 8 + "lsl __tmp_reg__\n\t" + "out %[port],__tmp_reg__\n\t" + "enter4:\n\t" + // 1 + "LD __tmp_reg__,X+\n\t" + "delay1\n\t" + "out %[port],__tmp_reg__\n\t" + // 2 + "delay2\n\t" + "lsl __tmp_reg__\n\t" + "out %[port],__tmp_reg__\n\t" + // 3 + "delay2\n\t" + "lsl __tmp_reg__\n\t" + "out %[port],__tmp_reg__\n\t" + // 4 + "delay2\n\t" + "lsl __tmp_reg__\n\t" + "out %[port],__tmp_reg__\n\t" + "delay2\n\t" + "lsl __tmp_reg__\n\t" + "out %[port],__tmp_reg__\n\t" + // 6 + "delay2\n\t" + "lsl __tmp_reg__\n\t" + "out %[port],__tmp_reg__\n\t" + // 7 + "delay1\n\t" + "lsl __tmp_reg__\n\t" + "dec %[hres]\n\t" + "out %[port],__tmp_reg__\n\t" + // go too loop4 + "brne loop4\n\t" + // 8 + "delay1\n\t" + "lsl __tmp_reg__\n\t" + "out %[port],__tmp_reg__\n\t" + "delay3\n\t" + "cbi %[port],7\n\t" + : + : [port] "i" (_SFR_IO_ADDR(PORT_VID)), + "x" (display.screen), + "y" (renderLine), + [hres] "d" (display.hres) + : "r16" // try to remove this clobber later... + ); + #endif +} + +// only 16mhz right now!!! +void render_line3c() { + #ifndef REMOVE3C + __asm__ __volatile__ ( + ".macro byteshift\n\t" + "LD __tmp_reg__,X+\n\t" + // 0 + "out %[port],__tmp_reg__\n\t" + "nop\n\t" + "lsl __tmp_reg__\n\t" + // 1 + "out %[port],__tmp_reg__\n\t" + "nop\n\t" + "lsl __tmp_reg__\n\t" + // 2 + "out %[port],__tmp_reg__\n\t" + "nop\n\t" + "lsl __tmp_reg__\n\t" + // 3 + "out %[port],__tmp_reg__\n\t" + "nop\n\t" + "lsl __tmp_reg__\n\t" + // 4 + "out %[port],__tmp_reg__\n\t" + "nop\n\t" + "lsl __tmp_reg__\n\t" + // 5 + "out %[port],__tmp_reg__\n\t" + "nop\n\t" + "lsl __tmp_reg__\n\t" + // 6 + "out %[port],__tmp_reg__\n\t" + "nop\n\t" + "lsl __tmp_reg__\n\t" + // 7 + "out %[port],__tmp_reg__\n\t" + ".endm\n\t" + "ADD r26,r28\n\t" + "ADC r27,r29\n\t" + // 615 + "cpi %[hres],30\n\t" + "breq skip0\n\t" + "cpi %[hres],29\n\t" + "breq jumpto1\n\t" + "cpi %[hres],28\n\t" + "breq jumpto2\n\t" + "cpi %[hres],27\n\t" + "breq jumpto3\n\t" + "cpi %[hres],26\n\t" + "breq jumpto4\n\t" + "cpi %[hres],25\n\t" + "breq jumpto5\n\t" + "cpi %[hres],24\n\t" + "breq jumpto6\n\t" + "jumpto1:\n\t" + "rjmp skip1\n\t" + "jumpto2:\n\t" + "rjmp skip2\n\t" + "jumpto3:\n\t" + "rjmp skip3\n\t" + "jumpto4:\n\t" + "rjmp skip4\n\t" + "jumpto5:\n\t" + "rjmp skip5\n\t" + "jumpto6:\n\t" + "rjmp skip6\n\t" + "skip0:\n\t" + //1 643 + "byteshift\n\t" + "skip1:\n\t" + // 2 + "byteshift\n\t" + "skip2:\n\t" + // 3 + "byteshift\n\t" + "skip3:\n\t" + // 4 + "byteshift\n\t" + "skip4:\n\t" + // 5 + "byteshift\n\t" + "skip5:\n\t" + // 6 + "byteshift\n\t" + "skip6:\n\t" + // 7 + "byteshift\n\t" + // 8 + "byteshift\n\t" + // 9 + "byteshift\n\t" + // 10 + "byteshift\n\t" + // 11 + "byteshift\n\t" + // 12 + "byteshift\n\t" + // 13 + "byteshift\n\t" + // 14 + "byteshift\n\t" + // 15 + "byteshift\n\t" + // 16 + "byteshift\n\t" + // 17 + "byteshift\n\t" + // 18 + "byteshift\n\t" + // 19 + "byteshift\n\t" + // 20 + "byteshift\n\t" + // 21 + "byteshift\n\t" + // 22 + "byteshift\n\t" + // 23 + "byteshift\n\t" + // 24 + "byteshift\n\t" + // 25 + "byteshift\n\t" + // 26 + "byteshift\n\t" + // 27 + "byteshift\n\t" + // 28 + "byteshift\n\t" + // 29 + "byteshift\n\t" + // 30 + "byteshift\n\t" + "delay2\n\t" + "cbi %[port],7\n\t" + : + : [port] "i" (_SFR_IO_ADDR(PORT_VID)), + "x" (display.screen), + "y" (renderLine), + [hres] "d" (display.hres) + : "r16" // try to remove this clobber later... + ); + #endif +} diff --git a/Arduino/libraries/TVout/video_gen.h b/Arduino/libraries/TVout/video_gen.h new file mode 100755 index 0000000..bd19659 --- /dev/null +++ b/Arduino/libraries/TVout/video_gen.h @@ -0,0 +1,71 @@ +/* + Copyright (c) 2010 Myles Metzer + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions: + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef VIDEO_GEN_H +#define VIDEO_GEN_H + +#include +#include +#include "spec/video_properties.h" +#include "spec/hardware_setup.h" + +typedef struct { + volatile int scanLine; + volatile unsigned long frames; + unsigned char start_render; + // remove me + int lines_frame; + uint8_t vres; + uint8_t hres; + // remove me + uint8_t output_delay; + // combine me with status switch + char vscale_const; + // combine me too. + char vscale; + // remove me + char vsync_end; + uint8_t* screen; +} TVout_vid; + +extern TVout_vid display; + +extern void (*hbi_hook)(); +extern void (*vbi_hook)(); + +void render_setup(uint8_t mode, uint8_t x, uint8_t y, uint8_t *scrnptr); + +void blank_line(); +void active_line(); +void vsync_line(); +void empty(); + +// tone generation properties +extern volatile long remainingToneVsyncs; + +// 6cycles functions +void render_line6c(); +void render_line5c(); +void render_line4c(); +void render_line3c(); +static void inline wait_until(uint8_t time); +#endif