src/dps8/blinkenLightsPi.c
// Draw a text string on the display
Draw a text string on the display
Draw a text string on the display
static void draw (int textX, int textY, char *arg)
  {
    textX *= FONTW;
    textY *= FONTH;
    char * text = arg;
    int i, l, x, y;
    l = strlen (text);
    for (i = 0; i < l; i ++)
      {
        char ch = text [i];
        if (ch == 'n') 
          {
            textX = 0;
            textY += FONTH;
            continue;
          }
        pxl color = fg_col;
        if (ch == '+')
          {
            ch = '@';
          }
        else if (ch == '-')
          {
            ch = '@';
            color = bg_col;
          }
        int ix = font_index (ch);
        char * img = fontImg [ix];
        for (y = 0; y < FONTH; y ++)
          {
            for (x = 0; x < FONTW; x ++)
              {
                char b = img [y * FONTW + x];
                if (b > 0)
                  { 
                    put_pixel (textX + x, textY + y, color);
                  }
                else
                  {
                    put_pixel (textX + x, textY + y, grey);
                  }
              } 
          } 
        textX += FONTW;
      } 
  }
static void draw ( int textX , int textY , char * arg ) { textX *= FONTW ; textY *= FONTH ; char * text = arg ; int i , l , x , y ; l = strlen ( text ) ; for ( i = 0 ; i < l ; i ++ ) { char ch = text [ i ] ; if ( ch == ' ' ) { textX = 0 ; textY += FONTH ; continue ; } pxl color = fg_col ; if ( ch == ' ' ) { ch = ' ' ; } else if ( ch == ' ' ) { ch = ' ' ; color = bg_col ; } int ix = font_index ( ch ) ; char * img = fontImg [ ix ] ; for ( y = 0 ; y < FONTH ; y ++ ) { for ( x = 0 ; x < FONTW ; x ++ ) { char b = img [ y * FONTW + x ] ; if ( b > 0 ) { put_pixel ( textX + x , textY + y , color ) ; } else { put_pixel ( textX + x , textY + y , grey ) ; } } } textX += FONTW ; } }
Draw a text string on the display
Draw a text string on the display
// Convert from text row/col to pixel coordinates. // loop through all characters in the text string // newline // Draw '+' as a white circle // Draw '-' as a black circle // get the 'image' index for this character // get the font 'image' // loop through pixel rows // loop through pixel columns // get the pixel value // plot the pixel // end "for x" // end "for y" // end "for i"