text
stringlengths
0
234
Write (This, REG_ALGO_PHASECAL_CONFIG_TIMEOUT,
Cal_Timeout, Status);
if not Status then
return;
end if;
Write (This, 16#FF#, UInt8'(16#01#), Status);
Write (This, REG_ALGO_PHASECAL_LIM,
Cal_Lim, Status);
Write (This, 16#FF#, UInt8'(16#00#), Status);
if not Status then
return;
end if;
Function Definition: function To_UInt16 is
Function Body: new Ada.Unchecked_Conversion (UInt16_HL_Type, UInt16);
Ret : TP_Touch_State;
Regs : FT6206_Pressure_Registers;
Tmp : UInt16_HL_Type;
Status : Boolean;
begin
if Touch_Id not in FT6206_Px_Regs'Range then
return (0, 0, 0);
end if;
if Touch_Id > This.Active_Touch_Points then
return (0, 0, 0);
end if;
-- X/Y are swaped from the screen coordinates
Regs := FT6206_Px_Regs (Touch_Id);
Tmp.Low := This.I2C_Read (Regs.XL_Reg, Status);
if not Status then
return (0, 0, 0);
end if;
Tmp.High := This.I2C_Read (Regs.XH_Reg, Status) and
FT6206_TOUCH_POS_MSB_MASK;
if not Status then
return (0, 0, 0);
end if;
Ret.Y := Natural (To_UInt16 (Tmp));
Tmp.Low := This.I2C_Read (Regs.YL_Reg, Status);
if not Status then
return (0, 0, 0);
end if;
Tmp.High := This.I2C_Read (Regs.YH_Reg, Status) and
FT6206_TOUCH_POS_MSB_MASK;
if not Status then
return (0, 0, 0);
end if;
Ret.X := Natural (To_UInt16 (Tmp));
Ret.Weight := Natural (This.I2C_Read (Regs.Weight_Reg, Status));
if not Status then
Ret.Weight := 0;
end if;
if Ret.Weight = 0 then
Ret.Weight := 50;
end if;
Ret.X := Natural'Max (0, Ret.X);
Ret.Y := Natural'Max (0, Ret.Y);
Ret.X := Natural'Min (This.LCD_Natural_Width - 1, Ret.X);
Ret.Y := Natural'Min (This.LCD_Natural_Height - 1, Ret.Y);
if (This.Swap and Invert_X) /= 0 then
Ret.X := This.LCD_Natural_Width - Ret.X - 1;
end if;
if (This.Swap and Invert_Y) /= 0 then
Ret.Y := This.LCD_Natural_Height - Ret.Y - 1;
end if;
if (This.Swap and Swap_XY) /= 0 then
declare
Tmp_X : constant Integer := Ret.X;
begin
Ret.X := Ret.Y;
Ret.Y := Tmp_X;
Function Definition: function Read_Register (This : STMPE811_Device;
Function Body: Reg_Addr : UInt8) return UInt8
is
Data : TSC_Data (1 .. 1);
Status : I2C_Status;
begin
This.Port.Mem_Read (This.I2C_Addr,