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.
Diff: kt_vfd.cpp
- Revision:
- 1:e1e942d03093
- Parent:
- 0:94347d9bbcf4
--- a/kt_vfd.cpp Mon Jul 03 14:14:06 2017 +0000
+++ b/kt_vfd.cpp Tue Jul 11 23:41:56 2017 +0000
@@ -1,6 +1,6 @@
/**
* @bref VFD class imprementation
- * for GU140X16G-7040
+ * for GU256X128C-3900
*/
#include "mbed.h"
#include "kt_vfd.h"
@@ -15,41 +15,89 @@
_wr = 1 ;
wait_ms(100) ;
- writeByte(0x1b) ;
- writeByte(0x40) ;
+ write_byte(0x1b) ;
+ write_byte(0x40) ;
wait_ms(100) ;
}
-void KT_VFD::mode(unsigned char mode)
+void KT_VFD::write_mode(unsigned char mode)
+{
+ write_byte(0x1f) ;
+ write_byte(0x28) ;
+ write_byte(0x77) ;
+ write_byte(0x10) ;
+ write_byte(mode) ;
+}
+
+void KT_VFD::disp_mode(unsigned char mode)
+{
+ write_byte(0x1f) ;
+ write_byte(mode) ;
+}
+
+void KT_VFD::scroll_speed(unsigned char n)
{
- writeByte(0x1f) ;
- writeByte(mode) ;
+ write_byte(0x1f) ;
+ write_byte(0x73) ;
+ write_byte(n) ; // 0x00 - 0x1f:
+}
+
+void KT_VFD::scroll_act(unsigned int w, unsigned int c, unsigned char s)
+{
+ write_byte(0x1f) ;
+ write_byte(0x28) ;
+ write_byte(0x61) ;
+ write_byte(0x10) ;
+ write_byte(w%0x100) ;
+ write_byte(w/0x100) ;
+ write_byte(c%0x100) ;
+ write_byte(c/0x100) ;
+ write_byte(s) ;
}
void KT_VFD::cls()
{
- writeByte(0x0C) ;
+ write_byte(0x0C) ;
locate(0, 0) ;
}
void KT_VFD::locate(unsigned int x, unsigned int y)
{
- writeByte(0x1f) ;
- writeByte(0x24) ;
- writeByte(x % 0x100) ; // xL
- writeByte(x / 0x100) ; // xH
- writeByte(y % 0x100) ; // yL
- writeByte(y / 0x100) ; // yH
+ write_byte(0x1f) ;
+ write_byte(0x24) ;
+ write_byte(x % 0x100) ; // xL
+ write_byte(x / 0x100) ; // xH
+ write_byte(y % 0x100) ; // yL
+ write_byte(y / 0x100) ; // yH
}
void KT_VFD::lf()
{
- writeByte(0x0a) ;
+ write_byte(0x0a) ;
}
void KT_VFD::cr()
{
- writeByte(0x0d) ;
+ write_byte(0x0d) ;
+}
+
+void KT_VFD::font_size(unsigned char m)
+{
+ write_byte(0x1f) ;
+ write_byte(0x28) ;
+ write_byte(0x67) ;
+ write_byte(0x01) ;
+ write_byte(m) ;
+}
+
+void KT_VFD::char_ext(unsigned char x, unsigned char y)
+{
+ write_byte(0x1f) ;
+ write_byte(0x28) ;
+ write_byte(0x67) ;
+ write_byte(0x40) ;
+ write_byte(x) ;
+ write_byte(y) ;
}
int KT_VFD::_putc(int c)
@@ -58,7 +106,7 @@
cr() ;
lf() ;
} else {
- writeByte(c) ;
+ write_byte(c) ;
}
return 0 ;
}
@@ -68,8 +116,9 @@
return -1 ;
}
-void KT_VFD::writeByte(unsigned char value)
+void KT_VFD::write_byte(unsigned char value)
{
+#if 0
bool ok ;
_d[7] = 0 ;
do {
@@ -79,10 +128,14 @@
_rd = 1 ;
} while (ok) ;
_d[7] = 1 ;
+#else
+ while (!_rd) ;
+#endif
_d = value ;
_wr = 0 ;
wait_us(0.11) ;
_wr = 1 ;
- wait_us(1.6) ;
+// wait_us(1.6) ;
+ wait_us(16) ;
}