IPS(Interpreter for Process Structures) for mbed
Dependencies: ConfigFile FATFileSystem mbed
VideoRAM.h
00001 // VideoRAM.h 2015/5/22 00002 #pragma once 00003 00004 template<class SERIAL_T> 00005 class VideoRAM { 00006 SERIAL_T& _pc; 00007 uint16_t x, y; 00008 bool f_init; 00009 00010 public: 00011 VideoRAM(RawSerial& pc):_pc(pc),x(0),y(0),f_init(false) { 00012 } 00013 void vpoke(uint16_t i, uint8_t b) { 00014 if (i < 1024) { 00015 if (x != i%64 || y != i/64) { 00016 x = i%64; 00017 y = i/64; 00018 char buf[16]; 00019 snprintf(buf, sizeof(buf), "\x1b[%d;%dH", y+1, x+1) ; // locate 00020 _puts(buf); 00021 } 00022 _putc(b & 0x7f); 00023 x++; 00024 } 00025 } 00026 00027 private: 00028 void init() { 00029 _puts("\x1b[2J"); // erase 00030 } 00031 void _puts(const char* s) { 00032 while(*s) { 00033 _putc(*s++); 00034 } 00035 } 00036 void _putc(int c) { 00037 if (!f_init) { 00038 f_init = true; 00039 init(); 00040 } 00041 _pc.putc(c); 00042 } 00043 }; 00044
Generated on Fri Jul 15 2022 06:25:55 by 1.7.2