LCD4884

Dependencies:   LCD4884 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "LCD4884.h"
00003 
00004 LCD4884 object;
00005 AnalogIn analog(A0);
00006 char b[10];
00007 int state_menu=0;
00008 int data=0;
00009 
00010 void choose_menu(int dog)
00011 {
00012     
00013     switch(dog) {
00014             case 1:
00015                 float a=analog.read();
00016                 if( a>0.3 && a<0.5){
00017                     //object.LCD_write_string(3,0,b, MENU_NORMAL);
00018                     object.LCD_clear();
00019                     object.LCD_write_string(0,1,"MENU", MENU_NORMAL);
00020                     object.LCD_write_string(0,2,"1.SET_TIME", MENU_HIGHLIGHT);
00021                     object.LCD_write_string(0,3,"2.FOOD_DATA", MENU_NORMAL);
00022                     object.LCD_write_string(0,4,"3.FOOD_TOTAL", MENU_NORMAL);
00023                     data++;
00024                 }
00025             case 2:
00026                 if( a>0.3 && a<0.5){
00027                     //object.LCD_write_string(3,0,b, MENU_NORMAL);
00028                     object.LCD_write_string(0,1,"MENU", MENU_NORMAL);
00029                     object.LCD_write_string(0,2,"1.SET_TIME", MENU_NORMAL);
00030                     object.LCD_write_string(0,3,"2.FOOD_DATA", MENU_HIGHLIGHT);
00031                     object.LCD_write_string(0,4,"3.FOOD_TOTAL", MENU_NORMAL);
00032                     data++;
00033                 }
00034             case 3:
00035                 if( a>0.3 && a<0.5){
00036                     //object.LCD_write_string(3,0,d, MENU_NORMAL);
00037                     object.LCD_write_string(0,1,"MENU", MENU_NORMAL);
00038                     object.LCD_write_string(0,2,"1.SET_TIME", MENU_NORMAL);
00039                     object.LCD_write_string(0,3,"2.FOOD_DATA", MENU_NORMAL);
00040                     object.LCD_write_string(0,4,"3.FOOD_TOTAL", MENU_HIGHLIGHT);
00041                     data=1;
00042                 }
00043     }
00044 }
00045 int main()
00046 {
00047     object.LCD_init();
00048     while(1) {
00049         if(state_menu == 0){
00050             float a=analog.read();
00051             sprintf(b,"%.01f",a);
00052             object.LCD_write_string(3,0,b, MENU_NORMAL);
00053             object.LCD_write_string(0,1,"MENU", MENU_NORMAL);
00054             object.LCD_write_string(0,2,"1.SET_TIME", MENU_NORMAL);
00055             object.LCD_write_string(0,3,"2.FOOD_DATA", MENU_NORMAL);
00056             object.LCD_write_string(0,4,"3.FOOD_TOTAL", MENU_NORMAL);
00057             if( a>0.3 && a<0.5){
00058                 data=1;
00059                 choose_menu(data);
00060             }
00061 
00062             
00063         }
00064         wait(0.1);
00065     }
00066 }