Zur Übersicht - INFO - Neueste 50 Beiträge - Neuer Beitrag - Suchen - FAQ - Zum CC1-Forum - Zum CC-Pro-Forum

Große Zahlen auf Display Kategorie: Programmierung (von Rocky98 - 18.02.2006 13:14)
Ich nutze:
C-Control II Unit, CC2-StarterBoard, OSOPT V3.0
Hi @all,

hier die Funktionen für die Darstellung von gro�en Zahlen.

Funktionsset für Zahlen über 2 Zeilen


function def_doublelinenums()
{byte chars[8];

 chars[0] = 0x01;
 chars[1] = 0x01;
 chars[2] = 0x01;
 chars[3] = 0x01;
 chars[4] = 0x01;
 chars[5] = 0x01;
 chars[6] = 0x01;
 chars[7] = 0x01;
 defineChar(0,chars);
 chars[0] = 0x1F;
 chars[1] = 0x11;
 chars[2] = 0x11;
 chars[3] = 0x11;
 chars[4] = 0x11;
 chars[5] = 0x11;
 chars[6] = 0x11;
 chars[7] = 0x11;
 defineChar(1,chars);
 chars[0] = 0x1F;
 chars[1] = 0x10;
 chars[2] = 0x10;
 chars[3] = 0x10;
 chars[4] = 0x10;
 chars[5] = 0x10;
 chars[6] = 0x10;
 chars[7] = 0x1F;
 defineChar(2,chars);
 chars[0] = 0x01;
 chars[1] = 0x01;
 chars[2] = 0x01;
 chars[3] = 0x01;
 chars[4] = 0x01;
 chars[5] = 0x01;
 chars[6] = 0x01;
 chars[7] = 0x1F;
 defineChar(3,chars);
 chars[0] = 0x1F;
 chars[1] = 0x11;
 chars[2] = 0x11;
 chars[3] = 0x11;
 chars[4] = 0x11;
 chars[5] = 0x11;
 chars[6] = 0x11;
 chars[7] = 0x1F;
 defineChar(4,chars);
 chars[0] = 0x11;
 chars[1] = 0x11;
 chars[2] = 0x11;
 chars[3] = 0x11;
 chars[4] = 0x11;
 chars[5] = 0x11;
 chars[6] = 0x11;
 chars[7] = 0x1F;
 defineChar(5,chars);
 chars[0] = 0x1F;
 chars[1] = 0x01;
 chars[2] = 0x01;
 chars[3] = 0x01;
 chars[4] = 0x01;
 chars[5] = 0x01;
 chars[6] = 0x01;
 chars[7] = 0x1F;
 defineChar(6,chars);
 chars[0] = 0x1F;
 chars[1] = 0x01;
 chars[2] = 0x01;
 chars[3] = 0x01;
 chars[4] = 0x01;
 chars[5] = 0x01;
 chars[6] = 0x01;
 chars[7] = 0x01;
 defineChar(7,chars);

}
function print_upper_num(int num)
{
  if num == 0 {put(1);};
  if num == 1 {put(0);};
  if num == 2 {put(7);};
  if num == 3 {put(6);};
  if num == 4 {put(5);};
  if num == 5 {put(2);};
  if num == 6 {put(2);};
  if num == 7 {put(7);};
  if num == 8 {put(4);};
  if num == 9 {put(4);};
}
function print_lower_num(int num)
{
  if num == 0 {put(5);};
  if num == 1 {put(0);};
  if num == 2 {put(2);};
  if num == 3 {put(3);};
  if num == 4 {put(0);};
  if num == 5 {put(3);};
  if num == 6 {put(5);};
  if num == 7 {put(0);};
  if num == 8 {put(5);};
  if num == 9 {put(3);};
}


function print_doublelinenum(int num,int row, int col)
{
   goto(row,col);
   print_upper_num(num);
   goto(row+1,col);
   print_lower_num(num);
}



Und hier der Code für die Darstellung über alle 4 Zeilen


