Edoardo Armeriv / Mbed 2 deprecated lab5

Dependencies:   mbed mbed-rtos tsi_sensor SLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NKC_LCD.h Source File

NKC_LCD.h

00001 #ifndef NKC_LCD_H
00002 #define NKC_LCD_H
00003 
00004 Serial lcd(PTD3,NC);
00005 
00006 int NKC_BAUD[9]={0,300,1200,2400,9600,14400,19200,57600,115200};
00007 
00008 int lcd_baud_decode(int baud)
00009 {
00010     int target_baud;
00011     target_baud=0;
00012     if(baud >= 1 && baud <= 8)
00013     {
00014         target_baud=baud;
00015     }
00016     else
00017     {
00018         for(int i = 1; i <=8; i++)
00019         {
00020             if(baud ==  NKC_BAUD[i])
00021             {
00022                 target_baud=i;           
00023             }
00024         }
00025     }
00026     if(target_baud >0)
00027     {
00028         return(target_baud);
00029     }
00030     else
00031     {
00032         return(-1);   
00033     }    
00034 }
00035 
00036 int lcd_baud(int baud)
00037 {
00038     int target_baud;
00039     target_baud=lcd_baud_decode(baud);
00040     if(target_baud > 0)
00041     {
00042         lcd.baud(NKC_BAUD[target_baud]);
00043         return(NKC_BAUD[target_baud]);
00044     }
00045     else
00046     {
00047         return(-1);   
00048     }     
00049 }
00050 
00051 int lcd_default_baud(int baud)
00052 {
00053     int target_baud;
00054     target_baud=lcd_baud_decode(baud);
00055     if(target_baud < 0)
00056     {
00057         return(-1);   
00058     }  
00059     for(int i=1; i<=8; i++)
00060     {
00061         lcd.baud(NKC_BAUD[i]);
00062         lcd.printf("\xFE\x61%1i",target_baud);
00063 
00064         //wait(2E-3);  
00065         wait_us(2000);     
00066     }
00067     lcd.baud(NKC_BAUD[target_baud]);   
00068     return(NKC_BAUD[target_baud]);       
00069 }
00070 
00071 void lcd_on()
00072 {
00073     lcd.printf("\xFE\x41");
00074     //wait(2E-3); 
00075         wait_us(2000); 
00076 }
00077 
00078 void lcd_off()
00079 {
00080     lcd.printf("\xFE\x42");
00081     //wait(2E-3); 
00082         wait_us(2000); 
00083 }
00084 
00085 void lcd_ddram_address(int address)
00086 {
00087     lcd.printf("\xFE\x45%c",address);
00088     //wait(2E-3); 
00089         wait_us(2000); 
00090 }
00091 
00092 int lcd_cursor(int row, int column)
00093 {
00094     int row_offsets[4]={0x00, 0x40, 0x13, 0x53};
00095     int address;
00096     if( row < 0 || row > 3 || column < 0 || column > 19) {return(-1);}
00097     address = row_offsets[row]+column;
00098     lcd.printf("\xFE\x45%c",address);
00099     //wait(2E-3); 
00100         wait_us(2000); 
00101     return(address);
00102 }
00103 
00104 void lcd_home()
00105 {
00106     lcd.printf("\xFE\x46");
00107     //wait(2E-3); 
00108         wait_us(2000); 
00109 }
00110 
00111 void lcd_underline_on()
00112 {
00113     lcd.printf("\xFE\x47");
00114     //wait(2E-3); 
00115         wait_us(2000); 
00116 }
00117 
00118 void lcd_underline_off()
00119 {
00120     lcd.printf("\xFE\x48");
00121     //wait(2E-3); 
00122         wait_us(2000); 
00123 }
00124 
00125 int lcd_underline(int select)
00126 {
00127     if(select)
00128     {
00129         lcd_underline_on();
00130         return(true);
00131     }
00132     else
00133     {
00134         lcd_underline_off();
00135         return(false);
00136     }      
00137 }
00138 
00139 void lcd_backspace()
00140 {
00141     lcd.printf("\xFE\x4E");
00142     //wait(2E-3); 
00143         wait_us(2000); 
00144 }
00145 
00146 void lcd_clear()
00147 {
00148     lcd.printf("\xFE\x51");
00149     //wait(2E-3);
00150         wait_us(2000); 
00151 }
00152 
00153 void lcd_blink_on()
00154 {
00155     lcd.printf("\xFE\x4B");
00156     //wait(2E-3); 
00157         wait_us(2000); 
00158 }
00159 
00160 void lcd_blink_off()
00161 {
00162     lcd.printf("\xFE\x4C");
00163     //wait(2E-3);
00164         wait_us(2000); 
00165 }
00166 
00167 int lcd_blink(int select)
00168 {
00169     if(select)
00170     {
00171         lcd_blink_on();
00172         return(true);
00173     }
00174     else
00175     {
00176         lcd_blink_off();
00177         return(false);
00178     }      
00179 }
00180 
00181 void lcd_move_left()
00182 {
00183     lcd.printf("\xFE\x49");
00184     //wait(2E-3); 
00185         wait_us(2000); 
00186 }
00187 
00188 void lcd_move_right()
00189 {
00190     lcd.printf("\xFE\x4A");
00191     //wait(2E-3); 
00192         wait_us(2000); 
00193 }
00194 
00195 void lcd_shift_left()
00196 {
00197     lcd.printf("\xFE\x55");
00198     //wait(2E-3);
00199         wait_us(2000); 
00200 }
00201 
00202 void lcd_shift_right()
00203 {
00204     lcd.printf("\xFE\x56");
00205     //wait(2E-3);
00206         wait_us(2000);  
00207 }
00208 
00209 #endif //NKC_LCD_H