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.
kt_vfd.cpp
00001 /** 00002 * @bref VFD class imprementation 00003 * for GU256X128C-3900 00004 */ 00005 #include "mbed.h" 00006 #include "kt_vfd.h" 00007 00008 KT_VFD::KT_VFD(PinName rd, PinName wr, 00009 PinName d0, PinName d1, PinName d2, PinName d3, 00010 PinName d4, PinName d5, PinName d6, PinName d7) : 00011 _rd(rd), _wr(wr), 00012 _d(d0, d1, d2, d3, d4, d5, d6, d7) 00013 { 00014 _rd = 1 ; 00015 _wr = 1 ; 00016 00017 wait_ms(100) ; 00018 write_byte(0x1b) ; 00019 write_byte(0x40) ; 00020 wait_ms(100) ; 00021 } 00022 00023 void KT_VFD::write_mode(unsigned char mode) 00024 { 00025 write_byte(0x1f) ; 00026 write_byte(0x28) ; 00027 write_byte(0x77) ; 00028 write_byte(0x10) ; 00029 write_byte(mode) ; 00030 } 00031 00032 void KT_VFD::disp_mode(unsigned char mode) 00033 { 00034 write_byte(0x1f) ; 00035 write_byte(mode) ; 00036 } 00037 00038 void KT_VFD::scroll_speed(unsigned char n) 00039 { 00040 write_byte(0x1f) ; 00041 write_byte(0x73) ; 00042 write_byte(n) ; // 0x00 - 0x1f: 00043 } 00044 00045 void KT_VFD::scroll_act(unsigned int w, unsigned int c, unsigned char s) 00046 { 00047 write_byte(0x1f) ; 00048 write_byte(0x28) ; 00049 write_byte(0x61) ; 00050 write_byte(0x10) ; 00051 write_byte(w%0x100) ; 00052 write_byte(w/0x100) ; 00053 write_byte(c%0x100) ; 00054 write_byte(c/0x100) ; 00055 write_byte(s) ; 00056 } 00057 00058 void KT_VFD::cls() 00059 { 00060 write_byte(0x0C) ; 00061 locate(0, 0) ; 00062 } 00063 00064 void KT_VFD::locate(unsigned int x, unsigned int y) 00065 { 00066 write_byte(0x1f) ; 00067 write_byte(0x24) ; 00068 write_byte(x % 0x100) ; // xL 00069 write_byte(x / 0x100) ; // xH 00070 write_byte(y % 0x100) ; // yL 00071 write_byte(y / 0x100) ; // yH 00072 } 00073 00074 void KT_VFD::lf() 00075 { 00076 write_byte(0x0a) ; 00077 } 00078 00079 void KT_VFD::cr() 00080 { 00081 write_byte(0x0d) ; 00082 } 00083 00084 void KT_VFD::font_size(unsigned char m) 00085 { 00086 write_byte(0x1f) ; 00087 write_byte(0x28) ; 00088 write_byte(0x67) ; 00089 write_byte(0x01) ; 00090 write_byte(m) ; 00091 } 00092 00093 void KT_VFD::char_ext(unsigned char x, unsigned char y) 00094 { 00095 write_byte(0x1f) ; 00096 write_byte(0x28) ; 00097 write_byte(0x67) ; 00098 write_byte(0x40) ; 00099 write_byte(x) ; 00100 write_byte(y) ; 00101 } 00102 00103 int KT_VFD::_putc(int c) 00104 { 00105 if (c == '\n') { 00106 cr() ; 00107 lf() ; 00108 } else { 00109 write_byte(c) ; 00110 } 00111 return 0 ; 00112 } 00113 00114 int KT_VFD::_getc() 00115 { 00116 return -1 ; 00117 } 00118 00119 void KT_VFD::write_byte(unsigned char value) 00120 { 00121 #if 0 00122 bool ok ; 00123 _d[7] = 0 ; 00124 do { 00125 _rd = 0 ; 00126 wait_us(0.08) ; 00127 ok = _d[7] ; 00128 _rd = 1 ; 00129 } while (ok) ; 00130 _d[7] = 1 ; 00131 #else 00132 while (!_rd) ; 00133 #endif 00134 00135 _d = value ; 00136 _wr = 0 ; 00137 wait_us(0.11) ; 00138 _wr = 1 ; 00139 // wait_us(1.6) ; 00140 wait_us(16) ; 00141 }
Generated on Thu Jul 21 2022 14:31:47 by
1.7.2