function IntToStr(I: Longint): String;
{ Convert any integer type to a string }
var
  S: string[6];
begin
  Str(I, S);
  IntToStr := S;
end;

function IntToStr1(I: Longint): String;
{ Convert any integer type to a string }
var
  S: string[8];
begin
  Str(I:8, S);
  IntToStr1 := S;
end;


procedure Led_Anzeige_1;
var x,y:word;
begin
  for y:=0 to 45 div 2 do
  begin
    for x:=0 to 319 div 2 do
    begin
      put_pixel_led(x,y,led_color_1);
    end;
  end;
end;
procedure Led_Anzeige_2;
begin
  if led_timer and 1=1 then set_rgb_color(led_color_1,255,00,00) else
  set_RGB_color(led_color_1,20,00,00);
end;

procedure Led_Anzeige_3;
begin
  if led_timer and 1=1 then
  begin
    set_rgb_color(led_color_1,255,00,00);
    set_rgb_color(led_color_2,020,00,00);
  end else
  begin
    set_RGB_color(led_color_1,020,00,00);
    set_rgb_color(led_color_2,255,00,00);
  end;
end;

procedure Led_Anzeige_4;
var x,y:word;
begin
  inc(ran255z);
  for y:=0 to (45) div 2 do
  begin
    for x:=0 to 319 div 2 do
    begin
      if random255<50 then put_pixel_led(x,y,led_color_2) else put_pixel_led(x,y,led_color_1);
    end;
  end;
end;

procedure led_Anzeige_5_init(x,y:byte;stg:string);
begin
  led_x:=x;
  led_y:=y+1;
  led_anzeige_text:=stg;
  led_status:=1;
  led_f_status_1:=1;
  led_f_status_2:=length(stg);
  led_funktion:=5;
end;

procedure Led_Anzeige_5;
var I,J,POSI: word;
    CharPos : byte;
    CharacPos : word;
    c1:string;
    color:byte;
    x:word;
begin
  x:=led_x{+led_y*80};
  if led_f_status_1<led_f_status_2+1 then
  begin
    c1:= copy(LED_ANZEIGE_TEXT,led_f_status_1,1);
    CharacPos :=ord(c1[1])*16;
    for CharPos := 0 to 7 do
    begin
      for I := 0 to 7 do
      begin
        if mem[Fseg:Fofs+CharacPos+I] and Bits[CharPos] <> 0 then Color := LED_COLOR_2
        else Color := led_color_1;
        put_pixel_led(x,i+led_y,color); {NEU}
      end;
      inc(x);
    end;
    led_x:=x;
    inc(led_f_status_1);
  end else
  begin
    led_status:=255;
    led_funktion:=0;
  end;
end;

procedure LED_ANZEIGE_6_init; {Scroll right 2 left}
begin
  led_f_status_1:=80;
  led_funktion:=6;
end;

procedure LED_ANZEIGE_6; {Scroll right 2 left}
var x:byte;
    z1,z2:word;
begin
  for x:=0 to 47 do
  begin
    z1:=x*80;
    z2:=z1+1;
    asm
      push ds
      mov es,[ledseg] {ES:DI DESTINATION}
      mov ds,[ledseg]
      mov di,z1
      mov si,z2
      mov cx,39
      rep movsw
      pop ds
    end;
  end;
  put_pixel_led(320,0,led_color_1);
  led_status:=255;
  if led_F_status_1>0 then dec(led_f_status_1) else led_funktion:=0;{}
end;

procedure led_anzeige;
begin
  {led_anzeige}
  inc(led_timer,1);
  if led_funktion=1 then Led_Anzeige_1;
  if led_funktion=2 then Led_Anzeige_2;
  if led_funktion=3 then Led_Anzeige_3;
  if led_funktion=4 then Led_Anzeige_4;
  if led_funktion=5 then Led_Anzeige_5;{}
  if led_funktion=5 then Led_Anzeige_5;{}
  if led_funktion=6 then Led_Anzeige_6;{}
  if led_status=255 then flip_led;{}
end;

