Only Yesterday 制御プログラム

Dependencies:   mbed FATFileSystem

Fork of OnlyYestaerday by Junichi Katsu

Committer:
jksoft
Date:
Wed Apr 02 01:43:55 2014 +0000
Revision:
0:5975af170e43
1st Prototype

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:5975af170e43 1 /* mbed eDISP Library
jksoft 0:5975af170e43 2 * Copyright (c) 2010 todotani
jksoft 0:5975af170e43 3 * Version 0.1 (March 6, 2010)
jksoft 0:5975af170e43 4 * Released under the MIT License: http://mbed.org/license/mit
jksoft 0:5975af170e43 5 */
jksoft 0:5975af170e43 6
jksoft 0:5975af170e43 7 #include "eDisp.h"
jksoft 0:5975af170e43 8 #include "error.h"
jksoft 0:5975af170e43 9
jksoft 0:5975af170e43 10 using namespace mbed;
jksoft 0:5975af170e43 11
jksoft 0:5975af170e43 12 eDisp::eDisp(PinName tx, PinName rx, int baud, int columns, int rows)
jksoft 0:5975af170e43 13 :_serial(tx, rx), _columns(columns), _rows(rows) {
jksoft 0:5975af170e43 14 _serial.baud(baud);
jksoft 0:5975af170e43 15 cls();
jksoft 0:5975af170e43 16 }
jksoft 0:5975af170e43 17
jksoft 0:5975af170e43 18 int eDisp::_putc(int value) {
jksoft 0:5975af170e43 19 if(value == '\n') {
jksoft 0:5975af170e43 20 newline();
jksoft 0:5975af170e43 21 } else {
jksoft 0:5975af170e43 22 _serial.putc(value);
jksoft 0:5975af170e43 23 }
jksoft 0:5975af170e43 24 return value;
jksoft 0:5975af170e43 25 }
jksoft 0:5975af170e43 26
jksoft 0:5975af170e43 27 int eDisp::_getc() {
jksoft 0:5975af170e43 28 return 0;
jksoft 0:5975af170e43 29 }
jksoft 0:5975af170e43 30
jksoft 0:5975af170e43 31 void eDisp::newline() {
jksoft 0:5975af170e43 32 _column = 0;
jksoft 0:5975af170e43 33 _row++;
jksoft 0:5975af170e43 34 if (_row >= _rows) {
jksoft 0:5975af170e43 35 _row = 0;
jksoft 0:5975af170e43 36 }
jksoft 0:5975af170e43 37 locate(_column, _row);
jksoft 0:5975af170e43 38 }
jksoft 0:5975af170e43 39
jksoft 0:5975af170e43 40 void eDisp::locate(int column, int row) {
jksoft 0:5975af170e43 41 if (column < 0 || column >= _columns || row < 0 || row >= _rows) {
jksoft 0:5975af170e43 42 error("locate(%d,%d) out of range on %dx%d display", column, row, _columns, _rows);
jksoft 0:5975af170e43 43 return;
jksoft 0:5975af170e43 44 }
jksoft 0:5975af170e43 45
jksoft 0:5975af170e43 46 _row = row;
jksoft 0:5975af170e43 47 _column = column;
jksoft 0:5975af170e43 48 _serial.printf("\x1B[%d;%dH", _row, _column);
jksoft 0:5975af170e43 49 }
jksoft 0:5975af170e43 50
jksoft 0:5975af170e43 51 void eDisp::cls() {
jksoft 0:5975af170e43 52 locate(0, 0);
jksoft 0:5975af170e43 53 _serial.printf("\x1B[J");
jksoft 0:5975af170e43 54 }
jksoft 0:5975af170e43 55
jksoft 0:5975af170e43 56 void eDisp::reset() {
jksoft 0:5975af170e43 57 _serial.printf("\x1B[m");
jksoft 0:5975af170e43 58 cls();
jksoft 0:5975af170e43 59 }
jksoft 0:5975af170e43 60
jksoft 0:5975af170e43 61 void eDisp::textColor (int color) {
jksoft 0:5975af170e43 62 _serial.printf("\x1B[%dm", color);
jksoft 0:5975af170e43 63 }
jksoft 0:5975af170e43 64
jksoft 0:5975af170e43 65 void eDisp::backgroundColor (int color) {
jksoft 0:5975af170e43 66 _serial.printf("\x1B[%dm", color + 10);
jksoft 0:5975af170e43 67 }
jksoft 0:5975af170e43 68
jksoft 0:5975af170e43 69 void eDisp::fillRect (int buffer, int width, int hight, int x, int y, int color ) {
jksoft 0:5975af170e43 70 _serial.printf("\x1B@0;%d;%d;%d;%d;%d;%dz", buffer, width, hight, x, y, color);
jksoft 0:5975af170e43 71 }
jksoft 0:5975af170e43 72
jksoft 0:5975af170e43 73 void eDisp::drawLine (int buffer, int x0, int y0, int x1, int y1, int color) {
jksoft 0:5975af170e43 74 _serial.printf("\x1B@2;%d;%d;%d;%d;%d;%dz", buffer, x0, y0, x1, y1, color);
jksoft 0:5975af170e43 75 }
jksoft 0:5975af170e43 76
jksoft 0:5975af170e43 77 void eDisp::pic(int buffer ,int num) {
jksoft 0:5975af170e43 78 _serial.printf("\x1B@%d;%d;I",num,buffer);
jksoft 0:5975af170e43 79 }
jksoft 0:5975af170e43 80
jksoft 0:5975af170e43 81 void eDisp::chg_buff(int buffer) {
jksoft 0:5975af170e43 82 _serial.printf("\x1B@%dZ",buffer + 30);
jksoft 0:5975af170e43 83 }