simonjwright / FreeRTOS-Ada

This project contains various GNAT Ada Run Time Systems (RTSs) based on FreeRTOS for MCUs: the Arduino Due, the STM32F4-series evaluation boards from STMicroelectronics and the BBC micro:bit (v1); working on Espressif ESP32-H2 and RaspberryPi RP2350 (risc-v core)
GNU General Public License v3.0
65 stars 14 forks source link

Time_First is 0.0 #33

Closed simonjwright closed 3 years ago

simonjwright commented 3 years ago

You’d expect Ada.Real_Time.Time_First to be quite a long time before any possible value of Ada.Real_Time.Clock; but in fact the system starts with Clock equal to Time_First.

This leads to clumsiness such as

         Quad_Is_Flying :=
           Last_Flight_Command_Time /= Ada.Real_Time.Time_First
             and then
           Ada.Real_Time.To_Duration (Now - Last_Flight_Command_Time)
             < In_Flight_Time_Threshold;
simonjwright commented 3 years ago

Following conversations on comp.lang.ada, & private communications, this change seems like a Bad Idea.

If you need a flag, use a boolean and stay away from sentinel values. Much safer, explicit, and the extra cost is negligible.