----------------------------------------------------------------------------
--  High Integrity Sumobot                                                --
--  Copyright (C) 2019-2020 Blaine Osepchuk <bosepchuk@gmail.com>         --
--                                                                        --
--  This program is free software: you can redistribute it and/or modify  --
--  it under the terms of the GNU General Public License as published by  --
--  the Free Software Foundation, either version 3 of the License, or     --
--  (at your option) any later version.                                   --
--                                                                        --
--  This program is distributed in the hope that it will be useful,       --
--  but WITHOUT ANY WARRANTY; without even the implied warranty of        --
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         --
--  GNU General Public License for more details.                          --
--                                                                        --
--  You should have received a copy of the GNU General Public License     --
--  along with this program (LICENSE.txt).                                --
--  If not, see <https://www.gnu.org/licenses/>.                          --
----------------------------------------------------------------------------


with View.Motors.Utils; use View.Motors.Utils;


package body View.Motors with SPARK_Mode => On is




   procedure Set_Speed (Speeds : in Motor_Speeds; Is_Successful : out Boolean) is
      Is_Left_Successful : Boolean;
      Is_Right_Successful : Boolean;
   begin
      --  I was unable to get the microbit to successfully send
      --  more than one byte to the zumo in one communication.
      --  So I send the motor commands to the zumo separately.
      Set_Motor_Speed (Convert_Left_Speed (Speeds.Left), Is_Left_Successful);
      Set_Motor_Speed (Convert_Right_Speed (Speeds.Right), Is_Right_Successful);
      Is_Successful := Is_Left_Successful and Is_Right_Successful;
   end Set_Speed;
end View.Motors;
