/* * NAME: WriteCharDisplayBuf * DESCRIPTION: Writes one character to the display screen buffer (DisplayUpdate() needs to be called subsequently to output the buffer to the screen) * INPUTS: * * Character: The character we want to draw. In this sample, special characters like tabs and newlines are not supported. * Col: The horizontal column we want to start drawing at. This is equivalent to the 'X' axis pixel position. * Row: The vertical row we want to write to. The screen is divided up into 4 rows of 16 pixels each, so valid values for Row are 0,1,2,3. * * RETURN VALUE: * We return the number of horizontal pixels used. This value is 0 if Row/Col are out-of-bounds, or if the character isn't available in the font. */ private UInt32 WriteCharDisplayBuf(Char Chr, UInt32 Col, UInt32 Row) { /* Check that we were able to find the font corresponding to our character */ FontCharacterDescriptor CharDescriptor = DisplayFontTable.GetCharacterDescriptor(Chr); if (CharDescriptor == null) { return(0); } /* Make sure we're drawing within the boundaries of the screen buffer */ UInt32 MaxRowValue = (SCREEN_HEIGHT_PAGES / DisplayFontTable.FontHeightBytes) - 1; UInt32 MaxColValue = SCREEN_WIDTH_PX; if (Row > MaxRowValue) { return(0); } if ((Col + CharDescriptor.CharacterWidthPx + DisplayFontTable.FontCharSpacing) > MaxColValue) { return(0); } UInt32 CharDataIndex = 0; UInt32 StartPage = Row * 2; UInt32 EndPage = StartPage + CharDescriptor.CharacterHeightBytes; UInt32 StartCol = Col; UInt32 EndCol = StartCol + CharDescriptor.CharacterWidthPx; UInt32 CurrentPage = 0; UInt32 CurrentCol = 0; /* Copy the character image into the display buffer */ for (CurrentPage = StartPage; CurrentPage < EndPage; CurrentPage++) { for (CurrentCol = StartCol; CurrentCol < EndCol; CurrentCol++) { //WorkingDisplayBuffer[CurrentCol, CurrentPage] = new CPixel(CharDescriptor.CharacterData[CharDataIndex]); CharDataIndex++; } } /* Pad blank spaces to the right of the character so there exists space between adjacent characters */ for (CurrentPage = StartPage; CurrentPage < EndPage; CurrentPage++) { for (; CurrentCol < EndCol + DisplayFontTable.FontCharSpacing; CurrentCol++) { //WorkingDisplayBuffer[CurrentCol, CurrentPage] = new CPixel(0); } } /* Return the number of horizontal pixels used by the character */ return(CurrentCol - StartCol); }
private void BtnNext_Click(object sender, RoutedEventArgs e) { if (Order < (UInt16)(DisplayFontTable.GetFontTableStandartSize() - 1)) { Order = (UInt16)(Order + 1); } else { Order = 0; } fcd = DisplayFontTable.GetFontCharacterDescriptorFromFontTableStandart(Order); FontCharacterDescriptorToScreen(fcd); }
private void BtnPrevious_Click(object sender, RoutedEventArgs e) { if (Order > 0) { Order = (UInt16)(Order - 1); } else { Order = 255; } fcd = DisplayFontTable.GetFontCharacterDescriptorFromFontTableStandart(Order); FontCharacterDescriptorToScreen(fcd); }
/* * NAME: WriteCharDisplayBuf * DESCRIPTION: Writes one character to the display screen buffer (DisplayUpdate() needs to be called subsequently to output the buffer to the screen) * INPUTS: * * Character: The character we want to draw. In this sample, special characters like tabs and newlines are not supported. * Col: The horizontal column we want to start drawing at. This is equivalent to the 'X' axis pixel position. * Row: The vertical row we want to write to. The screen is divided up into 4 rows of 16 pixels each, so valid values for Row are 0,1,2,3. * * RETURN VALUE: * We return the number of horizontal pixels used. This value is 0 if Row/Col are out-of-bounds, or if the character isn't available in the font. */ public uint WriteCharDisplayBuf(char Chr, uint Col, uint Row) { /* Get our character descriptor or the undefined box */ FontCharacterDescriptor CharDescriptor = DisplayFontTable.GetCharacterDescriptor(Chr); /* Make sure we're drawing within the boundaries of the screen buffer */ uint MaxRowValue = (SCREEN_HEIGHT_PAGES / DisplayFontTable.FontHeightBytes) - 1; uint MaxColValue = SCREEN_WIDTH_PX; if (Row > MaxRowValue) { return(0); } if ((Col + CharDescriptor.CharacterWidthPx + DisplayFontTable.FontCharSpacing) > MaxColValue) { return(0); } uint CharDataIndex = 0; uint StartPage = Row * 2; //0 uint EndPage = StartPage + CharDescriptor.CharacterHeightBytes; //2 uint StartCol = Col; uint EndCol = StartCol + CharDescriptor.CharacterWidthPx; uint CurrentPage = 0; uint CurrentCol = 0; /* Copy the character image into the display buffer */ for (CurrentPage = StartPage; CurrentPage < EndPage; CurrentPage++) { for (CurrentCol = StartCol; CurrentCol < EndCol; CurrentCol++) { DisplayBuffer[CurrentCol, CurrentPage] = CharDescriptor.CharacterData[CharDataIndex]; CharDataIndex++; } } /* Pad blank spaces to the right of the character so there exists space between adjacent characters */ for (CurrentPage = StartPage; CurrentPage < EndPage; CurrentPage++) { for (; CurrentCol < EndCol + DisplayFontTable.FontCharSpacing; CurrentCol++) { DisplayBuffer[CurrentCol, CurrentPage] = 0x00; } } /* Return the number of horizontal pixels used by the character */ return(CurrentCol - StartCol); }
public void DrawText(uint x, uint y, string Line, uint color) { foreach (Char Character in Line) { FontCharacterDescriptor CharDescriptor = DisplayFontTable.GetCharacterDescriptor(Character); if (CharDescriptor == null) { return; } uint w = CharDescriptor.CharacterWidthPx; w = 16; uint h = CharDescriptor.CharacterHeightBytes; addressSet(x, y, x + w, y + h); DisplaySendData(CharDescriptor.CharacterData); x += w; } }
async private void BtnPlay_Click(object sender, RoutedEventArgs e) { isPlaying = !isPlaying; if (isPlaying) { btnPlay.Content = "\xE769"; while (Order < (UInt16)(DisplayFontTable.GetFontTableStandartSize() - 1) && isPlaying) { Order = (UInt16)(Order + 1); fcd = DisplayFontTable.GetFontCharacterDescriptorFromFontTableStandart(Order); FontCharacterDescriptorToScreen(fcd); await Task.Delay(500); } } else { btnPlay.Content = "\xE768"; } }
public void MakeChar(UInt16 x, UInt16 y, char c, UInt16 textsize, int color) { UInt16 wCharOriginal = 6; UInt16 hCharOriginal = 8; UInt16 wCharSized = (UInt16)(wCharOriginal * textsize); UInt16 hCharSized = (UInt16)(hCharOriginal * textsize); // bounds checks if ((x >= LCD_W) || (y >= LCD_H) || ((x + wCharSized - 1) < 0) || ((y + hCharSized - 1) < 0)) { return; } byte[] car = DisplayFontTable.GetFontCharacterDescriptorFromFontTableStandart(c).Data; String c0 = car[0].ToString("X"); String c1 = car[1].ToString("X"); String c2 = car[2].ToString("X"); String c3 = car[3].ToString("X"); String c4 = car[4].ToString("X"); if (c0.Length < 2) { c0 = "0" + c0; } if (c1.Length < 2) { c1 = "0" + c1; } if (c2.Length < 2) { c2 = "0" + c2; } if (c3.Length < 2) { c3 = "0" + c3; } if (c4.Length < 2) { c4 = "0" + c4; } String c01 = c0.Substring(0, 1); String c00 = c0.Substring(1, 1); String c11 = c1.Substring(0, 1); String c10 = c1.Substring(1, 1); String c21 = c2.Substring(0, 1); String c20 = c2.Substring(1, 1); String c31 = c3.Substring(0, 1); String c30 = c3.Substring(1, 1); String c41 = c4.Substring(0, 1); String c40 = c4.Substring(1, 1); bool[] b01 = Util.Convert.ConvertHexToBin(c01); bool[] b00 = Util.Convert.ConvertHexToBin(c00); bool[] b11 = Util.Convert.ConvertHexToBin(c11); bool[] b10 = Util.Convert.ConvertHexToBin(c10); bool[] b21 = Util.Convert.ConvertHexToBin(c21); bool[] b20 = Util.Convert.ConvertHexToBin(c20); bool[] b31 = Util.Convert.ConvertHexToBin(c31); bool[] b30 = Util.Convert.ConvertHexToBin(c30); bool[] b41 = Util.Convert.ConvertHexToBin(c41); bool[] b40 = Util.Convert.ConvertHexToBin(c40); ushort[] _charOriginal = new ushort[wCharOriginal * hCharOriginal]; if (b00[0]) { _charOriginal[0] = (ushort)color; } else { _charOriginal[0] = RGB888ToRGB565(0, 0, 0); } if (b10[0]) { _charOriginal[1] = (ushort)color; } else { _charOriginal[1] = RGB888ToRGB565(0, 0, 0); } if (b20[0]) { _charOriginal[2] = (ushort)color; } else { _charOriginal[2] = RGB888ToRGB565(0, 0, 0); } if (b30[0]) { _charOriginal[3] = (ushort)color; } else { _charOriginal[3] = RGB888ToRGB565(0, 0, 0); } if (b40[0]) { _charOriginal[4] = (ushort)color; } else { _charOriginal[4] = RGB888ToRGB565(0, 0, 0); } _charOriginal[5] = RGB888ToRGB565(0, 0, 0); if (b00[1]) { _charOriginal[6] = (ushort)color; } else { _charOriginal[6] = RGB888ToRGB565(0, 0, 0); } if (b10[1]) { _charOriginal[7] = (ushort)color; } else { _charOriginal[7] = RGB888ToRGB565(0, 0, 0); } if (b20[1]) { _charOriginal[8] = (ushort)color; } else { _charOriginal[8] = RGB888ToRGB565(0, 0, 0); } if (b30[1]) { _charOriginal[9] = (ushort)color; } else { _charOriginal[9] = RGB888ToRGB565(0, 0, 0); } if (b40[1]) { _charOriginal[10] = (ushort)color; } else { _charOriginal[10] = RGB888ToRGB565(0, 0, 0); } _charOriginal[11] = RGB888ToRGB565(0, 0, 0); if (b00[2]) { _charOriginal[12] = (ushort)color; } else { _charOriginal[12] = RGB888ToRGB565(0, 0, 0); } if (b10[2]) { _charOriginal[13] = (ushort)color; } else { _charOriginal[13] = RGB888ToRGB565(0, 0, 0); } if (b20[2]) { _charOriginal[14] = (ushort)color; } else { _charOriginal[14] = RGB888ToRGB565(0, 0, 0); } if (b30[2]) { _charOriginal[15] = (ushort)color; } else { _charOriginal[15] = RGB888ToRGB565(0, 0, 0); } if (b40[2]) { _charOriginal[16] = (ushort)color; } else { _charOriginal[16] = RGB888ToRGB565(0, 0, 0); } _charOriginal[17] = RGB888ToRGB565(0, 0, 0); if (b00[3]) { _charOriginal[18] = (ushort)color; } else { _charOriginal[18] = RGB888ToRGB565(0, 0, 0); } if (b10[3]) { _charOriginal[19] = (ushort)color; } else { _charOriginal[19] = RGB888ToRGB565(0, 0, 0); } if (b20[3]) { _charOriginal[20] = (ushort)color; } else { _charOriginal[20] = RGB888ToRGB565(0, 0, 0); } if (b30[3]) { _charOriginal[21] = (ushort)color; } else { _charOriginal[21] = RGB888ToRGB565(0, 0, 0); } if (b40[3]) { _charOriginal[22] = (ushort)color; } else { _charOriginal[22] = RGB888ToRGB565(0, 0, 0); } _charOriginal[23] = RGB888ToRGB565(0, 0, 0); if (b01[0]) { _charOriginal[24] = (ushort)color; } else { _charOriginal[24] = RGB888ToRGB565(0, 0, 0); } if (b11[0]) { _charOriginal[25] = (ushort)color; } else { _charOriginal[25] = RGB888ToRGB565(0, 0, 0); } if (b21[0]) { _charOriginal[26] = (ushort)color; } else { _charOriginal[26] = RGB888ToRGB565(0, 0, 0); } if (b31[0]) { _charOriginal[27] = (ushort)color; } else { _charOriginal[27] = RGB888ToRGB565(0, 0, 0); } if (b41[0]) { _charOriginal[28] = (ushort)color; } else { _charOriginal[28] = RGB888ToRGB565(0, 0, 0); } _charOriginal[29] = RGB888ToRGB565(0, 0, 0); if (b01[1]) { _charOriginal[30] = (ushort)color; } else { _charOriginal[30] = RGB888ToRGB565(0, 0, 0); } if (b11[1]) { _charOriginal[31] = (ushort)color; } else { _charOriginal[31] = RGB888ToRGB565(0, 0, 0); } if (b21[1]) { _charOriginal[32] = (ushort)color; } else { _charOriginal[32] = RGB888ToRGB565(0, 0, 0); } if (b31[1]) { _charOriginal[33] = (ushort)color; } else { _charOriginal[33] = RGB888ToRGB565(0, 0, 0); } if (b41[1]) { _charOriginal[34] = (ushort)color; } else { _charOriginal[34] = RGB888ToRGB565(0, 0, 0); } _charOriginal[35] = RGB888ToRGB565(0, 0, 0); if (b01[2]) { _charOriginal[36] = (ushort)color; } else { _charOriginal[36] = RGB888ToRGB565(0, 0, 0); } if (b11[2]) { _charOriginal[37] = (ushort)color; } else { _charOriginal[37] = RGB888ToRGB565(0, 0, 0); } if (b21[2]) { _charOriginal[38] = (ushort)color; } else { _charOriginal[38] = RGB888ToRGB565(0, 0, 0); } if (b31[2]) { _charOriginal[39] = (ushort)color; } else { _charOriginal[39] = RGB888ToRGB565(0, 0, 0); } if (b41[2]) { _charOriginal[40] = (ushort)color; } else { _charOriginal[40] = RGB888ToRGB565(0, 0, 0); } _charOriginal[41] = RGB888ToRGB565(0, 0, 0); _charOriginal[42] = RGB888ToRGB565(0, 0, 0); _charOriginal[43] = RGB888ToRGB565(0, 0, 0); _charOriginal[44] = RGB888ToRGB565(0, 0, 0); _charOriginal[45] = RGB888ToRGB565(0, 0, 0); _charOriginal[46] = RGB888ToRGB565(0, 0, 0); _charOriginal[47] = RGB888ToRGB565(0, 0, 0); ushort[] _charSized = new ushort[wCharSized * hCharSized]; int cs = 0; for (int hco = 0; hco < hCharOriginal; hco++) { for (int hts = 0; hts < textsize; hts++) { for (int wco = 0; wco < wCharOriginal; wco++) { for (int wts = 0; wts < textsize; wts++) { _charSized[cs] = _charOriginal[hco * wCharOriginal + wco]; cs++; } } } } DrawPicture08(_charSized, wCharSized, hCharSized, x, y); }
private void BtnFastForward_Click(object sender, RoutedEventArgs e) { Order = (UInt16)(DisplayFontTable.GetFontTableStandartSize() - 1); fcd = DisplayFontTable.GetFontCharacterDescriptorFromFontTableStandart(Order); FontCharacterDescriptorToScreen(fcd); }
private void BtnRewind_Click(object sender, RoutedEventArgs e) { Order = 0; fcd = DisplayFontTable.GetFontCharacterDescriptorFromFontTableStandart(Order); FontCharacterDescriptorToScreen(fcd); }