Charles Young's development fork. Going forward I only want to push mature code to main repository.
Fork of GEO_COUNTER_L432KC by
Diff: main.cpp
- Revision:
- 49:a67f2a3d228a
- Parent:
- 48:468220d69071
- Child:
- 50:19ab5315e2b4
--- a/main.cpp Sat Sep 08 16:36:02 2018 -0700 +++ b/main.cpp Sat Sep 08 16:42:53 2018 -0700 @@ -143,23 +143,43 @@ void UpdateOutput() { + // Capture the counts early so they will be more accurate + uint32_t Count1Save = Count1; + uint32_t Count2Save = Count2; + + if(Stopped) + { + // disable interrupts on TRIG1 and TRIG2 + TRIG1.rise(NULL); + TRIG2.rise(NULL); + } + else + { + // Enable interrupts on rising edge of digital inputs TRIG1 & TRIG2 + TRIG1.rise(&Count1_up); + TRIG2.rise(&Count2_up); + + Count1 = 0; // clear both counters + Count2 = 0; + } + // This must be called periodically to update the LEDs ModeSwitch.UpdateOutput(); switch (currentModeToDisplay) { case CNT1: - DigitsDisplay.Display_6D_write(Count1); + DigitsDisplay.Display_6D_write(Count1Save); DigitsDisplay.Display_2D_Blank(); break; case CNT2: - DigitsDisplay.Display_6D_write(Count2); + DigitsDisplay.Display_6D_write(Count2Save); DigitsDisplay.Display_2D_Blank(); break; case PROSPECT: - if (Count1) - DigitsDisplay.Display_6D_write(Count1); + if (Count1Save) + DigitsDisplay.Display_6D_write(Count1Save); else - DigitsDisplay.Display_6D_write(Count2); + DigitsDisplay.Display_6D_write(Count2Save); DigitsDisplay.Display_2D_Blank(); break; case NULL1: @@ -179,22 +199,6 @@ default: break; } - - if(Stopped) - { - // disable interrupts on TRIG1 and TRIG2 - TRIG1.rise(NULL); - TRIG2.rise(NULL); - } - else - { - // Enable interrupts on rising edge of digital inputs TRIG1 & TRIG2 - TRIG1.rise(&Count1_up); - TRIG2.rise(&Count2_up); - - Count1 = 0; // clear both counters - Count2 = 0; - } } void UpdateInput()