Commit c42b5089 authored by lcgamboa's avatar lcgamboa

fix: Fix Spareparts Prop window position on windows !minor

parent bbdb4cf0
......@@ -90,6 +90,7 @@ cpart_lblock::cpart_lblock(const unsigned x, const unsigned y, const char* name,
input_pins[7] = 0;
output_value = 0;
output_value_prev = !output_value;
output_pins[0] = 0;
output_pins[1] = SpareParts.RegisterIOpin("LB0");
......@@ -192,6 +193,14 @@ void cpart_lblock::PreProcess(void) {
void cpart_lblock::Process(void) {
const picpin* ppins = SpareParts.GetPinsValues();
// Add one clock pulse delay to output
if (output_value_prev != output_value) {
SpareParts.SetPin(output_pins[0], output_value);
SpareParts.WritePin(output_pins[1], output_value);
output_value_prev = output_value;
ioupdated = 1;
}
if (ioupdated) {
switch (gatetype) {
case LG_NOT:
......@@ -239,10 +248,7 @@ void cpart_lblock::Process(void) {
}
output_value = !output_value;
break;
break;
}
SpareParts.SetPin(output_pins[0], output_value);
SpareParts.WritePin(output_pins[1], output_value);
}
mcount++;
......@@ -256,21 +262,21 @@ void cpart_lblock::Process(void) {
void cpart_lblock::PostProcess(void) {
const long int NSTEPJ = PICSimLab.GetNSTEPJ();
// const picpin* ppins = SpareParts.GetPinsValues();
/*
const picpin* ppins = SpareParts.GetPinsValues();
SpareParts.WritePinOA(output_pins[1], ((output_pins_alm * 200.0) / NSTEPJ) + 55);
for (unsigned int i = 0; i < Size; i++) {
if (input_pins[i] && (output_ids[O_L1 + i]->value != ppins[input_pins[i] - 1].oavalue)) {
output_ids[O_L1 + i]->value = ppins[input_pins[i] - 1].oavalue;
output_ids[O_L1 + i]->update = 1;
if (input_pins[i] && (output_ids[O_IN1 + i]->value != ppins[input_pins[i] - 1].oavalue)) {
output_ids[O_IN1 + i]->value = ppins[input_pins[i] - 1].oavalue;
output_ids[O_IN1 + i]->update = 1;
}
}
*/
// SpareParts.WritePinOA(output_pins[1],
// (ppins[output_pins[1] - 1].oavalue + ((output_pins_alm * 200.0) / NSTEPJ) + 55) / 2);
SpareParts.WritePinOA(output_pins[1], ((output_pins_alm * 200.0) / NSTEPJ) + 55);
SetUpdate(1); // TODO update only when necessary
if ((output_ids[O_OUT]->value != ppins[output_pins[1] - 1].oavalue)) {
output_ids[O_OUT]->value = ppins[output_pins[1] - 1].oavalue;
output_ids[O_OUT]->update = 1;
}
}
unsigned short cpart_lblock::GetInputId(char* name) {
......@@ -360,6 +366,8 @@ void cpart_lblock::ConfigurePropertiesWindow(void) {
SetPCWComboWithPinNames("combo8", input_pins[7]);
SetPCWComboWithPinNames("combo9", output_pins[0]);
SpareParts.WPropCmd("label_10", PWA_LABELSETTEXT, std::to_string(output_pins[1]).c_str());
SpareParts.WPropCmd("combo11", PWA_COMBOSETITEMS, "NOT,BUFFER,AND,NAND,OR,NOR,XOR,XNOR,");
SpareParts.WPropCmd("combo11", PWA_COMBOPROPEV, "1");
switch (gatetype) {
......
......@@ -60,6 +60,7 @@ private:
unsigned char output_pins[2];
unsigned long output_pins_alm;
unsigned char output_value;
unsigned char output_value_prev;
int OWidth;
int OHeight;
int xoff;
......
......@@ -165,9 +165,12 @@ void CPWindow5::pmenu2_Properties_EvMenuActive(CControl* control) {
const PCWProp* items = SpareParts.GetPart(PartSelected)->GetPCWProperties();
Windows[PW_WPROP]->SetName("window1"); // must be the same as in xml
Application->ACreateWindow(Windows[PW_WPROP]);
Windows[PW_WPROP]->HideExclusive();
Windows[PW_WPROP]->DestroyChilds();
Windows[PW_WPROP]->SetTitle(SpareParts.GetPart(PartSelected)->GetName());
Windows[PW_WPROP]->SetWidth(370);
Windows[PW_WPROP]->SetX(SpareParts.GetPart(PartSelected)->GetX() + GetX() - offsetx);
Windows[PW_WPROP]->SetY(SpareParts.GetPart(PartSelected)->GetY() + GetY() - offsety);
CLabel* label;
CCombo* combo;
......@@ -388,9 +391,6 @@ void CPWindow5::pmenu2_Properties_EvMenuActive(CControl* control) {
SpareParts.GetPart(PartSelected)->ConfigurePropertiesWindow();
Windows[PW_WPROP]->SetX(SpareParts.GetPart(PartSelected)->GetX() + GetX() - offsetx);
Windows[PW_WPROP]->SetY(SpareParts.GetPart(PartSelected)->GetY() + GetY() - offsety);
Windows[PW_WPROP]->Draw();
Windows[PW_WPROP]->ShowExclusive();
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment