Daniel Scarnatto
/
STM32F103C8T6_TextLCD
Simple analog input and LCD 4 bit Example reading a LM35. Tested in BluePill board
Revision 2:93417af6f469, committed 2020-07-28
- Comitter:
- dscarnatto
- Date:
- Tue Jul 28 09:20:47 2020 +0000
- Parent:
- 1:e10c603cf0ae
- Commit message:
- first commit;
Changed in this revision
diff -r e10c603cf0ae -r 93417af6f469 main.cpp --- a/main.cpp Tue Feb 05 14:00:02 2019 +0000 +++ b/main.cpp Tue Jul 28 09:20:47 2020 +0000 @@ -1,60 +1,43 @@ /* Hello World! for the TextLCD Enhanced Library*/ +//Probado en el BluePill 27/07/20 #include "mbed.h" #include "TextLCD.h" // Host PC Communication channels -Serial pc(PA_2, PA_3); // tx, rx - +//Serial pc(PA_2, PA_3); // tx, rx +AnalogIn LM35(PA_7); // LCD instantiation -TextLCD lcd(PA_8, PA_9, PA_10, PA_11, PA_12, PA_15, TextLCD::LCD16x2); // 4-bit bus: RS, E, D4, D5, D6, D7 +TextLCD lcd(PB_4, PB_3, PB_12, PB_13, PB_14, PB_15, TextLCD::LCD20x4); // 4-bit bus: RS, E, D4, D5, D6, D7 Timer t; int main() { - 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('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; + //pc.printf("TextLCD Enhanced Test. Columns=%d, Rows=%d\n\r", lcd.columns(), lcd.rows()); + lcd.printf("Funka locoso"); + float tempC,tempF,a[10],avg; + int i; + lcd.locate(0,1); + while(1) { - lcd.putc('0' + row); - - for (col=1; col<lcd.columns()-1; col++) { - lcd.putc('*'); + avg=0; + //Toma 10 lecturas del LM35 + for(i=0; i<10; i++) { + a[i]=LM35.read(); + wait(.02); } - - lcd.putc('+'); - } - t.stop(); - pc.printf("All my hard work took %f sec\r\n", t.read()); + //Calcula el promedio + for(i=0; i<10; i++) { + avg=avg+(a[i]/10); + } + //Ajusta conversion -// Show cursor as blinking character - lcd.setCursor(TextLCD::CurOff_BlkOn); + tempC=(avg*3.685503686*100); + tempF=(9.0*tempC)/5.0 + 32.0; + //Imprime en LCD + lcd.printf("Temp = %.0f C -> %.0f F\r\n", tempC,tempF); -// 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"); + wait(1); + lcd.locate(0,1); + } }
diff -r e10c603cf0ae -r 93417af6f469 mbed.bld --- a/mbed.bld Tue Feb 05 14:00:02 2019 +0000 +++ b/mbed.bld Tue Jul 28 09:20:47 2020 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file
diff -r e10c603cf0ae -r 93417af6f469 mbed1.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed1.bld Tue Jul 28 09:20:47 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc \ No newline at end of file