function def_bignums()
{byte chars[8];

 chars[0] = 0;
 chars[1] = 0;
 chars[2] = 0;
 chars[3] = 0;
 chars[4] = 1;
 chars[5] = 3;
 chars[6] = 7;
 chars[7] = 15;
 defineChar(0,chars);
 chars[0] = 0;
 chars[1] = 0;
 chars[2] = 0;
 chars[3] = 0;
 chars[4] = 31;
 chars[5] = 31;
 chars[6] = 31;
 chars[7] = 31;
 defineChar(1,chars);
 chars[0] = 0;
 chars[1] = 0;
 chars[2] = 0;
 chars[3] = 0;
 chars[4] = 16;
 chars[5] = 24;
 chars[6] = 28;
 chars[7] = 30;
 defineChar(2,chars);
 chars[0] = 31;
 chars[1] = 31;
 chars[2] = 31;
 chars[3] = 31;
 chars[4] = 30;
 chars[5] = 28;
 chars[6] = 24;
 chars[7] = 16;
 defineChar(3,chars);
 chars[0] = 16;
 chars[1] = 24;
 chars[2] = 28;
 chars[3] = 30;
 chars[4] = 31;
 chars[5] = 31;
 chars[6] = 31;
 chars[7] = 31;
 defineChar(4,chars);
 chars[0] = 15;
 chars[1] = 7;
 chars[2] = 3;
 chars[3] = 1;
 chars[4] = 0;
 chars[5] = 0;
 chars[6] = 0;
 chars[7] = 0;
 defineChar(5,chars);
 chars[0] = 31;
 chars[1] = 31;
 chars[2] = 31;
 chars[3] = 31;
 chars[4] = 0;
 chars[5] = 0;
 chars[6] = 0;
 chars[7] = 0;
 defineChar(6,chars);
 chars[0] = 30;
 chars[1] = 28;
 chars[2] = 24;
 chars[3] = 16;
 chars[4] = 0;
 chars[5] = 0;
 chars[6] = 0;
 chars[7] = 0;
 defineChar(7,chars);

}
const bignum0[] = 0,1,2,255,32,255,255,32,255,5,6,7;
const bignum1[] = 0,1,32,32,255,32,32,255,32,6,6,6;
const bignum2[] = 0,1,2,0,1,3,255,32,32,6,6,6;
const bignum3[] = 0,1,2,32,0,3,32,5,4,5,6,7;
const bignum4[] = 0,32,1,255,32,255,6,6,255,32,32,6;
const bignum5[] = 1,1,1,255,1,2,32,32,255,5,6,7;
const bignum6[] = 0,1,2,255,1,2,255,32,255,5,6,7;
const bignum7[] = 1,1,1,32,0,3,32,255,32,32,6,32;
const bignum8[] = 0,1,2,255,1,255,255,32,255,5,6,7;
const bignum9[] = 0,1,2,255,1,255,32,32,255,5,6,7;
function print_bignum(int num,int col)
{
  int c,r,i;
  byte pchar[11];
 
 if num == 0
  {
    for i = 0...11
    {
      pchar[i] = bignum0[i];
    }
  }
  if num == 1
  {
    for i = 0...11
    {
      pchar[i] = bignum1[i];
    }
   }
  if num == 2
  {
    for i = 0...11
    {
      pchar[i] = bignum2[i];
    }
  }
  if num == 3
  {
    for i = 0...11
    {
      pchar[i] = bignum3[i];
    }
  }
  if num == 4
  {
    for i = 0...11
    {
      pchar[i] = bignum4[i];
    }
  }
  if num == 5
  {
    for i = 0...11
    {
      pchar[i] = bignum5[i];
    }
  }
  if num == 6
  {
    for i = 0...11
    {
      pchar[i] = bignum6[i];
    }
  }
  if num == 7
  {
    for i = 0...11
    {
      pchar[i] = bignum7[i];
    }
  }
  if num == 8
  {
    for i = 0...11
    {
      pchar[i] = bignum8[i];
    }
  }
  if num == 9
  {
    for i = 0...11
    {
      pchar[i] = bignum9[i];
    }
  }

  i=0;
  for r = 1 ... 4
  {
    goto(r,col);
    for c = 0 ... 2
    {
       put(pchar[i]);
       i = i + 1;
    }
  }
}




Der Code kann einfach in die pcflcd od. rblcd Unit reinkopiert werden.

�ber die Funktionen def_doublelinenums() bzw. def_bignums() werden die benötigten Zeichen in den
CGRAM des Display geladen.
�ber die Funktionen print_bignum bzw. print_doublelinenum können dann die Zahlen ausgegeben werden

Viel SpaÃ? damit

GruÃ? Frank


    Antwort schreiben


Antworten: