00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef __VFD_GP1059_H__
00043 #define __VFD_GP1059_H__
00044
00045 #include "mbed.h"
00046
00047 class VFD_GP1059 {
00048 private:
00049 BusOut data;
00050 DigitalOut wr,rd,cs,cd;
00051 DigitalIn intr;
00052
00053 void init(){
00054 cs = 1;
00055 wr = 1;
00056 rd = 1;
00057 cd = 1;
00058 }
00059
00060 public:
00061
00062 VFD_GP1059(PinName d0_pin,
00063 PinName d1_pin,
00064 PinName d2_pin,
00065 PinName d3_pin,
00066 PinName d4_pin,
00067 PinName d5_pin,
00068 PinName d6_pin,
00069 PinName d7_pin,
00070 PinName intr_pin,
00071 PinName wr_pin,
00072 PinName rd_pin,
00073 PinName cs_pin,
00074 PinName cd_pin) :
00075 data(d0_pin, d1_pin, d2_pin, d3_pin, d4_pin, d5_pin, d6_pin, d7_pin),
00076 intr(intr_pin),
00077 wr(wr_pin),
00078 rd(rd_pin),
00079 cs(cs_pin),
00080 cd(cd_pin) {
00081 init();
00082 cls();
00083 }
00084
00085 void send_cmd(uint8_t cmd){
00086 cd = 1;
00087 data = cmd;
00088 cs = 0;
00089 wr = 0;
00090 wait_us(2);
00091 wr = 1;
00092 cs = 1;
00093 wait_us(4);
00094
00095 return;
00096 }
00097
00098 void send_data(uint8_t data_value){
00099 cd = 0;
00100 data = data_value;
00101 cs = 0;
00102 wr = 0;
00103 wait_us(2);
00104 wr = 1;
00105 cs = 1;
00106 wait_us(4);
00107
00108 return;
00109 }
00110
00111
00112 void luminance_adjustment(uint8_t data){
00113 send_cmd(6);
00114 send_data(data);
00115
00116 return;
00117 }
00118
00119
00120 void set_write_read_address(uint16_t address){
00121 send_cmd(4);
00122 send_data((uint8_t)(address & 0x0ff));
00123
00124 send_cmd(5);
00125 send_data((uint8_t)(address >> 8));
00126
00127 send_cmd(2);
00128
00129 return;
00130 }
00131
00132
00133 void set_disp_start_address(uint16_t address){
00134 send_cmd(7);
00135 send_data((uint8_t)(address & 0x0ff));
00136
00137 send_cmd(8);
00138 send_data((uint8_t)(address >> 8));
00139
00140 return;
00141 }
00142
00143
00144 void cls(){
00145 set_disp_start_address(0);
00146 set_write_read_address(0);
00147 for (int i = 0; i < 0x1fff; i++){
00148 send_data(0);
00149 }
00150 return;
00151 }
00152
00153 };
00154
00155 #endif