├── ATMega328P+ColorLCD └── Ada_ATMega328_LCD.ino ├── Ada_1325_OLED_SD_PRT_SS_CAM_AS_RTC.ino ├── Ada_1351_L_SingleAVR_OLED_SD_PRT_SS_CAM_AS_RTC.ino ├── Ada_ATMega1284_LCD_PQD ├── Ada_ATMega1284_LCD_PQD.ino ├── PDQ_ST7735.h └── PDQ_ST7735_config.h ├── Ada_ATMega1284_LCD_SD_CAMERA.ino ├── Ada_ATMega1284_LCD_SD_CAM_DISP.ino ├── Ada_ATMega1284_LCD_SDcard_3.ino ├── Ada_ATMega1284_LCD_Twit_R └── Ada_ATMega1284_LCD_Twit_R.ino ├── Ada_SingleAVR_OLED_SD_CAMERA.ino ├── Ada_SingleAVR_OLED_SD_PRT.ino ├── Ada_SingleAVR_OLED_SD_PRT_QR.ino ├── Ada_SingleAVR_OLED_SD_PRT_SS_CAM_AS.ino ├── Ada_SingleAVR_OLED_SD_PRT_SS_CAM_AS_RTC.ino ├── Ada_SingleAVR_OLED_SD_PRT_SS_CAM_DISP2.ino ├── Ada_SingleAVR_OLED_SD_PRT_SS_CAM_DISP2_TONE.ino ├── Apple_one_OLED17 ├── Apple_one_OLED17.ino └── cpu.c ├── Kanji_clock1.ino ├── LICENSE ├── README.md ├── XMEM_support ├── Ada_SingleAVR_OLED_SDCARD_GIGA_XMEM.ino ├── Atmega1280_xmem_512K.brd ├── Atmega1280_xmem_512K.sch ├── Atmega1280_xmem_512K_v2.brd └── Atmega1280_xmem_512K_v2.sch ├── atmega1284_oled.brd ├── atmega1284_oled.sch ├── atmega1284_oled_v2.brd ├── atmega1284_oled_v2.sch ├── atmega1284p_v4_gerber ├── atmega1284_v4.drd ├── atmega1284_v4.dri ├── atmega1284_v4_bot.gpi ├── atmega1284_v4_bot.grb ├── atmega1284_v4_top.gpi └── atmega1284_v4_top.grb ├── bitlash_OLED.ino ├── bitlasholed.ino ├── gerber_LCD_ATMEGA1284 ├── atmega_LCD.drd ├── atmega_LCD_bottom.gbr └── atmega_LCD_top.gbr ├── kanji_test_OLED.ino ├── morse_encode_decode.ino ├── oled_pattern.jpg ├── oled_sch.jpg ├── simple_nihongo_reader_OLED.ino ├── tinybasic_for_1284_LCD.ino └── toyoshiki-tinybasic ├── ttbasic.cpp ├── ttbasic.h └── ttbasic_arduino.ino /Ada_ATMega1284_LCD_PQD/PDQ_ST7735.h: -------------------------------------------------------------------------------- 1 | // This is the PDQ re-mixed version of Adafruit's library 2 | // here is the original copyright notice: 3 | 4 | /*************************************************** 5 | This is a library for the Adafruit 1.8" SPI display. 6 | 7 | This library works with the Adafruit 1.8" TFT Breakout w/SD card 8 | ----> http://www.adafruit.com/products/358 9 | The 1.8" TFT shield 10 | ----> https://www.adafruit.com/product/802 11 | The 1.44" TFT breakout 12 | ----> https://www.adafruit.com/product/2088 13 | as well as Adafruit raw 1.8" TFT display 14 | ----> http://www.adafruit.com/products/618 15 | 16 | Check out the links above for our tutorials and wiring diagrams 17 | These displays use SPI to communicate, 4 or 5 pins are required to 18 | interface (RST is optional) 19 | Adafruit invests time and resources providing this open source code, 20 | please support Adafruit and open-source hardware by purchasing 21 | products from Adafruit! 22 | 23 | Written by Limor Fried/Ladyada for Adafruit Industries. 24 | MIT license, all text above must be included in any redistribution 25 | ****************************************************/ 26 | 27 | //=============================================================== 28 | // This PDQ optimized version is by Xark 29 | // 30 | // Inspiration from Paul Stoffregen and the Teensy 3.1 community. 31 | // 32 | // GOALS: 33 | // 1) Maintain "sketch" compatibility with original Adafruit libraries. 34 | // 2) Be as much faster as is reasonably possible honoring goal 1. :-) 35 | // 3) Be at least as small as Adafruit libraries. 36 | // 37 | // I believe all three of these have largely been achieved: 38 | // 1) Near full compatibility. Only minor initialization changes in original sketch. 39 | // 2) Between ~3.5 and ~12 times faster (fillRect ~2.5x, drawLine > ~14x). 40 | // An average of almost 5x faster over entire "graphictest.ino" benchmark. 41 | // 42 | // Even if this library is faster, it was based on the Adafruit original. 43 | // Adafruit deserves your support for making their library open-source (and 44 | // for having some nice LCD modules and all kinds of other great parts too). 45 | // Consider giving them your support if possible! 46 | 47 | #if !defined(_PDQ_ST7735H_) 48 | #define _PDQ_ST7735H_ 49 | 50 | #include "Arduino.h" 51 | #include "Print.h" 52 | 53 | #include 54 | 55 | #include 56 | #include 57 | 58 | #if !defined(ST7735_CHIPSET) || !defined(ST7735_CS_PIN) || !defined(ST7735_DC_PIN) 59 | #error Oops! You need to #include "PDQ_ST7735_config.h" (modified with your pin configuration and options) from your sketch before #include "PDQ_ST7735.h". 60 | #endif 61 | 62 | #include 63 | 64 | #if !defined(AVR_HARDWARE_SPI) 65 | #error Oops! Currently hardware SPI is required. Bother Xark if you would like USI or bit-bang SPI supported. 66 | #endif 67 | 68 | #define INLINE inline 69 | #define INLINE_OPT __attribute__((always_inline)) 70 | 71 | // Color definitions 72 | enum 73 | { 74 | ST7735_BLACK = 0x0000, 75 | ST7735_BLUE = 0x001F, 76 | ST7735_RED = 0xF800, 77 | ST7735_GREEN = 0x07E0, 78 | ST7735_CYAN = 0x07FF, 79 | ST7735_MAGENTA = 0xF81F, 80 | ST7735_YELLOW = 0xFFE0, 81 | ST7735_WHITE = 0xFFFF, 82 | }; 83 | 84 | class PDQ_ST7735 : public PDQ_GFX 85 | { 86 | public: 87 | // ST7735 commands (read commands omitted) 88 | // For datasheet see https://www.adafruit.com/products/358 89 | enum 90 | { 91 | ST7735_NOP = 0x00, 92 | ST7735_SWRESET = 0x01, 93 | 94 | ST7735_SLPIN = 0x10, 95 | ST7735_SLPOUT = 0x11, 96 | ST7735_PTLON = 0x12, 97 | ST7735_NORON = 0x13, 98 | 99 | ST7735_INVOFF = 0x20, 100 | ST7735_INVON = 0x21, 101 | ST7735_DISPOFF = 0x28, 102 | ST7735_DISPON = 0x29, 103 | ST7735_CASET = 0x2A, 104 | ST7735_RASET = 0x2B, 105 | ST7735_RAMWR = 0x2C, 106 | 107 | ST7735_COLMOD = 0x3A, 108 | ST7735_MADCTL = 0x36, 109 | 110 | ST7735_FRMCTR1 = 0xB1, 111 | ST7735_FRMCTR2 = 0xB2, 112 | ST7735_FRMCTR3 = 0xB3, 113 | ST7735_INVCTR = 0xB4, 114 | ST7735_DISSET5 = 0xB6, 115 | 116 | ST7735_PWCTR1 = 0xC0, 117 | ST7735_PWCTR2 = 0xC1, 118 | ST7735_PWCTR3 = 0xC2, 119 | ST7735_PWCTR4 = 0xC3, 120 | ST7735_PWCTR5 = 0xC4, 121 | ST7735_VMCTR1 = 0xC5, 122 | 123 | ST7735_GMCTRP1 = 0xE0, 124 | ST7735_GMCTRN1 = 0xE1, 125 | 126 | ST7735_PWCTR6 = 0xFC, 127 | }; 128 | 129 | // some other misc. constants 130 | enum 131 | { 132 | // screen dimensions 133 | ST7735_TFTWIDTH = 128, 134 | ST7735_TFTHEIGHT_144 = 128, // 1.44" display 135 | ST7735_TFTHEIGHT_18 = 160, // 1.8" display 136 | 137 | // MADCTL bits 138 | ST7735_MADCTL_MH = 0x04, // bit 2 = 0 for refresh left -> right, 1 for refresh right -> left 139 | ST7735_MADCTL_RGB = 0x00, // bit 3 = 0 for RGB color order 140 | ST7735_MADCTL_BGR = 0x08, // bit 3 = 1 for BGR color order 141 | ST7735_MADCTL_ML = 0x10, // bit 4 = 0 for refresh top -> bottom, 1 for bottom -> top 142 | ST7735_MADCTL_MV = 0x20, // bit 5 = 0 for column, row order (portrait), 1 for row, column order (landscape) 143 | ST7735_MADCTL_MX = 0x40, // bit 6 = 0 for left -> right, 1 for right -> left order 144 | ST7735_MADCTL_MY = 0x80, // bit 7 = 0 for top -> bottom, 1 for bottom -> top 145 | 146 | // delay indicator bit for commandList() 147 | DELAY = 0x80 148 | }; 149 | 150 | // higher-level routines 151 | PDQ_ST7735(); 152 | static void inline begin(); 153 | // NOTE: initB and initR(tabcolor) are here for compatibility (but both just call begin()). 154 | // NOTE: You must set the ST7735 chip version using ST7735_CHIPSET in "PDQ_ST7735_config.h" file (in sketch folder) 155 | static void inline initB() __attribute__((always_inline)) { begin(); } // compatibility alias for begin 156 | static void inline initR(uint8_t tabcolor) __attribute__((always_inline)) { (void)tabcolor; begin(); } // compatibility alias for begin 157 | 158 | static void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); 159 | static void pushColor(uint16_t color); 160 | static void pushColor(uint16_t color, int16_t count); 161 | 162 | // Pass 8-bit (each) R,G,B, get back 16-bit packed color 163 | static INLINE uint16_t color565(uint8_t r, uint8_t g, uint8_t b) 164 | { 165 | return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); 166 | } 167 | static INLINE uint16_t Color565(uint8_t r, uint8_t g, uint8_t b) // older inconsistent name for compatibility 168 | { 169 | return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); 170 | } 171 | 172 | // required driver primitive methods (all except drawPixel can call generic version in PDQ_GFX with "_" postfix). 173 | static void drawPixel(int16_t x, int16_t y, uint16_t color); 174 | static void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 175 | static void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 176 | static void setRotation(uint8_t r); 177 | static void invertDisplay(boolean i); 178 | 179 | static inline void fillScreen(uint16_t color) __attribute__((always_inline)) 180 | { 181 | fillScreen_(color); // call generic version 182 | } 183 | 184 | static void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); 185 | static void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 186 | 187 | // === lower-level internal routines ========= 188 | static void commandList(const uint8_t *addr); 189 | 190 | // NOTE: Make sure each spi_begin() is matched with a single spi_end() (and don't call either twice) 191 | // set CS back to low (LCD selected) 192 | static inline void spi_begin() __attribute__((always_inline)) 193 | { 194 | #if ST7735_SAVE_SPCR 195 | swap(save_SPCR, SPCR); // swap initial/current SPCR settings 196 | #endif 197 | FastPin::lo(); // CS <= LOW (selected) 198 | } 199 | 200 | // NOTE: Make sure each spi_begin() is matched with a single spi_end() (and don't call either twice) 201 | // reset CS back to high (LCD unselected) 202 | static inline void spi_end() __attribute__((always_inline)) 203 | { 204 | FastPin::hi(); // CS <= HIGH (deselected) 205 | #if ST7735_SAVE_SPCR 206 | swap(SPCR, save_SPCR); // swap current/initial SPCR settings 207 | #endif 208 | } 209 | 210 | // 10 cycle delay (including "call") 211 | static void delay10() __attribute__((noinline)) __attribute__((naked)) 212 | { 213 | __asm__ __volatile__ 214 | ( 215 | // +4 (call to get here) 216 | #if !defined(__AVR_HAVE_RAMPD__) 217 | " adiw r24,0\n" // +2 (2-cycle NOP) 218 | #else 219 | " nop\n" // +1 (1-cycle NOP) 220 | #endif 221 | " ret\n" // +4 (or +5 on >64KB AVR with RAMPD reg) 222 | // = 10 cycles 223 | : : : 224 | ); 225 | } 226 | 227 | // 13 cycle delay (including "call") 228 | static void delay13() __attribute__((noinline)) __attribute__((naked)) 229 | { 230 | __asm__ __volatile__ 231 | ( 232 | // +4 (call to get here) 233 | " adiw r24,0\n" // +2 (2-cycle NOP) 234 | " adiw r24,0\n" // +2 (2-cycle NOP) 235 | #if !defined(__AVR_HAVE_RAMPD__) 236 | " nop\n" // +1 (1-cycle NOP) 237 | #endif 238 | " ret\n" // +4 (or +5 on >64KB AVR with RAMPD reg) 239 | // = 13 cycles 240 | : : : 241 | ); 242 | } 243 | 244 | // 15 cycle delay (including "call") 245 | static void delay15() __attribute__((noinline)) __attribute__((naked)) 246 | { 247 | __asm__ __volatile__ 248 | ( 249 | // +4 (call to get here) 250 | " adiw r24,0\n" // +2 (2-cycle NOP) 251 | " adiw r24,0\n" // +2 (2-cycle NOP) 252 | " adiw r24,0\n" // +2 (2-cycle NOP) 253 | #if !defined(__AVR_HAVE_RAMPD__) 254 | " nop\n" // +1 (1-cycle NOP) 255 | #endif 256 | " ret\n" // +4 (or +5 on >64KB AVR with RAMPD reg) 257 | // = 15 cycles 258 | : : : 259 | ); 260 | } 261 | 262 | // 17 cycle delay (including "call") 263 | static void delay17() __attribute__((noinline)) __attribute__((naked)) 264 | { 265 | __asm__ __volatile__ 266 | ( 267 | // +4 (call to get here) 268 | " adiw r24,0\n" // +2 (2-cycle NOP) 269 | " adiw r24,0\n" // +2 (2-cycle NOP) 270 | " adiw r24,0\n" // +2 (2-cycle NOP) 271 | " adiw r24,0\n" // +2 (2-cycle NOP) 272 | #if !defined(__AVR_HAVE_RAMPD__) 273 | " nop\n" // +1 (2-cycle NOP) 274 | #endif 275 | " ret\n" // +4 (or +5 on >64KB AVR with RAMPD reg) 276 | // = 17 cycles 277 | : : : 278 | ); 279 | } 280 | 281 | // normal SPI write with minimal hand-tuned delay (assuming max DIV2 SPI rate) 282 | static INLINE void spiWrite(uint8_t data) INLINE_OPT 283 | { 284 | SPDR = data; 285 | __asm__ __volatile__ 286 | ( 287 | " call _ZN10PDQ_ST77357delay17Ev\n" // call mangled delay17 (compiler would needlessly save/restore regs) 288 | : : : 289 | ); 290 | } 291 | 292 | // special SPI write with minimal hand-tuned delay (assuming max DIV2 SPI rate) - minus 2 cycles for RS (etc.) change 293 | static INLINE void spiWrite_preCmd(uint8_t data) INLINE_OPT 294 | { 295 | SPDR = data; 296 | 297 | __asm__ __volatile__ 298 | ( 299 | " call _ZN10PDQ_ST77357delay15Ev\n" // call mangled delay15 (compiler would needlessly save/restore regs) 300 | : : : 301 | ); 302 | } 303 | 304 | // SPI 16-bit write with minimal hand-tuned delay (assuming max DIV2 SPI rate) 305 | static INLINE void spiWrite16(uint16_t data) INLINE_OPT 306 | { 307 | uint8_t temp; 308 | __asm__ __volatile__ 309 | ( 310 | " out %[spi],%[hi]\n" // write SPI data (18 cycles until next write) 311 | " call _ZN10PDQ_ST77357delay17Ev\n" // call mangled delay17 (compiler would needlessly save/restore regs) 312 | " out %[spi],%[lo]\n" // write SPI data (18 cycles until next write) 313 | " call _ZN10PDQ_ST77357delay17Ev\n" // call mangled delay17 (compiler would needlessly save/restore regs) 314 | 315 | : [temp] "=d" (temp) 316 | : [spi] "i" (_SFR_IO_ADDR(SPDR)), [lo] "r" ((uint8_t)data), [hi] "r" ((uint8_t)(data>>8)) 317 | : 318 | ); 319 | } 320 | 321 | // SPI 16-bit write with minimal hand-tuned delay (assuming max DIV2 SPI rate) minus 2 cycles 322 | static INLINE void spiWrite16_preCmd(uint16_t data) INLINE_OPT 323 | { 324 | uint8_t temp; 325 | __asm__ __volatile__ 326 | ( 327 | " out %[spi],%[hi]\n" // write SPI data (18 cycles until next write) 328 | " call _ZN10PDQ_ST77357delay17Ev\n" // call mangled delay17 (compiler would needlessly save/restore regs) 329 | " out %[spi],%[lo]\n" // write SPI data (18 cycles until next write) 330 | " call _ZN10PDQ_ST77357delay15Ev\n" // call mangled delay15 (compiler would needlessly save/restore regs) 331 | 332 | : [temp] "=d" (temp) 333 | : [spi] "i" (_SFR_IO_ADDR(SPDR)), [lo] "r" ((uint8_t)data), [hi] "r" ((uint8_t)(data>>8)) 334 | : 335 | ); 336 | } 337 | 338 | // SPI 16-bit write with minimal hand-tuned delay (assuming max DIV2 SPI rate) for drawLine 339 | static INLINE void spiWrite16_lineDraw(uint16_t data) INLINE_OPT 340 | { 341 | uint8_t temp; 342 | __asm__ __volatile__ 343 | ( 344 | " out %[spi],%[hi]\n" // write SPI data (18 cycles until next write) 345 | " call _ZN10PDQ_ST77357delay17Ev\n" // call mangled delay17 (compiler would needlessly save/restore regs) 346 | " out %[spi],%[lo]\n" // write SPI data (18 cycles until next write) 347 | 348 | : [temp] "=d" (temp) 349 | : [spi] "i" (_SFR_IO_ADDR(SPDR)), [lo] "r" ((uint8_t)data), [hi] "r" ((uint8_t)(data>>8)) 350 | : 351 | ); 352 | } 353 | 354 | // normal SPI write with minimal hand-tuned delay (assuming max DIV2 SPI rate) 355 | static INLINE void spiWrite16(uint16_t data, int16_t count) INLINE_OPT 356 | { 357 | uint8_t temp; 358 | __asm__ __volatile__ 359 | ( 360 | " sbiw %[count],0\n" // test count 361 | " brmi 4f\n" // if < 0 then done 362 | " breq 4f\n" // if == 0 then done 363 | "1: out %[spi],%[hi]\n" // write SPI data (18 cycles until next write) 364 | " call _ZN10PDQ_ST77357delay17Ev\n" // call mangled delay17 (compiler would needlessly save/restore regs) 365 | " out %[spi],%[lo]\n" // write SPI data (18 cycles until next write) 366 | " call _ZN10PDQ_ST77357delay13Ev\n" // call mangled delay13 (compiler would needlessly save/restore regs) 367 | " sbiw %[count],1\n" // +2 decrement count 368 | " brne 1b\n" // +2/1 if != 0 then loop 369 | // = 13 + 2 + 2 (17 cycles) 370 | "4:\n" 371 | 372 | : [temp] "=d" (temp), [count] "+w" (count) 373 | : [spi] "i" (_SFR_IO_ADDR(SPDR)), [lo] "r" ((uint8_t)data), [hi] "r" ((uint8_t)(data>>8)) 374 | : 375 | ); 376 | } 377 | // write SPI byte with RS (aka D/C) pin set low to indicate a command byte (and then reset back to high when done) 378 | static INLINE void writeCommand(uint8_t data) INLINE_OPT 379 | { 380 | FastPin::lo(); // RS <= LOW indicate command byte 381 | spiWrite_preCmd(data); 382 | FastPin::hi(); // RS <= HIGH indicate data byte (always assumed left in data mode) 383 | } 384 | 385 | // write SPI byte with RS assumed low indicating a data byte 386 | static inline void writeData(uint8_t data) __attribute__((always_inline)) 387 | { 388 | spiWrite(data); 389 | } 390 | 391 | // internal version that does not spi_begin()/spi_end() 392 | static INLINE void setAddrWindow_(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) INLINE_OPT 393 | { 394 | writeCommand(ST7735_CASET); // column address set 395 | if ((ST7735_CHIPSET == ST7735_INITR_GREENTAB) || (ST7735_CHIPSET == ST7735_INITR_144GREENTAB)) 396 | { 397 | spiWrite16(x0+2); // XSTART 398 | spiWrite16_preCmd(x1+2); // XEND 399 | } 400 | else 401 | { 402 | spiWrite16(x0); // XSTART 403 | spiWrite16_preCmd(x1); // XEND 404 | } 405 | 406 | writeCommand(ST7735_RASET); // row address set 407 | if (ST7735_CHIPSET == ST7735_INITR_GREENTAB) 408 | { 409 | spiWrite16(y0+1); // YSTART 410 | spiWrite16_preCmd(y1+1); // YEND 411 | } 412 | else if (ST7735_CHIPSET == ST7735_INITR_144GREENTAB) 413 | { 414 | spiWrite16(y0+3); // YSTART 415 | spiWrite16_preCmd(y1+3); // YEND 416 | } 417 | else 418 | { 419 | spiWrite16(y0); // YSTART 420 | spiWrite16_preCmd(y1); // YEND 421 | } 422 | 423 | writeCommand(ST7735_RAMWR); // write to RAM 424 | } 425 | 426 | #if ST7735_SAVE_SPCR 427 | static volatile uint8_t save_SPCR; // initial SPCR value/saved SPCR value (swapped in spi_begin/spi_end) 428 | #endif 429 | }; 430 | 431 | /*************************************************** 432 | This is a library for the Adafruit 1.8" SPI display. 433 | 434 | This library works with the Adafruit 1.8" TFT Breakout w/SD card 435 | ----> http://www.adafruit.com/products/358 436 | The 1.8" TFT shield 437 | ----> https://www.adafruit.com/product/802 438 | The 1.44" TFT breakout 439 | ----> https://www.adafruit.com/product/2088 440 | as well as Adafruit raw 1.8" TFT display 441 | ----> http://www.adafruit.com/products/618 442 | 443 | Check out the links above for our tutorials and wiring diagrams 444 | These displays use SPI to communicate, 4 or 5 pins are required to 445 | interface (RST is optional) 446 | Adafruit invests time and resources providing this open source code, 447 | please support Adafruit and open-source hardware by purchasing 448 | products from Adafruit! 449 | 450 | Written by Limor Fried/Ladyada for Adafruit Industries. 451 | MIT license, all text above must be included in any redistribution 452 | ****************************************************/ 453 | 454 | #if ST7735_SAVE_SPCR 455 | // static data needed by base class 456 | volatile uint8_t PDQ_ST7735::save_SPCR; 457 | #endif 458 | 459 | // Constructor when using hardware SPI. 460 | PDQ_ST7735::PDQ_ST7735() : PDQ_GFX(ST7735_TFTWIDTH, ST7735_TFTHEIGHT_18) 461 | { 462 | // must reference these functions from C++ or they will be stripped by linker (called from inline asm) 463 | delay10(); 464 | delay13(); 465 | delay15(); 466 | delay17(); 467 | } 468 | 469 | // Companion code to the above tables. Reads and issues 470 | // a series of LCD commands stored in PROGMEM byte array. 471 | void PDQ_ST7735::commandList(const uint8_t *addr) 472 | { 473 | uint8_t numCommands, numArgs; 474 | uint16_t ms; 475 | 476 | numCommands = pgm_read_byte(addr++); // Number of commands to follow 477 | while (numCommands--) // For each command... 478 | { 479 | writeCommand(pgm_read_byte(addr++)); // Read, issue command 480 | numArgs = pgm_read_byte(addr++); // Number of args to follow 481 | ms = numArgs & DELAY; // If hibit set, delay follows args 482 | numArgs &= ~DELAY; // Mask out delay bit 483 | while (numArgs--) // For each argument... 484 | { 485 | writeData(pgm_read_byte(addr++)); // Read, issue argument 486 | } 487 | 488 | if (ms) 489 | { 490 | ms = pgm_read_byte(addr++); // Read post-command delay time (ms) 491 | if(ms == 255) 492 | ms = 500; // If 255, delay for 500 ms 493 | delay(ms); 494 | } 495 | } 496 | } 497 | 498 | void PDQ_ST7735::begin() 499 | { 500 | // set CS and RS pin directions to output 501 | FastPin::setOutput(); 502 | FastPin::setOutput(); 503 | 504 | FastPin::hi(); // CS <= HIGH (so no spurious data) 505 | FastPin::hi(); // RS <= HIGH (default data byte) 506 | 507 | #if ST7735_SAVE_SPCR 508 | uint8_t oldSPCR = SPCR; // save current SPCR settings 509 | #endif 510 | SPI.begin(); 511 | SPI.setBitOrder(MSBFIRST); 512 | SPI.setDataMode(SPI_MODE0); 513 | SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!) [1 byte every 18 cycles] 514 | 515 | #if ST7735_SAVE_SPCR 516 | save_SPCR = SPCR; // save new initial SPCR settings 517 | SPCR = oldSPCR; // restore previous SPCR settings (spi_begin/spi_end will switch between the two) 518 | #endif 519 | spi_begin(); 520 | 521 | // ST7735B 522 | if (ST7735_CHIPSET == ST7735_INITB) 523 | { 524 | // Initialization commands for ST7735B screens 525 | static const uint8_t PROGMEM Bcmd[] = // ==== Initialization commands for 7735B screens 526 | { 527 | 18, // 18 commands in list: 528 | ST7735_SWRESET, DELAY, // 1: Software reset, no args, w/delay 529 | 50, // 50 ms delay 530 | ST7735_SLPOUT , DELAY, // 2: Out of sleep mode, no args, w/delay 531 | 255, // 255 = 500 ms delay 532 | ST7735_COLMOD , 1+DELAY, // 3: Set color mode, 1 arg + delay: 533 | 0x05, // 16-bit color 534 | 10, // 10 ms delay 535 | ST7735_FRMCTR1, 3+DELAY, // 4: Frame rate control, 3 args + delay: 536 | 0x00, // fastest refresh 537 | 0x06, // 6 lines front porch 538 | 0x03, // 3 lines back porch 539 | 10, // 10 ms delay 540 | ST7735_MADCTL , 1 , // 5: Memory access ctrl (directions), 1 arg: 541 | 0x08, // Row addr/col addr, bottom to top refresh 542 | ST7735_DISSET5, 2 , // 6: Display settings #5, 2 args, no delay: 543 | 0x15, // 1 clk cycle nonoverlap, 2 cycle gate 544 | // rise, 3 cycle osc equalize 545 | 0x02, // Fix on VTL 546 | ST7735_INVCTR , 1 , // 7: Display inversion control, 1 arg: 547 | 0x0, // Line inversion 548 | ST7735_PWCTR1 , 2+DELAY, // 8: Power control, 2 args + delay: 549 | 0x02, // GVDD = 4.7V 550 | 0x70, // 1.0uA 551 | 10, // 10 ms delay 552 | ST7735_PWCTR2 , 1 , // 9: Power control, 1 arg, no delay: 553 | 0x05, // VGH = 14.7V, VGL = -7.35V 554 | ST7735_PWCTR3 , 2 , // 10: Power control, 2 args, no delay: 555 | 0x01, // Opamp current small 556 | 0x02, // Boost frequency 557 | ST7735_VMCTR1 , 2+DELAY, // 11: Power control, 2 args + delay: 558 | 0x3C, // VCOMH = 4V 559 | 0x38, // VCOML = -1.1V 560 | 10, // 10 ms delay 561 | ST7735_PWCTR6 , 2 , // 12: Power control, 2 args, no delay: 562 | 0x11, 0x15, 563 | ST7735_GMCTRP1,16 , // 13: Magical unicorn dust, 16 args, no delay: 564 | 0x09, 0x16, 0x09, 0x20, // (seriously though, not sure what 565 | 0x21, 0x1B, 0x13, 0x19, // these config values represent) 566 | 0x17, 0x15, 0x1E, 0x2B, 567 | 0x04, 0x05, 0x02, 0x0E, 568 | ST7735_GMCTRN1,16+DELAY, // 14: Sparkles and rainbows, 16 args + delay: 569 | 0x0B, 0x14, 0x08, 0x1E, // (ditto) 570 | 0x22, 0x1D, 0x18, 0x1E, 571 | 0x1B, 0x1A, 0x24, 0x2B, 572 | 0x06, 0x06, 0x02, 0x0F, 573 | 10, // 10 ms delay 574 | ST7735_CASET , 4 , // 15: Column addr set, 4 args, no delay: 575 | 0x00, 0x02, // XSTART = 2 576 | 0x00, 0x81, // XEND = 129 577 | ST7735_RASET , 4 , // 16: Row addr set, 4 args, no delay: 578 | 0x00, 0x02, // XSTART = 1 579 | 0x00, 0x81, // XEND = 160 580 | ST7735_NORON , DELAY, // 17: Normal display on, no args, w/delay 581 | 10, // 10 ms delay 582 | ST7735_DISPON , DELAY, // 18: Main screen turn on, no args, w/delay 583 | 255 // 255 = 500 ms delay 584 | }; 585 | commandList(Bcmd); 586 | } 587 | else 588 | { 589 | static const uint8_t PROGMEM Rcmd1[] = // ==== Init for 7735R, part 1 (red or green tab) 590 | { 591 | 15, // 15 commands in list: 592 | ST7735_SWRESET, DELAY, // 1: Software reset, 0 args, w/delay 593 | 150, // 150 ms delay 594 | ST7735_SLPOUT , DELAY, // 2: Out of sleep mode, 0 args, w/delay 595 | 255, // 500 ms delay 596 | ST7735_FRMCTR1, 3 , // 3: Frame rate ctrl - normal mode, 3 args: 597 | 0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D) 598 | ST7735_FRMCTR2, 3 , // 4: Frame rate control - idle mode, 3 args: 599 | 0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D) 600 | ST7735_FRMCTR3, 6 , // 5: Frame rate ctrl - partial mode, 6 args: 601 | 0x01, 0x2C, 0x2D, // Dot inversion mode 602 | 0x01, 0x2C, 0x2D, // Line inversion mode 603 | ST7735_INVCTR , 1 , // 6: Display inversion ctrl, 1 arg, no delay: 604 | 0x07, // No inversion 605 | ST7735_PWCTR1 , 3 , // 7: Power control, 3 args, no delay: 606 | 0xA2, 607 | 0x02, // -4.6V 608 | 0x84, // AUTO mode 609 | ST7735_PWCTR2 , 1 , // 8: Power control, 1 arg, no delay: 610 | 0xC5, // VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD 611 | ST7735_PWCTR3 , 2 , // 9: Power control, 2 args, no delay: 612 | 0x0A, // Opamp current small 613 | 0x00, // Boost frequency 614 | ST7735_PWCTR4 , 2 , // 10: Power control, 2 args, no delay: 615 | 0x8A, // BCLK/2, Opamp current small & Medium low 616 | 0x2A, 617 | ST7735_PWCTR5 , 2 , // 11: Power control, 2 args, no delay: 618 | 0x8A, 0xEE, 619 | ST7735_VMCTR1 , 1 , // 12: Power control, 1 arg, no delay: 620 | 0x0E, 621 | ST7735_INVOFF , 0 , // 13: Don't invert display, no args, no delay 622 | ST7735_MADCTL , 1 , // 14: Memory access control (directions), 1 arg: 623 | 0xC8, // row addr/col addr, bottom to top refresh 624 | ST7735_COLMOD , 1 , // 15: set color mode, 1 arg, no delay: 625 | 0x05 // 16-bit color 626 | }; 627 | // ST7735R with a few types denoted by "tab type" (color of tab on LCD cover sheet) and 144 for 1.44" LCD 628 | commandList(Rcmd1); 629 | if (ST7735_CHIPSET == ST7735_INITR_GREENTAB) 630 | { 631 | static const uint8_t PROGMEM Rcmd2green[] = // ==== Init for 7735R, part 2 (green tab only) 632 | { 633 | 2, // 2 commands in list: 634 | ST7735_CASET , 4 , // 1: Column addr set, 4 args, no delay: 635 | 0x00, 0x02, // XSTART = 0 636 | 0x00, 0x7F+0x02, // XEND = 127 637 | ST7735_RASET , 4 , // 2: Row addr set, 4 args, no delay: 638 | 0x00, 0x01, // XSTART = 0 639 | 0x00, 0x9F+0x01 // XEND = 159 640 | }; 641 | commandList(Rcmd2green); 642 | } 643 | else if (ST7735_CHIPSET == ST7735_INITR_144GREENTAB) 644 | { 645 | static const uint8_t PROGMEM Rcmd2green144[] = // ==== Init for 7735R, part 2 (green 1.44 tab) 646 | { 647 | 2, // 2 commands in list: 648 | ST7735_CASET , 4 , // 1: Column addr set, 4 args, no delay: 649 | 0x00, 0x00, // XSTART = 0 650 | 0x00, 0x7F, // XEND = 127 651 | ST7735_RASET , 4 , // 2: Row addr set, 4 args, no delay: 652 | 0x00, 0x00, // XSTART = 0 653 | 0x00, 0x7F // XEND = 127 654 | }; 655 | _height = ST7735_TFTHEIGHT_144; 656 | commandList(Rcmd2green144); 657 | } 658 | else 659 | { 660 | static const uint8_t PROGMEM Rcmd2red[] = // Init for 7735R, part 2 (red tab only) 661 | { 662 | 2, // 2 commands in list: 663 | ST7735_CASET , 4 , // 1: Column addr set, 4 args, no delay: 664 | 0x00, 0x00, // XSTART = 0 665 | 0x00, 0x7F, // XEND = 127 666 | ST7735_RASET , 4 , // 2: Row addr set, 4 args, no delay: 667 | 0x00, 0x00, // XSTART = 0 668 | 0x00, 0x9F // XEND = 159 669 | }; 670 | commandList(Rcmd2red); 671 | } 672 | 673 | static const uint8_t PROGMEM Rcmd3[] = // ==== Init for 7735R, part 3 (red or green tab) 674 | { 675 | 4, // 4 commands in list: 676 | ST7735_GMCTRP1, 16 , // 1: Magical unicorn dust, 16 args, no delay: 677 | #if 0 // Adafruit or alternate gamma settings... 678 | 0x02, 0x1c, 0x07, 0x12, 679 | 0x37, 0x32, 0x29, 0x2d, 680 | 0x29, 0x25, 0x2B, 0x39, 681 | 0x00, 0x01, 0x03, 0x10, 682 | #else 683 | 0x0f, 0x1a, 0x0f, 0x18, 684 | 0x2f, 0x28, 0x20, 0x22, 685 | 0x1f, 0x1b, 0x23, 0x37, 686 | 0x00, 0x07, 0x02, 0x10, 687 | #endif 688 | ST7735_GMCTRN1, 16 , // 2: Sparkles and rainbows, 16 args, no delay: 689 | #if 0 // Adafruit or alternate gamma settings... 690 | 0x03, 0x1d, 0x07, 0x06, 691 | 0x2E, 0x2C, 0x29, 0x2D, 692 | 0x2E, 0x2E, 0x37, 0x3F, 693 | 0x00, 0x00, 0x02, 0x10, 694 | #else 695 | 0x0f, 0x1b, 0x0f, 0x17, 696 | 0x33, 0x2c, 0x29, 0x2e, 697 | 0x30, 0x30, 0x39, 0x3f, 698 | 0x00, 0x07, 0x03, 0x10, 699 | #endif 700 | ST7735_NORON , DELAY, // 3: Normal display on, no args, w/delay 701 | 10, // 10 ms delay 702 | ST7735_DISPON , DELAY, // 4: Main screen turn on, no args w/delay 703 | 100 // 100 ms delay 704 | }; 705 | 706 | commandList(Rcmd3); 707 | if (ST7735_CHIPSET == ST7735_INITR_BLACKTAB) 708 | { 709 | // ST7735S has a few differences 710 | writeCommand(ST7735_MADCTL); 711 | writeData(ST7735_MADCTL_MX | ST7735_MADCTL_MY | ST7735_MADCTL_RGB); 712 | } 713 | } 714 | 715 | spi_end(); 716 | } 717 | 718 | void PDQ_ST7735::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) 719 | { 720 | spi_begin(); 721 | 722 | setAddrWindow_(x0, y0, x1, y1); 723 | 724 | spi_end(); 725 | } 726 | 727 | void PDQ_ST7735::pushColor(uint16_t color) 728 | { 729 | spi_begin(); 730 | 731 | spiWrite16_preCmd(color); 732 | 733 | spi_end(); 734 | } 735 | 736 | void PDQ_ST7735::pushColor(uint16_t color, int16_t count) 737 | { 738 | spi_begin(); 739 | 740 | spiWrite16(color, count); 741 | 742 | spi_end(); 743 | } 744 | 745 | void PDQ_ST7735::drawPixel(int16_t x, int16_t y, uint16_t color) 746 | { 747 | if ((x < 0) ||(x >= _width) || (y < 0) || (y >= _height)) 748 | return; 749 | 750 | spi_begin(); 751 | 752 | setAddrWindow_(x, y, x, y); 753 | 754 | spiWrite16_preCmd(color); 755 | 756 | spi_end(); 757 | } 758 | 759 | void PDQ_ST7735::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) 760 | { 761 | // clipping 762 | if ((x < 0) || (x >= _width) || (y >= _height)) 763 | return; 764 | 765 | if (y < 0) 766 | { 767 | h += y; 768 | y = 0; 769 | } 770 | 771 | int y1 = y+h; 772 | 773 | if (y1 < 0) 774 | return; 775 | 776 | if (y1 > _height) 777 | h = _height-y; 778 | 779 | spi_begin(); 780 | 781 | setAddrWindow_(x, y, x, _height); 782 | spiWrite16(color, h); 783 | 784 | spi_end(); 785 | } 786 | 787 | 788 | void PDQ_ST7735::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) 789 | { 790 | // clipping 791 | if ((x >= _width) || (y < 0) || (y >= _height)) 792 | return; 793 | 794 | if (x < 0) 795 | { 796 | w += x; 797 | x = 0; 798 | } 799 | 800 | int x1 = x+w; 801 | 802 | if (x1 < 0) 803 | return; 804 | 805 | if (x1 > _width) 806 | w = _width-w; 807 | 808 | spi_begin(); 809 | 810 | setAddrWindow_(x, y, _width, y); 811 | spiWrite16(color, w); 812 | 813 | spi_end(); 814 | } 815 | 816 | void PDQ_ST7735::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) 817 | { 818 | // rudimentary clipping (drawChar w/big text requires this) 819 | if ((x >= _width) || (y >= _height)) 820 | return; 821 | if (x < 0) 822 | { 823 | w += x; 824 | x = 0; 825 | } 826 | if (y < 0) 827 | { 828 | h += y; 829 | y = 0; 830 | } 831 | if ((x + w) > _width) 832 | w = _width - x; 833 | if ((y + h) > _height) 834 | h = _height - y; 835 | 836 | spi_begin(); 837 | 838 | setAddrWindow_(x, y, x+w-1, _height); 839 | 840 | for (; h > 0; h--) 841 | { 842 | spiWrite16(color, w); 843 | } 844 | 845 | spi_end(); 846 | } 847 | 848 | // Bresenham's algorithm - thx Wikipedia 849 | void PDQ_ST7735::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color) 850 | { 851 | int8_t steep = abs(y1 - y0) > abs(x1 - x0); 852 | if (steep) 853 | { 854 | swap(x0, y0); 855 | swap(x1, y1); 856 | } 857 | 858 | if (x0 > x1) 859 | { 860 | swap(x0, x1); 861 | swap(y0, y1); 862 | } 863 | 864 | if (x1 < 0) 865 | return; 866 | 867 | int16_t dx, dy; 868 | dx = x1 - x0; 869 | dy = abs(y1 - y0); 870 | 871 | int16_t err = dx / 2; 872 | int8_t ystep; 873 | 874 | if (y0 < y1) 875 | { 876 | ystep = 1; 877 | } 878 | else 879 | { 880 | ystep = -1; 881 | } 882 | 883 | uint8_t setaddr = 1; 884 | 885 | if (steep) // y increments every iteration (y0 is x-axis, and x0 is y-axis) 886 | { 887 | if (x1 >= _height) 888 | x1 = _height - 1; 889 | 890 | for (; x0 <= x1; x0++) 891 | { 892 | if ((x0 >= 0) && (y0 >= 0) && (y0 < _width)) 893 | break; 894 | 895 | err -= dy; 896 | if (err < 0) 897 | { 898 | err += dx; 899 | y0 += ystep; 900 | } 901 | } 902 | 903 | if (x0 > x1) 904 | return; 905 | 906 | spi_begin(); 907 | 908 | for (; x0 <= x1; x0++) 909 | { 910 | if (setaddr) 911 | { 912 | setAddrWindow_(y0, x0, y0, _height); 913 | setaddr = 0; 914 | } 915 | spiWrite16_lineDraw(color); 916 | err -= dy; 917 | if (err < 0) 918 | { 919 | y0 += ystep; 920 | if ((y0 < 0) || (y0 >= _width)) 921 | break; 922 | err += dx; 923 | setaddr = 1; 924 | } 925 | else 926 | { 927 | __asm__ __volatile__ 928 | ( 929 | " call _ZN10PDQ_ST77357delay10Ev\n" 930 | : : : 931 | ); 932 | } 933 | } 934 | } 935 | else // x increments every iteration (x0 is x-axis, and y0 is y-axis) 936 | { 937 | if (x1 >= _width) 938 | x1 = _width - 1; 939 | 940 | for (; x0 <= x1; x0++) 941 | { 942 | if ((x0 >= 0) && (y0 >= 0) && (y0 < _height)) 943 | break; 944 | 945 | err -= dy; 946 | if (err < 0) 947 | { 948 | err += dx; 949 | y0 += ystep; 950 | } 951 | } 952 | 953 | if (x0 > x1) 954 | return; 955 | 956 | spi_begin(); 957 | 958 | for (; x0 <= x1; x0++) 959 | { 960 | if (setaddr) 961 | { 962 | setAddrWindow_(x0, y0, _width, y0); 963 | setaddr = 0; 964 | } 965 | spiWrite16_lineDraw(color); 966 | err -= dy; 967 | if (err < 0) 968 | { 969 | y0 += ystep; 970 | if ((y0 < 0) || (y0 >= _height)) 971 | break; 972 | err += dx; 973 | setaddr = 1; 974 | } 975 | else 976 | { 977 | __asm__ __volatile__ 978 | ( 979 | " call _ZN10PDQ_ST77357delay10Ev\n" 980 | : : : 981 | ); 982 | } 983 | } 984 | } 985 | 986 | spi_end(); 987 | } 988 | 989 | void PDQ_ST7735::setRotation(uint8_t m) 990 | { 991 | rotation = (m & 3); // can't be higher than 3 992 | 993 | spi_begin(); 994 | 995 | writeCommand(ST7735_MADCTL); 996 | 997 | switch (rotation) 998 | { 999 | default: 1000 | case 0: 1001 | if (ST7735_CHIPSET == ST7735_INITR_BLACKTAB) 1002 | writeData(ST7735_MADCTL_MX | ST7735_MADCTL_MY | ST7735_MADCTL_RGB); 1003 | else 1004 | writeData(ST7735_MADCTL_MX | ST7735_MADCTL_MY | ST7735_MADCTL_BGR); 1005 | _width = ST7735_TFTWIDTH; 1006 | if (ST7735_CHIPSET == ST7735_INITR_144GREENTAB) 1007 | _height = ST7735_TFTHEIGHT_144; 1008 | else 1009 | _height = ST7735_TFTHEIGHT_18; 1010 | 1011 | break; 1012 | case 1: 1013 | if (ST7735_CHIPSET == ST7735_INITR_BLACKTAB) 1014 | writeData(ST7735_MADCTL_MY | ST7735_MADCTL_MV | ST7735_MADCTL_RGB); 1015 | else 1016 | writeData(ST7735_MADCTL_MY | ST7735_MADCTL_MV | ST7735_MADCTL_BGR); 1017 | if (ST7735_CHIPSET == ST7735_INITR_144GREENTAB) 1018 | _width = ST7735_TFTHEIGHT_144; 1019 | else 1020 | _width = ST7735_TFTHEIGHT_18; 1021 | _height = ST7735_TFTWIDTH; 1022 | break; 1023 | case 2: 1024 | if (ST7735_CHIPSET == ST7735_INITR_BLACKTAB) 1025 | writeData(ST7735_MADCTL_RGB); 1026 | else 1027 | writeData(ST7735_MADCTL_BGR); 1028 | _width = ST7735_TFTWIDTH; 1029 | if (ST7735_CHIPSET == ST7735_INITR_144GREENTAB) 1030 | _height = ST7735_TFTHEIGHT_144; 1031 | else 1032 | _height = ST7735_TFTHEIGHT_18; 1033 | break; 1034 | case 3: 1035 | if (ST7735_CHIPSET == ST7735_INITR_BLACKTAB) 1036 | writeData(ST7735_MADCTL_MX | ST7735_MADCTL_MV | ST7735_MADCTL_RGB); 1037 | else 1038 | writeData(ST7735_MADCTL_MX | ST7735_MADCTL_MV | ST7735_MADCTL_BGR); 1039 | if (ST7735_CHIPSET == ST7735_INITR_144GREENTAB) 1040 | _width = ST7735_TFTHEIGHT_144; 1041 | else 1042 | _width = ST7735_TFTHEIGHT_18; 1043 | _height = ST7735_TFTWIDTH; 1044 | break; 1045 | } 1046 | 1047 | spi_end(); 1048 | } 1049 | 1050 | void PDQ_ST7735::invertDisplay(boolean i) 1051 | { 1052 | spi_begin(); 1053 | 1054 | writeCommand(i ? ST7735_INVON : ST7735_INVOFF); 1055 | 1056 | spi_end(); 1057 | } 1058 | 1059 | #endif // !defined(_PDQ_ST7735H_) 1060 | -------------------------------------------------------------------------------- /Ada_ATMega1284_LCD_PQD/PDQ_ST7735_config.h: -------------------------------------------------------------------------------- 1 | // 2 | // PDQ_ST7735 configuration 3 | // 4 | // You need to include this file above #include "PDQ_ILI9340.h" in your sketch. 5 | // Check settings on lines marked with "<=". 6 | 7 | // ST7735 has several variations, set your version based on this list (using the color of the "tab" on the screen cover). 8 | // NOTE: The tab colors refer to Adafruit versions, other suppliers may vary (you may have to experiment to find the right one). 9 | enum 10 | { 11 | ST7735_INITB = 0, // 1.8" (128x160) ST7735B chipset (only one type) 12 | ST7735_INITR_GREENTAB = 1, // 1.8" (128x160) ST7735R chipset with green tab (same as ST7735_INITR_18GREENTAB) 13 | ST7735_INITR_REDTAB = 2, // 1.8" (128x160) ST7735R chipset with red tab (same as ST7735_INITR_18REDTAB) 14 | ST7735_INITR_BLACKTAB = 3, // 1.8" (128x160) ST7735S chipset with black tab (same as ST7735_INITR_18BLACKTAB) 15 | ST7735_INITR_144GREENTAB = 4, // 1.4" (128x128) ST7735R chipset with green tab 16 | ST7735_INITR_18GREENTAB = ST7735_INITR_GREENTAB, // 1.8" (128x160) ST7735R chipset with green tab 17 | ST7735_INITR_18REDTAB = ST7735_INITR_REDTAB, // 1.8" (128x160) ST7735R chipset with red tab 18 | ST7735_INITR_18BLACKTAB = ST7735_INITR_BLACKTAB, // 1.8" (128x160) ST7735S chipset with black tab 19 | }; 20 | 21 | #define ST7735_CHIPSET ST7735_INITR_BLACKTAB // <= Set ST7735 LCD chipset/variation here (from above list) 22 | 23 | // NOTE: These are typical hookups individual boards will vary, please check your documentation. 24 | // CAUTION: While Adafruit boards generally always come with needed level-converters, I find many 25 | // other LCD displays advertised as supporting 5V only support 5V power (with a regulator). 26 | // They still only have 3.3V safe logic (CS, DC, RESET, MOSI, SCK marked with * below). 27 | // If this is the case you will need a voltage level-converter (e.g., HC4050, divider circuit etc.). 28 | // 29 | // LCD PIN Uno (328) Leo (32u4) 644/1284 30 | // ------- --------- ---------- -------- 31 | // 1 VCC 3.3V/5V 3.3V/5V 3.3V/5V // +3.3V or 5V with on-board regulator 32 | // 2 GND GND GND GND 33 | // 3* CS 10 10 4 // Could be any GPIO pin, but then need to make sure SS isn't a LOW input (or slave SPI mode) 34 | // 4* RESET 3.3V/5V 3.3V/5V 3.3V/5V // This relies on soft-reset. You can also use Arduino reset pin (if correct voltage). 35 | // 5* DC/RS 9 9 3 // Could be any GPIO pin 36 | // 6* SDI/MOSI 11 ICSP4 5 // HW SPI pin (can't change) 37 | // 7* SCK 13 ICSP3 7 // HW SPI pin (can't change) NOTE: On Uno this causes on-board LED to flicker during SPI use 38 | // 8* LED 3.3V/5V 3.3V/5V 3.3V/5V // LCD screen blanked when LOW (could use GPIO for PWM dimming) 39 | // 9 SDO/MISO - - - // (not used if present, LCD code is currently "write only") 40 | // 41 | // * = Typically only 3.3V safe logic-line (unless board has level converter [ala Adafruit]). Be careful with 5V! 42 | 43 | #define ST7735_CS_PIN 18 // <= /CS pin (chip-select, LOW to get attention of ST7735, HIGH and it ignores SPI bus) 44 | #define ST7735_DC_PIN 19 // <= DC pin (1=data or 0=command indicator line) also called RS 45 | // 644/1284 #define ST7735_CS_PIN 4 // <= /CS pin (chip-select, LOW to get attention of ST7735, HIGH and it ignores SPI bus) 46 | // 644/1284 #define ST7735_DC_PIN 3 // <= DC pin (1=data or 0=command indicator line) also called RS 47 | // (other pins used are dictated by AVR HW SPI used as shown above) 48 | 49 | // other PDQ library options 50 | #define ST7735_SAVE_SPCR 0 // <= 0/1 with 1 to save/restore AVR SPI control register (to "play nice" when other SPI use) 51 | -------------------------------------------------------------------------------- /Apple_one_OLED17/Apple_one_OLED17.ino: -------------------------------------------------------------------------------- 1 | // 12.01.2015 (c) P.Sieg simple Apple 1 emulator based on arduino_6502 2 | // project from miker00lz (Mike Chambers) 3 | // Link: http://forum.arduino.cc/index.php?topic=193216.0 4 | // apple 1 roms are (c) Steve Wozniak / Apple Inc. Status is Freeware 5 | // according to: http://www.callapple.org/soft/ap1/emul.html 6 | // a1 assembler (c) 9/2006 San Bergmans released as freeware 7 | // Link: http://www.sbprojects.com 8 | // My code released under GNU GPL V2 9 | 10 | // HIGH = apple integer basic at 0xE000 11 | // LOW = a1 assembler at 0xE000 12 | 13 | // OLED flame buffer added Mar. 29, 2015 kodera2t 14 | // cpu.c is un-touched. 15 | // April 5, 2015, cpu.c is modified for Arduino IDE 1.7.0 16 | //////////////// Newly added for graphic OLED(LCD) 128x64 support///////////// 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | // SPI PIN definition. Change to fit your board.... 23 | #define OLED_MOSI 5 24 | #define OLED_CLK 7 25 | #define OLED_DC 19 26 | #define OLED_CS 18 27 | #define OLED_RESET 20 28 | Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); 29 | 30 | 31 | int screenMem[168]; //the implementation of frame buffer is referenced from Ben Heck's 32 | int cursorX = 0; //Retro BASIC computer's source 33 | int checkChar = 0; 34 | static const unsigned char initmsg[] PROGMEM = "tiny apple 1"; 35 | ////////////////////////////////////////////////////////////////////////////// 36 | //////////////////////////////////////////////////////////////////////////////// 37 | // ASCII Characters 38 | #define CR '\r' 39 | #define NL '\n' 40 | #define LF 0x0a 41 | #define TAB '\t' 42 | #define BELL '\b' 43 | #define SPACE ' ' 44 | #define SQUOTE '\'' 45 | #define DQUOTE '\"' 46 | #define CTRLC 0x1B // Changed to ESC key (27 - 0x1B) 47 | #define CTRLH 0x08 48 | #define CTRLS 0x13 49 | #define CTRLX 0x18 50 | 51 | ////////////////////////////////////////////////////////////////////// 52 | 53 | // 54 | #define e0_pin 2 55 | 56 | uint8_t curkey = 0; 57 | uint8_t iskey = 0; 58 | uint8_t e0_bas = 1; 59 | 60 | extern "C" { 61 | uint16_t getpc(); 62 | uint8_t getop(); 63 | void exec6502(int32_t tickcount); 64 | void reset6502(); 65 | void serout(uint8_t val) { 66 | //Serial.print(val, HEX); 67 | //Serial.println(); 68 | // Serial.write(val); 69 | outchar(val); 70 | } 71 | uint8_t isakey() { 72 | if (Serial.available()) iskey = 0x80; 73 | else iskey = 0; 74 | return(iskey); 75 | } 76 | uint8_t getkey() { 77 | //curkey = Serial.read() & 0x7F; 78 | curkey = Serial.read(); 79 | // make a-z => A-Z 80 | if(curkey !=0x00){ 81 | if ((curkey >= 97) && (curkey <= 122)) curkey = curkey - 0x20; 82 | return(curkey); 83 | } 84 | } 85 | void clearkey() { 86 | curkey = 0; 87 | } 88 | void printhex(uint16_t val) { 89 | // Serial.print(val, HEX); 90 | // Serial.println(); 91 | outchar(val); 92 | } 93 | uint8_t get_e0_bas() { 94 | return(e0_bas); 95 | } 96 | } 97 | 98 | void setup () { 99 | pinMode(e0_pin,INPUT); 100 | digitalWrite(e0_pin,HIGH); //pullup on 101 | delay(100); 102 | e0_bas = digitalRead(e0_pin); 103 | Serial.begin (4800); 104 | 105 | //Serial.println("apple 1 emulator"); 106 | //Serial.println (); 107 | 108 | reset6502(); 109 | ////////added OLED part///// 110 | display.begin(); 111 | // init done 112 | display.display(); 113 | display.clearDisplay(); 114 | display.setTextSize(1); 115 | display.setTextColor(WHITE); 116 | display.setCursor(0,0); 117 | for (int xg = 0 ; xg < 169 ; xg++) { 118 | screenMem[xg] = 32; 119 | } 120 | // setOutputHandler(&lcdChar); 121 | printmsg(initmsg); 122 | doFrame(147); 123 | printmsg(initmsg); 124 | 125 | 126 | } 127 | 128 | void loop () { 129 | exec6502(100); //if timing is enabled, this value is in 6502 clock ticks. otherwise, simply instruction count. 130 | } 131 | 132 | 133 | static void outchar(unsigned char c) 134 | { 135 | lcdChar(c); 136 | } 137 | 138 | static void lcdChar(byte c) { 139 | 140 | if (c == 8) { //Backspace? 141 | 142 | if (cursorX > 0) { 143 | 144 | cursorX -= 1; 145 | screenMem[147 + cursorX] = 32; 146 | doFrame(147 + cursorX); 147 | 148 | } 149 | 150 | } 151 | 152 | if (c != 13 and c != 10 and c != 8) { 153 | 154 | screenMem[147 + cursorX] = c; 155 | cursorX += 1; 156 | if (cursorX < 21) { 157 | display.setCursor(cursorX*6,8*7); 158 | display.write(c); 159 | display.display(); 160 | } 161 | 162 | } 163 | 164 | if (cursorX == 21 or c == 10 or c == 13) { 165 | 166 | for (int xg = 21 ; xg > 0 ; xg--) { 167 | 168 | screenMem[0 + xg] = screenMem[21 + xg]; 169 | screenMem[21 + xg] = screenMem[42 + xg]; 170 | screenMem[42 + xg] = screenMem[63 + xg]; 171 | screenMem[63 + xg] = screenMem[84 + xg]; 172 | screenMem[84 + xg] = screenMem[105 + xg]; 173 | screenMem[105 + xg] = screenMem[126 + xg]; 174 | screenMem[126 + xg] = screenMem[147 + xg]; 175 | 176 | 177 | 178 | screenMem[147 + xg] = 32; 179 | 180 | 181 | } 182 | 183 | cursorX = 0; 184 | 185 | doFrame(147); 186 | 187 | } 188 | 189 | 190 | } 191 | 192 | static void doFrame(byte amount) { 193 | int xposi,yposi,yshift; 194 | display.clearDisplay(); 195 | for (int xg = 0 ; xg < amount ; xg++) { 196 | yshift=int(xg/21.0); 197 | yposi=yshift*8; 198 | xposi=(xg-yshift*21)*6; 199 | display.setCursor(xposi,yposi); 200 | display.write(screenMem[xg]); 201 | } 202 | display.display(); 203 | } 204 | 205 | /***************************************************************************/ 206 | void printmsgNoNL(const unsigned char *msg) 207 | { 208 | while( pgm_read_byte( msg ) != 0 ) { 209 | outchar( pgm_read_byte( msg++ ) ); 210 | }; 211 | } 212 | 213 | /***************************************************************************/ 214 | void printmsg(const unsigned char *msg) 215 | { 216 | printmsgNoNL(msg); 217 | line_terminator(); 218 | } 219 | 220 | static void line_terminator(void) 221 | { 222 | outchar(NL); 223 | outchar(CR); 224 | } 225 | -------------------------------------------------------------------------------- /Kanji_clock1.ino: -------------------------------------------------------------------------------- 1 | // Kanji Clock with OLED display 2 | // (c) kodera2t June 14 2015 3 | // Referenced website: http://tronixstuff.com/2013/08/13/tutorial-arduino-and-pcf8563-real-time-clock-ic/ 4 | //Example 54.1 - PCF2129 RTC write/read demonstration 5 | #include 6 | #include "Wire.h" 7 | #define PCF2129address 0xA2>>1 8 | #include 9 | #include 10 | #include 11 | #define ASC8x16S 255968 12 | #define ASC8x16N 257504 13 | #define kanji_CS 4 14 | byte rawdata[32]; 15 | int i=0; 16 | int toneflag=0; 17 | byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; 18 | String days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; 19 | 20 | // SPI PIN definition. Change to fit your board.... 21 | #define OLED_MOSI 5 22 | #define OLED_CLK 7 23 | #define OLED_DC 19 24 | #define OLED_CS 18 25 | #define OLED_RESET 22 ///v3:22, v2:20 26 | //Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); 27 | Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS); 28 | 29 | #include 30 | Tone tone1; 31 | #define piezo 14 32 | #define OCTAVE_OFFSET 0 33 | #define isdigit(n) (n >= '0' && n <= '9') 34 | int notes[] = { 0, 35 | NOTE_C4, NOTE_CS4, NOTE_D4, NOTE_DS4, NOTE_E4, NOTE_F4, NOTE_FS4, NOTE_G4, NOTE_GS4, NOTE_A4, NOTE_AS4, NOTE_B4, 36 | NOTE_C5, NOTE_CS5, NOTE_D5, NOTE_DS5, NOTE_E5, NOTE_F5, NOTE_FS5, NOTE_G5, NOTE_GS5, NOTE_A5, NOTE_AS5, NOTE_B5, 37 | NOTE_C6, NOTE_CS6, NOTE_D6, NOTE_DS6, NOTE_E6, NOTE_F6, NOTE_FS6, NOTE_G6, NOTE_GS6, NOTE_A6, NOTE_AS6, NOTE_B6, 38 | NOTE_C7, NOTE_CS7, NOTE_D7, NOTE_DS7, NOTE_E7, NOTE_F7, NOTE_FS7, NOTE_G7, NOTE_GS7, NOTE_A7, NOTE_AS7, NOTE_B7 39 | }; 40 | 41 | ////// copy-pasted from Arduino Tone library RTTTL sample////// 42 | char *song1 = "The Simpsons:d=4,o=5,b=160:c.6,e6,f#6,8a6,g.6,e6,c6,8a,8f#,8f#,8f#,2g,8p,8p,8f#,8f#,8f#,8g,a#.,8c6,8c6,8c6,c6"; 43 | char *song2 = "Indiana:d=4,o=5,b=250:e,8p,8f,8g,8p,1c6,8p.,d,8p,8e,1f,p.,g,8p,8a,8b,8p,1f6,p,a,8p,8b,2c6,2d6,2e6,e,8p,8f,8g,8p,1c6,p,d6,8p,8e6,1f.6,g,8p,8g,e.6,8p,d6,8p,8g,e.6,8p,d6,8p,8g,f.6,8p,e6,8p,8d6,2c6"; 44 | char *song3 = "TakeOnMe:d=4,o=4,b=160:8f#5,8f#5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8p,8f#5,8p,8f#5,8p,8f#5,8e5,8e5,8f#5,8e5,8f#5,8f#5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8p,8f#5,8p,8f#5,8p,8f#5,8e5,8e5"; 45 | char *song4 = "Entertainer:d=4,o=5,b=140:8d,8d#,8e,c6,8e,c6,8e,2c.6,8c6,8d6,8d#6,8e6,8c6,8d6,e6,8b,d6,2c6,p,8d,8d#,8e,c6,8e,c6,8e,2c.6,8p,8a,8g,8f#,8a,8c6,e6,8d6,8c6,8a,2d6"; 46 | char *song9 = "Muppets:d=4,o=5,b=250:c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,8a,8p,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,8e,8p,8e,g,2p,c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,a,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,d,8d,c"; 47 | char *song8 = "Xfiles:d=4,o=5,b=125:e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,g6,f#6,e6,d6,e6,2b.,1p,g6,f#6,e6,d6,f#6,2b.,1p,e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,e6,2b."; 48 | char *song10 = "Looney:d=4,o=5,b=140:32p,c6,8f6,8e6,8d6,8c6,a.,8c6,8f6,8e6,8d6,8d#6,e.6,8e6,8e6,8c6,8d6,8c6,8e6,8c6,8d6,8a,8c6,8g,8a#,8a,8f"; 49 | char *song5 = "20thCenFox:d=16,o=5,b=140:b,8p,b,b,2b,p,c6,32p,b,32p,c6,32p,b,32p,c6,32p,b,8p,b,b,b,32p,b,32p,b,32p,b,32p,b,32p,b,32p,b,32p,g#,32p,a,32p,b,8p,b,b,2b,4p,8e,8g#,8b,1c#6,8f#,8a,8c#6,1e6,8a,8c#6,8e6,1e6,8b,8g#,8a,2b"; 50 | char *song11 = "Bond:d=4,o=5,b=80:32p,16c#6,32d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6,32e6,16e6,8e6,16d#6,16d#6,16d#6,16c#6,32d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6,32e6,16e6,8e6,16d#6,16d6,16c#6,16c#7,c.7,16g#6,16f#6,g#.6"; 51 | char *song0 = "MASH:d=8,o=5,b=140:4a,4g,f#,g,p,f#,p,g,p,f#,p,2e.,p,f#,e,4f#,e,f#,p,e,p,4d.,p,f#,4e,d,e,p,d,p,e,p,d,p,2c#.,p,d,c#,4d,c#,d,p,e,p,4f#,p,a,p,4b,a,b,p,a,p,b,p,2a.,4p,a,b,a,4b,a,b,p,2a.,a,4f#,a,b,p,d6,p,4e.6,d6,b,p,a,p,2b"; 52 | char *song6 = "StarWars:d=4,o=5,b=45:32p,32f#,32f#,32f#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#.6,32f#,32f#,32f#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#6"; 53 | //char *song = "GoodBad:d=4,o=5,b=56:32p,32a#,32d#6,32a#,32d#6,8a#.,16f#.,16g#.,d#,32a#,32d#6,32a#,32d#6,8a#.,16f#.,16g#.,c#6,32a#,32d#6,32a#,32d#6,8a#.,16f#.,32f.,32d#.,c#,32a#,32d#6,32a#,32d#6,8a#.,16g#.,d#"; 54 | //char *song = "TopGun:d=4,o=4,b=31:32p,16c#,16g#,16g#,32f#,32f,32f#,32f,16d#,16d#,32c#,32d#,16f,32d#,32f,16f#,32f,32c#,16f,d#,16c#,16g#,16g#,32f#,32f,32f#,32f,16d#,16d#,32c#,32d#,16f,32d#,32f,16f#,32f,32c#,g#"; 55 | //char *song = "A-Team:d=8,o=5,b=125:4d#6,a#,2d#6,16p,g#,4a#,4d#.,p,16g,16a#,d#6,a#,f6,2d#6,16p,c#.6,16c6,16a#,g#.,2a#"; 56 | //char *song = "Flinstones:d=4,o=5,b=40:32p,16f6,16a#,16a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c6,d6,16f6,16a#.,16a#6,32g6,16f6,16a#.,32f6,32f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c6,a#,16a6,16d.6,16a#6,32a6,32a6,32g6,32f#6,32a6,8g6,16g6,16c.6,32a6,32a6,32g6,32g6,32f6,32e6,32g6,8f6,16f6,16a#.,16a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,32f6,16a#6,16c7,8a#.6"; 57 | //char *song = "Jeopardy:d=4,o=6,b=125:c,f,c,f5,c,f,2c,c,f,c,f,a.,8g,8f,8e,8d,8c#,c,f,c,f5,c,f,2c,f.,8d,c,a#5,a5,g5,f5,p,d#,g#,d#,g#5,d#,g#,2d#,d#,g#,d#,g#,c.7,8a#,8g#,8g,8f,8e,d#,g#,d#,g#5,d#,g#,2d#,g#.,8f,d#,c#,c,p,a#5,p,g#.5,d#,g#"; 58 | //char *song = "Gadget:d=16,o=5,b=50:32d#,32f,32f#,32g#,a#,f#,a,f,g#,f#,32d#,32f,32f#,32g#,a#,d#6,4d6,32d#,32f,32f#,32g#,a#,f#,a,f,g#,f#,8d#"; 59 | //char *song = "Smurfs:d=32,o=5,b=200:4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8f#,p,8a#,p,4g#,4p,g#,p,a#,p,b,p,c6,p,4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8b,p,8f,p,4f#"; 60 | //char *song = "MahnaMahna:d=16,o=6,b=125:c#,c.,b5,8a#.5,8f.,4g#,a#,g.,4d#,8p,c#,c.,b5,8a#.5,8f.,g#.,8a#.,4g,8p,c#,c.,b5,8a#.5,8f.,4g#,f,g.,8d#.,f,g.,8d#.,f,8g,8d#.,f,8g,d#,8c,a#5,8d#.,8d#.,4d#,8d#."; 61 | //char *song = "LeisureSuit:d=16,o=6,b=56:f.5,f#.5,g.5,g#5,32a#5,f5,g#.5,a#.5,32f5,g#5,32a#5,g#5,8c#.,a#5,32c#,a5,a#.5,c#.,32a5,a#5,32c#,d#,8e,c#.,f.,f.,f.,f.,f,32e,d#,8d,a#.5,e,32f,e,32f,c#,d#.,c#"; 62 | char *song7 = "MissionImp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d"; 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | unsigned long calcAddr(unsigned short jiscode) { 75 | unsigned long MSB; 76 | unsigned long LSB; 77 | unsigned long Address; 78 | MSB = (jiscode >> 8) - 0x20; 79 | LSB = (jiscode & 0xff) -0x20; 80 | if(MSB >=1 && MSB <= 15 && LSB >=1 && LSB <= 94) 81 | Address =( (MSB - 1) * 94 + (LSB - 01))*32; 82 | else if(MSB >=16 && MSB <= 47 && LSB >=1 && LSB <= 94) 83 | Address =( (MSB - 16) * 94 + (LSB - 1))*32+43584; 84 | else if(MSB >=48 && MSB <=84 && LSB >=1 && LSB <= 94) 85 | Address = ((MSB - 48) * 94 + (LSB - 1))*32+ 138464; 86 | else if(MSB ==85 && LSB >=0x01 && LSB <= 94) 87 | Address = ((MSB - 85) * 94 + (LSB - 1))*32+ 246944; 88 | else if(MSB >=88 && MSB <=89 && LSB >=1 && LSB <= 94) 89 | Address = ((MSB - 88) * 94 + (LSB - 1))*32+ 249952; 90 | 91 | return Address; 92 | } 93 | 94 | void getCharData(unsigned short code) { 95 | byte data; 96 | unsigned long addr=0; 97 | byte n; 98 | addr =calcAddr(code); 99 | n = 32; 100 | digitalWrite(kanji_CS, HIGH); 101 | delayMicroseconds(4); 102 | digitalWrite(kanji_CS, LOW); 103 | SPI.transfer(0x03); 104 | SPI.transfer((addr>>16) & 0xff); 105 | SPI.transfer((addr>>8) & 0xff); 106 | SPI.transfer(addr & 0xff); 107 | for(byte i = 0;i< n; i++) { 108 | rawdata[i] = SPI.transfer(0x00); 109 | } 110 | digitalWrite(kanji_CS, HIGH); 111 | } 112 | 113 | void displayChar(unsigned short code, unsigned int offset_x,unsigned int offset_y) { 114 | offset_x=offset_x*16; 115 | offset_y=offset_y*16; 116 | getCharData(code); 117 | for(int x=0; x<32; x++) 118 | { 119 | for(int y=0; y<8; y++) 120 | { 121 | if (rawdata[x] & (1<>4)) + offset_y, WHITE); 123 | else 124 | display.drawPixel(x%16 + offset_x, y+(8*(x>>4)) + offset_y, BLACK); 125 | } 126 | } 127 | display.display(); 128 | } 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | byte bcdToDec(byte value) 137 | { 138 | return ((value / 16) * 10 + value % 16); 139 | } 140 | 141 | byte decToBcd(byte value){ 142 | return (value / 10 * 16 + value % 10); 143 | } 144 | 145 | void setPCF2129() 146 | // this sets the time and date to the PCF2129 147 | { 148 | Wire.beginTransmission(PCF2129address); 149 | Wire.write(0x03); 150 | Wire.write(decToBcd(second)); 151 | Wire.write(decToBcd(minute)); 152 | Wire.write(decToBcd(hour)); 153 | Wire.write(decToBcd(dayOfMonth)); 154 | Wire.write(decToBcd(dayOfWeek)); 155 | Wire.write(decToBcd(month)); 156 | Wire.write(decToBcd(year)); 157 | Wire.endTransmission(); 158 | } 159 | 160 | void readPCF2129() 161 | // this gets the time and date from the PCF2129 162 | { 163 | Wire.beginTransmission(PCF2129address); 164 | Wire.write(0x03); 165 | Wire.endTransmission(); 166 | Wire.requestFrom(PCF2129address, 7); 167 | second = bcdToDec(Wire.read() & B01111111); // remove VL error bit 168 | minute = bcdToDec(Wire.read() & B01111111); // remove unwanted bits from MSB 169 | hour = bcdToDec(Wire.read() & B00111111); 170 | dayOfMonth = bcdToDec(Wire.read() & B00111111); 171 | dayOfWeek = bcdToDec(Wire.read() & B00000111); 172 | month = bcdToDec(Wire.read() & B00011111); // remove century bit, 1999 is over 173 | year = bcdToDec(Wire.read()); 174 | } 175 | 176 | void setup() 177 | { 178 | tone1.begin(14); 179 | pinMode(kanji_CS,OUTPUT); 180 | digitalWrite(kanji_CS,HIGH); 181 | //pinMode(6, INPUT); 182 | SPI.begin(); 183 | display.begin(); 184 | display.display(); 185 | display.clearDisplay(); 186 | display.fillScreen(0); 187 | display.clearDisplay(); 188 | 189 | Wire.begin(); 190 | Serial.begin(4800); 191 | // change the following to set your initial time 192 | second = 30; 193 | minute = 45; 194 | hour = 17; 195 | dayOfWeek = 0; 196 | dayOfMonth = 14; 197 | month = 6; 198 | year = 15; 199 | // comment out the next line and upload again to set and keep the time from resetting every reset 200 | //if(year!=2015){ 201 | //setPCF2129(); 202 | //} 203 | 204 | } 205 | 206 | void loop() 207 | { 208 | int second2,second1; 209 | int minute2,minute1; 210 | int hour2,hour1; 211 | int month2,month1; 212 | int day2,day1; 213 | int wareki2,wareki1; 214 | int heisei; 215 | int tmpsec; 216 | int tmpday; 217 | int tmphour; 218 | 219 | readPCF2129(); 220 | 221 | 222 | 223 | 224 | if(second!=tmpsec){ 225 | second2=second/10; 226 | second1=second-second2*10; 227 | 228 | switch(second1){ 229 | case(0): 230 | displayChar(0x4E6D,6,3); 231 | break; 232 | case(1): 233 | displayChar(0x306C,6,3); 234 | break; 235 | case(2): 236 | displayChar(0x4673,6,3); 237 | break; 238 | case(3): 239 | displayChar(0x3B30,6,3); 240 | break; 241 | case(4): 242 | displayChar(0x3B4D,6,3); 243 | break; 244 | case(5): 245 | displayChar(0x385E,6,3); 246 | break; 247 | case(6): 248 | displayChar(0x4F3B,6,3); 249 | break; 250 | case(7): 251 | displayChar(0x3C37,6,3); 252 | break; 253 | case(8): 254 | displayChar(0x482C,6,3); 255 | break; 256 | case(9): 257 | displayChar(0x3665,6,3); 258 | break; 259 | } 260 | 261 | switch(second2){ 262 | case(0): 263 | displayChar(0x2121,4,3); 264 | displayChar(0x2121,5,3); 265 | break; 266 | case(1): 267 | displayChar(0x2121,4,3); 268 | displayChar(0x3D3D,5,3); 269 | break; 270 | case(2): 271 | displayChar(0x4673,4,3); 272 | displayChar(0x3D3D,5,3); 273 | break; 274 | case(3): 275 | displayChar(0x3B30,4,3); 276 | displayChar(0x3D3D,5,3); 277 | break; 278 | case(4): 279 | displayChar(0x3B4D,4,3); 280 | displayChar(0x3D3D,5,3); 281 | break; 282 | case(5): 283 | displayChar(0x385E,4,3); 284 | displayChar(0x3D3D,5,3); 285 | break; 286 | } 287 | 288 | 289 | 290 | displayChar(0x4943,7,3); 291 | 292 | 293 | minute2=minute/10; 294 | minute1=minute-minute2*10; 295 | 296 | switch(minute1){ 297 | case(0): 298 | displayChar(0x4E6D,6,2); 299 | break; 300 | case(1): 301 | displayChar(0x306C,6,2); 302 | break; 303 | case(2): 304 | displayChar(0x4673,6,2); 305 | break; 306 | case(3): 307 | displayChar(0x3B30,6,2); 308 | break; 309 | case(4): 310 | displayChar(0x3B4D,6,2); 311 | break; 312 | case(5): 313 | displayChar(0x385E,6,2); 314 | break; 315 | case(6): 316 | displayChar(0x4F3B,6,2); 317 | break; 318 | case(7): 319 | displayChar(0x3C37,6,2); 320 | break; 321 | case(8): 322 | displayChar(0x482C,6,2); 323 | break; 324 | case(9): 325 | displayChar(0x3665,6,2); 326 | break; 327 | } 328 | 329 | switch(minute2){ 330 | case(0): 331 | displayChar(0x2121,4,2); 332 | displayChar(0x2121,5,2); 333 | break; 334 | case(1): 335 | displayChar(0x2121,4,2); 336 | displayChar(0x3D3D,5,2); 337 | break; 338 | case(2): 339 | displayChar(0x4673,4,2); 340 | displayChar(0x3D3D,5,2); 341 | break; 342 | case(3): 343 | displayChar(0x3B30,4,2); 344 | displayChar(0x3D3D,5,2); 345 | break; 346 | case(4): 347 | displayChar(0x3B4D,4,2); 348 | displayChar(0x3D3D,5,2); 349 | break; 350 | case(5): 351 | displayChar(0x385E,4,2); 352 | displayChar(0x3D3D,5,2); 353 | break; 354 | } 355 | displayChar(0x4A2C,7,2); 356 | 357 | 358 | 359 | hour2=hour/10; 360 | hour1=hour-hour2*10; 361 | 362 | switch(hour1){ 363 | case(0): 364 | displayChar(0x4E6D,2,2); 365 | break; 366 | case(1): 367 | displayChar(0x306C,2,2); 368 | break; 369 | case(2): 370 | displayChar(0x4673,2,2); 371 | break; 372 | case(3): 373 | displayChar(0x3B30,2,2); 374 | break; 375 | case(4): 376 | displayChar(0x3B4D,2,2); 377 | break; 378 | case(5): 379 | displayChar(0x385E,2,2); 380 | break; 381 | case(6): 382 | displayChar(0x4F3B,2,2); 383 | break; 384 | case(7): 385 | displayChar(0x3C37,2,2); 386 | break; 387 | case(8): 388 | displayChar(0x482C,2,2); 389 | break; 390 | case(9): 391 | displayChar(0x3665,2,2); 392 | break; 393 | } 394 | 395 | switch(hour2){ 396 | case(0): 397 | displayChar(0x2121,0,2); 398 | displayChar(0x2121,1,2); 399 | break; 400 | case(1): 401 | displayChar(0x2121,0,2); 402 | displayChar(0x3D3D,1,2); 403 | break; 404 | case(2): 405 | displayChar(0x4673,0,2); 406 | displayChar(0x3D3D,1,2); 407 | break; 408 | case(3): 409 | displayChar(0x3B30,0,2); 410 | displayChar(0x3D3D,1,2); 411 | break; 412 | case(4): 413 | displayChar(0x3B4D,0,2); 414 | displayChar(0x3D3D,1,2); 415 | break; 416 | case(5): 417 | displayChar(0x385E,0,2); 418 | displayChar(0x3D3D,1,2); 419 | break; 420 | } 421 | 422 | 423 | 424 | displayChar(0x3B7E,3,2); 425 | 426 | 427 | // if(tmpday!=dayOfMonth){ 428 | month2=month/10; 429 | month1=month-month2*10; 430 | 431 | switch(month1){ 432 | case(0): 433 | displayChar(0x4E6D,2,1); 434 | break; 435 | case(1): 436 | displayChar(0x306C,2,1); 437 | break; 438 | case(2): 439 | displayChar(0x4673,2,1); 440 | break; 441 | case(3): 442 | displayChar(0x3B30,2,1); 443 | break; 444 | case(4): 445 | displayChar(0x3B4D,2,1); 446 | break; 447 | case(5): 448 | displayChar(0x385E,2,1); 449 | break; 450 | case(6): 451 | displayChar(0x4F3B,2,1); 452 | break; 453 | case(7): 454 | displayChar(0x3C37,2,1); 455 | break; 456 | case(8): 457 | displayChar(0x482C,2,1); 458 | break; 459 | case(9): 460 | displayChar(0x3665,2,1); 461 | break; 462 | } 463 | 464 | switch(month2){ 465 | case(0): 466 | displayChar(0x2121,0,1); 467 | displayChar(0x2121,1,1); 468 | break; 469 | case(1): 470 | displayChar(0x2121,0,1); 471 | displayChar(0x3D3D,1,1); 472 | break; 473 | case(2): 474 | displayChar(0x4673,0,1); 475 | displayChar(0x3D3D,1,1); 476 | break; 477 | case(3): 478 | displayChar(0x3B30,0,1); 479 | displayChar(0x3D3D,1,1); 480 | break; 481 | case(4): 482 | displayChar(0x3B4D,0,1); 483 | displayChar(0x3D3D,1,1); 484 | break; 485 | case(5): 486 | displayChar(0x385E,0,1); 487 | displayChar(0x3D3D,1,1); 488 | break; 489 | } 490 | displayChar(0x376E,3,1); 491 | 492 | 493 | day2=dayOfMonth/10; 494 | day1=dayOfMonth-day2*10; 495 | 496 | switch(day1){ 497 | case(0): 498 | displayChar(0x4E6D,6,1); 499 | break; 500 | case(1): 501 | displayChar(0x306C,6,1); 502 | break; 503 | case(2): 504 | displayChar(0x4673,6,1); 505 | break; 506 | case(3): 507 | displayChar(0x3B30,6,1); 508 | break; 509 | case(4): 510 | displayChar(0x3B4D,6,1); 511 | break; 512 | case(5): 513 | displayChar(0x385E,6,1); 514 | break; 515 | case(6): 516 | displayChar(0x4F3B,6,1); 517 | break; 518 | case(7): 519 | displayChar(0x3C37,6,1); 520 | break; 521 | case(8): 522 | displayChar(0x482C,6,1); 523 | break; 524 | case(9): 525 | displayChar(0x3665,6,1); 526 | break; 527 | } 528 | 529 | switch(day2){ 530 | case(0): 531 | displayChar(0x2121,4,1); 532 | displayChar(0x2121,5,1); 533 | break; 534 | case(1): 535 | displayChar(0x2121,4,1); 536 | displayChar(0x3D3D,5,1); 537 | break; 538 | case(2): 539 | displayChar(0x4673,4,1); 540 | displayChar(0x3D3D,5,1); 541 | break; 542 | case(3): 543 | displayChar(0x3B30,4,1); 544 | displayChar(0x3D3D,5,1); 545 | break; 546 | } 547 | displayChar(0x467C,7,1); 548 | 549 | 550 | 551 | 552 | displayChar(0x4A3F,2,0); 553 | displayChar(0x402E,3,0); 554 | 555 | 556 | heisei=int(year)+12; 557 | wareki2=heisei/10; 558 | wareki1=heisei-wareki2*10; 559 | 560 | switch(wareki1){ 561 | case(0): 562 | displayChar(0x4E6D,6,0); 563 | break; 564 | case(1): 565 | displayChar(0x306C,6,0); 566 | break; 567 | case(2): 568 | displayChar(0x4673,6,0); 569 | break; 570 | case(3): 571 | displayChar(0x3B30,6,0); 572 | break; 573 | case(4): 574 | displayChar(0x3B4D,6,0); 575 | break; 576 | case(5): 577 | displayChar(0x385E,6,0); 578 | break; 579 | case(6): 580 | displayChar(0x4F3B,6,0); 581 | break; 582 | case(7): 583 | displayChar(0x3C37,6,0); 584 | break; 585 | case(8): 586 | displayChar(0x482C,6,0); 587 | break; 588 | case(9): 589 | displayChar(0x3665,6,0); 590 | break; 591 | 592 | } 593 | 594 | switch(wareki2){ 595 | case(0): 596 | displayChar(0x2121,4,0); 597 | displayChar(0x2121,5,0); 598 | break; 599 | case(1): 600 | displayChar(0x2121,4,0); 601 | displayChar(0x3D3D,5,0); 602 | break; 603 | case(2): 604 | displayChar(0x4673,4,0); 605 | displayChar(0x3D3D,5,0); 606 | break; 607 | case(3): 608 | displayChar(0x3B30,4,0); 609 | displayChar(0x3D3D,5,0); 610 | break; 611 | } 612 | displayChar(0x472F,7,0); 613 | 614 | 615 | switch(dayOfWeek){ 616 | case(0): 617 | displayChar(0x467C,0,3); 618 | displayChar(0x4D4B,1,3); 619 | break; 620 | case(1): 621 | displayChar(0x376E,0,3); 622 | displayChar(0x4D4B,1,3); 623 | break; 624 | case(2): 625 | displayChar(0x3250,0,3); 626 | displayChar(0x4D4B,1,3); 627 | break; 628 | case(3): 629 | displayChar(0x3F65,0,3); 630 | displayChar(0x4D4B,1,3); 631 | break; 632 | case(4): 633 | displayChar(0x4C5A,0,3); 634 | displayChar(0x4D4B,1,3); 635 | break; 636 | case(5): 637 | displayChar(0x3662,0,3); 638 | displayChar(0x4D4B,1,3); 639 | break; 640 | case(6): 641 | displayChar(0x467C,0,3); 642 | displayChar(0x455A,1,3); 643 | break; 644 | } 645 | // } 646 | } 647 | tmpsec=second; 648 | tmpday=dayOfMonth; 649 | 650 | if(minute==59){ 651 | toneflag=1; 652 | } 653 | 654 | if((toneflag==1)&&(minute==0)){ 655 | tmphour=hour-12; 656 | switch(tmphour){ 657 | case(0): 658 | play_rtttl(song0); 659 | toneflag=0; 660 | break; 661 | case(1): 662 | play_rtttl(song1); 663 | toneflag=0; 664 | break; 665 | case(2): 666 | play_rtttl(song2); 667 | toneflag=0; 668 | break; 669 | case(3): 670 | play_rtttl(song3); 671 | toneflag=0; 672 | break; 673 | case(4): 674 | play_rtttl(song4); 675 | toneflag=0; 676 | break; 677 | case(5): 678 | play_rtttl(song5); 679 | toneflag=0; 680 | break; 681 | case(6): 682 | play_rtttl(song6); 683 | toneflag=0; 684 | break; 685 | case(7): 686 | play_rtttl(song7); 687 | toneflag=0; 688 | break; 689 | case(8): 690 | play_rtttl(song8); 691 | toneflag=0; 692 | break; 693 | case(9): 694 | play_rtttl(song9); 695 | toneflag=0; 696 | break; 697 | case(10): 698 | play_rtttl(song10); 699 | toneflag=0; 700 | break; 701 | case(11): 702 | play_rtttl(song11); 703 | toneflag=0; 704 | break; 705 | 706 | } 707 | 708 | 709 | 710 | } 711 | 712 | 713 | 714 | 715 | 716 | } 717 | 718 | 719 | 720 | #define isdigit(n) (n >= '0' && n <= '9') 721 | void play_rtttl(char *p) 722 | { 723 | // Absolutely no error checking in here 724 | 725 | byte default_dur = 4; 726 | byte default_oct = 6; 727 | int bpm = 63; 728 | int num; 729 | long wholenote; 730 | long duration; 731 | byte note; 732 | byte scale; 733 | 734 | // format: d=N,o=N,b=NNN: 735 | // find the start (skip name, etc) 736 | 737 | while(*p != ':') p++; // ignore name 738 | p++; // skip ':' 739 | 740 | // get default duration 741 | if(*p == 'd') 742 | { 743 | p++; p++; // skip "d=" 744 | num = 0; 745 | while(isdigit(*p)) 746 | { 747 | num = (num * 10) + (*p++ - '0'); 748 | } 749 | if(num > 0) default_dur = num; 750 | p++; // skip comma 751 | } 752 | 753 | Serial.print("ddur: "); Serial.println(default_dur, 10); 754 | 755 | // get default octave 756 | if(*p == 'o') 757 | { 758 | p++; p++; // skip "o=" 759 | num = *p++ - '0'; 760 | if(num >= 3 && num <=7) default_oct = num; 761 | p++; // skip comma 762 | } 763 | 764 | Serial.print("doct: "); Serial.println(default_oct, 10); 765 | 766 | // get BPM 767 | if(*p == 'b') 768 | { 769 | p++; p++; // skip "b=" 770 | num = 0; 771 | while(isdigit(*p)) 772 | { 773 | num = (num * 10) + (*p++ - '0'); 774 | } 775 | bpm = num; 776 | p++; // skip colon 777 | } 778 | 779 | Serial.print("bpm: "); Serial.println(bpm, 10); 780 | 781 | // BPM usually expresses the number of quarter notes per minute 782 | wholenote = (60 * 1000L / bpm) * 4; // this is the time for whole note (in milliseconds) 783 | 784 | Serial.print("wn: "); Serial.println(wholenote, 10); 785 | 786 | 787 | // now begin note loop 788 | while(*p) 789 | { 790 | // first, get note duration, if available 791 | num = 0; 792 | while(isdigit(*p)) 793 | { 794 | num = (num * 10) + (*p++ - '0'); 795 | } 796 | 797 | if(num) duration = wholenote / num; 798 | else duration = wholenote / default_dur; // we will need to check if we are a dotted note after 799 | 800 | // now get the note 801 | note = 0; 802 | 803 | switch(*p) 804 | { 805 | case 'c': 806 | note = 1; 807 | break; 808 | case 'd': 809 | note = 3; 810 | break; 811 | case 'e': 812 | note = 5; 813 | break; 814 | case 'f': 815 | note = 6; 816 | break; 817 | case 'g': 818 | note = 8; 819 | break; 820 | case 'a': 821 | note = 10; 822 | break; 823 | case 'b': 824 | note = 12; 825 | break; 826 | case 'p': 827 | default: 828 | note = 0; 829 | } 830 | p++; 831 | 832 | // now, get optional '#' sharp 833 | if(*p == '#') 834 | { 835 | note++; 836 | p++; 837 | } 838 | 839 | // now, get optional '.' dotted note 840 | if(*p == '.') 841 | { 842 | duration += duration/2; 843 | p++; 844 | } 845 | 846 | // now, get scale 847 | if(isdigit(*p)) 848 | { 849 | scale = *p - '0'; 850 | p++; 851 | } 852 | else 853 | { 854 | scale = default_oct; 855 | } 856 | 857 | scale += OCTAVE_OFFSET; 858 | 859 | if(*p == ',') 860 | p++; // skip comma for next note (or we may be at the end) 861 | 862 | // now play the note 863 | 864 | if(note) 865 | { 866 | Serial.print("Playing: "); 867 | Serial.print(scale, 10); Serial.print(' '); 868 | Serial.print(note, 10); Serial.print(" ("); 869 | Serial.print(notes[(scale - 4) * 12 + note], 10); 870 | Serial.print(") "); 871 | Serial.println(duration, 10); 872 | tone1.play(notes[(scale - 4) * 12 + note]); 873 | delay(duration); 874 | tone1.stop(); 875 | } 876 | else 877 | { 878 | Serial.print("Pausing: "); 879 | Serial.println(duration, 10); 880 | delay(duration); 881 | } 882 | } 883 | } 884 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TinyBasicPlus_OLED_support 2 | ! PLEASE select LCD version if you are searching character LCD support for TinyBasicPlus!!, If you need graphic LCD support for TinyBasicPluse, please select OLED version. ! 3 | SSD1306 compatible OLED/LCD (128x64 dots) support is added to TinyBasicPlus, using Adafruit_GFX lib. 4 | Frame buffer for 21x8 characters is added for text display. Along this support, TVout and PS2 keyboard support is subtracted, assuming re-programmed Xbox360 or serial console usage for input device. (you can add PS/2, if you need) I refered the source code by Ben Heck's Retro Basic Computer. GRAPHIC related BASIC commands (currently supporting only direct command): CLS (clear screen), LINE x0,y0,x1,y1 CIRCLE x,y,radius FILLCIRCLE x,y,radius ROUNDRECT x,y,w,h,r FILLROUNDRECT x,y,w,h,r are added just for graphic test.. 5 | Not only Arduino sketch, also circuit schematic and circuit pattern (.brd) is uploaded for your quick test of OLED version. 6 | -------------------------------------------------------------------------------- /atmega1284p_v4_gerber/atmega1284_v4.drd: -------------------------------------------------------------------------------- 1 | % 2 | M48 3 | M72 4 | T01C0.0240 5 | T02C0.0276 6 | T03C0.0354 7 | T04C0.0400 8 | T05C0.0433 9 | T06C0.0591 10 | T07C0.0827 11 | % 12 | T01 13 | X11530Y14050 14 | X12250Y16210 15 | X12790Y17650 16 | X13060Y18460 17 | X12790Y19720 18 | X14500Y20440 19 | X14860Y19810 20 | X17920Y20710 21 | X18820Y21430 22 | X21700Y19900 23 | X21700Y18460 24 | X19630Y16120 25 | X20620Y15130 26 | X19990Y13960 27 | X17740Y16750 28 | X15490Y17020 29 | X10900Y18820 30 | X9910Y20350 31 | X10270Y20710 32 | X9550Y21520 33 | X9550Y22060 34 | X9100Y22330 35 | X8020Y21970 36 | X8740Y21250 37 | X11620Y21970 38 | T02 39 | X7100Y21050 40 | X7100Y20089 41 | X7100Y19150 42 | T03 43 | X20100Y16663 44 | X20100Y24537 45 | T04 46 | X14600Y23600 47 | X13600Y23600 48 | X12600Y23600 49 | X11600Y23600 50 | X10600Y23600 51 | X10100Y15100 52 | X11100Y15100 53 | X12100Y15100 54 | X13100Y15100 55 | X14100Y15100 56 | X15100Y15100 57 | X17600Y15100 58 | X18600Y15100 59 | X19600Y15100 60 | X27100Y17100 61 | X27100Y18100 62 | X27100Y19100 63 | X27100Y20100 64 | X27100Y21100 65 | X27100Y22100 66 | X7100Y15100 67 | X6100Y15100 68 | X5100Y15100 69 | X4100Y15100 70 | T05 71 | X5100Y17631 72 | X5100Y21569 73 | T06 74 | X22202Y23868 75 | T07 76 | X22202Y15600 77 | M30 78 | -------------------------------------------------------------------------------- /atmega1284p_v4_gerber/atmega1284_v4.dri: -------------------------------------------------------------------------------- 1 | Generated by EAGLE CAM Processor 7.1.0 2 | 3 | Drill Station Info File: /Users/kodera2t/Desktop/atmega1284_v4.dri 4 | 5 | Date : 6/11/15 09:59 6 | Drills : generated 7 | Device : Excellon drill station 8 | 9 | Parameter settings: 10 | 11 | Tolerance Drill + : 0.00 % 12 | Tolerance Drill - : 0.00 % 13 | Rotate : no 14 | Mirror : no 15 | Optimize : yes 16 | Auto fit : yes 17 | OffsetX : 0inch 18 | OffsetY : 0inch 19 | Layers : Drills Holes 20 | 21 | Drill File Info: 22 | 23 | Data Mode : Absolute 24 | Units : 1/10000 Inch 25 | 26 | Drills used: 27 | 28 | Code Size used 29 | 30 | T01 0.0240inch 25 31 | T02 0.0276inch 3 32 | T03 0.0354inch 2 33 | T04 0.0400inch 24 34 | T05 0.0433inch 2 35 | T06 0.0591inch 1 36 | T07 0.0827inch 1 37 | 38 | Total number of drills: 58 39 | 40 | Plotfiles: 41 | 42 | /Users/kodera2t/Desktop/atmega1284_v4.drd 43 | -------------------------------------------------------------------------------- /atmega1284p_v4_gerber/atmega1284_v4_bot.gpi: -------------------------------------------------------------------------------- 1 | Generated by EAGLE CAM Processor 7.1.0 2 | 3 | Photoplotter Info File: /Users/kodera2t/Desktop/atmega1284_v4_bot.gpi 4 | 5 | Date : 6/11/15 09:59 6 | Plotfile : /Users/kodera2t/Desktop/atmega1284_v4_bot.grb 7 | Apertures : generated: 8 | Device : Gerber RS-274-X photoplotter, coordinate format 2.4 inch 9 | 10 | Parameter settings: 11 | 12 | Emulate Apertures : no 13 | Tolerance Draw + : 0.00 % 14 | Tolerance Draw - : 0.00 % 15 | Tolerance Flash + : 0.00 % 16 | Tolerance Flash - : 0.00 % 17 | Rotate : no 18 | Mirror : no 19 | Optimize : yes 20 | Auto fit : yes 21 | OffsetX : 0inch 22 | OffsetY : 0inch 23 | 24 | Plotfile Info: 25 | 26 | Coordinate Format : 2.4 27 | Coordinate Units : Inch 28 | Data Mode : Absolute 29 | Zero Suppression : None 30 | End Of Block : * 31 | 32 | Apertures used: 33 | 34 | Code Shape Size used 35 | 36 | D10 draw 0.0600inch 24 37 | D11 round 0.0476inch 3 38 | D12 rectangle 0.0591inch x 0.0394inch 9 39 | D13 rectangle 0.0591inch x 0.0276inch 2 40 | D14 rectangle 0.1102inch x 0.0591inch 4 41 | D15 rectangle 0.0240inch x 0.0870inch 8 42 | D16 rectangle 0.0531inch x 0.0217inch 6 43 | D17 rectangle 0.0800inch x 0.0260inch 20 44 | D18 rectangle 0.0394inch x 0.0433inch 4 45 | D19 round 0.0554inch 2 46 | D20 round 0.0660inch 2 47 | D21 draw 0.0100inch 204 48 | D22 round 0.0400inch 25 49 | 50 | -------------------------------------------------------------------------------- /atmega1284p_v4_gerber/atmega1284_v4_bot.grb: -------------------------------------------------------------------------------- 1 | G75* 2 | %MOIN*% 3 | %OFA0B0*% 4 | %FSLAX24Y24*% 5 | %IPPOS*% 6 | %LPD*% 7 | %AMOC8* 8 | 5,1,8,0,0,1.08239X$1,22.5* 9 | % 10 | %ADD10C,0.0600*% 11 | %ADD11C,0.0476*% 12 | %ADD12R,0.0591X0.0394*% 13 | %ADD13R,0.0591X0.0276*% 14 | %ADD14R,0.1102X0.0591*% 15 | %ADD15R,0.0240X0.0870*% 16 | %ADD16R,0.0531X0.0217*% 17 | %ADD17R,0.0800X0.0260*% 18 | %ADD18R,0.0394X0.0433*% 19 | %ADD19C,0.0554*% 20 | %ADD20C,0.0660*% 21 | %ADD21C,0.0100*% 22 | %ADD22C,0.0400*% 23 | D10* 24 | X004100Y014800D02* 25 | X004100Y015400D01* 26 | X005100Y015400D02* 27 | X005100Y014800D01* 28 | X006100Y014800D02* 29 | X006100Y015400D01* 30 | X007100Y015400D02* 31 | X007100Y014800D01* 32 | X010100Y014800D02* 33 | X010100Y015400D01* 34 | X011100Y015400D02* 35 | X011100Y014800D01* 36 | X012100Y014800D02* 37 | X012100Y015400D01* 38 | X013100Y015400D02* 39 | X013100Y014800D01* 40 | X014100Y014800D02* 41 | X014100Y015400D01* 42 | X015100Y015400D02* 43 | X015100Y014800D01* 44 | X017600Y014800D02* 45 | X017600Y015400D01* 46 | X018600Y015400D02* 47 | X018600Y014800D01* 48 | X019600Y014800D02* 49 | X019600Y015400D01* 50 | X026800Y017100D02* 51 | X027400Y017100D01* 52 | X027400Y018100D02* 53 | X026800Y018100D01* 54 | X026800Y019100D02* 55 | X027400Y019100D01* 56 | X027400Y020100D02* 57 | X026800Y020100D01* 58 | X026800Y021100D02* 59 | X027400Y021100D01* 60 | X027400Y022100D02* 61 | X026800Y022100D01* 62 | X014600Y023300D02* 63 | X014600Y023900D01* 64 | X013600Y023900D02* 65 | X013600Y023300D01* 66 | X012600Y023300D02* 67 | X012600Y023900D01* 68 | X011600Y023900D02* 69 | X011600Y023300D01* 70 | X010600Y023300D02* 71 | X010600Y023900D01* 72 | D11* 73 | X007100Y021050D03* 74 | X007100Y020089D03* 75 | X007100Y019150D03* 76 | D12* 77 | X021100Y019537D03* 78 | X021100Y018553D03* 79 | X021100Y017569D03* 80 | X021100Y016584D03* 81 | X021100Y015600D03* 82 | X021100Y020521D03* 83 | X021100Y021506D03* 84 | X021100Y022460D03* 85 | X021100Y023130D03* 86 | D13* 87 | X021100Y023641D03* 88 | X021100Y024114D03* 89 | D14* 90 | X021809Y024658D03* 91 | X030273Y024658D03* 92 | X021809Y014776D03* 93 | X030273Y013910D03* 94 | D15* 95 | X012350Y018070D03* 96 | X011850Y018070D03* 97 | X011350Y018070D03* 98 | X010850Y018070D03* 99 | X010850Y020130D03* 100 | X011350Y020130D03* 101 | X011850Y020130D03* 102 | X012350Y020130D03* 103 | D16* 104 | X009141Y022726D03* 105 | X009141Y023100D03* 106 | X009141Y023474D03* 107 | X008059Y023474D03* 108 | X008059Y023100D03* 109 | X008059Y022726D03* 110 | D17* 111 | X015620Y022850D03* 112 | X015620Y022350D03* 113 | X015620Y021850D03* 114 | X015620Y021350D03* 115 | X015620Y020850D03* 116 | X015620Y020350D03* 117 | X015620Y019850D03* 118 | X015620Y019350D03* 119 | X015620Y018850D03* 120 | X015620Y018350D03* 121 | X019580Y018350D03* 122 | X019580Y018850D03* 123 | X019580Y019350D03* 124 | X019580Y019850D03* 125 | X019580Y020350D03* 126 | X019580Y020850D03* 127 | X019580Y021350D03* 128 | X019580Y021850D03* 129 | X019580Y022350D03* 130 | X019580Y022850D03* 131 | D18* 132 | X018935Y017100D03* 133 | X018265Y017100D03* 134 | X018265Y016100D03* 135 | X018935Y016100D03* 136 | D19* 137 | X020100Y016663D03* 138 | X020100Y024537D03* 139 | D20* 140 | X005100Y021569D03* 141 | X005100Y017631D03* 142 | D21* 143 | X004150Y015850D02* 144 | X010360Y015850D01* 145 | X011080Y015130D01* 146 | X011100Y015100D01* 147 | X011530Y014590D02* 148 | X011980Y014140D01* 149 | X018910Y014140D01* 150 | X019720Y014950D01* 151 | X019600Y015100D01* 152 | X019630Y015040D01* 153 | X019720Y014950D01* 154 | X019900Y014770D01* 155 | X021790Y014770D01* 156 | X021809Y014776D01* 157 | X021880Y014770D01* 158 | X022690Y013960D01* 159 | X027910Y013960D01* 160 | X027910Y021250D01* 161 | X027100Y022060D01* 162 | X027100Y022100D01* 163 | X027100Y022150D01* 164 | X025750Y023500D01* 165 | X022960Y023500D01* 166 | X022960Y024220D01* 167 | X022510Y024670D01* 168 | X021880Y024670D01* 169 | X021809Y024658D01* 170 | X022960Y023500D02* 171 | X021160Y021700D01* 172 | X021160Y021520D01* 173 | X021100Y021506D01* 174 | X021100Y022460D02* 175 | X021070Y022510D01* 176 | X020800Y022780D01* 177 | X020710Y022780D01* 178 | X020530Y022960D01* 179 | X020530Y024760D01* 180 | X020260Y025030D01* 181 | X017020Y025030D01* 182 | X014320Y022330D01* 183 | X011440Y022330D01* 184 | X011080Y021970D01* 185 | X010540Y022510D01* 186 | X009550Y021520D01* 187 | X009460Y021970D02* 188 | X008920Y021970D01* 189 | X008740Y022150D01* 190 | X008740Y023050D01* 191 | X008380Y023410D01* 192 | X008110Y023410D01* 193 | X008059Y023474D01* 194 | X008380Y023770D02* 195 | X006580Y023770D01* 196 | X004150Y021340D01* 197 | X004150Y015850D01* 198 | X004150Y015130D01* 199 | X004100Y015100D01* 200 | X007100Y015100D02* 201 | X007120Y015130D01* 202 | X010090Y015130D01* 203 | X010100Y015100D01* 204 | X010180Y015040D01* 205 | X010900Y014320D01* 206 | X011260Y014320D01* 207 | X011530Y014590D01* 208 | X011530Y017110D01* 209 | X012790Y017110D01* 210 | X014860Y019180D01* 211 | X015040Y019180D01* 212 | X015040Y019810D01* 213 | X014860Y019810D01* 214 | X015040Y019810D02* 215 | X015040Y021970D01* 216 | X011620Y021970D01* 217 | X011080Y021970D02* 218 | X012340Y020710D01* 219 | X012520Y020710D01* 220 | X013150Y020080D01* 221 | X013150Y019540D01* 222 | X012250Y018640D01* 223 | X012160Y018640D01* 224 | X011890Y018370D01* 225 | X011890Y018100D01* 226 | X011850Y018070D01* 227 | X012350Y018070D02* 228 | X012430Y018100D01* 229 | X012790Y018460D01* 230 | X013060Y018460D01* 231 | X012790Y017650D02* 232 | X014500Y019360D01* 233 | X014500Y020440D01* 234 | X015620Y020350D02* 235 | X018280Y020350D01* 236 | X019270Y019360D01* 237 | X019540Y019360D01* 238 | X019580Y019350D01* 239 | X019900Y018910D02* 240 | X020170Y019180D01* 241 | X020170Y024490D01* 242 | X020100Y024537D01* 243 | X018820Y021430D02* 244 | X018100Y020710D01* 245 | X017920Y020710D01* 246 | X015940Y019810D02* 247 | X015670Y019810D01* 248 | X015620Y019850D01* 249 | X015940Y019810D02* 250 | X018190Y017560D01* 251 | X018190Y017110D01* 252 | X018265Y017100D01* 253 | X018190Y017020D01* 254 | X017920Y016750D01* 255 | X017740Y016750D01* 256 | X018010Y016480D02* 257 | X017920Y016390D01* 258 | X016120Y016390D01* 259 | X015490Y017020D01* 260 | X015130Y016840D02* 261 | X014500Y016210D01* 262 | X012250Y016210D01* 263 | X011530Y017110D02* 264 | X010900Y017740D01* 265 | X010900Y018010D01* 266 | X010850Y018070D01* 267 | X010810Y018100D01* 268 | X009100Y018100D01* 269 | X007120Y020080D01* 270 | X007100Y020089D01* 271 | X007120Y020170D01* 272 | X005410Y021880D01* 273 | X006580Y023050D01* 274 | X008020Y023050D01* 275 | X008059Y023100D01* 276 | X008059Y022726D02* 277 | X008110Y022690D01* 278 | X008110Y022420D01* 279 | X009820Y020710D01* 280 | X010270Y020710D01* 281 | X011080Y020710D01* 282 | X011350Y020440D01* 283 | X011350Y020130D01* 284 | X011800Y020080D02* 285 | X011800Y019720D01* 286 | X010900Y018820D01* 287 | X010850Y020130D02* 288 | X010810Y020170D01* 289 | X010090Y020170D01* 290 | X009910Y020350D01* 291 | X009010Y021250D01* 292 | X008740Y021250D01* 293 | X008020Y021970D01* 294 | X009100Y022330D02* 295 | X009100Y022690D01* 296 | X009141Y022726D01* 297 | X009190Y023050D02* 298 | X009141Y023100D01* 299 | X009190Y023050D02* 300 | X010000Y023050D01* 301 | X010540Y022510D01* 302 | X009550Y022060D02* 303 | X009460Y021970D01* 304 | X009141Y023474D02* 305 | X009100Y023500D01* 306 | X008650Y023500D01* 307 | X008380Y023770D01* 308 | X005410Y021880D02* 309 | X005140Y021610D01* 310 | X005100Y021569D01* 311 | X011800Y020080D02* 312 | X011850Y020130D01* 313 | X011890Y020170D01* 314 | X012340Y020170D01* 315 | X012350Y020130D01* 316 | X012430Y020080D01* 317 | X012790Y019720D01* 318 | X015040Y019180D02* 319 | X015310Y018910D01* 320 | X015580Y018910D01* 321 | X015620Y018850D01* 322 | X015620Y018350D02* 323 | X015580Y018280D01* 324 | X015130Y017830D01* 325 | X015130Y016840D01* 326 | X015850Y016120D01* 327 | X018190Y016120D01* 328 | X018265Y016100D01* 329 | X018010Y016480D02* 330 | X019000Y016480D01* 331 | X019000Y016120D01* 332 | X018935Y016100D01* 333 | X019000Y016480D02* 334 | X019000Y017020D01* 335 | X018935Y017100D01* 336 | X019000Y017110D01* 337 | X019000Y017740D01* 338 | X019540Y018280D01* 339 | X019580Y018350D01* 340 | X019630Y018370D01* 341 | X019990Y018370D01* 342 | X021070Y019450D01* 343 | X021100Y019537D01* 344 | X021160Y019540D01* 345 | X021880Y019540D01* 346 | X022420Y020080D01* 347 | X027100Y020080D01* 348 | X027100Y020100D01* 349 | X027100Y022150D02* 350 | X029530Y024580D01* 351 | X030250Y024580D01* 352 | X030273Y024658D01* 353 | X021700Y019900D02* 354 | X021160Y020440D01* 355 | X021100Y020521D01* 356 | X019900Y018910D02* 357 | X019630Y018910D01* 358 | X019580Y018850D01* 359 | X021070Y018550D02* 360 | X021070Y018280D01* 361 | X020170Y017380D01* 362 | X020170Y016750D01* 363 | X020100Y016663D01* 364 | X019630Y016120D02* 365 | X019090Y015580D01* 366 | X019090Y014680D01* 367 | X018730Y014320D01* 368 | X012880Y014320D01* 369 | X012100Y015100D01* 370 | X011800Y014050D02* 371 | X011890Y013960D01* 372 | X019990Y013960D01* 373 | X020620Y015130D02* 374 | X020620Y016120D01* 375 | X021070Y016570D01* 376 | X021100Y016584D01* 377 | X021100Y017569D02* 378 | X021160Y017650D01* 379 | X021160Y017920D01* 380 | X021700Y018460D01* 381 | X021100Y018553D02* 382 | X021070Y018550D01* 383 | X015620Y021850D02* 384 | X015580Y021880D01* 385 | X015490Y021970D01* 386 | X015040Y021970D01* 387 | X011800Y014050D02* 388 | X011530Y014050D01* 389 | X027910Y013960D02* 390 | X030250Y013960D01* 391 | X030273Y013910D01* 392 | D22* 393 | X011530Y014050D03* 394 | X012250Y016210D03* 395 | X012790Y017650D03* 396 | X013060Y018460D03* 397 | X012790Y019720D03* 398 | X014500Y020440D03* 399 | X014860Y019810D03* 400 | X017920Y020710D03* 401 | X018820Y021430D03* 402 | X021700Y019900D03* 403 | X021700Y018460D03* 404 | X019630Y016120D03* 405 | X020620Y015130D03* 406 | X019990Y013960D03* 407 | X017740Y016750D03* 408 | X015490Y017020D03* 409 | X010900Y018820D03* 410 | X009910Y020350D03* 411 | X010270Y020710D03* 412 | X009550Y021520D03* 413 | X009550Y022060D03* 414 | X009100Y022330D03* 415 | X008020Y021970D03* 416 | X008740Y021250D03* 417 | X011620Y021970D03* 418 | M02* 419 | -------------------------------------------------------------------------------- /atmega1284p_v4_gerber/atmega1284_v4_top.gpi: -------------------------------------------------------------------------------- 1 | Generated by EAGLE CAM Processor 7.1.0 2 | 3 | Photoplotter Info File: /Users/kodera2t/Desktop/atmega1284_v4_top.gpi 4 | 5 | Date : 6/11/15 09:59 6 | Plotfile : /Users/kodera2t/Desktop/atmega1284_v4_top 7 | Apertures : generated: 8 | Device : Gerber RS-274-X photoplotter, coordinate format 2.4 inch 9 | 10 | Parameter settings: 11 | 12 | Emulate Apertures : no 13 | Tolerance Draw + : 0.00 % 14 | Tolerance Draw - : 0.00 % 15 | Tolerance Flash + : 0.00 % 16 | Tolerance Flash - : 0.00 % 17 | Rotate : no 18 | Mirror : no 19 | Optimize : yes 20 | Auto fit : yes 21 | OffsetX : 0inch 22 | OffsetY : 0inch 23 | 24 | Plotfile Info: 25 | 26 | Coordinate Format : 2.4 27 | Coordinate Units : Inch 28 | Data Mode : Absolute 29 | Zero Suppression : None 30 | End Of Block : * 31 | 32 | Apertures used: 33 | 34 | Code Shape Size used 35 | 36 | D10 rectangle 0.0512inch x 0.0591inch 6 37 | D11 draw 0.0600inch 24 38 | D12 round 0.0476inch 3 39 | D13 rectangle 0.0591inch x 0.0197inch 22 40 | D14 rectangle 0.0197inch x 0.0591inch 22 41 | D15 round 0.0554inch 2 42 | D16 round 0.0660inch 2 43 | D17 draw 0.0100inch 241 44 | D18 round 0.0400inch 25 45 | 46 | -------------------------------------------------------------------------------- /atmega1284p_v4_gerber/atmega1284_v4_top.grb: -------------------------------------------------------------------------------- 1 | G75* 2 | %MOIN*% 3 | %OFA0B0*% 4 | %FSLAX24Y24*% 5 | %IPPOS*% 6 | %LPD*% 7 | %AMOC8* 8 | 5,1,8,0,0,1.08239X$1,22.5* 9 | % 10 | %ADD10R,0.0512X0.0591*% 11 | %ADD11C,0.0600*% 12 | %ADD12C,0.0476*% 13 | %ADD13R,0.0591X0.0197*% 14 | %ADD14R,0.0197X0.0591*% 15 | %ADD15C,0.0554*% 16 | %ADD16C,0.0660*% 17 | %ADD17C,0.0100*% 18 | %ADD18C,0.0400*% 19 | D10* 20 | X015726Y017600D03* 21 | X016474Y017600D03* 22 | X016474Y019600D03* 23 | X015726Y019600D03* 24 | X015726Y020600D03* 25 | X016474Y020600D03* 26 | D11* 27 | X014600Y023300D02* 28 | X014600Y023900D01* 29 | X013600Y023900D02* 30 | X013600Y023300D01* 31 | X012600Y023300D02* 32 | X012600Y023900D01* 33 | X011600Y023900D02* 34 | X011600Y023300D01* 35 | X010600Y023300D02* 36 | X010600Y023900D01* 37 | X010100Y015400D02* 38 | X010100Y014800D01* 39 | X011100Y014800D02* 40 | X011100Y015400D01* 41 | X012100Y015400D02* 42 | X012100Y014800D01* 43 | X013100Y014800D02* 44 | X013100Y015400D01* 45 | X014100Y015400D02* 46 | X014100Y014800D01* 47 | X015100Y014800D02* 48 | X015100Y015400D01* 49 | X017600Y015400D02* 50 | X017600Y014800D01* 51 | X018600Y014800D02* 52 | X018600Y015400D01* 53 | X019600Y015400D02* 54 | X019600Y014800D01* 55 | X026800Y017100D02* 56 | X027400Y017100D01* 57 | X027400Y018100D02* 58 | X026800Y018100D01* 59 | X026800Y019100D02* 60 | X027400Y019100D01* 61 | X027400Y020100D02* 62 | X026800Y020100D01* 63 | X026800Y021100D02* 64 | X027400Y021100D01* 65 | X027400Y022100D02* 66 | X026800Y022100D01* 67 | X007100Y015400D02* 68 | X007100Y014800D01* 69 | X006100Y014800D02* 70 | X006100Y015400D01* 71 | X005100Y015400D02* 72 | X005100Y014800D01* 73 | X004100Y014800D02* 74 | X004100Y015400D01* 75 | D12* 76 | X007100Y019150D03* 77 | X007100Y020089D03* 78 | X007100Y021050D03* 79 | D13* 80 | X009317Y020675D03* 81 | X009317Y020360D03* 82 | X009317Y020045D03* 83 | X009317Y019730D03* 84 | X009317Y019415D03* 85 | X009317Y019100D03* 86 | X009317Y018785D03* 87 | X009317Y018470D03* 88 | X009317Y018155D03* 89 | X009317Y017840D03* 90 | X009317Y017525D03* 91 | X013883Y017525D03* 92 | X013883Y017840D03* 93 | X013883Y018155D03* 94 | X013883Y018470D03* 95 | X013883Y018785D03* 96 | X013883Y019100D03* 97 | X013883Y019415D03* 98 | X013883Y019730D03* 99 | X013883Y020045D03* 100 | X013883Y020360D03* 101 | X013883Y020675D03* 102 | D14* 103 | X013175Y021383D03* 104 | X012860Y021383D03* 105 | X012545Y021383D03* 106 | X012230Y021383D03* 107 | X011915Y021383D03* 108 | X011600Y021383D03* 109 | X011285Y021383D03* 110 | X010970Y021383D03* 111 | X010655Y021383D03* 112 | X010340Y021383D03* 113 | X010025Y021383D03* 114 | X010025Y016817D03* 115 | X010340Y016817D03* 116 | X010655Y016817D03* 117 | X010970Y016817D03* 118 | X011285Y016817D03* 119 | X011600Y016817D03* 120 | X011915Y016817D03* 121 | X012230Y016817D03* 122 | X012545Y016817D03* 123 | X012860Y016817D03* 124 | X013175Y016817D03* 125 | D15* 126 | X020100Y016663D03* 127 | X020100Y024537D03* 128 | D16* 129 | X005100Y021569D03* 130 | X005100Y017631D03* 131 | D17* 132 | X004780Y013510D02* 133 | X022510Y013510D01* 134 | X027100Y018100D01* 135 | X027640Y018550D02* 136 | X027910Y018280D01* 137 | X027910Y017920D01* 138 | X027100Y017110D01* 139 | X027100Y017100D01* 140 | X027640Y018550D02* 141 | X025210Y018550D01* 142 | X022330Y021430D01* 143 | X018820Y021430D01* 144 | X018550Y020620D02* 145 | X018550Y015130D01* 146 | X018600Y015100D01* 147 | X018100Y015580D02* 148 | X017650Y015130D01* 149 | X017600Y015100D01* 150 | X018100Y015580D02* 151 | X018100Y016930D01* 152 | X017920Y017110D01* 153 | X017560Y017110D01* 154 | X017110Y016660D01* 155 | X014140Y016660D01* 156 | X013420Y017380D01* 157 | X013420Y017560D01* 158 | X011350Y019630D01* 159 | X011350Y021340D01* 160 | X011285Y021383D01* 161 | X010970Y021383D02* 162 | X010900Y021430D01* 163 | X010900Y022330D01* 164 | X010090Y023140D01* 165 | X010090Y024040D01* 166 | X010450Y024400D01* 167 | X014770Y024400D01* 168 | X018550Y020620D01* 169 | X017920Y020710D02* 170 | X017920Y018280D01* 171 | X016750Y017110D01* 172 | X016210Y017110D01* 173 | X015760Y017560D01* 174 | X015726Y017600D01* 175 | X015490Y017020D02* 176 | X014950Y017560D01* 177 | X014950Y018820D01* 178 | X015670Y019540D01* 179 | X015726Y019600D01* 180 | X015760Y019630D01* 181 | X015760Y020530D01* 182 | X015726Y020600D01* 183 | X015310Y020260D02* 184 | X015310Y020980D01* 185 | X015400Y021070D01* 186 | X016030Y021070D01* 187 | X016480Y020620D01* 188 | X016474Y020600D01* 189 | X016930Y020890D02* 190 | X016930Y020080D01* 191 | X016480Y019630D01* 192 | X016474Y019600D01* 193 | X016480Y019540D01* 194 | X016480Y017650D01* 195 | X016474Y017600D01* 196 | X017740Y016750D02* 197 | X015310Y014320D01* 198 | X013960Y014320D01* 199 | X013600Y014680D01* 200 | X013600Y015580D01* 201 | X013330Y015850D01* 202 | X013240Y015850D01* 203 | X012610Y016480D01* 204 | X012610Y016750D01* 205 | X012545Y016817D01* 206 | X012250Y016750D02* 207 | X012230Y016817D01* 208 | X012250Y016750D02* 209 | X012250Y016210D01* 210 | X011890Y015850D02* 211 | X011530Y015490D01* 212 | X011530Y014590D01* 213 | X011260Y014320D01* 214 | X010900Y014320D01* 215 | X010180Y015040D01* 216 | X010100Y015100D01* 217 | X009640Y015580D02* 218 | X009640Y014590D01* 219 | X010540Y013690D01* 220 | X019180Y013690D01* 221 | X020620Y015130D01* 222 | X021250Y015220D02* 223 | X021250Y017200D01* 224 | X022240Y018190D01* 225 | X022240Y019900D01* 226 | X021880Y020260D01* 227 | X021430Y020260D01* 228 | X020440Y019270D01* 229 | X021250Y018460D01* 230 | X021700Y018460D01* 231 | X021880Y018100D02* 232 | X021340Y018100D01* 233 | X021070Y018370D01* 234 | X019630Y016930D01* 235 | X019630Y016120D01* 236 | X020080Y015580D02* 237 | X019600Y015100D01* 238 | X020080Y015580D02* 239 | X020080Y016660D01* 240 | X020100Y016663D01* 241 | X021250Y015220D02* 242 | X019990Y013960D01* 243 | X015100Y015100D02* 244 | X015040Y015130D01* 245 | X013420Y016750D01* 246 | X013240Y016750D01* 247 | X013175Y016817D01* 248 | X012790Y017650D02* 249 | X010720Y019720D01* 250 | X009370Y019720D01* 251 | X009317Y019730D01* 252 | X009370Y019990D02* 253 | X009317Y020045D01* 254 | X009280Y020080D01* 255 | X009010Y020080D01* 256 | X008380Y020710D01* 257 | X008380Y022600D01* 258 | X010360Y024580D01* 259 | X014860Y024580D01* 260 | X021070Y018370D01* 261 | X021880Y018100D02* 262 | X022060Y018280D01* 263 | X022060Y018640D01* 264 | X021700Y019000D01* 265 | X021700Y019900D01* 266 | X020440Y019270D02* 267 | X014950Y024760D01* 268 | X010270Y024760D01* 269 | X008020Y022510D01* 270 | X008020Y021970D01* 271 | X007300Y021430D02* 272 | X006940Y021430D01* 273 | X006670Y021160D01* 274 | X006670Y020530D01* 275 | X007030Y020170D01* 276 | X007100Y020089D01* 277 | X007120Y020710D02* 278 | X007120Y020980D01* 279 | X007100Y021050D01* 280 | X007120Y020710D02* 281 | X009010Y018820D01* 282 | X009280Y018820D01* 283 | X009317Y018785D01* 284 | X009280Y018550D02* 285 | X009317Y018470D01* 286 | X009280Y018550D02* 287 | X007660Y018550D01* 288 | X007120Y019090D01* 289 | X007100Y019150D01* 290 | X006490Y019180D02* 291 | X006490Y021250D01* 292 | X010180Y024940D01* 293 | X019090Y024940D01* 294 | X024850Y019180D01* 295 | X027100Y019180D01* 296 | X027100Y019100D01* 297 | X016930Y020890D02* 298 | X016570Y021250D01* 299 | X015310Y021250D01* 300 | X014500Y020440D01* 301 | X013960Y020710D02* 302 | X013883Y020675D01* 303 | X013960Y020710D02* 304 | X013960Y022960D01* 305 | X014600Y023600D01* 306 | X013600Y023590D02* 307 | X013600Y023600D01* 308 | X013600Y023590D02* 309 | X013240Y023230D01* 310 | X013240Y021430D01* 311 | X013175Y021383D01* 312 | X012860Y021383D02* 313 | X012790Y021430D01* 314 | X012790Y023410D01* 315 | X012600Y023600D01* 316 | X012520Y022690D02* 317 | X011620Y023590D01* 318 | X011600Y023600D01* 319 | X010630Y023590D02* 320 | X010600Y023600D01* 321 | X010630Y023590D02* 322 | X012160Y022060D01* 323 | X012160Y021430D01* 324 | X012230Y021383D01* 325 | X011980Y021340D02* 326 | X011915Y021383D01* 327 | X011980Y021340D02* 328 | X011980Y020350D01* 329 | X012700Y019630D01* 330 | X012790Y019720D01* 331 | X012700Y019630D02* 332 | X013510Y018820D01* 333 | X013870Y018820D01* 334 | X013883Y018785D01* 335 | X013960Y018820D01* 336 | X014950Y018820D01* 337 | X014230Y019180D02* 338 | X014860Y019810D01* 339 | X015310Y020260D01* 340 | X014230Y019180D02* 341 | X013960Y019180D01* 342 | X013883Y019100D01* 343 | X013883Y018470D02* 344 | X013870Y018460D01* 345 | X013060Y018460D01* 346 | X011530Y017470D02* 347 | X011530Y016840D01* 348 | X011600Y016817D01* 349 | X011530Y016750D01* 350 | X011530Y015760D01* 351 | X011170Y015400D01* 352 | X011170Y015130D01* 353 | X011100Y015100D01* 354 | X011890Y015850D02* 355 | X011890Y016750D01* 356 | X011915Y016817D01* 357 | X011530Y017470D02* 358 | X010540Y018460D01* 359 | X010900Y018820D01* 360 | X010540Y018460D02* 361 | X009640Y019360D01* 362 | X009370Y019360D01* 363 | X009317Y019415D01* 364 | X009280Y019180D02* 365 | X008920Y019180D01* 366 | X007480Y020620D01* 367 | X007480Y021250D01* 368 | X007300Y021430D01* 369 | X008740Y021250D02* 370 | X009100Y021610D01* 371 | X009100Y022330D01* 372 | X009550Y022060D02* 373 | X010000Y021610D01* 374 | X010000Y021430D01* 375 | X010025Y021383D01* 376 | X009550Y021520D02* 377 | X008830Y020800D01* 378 | X008830Y020530D01* 379 | X008920Y020440D01* 380 | X009280Y020440D01* 381 | X009317Y020360D01* 382 | X009370Y020620D02* 383 | X009317Y020675D01* 384 | X009370Y020620D02* 385 | X009640Y020620D01* 386 | X009910Y020350D01* 387 | X010270Y020170D02* 388 | X010270Y020710D01* 389 | X010270Y020170D02* 390 | X010090Y019990D01* 391 | X009370Y019990D01* 392 | X009280Y019180D02* 393 | X009317Y019100D01* 394 | X009280Y018190D02* 395 | X009317Y018155D01* 396 | X009280Y018190D02* 397 | X007480Y018190D01* 398 | X006490Y019180D01* 399 | X005410Y018280D02* 400 | X004780Y018280D01* 401 | X003610Y017110D01* 402 | X003610Y014680D01* 403 | X004780Y013510D01* 404 | X005100Y015100D02* 405 | X005050Y015130D01* 406 | X004600Y015580D01* 407 | X004600Y017830D01* 408 | X004870Y018100D01* 409 | X005320Y018100D01* 410 | X005860Y017560D01* 411 | X009280Y017560D01* 412 | X009317Y017525D01* 413 | X009317Y017840D02* 414 | X009280Y017920D01* 415 | X005770Y017920D01* 416 | X005410Y018280D01* 417 | X005100Y017631D02* 418 | X005140Y017560D01* 419 | X005410Y017290D01* 420 | X010810Y017290D01* 421 | X010900Y017200D01* 422 | X010900Y016840D01* 423 | X010970Y016817D01* 424 | X010655Y016817D02* 425 | X010630Y016750D01* 426 | X010630Y016480D01* 427 | X010000Y015850D01* 428 | X009910Y015850D01* 429 | X009640Y015580D01* 430 | X010000Y016750D02* 431 | X010025Y016817D01* 432 | X010000Y016750D02* 433 | X007750Y016750D01* 434 | X006100Y015100D01* 435 | X011530Y014050D02* 436 | X012070Y014050D01* 437 | X013060Y015040D01* 438 | X013100Y015100D01* 439 | X012545Y021383D02* 440 | X012520Y021430D01* 441 | X012520Y022690D01* 442 | X011620Y021970D02* 443 | X011620Y021430D01* 444 | X011600Y021383D01* 445 | D18* 446 | X011620Y021970D03* 447 | X010270Y020710D03* 448 | X009910Y020350D03* 449 | X009550Y021520D03* 450 | X009550Y022060D03* 451 | X009100Y022330D03* 452 | X008020Y021970D03* 453 | X008740Y021250D03* 454 | X010900Y018820D03* 455 | X012790Y019720D03* 456 | X013060Y018460D03* 457 | X012790Y017650D03* 458 | X012250Y016210D03* 459 | X011530Y014050D03* 460 | X015490Y017020D03* 461 | X017740Y016750D03* 462 | X019630Y016120D03* 463 | X020620Y015130D03* 464 | X019990Y013960D03* 465 | X021700Y018460D03* 466 | X021700Y019900D03* 467 | X018820Y021430D03* 468 | X017920Y020710D03* 469 | X014860Y019810D03* 470 | X014500Y020440D03* 471 | M02* 472 | -------------------------------------------------------------------------------- /bitlash_OLED.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "bitlash.h" 3 | 4 | //////////////// Newly added for graphic OLED(LCD) 128x64 support///////////// 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | // SPI PIN definition. Change to fit your board.... 11 | #define OLED_MOSI 5 12 | #define OLED_CLK 7 13 | #define OLED_DC 19 14 | #define OLED_CS 18 15 | #define OLED_RESET 20 16 | Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); 17 | 18 | 19 | int screenMem[168]; //the implementation of frame buffer is referenced from Ben Heck's 20 | int cursorX = 0; //Retro BASIC computer's source 21 | int checkChar = 0; 22 | 23 | ////////////////////////////////////////////////////////////////////////////// 24 | //////////////////////////////////////////////////////////////////////////////// 25 | // ASCII Characters 26 | #define CR '\r' 27 | #define NL '\n' 28 | #define LF 0x0a 29 | #define TAB '\t' 30 | #define BELL '\b' 31 | #define SPACE ' ' 32 | #define SQUOTE '\'' 33 | #define DQUOTE '\"' 34 | #define CTRLC 0x1B // Changed to ESC key (27 - 0x1B) 35 | #define CTRLH 0x08 36 | #define CTRLS 0x13 37 | #define CTRLX 0x18 38 | 39 | static const unsigned char initmsg[] PROGMEM = "bitlash here! v2.0 (c) 2013 Bill Roy -type HELP- 13346 bytes free"; 40 | 41 | 42 | void send_cmd_2(char c) { 43 | outchar(c); 44 | doFrame(147); 45 | } 46 | 47 | 48 | void send_cmd(char c) { 49 | outchar(c); 50 | doFrame(147); 51 | } 52 | 53 | 54 | void setup(void) { 55 | initBitlash(4800); 56 | display.begin(); 57 | // init done 58 | display.display(); 59 | display.clearDisplay(); 60 | display.setTextSize(1); 61 | display.setTextColor(WHITE); 62 | display.setCursor(0,0); 63 | for (int xg = 0 ; xg < 169 ; xg++) { 64 | screenMem[xg] = 32; 65 | } 66 | setOutputHandler(&lcdChar); 67 | printmsg(initmsg); 68 | doFrame(147); 69 | printmsg(initmsg); 70 | } 71 | 72 | void loop(void) { 73 | runBitlash(); 74 | } 75 | 76 | static void outchar(unsigned char c) 77 | { 78 | lcdChar(c); 79 | } 80 | 81 | static void lcdChar(byte c) { 82 | 83 | if (c == 8) { //Backspace? 84 | 85 | if (cursorX > 0) { 86 | 87 | cursorX -= 1; 88 | screenMem[147 + cursorX] = 32; 89 | doFrame(147 + cursorX); 90 | 91 | } 92 | 93 | } 94 | 95 | if (c != 13 and c != 10 and c != 8) { 96 | 97 | screenMem[147 + cursorX] = c; 98 | cursorX += 1; 99 | if (cursorX < 21) { 100 | display.setCursor(cursorX*6,8*7); 101 | display.write(c); 102 | display.display(); 103 | } 104 | 105 | } 106 | 107 | if (cursorX == 21 or c == 10) { 108 | 109 | for (int xg = 21 ; xg > 0 ; xg--) { 110 | 111 | screenMem[0 + xg] = screenMem[21 + xg]; 112 | screenMem[21 + xg] = screenMem[42 + xg]; 113 | screenMem[42 + xg] = screenMem[63 + xg]; 114 | screenMem[63 + xg] = screenMem[84 + xg]; 115 | screenMem[84 + xg] = screenMem[105 + xg]; 116 | screenMem[105 + xg] = screenMem[126 + xg]; 117 | screenMem[126 + xg] = screenMem[147 + xg]; 118 | 119 | 120 | 121 | screenMem[147 + xg] = 32; 122 | 123 | 124 | } 125 | 126 | cursorX = 0; 127 | 128 | doFrame(147); 129 | 130 | } 131 | 132 | 133 | } 134 | 135 | static void doFrame(byte amount) { 136 | int xposi,yposi,yshift; 137 | display.clearDisplay(); 138 | for (int xg = 0 ; xg < amount ; xg++) { 139 | yshift=int(xg/21.0); 140 | yposi=yshift*8; 141 | xposi=(xg-yshift*21)*6; 142 | display.setCursor(xposi,yposi); 143 | display.write(screenMem[xg]); 144 | } 145 | display.display(); 146 | } 147 | 148 | /***************************************************************************/ 149 | void printmsgNoNL(const unsigned char *msg) 150 | { 151 | while( pgm_read_byte( msg ) != 0 ) { 152 | outchar( pgm_read_byte( msg++ ) ); 153 | }; 154 | } 155 | 156 | /***************************************************************************/ 157 | void printmsg(const unsigned char *msg) 158 | { 159 | printmsgNoNL(msg); 160 | line_terminator(); 161 | } 162 | 163 | static void line_terminator(void) 164 | { 165 | outchar(NL); 166 | outchar(CR); 167 | } 168 | -------------------------------------------------------------------------------- /bitlasholed.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "bitlash.h" 3 | 4 | //////////////// Newly added for graphic OLED(LCD) 128x64 support///////////// 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | // SPI PIN definition. Change to fit your board.... 11 | #define OLED_MOSI 5 12 | #define OLED_CLK 7 13 | #define OLED_DC 19 14 | #define OLED_CS 18 15 | #define OLED_RESET 20 16 | Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); 17 | 18 | 19 | int screenMem[168]; //the implementation of frame buffer is referenced from Ben Heck's 20 | int cursorX = 0; //Retro BASIC computer's source 21 | int checkChar = 0; 22 | 23 | ////////////////////////////////////////////////////////////////////////////// 24 | //////////////////////////////////////////////////////////////////////////////// 25 | // ASCII Characters 26 | #define CR '\r' 27 | #define NL '\n' 28 | #define LF 0x0a 29 | #define TAB '\t' 30 | #define BELL '\b' 31 | #define SPACE ' ' 32 | #define SQUOTE '\'' 33 | #define DQUOTE '\"' 34 | #define CTRLC 0x1B // Changed to ESC key (27 - 0x1B) 35 | #define CTRLH 0x08 36 | #define CTRLS 0x13 37 | #define CTRLX 0x18 38 | 39 | static const unsigned char initmsg[] PROGMEM = "bitlash here! v2.0 (c) 2013 Bill Roy -type HELP- 13346 bytes free"; 40 | 41 | 42 | void send_cmd_2(char c) { 43 | outchar(c); 44 | doFrame(147); 45 | } 46 | 47 | 48 | void send_cmd(char c) { 49 | outchar(c); 50 | doFrame(147); 51 | } 52 | 53 | 54 | void setup(void) { 55 | initBitlash(4800); 56 | display.begin(); 57 | // init done 58 | display.display(); 59 | display.clearDisplay(); 60 | display.setTextSize(1); 61 | display.setTextColor(WHITE); 62 | display.setCursor(0,0); 63 | for (int xg = 0 ; xg < 169 ; xg++) { 64 | screenMem[xg] = 32; 65 | } 66 | setOutputHandler(&lcdChar); 67 | printmsg(initmsg); 68 | doFrame(147); 69 | printmsg(initmsg); 70 | } 71 | 72 | void loop(void) { 73 | runBitlash(); 74 | } 75 | 76 | static void outchar(unsigned char c) 77 | { 78 | lcdChar(c); 79 | } 80 | 81 | static void lcdChar(byte c) { 82 | 83 | if (c == 8) { //Backspace? 84 | 85 | if (cursorX > 0) { 86 | 87 | cursorX -= 1; 88 | screenMem[147 + cursorX] = 32; 89 | doFrame(147 + cursorX); 90 | 91 | } 92 | 93 | } 94 | 95 | if (c != 13 and c != 10 and c != 8) { 96 | 97 | screenMem[147 + cursorX] = c; 98 | cursorX += 1; 99 | if (cursorX < 21) { 100 | display.setCursor(cursorX*6,8*7); 101 | display.write(c); 102 | display.display(); 103 | } 104 | 105 | } 106 | 107 | if (cursorX == 21 or c == 10) { 108 | 109 | for (int xg = 21 ; xg > 0 ; xg--) { 110 | 111 | screenMem[0 + xg] = screenMem[21 + xg]; 112 | screenMem[21 + xg] = screenMem[42 + xg]; 113 | screenMem[42 + xg] = screenMem[63 + xg]; 114 | screenMem[63 + xg] = screenMem[84 + xg]; 115 | screenMem[84 + xg] = screenMem[105 + xg]; 116 | screenMem[105 + xg] = screenMem[126 + xg]; 117 | screenMem[126 + xg] = screenMem[147 + xg]; 118 | 119 | 120 | 121 | screenMem[147 + xg] = 32; 122 | 123 | 124 | } 125 | 126 | cursorX = 0; 127 | 128 | doFrame(147); 129 | 130 | } 131 | 132 | 133 | } 134 | 135 | static void doFrame(byte amount) { 136 | int xposi,yposi,yshift; 137 | display.clearDisplay(); 138 | for (int xg = 0 ; xg < amount ; xg++) { 139 | yshift=int(xg/21.0); 140 | yposi=yshift*8; 141 | xposi=(xg-yshift*21)*6; 142 | display.setCursor(xposi,yposi); 143 | display.write(screenMem[xg]); 144 | } 145 | display.display(); 146 | } 147 | 148 | /***************************************************************************/ 149 | void printmsgNoNL(const unsigned char *msg) 150 | { 151 | while( pgm_read_byte( msg ) != 0 ) { 152 | outchar( pgm_read_byte( msg++ ) ); 153 | }; 154 | } 155 | 156 | /***************************************************************************/ 157 | void printmsg(const unsigned char *msg) 158 | { 159 | printmsgNoNL(msg); 160 | line_terminator(); 161 | } 162 | 163 | static void line_terminator(void) 164 | { 165 | outchar(NL); 166 | outchar(CR); 167 | } 168 | -------------------------------------------------------------------------------- /gerber_LCD_ATMEGA1284/atmega_LCD.drd: -------------------------------------------------------------------------------- 1 | % 2 | M48 3 | M72 4 | T01C0.0240 5 | T02C0.0276 6 | T03C0.0400 7 | % 8 | T01 9 | X16390Y11980 10 | X10000Y16210 11 | X8740Y18100 12 | X10360Y18550 13 | X11980Y20080 14 | X15220Y20080 15 | X4060Y19990 16 | T02 17 | X6100Y19050 18 | X6100Y18089 19 | X6100Y17150 20 | T03 21 | X5600Y13100 22 | X6600Y13100 23 | X7600Y13100 24 | X8600Y13100 25 | X9600Y13100 26 | X10600Y13100 27 | X11600Y13100 28 | X12600Y13100 29 | X13600Y13100 30 | X14600Y13100 31 | X15600Y13100 32 | X16600Y13100 33 | X17600Y13100 34 | X18600Y13100 35 | X21100Y17100 36 | X21100Y18100 37 | X21100Y19100 38 | X21100Y20100 39 | X21100Y21100 40 | X21100Y22100 41 | X14600Y26100 42 | X13600Y26100 43 | X12600Y26100 44 | X11600Y26100 45 | X10600Y26100 46 | X3100Y18600 47 | X3100Y17600 48 | X3100Y16600 49 | X3100Y15600 50 | M30 51 | -------------------------------------------------------------------------------- /gerber_LCD_ATMEGA1284/atmega_LCD_bottom.gbr: -------------------------------------------------------------------------------- 1 | G75* 2 | %MOIN*% 3 | %OFA0B0*% 4 | %FSLAX24Y24*% 5 | %IPPOS*% 6 | %LPD*% 7 | %AMOC8* 8 | 5,1,8,0,0,1.08239X$1,22.5* 9 | % 10 | %ADD10C,0.0600*% 11 | %ADD11C,0.0476*% 12 | %ADD12C,0.0100*% 13 | %ADD13C,0.0400*% 14 | D10* 15 | X005600Y012800D02* 16 | X005600Y013400D01* 17 | X006600Y013400D02* 18 | X006600Y012800D01* 19 | X007600Y012800D02* 20 | X007600Y013400D01* 21 | X008600Y013400D02* 22 | X008600Y012800D01* 23 | X009600Y012800D02* 24 | X009600Y013400D01* 25 | X010600Y013400D02* 26 | X010600Y012800D01* 27 | X011600Y012800D02* 28 | X011600Y013400D01* 29 | X012600Y013400D02* 30 | X012600Y012800D01* 31 | X013600Y012800D02* 32 | X013600Y013400D01* 33 | X014600Y013400D02* 34 | X014600Y012800D01* 35 | X015600Y012800D02* 36 | X015600Y013400D01* 37 | X016600Y013400D02* 38 | X016600Y012800D01* 39 | X017600Y012800D02* 40 | X017600Y013400D01* 41 | X018600Y013400D02* 42 | X018600Y012800D01* 43 | X020800Y017100D02* 44 | X021400Y017100D01* 45 | X021400Y018100D02* 46 | X020800Y018100D01* 47 | X020800Y019100D02* 48 | X021400Y019100D01* 49 | X021400Y020100D02* 50 | X020800Y020100D01* 51 | X020800Y021100D02* 52 | X021400Y021100D01* 53 | X021400Y022100D02* 54 | X020800Y022100D01* 55 | X014600Y025800D02* 56 | X014600Y026400D01* 57 | X013600Y026400D02* 58 | X013600Y025800D01* 59 | X012600Y025800D02* 60 | X012600Y026400D01* 61 | X011600Y026400D02* 62 | X011600Y025800D01* 63 | X010600Y025800D02* 64 | X010600Y026400D01* 65 | X003400Y018600D02* 66 | X002800Y018600D01* 67 | X002800Y017600D02* 68 | X003400Y017600D01* 69 | X003400Y016600D02* 70 | X002800Y016600D01* 71 | X002800Y015600D02* 72 | X003400Y015600D01* 73 | D11* 74 | X006100Y017150D03* 75 | X006100Y018089D03* 76 | X006100Y019050D03* 77 | D12* 78 | X007120Y012610D02* 79 | X007750Y011980D01* 80 | X016390Y011980D01* 81 | X016840Y012340D02* 82 | X010360Y012340D01* 83 | X009600Y013100D01* 84 | X008830Y013870D01* 85 | X008380Y013870D01* 86 | X007660Y013150D01* 87 | X007600Y013100D01* 88 | X007120Y012610D02* 89 | X007120Y013600D01* 90 | X007570Y014050D01* 91 | X009640Y014050D01* 92 | X010540Y013150D01* 93 | X010600Y013100D01* 94 | X012520Y014230D02* 95 | X013600Y013150D01* 96 | X013600Y013100D01* 97 | X014590Y013150D02* 98 | X014600Y013100D01* 99 | X014590Y013150D02* 100 | X011980Y015760D01* 101 | X011980Y017740D01* 102 | X008560Y017740D01* 103 | X007660Y018640D01* 104 | X003160Y018640D01* 105 | X003100Y018600D01* 106 | X002350Y018820D02* 107 | X002350Y015400D01* 108 | X003520Y014230D01* 109 | X012520Y014230D01* 110 | X010000Y016210D02* 111 | X008560Y016210D01* 112 | X006310Y018460D01* 113 | X004960Y018460D01* 114 | X003100Y016600D01* 115 | X003160Y015670D02* 116 | X003100Y015600D01* 117 | X003160Y015670D02* 118 | X005500Y018010D01* 119 | X006040Y018010D01* 120 | X006100Y018089D01* 121 | X004060Y019990D02* 122 | X003520Y019990D01* 123 | X002350Y018820D01* 124 | X008740Y018100D02* 125 | X009190Y018100D01* 126 | X012700Y021610D01* 127 | X021520Y021610D01* 128 | X022060Y021070D01* 129 | X022060Y018100D01* 130 | X021610Y017650D01* 131 | X020620Y017650D01* 132 | X020350Y017920D01* 133 | X020350Y018370D01* 134 | X021070Y019090D01* 135 | X021100Y019100D01* 136 | X021880Y018820D02* 137 | X021160Y018100D01* 138 | X021100Y018100D01* 139 | X021880Y018820D02* 140 | X021880Y020260D01* 141 | X021610Y020530D01* 142 | X011890Y020530D01* 143 | X010360Y019000D01* 144 | X010360Y018550D01* 145 | X011980Y017740D02* 146 | X011980Y020080D01* 147 | X015220Y020080D01* 148 | X021070Y020080D01* 149 | X021100Y020100D01* 150 | X017600Y013100D02* 151 | X016840Y012340D01* 152 | D13* 153 | X016390Y011980D03* 154 | X010000Y016210D03* 155 | X008740Y018100D03* 156 | X010360Y018550D03* 157 | X011980Y020080D03* 158 | X015220Y020080D03* 159 | X004060Y019990D03* 160 | M02* 161 | -------------------------------------------------------------------------------- /gerber_LCD_ATMEGA1284/atmega_LCD_top.gbr: -------------------------------------------------------------------------------- 1 | G75* 2 | %MOIN*% 3 | %OFA0B0*% 4 | %FSLAX24Y24*% 5 | %IPPOS*% 6 | %LPD*% 7 | %AMOC8* 8 | 5,1,8,0,0,1.08239X$1,22.5* 9 | % 10 | %ADD10R,0.0512X0.0591*% 11 | %ADD11C,0.0600*% 12 | %ADD12C,0.0476*% 13 | %ADD13R,0.0591X0.0197*% 14 | %ADD14R,0.0197X0.0591*% 15 | %ADD15C,0.0100*% 16 | %ADD16C,0.0400*% 17 | D10* 18 | X013726Y015100D03* 19 | X014474Y015100D03* 20 | X015726Y017600D03* 21 | X016474Y017600D03* 22 | X016474Y019600D03* 23 | X015726Y019600D03* 24 | X015726Y020600D03* 25 | X016474Y020600D03* 26 | D11* 27 | X020800Y020100D02* 28 | X021400Y020100D01* 29 | X021400Y019100D02* 30 | X020800Y019100D01* 31 | X020800Y018100D02* 32 | X021400Y018100D01* 33 | X021400Y017100D02* 34 | X020800Y017100D01* 35 | X018600Y013400D02* 36 | X018600Y012800D01* 37 | X017600Y012800D02* 38 | X017600Y013400D01* 39 | X016600Y013400D02* 40 | X016600Y012800D01* 41 | X015600Y012800D02* 42 | X015600Y013400D01* 43 | X014600Y013400D02* 44 | X014600Y012800D01* 45 | X013600Y012800D02* 46 | X013600Y013400D01* 47 | X012600Y013400D02* 48 | X012600Y012800D01* 49 | X011600Y012800D02* 50 | X011600Y013400D01* 51 | X010600Y013400D02* 52 | X010600Y012800D01* 53 | X009600Y012800D02* 54 | X009600Y013400D01* 55 | X008600Y013400D02* 56 | X008600Y012800D01* 57 | X007600Y012800D02* 58 | X007600Y013400D01* 59 | X006600Y013400D02* 60 | X006600Y012800D01* 61 | X005600Y012800D02* 62 | X005600Y013400D01* 63 | X003400Y015600D02* 64 | X002800Y015600D01* 65 | X002800Y016600D02* 66 | X003400Y016600D01* 67 | X003400Y017600D02* 68 | X002800Y017600D01* 69 | X002800Y018600D02* 70 | X003400Y018600D01* 71 | X010600Y025800D02* 72 | X010600Y026400D01* 73 | X011600Y026400D02* 74 | X011600Y025800D01* 75 | X012600Y025800D02* 76 | X012600Y026400D01* 77 | X013600Y026400D02* 78 | X013600Y025800D01* 79 | X014600Y025800D02* 80 | X014600Y026400D01* 81 | X020800Y022100D02* 82 | X021400Y022100D01* 83 | X021400Y021100D02* 84 | X020800Y021100D01* 85 | D12* 86 | X006100Y019050D03* 87 | X006100Y018089D03* 88 | X006100Y017150D03* 89 | D13* 90 | X009317Y017525D03* 91 | X009317Y017840D03* 92 | X009317Y018155D03* 93 | X009317Y018470D03* 94 | X009317Y018785D03* 95 | X009317Y019100D03* 96 | X009317Y019415D03* 97 | X009317Y019730D03* 98 | X009317Y020045D03* 99 | X009317Y020360D03* 100 | X009317Y020675D03* 101 | X013883Y020675D03* 102 | X013883Y020360D03* 103 | X013883Y020045D03* 104 | X013883Y019730D03* 105 | X013883Y019415D03* 106 | X013883Y019100D03* 107 | X013883Y018785D03* 108 | X013883Y018470D03* 109 | X013883Y018155D03* 110 | X013883Y017840D03* 111 | X013883Y017525D03* 112 | D14* 113 | X013175Y016817D03* 114 | X012860Y016817D03* 115 | X012545Y016817D03* 116 | X012230Y016817D03* 117 | X011915Y016817D03* 118 | X011600Y016817D03* 119 | X011285Y016817D03* 120 | X010970Y016817D03* 121 | X010655Y016817D03* 122 | X010340Y016817D03* 123 | X010025Y016817D03* 124 | X010025Y021383D03* 125 | X010340Y021383D03* 126 | X010655Y021383D03* 127 | X010970Y021383D03* 128 | X011285Y021383D03* 129 | X011600Y021383D03* 130 | X011915Y021383D03* 131 | X012230Y021383D03* 132 | X012545Y021383D03* 133 | X012860Y021383D03* 134 | X013175Y021383D03* 135 | D15* 136 | X008650Y012790D02* 137 | X009460Y011980D01* 138 | X012430Y011980D01* 139 | X013060Y012610D01* 140 | X013060Y013510D01* 141 | X014410Y014860D01* 142 | X014410Y015040D01* 143 | X014474Y015100D01* 144 | X014050Y015400D02* 145 | X014050Y015490D01* 146 | X014140Y015580D01* 147 | X014770Y015580D01* 148 | X014860Y015490D01* 149 | X014860Y013150D01* 150 | X014600Y013100D01* 151 | X014680Y013150D01* 152 | X014860Y013150D01* 153 | X015580Y013150D01* 154 | X015600Y013100D01* 155 | X016570Y013150D02* 156 | X016600Y013100D01* 157 | X016570Y013150D02* 158 | X016570Y014050D01* 159 | X013330Y017290D01* 160 | X013060Y017290D01* 161 | X012880Y017110D01* 162 | X012880Y016840D01* 163 | X012860Y016817D01* 164 | X013150Y016750D02* 165 | X013175Y016817D01* 166 | X013150Y016750D02* 167 | X013150Y014860D01* 168 | X011620Y013330D01* 169 | X011620Y013150D01* 170 | X011600Y013100D01* 171 | X011170Y012610D02* 172 | X011170Y013600D01* 173 | X011530Y013960D01* 174 | X011530Y016750D01* 175 | X011600Y016817D01* 176 | X011915Y016817D02* 177 | X011980Y016840D01* 178 | X011980Y017470D01* 179 | X010990Y018460D01* 180 | X009640Y017110D01* 181 | X009640Y013150D01* 182 | X009600Y013100D01* 183 | X009100Y013510D02* 184 | X009100Y012610D01* 185 | X009550Y012160D01* 186 | X011890Y012160D01* 187 | X012520Y012790D01* 188 | X012520Y013060D01* 189 | X012600Y013100D01* 190 | X012160Y012700D02* 191 | X012160Y013600D01* 192 | X013690Y015130D01* 193 | X013726Y015100D01* 194 | X013780Y015130D01* 195 | X014050Y015400D01* 196 | X013960Y016930D02* 197 | X017110Y013780D01* 198 | X017110Y012700D01* 199 | X016390Y011980D01* 200 | X017600Y013100D02* 201 | X018370Y013870D01* 202 | X018820Y013870D01* 203 | X021880Y016930D01* 204 | X021880Y021340D01* 205 | X021160Y022060D01* 206 | X021100Y022100D01* 207 | X016930Y020080D02* 208 | X016480Y019630D01* 209 | X016474Y019600D01* 210 | X016480Y019540D01* 211 | X016480Y017650D01* 212 | X016474Y017600D01* 213 | X016210Y017110D02* 214 | X021070Y017110D01* 215 | X021100Y017100D01* 216 | X016930Y020080D02* 217 | X016930Y024760D01* 218 | X014860Y026830D01* 219 | X014410Y026830D01* 220 | X014140Y026560D01* 221 | X014140Y021700D01* 222 | X012160Y019720D01* 223 | X009370Y019720D01* 224 | X009317Y019730D01* 225 | X009280Y019990D02* 226 | X009317Y020045D01* 227 | X009280Y019990D02* 228 | X004060Y019990D01* 229 | X003970Y019450D02* 230 | X003160Y018640D01* 231 | X003100Y018600D01* 232 | X002350Y018820D02* 233 | X002350Y016390D01* 234 | X002710Y016030D01* 235 | X006580Y016030D01* 236 | X009100Y013510D01* 237 | X008650Y013060D02* 238 | X008600Y013100D01* 239 | X008650Y013060D02* 240 | X008650Y012790D01* 241 | X007600Y013100D02* 242 | X007570Y013150D01* 243 | X006670Y013150D01* 244 | X006600Y013100D01* 245 | X006580Y013150D01* 246 | X004150Y015580D01* 247 | X003160Y015580D01* 248 | X003100Y015600D01* 249 | X003070Y015670D01* 250 | X002800Y015670D01* 251 | X002170Y016300D01* 252 | X002170Y018910D01* 253 | X004240Y020980D01* 254 | X009640Y020980D01* 255 | X009730Y020890D01* 256 | X011440Y020890D01* 257 | X011530Y020980D01* 258 | X011530Y021340D01* 259 | X011600Y021383D01* 260 | X011915Y021383D02* 261 | X011980Y021340D01* 262 | X011980Y020080D01* 263 | X012230Y021383D02* 264 | X012160Y021430D01* 265 | X012160Y024490D01* 266 | X010630Y026020D01* 267 | X010600Y026100D01* 268 | X011600Y026100D02* 269 | X011620Y026020D01* 270 | X012520Y025120D01* 271 | X012520Y021430D01* 272 | X012545Y021383D01* 273 | X012790Y021430D02* 274 | X012860Y021383D01* 275 | X012790Y021430D02* 276 | X012790Y025840D01* 277 | X012610Y026020D01* 278 | X012600Y026100D01* 279 | X013240Y025660D02* 280 | X013600Y026020D01* 281 | X013600Y026100D01* 282 | X013240Y025660D02* 283 | X013240Y021430D01* 284 | X013175Y021383D01* 285 | X013960Y021250D02* 286 | X013960Y020710D01* 287 | X013883Y020675D01* 288 | X013960Y021250D02* 289 | X014590Y021880D01* 290 | X014590Y026020D01* 291 | X014600Y026100D01* 292 | X015400Y021070D02* 293 | X014320Y019990D01* 294 | X014320Y019270D01* 295 | X014230Y019180D01* 296 | X013960Y019180D01* 297 | X013883Y019100D01* 298 | X013870Y019090D01* 299 | X013600Y019090D01* 300 | X011980Y017470D01* 301 | X010990Y018460D02* 302 | X010360Y019090D01* 303 | X009370Y019090D01* 304 | X009317Y019100D01* 305 | X009280Y018820D02* 306 | X009317Y018785D01* 307 | X009280Y018820D02* 308 | X006310Y018820D01* 309 | X006130Y019000D01* 310 | X006100Y019050D01* 311 | X007390Y018460D02* 312 | X006130Y017200D01* 313 | X006100Y017150D01* 314 | X006310Y016750D02* 315 | X003970Y016750D01* 316 | X003160Y017560D01* 317 | X003100Y017600D01* 318 | X002350Y018820D02* 319 | X004150Y020620D01* 320 | X009280Y020620D01* 321 | X009317Y020675D01* 322 | X009280Y019450D02* 323 | X009317Y019415D01* 324 | X009280Y019450D02* 325 | X003970Y019450D01* 326 | X006310Y016750D02* 327 | X007030Y017470D01* 328 | X009280Y017470D01* 329 | X009317Y017525D01* 330 | X009317Y017840D02* 331 | X009370Y017920D01* 332 | X009730Y017920D01* 333 | X010360Y018550D01* 334 | X009317Y018470D02* 335 | X009280Y018460D01* 336 | X007390Y018460D01* 337 | X008740Y018100D02* 338 | X009280Y018100D01* 339 | X009317Y018155D01* 340 | X010025Y016817D02* 341 | X010000Y016750D01* 342 | X010000Y016210D01* 343 | X013960Y016930D02* 344 | X013960Y017470D01* 345 | X013883Y017525D01* 346 | X013883Y018785D02* 347 | X013960Y018820D01* 348 | X014950Y018820D01* 349 | X015670Y019540D01* 350 | X015726Y019600D01* 351 | X015760Y019630D01* 352 | X015760Y020080D01* 353 | X015220Y020080D01* 354 | X015760Y020080D02* 355 | X015760Y020530D01* 356 | X015726Y020600D01* 357 | X016120Y020890D02* 358 | X016120Y020980D01* 359 | X016030Y021070D01* 360 | X015400Y021070D01* 361 | X016120Y020890D02* 362 | X016390Y020620D01* 363 | X016474Y020600D01* 364 | X015726Y017600D02* 365 | X015760Y017560D01* 366 | X016210Y017110D01* 367 | X012160Y012700D02* 368 | X011800Y012340D01* 369 | X011440Y012340D01* 370 | X011170Y012610D01* 371 | D16* 372 | X010000Y016210D03* 373 | X008740Y018100D03* 374 | X010360Y018550D03* 375 | X011980Y020080D03* 376 | X015220Y020080D03* 377 | X016390Y011980D03* 378 | X004060Y019990D03* 379 | M02* 380 | -------------------------------------------------------------------------------- /kanji_test_OLED.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #define ASC8x16S 255968 7 | #define ASC8x16N 257504 8 | #define kanji_CS 4 9 | byte rawdata[32]; 10 | int i=0; 11 | 12 | // SPI PIN definition. Change to fit your board.... 13 | #define OLED_MOSI 5 14 | #define OLED_CLK 7 15 | #define OLED_DC 19 16 | #define OLED_CS 18 17 | #define OLED_RESET 20 18 | //Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); 19 | Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS); 20 | unsigned long calcAddr(unsigned short jiscode) { 21 | unsigned long MSB; 22 | unsigned long LSB; 23 | unsigned long Address; 24 | MSB = (jiscode >> 8) - 0x20; 25 | LSB = (jiscode & 0xff) -0x20; 26 | if(MSB >=1 && MSB <= 15 && LSB >=1 && LSB <= 94) 27 | Address =( (MSB - 1) * 94 + (LSB - 01))*32; 28 | else if(MSB >=16 && MSB <= 47 && LSB >=1 && LSB <= 94) 29 | Address =( (MSB - 16) * 94 + (LSB - 1))*32+43584; 30 | else if(MSB >=48 && MSB <=84 && LSB >=1 && LSB <= 94) 31 | Address = ((MSB - 48) * 94 + (LSB - 1))*32+ 138464; 32 | else if(MSB ==85 && LSB >=0x01 && LSB <= 94) 33 | Address = ((MSB - 85) * 94 + (LSB - 1))*32+ 246944; 34 | else if(MSB >=88 && MSB <=89 && LSB >=1 && LSB <= 94) 35 | Address = ((MSB - 88) * 94 + (LSB - 1))*32+ 249952; 36 | 37 | return Address; 38 | } 39 | 40 | void getCharData(unsigned short code) { 41 | byte data; 42 | unsigned long addr=0; 43 | byte n; 44 | addr =calcAddr(code); 45 | n = 32; 46 | digitalWrite(kanji_CS, HIGH); 47 | delayMicroseconds(4); 48 | digitalWrite(kanji_CS, LOW); 49 | SPI.transfer(0x03); 50 | SPI.transfer((addr>>16) & 0xff); 51 | SPI.transfer((addr>>8) & 0xff); 52 | SPI.transfer(addr & 0xff); 53 | for(byte i = 0;i< n; i++) { 54 | rawdata[i] = SPI.transfer(0x00); 55 | } 56 | digitalWrite(kanji_CS, HIGH); 57 | } 58 | 59 | void displayChar(unsigned short code, unsigned int offset_x,unsigned int offset_y) { 60 | offset_x=offset_x*16; 61 | offset_y=offset_y*16; 62 | getCharData(code); 63 | for(int x=0; x<32; x++) 64 | { 65 | for(int y=0; y<8; y++) 66 | { 67 | if (rawdata[x] & (1<>4)) + offset_y, WHITE); 69 | else 70 | display.drawPixel(x%16 + offset_x, y+(8*(x>>4)) + offset_y, BLACK); 71 | } 72 | } 73 | display.display(); 74 | } 75 | 76 | void setup() { 77 | pinMode(kanji_CS,OUTPUT); 78 | SPI.begin(); 79 | Serial.begin(4800); 80 | display.begin(); 81 | display.display(); 82 | display.clearDisplay(); 83 | display.fillScreen(0); 84 | display.clearDisplay(); 85 | } 86 | 87 | void loop() { 88 | int count; 89 | int count1,count2,count3,count4; 90 | count=i%4; 91 | 92 | displayChar(0x467c,0,count); 93 | displayChar(0x4B5c,1,count); 94 | displayChar(0x386C,2,count); 95 | displayChar(0x242A,3,count); 96 | displayChar(0x2141,4,count); 97 | displayChar(0x2431,5,count); 98 | displayChar(0x2141,6,count); 99 | displayChar(0x212A,7,count); 100 | 101 | count1=count+1; 102 | if(count1>3){ 103 | count1=count1-4; 104 | } 105 | displayChar(0x3441,0,count1); 106 | displayChar(0x3B7A,1,count1); 107 | displayChar(0x256D,2,count1); 108 | displayChar(0x2560,3,count1); 109 | displayChar(0x456B,4,count1); 110 | displayChar(0x3A5C,5,count1); 111 | displayChar(0x2443,6,count1); 112 | displayChar(0x2439,7,count1); 113 | 114 | count2=count+2; 115 | if(count2>3){ 116 | count2=count2-4; 117 | } 118 | displayChar(0x2338,0,count2); 119 | displayChar(0x215F,1,count2); 120 | displayChar(0x2334,2,count2); 121 | displayChar(0x4A38,3,count2); 122 | displayChar(0x3B7A,4,count2); 123 | displayChar(0x493D,5,count2); 124 | displayChar(0x3C28,6,count2); 125 | displayChar(0x212A,7,count2); 126 | 127 | 128 | count3=count+3; 129 | if(count3>3){ 130 | count3=count3-4; 131 | } 132 | displayChar(0x4954,0,count3); 133 | displayChar(0x597A,1,count3); 134 | displayChar(0x4954,2,count3); 135 | displayChar(0x367E,3,count3); 136 | displayChar(0x3140,4,count3); 137 | displayChar(0x3330,5,count3); 138 | displayChar(0x4173,6,count3); 139 | displayChar(0x4537,7,count3); 140 | 141 | i++; 142 | delay(2000); 143 | } 144 | -------------------------------------------------------------------------------- /morse_encode_decode.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | //////////////// Newly added for graphic OLED(LCD) 128x64 support///////////// 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | // SPI PIN definition. Change to fit your board.... 12 | #define OLED_MOSI 5 13 | #define OLED_CLK 7 14 | #define OLED_DC 19 15 | #define OLED_CS 18 16 | #define OLED_RESET 20 17 | Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); 18 | 19 | 20 | int screenMem[168]; //the implementation of frame buffer is referenced from Ben Heck's 21 | int cursorX = 0; //Retro BASIC computer's source 22 | int checkChar = 0; 23 | int wpm = 13; 24 | 25 | ////////////////////////////////////////////////////////////////////////////// 26 | //////////////////////////////////////////////////////////////////////////////// 27 | // ASCII Characters 28 | #define CR '\r' 29 | #define NL '\n' 30 | #define LF 0x0a 31 | #define TAB '\t' 32 | #define BELL '\b' 33 | #define SPACE ' ' 34 | #define SQUOTE '\'' 35 | #define DQUOTE '\"' 36 | #define CTRLC 0x1B // Changed to ESC key (27 - 0x1B) 37 | #define CTRLH 0x08 38 | #define CTRLS 0x13 39 | #define CTRLX 0x18 40 | 41 | static const unsigned char initmsg[] PROGMEM = "Morse EnDecoder"; 42 | static const unsigned char wpmsg[] PROGMEM = "Current wpm is "; 43 | static const unsigned char errormsg[] PROGMEM = "< ERROR:too many morse signals! >"; 44 | 45 | // Pin mapping 46 | const byte morseInPin = 10; 47 | const byte morseOutPin = 11; 48 | 49 | // Instantiate Morse objects 50 | morseDecoder morseInput(morseInPin, MORSE_KEYER, MORSE_ACTIVE_LOW); 51 | morseEncoder morseOutput(morseOutPin); 52 | 53 | void setup() 54 | { 55 | Serial.begin(4800); 56 | display.begin(); 57 | // init done 58 | display.display(); 59 | display.clearDisplay(); 60 | display.setTextSize(1); 61 | display.setTextColor(WHITE); 62 | display.setCursor(0,0); 63 | for (int xg = 0 ; xg < 169 ; xg++) { 64 | screenMem[xg] = 32; 65 | } 66 | // setOutputHandler(&lcdChar); 67 | printmsg(initmsg); 68 | doFrame(147); 69 | printmsg(initmsg); 70 | // printmsg(wpmsg); 71 | // printmsg(char(wpm)); 72 | 73 | morseInput.setspeed(wpm); 74 | morseOutput.setspeed(wpm); 75 | } 76 | 77 | 78 | void loop() 79 | { 80 | // Need to call these once per loop 81 | 82 | 83 | morseOutput.encode(); 84 | // SEND MORSE (OUTPUT) 85 | // Encode and send text received from the serial port (serial monitor) 86 | if (morseOutput.available()) 87 | { 88 | // Get character from serial and send as Morse code 89 | char sendMorse = Serial.read(); 90 | morseOutput.write(sendMorse); 91 | //Serial.print(sendMorse); 92 | lcdChar(sendMorse); 93 | } 94 | 95 | morseInput.decode(); 96 | // RECEIVE MORSE (INPUT) 97 | // If a character is decoded from the input, write it to serial port 98 | if (morseInput.available()) 99 | { 100 | char receivedMorse = morseInput.read(); 101 | lcdChar(receivedMorse); 102 | if(receivedMorse != 0xFF){ 103 | Serial.print(receivedMorse); 104 | // A little error checking 105 | if (receivedMorse == '#') printmsg(errormsg); 106 | } 107 | } 108 | } 109 | 110 | 111 | static void outchar(unsigned char c) 112 | { 113 | lcdChar(c); 114 | } 115 | 116 | static void lcdChar(unsigned int c) { 117 | if(c <= 128){ 118 | if (c == 8) { //Backspace? 119 | 120 | if (cursorX > 0) { 121 | 122 | cursorX -= 1; 123 | screenMem[147 + cursorX] = 32; 124 | doFrame(147 + cursorX); 125 | 126 | } 127 | 128 | } 129 | 130 | if (c != 13 and c != 10 and c != 8) { 131 | 132 | screenMem[147 + cursorX] = c; 133 | cursorX += 1; 134 | if (cursorX < 21) { 135 | display.setCursor(cursorX*6,8*7); 136 | display.write(c); 137 | display.display(); 138 | } 139 | 140 | } 141 | 142 | if (cursorX == 21 or c == 10) { 143 | 144 | for (int xg = 21 ; xg > 0 ; xg--) { 145 | 146 | screenMem[0 + xg] = screenMem[21 + xg]; 147 | screenMem[21 + xg] = screenMem[42 + xg]; 148 | screenMem[42 + xg] = screenMem[63 + xg]; 149 | screenMem[63 + xg] = screenMem[84 + xg]; 150 | screenMem[84 + xg] = screenMem[105 + xg]; 151 | screenMem[105 + xg] = screenMem[126 + xg]; 152 | screenMem[126 + xg] = screenMem[147 + xg]; 153 | 154 | 155 | 156 | screenMem[147 + xg] = 32; 157 | 158 | 159 | } 160 | 161 | cursorX = 0; 162 | 163 | doFrame(147); 164 | 165 | } 166 | 167 | 168 | } 169 | } 170 | 171 | static void doFrame(byte amount) { 172 | int xposi,yposi,yshift; 173 | display.clearDisplay(); 174 | for (int xg = 0 ; xg < amount ; xg++) { 175 | yshift=int(xg/21.0); 176 | yposi=yshift*8; 177 | xposi=(xg-yshift*21)*6; 178 | display.setCursor(xposi,yposi); 179 | display.write(screenMem[xg]); 180 | } 181 | display.display(); 182 | } 183 | 184 | /***************************************************************************/ 185 | void printmsgNoNL(const unsigned char *msg) 186 | { 187 | while( pgm_read_byte( msg ) != 0 ) { 188 | outchar( pgm_read_byte( msg++ ) ); 189 | }; 190 | } 191 | 192 | /***************************************************************************/ 193 | void printmsg(const unsigned char *msg) 194 | { 195 | printmsgNoNL(msg); 196 | line_terminator(); 197 | } 198 | 199 | static void line_terminator(void) 200 | { 201 | outchar(NL); 202 | outchar(CR); 203 | } 204 | -------------------------------------------------------------------------------- /oled_pattern.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodera2t/tinyBASIC_OLED/9a7f111805d1996531d66d6a065e12cdd181add6/oled_pattern.jpg -------------------------------------------------------------------------------- /oled_sch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodera2t/tinyBASIC_OLED/9a7f111805d1996531d66d6a065e12cdd181add6/oled_sch.jpg -------------------------------------------------------------------------------- /simple_nihongo_reader_OLED.ino: -------------------------------------------------------------------------------- 1 | //// Simple Nihongo(Japanese) text reader 2 | //// consisting of.... ATMega1284P, OLED-display (SPI), japanese font SPI-ROM (GT20L16J1Y) 3 | //// Author: kodera2t May 16, 2015. this software is distributed under LGPL. 4 | /// usage: Put plain Japanese (JIS0208-coded) text on Fat formatted SD card. Half-width(single byte) 5 | /// character, including 0x20 in text file will lead to display error. 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #define ASC8x16S 255968 13 | #define ASC8x16N 257504 14 | #define kanji_CS 4 15 | #define kSD_CS 13 16 | byte rawdata[32]; 17 | 18 | byte read_char=0x00, old_char; 19 | int count=0; 20 | boolean flag=false; 21 | long unsigned int charact=0,i=0; 22 | boolean jp_flag=false; 23 | int xpos, ypos; 24 | // SPI PIN definition. Change to fit your board.... 25 | #define OLED_MOSI 5 26 | #define OLED_CLK 7 27 | #define OLED_DC 19 28 | #define OLED_CS 18 29 | #define OLED_RESET 20 ///v3:22, v2:20 30 | //Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); 31 | Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS); 32 | 33 | 34 | unsigned long calcAddr(unsigned short jiscode) { 35 | unsigned long MSB; 36 | unsigned long LSB; 37 | unsigned long Address; 38 | MSB = (jiscode >> 8) - 0x20; 39 | LSB = (jiscode & 0xff) -0x20; 40 | if(MSB >=1 && MSB <= 15 && LSB >=1 && LSB <= 94) 41 | Address =( (MSB - 1) * 94 + (LSB - 01))*32; 42 | else if(MSB >=16 && MSB <= 47 && LSB >=1 && LSB <= 94) 43 | Address =( (MSB - 16) * 94 + (LSB - 1))*32+43584; 44 | else if(MSB >=48 && MSB <=84 && LSB >=1 && LSB <= 94) 45 | Address = ((MSB - 48) * 94 + (LSB - 1))*32+ 138464; 46 | else if(MSB ==85 && LSB >=0x01 && LSB <= 94) 47 | Address = ((MSB - 85) * 94 + (LSB - 1))*32+ 246944; 48 | else if(MSB >=88 && MSB <=89 && LSB >=1 && LSB <= 94) 49 | Address = ((MSB - 88) * 94 + (LSB - 1))*32+ 249952; 50 | 51 | return Address; 52 | } 53 | 54 | void getCharData(unsigned short code) { 55 | byte data; 56 | unsigned long addr=0; 57 | byte n; 58 | addr =calcAddr(code); 59 | n = 32; 60 | digitalWrite(kanji_CS, HIGH); 61 | delayMicroseconds(4); 62 | digitalWrite(kanji_CS, LOW); 63 | SPI.transfer(0x03); 64 | SPI.transfer((addr>>16) & 0xff); 65 | SPI.transfer((addr>>8) & 0xff); 66 | SPI.transfer(addr & 0xff); 67 | for(byte i = 0;i< n; i++) { 68 | rawdata[i] = SPI.transfer(0x00); 69 | } 70 | digitalWrite(kanji_CS, HIGH); 71 | } 72 | 73 | void displayChar(unsigned short code, unsigned int offset_x,unsigned int offset_y) { 74 | offset_x=offset_x*16; 75 | offset_y=offset_y*16; 76 | getCharData(code); 77 | for(int x=0; x<32; x++) 78 | { 79 | for(int y=0; y<8; y++) 80 | { 81 | if (rawdata[x] & (1<>4)) + offset_y, WHITE); 83 | else 84 | display.drawPixel(x%16 + offset_x, y+(8*(x>>4)) + offset_y, BLACK); 85 | } 86 | } 87 | display.display(); 88 | } 89 | 90 | void setup() { 91 | pinMode(SS, OUTPUT); 92 | SPI.begin(); 93 | Serial.begin(4800); 94 | display.begin(); 95 | display.display(); 96 | display.clearDisplay(); 97 | display.fillScreen(0); 98 | display.clearDisplay(); 99 | if (!SD.begin(kSD_CS)) { 100 | Serial.println("Card failed, or not present"); 101 | while(1); 102 | } 103 | Serial.println("ok"); 104 | 105 | 106 | } 107 | 108 | void loop() { 109 | File dataFile = SD.open("test3.txt"); 110 | if (dataFile) { 111 | while (dataFile.available()) { 112 | old_char=read_char; 113 | read_char=dataFile.read(); 114 | if(i>3){ 115 | if(i%2==0){ 116 | charact=(old_char<<8)|read_char; 117 | xpos=count-(count/8)*8; 118 | ypos=count/8; 119 | displayChar(charact,xpos,ypos); 120 | count++;//character number 121 | } 122 | } 123 | if(count==32){ 124 | delay(7000); 125 | count=0; 126 | } 127 | i++; 128 | } 129 | dataFile.close(); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /toyoshiki-tinybasic/ttbasic.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TOYOSHIKI Tiny BASIC for Arduino 3 | (C)2012 Tetsuya Suzuki 4 | GNU General Public License 5 | */ 6 | /// Feb. 12, 2015 Kodera2t SPI OLED(SSD1306) frame buffer support is added.. 7 | 8 | 9 | #include "ttbasic.h" 10 | 11 | //////////////// Newly added for graphic OLED(LCD) 128x64 support///////////// 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | // SPI PIN definition. Change to fit your board.... 18 | #define OLED_MOSI 5 19 | #define OLED_CLK 7 20 | #define OLED_DC 19 21 | #define OLED_CS 18 22 | #define OLED_RESET 20 23 | Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS); 24 | 25 | // ASCII Characters 26 | #define CR '\r' 27 | #define NL '\n' 28 | #define LF 0x0a 29 | #define TAB '\t' 30 | #define BELL '\b' 31 | #define SPACE ' ' 32 | #define SQUOTE '\'' 33 | #define DQUOTE '\"' 34 | #define CTRLC 0x1B // Changed to ESC key (27 - 0x1B) 35 | #define CTRLH 0x08 36 | #define CTRLS 0x13 37 | #define CTRLX 0x18 38 | 39 | int screenMem[168]; //the implementation of frame buffer is referenced from Ben Heck's 40 | int cursorX = 0; //Retro BASIC computer's source 41 | int checkChar = 0; 42 | static void doFrame(byte amount); 43 | static void lcdChar(byte c); 44 | 45 | ////////////////////////////////////////////////////////////////////////////// 46 | 47 | 48 | 49 | // Depending on device functions 50 | // TO-DO Rewrite these functions to fit your machine 51 | // And see 'getrnd()' 52 | 53 | #define c_putch(c) lcdChar(c) 54 | #define c_getch( ) Serial.read() 55 | #define c_kbhit( ) Serial.available() 56 | 57 | void newline(void){ 58 | c_putch(NL); 59 | // c_putch(10); //LF 60 | } 61 | 62 | 63 | 64 | 65 | 66 | // TOYOSHIKI TinyBASIC symbols 67 | // TO-DO Rewrite defined values to fit your machine as needed 68 | #define SIZE_LINE 80 //Command line buffer length + NULL 69 | #define SIZE_IBUF 80 //i-code conversion buffer size 70 | #define SIZE_LIST 256 //List buffer size 71 | #define SIZE_ARRY 32 //Array area size 72 | #define SIZE_GSTK 6 //GOSUB stack size(2/nest) 73 | #define SIZE_LSTK 15 //FOR stack size(5/nest) 74 | 75 | // RAM mapping 76 | char lbuf[SIZE_LINE]; //Command line buffer 77 | unsigned char ibuf[SIZE_IBUF]; //i-code conversion buffer 78 | short var[26]; //Variable area 79 | short arr[SIZE_ARRY]; //Array area 80 | unsigned char listbuf[SIZE_LIST]; //List area 81 | unsigned char* clp; //Pointer current line 82 | unsigned char* cip; //Pointer current Intermediate code 83 | unsigned char* gstk[SIZE_GSTK]; //GOSUB stack 84 | unsigned char gstki; //GOSUB stack index 85 | unsigned char* lstk[SIZE_LSTK]; //FOR stack 86 | unsigned char lstki; //FOR stack index 87 | 88 | // Keyword table 89 | const char* kwtbl[] = { 90 | "GOTO", "GOSUB", "RETURN", 91 | "FOR", "TO", "STEP", "NEXT", 92 | "IF", "REM", "STOP", 93 | "INPUT", "PRINT", "LET", 94 | ",", ";", 95 | "-", "+", "*", "/", "(", ")", 96 | ">=", "#", ">", "=", "<=", "<", 97 | "@", "RND", "ABS", "SIZE", 98 | "LIST", "RUN", "NEW" 99 | }; 100 | 101 | // Keyword count 102 | #define SIZE_KWTBL (sizeof(kwtbl) / sizeof(const char*)) 103 | 104 | // i-code(Intermediate code) assignment 105 | enum{ 106 | I_GOTO, I_GOSUB, I_RETURN, 107 | I_FOR, I_TO, I_STEP, I_NEXT, 108 | I_IF, I_REM, I_STOP, 109 | I_INPUT, I_PRINT, I_LET, 110 | I_COMMA, I_SEMI, 111 | I_MINUS, I_PLUS, I_MUL, I_DIV, I_OPEN, I_CLOSE, 112 | I_GTE, I_SHARP, I_GT, I_EQ, I_LTE, I_LT, 113 | I_ARRAY, I_RND, I_ABS, I_SIZE, 114 | I_LIST, I_RUN, I_NEW, 115 | I_NUM, I_VAR, I_STR, 116 | I_EOL 117 | }; 118 | 119 | // List formatting condition 120 | #define IS_OP(p) (p >= I_MINUS && p <= I_LT) // Operator style 121 | #define IS_SEP(p) (p == I_COMMA || p == I_SEMI) // Separator style 122 | #define IS_TOKSP(p) (/*p >= I_GOTO && */p <= I_LET && p != I_RETURN) // Token style 123 | 124 | // Error messages 125 | unsigned char err;// Error message index 126 | const char* errmsg[] ={ 127 | "OK", 128 | "Devision by zero", 129 | "Overflow", 130 | "Subscript out of range", 131 | "Icode buffer full", 132 | "List full", 133 | "GOSUB too many nested", 134 | "RETURN stack underflow", 135 | "FOR too many nested", 136 | "NEXT without FOR", 137 | "NEXT without counter", 138 | "NEXT mismatch FOR", 139 | "FOR without variable", 140 | "FOR without TO", 141 | "LET without variable", 142 | "IF without condition", 143 | "Undefined line number", 144 | "\'(\' or \')\' expected", 145 | "\'=\' expected", 146 | "Illegal command", 147 | "Syntax error", 148 | "Internal error", 149 | "Abort by [ESC]" 150 | }; 151 | 152 | // Error code assignment 153 | enum{ 154 | ERR_OK, 155 | ERR_DIVBY0, 156 | ERR_VOF, 157 | ERR_SOL, 158 | ERR_IBUFOF, 159 | ERR_LBUFOF, 160 | ERR_GSTKOF, 161 | ERR_GSTKUF, 162 | ERR_LSTKOF, 163 | ERR_LSTKUF, 164 | ERR_NEXTWOV, 165 | ERR_NEXTUM, 166 | ERR_FORWOV, 167 | ERR_FORWOTO, 168 | ERR_LETWOV, 169 | ERR_IFWOC, 170 | ERR_ULN, 171 | ERR_PAREN, 172 | ERR_VWOEQ, 173 | ERR_COM, 174 | ERR_SYNTAX, 175 | ERR_SYS, 176 | ERR_ESC 177 | }; 178 | 179 | // Standard C libraly (about same) functions 180 | #define c_toupper(c) (c <= 'z' && c >= 'a' ? c - 32 : c) 181 | #define c_isprint(c) (c >= 32 && c <= 126) 182 | #define c_isspace(c) (c <= ' ' &&(c == ' ' || (c <= 13 && c >= 9))) 183 | #define c_isdigit(c) (c <= '9' && c >= '0') 184 | #define c_isalpha(c) ((c <= 'z' && c >= 'a') || (c <= 'Z' && c >= 'A')) 185 | 186 | char* c_strchr(char *s, char c){ 187 | while(*s) { 188 | if(*s == c) return (s); 189 | ++s; 190 | } 191 | return NULL; 192 | } 193 | 194 | void c_puts(const char *s) { 195 | while(*s) c_putch(*s++); 196 | } 197 | 198 | void c_gets(){ 199 | char c; 200 | unsigned char len; 201 | 202 | len = 0; 203 | while((c = c_getch()) != NL){ 204 | if( c == 9) c = ' '; // TAB exchange Space 205 | if((c == 8) && (len > 0)){ // Backspace manipulation 206 | len--; 207 | c_putch(8); 208 | c_putch(' '); 209 | c_putch(8); 210 | } 211 | else 212 | if(c_isprint(c) && (len < (SIZE_LINE - 1))){ 213 | lbuf[len++] = c; 214 | c_putch(c); 215 | } 216 | } 217 | newline(); 218 | lbuf[len] = 0; // Put NULL 219 | 220 | if(len > 0){ 221 | while(c_isspace(lbuf[--len])); // Skip space 222 | lbuf[++len] = 0; // Put NULL 223 | } 224 | } 225 | 226 | // GOSUB-RETURN stack 227 | void gpush(unsigned char* pd){ 228 | if(gstki < SIZE_GSTK){ 229 | gstk[gstki++] = pd; 230 | return; 231 | } 232 | err = ERR_GSTKOF; 233 | } 234 | 235 | unsigned char* gpop(){ 236 | if(gstki > 0){ 237 | return gstk[--gstki]; 238 | } 239 | err = ERR_GSTKUF; 240 | return NULL; 241 | } 242 | 243 | // FOR-NEXT stack 244 | void lpush(unsigned char* pd){ 245 | if(lstki < SIZE_LSTK){ 246 | lstk[lstki++] = pd; 247 | return; 248 | } 249 | err = ERR_LSTKOF; 250 | } 251 | 252 | unsigned char* lpop(){ 253 | if(lstki > 0){ 254 | return lstk[--lstki]; 255 | } 256 | err = ERR_LSTKUF; 257 | return NULL; 258 | } 259 | 260 | // Print OK or error message 261 | void error() 262 | { 263 | newline(); 264 | c_puts(errmsg[err]); 265 | newline(); 266 | err = 0; 267 | } 268 | 269 | // Print numeric specified columns 270 | void putnum(short value, short d){ 271 | unsigned char i; 272 | unsigned char sign; 273 | 274 | if(value < 0){ 275 | sign = 1; 276 | value = -value; 277 | } 278 | else { 279 | sign = 0; 280 | } 281 | 282 | lbuf[6] = 0; 283 | i = 6; 284 | do { 285 | lbuf[--i] = (value % 10) + '0'; 286 | value /= 10; 287 | } 288 | while(value > 0); 289 | 290 | if(sign) 291 | lbuf[--i] = '-'; 292 | 293 | //String length = 6 - i 294 | while(6 - i < d){ // If short 295 | c_putch(' '); // Fill space 296 | d--; 297 | } 298 | c_puts(&lbuf[i]); 299 | } 300 | 301 | // Input numeric and return value 302 | // Called by only INPUT statement 303 | short getnum(){ 304 | short value, tmp; 305 | char c; 306 | unsigned char len; 307 | unsigned char sign; 308 | 309 | len = 0; 310 | while((c = c_getch()) != 13){ 311 | if((c == 8) && (len > 0)){ // Backspace manipulation 312 | len--; 313 | c_putch(8); 314 | c_putch(' '); 315 | c_putch(8); 316 | } 317 | else 318 | if( (len == 0 && (c == '+' || c == '-')) || 319 | (len < 6 && c_isdigit(c))){ // Numeric or sign only 320 | lbuf[len++] = c; 321 | c_putch(c); 322 | } 323 | } 324 | newline(); 325 | lbuf[len] = 0; 326 | 327 | switch(lbuf[0]){ 328 | case '-': 329 | sign = 1; 330 | len = 1; 331 | break; 332 | case '+': 333 | sign = 0; 334 | len = 1; 335 | break; 336 | default: 337 | sign = 0; 338 | len = 0; 339 | break; 340 | } 341 | 342 | value = 0; // Initialize value 343 | tmp = 0; // Temp value 344 | while(lbuf[len]){ 345 | tmp = 10 * value + lbuf[len++] - '0'; 346 | if(value > tmp){ // It means overflow 347 | err = ERR_VOF; 348 | } 349 | value = tmp; 350 | } 351 | if(sign) 352 | return -value; 353 | return value; 354 | } 355 | 356 | // Byte X,L,H -> Short HL 357 | // Used to get line number or I_NUM value 358 | short getvalue(unsigned char* ip){ 359 | if(*ip == 0) 360 | return 32767; // Case X = 0 361 | return((short)*(ip + 1) + ((short)*(ip + 2) << 8)); 362 | } 363 | 364 | // Get argument in parenthesis 365 | short getparam(){ 366 | short value; 367 | 368 | if(*cip != I_OPEN){ 369 | err = ERR_PAREN; 370 | return 0; 371 | } 372 | cip++; 373 | value = iexp(); 374 | if(err) return 0; 375 | 376 | if(*cip != I_CLOSE){ 377 | err = ERR_PAREN; 378 | return 0; 379 | } 380 | cip++; 381 | 382 | return value; 383 | } 384 | 385 | // Search line by line number 386 | unsigned char* getlp(short lineno){ 387 | unsigned char *lp; 388 | 389 | lp = listbuf; 390 | while(*lp){ 391 | if(getvalue(lp) >= lineno) 392 | break; 393 | lp += *lp; 394 | } 395 | return lp; 396 | } 397 | 398 | // Convert token to i-code 399 | // Return byte length or 0 400 | unsigned char toktoi(){ 401 | unsigned char i; // Loop counter(i-code sometime) 402 | unsigned char len; //byte counter 403 | short value; 404 | short tmp; 405 | char* pkw; // Temporary keyword pointer 406 | char* ptok; // Temporary token pointer 407 | char c; // Surround the string character, " or ' 408 | char* s; // Pointer to charactor at line buffer 409 | 410 | s = lbuf; 411 | len = 0; // Clear byte length 412 | while(*s){ 413 | while(c_isspace(*s)) s++; // Skip space 414 | 415 | //Try keyword conversion 416 | for(i = 0; i < SIZE_KWTBL; i++){ 417 | pkw = (char *)kwtbl[i]; // Point keyword 418 | ptok = s; // Point top of command line 419 | // Compare 420 | while((*pkw != 0) && (*pkw == c_toupper(*ptok))){ 421 | pkw++; 422 | ptok++; 423 | } 424 | if(*pkw == 0){// Case success 425 | // i have i-code 426 | if(len >= SIZE_IBUF - 1){// List area full 427 | err = ERR_IBUFOF; 428 | return 0; 429 | } 430 | ibuf[len++] = i; 431 | s = ptok; 432 | break; 433 | } 434 | } 435 | 436 | // Case statement needs an argument except numeric, valiable, or strings 437 | switch(i){ 438 | case I_REM: 439 | while(c_isspace(*s)) s++; // Skip space 440 | ptok = s; 441 | for(i = 0; *ptok++; i++); // Get length 442 | if(len >= SIZE_IBUF - 2 - i){ 443 | err = ERR_IBUFOF; 444 | return 0; 445 | } 446 | ibuf[len++] = i; // Put length 447 | while(i--){ // Copy strings 448 | ibuf[len++] = *s++; 449 | } 450 | return len; 451 | default: 452 | break; 453 | } 454 | 455 | if(*pkw != 0){ // Case not keyword 456 | ptok = s; // Point top of command line 457 | 458 | // Try numeric conversion 459 | if(c_isdigit(*ptok)){ 460 | value = 0; 461 | tmp = 0; 462 | do{ 463 | tmp = 10 * value + *ptok++ - '0'; 464 | if(value > tmp){ 465 | err = ERR_VOF; 466 | return 0; 467 | } 468 | value = tmp; 469 | } 470 | while(c_isdigit(*ptok)); 471 | 472 | if(len >= SIZE_IBUF - 3){ 473 | err = ERR_IBUFOF; 474 | return 0; 475 | } 476 | s = ptok; 477 | ibuf[len++] = I_NUM; 478 | ibuf[len++] = value & 255; 479 | ibuf[len++] = value >> 8; 480 | } 481 | else 482 | 483 | // Try valiable conversion 484 | if(c_isalpha(*ptok)){ 485 | if(len >= SIZE_IBUF - 2){ 486 | err = ERR_IBUFOF; 487 | return 0; 488 | } 489 | if(len >= 2 && ibuf[len -2] == I_VAR){ // Case series of variables 490 | err = ERR_SYNTAX; // Syntax error 491 | return 0; 492 | } 493 | ibuf[len++] = I_VAR; // Put i-code 494 | ibuf[len++] = c_toupper(*ptok) - 'A'; // Put index of valiable area 495 | s++; 496 | } 497 | else 498 | 499 | // Try string conversion 500 | if(*s == '\"' || *s == '\''){// If start of string 501 | c = *s; 502 | s++; // Skip " or ' 503 | ptok = s; 504 | for(i = 0; (*ptok != c) && c_isprint(*ptok); i++) // Get length 505 | ptok++; 506 | if(len >= SIZE_IBUF - 1 - i){ // List area full 507 | err = ERR_IBUFOF; 508 | return 0; 509 | } 510 | ibuf[len++] = I_STR; // Put i-code 511 | ibuf[len++] = i; // Put length 512 | while(i--){ // Put string 513 | ibuf[len++] = *s++; 514 | } 515 | if(*s == c) s++; // Skip " or ' 516 | 517 | // Nothing mutch 518 | } 519 | else { 520 | err = ERR_SYNTAX; 521 | return 0; 522 | } 523 | } 524 | } 525 | ibuf[len++] = I_EOL; // Put end of line 526 | return len; // Return byte length 527 | } 528 | 529 | //Listing 1 line of i-code 530 | void putlist(unsigned char* ip){ 531 | unsigned char i; 532 | short value; 533 | 534 | while(*ip != I_EOL){ 535 | // Case keyword 536 | if(*ip < SIZE_KWTBL){ 537 | c_puts(kwtbl[*ip]); 538 | if(IS_TOKSP(*ip) || *ip == I_SEMI)c_putch(' '); 539 | if(*ip == I_REM){ 540 | ip++; 541 | i = *ip++; 542 | while(i--){ 543 | c_putch(*ip++); 544 | } 545 | return; 546 | } 547 | ip++; 548 | } 549 | else 550 | 551 | // Case numeric 552 | if(*ip == I_NUM){ 553 | putnum(getvalue(ip), 0); 554 | ip += 3; 555 | if(!IS_OP(*ip) && !IS_SEP(*ip)) c_putch(' '); 556 | } 557 | else 558 | 559 | // Case valiable 560 | if(*ip == I_VAR){ 561 | ip++; 562 | c_putch(*ip++ + 'A'); 563 | if(!IS_OP(*ip) && !IS_SEP(*ip)) c_putch(' '); 564 | } 565 | else 566 | 567 | // Case string 568 | if(*ip == I_STR){ 569 | ip++; 570 | value = 0; 571 | i = *ip; 572 | while(i--){ 573 | if(*(ip + i + 1) == '\"') 574 | value = 1; 575 | } 576 | if(value) c_putch('\''); 577 | else c_putch('\"'); 578 | i = *ip++; 579 | while(i--){ 580 | c_putch(*ip++); 581 | } 582 | if(value) c_putch('\''); 583 | else c_putch('\"'); 584 | 585 | // Nothing match, I think, such case is impossible 586 | } 587 | else { 588 | err = ERR_SYS; 589 | return; 590 | } 591 | } 592 | } 593 | 594 | // Insert i-code to the list 595 | void inslist(){ 596 | unsigned char len; 597 | unsigned char *lp1, *lp2; 598 | 599 | cip = ibuf; 600 | clp = getlp(getvalue(cip)); 601 | 602 | lp1 = clp; 603 | if(getvalue(lp1) == getvalue(cip)){ 604 | // Temporary measures of the case that 605 | // same line numbere exists and list area full, 606 | // existing line is deleted and new line is not inserted in. 607 | 608 | // if((getsize() - *lp1) < *cip){ 609 | // err = ERR_LBUFOF; 610 | // return; 611 | // } 612 | 613 | lp2 = lp1 + *lp1; 614 | while((len = *lp2) != 0){ 615 | while(len--){ 616 | *lp1++ = *lp2++; 617 | } 618 | } 619 | *lp1 = 0; 620 | } 621 | 622 | // Case line number only 623 | if(*cip == 4) 624 | return; 625 | 626 | // Check insertable 627 | while(*lp1){ 628 | lp1 += *lp1; 629 | } 630 | if(*cip > (listbuf + SIZE_LIST - lp1 - 1)){ 631 | err = ERR_LBUFOF; 632 | return; 633 | } 634 | 635 | // Make space 636 | len = lp1 - clp + 1; 637 | lp2 = lp1 + *cip; 638 | while(len--){ 639 | *lp2-- = *lp1--; 640 | } 641 | 642 | // Insert 643 | len = *cip; 644 | while(len--){ 645 | *clp++ = *cip++; 646 | } 647 | } 648 | 649 | // Return free memory 650 | short getsize(){ 651 | short value; 652 | unsigned char* lp; 653 | 654 | lp = listbuf; 655 | while(*lp){ 656 | lp += *lp; 657 | } 658 | 659 | value = listbuf + SIZE_LIST - lp - 1; 660 | return value; 661 | } 662 | 663 | // Return Absolute value 664 | short getabs(){ 665 | short value; 666 | 667 | value = getparam(); 668 | if(err) return 0; 669 | 670 | if(value < 0) value *= -1; 671 | return value; 672 | } 673 | 674 | // Return random number 675 | // TO-DO Rewrite this function to fit your machine 676 | // And see 'irun()' 677 | short getrnd(void){ 678 | short value; 679 | 680 | value = getparam(); 681 | if(err) return 0; 682 | 683 | return (random(value)) + 1; 684 | } 685 | 686 | short getarray() 687 | { 688 | short index; 689 | 690 | index = getparam(); 691 | if(err) return 0; 692 | 693 | if(index < SIZE_ARRY){ 694 | return arr[index]; 695 | } 696 | else { 697 | err = ERR_SOL; 698 | return 0; 699 | } 700 | } 701 | 702 | short ivalue(){ 703 | short value; 704 | 705 | switch(*cip){ 706 | case I_PLUS: 707 | cip++; 708 | value = ivalue(); 709 | break; 710 | case I_MINUS: 711 | cip++; 712 | value = 0 - ivalue(); 713 | break; 714 | case I_VAR: 715 | cip++; 716 | value = var[*cip++]; 717 | break; 718 | case I_NUM: 719 | value = getvalue(cip); 720 | cip += 3; 721 | break; 722 | case I_ARRAY: 723 | cip++; 724 | value = getarray(); 725 | break; 726 | case I_OPEN: 727 | value = getparam(); 728 | break; 729 | case I_RND: 730 | cip++; 731 | value = getrnd(); 732 | break; 733 | case I_ABS: 734 | cip++; 735 | value = getabs(); 736 | break; 737 | case I_SIZE: 738 | cip++; 739 | if(*cip == I_OPEN){ 740 | cip++; 741 | if(*cip == I_CLOSE) 742 | cip++; 743 | else{ 744 | err = ERR_PAREN; 745 | } 746 | } 747 | value = getsize(); 748 | break; 749 | 750 | default: 751 | value = 0; 752 | err = ERR_SYNTAX; 753 | break; 754 | } 755 | return value; 756 | } 757 | 758 | short icalc(){ 759 | short value1, value2; 760 | 761 | value1 = ivalue(); 762 | 763 | while(1){ 764 | if(*cip == I_DIV){ 765 | cip++; 766 | value2 = ivalue(); 767 | if(value2 == 0){ 768 | err = ERR_DIVBY0; 769 | break; 770 | } 771 | value1 /= value2; 772 | } 773 | else 774 | if(*cip == I_MUL){ 775 | cip++; 776 | value2 = ivalue(); 777 | value1 *= value2; 778 | } 779 | else { 780 | break; 781 | } 782 | } 783 | return value1; 784 | } 785 | 786 | short iexp(){ 787 | short value1, value2; 788 | 789 | value1 = icalc(); 790 | 791 | while(*cip == I_PLUS || *cip == I_MINUS){ 792 | value2 = icalc(); 793 | value1 += value2; 794 | } 795 | return value1; 796 | } 797 | 798 | void iprint(){ 799 | short value; 800 | short len; 801 | unsigned char i; 802 | 803 | len = 0; 804 | while(1){ 805 | switch(*cip){ 806 | case I_SEMI: 807 | case I_EOL: 808 | break; 809 | case I_STR: 810 | cip++; 811 | i = *cip++; 812 | while(i--){ 813 | c_putch(*cip++); 814 | } 815 | break; 816 | case I_SHARP: 817 | cip++; 818 | len = iexp(); 819 | if(err) return; 820 | break; 821 | default: 822 | value = iexp(); 823 | if(err) return; 824 | putnum(value, len); 825 | break; 826 | } 827 | 828 | if(*cip == I_COMMA){ 829 | cip++; 830 | } 831 | else{ 832 | break; 833 | } 834 | }; 835 | newline(); 836 | } 837 | 838 | void iinput(){ 839 | unsigned char i; 840 | short value; 841 | short index; 842 | 843 | while(1){ 844 | switch(*cip){ 845 | case I_STR: 846 | cip++; 847 | i = *cip++; 848 | while(i--){ 849 | c_putch(*cip++); 850 | } 851 | if(*cip == I_VAR){ 852 | cip++; 853 | value = getnum(); 854 | var[*cip++] = value; 855 | } 856 | else 857 | if(*cip == I_ARRAY){ 858 | cip++; 859 | index = getparam(); 860 | if(err) return; 861 | if(index >= SIZE_ARRY){ 862 | err = ERR_SOL; 863 | return; 864 | } 865 | value = getnum(); 866 | arr[index] = value; 867 | } 868 | break; 869 | case I_VAR: 870 | cip++; 871 | c_putch(*cip + 'A'); 872 | c_putch(':'); 873 | value = getnum(); 874 | var[*cip++] = value; 875 | break; 876 | case I_ARRAY: 877 | cip++; 878 | index = getparam(); 879 | if(err) 880 | return; 881 | if(index >= SIZE_ARRY){ 882 | err = ERR_SOL; 883 | return; 884 | } 885 | c_putch('@'); 886 | c_putch('('); 887 | putnum(index,0); 888 | c_putch(')'); 889 | c_putch(':'); 890 | value = getnum(); 891 | arr[index] = value; 892 | break; 893 | } 894 | 895 | switch(*cip){ 896 | case I_COMMA: 897 | cip++; 898 | break; 899 | case I_SEMI: 900 | case I_EOL: 901 | return; 902 | default: 903 | err = ERR_SYNTAX; 904 | return; 905 | } 906 | } 907 | } 908 | 909 | char iif(){ 910 | short value1, value2; 911 | unsigned char i; 912 | 913 | value1 = iexp(); 914 | if(err) return -1; 915 | 916 | i = *cip++; 917 | 918 | value2 = iexp(); 919 | if(err) return -1; 920 | 921 | switch(i){ 922 | case I_EQ: 923 | return value1 == value2; 924 | case I_SHARP: 925 | return value1 != value2; 926 | case I_LT: 927 | return value1 < value2; 928 | case I_LTE: 929 | return value1 <= value2; 930 | case I_GT: 931 | return value1 > value2; 932 | case I_GTE: 933 | return value1 >= value2; 934 | default: 935 | err = ERR_IFWOC; 936 | return -1; 937 | } 938 | } 939 | 940 | void ivar(){ 941 | short value; 942 | short index; 943 | 944 | index = *cip++; 945 | if(*cip == I_EQ){ 946 | cip++; 947 | value = iexp(); 948 | if(err) return; 949 | } 950 | else { 951 | err = ERR_VWOEQ; 952 | return; 953 | } 954 | 955 | if(index < 26){ 956 | var[index] = value; 957 | } 958 | else { 959 | err = ERR_SOL; 960 | } 961 | } 962 | 963 | void iarray(){ 964 | short value; 965 | short index; 966 | 967 | index = getparam(); 968 | if(err) return; 969 | if(*cip == I_EQ){ 970 | cip++; 971 | value = iexp(); 972 | if(err) return; 973 | } 974 | else { 975 | err = ERR_VWOEQ; 976 | return; 977 | } 978 | 979 | if(index < SIZE_ARRY){ 980 | arr[index] = value; 981 | } 982 | else { 983 | err = ERR_SOL; 984 | } 985 | } 986 | 987 | void ilet(){ 988 | switch(*cip){ 989 | case I_VAR: 990 | cip++; 991 | ivar(); 992 | break; 993 | case I_ARRAY: 994 | cip++; 995 | iarray(); 996 | break; 997 | default: 998 | err = ERR_LETWOV; 999 | break; 1000 | } 1001 | } 1002 | 1003 | void ilist(){ 1004 | short lineno; 1005 | 1006 | if(*cip == I_NUM){ 1007 | lineno = getvalue(cip); 1008 | cip += 3; 1009 | } 1010 | else { 1011 | lineno = 0; 1012 | } 1013 | 1014 | for( clp = listbuf; 1015 | *clp && (getvalue(clp) < lineno); 1016 | clp += *clp); 1017 | 1018 | while(*clp){ 1019 | putnum(getvalue(clp), 0); 1020 | c_putch(' '); 1021 | putlist(clp + 3); 1022 | if(err){ 1023 | break; 1024 | } 1025 | newline(); 1026 | clp += *clp; 1027 | } 1028 | } 1029 | 1030 | void inew(void){ 1031 | unsigned char i; 1032 | 1033 | for(i = 0; i < 26; i++) 1034 | var[i] = 0; 1035 | gstki = 0; 1036 | lstki = 0; 1037 | *listbuf = 0; 1038 | clp = listbuf; 1039 | } 1040 | 1041 | unsigned char* iexe(){ 1042 | short lineno; 1043 | unsigned char cd; 1044 | unsigned char* lp; 1045 | short vto, vstep; 1046 | short index; 1047 | 1048 | while(1){ 1049 | if(c_kbhit()){ 1050 | if(c_getch() == 27){ 1051 | while(*clp){ 1052 | clp += *clp; 1053 | } 1054 | err = ERR_ESC; 1055 | return clp; 1056 | } 1057 | } 1058 | 1059 | switch(*cip){ 1060 | case I_GOTO: 1061 | cip++; 1062 | lineno = iexp(); 1063 | clp = getlp(lineno); 1064 | if(lineno != getvalue(clp)){ 1065 | err = ERR_ULN; 1066 | return NULL; 1067 | } 1068 | cip = clp + 3; 1069 | continue; 1070 | case I_GOSUB: 1071 | cip++; 1072 | lineno = iexp(); 1073 | if(err) return NULL; 1074 | lp = getlp(lineno); 1075 | if(lineno != getvalue(lp)){ 1076 | err = ERR_ULN; 1077 | return NULL; 1078 | } 1079 | gpush(clp); 1080 | gpush(cip); 1081 | if(err) return NULL; 1082 | clp = lp; 1083 | cip = clp + 3; 1084 | continue; 1085 | case I_RETURN: 1086 | cip = gpop(); 1087 | lp = gpop(); 1088 | if(err) return NULL; 1089 | clp = lp; 1090 | break; 1091 | case I_FOR: 1092 | cip++; 1093 | if(*cip++ != I_VAR){ 1094 | err = ERR_FORWOV; 1095 | return NULL; 1096 | } 1097 | index = *cip; 1098 | ivar(); 1099 | if(err) return NULL; 1100 | 1101 | if(*cip == I_TO){ 1102 | cip++; 1103 | vto = iexp(); 1104 | } 1105 | else { 1106 | err = ERR_FORWOTO; 1107 | return NULL; 1108 | } 1109 | if(*cip == I_STEP){ 1110 | cip++; 1111 | vstep = iexp(); 1112 | } 1113 | else { 1114 | vstep = 1; 1115 | } 1116 | 1117 | lpush(clp); 1118 | lpush(cip); 1119 | lpush((unsigned char*)vto); 1120 | lpush((unsigned char*)vstep); 1121 | lpush((unsigned char*)index); 1122 | if(err) return NULL; 1123 | break; 1124 | case I_NEXT: 1125 | cip++; 1126 | if(*cip++ !=I_VAR){ 1127 | err = ERR_NEXTWOV; 1128 | return NULL; 1129 | } 1130 | 1131 | if(lstki < 5){ 1132 | err = ERR_LSTKUF; 1133 | return NULL; 1134 | } 1135 | index = (short)lstk[lstki - 1]; 1136 | if(index != *cip){ 1137 | err = ERR_NEXTUM; 1138 | return NULL; 1139 | } 1140 | cip++; 1141 | vstep = (short)lstk[lstki - 2]; 1142 | var[index] += vstep; 1143 | 1144 | vto = (short)lstk[lstki - 3]; 1145 | if( ((vstep < 0) && (var[index] < vto)) || 1146 | ((vstep > 0) && (var[index] > vto))){ 1147 | lstki -= 5; 1148 | break; 1149 | } 1150 | cip = lstk[lstki - 4]; 1151 | clp = lstk[lstki - 5]; 1152 | continue; 1153 | 1154 | case I_IF: 1155 | cip++; 1156 | cd = iif(); 1157 | if(err){ 1158 | err = ERR_IFWOC; 1159 | return NULL; 1160 | } 1161 | if(cd) 1162 | continue; 1163 | // If false, same as REM 1164 | case I_REM: 1165 | // Seek pointer to I_EOL 1166 | // No problem even if it points not realy end of line 1167 | while(*cip != I_EOL) cip++; 1168 | break; 1169 | case I_STOP: 1170 | while(*clp){ 1171 | clp += *clp; 1172 | } 1173 | return clp; 1174 | case I_INPUT: 1175 | cip++; 1176 | iinput(); 1177 | break; 1178 | case I_PRINT: 1179 | cip++; 1180 | iprint(); 1181 | break; 1182 | case I_LET: 1183 | cip++; 1184 | ilet(); 1185 | break; 1186 | case I_VAR: 1187 | cip++; 1188 | ivar(); 1189 | break; 1190 | case I_ARRAY: 1191 | cip++; 1192 | iarray(); 1193 | break; 1194 | case I_LIST: 1195 | case I_NEW: 1196 | case I_RUN: 1197 | err = ERR_COM; 1198 | return NULL; 1199 | } 1200 | 1201 | switch(*cip){ 1202 | case I_SEMI: 1203 | cip++; 1204 | break; 1205 | case I_EOL: 1206 | return clp + *clp; 1207 | default: 1208 | err = ERR_SYNTAX; 1209 | return NULL; 1210 | } 1211 | } 1212 | } 1213 | 1214 | // Called by RUN command 1215 | // TO-DO Rewrite initialize part of this function to fit your machine 1216 | void irun(){ 1217 | unsigned char* lp; 1218 | 1219 | gstki = 0; 1220 | lstki = 0; 1221 | clp = listbuf; 1222 | 1223 | // Initialize 1224 | randomSeed(micros()); 1225 | 1226 | while(*clp){ 1227 | cip = clp + 3; 1228 | lp = iexe(); 1229 | if(err) 1230 | return; 1231 | clp = lp; 1232 | } 1233 | } 1234 | 1235 | void icom(){ 1236 | cip = ibuf; 1237 | switch(*cip){ 1238 | case I_LIST: 1239 | cip++; 1240 | if(*cip == I_EOL || *(cip + 3) == I_EOL) 1241 | ilist(); 1242 | else 1243 | err = ERR_SYNTAX; 1244 | break; 1245 | case I_NEW: 1246 | cip++; 1247 | if(*cip == I_EOL) 1248 | inew(); 1249 | else 1250 | err = ERR_SYNTAX; 1251 | break; 1252 | case I_RUN: 1253 | cip++; 1254 | irun(); 1255 | break; 1256 | default: 1257 | iexe(); 1258 | break; 1259 | } 1260 | 1261 | if(err && err != ERR_ESC){ 1262 | if(cip >= listbuf && cip < listbuf + SIZE_LIST && *clp) 1263 | { 1264 | newline(); 1265 | c_puts("ERR LINE:"); 1266 | putnum(getvalue(clp), 0); 1267 | c_putch(' '); 1268 | putlist(clp + 3); 1269 | } 1270 | else 1271 | { 1272 | newline(); 1273 | c_puts("YOU TYPE: "); 1274 | putlist(ibuf); 1275 | } 1276 | } 1277 | 1278 | } 1279 | 1280 | void basic(){ 1281 | unsigned char len; 1282 | ///////////////////// 1283 | // lcd.begin(16, 4); 1284 | display.begin(); 1285 | // init done 1286 | display.display(); 1287 | //delay(2000); 1288 | display.clearDisplay(); 1289 | // draw a single pixel 1290 | display.setTextSize(1); 1291 | display.setTextColor(WHITE); 1292 | display.setCursor(0,0); 1293 | for (int xg = 0 ; xg < 169 ; xg++) { 1294 | screenMem[xg] = 32; 1295 | } 1296 | //////////// 1297 | inew(); 1298 | c_puts("TOYOSHIKI TINY BASIC"); 1299 | newline(); 1300 | c_puts("TOYOSHIKI TINY BASIC ARDUINO EDITION"); 1301 | newline(); 1302 | error(); // Print OK, and Clear error flag 1303 | 1304 | // Input 1 line and execute 1305 | while(1){ 1306 | c_putch('>');// Prompt 1307 | c_gets(); // Input 1 line 1308 | len = toktoi(); // Convert token to i-code 1309 | if(err){ // Error 1310 | newline(); 1311 | c_puts("YOU TYPE:"); 1312 | c_puts(lbuf); 1313 | error(); 1314 | continue; // Do nothing 1315 | } 1316 | 1317 | if(*ibuf == I_NUM){ // Case the top includes line number 1318 | *ibuf = len; // Change I_NUM to byte length 1319 | inslist(); // Insert list 1320 | if(err){ 1321 | error(); // List buffer overflow 1322 | } 1323 | } 1324 | else { 1325 | icom(); // Execute direct 1326 | error(); // Print OK, and Clear error flag 1327 | } 1328 | } 1329 | } 1330 | 1331 | static void lcdChar(byte c) { 1332 | 1333 | if (c == 8) { //Backspace? 1334 | 1335 | if (cursorX > 0) { 1336 | 1337 | cursorX -= 1; //Go back one 1338 | screenMem[147 + cursorX] = 32; //Erase it from memory 1339 | doFrame(147 + cursorX); //Redraw screen up to that amount 1340 | 1341 | } 1342 | 1343 | } 1344 | 1345 | if (c != 13 and c != 10 and c != 8) { //Not a backspace or return, just a normal character 1346 | 1347 | screenMem[147 + cursorX] = c; 1348 | cursorX += 1; 1349 | if (cursorX < 21) { 1350 | display.setCursor(cursorX*6,8*7); 1351 | display.write(c); 1352 | display.display(); 1353 | } 1354 | 1355 | } 1356 | 1357 | if (cursorX == 21 or c == 10) { //Did we hit Enter or go type past the end of a visible line? 1358 | 1359 | for (int xg = 21 ; xg > 0 ; xg--) { 1360 | 1361 | screenMem[0 + xg] = screenMem[21 + xg]; 1362 | screenMem[21 + xg] = screenMem[42 + xg]; 1363 | screenMem[42 + xg] = screenMem[63 + xg]; 1364 | screenMem[63 + xg] = screenMem[84 + xg]; 1365 | screenMem[84 + xg] = screenMem[105 + xg]; 1366 | screenMem[105 + xg] = screenMem[126 + xg]; 1367 | screenMem[126 + xg] = screenMem[147 + xg]; 1368 | 1369 | 1370 | 1371 | screenMem[147 + xg] = 32; 1372 | 1373 | 1374 | } 1375 | 1376 | cursorX = 0; 1377 | 1378 | doFrame(147); 1379 | 1380 | } 1381 | 1382 | 1383 | } 1384 | 1385 | static void doFrame(byte amount) { 1386 | int xposi,yposi,yshift; 1387 | //display.cleardisplay(); 1388 | //lcd.noCursor(); 1389 | display.clearDisplay(); 1390 | for (int xg = 0 ; xg < amount ; xg++) { 1391 | yshift=int(xg/21.0); 1392 | yposi=yshift*8; 1393 | xposi=(xg-yshift*21)*6; 1394 | display.setCursor(xposi,yposi); 1395 | display.write(screenMem[xg]); 1396 | } 1397 | display.display(); 1398 | //lcd.cursor(); 1399 | 1400 | } 1401 | -------------------------------------------------------------------------------- /toyoshiki-tinybasic/ttbasic.h: -------------------------------------------------------------------------------- 1 | /* 2 | TOYOSHIKI Tiny BASIC for Arduino 3 | (C)2012 Tetsuya Suzuki 4 | GNU General Public License 5 | */ 6 | 7 | #include 8 | 9 | //Prototypes 10 | void newline(void); 11 | char* c_strchr(char *, char); 12 | void c_puts(const char *); 13 | void c_gets(void); 14 | void gpush(unsigned char*); 15 | unsigned char* gpop(void); 16 | void lpush(unsigned char*); 17 | unsigned char* lpop(void); 18 | void error(void); 19 | void putnum(short, short); 20 | short getnum(void); 21 | short getvalue(unsigned char*); 22 | short getparam(void); 23 | unsigned char* getlp(short); 24 | unsigned char toktoi(void); 25 | void putlist(unsigned char*); 26 | void inslist(void); 27 | short getsize(void); 28 | short getabs(void); 29 | short getrnd(void); 30 | short getarray(void); 31 | short ivalue(void); 32 | short icalc(void); 33 | short iexp(void); 34 | void iprint(void); 35 | void iinput(void); 36 | char iif(void); 37 | void ivar(void); 38 | void iarray(void); 39 | void ilet(void); 40 | void ilist(void); 41 | void inew(void); 42 | unsigned char* iexe(void); 43 | void irun(void); 44 | void icom(void); 45 | void basic(void); 46 | 47 | -------------------------------------------------------------------------------- /toyoshiki-tinybasic/ttbasic_arduino.ino: -------------------------------------------------------------------------------- 1 | /* 2 | TOYOSHIKI Tiny BASIC for Arduino 3 | (C)2012 Tetsuya Suzuki 4 | GNU General Public License 5 | 6 | Tested in Arduino Uno R3. 7 | Use UART terminal or serial monitor. 8 | 9 | The grammar is the same as 10 | PALO ALTO TinyBASIC by Li-Chen Wang 11 | Except 3 point to show below. 12 | 13 | (1)The contracted form of the description is invalid. 14 | 15 | (2)Force abort key 16 | PALO ALTO TinyBASIC -> [Ctrl]+[C] 17 | TOYOSHIKI TinyBASIC -> [ESC] 18 | NOTE: There is no input means in serial monitor. 19 | 20 | (3)Other some beyond my expectations. 21 | */ 22 | 23 | // Kodera2t Feb. 12, 2015, SPI OLED(SSD1306) support is added.. 24 | 25 | #include "ttbasic.h" 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | void setup(void){ 32 | Serial.begin(4800);// opens serial port, sets data rate to 4800 bps (Xbox360 chatpad speed) 33 | } 34 | 35 | void loop(void){ 36 | basic(); 37 | } 38 | 39 | 40 | --------------------------------------------------------------------------------