4 errors
Dependencies: KS0108_PCF8574 mbed
main.cpp
- Committer:
- GuiTwo
- Date:
- 2012-09-11
- Revision:
- 3:ec80bb6ff5da
- Parent:
- 2:66e4ebaba5df
File content as of revision 3:ec80bb6ff5da:
#include "mbed.h" #include "menbed.h" #include "PCF8574_DataBus.h" AnalogIn photocell(p15); PwmOut led1(LED1); PwmOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); I2C i2c(p9, p10); PCF8574_DataBus DB = PCF8574_DataBus(i2c, 0x40); float photocellVoltage(void) {return 3.3 * photocell;} void setLed1Pwm (float d) {led1 = d / 100.0;} float getLed1Pwm (void) {return led1 * 100.0;} void setLed2Pwm (float d) {led2 = d / 100.0;} float getLed2Pwm (void) {return led2 * 100.0;} void toggleLed3 () {led3 = led3 ^ 1;} void lightLed4 () {led4 = 1;} void extinguishLed4 () {led4 = 0;} int main() { /* // Declare all the submenus so that they can be referenced in the // definitions of other menus MenbedMenu *rootMenu; //MenbedMenu *measurementMenu; //MenbedMenu *controlMenu; //MenbedMenu *aboutMenu; MenbedMenuItem *rootMenuItems[2] = { new MenbedMenuItem (NULL, NULL, false, NULL, " Test"), new MenbedMenuItem (NULL, &rootMenu, true, NULL, "Home") }; //new MenbedMenuItem (NULL, &measurementMenu, false, NULL, "Measurements"), //new MenbedMenuItem (NULL, &controlMenu, false, NULL, "Controls"), //new MenbedMenuItem (NULL, &aboutMenu, false, NULL, "About"), rootMenu = new MenbedMenu (2, rootMenuItems); */ //MenbedMenuParam photocellParam (photocellVoltage, NULL, false, 0.0, 0.0, 0.0); // Having created the parameter, we pass it as the 4th argument of the // MenbedMenuItem constructor. Note the \t-offset %.2f format specified // in the menu item text. The menu system will call the photocellVoltage // function specified in the parameter constructor above and then print the // float that it returns in place of the %.2f in the menu text. /* MenbedMenuItem *measurementMenuItems[2] = { new MenbedMenuItem (NULL, NULL, false, &photocellParam, "Photocell: \t%.2f\tV"), new MenbedMenuItem (NULL, &rootMenu, true, NULL, "Home") }; measurementMenu = new MenbedMenu (2, measurementMenuItems);*/ /*MenbedMenuParam pwmParam1 (getLed1Pwm, setLed1Pwm, true, 0.0, 100.0, 1.0); MenbedMenuParam pwmParam2 (getLed2Pwm, setLed2Pwm, false, 0.0, 100.0, 1.0); // The third, fourth, and fifth items of the control menu demonstrate // functions when a menu item is selected. The ability to call a function // can be combined with either displaying a submenu or editing a parameter. MenbedMenuItem *controlMenuItems[6] = { new MenbedMenuItem (NULL, NULL, false, &pwmParam1, "LED1 PWM: \t%.0f\t%"), new MenbedMenuItem (NULL, NULL, false, &pwmParam2, "LED2 PWM: \t%.0f\t%"), new MenbedMenuItem (toggleLed3, NULL, false, NULL, "Toggle LED3"), new MenbedMenuItem (lightLed4, NULL, false, NULL, "Light LED4"), new MenbedMenuItem (extinguishLed4, NULL, false, NULL, "Extinguish LED4"), new MenbedMenuItem (NULL, &rootMenu, true, NULL, "Home") }; controlMenu = new MenbedMenu (6, controlMenuItems); // About menu--there's nothing fancy here, but the lack of a "Home" item // forces the user to employ the cancel button, either directly or by // pushing and hold the select button, to return to the root menu. MenbedMenuItem *aboutMenuItems[3] = { new MenbedMenuItem (NULL, NULL, false, NULL, " NXP3915"), new MenbedMenuItem (NULL, NULL, false, NULL, " Copyright 2011"), new MenbedMenuItem (NULL, NULL, false, NULL, " xxxxxxxx@xxx.xxx") }; aboutMenu = new MenbedMenu (3, aboutMenuItems); */ // Having created the menus, menu items, and item parameters, we are ready // to instantiate the display. MenbedDisplayHD44780 extends MenbedDisplay // and implements the all-important writeLine function allong with some // other less important functions. The pins we pass to the constructor // specify the physical interface connection to the LCD. //MenbedDisplay *LCD = new MenbedDisplay; /* KS0108 *LCD = new KS0108 ( p21,//_RST p5,//_DI p30,//_RW p29,//_E p25,//_CS2 p6,//_CS1 DB ); */ //Menbed (PinName select, PinName down, PinName up, PinName cancel,MenbedMenu *rootMenu,MenbedDisplay *display); //Four buttons (select, down, up, cancel ) // Menbed menbed(p8, p11, p12, p13, rootMenu, LCD); while(1) {} }