PICSimLab - Programmable IC Simulator Laboratory 0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
picsimlab1.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2010-2024 Luis Claudio GambĂ´a Lopes <lcgamboa@yahoo.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 For e-mail suggestions : lcgamboa@yahoo.com
24 ######################################################################## */
25
49#ifndef CPWINDOW1
50#define CPWINDOW1
51
52#include <lxrad.h>
53#include <condition_variable>
54#include <mutex>
55#include "lib/board.h"
56#include "lib/picsimlab.h"
57
58#define MAX_MIC 140
59#define MAX_AUDIO 10
60#define BITMAPS_MAX 50
61#define MUTEX_MAX 30
62
68class CPWindow1 : public CPWindow {
69public:
70 // lxrad automatic generated block start, don't edit below!
71 /*#Controls*/
72 CTimer timer1;
73 CTimer timer2;
74 CFileDialog filedialog1;
75 CDraw draw1;
76 CCombo combo1;
77 CLabel label1;
78 CLabel label2;
79 CMenu menu1;
80 CPMenu menu1_File;
81 CPMenu menu1_Board;
82 CPMenu menu1_Microcontroller;
83 CPMenu menu1_Modules;
84 CPMenu menu1_Tools;
85 CPMenu menu1_Help;
86 CItemMenu menu1_File_LoadHex;
87 CItemMenu menu1_File_ReloadLast;
88 CItemMenu menu1_File_SaveHex;
89 CItemMenu menu1_File_Configure;
90 CItemMenu menu1_File_SaveWorkspace;
91 CItemMenu menu1_File_LoadWorkspace;
92 CItemMenu menu1_File_LoadBoardDemo;
93 CItemMenu menu1_File_Exit;
94 CItemMenu menu1_Modules_Oscilloscope;
95 CItemMenu menu1_Modules_Spareparts;
96 CItemMenu menu1_Tools_SerialTerm;
97 CItemMenu menu1_Tools_SerialRemoteTank;
98 CItemMenu menu1_Tools_Esp8266ModemSimulator;
99 CItemMenu menu1_Tools_ArduinoBootloader;
100 CItemMenu menu1_Tools_MPLABXDebuggerPlugin;
101 CItemMenu menu1_Tools_PinViewer;
102 CItemMenu menu1_Help_Contents;
103 CItemMenu menu1_Help_Board;
104 CItemMenu menu1_Help_Examples;
105 CItemMenu menu1_Help_About_Board;
106 CItemMenu menu1_Help_About_PICSimLab;
107 CStatusbar statusbar1;
108 CToggleButton togglebutton1;
109 CFileDialog filedialog2;
110 /*#Events*/
111 void _EvOnCreate(CControl* control);
112 void _EvOnDestroy(CControl* control);
113 void _EvOnShow(CControl* control);
114 void _EvOnDropFile(CControl* control, const std::string fname);
115 void timer1_EvOnTime(CControl* control);
116 void timer2_EvOnTime(CControl* control);
117 void filedialog1_EvOnClose(const int retId);
118 void draw1_EvMouseMove(CControl* control, const unsigned int button, const unsigned int x, const unsigned int y,
119 const unsigned int state);
120 void draw1_EvMouseButtonPress(CControl* control, const unsigned int button, const unsigned int x,
121 const unsigned int y, const unsigned int state);
122 void draw1_EvMouseButtonRelease(CControl* control, const unsigned int button, const unsigned int x,
123 const unsigned int y, const unsigned int state);
124 void draw1_EvKeyboardPress(CControl* control, const unsigned int key, const unsigned int hkey,
125 const unsigned int mask);
126 void draw1_EvKeyboardRelease(CControl* control, const unsigned int key, const unsigned int hkey,
127 const unsigned int mask);
128 void combo1_EvOnComboChange(CControl* control);
129 void menu1_File_LoadHex_EvMenuActive(CControl* control);
130 void menu1_File_ReloadLast_EvMenuActive(CControl* control);
131 void menu1_File_SaveHex_EvMenuActive(CControl* control);
132 void menu1_File_Configure_EvMenuActive(CControl* control);
133 void menu1_File_SaveWorkspace_EvMenuActive(CControl* control);
134 void menu1_File_LoadWorkspace_EvMenuActive(CControl* control);
135 void menu1_File_LoadBoardDemo_EvMenuActive(CControl* control);
136 void menu1_File_Exit_EvMenuActive(CControl* control);
137 void menu1_Modules_Oscilloscope_EvMenuActive(CControl* control);
138 void menu1_Modules_Spareparts_EvMenuActive(CControl* control);
139 void menu1_Tools_SerialTerm_EvMenuActive(CControl* control);
140 void menu1_Tools_SerialRemoteTank_EvMenuActive(CControl* control);
141 void menu1_Tools_Esp8266ModemSimulator_EvMenuActive(CControl* control);
142 void menu1_Tools_ArduinoBootloader_EvMenuActive(CControl* control);
143 void menu1_Tools_MPLABXDebuggerPlugin_EvMenuActive(CControl* control);
144 void menu1_Tools_PinViewer_EvMenuActive(CControl* control);
145 void menu1_Help_Contents_EvMenuActive(CControl* control);
146 void menu1_Help_Examples_EvMenuActive(CControl* control);
147 void menu1_Help_Board_EvMenuActive(CControl* control);
148 void menu1_Help_About_Board_EvMenuActive(CControl* control);
149 void menu1_Help_About_PICSimLab_EvMenuActive(CControl* control);
150 void togglebutton1_EvOnToggleButton(CControl* control);
151 void filedialog2_EvOnClose(const int retId);
152
153 /*#Others*/
154 // lxrad automatic generated block end, don't edit above!
155
156 CPWindow1(void);
157 ~CPWindow1(void);
158
159 void board_Event(CControl* control);
160 void board_ButtonEvent(CControl* control, unsigned int button, unsigned int x, unsigned int y, unsigned int state);
161 void thread1_EvThreadRun(CControl* control);
162 void thread2_EvThreadRun(CControl* control);
163 void thread3_EvThreadRun(CControl* control);
164
165 void menu1_EvBoard(CControl* control);
166 void menu1_EvMicrocontroller(CControl* control);
167 void DrawBoard(void);
168 static void OnUpdateStatus(const int field, const std::string msg);
169 static void OnConfigure(void);
170 static void OnClockSet(const float clk, const int update);
171 static void OnReadPreferences(const char* name, const char* value, const int create);
172 static void OnSavePrefs(void);
173 static void OnLoadHexFile(const std::string fname);
174 static void OnOpenLoadHexFileDialog(void);
175 static void OnEndSimulation(void);
176 static void* OnUpdateGUI(const int id, const PICSimlabGUIType type, const PICSimlabGUIAction action,
177 const void* arg);
178 static void OnConfigMenuGUI(const PICSimlabGUIMenu type);
179 static int OnCanvasCmd(const CanvasCmd_t cmd);
180 static int OnWindowCmd(const int id, const char* ControlName, const PICSimLabWindowAction action, const char* Value,
181 void* ReturnBuff);
182 static int OnSystemCmd(const PICSimLabSystemCmd cmd, const char* Arg, void* ReturnBuff);
183
184 void Configure(void);
185 int GetNeedClkUpdate(void) { return need_clkupdate; };
186 void SetNeedClkUpdate(const int ncu) { need_clkupdate = ncu; };
187
188 lxBitmap* Bitmaps[BITMAPS_MAX];
189 CPWindow* Windows[BOARDS_MAX];
190 lxMutex* Mutexs[MUTEX_MAX];
191 lxaudio* AudioChannels[MAX_AUDIO];
192
193 int WinCmd(CControl* ctrl, const PICSimLabWindowAction action, const char* Value, void* ReturnBuff);
194
195private:
196 CItemMenu MBoard[BOARDS_MAX];
197 CItemMenu MMicro[MAX_MIC];
198 int pa;
199 float over;
200 int crt;
201 int zerocount;
202 int need_clkupdate;
203
204 CThread thread1; // main simulation
205 CThread thread2; // rcontrol
206 CThread thread3; // boards
207
208#ifndef _NOTHREAD
209 std::mutex cpu_mutex;
210 std::condition_variable cpu_cond;
211#endif
212};
213
214extern CPWindow1 Window1;
215
216#endif /*#CPWINDOW1*/
CPWindow1 class.
Definition picsimlab1.h:68
Definition draw.h:80