
Hello World application for the freetronicsLCDShield class
Dependencies: freetronicsLCDShield mbed
main.cpp
00001 #include "mbed.h" 00002 #include "freetronicsLCDShield.h" 00003 00004 /* These are the custom chars 8 of them 1 per row. */ 00005 const char CGRAM_DATA[64]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F, 00006 0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x1F, 00007 0x00,0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F, 00008 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F, 00009 0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F,0x1F, 00010 0x00,0x00,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, 00011 0x00,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, 00012 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F}; 00013 00014 /* Create a freetronics LCD Shield object named LCD */ 00015 /* freetronicsLCDShield LCD(rs, e, d0, d1, d2, d3, bl, a0); */ 00016 /* These are the connections for the Arduino footprint on the KL25Z */ 00017 freetronicsLCDShield LCD(PTA13, PTD5, PTA4, PTA5, PTC8, PTC9, PTA12, PTB0); 00018 00019 int main() { 00020 // Write custom generated chars to the 00021 LCD.writeCGRAM (0x00, &CGRAM_DATA[0], 8); 00022 LCD.writeCGRAM (0x08, &CGRAM_DATA[8], 8); 00023 LCD.writeCGRAM (0x10, &CGRAM_DATA[16], 8); 00024 LCD.writeCGRAM (0x18, &CGRAM_DATA[24], 8); 00025 LCD.writeCGRAM (0x20, &CGRAM_DATA[32], 8); 00026 LCD.writeCGRAM (0x28, &CGRAM_DATA[40], 8); 00027 LCD.writeCGRAM (0x30, &CGRAM_DATA[48], 8); 00028 LCD.writeCGRAM (0x38, &CGRAM_DATA[56], 8); 00029 00030 LCD.cls(); 00031 00032 00033 // The backlight can be turned on or off // 00034 LCD.setBackLight(true); wait(2.0); 00035 // The setBackLight method is overloaded so you can specify it's intensity by supplying it with a float value 00036 LCD.setBackLight((float) 0.05); 00037 00038 while (true) { 00039 LCD.cls(); 00040 LCD.setCursor(false); 00041 // You may want to set the cursor position at a specific location 00042 LCD.setCursorPosition (0, 0); 00043 LCD.printf("* Hello world *"); 00044 00045 // Shift the text on the LCD left ... 00046 for(int i = 0; i < 3; i++) {LCD.shift(true); wait(0.5);} 00047 00048 // Shift right ... 00049 for(int i = 0; i < 6; i++) {LCD.shift(false); wait(0.5);} 00050 00051 // Shift the text back to left ... 00052 for(int i = 0; i < 3; i++) {LCD.shift(true); wait(0.5);} 00053 00054 LCD.setCursorPosition (1,0); 00055 // Let the cursor blink 00056 LCD.setCursor(true, true); 00057 LCD.putc('A'); wait(0.5); 00058 LCD.putc('w'); wait(0.5); 00059 LCD.putc('e'); wait(0.5); 00060 LCD.putc('s'); wait(0.5); 00061 LCD.putc('o'); wait(0.5); 00062 LCD.putc('m'); wait(0.5); 00063 LCD.putc('e'); wait(0.5); 00064 00065 LCD.cls(); 00066 LCD.setCursor(false); 00067 // You may want to set the cursor position at a specific location 00068 LCD.setCursorPosition (0, 0); 00069 LCD.printf("Backlight = %0.3f", 0.000); 00070 int n = 0; 00071 00072 for (float intensity = 0.125; intensity <= 1.0; intensity += 0.125) { 00073 // Fire up the backlight 00074 LCD.setBackLight((float) intensity); 00075 // Display intensity 00076 LCD.setCursorPosition(0,11); 00077 LCD.printf("%0.3f", intensity); 00078 00079 // Print the custom char's 0 .. 7 00080 LCD.setCursorPosition(1,4+n); 00081 LCD.putc(n); 00082 n++; 00083 wait(0.5); 00084 } 00085 } 00086 }
Generated on Thu Jul 14 2022 22:45:40 by
