Chinaunix首页 | 论坛 | 博客
  • 博客访问: 272609
  • 博文数量: 53
  • 博客积分: 1910
  • 博客等级: 中尉
  • 技术积分: 1130
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-10 14:56
文章分类

全部博文(53)

文章存档

2013年(1)

2012年(17)

2011年(33)

2010年(2)

分类: Python/Ruby

2011-05-03 13:11:14

   在设备开机时有时需要简单的在lcd 上显示版本号字母,虽然工具很多,也可以自己写c代码实现
但使用python ,来实现,既简单又可以把功能一起集成到bsp 中,只需要修改txt文件中需要显示的字符
然后,每次build 系统,自己生成显示的代码c文件(包括点阵数组+显示代码),最后一起build 到image 中
 
   具体代码如下:
  1. import os,sys
  2. #print "liu creat for version c "
  3. a168=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  4.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  5.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  6.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  7.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  8.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  9.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  10.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  11.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  12.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  13.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  14.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  15.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  16.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  17.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  18.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  19.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  20.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  21.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  22.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  23.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  24.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  25.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  26.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  27.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  28.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  29.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  30.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  31.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  32.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  33.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  34.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  35.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  36.     0,0,24,60,60,60,24,24,24,0,24,24,0,0,0,0,
  37.     0,102,102,102,36,0,0,0,0,0,0,0,0,0,0,0,
  38.     0,0,0,108,108,254,108,108,108,254,108,108,0,0,0,0,
  39.     24,24,124,198,194,192,124,6,6,134,198,124,24,24,0,0,
  40.     0,0,0,0,194,198,12,24,48,96,198,134,0,0,0,0,
  41.     0,0,56,108,108,56,118,220,204,204,204,118,0,0,0,0,
  42.     0,48,48,48,96,0,0,0,0,0,0,0,0,0,0,0,
  43.     0,0,12,24,48,48,48,48,48,48,24,12,0,0,0,0,
  44.     0,0,48,24,12,12,12,12,12,12,24,48,0,0,0,0,
  45.     0,0,0,0,0,102,60,255,60,102,0,0,0,0,0,0,
  46.     0,0,0,0,0,24,24,126,24,24,0,0,0,0,0,0,
  47.     0,0,0,0,0,0,0,0,0,24,24,24,48,0,0,0,
  48.     0,0,0,0,0,0,0,126,0,0,0,0,0,0,0,0,
  49.     0,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,
  50.     0,0,0,0,2,6,12,24,48,96,192,128,0,0,0,0,
  51.     0,0,124,198,198,206,222,246,230,198,198,124,0,0,0,0,
  52.     0,0,24,56,120,24,24,24,24,24,24,126,0,0,0,0,
  53.     0,0,124,198,6,12,24,48,96,192,198,254,0,0,0,0,
  54.     0,0,124,198,6,6,60,6,6,6,198,124,0,0,0,0,
  55.     0,0,12,28,60,108,204,254,12,12,12,30,0,0,0,0,
  56.     0,0,254,192,192,192,252,6,6,6,198,124,0,0,0,0,
  57.     0,0,56,96,192,192,252,198,198,198,198,124,0,0,0,0,
  58.     0,0,254,198,6,6,12,24,48,48,48,48,0,0,0,0,
  59.     0,0,124,198,198,198,124,198,198,198,198,124,0,0,0,0,
  60.     0,0,124,198,198,198,126,6,6,6,12,120,0,0,0,0,
  61.     0,0,0,0,24,24,0,0,0,24,24,0,0,0,0,0,
  62.     0,0,0,0,24,24,0,0,0,24,24,48,0,0,0,0,
  63.     0,0,0,6,12,24,48,96,48,24,12,6,0,0,0,0,
  64.     0,0,0,0,0,126,0,0,126,0,0,0,0,0,0,0,
  65.     0,0,0,96,48,24,12,6,12,24,48,96,0,0,0,0,
  66.     0,0,124,198,198,12,24,24,24,0,24,24,0,0,0,0,
  67.     0,0,124,198,198,198,222,222,222,220,192,124,0,0,0,0,
  68.     0,0,16,56,108,198,198,254,198,198,198,198,0,0,0,0,
  69.     0,0,252,102,102,102,124,102,102,102,102,252,0,0,0,0,
  70.     0,0,60,102,194,192,192,192,192,194,102,60,0,0,0,0,
  71.     0,0,248,108,102,102,102,102,102,102,108,248,0,0,0,0,
  72.     0,0,254,102,98,104,120,104,96,98,102,254,0,0,0,0,
  73.     0,0,254,102,98,104,120,104,96,96,96,240,0,0,0,0,
  74.     0,0,60,102,194,192,192,222,198,198,102,58,0,0,0,0,
  75.     0,0,198,198,198,198,254,198,198,198,198,198,0,0,0,0,
  76.     0,0,60,24,24,24,24,24,24,24,24,60,0,0,0,0,
  77.     0,0,30,12,12,12,12,12,204,204,204,120,0,0,0,0,
  78.     0,0,230,102,102,108,120,120,108,102,102,230,0,0,0,0,
  79.     0,0,240,96,96,96,96,96,96,98,102,254,0,0,0,0,
  80.     0,0,198,238,254,254,214,198,198,198,198,198,0,0,0,0,
  81.     0,0,198,230,246,254,222,206,198,198,198,198,0,0,0,0,
  82.     0,0,124,198,198,198,198,198,198,198,198,124,0,0,0,0,
  83.     0,0,252,102,102,102,124,96,96,96,96,240,0,0,0,0,
  84.     0,0,124,198,198,198,198,198,198,214,222,124,12,14,0,0,
  85.     0,0,252,102,102,102,124,108,102,102,102,230,0,0,0,0,
  86.     0,0,124,198,198,96,56,12,6,198,198,124,0,0,0,0,
  87.     0,0,126,126,90,24,24,24,24,24,24,60,0,0,0,0,
  88.     0,0,198,198,198,198,198,198,198,198,198,124,0,0,0,0,
  89.     0,0,198,198,198,198,198,198,198,108,56,16,0,0,0,0,
  90.     0,0,198,198,198,198,214,214,214,254,238,108,0,0,0,0,
  91.     0,0,198,198,108,124,56,56,124,108,198,198,0,0,0,0,
  92.     0,0,102,102,102,102,60,24,24,24,24,60,0,0,0,0,
  93.     0,0,254,198,134,12,24,48,96,194,198,254,0,0,0,0,
  94.     0,0,60,48,48,48,48,48,48,48,48,60,0,0,0,0,
  95.     0,0,0,128,192,224,112,56,28,14,6,2,0,0,0,0,
  96.     0,0,60,12,12,12,12,12,12,12,12,60,0,0,0,0,
  97.     16,56,108,198,0,0,0,0,0,0,0,0,0,0,0,0,
  98.     0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,
  99.     48,48,24,0,0,0,0,0,0,0,0,0,0,0,0,0,
  100.     0,0,0,0,0,120,12,124,204,204,204,118,0,0,0,0,
  101.     0,0,224,96,96,120,108,102,102,102,102,124,0,0,0,0,
  102.     0,0,0,0,0,124,198,192,192,192,198,124,0,0,0,0,
  103.     0,0,28,12,12,60,108,204,204,204,204,118,0,0,0,0,
  104.     0,0,0,0,0,124,198,254,192,192,198,124,0,0,0,0,
  105.     0,0,56,108,100,96,240,96,96,96,96,240,0,0,0,0,
  106.     0,0,0,0,0,118,204,204,204,204,204,124,12,204,120,0,
  107.     0,0,224,96,96,108,118,102,102,102,102,230,0,0,0,0,
  108.     0,0,24,24,0,56,24,24,24,24,24,60,0,0,0,0,
  109.     0,0,6,6,0,14,6,6,6,6,6,6,102,102,60,0,
  110.     0,0,224,96,96,102,108,120,120,108,102,230,0,0,0,0,
  111.     0,0,56,24,24,24,24,24,24,24,24,60,0,0,0,0,
  112.     0,0,0,0,0,236,254,214,214,214,214,198,0,0,0,0,
  113.     0,0,0,0,0,220,102,102,102,102,102,102,0,0,0,0,
  114.     0,0,0,0,0,124,198,198,198,198,198,124,0,0,0,0,
  115.     0,0,0,0,0,220,102,102,102,102,102,124,96,96,240,0,
  116.     0,0,0,0,0,118,204,204,204,204,204,124,12,12,30,0,
  117.     0,0,0,0,0,220,118,102,96,96,96,240,0,0,0,0,
  118.     0,0,0,0,0,124,198,96,56,12,198,124,0,0,0,0,
  119.     0,0,16,48,48,252,48,48,48,48,54,28,0,0,0,0,
  120.     0,0,0,0,0,204,204,204,204,204,204,118,0,0,0,0,
  121.     0,0,0,0,0,102,102,102,102,102,60,24,0,0,0,0,
  122.     0,0,0,0,0,198,198,214,214,214,254,108,0,0,0,0,
  123.     0,0,0,0,0,198,108,56,56,56,108,198,0,0,0,0,
  124.     0,0,0,0,0,198,198,198,198,198,198,126,6,12,248,0,
  125.     0,0,0,0,0,254,204,24,48,96,198,254,0,0,0,0,
  126.     0,0,14,24,24,24,112,24,24,24,24,14,0,0,0,0,
  127.     0,0,24,24,24,24,0,24,24,24,24,24,0,0,0,0,
  128.     0,0,112,24,24,24,14,24,24,24,24,112,0,0,0,0,
  129.     0,0,118,220,0,0,0,0,0,0,0,0,0,0,0,0,
  130.     0,0,0,0,16,56,108,198,198,198,254,0,0,0,0,0,
  131.     0,0,60,102,194,192,192,192,194,102,60,12,6,124,0,0,
  132.     0,0,204,0,0,204,204,204,204,204,204,118,0,0,0,0,
  133.     0,12,24,48,0,124,198,254,192,192,198,124,0,0,0,0,
  134.     0,16,56,108,0,120,12,124,204,204,204,118,0,0,0,0,
  135.     0,0,204,0,0,120,12,124,204,204,204,118,0,0,0,0,
  136.     0,96,48,24,0,120,12,124,204,204,204,118,0,0,0,0,
  137.     0,56,108,56,0,120,12,124,204,204,204,118,0,0,0,0,
  138.     0,0,0,0,60,102,96,96,102,60,12,6,60,0,0,0,
  139.     0,16,56,108,0,124,198,254,192,192,198,124,0,0,0,0,
  140.     0,0,198,0,0,124,198,254,192,192,198,124,0,0,0,0,
  141.     0,96,48,24,0,124,198,254,192,192,198,124,0,0,0,0,
  142.     0,0,102,0,0,56,24,24,24,24,24,60,0,0,0,0,
  143.     0,24,60,102,0,56,24,24,24,24,24,60,0,0,0,0,
  144.     0,96,48,24,0,56,24,24,24,24,24,60,0,0,0,0,
  145.     0,198,0,16,56,108,198,198,254,198,198,198,0,0,0,0,
  146.     56,108,56,0,56,108,198,198,254,198,198,198,0,0,0,0,
  147.     24,48,96,0,254,102,96,124,96,96,102,254,0,0,0,0,
  148.     0,0,0,0,108,254,178,50,126,216,216,110,0,0,0,0,
  149.     0,0,62,108,204,204,254,204,204,204,204,206,0,0,0,0,
  150.     0,16,56,108,0,124,198,198,198,198,198,124,0,0,0,0,
  151.     0,0,198,0,0,124,198,198,198,198,198,124,0,0,0,0,
  152.     0,96,48,24,0,124,198,198,198,198,198,124,0,0,0,0,
  153.     0,48,120,204,0,204,204,204,204,204,204,118,0,0,0,0,
  154.     0,96,48,24,0,204,204,204,204,204,204,118,0,0,0,0,
  155.     0,0,198,0,0,198,198,198,198,198,198,126,6,12,120,0,
  156.     0,198,0,124,198,198,198,198,198,198,198,124,0,0,0,0,
  157.     0,198,0,198,198,198,198,198,198,198,198,124,0,0,0,0,
  158.     0,24,24,60,102,96,96,96,102,60,24,24,0,0,0,0,
  159.     0,56,108,100,96,240,96,96,96,96,230,252,0,0,0,0,
  160.     0,0,102,102,60,24,126,24,126,24,24,24,0,0,0,0,
  161.     0,248,204,204,248,196,204,222,204,204,204,198,0,0,0,0,
  162.     0,14,27,24,24,24,126,24,24,24,24,24,216,112,0,0,
  163.     0,24,48,96,0,120,12,124,204,204,204,118,0,0,0,0,
  164.     0,12,24,48,0,56,24,24,24,24,24,60,0,0,0,0,
  165.     0,24,48,96,0,124,198,198,198,198,198,124,0,0,0,0,
  166.     0,24,48,96,0,204,204,204,204,204,204,118,0,0,0,0,
  167.     0,0,118,220,0,220,102,102,102,102,102,102,0,0,0,0,
  168.     118,220,0,198,230,246,254,222,206,198,198,198,0,0,0,0,
  169.     0,60,108,108,62,0,126,0,0,0,0,0,0,0,0,0,
  170.     0,56,108,108,56,0,124,0,0,0,0,0,0,0,0,0,
  171.     0,0,48,48,0,48,48,96,192,198,198,124,0,0,0,0,
  172.     0,0,0,0,0,0,254,192,192,192,192,0,0,0,0,0,
  173.     0,0,0,0,0,0,254,6,6,6,6,0,0,0,0,0,
  174.     0,192,192,194,198,204,24,48,96,220,134,12,24,62,0,0,
  175.     0,192,192,194,198,204,24,48,102,206,158,62,6,6,0,0,
  176.     0,0,24,24,0,24,24,24,60,60,60,24,0,0,0,0,
  177.     0,0,0,0,0,54,108,216,108,54,0,0,0,0,0,0,
  178.     0,0,0,0,0,216,108,54,108,216,0,0,0,0,0,0,
  179.     17,68,17,68,17,68,17,68,17,68,17,68,17,68,17,68,
  180.     85,170,85,170,85,170,85,170,85,170,85,170,85,170,85,170,
  181.     221,119,221,119,221,119,221,119,221,119,221,119,221,119,221,119,
  182.     24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
  183.     24,24,24,24,24,24,24,248,24,24,24,24,24,24,24,24,
  184.     24,24,24,24,24,248,24,248,24,24,24,24,24,24,24,24,
  185.     54,54,54,54,54,54,54,246,54,54,54,54,54,54,54,54,
  186.     0,0,0,0,0,0,0,254,54,54,54,54,54,54,54,54,
  187.     0,0,0,0,0,248,24,248,24,24,24,24,24,24,24,24,
  188.     54,54,54,54,54,246,6,246,54,54,54,54,54,54,54,54,
  189.     54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,
  190.     0,0,0,0,0,254,6,246,54,54,54,54,54,54,54,54,
  191.     54,54,54,54,54,246,6,254,0,0,0,0,0,0,0,0,
  192.     54,54,54,54,54,54,54,254,0,0,0,0,0,0,0,0,
  193.     24,24,24,24,24,248,24,248,0,0,0,0,0,0,0,0,
  194.     0,0,0,0,0,0,0,248,24,24,24,24,24,24,24,24,
  195.     24,24,24,24,24,24,24,31,0,0,0,0,0,0,0,0,
  196.     24,24,24,24,24,24,24,255,0,0,0,0,0,0,0,0,
  197.     0,0,0,0,0,0,0,255,24,24,24,24,24,24,24,24,
  198.     24,24,24,24,24,24,24,31,24,24,24,24,24,24,24,24,
  199.     0,0,0,0,0,0,0,255,0,0,0,0,0,0,0,0,
  200.     24,24,24,24,24,24,24,255,24,24,24,24,24,24,24,24,
  201.     24,24,24,24,24,31,24,31,24,24,24,24,24,24,24,24,
  202.     54,54,54,54,54,54,54,55,54,54,54,54,54,54,54,54,
  203.     54,54,54,54,54,55,48,63,0,0,0,0,0,0,0,0,
  204.     0,0,0,0,0,63,48,55,54,54,54,54,54,54,54,54,
  205.     54,54,54,54,54,247,0,255,0,0,0,0,0,0,0,0,
  206.     0,0,0,0,0,255,0,247,54,54,54,54,54,54,54,54,
  207.     54,54,54,54,54,55,48,55,54,54,54,54,54,54,54,54,
  208.     0,0,0,0,0,255,0,255,0,0,0,0,0,0,0,0,
  209.     54,54,54,54,54,247,0,247,54,54,54,54,54,54,54,54,
  210.     24,24,24,24,24,255,0,255,0,0,0,0,0,0,0,0,
  211.     54,54,54,54,54,54,54,255,0,0,0,0,0,0,0,0,
  212.     0,0,0,0,0,255,0,255,24,24,24,24,24,24,24,24,
  213.     0,0,0,0,0,0,0,255,54,54,54,54,54,54,54,54,
  214.     54,54,54,54,54,54,54,63,0,0,0,0,0,0,0,0,
  215.     24,24,24,24,24,31,24,31,0,0,0,0,0,0,0,0,
  216.     0,0,0,0,0,31,24,31,24,24,24,24,24,24,24,24,
  217.     0,0,0,0,0,0,0,63,54,54,54,54,54,54,54,54,
  218.     54,54,54,54,54,54,54,255,54,54,54,54,54,54,54,54,
  219.     24,24,24,24,24,255,24,255,24,24,24,24,24,24,24,24,
  220.     24,24,24,24,24,24,24,248,0,0,0,0,0,0,0,0,
  221.     0,0,0,0,0,0,0,31,24,24,24,24,24,24,24,24,
  222.     255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  223.     0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,
  224.     240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
  225.     15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
  226.     255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,
  227.     0,0,0,0,0,118,220,216,216,216,220,118,0,0,0,0,
  228.     0,0,120,204,204,204,216,204,198,198,198,204,0,0,0,0,
  229.     0,0,254,198,198,192,192,192,192,192,192,192,0,0,0,0,
  230.     0,0,0,0,254,108,108,108,108,108,108,108,0,0,0,0,
  231.     0,0,0,254,198,96,48,24,48,96,198,254,0,0,0,0,
  232.     0,0,0,0,0,126,216,216,216,216,216,112,0,0,0,0,
  233.     0,0,0,0,102,102,102,102,102,124,96,96,192,0,0,0,
  234.     0,0,0,0,118,220,24,24,24,24,24,24,0,0,0,0,
  235.     0,0,0,126,24,60,102,102,102,60,24,126,0,0,0,0,
  236.     0,0,0,56,108,198,198,254,198,198,108,56,0,0,0,0,
  237.     0,0,56,108,198,198,198,108,108,108,108,238,0,0,0,0,
  238.     0,0,30,48,24,12,62,102,102,102,102,60,0,0,0,0,
  239.     0,0,0,0,0,126,219,219,219,126,0,0,0,0,0,0,
  240.     0,0,0,3,6,126,219,219,243,126,96,192,0,0,0,0,
  241.     0,0,28,48,96,96,124,96,96,96,48,28,0,0,0,0,
  242.     0,0,0,124,198,198,198,198,198,198,198,198,0,0,0,0,
  243.     0,0,0,0,254,0,0,254,0,0,254,0,0,0,0,0,
  244.     0,0,0,0,24,24,126,24,24,0,0,255,0,0,0,0,
  245.     0,0,0,48,24,12,6,12,24,48,0,126,0,0,0,0,
  246.     0,0,0,12,24,48,96,48,24,12,0,126,0,0,0,0,
  247.     0,0,14,27,27,27,24,24,24,24,24,24,24,24,24,24,
  248.     24,24,24,24,24,24,24,24,216,216,216,112,0,0,0,0,
  249.     0,0,0,0,24,24,0,126,0,24,24,0,0,0,0,0,
  250.     0,0,0,0,0,118,220,0,118,220,0,0,0,0,0,0,
  251.     0,56,108,108,56,0,0,0,0,0,0,0,0,0,0,0,
  252.     0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,
  253.     0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,
  254.     0,15,12,12,12,12,12,236,108,108,60,28,0,0,0,0,
  255.     0,216,108,108,108,108,108,0,0,0,0,0,0,0,0,0,
  256.     0,112,216,48,96,200,248,0,0,0,0,0,0,0,0,0,
  257.     0,0,0,0,124,124,124,124,124,124,124,0,0,0,0,0,
  258.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

  259. bit07=[1,2,4,8,16,32,64,128]
  260. #bit1=2
  261. #bit2=4
  262. #bit3=8
  263. #bit4=16
  264. #bit5=32
  265. #bit6=64
  266. #bit7=128

  267. my_width = 8 *2
  268. #my_width = 8 *12
  269. # my_buff=[[0]*my_width]*16 # error !!!
  270. # my_buff=[[0 for x in range(my_width)] for y in range(16)]
  271. test1=[0,0,0,0,0,0,0,0]


  272. def disp_ch(row,col,ch,transparence,forecolor,bkcolor,my_buff):
  273.    ch_int=ord(ch)
  274.    if ch_int>=0x80 :
  275.      return
  276.    
  277.    ch_matrixs=a168[16*ch_int:16*ch_int+16]
  278.    for i in range(0,16):
  279.        ch_matrix=ch_matrixs[i]
  280.        #print ch_matrix
  281.        k=0
  282.        for j in range(7,-1,-1):
  283.            # print row*16+i ,col*8+k

  284.            if (ch_matrix & bit07[j])>0 :
  285.      my_buff[row*16+i][col*8+k]=1
  286.             test1[k]=1
  287.            else:
  288.            my_buff[row*16+i][col*8+k]=0
  289.                 test1[k]=0
  290.            k=k+1
  291.        #print test1

  292. def testbuf(my_buff):
  293.    #disp_ch(0,0,'1',0,0,0)
  294.    #disp_ch(0,1,'2',0,0,0)
  295.    for i in range(0,16):
  296.       testline=[]
  297.       for j in range(0,my_width):
  298.         #print i
  299.     #print j
  300.         testline.append(my_buff[i][j])
  301.       print testline



  302. def b2c(pathtxt, path2c):
  303.     if pathtxt == path2c:
  304.         raise Exception("Can't read and write the same file")
  305.     
  306.     cf = file(path2c, "w")
  307.     bf = file(pathtxt, "rb")
  308.     char = bf.read(1)
  309.     
  310.     col=0
  311.     row=0
  312.     tsize=0
  313.     array = []
  314.     
  315.     while ord(char)!=0xd:
  316.       array.append(char)
  317.       tsize=tsize+1
  318.       if tsize>15:
  319.          break
  320.       char = bf.read(1)
  321.       
  322.     print tsize
  323.    
  324.     my_buff=[[0 for x in range(tsize*8)] for y in range(16)]
  325.     i=0
  326.     #print array
  327.     for char in array:
  328.       disp_ch(row,col+i,char,0,0,0,my_buff)
  329.       i=i+1
  330.     #testbuf(my_buff)
  331.     
  332.     cf.write("\n\n/* dont modify this file ! please run tools auto create it */\n\n")

  333.     cf.write("UINT16 ver_bitmap[] = {\n")
  334.     row =0
  335.     col=0
  336.     for row in range(0,16):
  337.       for col in range(0,tsize*8):
  338.             #print row,col, my_buff[row][col]
  339.             if my_buff[row][col] == 0:
  340.                 cf.write("0x0000, ")
  341.             elif my_buff[row][col] == 1:
  342.                 cf.write("0xFFFF, ")

  343.             if col % 8 == 0:
  344.                 cf.write("\n")

  345.     cf.write("0x0000};\n")


  346.     # 上面已经生成显示字母数组,下面可以自己添加一些代码(显示生成字符的函数)
  347.     cf.write("\n /* add you code for use above array*/\n")
  348.     cf.write("{\n")
  349.     
  350.     #cf.write(str(tsize*8)) # 写入数组大小
  351.     

  352.     cf.close();

  353. def main():
  354.     if len(sys.argv) != 3:
  355.         print "Usage:", sys.argv[0], "", ""
  356.         return
  357.     
  358.     try:
  359.         b2c(sys.argv[1], sys.argv[2])
  360.     except Exception, e:
  361.         print "ERROR:", e

  362. if __name__ == "__main__":
  363.     main()
目前只支持16*8 asccii 字母
阅读(1049) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~