view src/cs/drivers/drv_app/r2d/lcds/ColorPC/custom_process.pl @ 281:a75eefbf8be4

Phone boot with PWON: weed out short button presses Every standard end user phone has a design provision, most naturally implemented in firmware, whereby the PWON button effects a boot only if it is held down long enough - short presses of this PWON button are detected, assumed to be spurious and cause the fw to power back off instead of proceeding with boot. The present change introduces this standard function in FreeCalypso.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 24 Sep 2021 02:03:08 +0000
parents 4e78acac3d88
children
line wrap: on
line source

#!perl

# Mode os scanning (vertical or horizontal)
$mode=$ARGV[0];

# Name of file used to transfer data between this script and the r2d_font_tool
$data=$ARGV[1];

if (($#ARGV+1)>2)
{
   $x=$ARGV[3];
   open(DATA,">$data") or die "Cannot create data file : $!\n";
   $words = int($x)+1;

# One word must be added because the alignement is done by excess   
   print DATA $words;
   close(DATA);

   
}
     else
     {
# Open the data file to import glyph bit matrix generated by r2d_font_tool
open(DATA,"$data") or die "Cannot open input file : $!\n";

# It is the size unmodified by r2d_font_tool (width in vertical mode and
# height in horizontal mode). It corresponds to the width/height for the
# current glyph
$matrix_size=int(<DATA>);

# It is the size which is word aligned by r2d_font_tool (height in 
# vertical mode and width in horizontal one)
# It corresponds to the max width/height on all fonts.
$matrix_aligned_size=int(<DATA>);

# Original value before word alignment
# (Max value on all glyphs before alignment) 
$matrix_max_size=int(<DATA>);

# Width of the glyph image in the bitmap
$matrix_image_width=int(<DATA>);

# Height of the glyph in the bitmap
$matrix_image_height=int(<DATA>);

if ($mode =~ /vertical/)
{
   # Scanning of the glyph bit matrix done column per column
   # (since datas are saved column per column by r2d_font_tool
   # when in horizontal mode)
   for($i=0;$i<$matrix_size;$i++)
   {
      for($j=0;$j<$matrix_aligned_size;$j++)
      {
         $matrix{$i.".".$j}=int(<DATA>); 
      }
   }
}
else
{
   # Scanning of the glyph bit matrix done line per line
   for($i=0;$i<$matrix_aligned_size;$i++)
   {
      for($j=0;$j<$matrix_size;$j++)
      {
         $matrix{$i.".".$j}=int(<DATA>); 
      }
   }
}
close(DATA);


# That part of the code is translating the glyph (initially represented
# as a bit matrix) to a format which is compatible with the current LCD.
#
# In this example, the LCD is a 24 bpp one. So, a bit 0 (correponding to black)
# must be converted to 0, and 1 (for white) to 0xFFFFFF.
#
# The scanning must use the IMAGE width in  vertical mode
# and the IMAGE height in horizontal mode.

# In vertical mode, the height must use max_size on all glyph
# In horizontal mode, the width must use the max_size.
# You can either use the aligned_version if you LCD is a 1bpp one and
# or you can use the non aligned one (matrix_max_size) and do the alignment 
# yourself.

# In our case, the LCD is a 24bpp, so no alignment is required and the
# max_size is used directly.

$words=int($matrix_max_size) ;
$aligned=$words;

open(DATA,">$data") or die "Cannot create data file : $!\n";
  
  
    # Scanning line per line
    for($j=0;$j<$matrix_image_height;$j++)
    {
      for($i=0;$i<$aligned;$i++)
      {
         $ra=$matrix{$i.".".$j};
         

         # Conversion of bit to color value
         if ($ra == 0)
         {
            $ra=0x00FFFFFF;
         }
         else
         {
            $ra=0x00000000;
         }

           

   
         $res=sprintf "0x%08X\n",$ra;
         print DATA $res;
      }
    }
  
close(DATA);

}