PICSimLab - Programmable IC Simulator Laboratory 0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
spareparts.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
26#ifndef SPAREPARTS
27#define SPAREPARTS
28
29#include "draw.h"
30#include "part.h"
31#include "types.h"
32
33#define IOINIT 110
34
36public:
38
39 void Init(void);
40
41 void UpdateAll(const int force = 0);
42 int GetCount(void) { return partsc; };
43 part* GetPart(const int partn);
44 void DeleteParts(void);
45 void ResetPullupBus(unsigned char pin);
46 void SetPullupBus(unsigned char pin, unsigned char value);
47 unsigned char GetPullupBus(unsigned char pin);
48
52 void Process(void);
53
57 void PreProcess(void);
58
62 void PostProcess(void);
63
67 std::string GetPinsNames(void);
68
72 std::string GetPinName(unsigned char pin);
73
74 const picpin* GetPinsValues(void);
75 void SetPin(unsigned char pin, unsigned char value);
76 void SetAPin(unsigned char pin, float value);
77 void SetPinDOV(unsigned char pin, unsigned char ovalue);
78 void SetPinDir(unsigned char pin, unsigned char dir);
79 void WritePin(unsigned char pin, unsigned char value);
80 void WritePinA(unsigned char pin, unsigned char avalue);
81 void WritePinOA(unsigned char pin, unsigned short oavalue);
82 unsigned char RegisterIOpin(std::string pname, unsigned char pin = 0, unsigned char dir = PD_OUT);
83 unsigned char UnregisterIOpin(unsigned char pin);
84 part* AddPart(const char* partname, const int x, const int y, const float scale, board* pboard_);
85 void DeletePart(const int partn);
86 void SetUseAlias(const int use) { useAlias = use; };
87 unsigned char GetUseAlias(void) { return useAlias; };
88 bool SavePinAlias(std::string fname);
89 bool LoadPinAlias(std::string fname, unsigned char show_error_msg = 0);
90 bool LoadConfig(std::string fname, const int disable_debug = 0);
91 void ClearPinAlias(void);
92 std::string GetAliasFname(void) { return alias_fname; };
93 float GetScale(void) { return scale; };
94 void SetScale(float s) { scale = s; };
95 void Reset(void);
96
97 void Setfdtype(int value);
98
99 int Getfdtype(void) { return fdtype; };
100
101 void ReadPreferences(char* name, char* value);
102 void WritePreferences(void);
103
104 bool SaveConfig(std::string fname);
105
106 std::string GetLoadConfigFile(void) { return LoadConfigFile; };
107
108 void SetfdOldFilename(const std::string ofn);
109
110 std::string GetOldFilename(void) { return oldfname; };
111
112 void SetPartOnDraw(int pod) { PartOnDraw = pod; };
113 int GetPartOnDraw(void) { return PartOnDraw; };
114
115 static int CanvasCmd(const CanvasCmd_t cmd);
116
117 static int WPropCmd(const char* ControlName, const PICSimLabWindowAction action, const char* Value,
118 void* ReturnBuff = NULL);
119
120 static int WindowCmd(const int id, const char* ControlName, const PICSimLabWindowAction action, const char* Value,
121 void* ReturnBuff = NULL);
122
123 int (*OnCanvasCmd)(const CanvasCmd_t cmd);
124
125 int (*OnWindowCmd)(const int id, const char* ControlName, const PICSimLabWindowAction action, const char* Value,
126 void* ReturnBuff);
127
128private:
129 float scale;
130 board* pboard;
131 std::string PinNames[256];
132 std::string PinAlias[256];
133 std::string alias_fname;
134 std::string LoadConfigFile;
135 picpin* Pins;
136 unsigned char PinsCount;
137 unsigned char useAlias;
138 int partsc;
139 part* parts[MAX_PARTS];
140 int partsc_aup; // always update list
141 part* parts_aup[MAX_PARTS]; // always update list
142 unsigned char pullup_bus[IOINIT];
143 int pullup_bus_count;
144 unsigned char pullup_bus_ptr[IOINIT];
145 int fdtype;
146 std::string oldfname;
147 int PartOnDraw;
148};
149
150extern CSpareParts SpareParts;
151
152#endif // SPAREPARTS
Definition spareparts.h:35
void Process(void)
Execute the process code of spare parts N times (where N is the number of steps in 100ms)
Definition spareparts.cc:545
std::string GetPinsNames(void)
Return the name of all pins.
Definition spareparts.cc:118
std::string GetPinName(unsigned char pin)
Return the name of one pin.
Definition spareparts.cc:145
void PostProcess(void)
Execute the post process code of spare parts one time per 100ms.
Definition spareparts.cc:565
void PreProcess(void)
Execute the pre process code of spare parts one time per 100ms.
Definition spareparts.cc:520
Board class.
Definition board.h:111
PART class.
Definition part.h:49
Definition draw.h:77