PICSimLab - Programmable IC Simulator Laboratory 0.9.3
PICSimLab - API
Loading...
Searching...
No Matches
picsimlab1.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2010-2026 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
48
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_Code;
86 CPMenu menu1_Help;
87 CItemMenu menu1_File_LoadHex;
88 CItemMenu menu1_File_ReloadLast;
89 CItemMenu menu1_File_SaveHex;
90 CItemMenu menu1_File_Configure;
91 CItemMenu menu1_File_SaveWorkspace;
92 CItemMenu menu1_File_LoadWorkspace;
93 CItemMenu menu1_File_LoadBoardDemo;
94 CItemMenu menu1_File_Exit;
95 CItemMenu menu1_Modules_Oscilloscope;
96 CItemMenu menu1_Modules_Spareparts;
97 CItemMenu menu1_Tools_SerialTerm;
98 CItemMenu menu1_Tools_SerialRemoteTank;
99 CItemMenu menu1_Tools_Esp8266ModemSimulator;
100 CItemMenu menu1_Tools_ArduinoBootloader;
101 CItemMenu menu1_Tools_MPLABXDebuggerPlugin;
102 CItemMenu menu1_Tools_PinViewer;
103 CItemMenu menu1_Code_Project_Wizard;
104 CItemMenu menu1_Code_Open_Active_Project;
105 CItemMenu menu1_Code_Open_Active_Project_Dir;
106 CItemMenu menu1_Help_Contents;
107 CItemMenu menu1_Help_Board;
108 CItemMenu menu1_Help_Examples;
109 CItemMenu menu1_Help_About_Board;
110 CItemMenu menu1_Help_About_PICSimLab;
111 CItemMenu menu1_Help_Check_for_Update;
112 CStatusbar statusbar1;
113 CToggleButton togglebutton1;
114 CFileDialog filedialog2;
115 /*#Events*/
116 void _EvOnCreate(CControl* control);
117 void _EvOnDestroy(CControl* control);
118 void _EvOnShow(CControl* control);
119 void _EvOnDropFile(CControl* control, const lxString fname);
120 void timer1_EvOnTime(CControl* control);
121 void timer2_EvOnTime(CControl* control);
122 void filedialog1_EvOnClose(const int retId);
123 void draw1_EvMouseMove(CControl* control, const unsigned int button, const unsigned int x, const unsigned int y,
124 const unsigned int state);
125 void draw1_EvMouseButtonPress(CControl* control, const unsigned int button, const unsigned int x,
126 const unsigned int y, const unsigned int state);
127 void draw1_EvMouseButtonRelease(CControl* control, const unsigned int button, const unsigned int x,
128 const unsigned int y, const unsigned int state);
129 void draw1_EvKeyboardPress(CControl* control, const unsigned int key, const unsigned int hkey,
130 const unsigned int mask);
131 void draw1_EvKeyboardRelease(CControl* control, const unsigned int key, const unsigned int hkey,
132 const unsigned int mask);
133 void combo1_EvOnComboChange(CControl* control);
134 void menu1_File_LoadHex_EvMenuActive(CControl* control);
135 void menu1_File_ReloadLast_EvMenuActive(CControl* control);
136 void menu1_File_SaveHex_EvMenuActive(CControl* control);
137 void menu1_File_Configure_EvMenuActive(CControl* control);
138 void menu1_File_SaveWorkspace_EvMenuActive(CControl* control);
139 void menu1_File_LoadWorkspace_EvMenuActive(CControl* control);
140 void menu1_File_LoadBoardDemo_EvMenuActive(CControl* control);
141 void menu1_File_Exit_EvMenuActive(CControl* control);
142 void menu1_Modules_Oscilloscope_EvMenuActive(CControl* control);
143 void menu1_Modules_Spareparts_EvMenuActive(CControl* control);
144 void menu1_Tools_SerialTerm_EvMenuActive(CControl* control);
145 void menu1_Tools_SerialRemoteTank_EvMenuActive(CControl* control);
146 void menu1_Tools_Esp8266ModemSimulator_EvMenuActive(CControl* control);
147 void menu1_Tools_ArduinoBootloader_EvMenuActive(CControl* control);
148 void menu1_Tools_MPLABXDebuggerPlugin_EvMenuActive(CControl* control);
149 void menu1_Tools_PinViewer_EvMenuActive(CControl* control);
150 void menu1_Code_Project_Wizard_EvMenuActive(CControl* control);
151 void menu1_Code_Open_Active_Project_EvMenuActive(CControl* control);
152 void menu1_Code_Open_Active_Project_Dir_EvMenuActive(CControl* control);
153 void menu1_Help_Contents_EvMenuActive(CControl* control);
154 void menu1_Help_Examples_EvMenuActive(CControl* control);
155 void menu1_Help_Board_EvMenuActive(CControl* control);
156 void menu1_Help_About_Board_EvMenuActive(CControl* control);
157 void menu1_Help_About_PICSimLab_EvMenuActive(CControl* control);
158 void menu1_Help_Check_for_Update_EvMenuActive(CControl* control);
159 void togglebutton1_EvOnToggleButton(CControl* control);
160 void filedialog2_EvOnClose(const int retId);
161
162 /*#Others*/
163 // lxrad automatic generated block end, don't edit above!
164
165 CPWindow1(void);
166 ~CPWindow1(void);
167
168 void board_Event(CControl* control);
169 void board_ButtonEvent(CControl* control, unsigned int button, unsigned int x, unsigned int y, unsigned int state);
170 void thread1_EvThreadRun(CControl* control);
171 void thread2_EvThreadRun(CControl* control);
172 void thread3_EvThreadRun(CControl* control);
173
174 void menu1_EvBoard(CControl* control);
175 void menu1_EvMicrocontroller(CControl* control);
176 void DrawBoard(void);
177 static void OnUpdateStatus(const int field, const std::string msg);
178 static void OnConfigure(void);
179 static void OnClockSet(const float clk, const int update);
180 static void OnReadPreferences(const char* name, const char* value, const int create);
181 static void OnSavePrefs(void);
182 static void OnLoadHexFile(const std::string fname);
183 static void OnOpenLoadHexFileDialog(void);
184 static void OnEndSimulation(void);
185 static void* OnUpdateGUI(const int id, const PICSimlabGUIType type, const PICSimlabGUIAction action,
186 const void* arg);
187 static void OnConfigMenuGUI(const PICSimlabGUIMenu type);
188 static int OnCanvasCmd(const CanvasCmd_t cmd);
189 static int OnWindowCmd(const int id, const char* ControlName, const PICSimLabWindowAction action, const char* Value,
190 void* ReturnBuff);
191 static int OnSystemCmd(const PICSimLabSystemCmd cmd, const char* Arg, void* ReturnBuff);
192
193 void Configure(void);
194 int GetNeedClkUpdate(void) { return need_clkupdate; };
195 void SetNeedClkUpdate(const int ncu) { need_clkupdate = ncu; };
196
197 lxBitmap* Bitmaps[BITMAPS_MAX];
198 CPWindow* Windows[BOARDS_MAX];
199 lxMutex* Mutexs[MUTEX_MAX];
200 lxaudio* AudioChannels[MAX_AUDIO];
201
202 int WinCmd(CControl* ctrl, const PICSimLabWindowAction action, const char* Value, void* ReturnBuff);
203
204private:
205 CItemMenu MBoard[BOARDS_MAX];
206 CItemMenu MMicro[MAX_MIC];
207 int pa;
208 float over;
209 int crt;
210 int zerocount;
211 int need_clkupdate;
212 int force_resize;
213
214 CThread thread1; // main simulation
215 CThread thread2; // rcontrol
216 CThread thread3; // boards
217
218#ifndef _NOTHREAD
219 std::mutex cpu_mutex;
220 std::condition_variable cpu_cond;
221#endif
222};
223
224extern CPWindow1 Window1;
225
226#endif /*#CPWINDOW1*/
CPWindow1 class.
Definition picsimlab1.h:68
Definition draw.h:81