copy of https://github.com/MarlinFirmware/MarlinDev/pull/199/commits/406992f9dd44655b33dab46e0cb4fd4a29be1695