From 6003cfad006dd6a1b315ac5ae0a6f4a1a6e2dbf5 Mon Sep 17 00:00:00 2001 From: lcgamboa Date: Sun, 14 Apr 2024 22:59:29 -0300 Subject: [PATCH] chg: Add board method MGetClocksPerInstructions. !minor --- src/lib/board.cc | 4 +++ src/lib/board.h | 25 +++++++++------ src/parts/other_IO_74xx573.cc | 27 ++++++---------- src/parts/other_IO_74xx595.cc | 30 ++++++------------ src/parts/other_IO_MCP23S17.cc | 51 ++++++++++-------------------- src/parts/other_IO_MM74C922.cc | 27 ++++++---------- src/parts/other_IO_PCF8574.cc | 30 ++++++------------ src/parts/other_jumpers.cc | 5 ++- src/parts/other_logic_block.cc | 20 ++++++------ src/parts/output_7s_Display.cc | 2 +- src/parts/output_7s_Display_Dec.cc | 2 +- 11 files changed, 88 insertions(+), 135 deletions(-) diff --git a/src/lib/board.cc b/src/lib/board.cc index efd11c45..3a147400 100644 --- a/src/lib/board.cc +++ b/src/lib/board.cc @@ -330,6 +330,10 @@ output_t* board::GetOutput(int n) { return NULL; } +int board::MGetClocksPerInstructions(void) { + return MGetFreq() / MGetInstClockFreq(); +} + unsigned char board::CalcAngle(int in, int x, int y) { int dx = input[in].cx - x; int dy = y - input[in].cy; diff --git a/src/lib/board.h b/src/lib/board.h index ad635f5e..0b4b5c9b 100644 --- a/src/lib/board.h +++ b/src/lib/board.h @@ -153,7 +153,7 @@ class board { /** * @brief Event on the board */ - virtual void EvMouseMove(unsigned int button, unsigned int x, unsigned int y, unsigned int state){}; + virtual void EvMouseMove(unsigned int button, unsigned int x, unsigned int y, unsigned int state) {}; /** * @brief Event on the board @@ -173,7 +173,7 @@ class board { /** * @brief Event on the board */ - virtual void EvThreadRun(void){}; + virtual void EvThreadRun(void) {}; /** * @brief Called ever 1s to refresh status @@ -183,12 +183,12 @@ class board { /** * @brief Called to save board preferences in configuration file */ - virtual void WritePreferences(void){}; + virtual void WritePreferences(void) {}; /** * @brief Called whe configuration file load preferences */ - virtual void ReadPreferences(char* name, char* value){}; + virtual void ReadPreferences(char* name, char* value) {}; /** * @brief return the input ids numbers of names used in input map @@ -203,13 +203,13 @@ class board { /** * @brief Called when window side controls are activated */ - virtual void board_Event(const char* controlname){}; + virtual void board_Event(const char* controlname) {}; /** * @brief Called when window side controls are activated */ virtual void board_ButtonEvent(const char* controlname, unsigned int button, unsigned int x, unsigned int y, - unsigned int state){}; + unsigned int state) {}; /** * @brief Called once on board creation @@ -324,7 +324,7 @@ class board { /** * @brief board servers shutdown */ - virtual void EndServers(void){}; + virtual void EndServers(void) {}; /** * @brief board microcontroller save non volatile memory to hex file @@ -361,6 +361,11 @@ class board { */ virtual float MGetInstClockFreq(void) = 0; + /** + * @brief board microcontroller get Clock pulses per instruction (in PIC equal to 4) + */ + int MGetClocksPerInstructions(void); + /** * @brief board microcontroller pin count */ @@ -619,12 +624,12 @@ class board { /** * @brief Lock IO to others threads access */ - virtual void IoLockAccess(void){}; + virtual void IoLockAccess(void) {}; /** * @brief Unlock IO to others threads access */ - virtual void IoUnlockAccess(void){}; + virtual void IoUnlockAccess(void) {}; /** * @brief Return the UART N RX pin number @@ -645,7 +650,7 @@ class board { /** * @brief Register remote control variables */ - virtual void RegisterRemoteControl(void){}; + virtual void RegisterRemoteControl(void) {}; /** * @brief Increment the Intructions Counter diff --git a/src/parts/other_IO_74xx573.cc b/src/parts/other_IO_74xx573.cc index a7b7ce8b..dee5bb15 100644 --- a/src/parts/other_IO_74xx573.cc +++ b/src/parts/other_IO_74xx573.cc @@ -302,7 +302,7 @@ void cpart_IO_74xx573::ReadPropertiesWindow(void) { void cpart_IO_74xx573::PreProcess(void) { memset(output_pins_alm, 0, 8 * sizeof(unsigned long)); - JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS(); + JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS() * 4.0 / PICSimLab.GetBoard()->MGetClocksPerInstructions(); mcount = JUMPSTEPS_; } @@ -360,24 +360,15 @@ void cpart_IO_74xx573::Process(void) { void cpart_IO_74xx573::PostProcess(void) { long int NSTEPJ = PICSimLab.GetNSTEPJ(); - const picpin* ppins = SpareParts.GetPinsValues(); - SpareParts.WritePinOA(output_pins[0], - (ppins[output_pins[0] - 1].oavalue + ((output_pins_alm[0] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[1], - (ppins[output_pins[1] - 1].oavalue + ((output_pins_alm[1] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[2], - (ppins[output_pins[2] - 1].oavalue + ((output_pins_alm[2] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[3], - (ppins[output_pins[3] - 1].oavalue + ((output_pins_alm[3] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[4], - (ppins[output_pins[4] - 1].oavalue + ((output_pins_alm[4] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[5], - (ppins[output_pins[5] - 1].oavalue + ((output_pins_alm[5] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[6], - (ppins[output_pins[6] - 1].oavalue + ((output_pins_alm[6] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[7], - (ppins[output_pins[7] - 1].oavalue + ((output_pins_alm[7] * 200.0) / NSTEPJ) + 55) / 2); + SpareParts.WritePinOA(output_pins[0], ((output_pins_alm[0] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[1], ((output_pins_alm[1] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[2], ((output_pins_alm[2] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[3], ((output_pins_alm[3] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[4], ((output_pins_alm[4] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[5], ((output_pins_alm[5] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[6], ((output_pins_alm[6] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[7], ((output_pins_alm[7] * 200.0) / NSTEPJ) + 55); } part_init(PART_IO_74XX573_Name, cpart_IO_74xx573, "Other"); diff --git a/src/parts/other_IO_74xx595.cc b/src/parts/other_IO_74xx595.cc index aa540709..c2fb456e 100644 --- a/src/parts/other_IO_74xx595.cc +++ b/src/parts/other_IO_74xx595.cc @@ -266,7 +266,7 @@ void cpart_IO_74xx595::ReadPropertiesWindow(void) { void cpart_IO_74xx595::PreProcess(void) { memset(output_pins_alm, 0, 9 * sizeof(unsigned long)); - JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS(); + JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS() * 4.0 / PICSimLab.GetBoard()->MGetClocksPerInstructions(); mcount = JUMPSTEPS_; } @@ -319,26 +319,16 @@ void cpart_IO_74xx595::Process(void) { void cpart_IO_74xx595::PostProcess(void) { long int NSTEPJ = PICSimLab.GetNSTEPJ(); - const picpin* ppins = SpareParts.GetPinsValues(); - SpareParts.WritePinOA(output_pins[0], - (ppins[output_pins[0] - 1].oavalue + ((output_pins_alm[0] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[1], - (ppins[output_pins[1] - 1].oavalue + ((output_pins_alm[1] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[2], - (ppins[output_pins[2] - 1].oavalue + ((output_pins_alm[2] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[3], - (ppins[output_pins[3] - 1].oavalue + ((output_pins_alm[3] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[4], - (ppins[output_pins[4] - 1].oavalue + ((output_pins_alm[4] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[5], - (ppins[output_pins[5] - 1].oavalue + ((output_pins_alm[5] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[6], - (ppins[output_pins[6] - 1].oavalue + ((output_pins_alm[6] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[7], - (ppins[output_pins[7] - 1].oavalue + ((output_pins_alm[7] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[8], - (ppins[output_pins[8] - 1].oavalue + ((output_pins_alm[8] * 200.0) / NSTEPJ) + 55) / 2); + SpareParts.WritePinOA(output_pins[0], ((output_pins_alm[0] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[1], ((output_pins_alm[1] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[2], ((output_pins_alm[2] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[3], ((output_pins_alm[3] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[4], ((output_pins_alm[4] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[5], ((output_pins_alm[5] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[6], ((output_pins_alm[6] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[7], ((output_pins_alm[7] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[8], ((output_pins_alm[8] * 200.0) / NSTEPJ) + 55); } part_init(PART_IO_74XX595_Name, cpart_IO_74xx595, "Other"); diff --git a/src/parts/other_IO_MCP23S17.cc b/src/parts/other_IO_MCP23S17.cc index edfc9e6d..c3c99b48 100644 --- a/src/parts/other_IO_MCP23S17.cc +++ b/src/parts/other_IO_MCP23S17.cc @@ -372,7 +372,7 @@ void cpart_IO_MCP23S17::ReadPropertiesWindow(void) { void cpart_IO_MCP23S17::PreProcess(void) { memset(output_pins_alm, 0, 16 * sizeof(unsigned long)); - JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS(); + JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS() * 4.0 / PICSimLab.GetBoard()->MGetClocksPerInstructions(); mcount = JUMPSTEPS_; } @@ -460,40 +460,23 @@ void cpart_IO_MCP23S17::Process(void) { void cpart_IO_MCP23S17::PostProcess(void) { long int NSTEPJ = PICSimLab.GetNSTEPJ(); - const picpin* ppins = SpareParts.GetPinsValues(); - SpareParts.WritePinOA(output_pins[0], - (ppins[output_pins[0] - 1].oavalue + ((output_pins_alm[0] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[1], - (ppins[output_pins[1] - 1].oavalue + ((output_pins_alm[1] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[2], - (ppins[output_pins[2] - 1].oavalue + ((output_pins_alm[2] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[3], - (ppins[output_pins[3] - 1].oavalue + ((output_pins_alm[3] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[4], - (ppins[output_pins[4] - 1].oavalue + ((output_pins_alm[4] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[5], - (ppins[output_pins[5] - 1].oavalue + ((output_pins_alm[5] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[6], - (ppins[output_pins[6] - 1].oavalue + ((output_pins_alm[6] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[7], - (ppins[output_pins[7] - 1].oavalue + ((output_pins_alm[7] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[8], - (ppins[output_pins[8] - 1].oavalue + ((output_pins_alm[8] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[9], - (ppins[output_pins[9] - 1].oavalue + ((output_pins_alm[9] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[10], - (ppins[output_pins[10] - 1].oavalue + ((output_pins_alm[10] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[11], - (ppins[output_pins[11] - 1].oavalue + ((output_pins_alm[11] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[12], - (ppins[output_pins[12] - 1].oavalue + ((output_pins_alm[12] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[13], - (ppins[output_pins[13] - 1].oavalue + ((output_pins_alm[13] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[14], - (ppins[output_pins[14] - 1].oavalue + ((output_pins_alm[14] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[15], - (ppins[output_pins[15] - 1].oavalue + ((output_pins_alm[15] * 200.0) / NSTEPJ) + 55) / 2); + SpareParts.WritePinOA(output_pins[0], ((output_pins_alm[0] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[1], ((output_pins_alm[1] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[2], ((output_pins_alm[2] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[3], ((output_pins_alm[3] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[4], ((output_pins_alm[4] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[5], ((output_pins_alm[5] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[6], ((output_pins_alm[6] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[7], ((output_pins_alm[7] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[8], ((output_pins_alm[8] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[9], ((output_pins_alm[9] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[10], ((output_pins_alm[10] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[11], ((output_pins_alm[11] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[12], ((output_pins_alm[12] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[13], ((output_pins_alm[13] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[14], ((output_pins_alm[14] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[15], ((output_pins_alm[15] * 200.0) / NSTEPJ) + 55); } part_init(PART_IO_MCP23S17_Name, cpart_IO_MCP23S17, "Other"); diff --git a/src/parts/other_IO_MM74C922.cc b/src/parts/other_IO_MM74C922.cc index 67b16501..d61ca94e 100644 --- a/src/parts/other_IO_MM74C922.cc +++ b/src/parts/other_IO_MM74C922.cc @@ -328,7 +328,7 @@ void cpart_IO_MM74C922::ReadPropertiesWindow(void) { void cpart_IO_MM74C922::PreProcess(void) { memset(pins_alm, 0, 8 * sizeof(unsigned long)); - JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS(); + JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS() * 4.0 / PICSimLab.GetBoard()->MGetClocksPerInstructions(); mcount = JUMPSTEPS_; io_MM74C922_set_clk_freq(&kc, pboard->MGetInstClockFreq()); @@ -384,24 +384,15 @@ void cpart_IO_MM74C922::Process(void) { void cpart_IO_MM74C922::PostProcess(void) { long int NSTEPJ = PICSimLab.GetNSTEPJ(); - const picpin* ppins = SpareParts.GetPinsValues(); - SpareParts.WritePinOA(output_pins[0], - (ppins[output_pins[0] - 1].oavalue + ((pins_alm[0] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[1], - (ppins[output_pins[1] - 1].oavalue + ((pins_alm[1] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[2], - (ppins[output_pins[2] - 1].oavalue + ((pins_alm[2] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[3], - (ppins[output_pins[3] - 1].oavalue + ((pins_alm[3] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(input_pins[0], - (ppins[input_pins[0] - 1].oavalue + ((pins_alm[4] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(input_pins[1], - (ppins[input_pins[1] - 1].oavalue + ((pins_alm[5] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(input_pins[2], - (ppins[input_pins[2] - 1].oavalue + ((pins_alm[6] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(input_pins[3], - (ppins[input_pins[3] - 1].oavalue + ((pins_alm[7] * 200.0) / NSTEPJ) + 55) / 2); + SpareParts.WritePinOA(output_pins[0], ((pins_alm[0] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[1], ((pins_alm[1] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[2], ((pins_alm[2] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[3], ((pins_alm[3] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(input_pins[0], ((pins_alm[4] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(input_pins[1], ((pins_alm[5] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(input_pins[2], ((pins_alm[6] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(input_pins[3], ((pins_alm[7] * 200.0) / NSTEPJ) + 55); } part_init(PART_IO_MM74C922_Name, cpart_IO_MM74C922, "Other"); diff --git a/src/parts/other_IO_PCF8574.cc b/src/parts/other_IO_PCF8574.cc index 7e624b76..0b6a349e 100644 --- a/src/parts/other_IO_PCF8574.cc +++ b/src/parts/other_IO_PCF8574.cc @@ -280,7 +280,7 @@ void cpart_IO_PCF8574::PreProcess(void) { memset(output_pins_alm, 0, 9 * sizeof(unsigned long)); - JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS(); + JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS() * 4.0 / PICSimLab.GetBoard()->MGetClocksPerInstructions(); mcount = JUMPSTEPS_; if (input_pins[2]) { @@ -363,26 +363,16 @@ void cpart_IO_PCF8574::Process(void) { void cpart_IO_PCF8574::PostProcess(void) { long int NSTEPJ = PICSimLab.GetNSTEPJ(); - const picpin* ppins = SpareParts.GetPinsValues(); - SpareParts.WritePinOA(output_pins[0], - (ppins[output_pins[0] - 1].oavalue + ((output_pins_alm[0] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[1], - (ppins[output_pins[1] - 1].oavalue + ((output_pins_alm[1] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[2], - (ppins[output_pins[2] - 1].oavalue + ((output_pins_alm[2] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[3], - (ppins[output_pins[3] - 1].oavalue + ((output_pins_alm[3] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[4], - (ppins[output_pins[4] - 1].oavalue + ((output_pins_alm[4] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[5], - (ppins[output_pins[5] - 1].oavalue + ((output_pins_alm[5] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[6], - (ppins[output_pins[6] - 1].oavalue + ((output_pins_alm[6] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[7], - (ppins[output_pins[7] - 1].oavalue + ((output_pins_alm[7] * 200.0) / NSTEPJ) + 55) / 2); - SpareParts.WritePinOA(output_pins[8], - (ppins[output_pins[8] - 1].oavalue + ((output_pins_alm[8] * 200.0) / NSTEPJ) + 55) / 2); + SpareParts.WritePinOA(output_pins[0], ((output_pins_alm[0] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[1], ((output_pins_alm[1] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[2], ((output_pins_alm[2] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[3], ((output_pins_alm[3] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[4], ((output_pins_alm[4] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[5], ((output_pins_alm[5] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[6], ((output_pins_alm[6] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[7], ((output_pins_alm[7] * 200.0) / NSTEPJ) + 55); + SpareParts.WritePinOA(output_pins[8], ((output_pins_alm[8] * 200.0) / NSTEPJ) + 55); } part_init(PART_IO_PCF8574_Name, cpart_IO_PCF8574, "Other"); diff --git a/src/parts/other_jumpers.cc b/src/parts/other_jumpers.cc index 58833a65..d04a52b1 100644 --- a/src/parts/other_jumpers.cc +++ b/src/parts/other_jumpers.cc @@ -517,7 +517,7 @@ void cpart_Jumpers::ReadPropertiesWindow(void) { void cpart_Jumpers::PreProcess(void) { memset(output_pins_alm, 0, 16 * sizeof(unsigned long)); - JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS(); + JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS() * 4.0 / PICSimLab.GetBoard()->MGetClocksPerInstructions(); mcount = JUMPSTEPS_; } @@ -557,8 +557,7 @@ void cpart_Jumpers::PostProcess(void) { const picpin* ppins = SpareParts.GetPinsValues(); for (int i = 0; i < 16; i++) { - SpareParts.WritePinOA(output_pins[i], - (ppins[output_pins[i] - 1].oavalue + ((output_pins_alm[i] * 200.0) / NSTEPJ) + 55) / 2); + SpareParts.WritePinOA(output_pins[i], ((output_pins_alm[i] * 200.0) / NSTEPJ) + 55); if (output_pins[i] && (output_ids[O_L1 + i]->value != ppins[output_pins[i] - 1].oavalue)) { output_ids[O_L1 + i]->value = ppins[output_pins[i] - 1].oavalue; diff --git a/src/parts/other_logic_block.cc b/src/parts/other_logic_block.cc index 866add5d..f6c486cc 100644 --- a/src/parts/other_logic_block.cc +++ b/src/parts/other_logic_block.cc @@ -138,9 +138,9 @@ void cpart_lblock::DrawOutput(const unsigned int i) { if (input_pins[output[i].id - O_P1] == 0) SpareParts.CanvasCmd({.cmd = CC_ROTATEDTEXT, .RotatedText{"NC", output[i].x1, output[i].y1, 0}}); else - SpareParts.CanvasCmd( - {.cmd = CC_ROTATEDTEXT, .RotatedText{SpareParts.GetPinName(input_pins[output[i].id - O_P1]).c_str(), - output[i].x1, output[i].y1, 0}}); + SpareParts.CanvasCmd({.cmd = CC_ROTATEDTEXT, + .RotatedText{SpareParts.GetPinName(input_pins[output[i].id - O_P1]).c_str(), + output[i].x1, output[i].y1, 0}}); break; case O_P9: case O_P10: @@ -152,9 +152,9 @@ void cpart_lblock::DrawOutput(const unsigned int i) { if (output_pins[output[i].id - O_P9] == 0) SpareParts.CanvasCmd({.cmd = CC_ROTATEDTEXT, .RotatedText{"NC", output[i].x1 - xoff, output[i].y1, 0}}); else - SpareParts.CanvasCmd( - {.cmd = CC_ROTATEDTEXT, .RotatedText{SpareParts.GetPinName(output_pins[output[i].id - O_P9]).c_str(), - output[i].x1 - xoff, output[i].y1, 0}}); + SpareParts.CanvasCmd({.cmd = CC_ROTATEDTEXT, + .RotatedText{SpareParts.GetPinName(output_pins[output[i].id - O_P9]).c_str(), + output[i].x1 - xoff, output[i].y1, 0}}); break; case O_IN1: case O_IN2: @@ -192,8 +192,7 @@ void cpart_lblock::DrawOutput(const unsigned int i) { void cpart_lblock::PreProcess(void) { output_pins_alm = 0; - JUMPSTEPS_ = - PICSimLab.GetJUMPSTEPS() * 4.0 * PICSimLab.GetBoard()->MGetInstClockFreq() / PICSimLab.GetBoard()->MGetFreq(); + JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS() * 4.0 / PICSimLab.GetBoard()->MGetClocksPerInstructions(); mcount = JUMPSTEPS_; } @@ -516,8 +515,9 @@ void cpart_lblock::LoadPartImage(void) { SpareParts.CanvasCmd({.cmd = CC_CREATE, .Create{BitmapId}}); int BackBitmap = SpareParts.CanvasCmd( - {.cmd = CC_LOADIMAGE, .LoadImage{(PICSimLab.GetSharePath() + "parts/" + Type + "/" + GetPictureFileName()).c_str(), - Scale, 0, Orientation}}); + {.cmd = CC_LOADIMAGE, + .LoadImage{(PICSimLab.GetSharePath() + "parts/" + Type + "/" + GetPictureFileName()).c_str(), Scale, 0, + Orientation}}); SpareParts.CanvasCmd({.cmd = CC_INIT, .Init{Scale, Scale, Orientation}}); SpareParts.CanvasCmd({.cmd = CC_SETCOLOR, .SetColor{0x31, 0x3d, 0x63}}); diff --git a/src/parts/output_7s_Display.cc b/src/parts/output_7s_Display.cc index 25667cf5..79efce15 100644 --- a/src/parts/output_7s_Display.cc +++ b/src/parts/output_7s_Display.cc @@ -668,7 +668,7 @@ void cpart_7s_display::PreProcess(void) { memset(alm4, 0, 8 * sizeof(unsigned int)); } - JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS(); + JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS() * 4.0 / PICSimLab.GetBoard()->MGetClocksPerInstructions(); mcount = JUMPSTEPS_; } diff --git a/src/parts/output_7s_Display_Dec.cc b/src/parts/output_7s_Display_Dec.cc index f2cc53ab..d1af7430 100644 --- a/src/parts/output_7s_Display_Dec.cc +++ b/src/parts/output_7s_Display_Dec.cc @@ -622,7 +622,7 @@ void cpart_7s_display_dec::PreProcess(void) { memset(alm3, 0, 8 * sizeof(unsigned int)); memset(alm4, 0, 8 * sizeof(unsigned int)); - JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS(); + JUMPSTEPS_ = PICSimLab.GetJUMPSTEPS() * 4.0 / PICSimLab.GetBoard()->MGetClocksPerInstructions(); mcount = JUMPSTEPS_; }