text
stringlengths
0
234
-- Print_Bitmap --
------------------
procedure Print_Bitmap (This : in out TP_Device;
BM : Thermal_Printer_Bitmap)
is
Nbr_Of_Rows : constant Natural := BM'Length (2);
Nbr_Of_Columns : constant Natural := BM'Length (1);
Str : String (1 .. Nbr_Of_Columns / 8);
begin
Write (This, ASCII.DC2 & 'v' &
To_Char (UInt8 (Nbr_Of_Rows rem 256)) &
To_Char (UInt8 (Nbr_Of_Rows / 256)));
for Row in 0 .. Nbr_Of_Rows - 1 loop
for Colum in 0 .. (Nbr_Of_Columns / 8) - 1 loop
declare
BM_Index : constant Natural := BM'First (1) + Colum * 8;
Str_Index : constant Natural := Str'First + Colum;
B : UInt8 := 0;
begin
for X in 0 .. 7 loop
B := B or (if BM (BM_Index + X,
BM'First (2) + Row)
then 2**X else 0);
end loop;
Str (Str_Index) := To_Char (B);
Function Definition: function As_UInt8 is new Ada.Unchecked_Conversion
Function Body: (Source => High_Pass_Filter_Mode, Target => UInt8);
function As_UInt8 is new Ada.Unchecked_Conversion
(Source => High_Pass_Cutoff_Frequency, Target => UInt8);
function As_UInt8 is new Ada.Unchecked_Conversion
(Source => Power_Mode_Selection, Target => UInt8);
function As_UInt8 is new Ada.Unchecked_Conversion
(Source => Output_Data_Rate_Selection, Target => UInt8);
function As_UInt8 is new Ada.Unchecked_Conversion
(Source => Axes_Selection, Target => UInt8);
function As_UInt8 is new Ada.Unchecked_Conversion
(Source => Bandwidth_Selection, Target => UInt8);
function As_UInt8 is new Ada.Unchecked_Conversion
(Source => Block_Data_Update_Selection, Target => UInt8);
function As_UInt8 is new Ada.Unchecked_Conversion
(Source => Endian_Data_Selection, Target => UInt8);
function As_UInt8 is new Ada.Unchecked_Conversion
(Source => Full_Scale_Selection, Target => UInt8);
type Angle_Rate_Pointer is access all Angle_Rate with Storage_Size => 0;
function As_Angle_Rate_Pointer is new Ada.Unchecked_Conversion
(Source => System.Address, Target => Angle_Rate_Pointer);
-- So that we can treat the address of a UInt8 as a pointer to a two-UInt8
-- sequence representing a signed integer quantity.
procedure Swap2 (Location : System.Address) with Inline;
-- Swaps the two UInt8s at Location and Location+1
procedure SPI_Mode (This : Three_Axis_Gyroscope; Enabled : Boolean);
-- Enable or disable SPI mode communication with the device. This is named
-- "chip select" in other demos/examples.
----------------
-- Initialize --
----------------
procedure Initialize
(This : in out Three_Axis_Gyroscope;
Port : Any_SPI_Port;
Chip_Select : Any_GPIO_Point)
is
begin
This.Port := Port;
This.CS := Chip_Select;
SPI_Mode (This, Enabled => False);
end Initialize;
-----------------
-- SPI_Mode --
-----------------
procedure SPI_Mode (This : Three_Axis_Gyroscope; Enabled : Boolean) is
-- When the pin is low (cleared), the device is in SPI mode.
-- When the pin is high (set), the device is in I2C mode.
-- We want SPI mode communication, so Enabled, when True,
-- means we must drive the pin low.
begin
if Enabled then
This.CS.Clear;
else
This.CS.Set;