IPS(Interpreter for Process Structures) for mbed

Dependencies:   ConfigFile FATFileSystem mbed

IPS port from linux/unix version.

mbed_blinky.ips

0 VAR led1
" LED1 " DigitalOut led1 !
: main
    ANFANG
    1 JA?
      1 led1 @ write
      200 wait_ms
      0 led1 @ write
      200 wait_ms
    DANN/NOCHMAL
;
main

VideoRAM.h

Committer:
va009039
Date:
2015-05-23
Revision:
2:908338b1151a
Parent:
1:e74530ad6b9e

File content as of revision 2:908338b1151a:

// VideoRAM.h 2015/5/22
#pragma once

template<class SERIAL_T>
class VideoRAM {
    SERIAL_T& _pc;
    uint16_t x, y;
    bool f_init;

public:
    VideoRAM(RawSerial& pc):_pc(pc),x(0),y(0),f_init(false) {
    }
    void vpoke(uint16_t i, uint8_t b) {
        if (i < 1024) {
            if (x != i%64 || y != i/64) {
                x = i%64;
                y = i/64;
                char buf[16];
                snprintf(buf, sizeof(buf), "\x1b[%d;%dH", y+1, x+1) ; // locate
                _puts(buf);
            }
            _putc(b & 0x7f);
            x++;
        }
    }

private:
    void init() {
        _puts("\x1b[2J"); // erase
    }
    void _puts(const char* s) {
        while(*s) {
            _putc(*s++);
        }
    }
    void _putc(int c) {
        if (!f_init) {
            f_init = true;
            init();
        }
        _pc.putc(c);
    }
};