00001 /* 00002 **************************************************************************** 00003 * 00004 * simulavr - A simulator for the Atmel AVR family of microcontrollers. 00005 * Copyright (C) 2001, 2002, 2003 Klaus Rudolph 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 **************************************************************************** 00022 * 00023 * $Id$ 00024 */ 00025 00026 #ifndef LCD_H_INCLUDED 00027 #define LCD_H_INCLUDED 00028 00029 00030 #include <fstream> 00031 #include <string> 00032 00033 #include "systemclocktypes.h" 00034 #include "simulationmember.h" 00035 //#include "hardware.h" 00036 #include "ui.h" 00037 #include "pin.h" 00038 00039 typedef enum { 00040 IDLE, 00041 POWER_ON, // First State after Reset 00042 PWR_AFTER_FS1,// After first Function Set Cmd no Busy Flag 00043 PWR_AFTER_FS2,// After second Function Set Cmd no Busy Flag 00044 PWR_ON_FINISH,// After third Function Set Cmd no Busy Flag. After the next CMD BF is valid 00045 CMDEXEC // Executing any command after init 00046 } t_myState; 00047 00048 00052 class Lcd : public SimulationMember { 00053 protected: 00054 UserInterface *ui; 00055 std::string name; 00056 unsigned char myPortValue; 00057 std::map<std::string, Pin*> allPins; 00058 Pin d0; 00059 Pin d1; 00060 Pin d2; 00061 Pin d3; 00062 00063 Pin enable; 00064 Pin readWrite; 00065 Pin commandData; 00066 00067 unsigned int CmdExecTime_ns; // Command Execution Time 00068 t_myState myState; // LCD State-Event machine 00069 char myd3; // internal D3 00070 00071 00072 int merke_x; 00073 int merke_y; 00074 00075 void LcdWriteData(unsigned char data); 00076 unsigned int LcdWriteCommand(unsigned char command); 00077 00078 std::ofstream debugOut; 00079 void SendCursorPosition(); 00080 00081 unsigned char lastPortValue; 00082 int readLow; 00083 unsigned char command; 00084 int enableOld; 00085 00086 public: 00087 virtual int Step(bool &trueHwStep, SystemClockOffset *timeToNextStepIn_ns=0); 00088 //Lcd(UserInterface *ui, const string &name, const string &baseWindow); 00089 Lcd(UserInterface *ui, const char *name, const char *baseWindow); 00090 virtual ~Lcd(); 00091 Pin *GetPin(const char *name); 00092 }; 00093 00094 #endif