walter azevedo / Mbed 2 deprecated teste

Dependencies:   mbed

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Files at this revision

API Documentation at this revision

Comitter:
walterlma
Date:
Tue Jul 04 19:43:04 2017 +0000
Parent:
4:a3e4bb2053cb
Commit message:
lcd

Changed in this revision

TextLCD.lib Show diff for this revision Revisions of this file
lcdpronto.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
--- a/TextLCD.lib	Sun Mar 29 13:12:07 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/wim/code/TextLCD/#ce348c002929
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lcdpronto.cpp	Tue Jul 04 19:43:04 2017 +0000
@@ -0,0 +1,112 @@
+#include "mbed.h"
+
+#define tuss 2
+#define tusl 20
+#define tms 2
+
+#define OFF 1
+#define ON 0
+
+Serial pc(USBTX, USBRX); // tx, rx 
+
+SPI lcd(PTE3, PTE1, PTE2);
+DigitalOut cs(PTE4);
+DigitalOut res(PTD5);
+DigitalOut dc(PTC12);
+char k;   
+
+void init_LCD(){
+    res = 0;
+    dc = 0;
+    cs = 1;
+    wait(0.1);
+    res = 1;
+    k = 0;
+    cs = 0;
+    lcd.write(0x3C);
+    wait_us(tuss);
+    cs = 1;
+    wait_ms(tms);
+    cs = 0;
+    lcd.write(0x0C);
+    wait_us(tuss);
+    cs = 1;
+    wait_us(tusl);
+    cs = 0;
+    lcd.write(0x01);
+    wait_us(tuss);
+    cs = 1;
+    wait_ms(tms);
+    cs = 0;
+    lcd.write(0x06);
+    wait_us(tuss);
+    
+    return;        
+}
+
+void pula_linha(){    
+    dc = 0;
+    wait_ms(tms);
+    cs = 0;
+    lcd.write(0xC0);
+    wait_us(tuss);
+    cs = 1;
+    wait_ms(tms);
+    
+    dc = 1;
+    wait_ms(tms);
+    
+    return;
+}    
+
+void limpa_lcd(void){
+    
+    dc = 0;
+    wait_ms(tms);
+    cs = 0;
+    lcd.write(0x01);
+    wait_us(tuss);
+    cs = 1;
+    wait_ms(tms);
+    
+    dc = 1;
+    wait_ms(tms);
+    
+    return;
+}
+
+int main() {
+    pc.baud(9600);
+    
+    lcd.format(8, 3); // Modo 0 ou 3
+    lcd.frequency(1000000); // 100kHz
+    
+    init_LCD();
+    
+    cs = 1;
+    wait_ms(tms);    
+    dc = 1;
+    wait_ms(tms);
+
+    for(k = 0x30; k < 0x3A; k++) {
+        cs = 0;
+        lcd.write(k);
+        wait_us(tuss);
+        cs = 1;
+        wait_ms(tms);
+    }
+    
+    pula_linha();
+    
+    for(k = 'A'; k < 'Q'; k++) {
+        cs = 0;
+        lcd.write(k);
+        wait_us(tuss);
+        cs = 1;
+        wait_ms(tms);
+    }
+    
+    wait(5);
+    
+    limpa_lcd();    
+}
--- a/main.cpp	Sun Mar 29 13:12:07 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/* Hello World! for the TextLCD Enhanced Library*/
-
-#include "mbed.h"
-#include "TextLCD.h"
- 
-// Host PC Communication channels
-Serial pc(USBTX, USBRX); // tx, rx
- 
-// I2C Communication
-I2C i2c_lcd(p9,p10); // SDA, SCL
-//I2C i2c_lcd(p28,p27); // SDA, SCL
- 
-// SPI Communication
-SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK
-
-// LCD instantiation 
-//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x2);        // 4bit bus: rs, e, d4-d7
-TextLCD_I2C lcd(&i2c_lcd, 0x40, TextLCD::LCD20x4);                  // I2C exp: I2C bus, PCF8574 Slaveaddress, LCD Type
-//TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C exp: I2C bus, PCF8574 Slaveaddress, LCD Type, Ctrl Type
-//TextLCD_I2C lcd(&spi_lcd, p8, TextLCD::LCD24x4D);                   // I2C exp: SPI bus, CS pin, LCD Type
-//TextLCD_SPI_N lcd(&spi_lcd, p8, p9, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // SPI native: SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032
-//TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C native: I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032 =Ok
-//TextLCD_I2C_N lcd(&i2c_lcd, SSD1803_SA1, TextLCD::LCD20x4D, NC, TextLCD::SSD1803_3V3); // I2C native: I2C bus, slaveaddress, LCDType=LCD20x4D, BL=NC, LCDTCtrl=SSD1803 =Ok
- 
-int main() {   
-  Timer t;
-
-  pc.printf("TextLCD Enhanced Test. Columns=%d, Rows=%d\n\r", lcd.columns(), lcd.rows());
-    
-  for (int row=0; row<lcd.rows(); row++) {
-    int col=0;
-      
-    pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));      
-//    lcd.putc('-');
-    lcd.putc('0' + row);      
-      
-    for (col=1; col<lcd.columns()-1; col++) {    
-      lcd.putc('*');
-    }
- 
-    pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));      
-    lcd.putc('+');       
-  }    
-
-// Fill screen again and time it
-  t.start();
-
-  for (int row=0; row<lcd.rows(); row++) {
-    int col=0;
-      
-    lcd.putc('0' + row);      
-      
-    for (col=1; col<lcd.columns()-1; col++) {    
-      lcd.putc('*');
-    }
- 
-    lcd.putc('+');       
-  }    
-  t.stop();    
-  pc.printf("All my hard work took %f sec\r\n", t.read());          
-
-// Show cursor as blinking character
-   lcd.setCursor(TextLCD::CurOff_BlkOn);
- 
-// Set and show user defined characters. A maximum of 8 UDCs are supported by the HD44780.
-// They are defined by a 5x7 bitpattern. 
-  lcd.setUDC(0, (char *) udc_0);  // Show |>
-  lcd.putc(0);    
-  lcd.setUDC(1, (char *) udc_1);  // Show <|
-  lcd.putc(1);    
-    
-  pc.printf("Bye now\r\n");          
-}
-
-
-