Skip to content

Commit

Permalink
fix: Fix Spareparts Prop window position on windows !minor
Browse files Browse the repository at this point in the history
  • Loading branch information
lcgamboa committed Apr 15, 2024
1 parent bbdb4cf commit c42b508
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
36 changes: 22 additions & 14 deletions src/parts/other_logic_block.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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++;
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/parts/other_logic_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class cpart_lblock : public part {
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;
Expand Down
6 changes: 3 additions & 3 deletions src/picsimlab5.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c42b508

Please sign in to comment.