Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
TextStar.cpp
00001 /* mbed TextStar serial LCD Library 00002 * Copyright (c) 2009-2010 Paul Griffith 00003 * Released under the MIT License: http://mbed.org/license/mit 00004 * 00005 * Last edit: 10 Jan 2010 00006 * 00007 * TextStar CW-LCD-02 16x2 serial LCD module 00008 * Cat's Whisker Technologies, http://www.cats-whisker.com 00009 */ 00010 00011 #include "TextStar.h" 00012 #include "mbed.h" 00013 00014 00015 TextStar::TextStar(PinName tx, PinName rx) : Serial(tx, rx) { 00016 reset(); 00017 } 00018 00019 void TextStar::cls() { 00020 //clear screen = 254,'S' 00021 //does not affect auto-blank and auto-scroll 00022 this->putc('\014'); 00023 } 00024 00025 void TextStar::locate(int column, int row) { 00026 //position cursor = 254,'P',line (0-15), col (0-15) 00027 this->printf("\376P%c%c", row + 1, column + 1); 00028 } 00029 00030 void TextStar::foreground(int colour) { 00031 //colours not supported 00032 } 00033 00034 void TextStar::background(int colour) { 00035 //colours not supported 00036 } 00037 00038 void TextStar::reset(int autoblank, int autoscroll) { 00039 //reset screen = 254,'R' 00040 this->printf("\376R"); 00041 //set up auto-blank and auto-scroll as per arguments 00042 _autoblank = (autoblank == 0) ? 0 : 1; 00043 _autoscroll = (autoscroll == 0) ? 0 : 1; 00044 this->printf("\376G%c", 1 + (_autoblank * 64) + (_autoscroll * 64) ); 00045 // this->printf("AB = %d AS = %d", _autoblank, _autoscroll); 00046 // wait(2.0); 00047 // cls(); 00048 } 00049 00050 void TextStar::left(void) { 00051 //move cursor left = 8 00052 this->putc('\010'); 00053 } 00054 00055 void TextStar::right(void) { 00056 //move cursor right = 9 00057 this->putc('\011'); 00058 } 00059 00060 void TextStar::down(void) { 00061 //move cursor down one line = 10 00062 this->putc('\012'); 00063 } 00064 00065 void TextStar::up(void) { 00066 //move cursor up one line = 11 00067 this->putc('\013'); 00068 } 00069 00070 void TextStar::home(void) { 00071 //cursor home = 254,'H' 00072 this->printf("\376H"); 00073 } 00074 00075 void TextStar::crlf(void) { 00076 //carriage return = 13 00077 this->putc('\015'); 00078 } 00079 00080 void TextStar::del(void) { 00081 //delete character = 127 00082 this->putc('\177'); 00083 } 00084 00085 void TextStar::set_cursor(int style) { 00086 //styles: 0 = none, 1 = solid block, 2 = flash block, 3 = solid uline, 4 = flash uline 00087 if (style < 0 || style > 4) 00088 return; 00089 this->printf("\376C%c", style); 00090 } 00091 00092 void TextStar::window(int line) { 00093 //move visible window to line (0-14) 00094 if (line < 0 || line > 14) 00095 return; 00096 this->printf("\376G%c", line + 1 + (_autoblank * 64) + (_autoscroll * 128) ); 00097 } 00098 00099 void TextStar::scroll_up(void) { 00100 //move visble window up one line 00101 this->printf("\376O%c", 1); 00102 } 00103 00104 void TextStar::scroll_down(void) { 00105 //move visible window down one line 00106 this->printf("\376O%c", 0); 00107 } 00108 00109 void TextStar::bar_graph(int capped, int length, int percentage) { 00110 if (length < 1 || length > 16) { 00111 this->printf("Bad len %d", length); 00112 wait(2.0); 00113 return; 00114 } 00115 if (percentage < 0 || percentage > 100) { 00116 this->printf("Bad val %d", percentage); 00117 wait(2.0); 00118 return; 00119 } 00120 this->printf("\376%c%c%c", (capped == 0)? 'B' : 'b', length, percentage); 00121 } 00122 00123 void TextStar::custom_char(int num, char *bitmap) { 00124 //define custom character = 254,'D',bm1,bm2,bm3,bm4,bm5,bm6,bm7,bm8 00125 if (num < 128 || num > 135) { 00126 this->printf("Bad CC num %d", num); 00127 wait(2.0); 00128 return; 00129 } 00130 this->printf("\376D%c%c%c%c%c%c%c%c%c", num, bitmap[0], bitmap[1], bitmap[2], bitmap[3], 00131 bitmap[4], bitmap[5], bitmap[6], bitmap[7]); 00132 } 00133 00134 void TextStar::version(void) { 00135 //display firmware version and custom characters = 254,'V' 00136 this->printf("\376V"); 00137 } 00138 00139 void TextStar::send_version(void) { 00140 //send firmware version = 254,'v' 00141 this->printf("\376v"); 00142 } 00143 00144 void TextStar::send_keys(void) { 00145 //send key states = 254,'K' 00146 this->printf("\376K"); 00147 }
Generated on Sun Jul 24 2022 19:15:07 by
1.7.2