Test of LCD code

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "lcd_i2c.h"
00003 
00004 Serial pc(USBTX, USBRX);    // tx, rx
00005 extern char update[NUPDATE];
00006 
00007 int main() {
00008 char ch, row, col;
00009 int address, frequency, rc;
00010 
00011     row = col = 0;
00012     pc.printf("Enter address ");
00013     pc.scanf("%x", &address);
00014     pc.printf("\n\rEnter frequency ");
00015     pc.scanf("%d", &frequency);
00016     pc.printf("\n\raddress: 0x%x   frequency=%d\n\r", address, frequency);
00017       while(1)
00018     {
00019         pc.scanf("%c ", &ch);
00020         if (ch == 27)
00021             break;
00022         pc.printf("%c", ch);
00023         switch (ch)
00024         {
00025         case 'c':
00026             rc = initLcd(address, frequency);
00027             pc.printf("rc: %d ", rc);
00028             row = 0;
00029             col = 0;
00030             break;
00031         case 'd':
00032             rc = lcdWriteMsg("Now is the time");
00033             pc.printf("rc: %d ", rc);
00034            break;
00035         case 'e':
00036             rc = lcdPositionCursor(row, col);
00037             pc.printf("rc: %d ", rc);
00038             row ^= 1;
00039             col = (col + 1) % 20;
00040             break;
00041         case 'f':
00042             rc = lcdClearDisplay();
00043             pc.printf("rc: %d ", rc);
00044             break;
00045         case 'g':
00046         {
00047             int k, j;
00048             j = 0;
00049             pc.printf("\n\r");
00050             for (k = 0; k < 6; k++)
00051             {
00052                 pc.printf("%02x  %02x  %02x\n\r", update[j], update[j+1], update[j+2]);
00053                 j += 3;
00054             }
00055         }
00056             break;
00057         default:
00058             break;
00059         }
00060     }
00061     pc.printf("done\n\r");
00062 }