A 55x31 font for the SPI_TFT library, based on the free Source Code Pro semi-bold (http://sourceforge.net/projects/sourcecodepro.adobe/) Includes optional characters for Mu (micro), Omega (Ohm), +-, square, cubed, Degree sign
main.cpp
00001 // example for Source Code Pro 31px font 00002 00003 #include "stdio.h" 00004 #include "mbed.h" 00005 #include "string" 00006 #include "SourceCodePro31.h" 00007 #include "SPI_TFT.h" 00008 00009 // the TFT is connected to SPI pin 11-13 00010 SPI_TFT TFT(p11, p12, p13, p14, p15,"TFT"); // mosi, miso, sclk, cs, reset 00011 00012 int main() { 00013 int i, j; float f; 00014 TFT.claim(stdout); // send stdout to the TFT display 00015 00016 TFT.set_orientation(1); 00017 00018 for(j = 0; 1; j++) { 00019 TFT.background(Blue); // set background to black 00020 TFT.foreground(White); // set chars to white 00021 TFT.cls(); // clear the screen 00022 00023 TFT.set_orientation(1); 00024 TFT.set_font((unsigned char*) SCProSB31x55); 00025 00026 for(i = 0; i < 320; i++) { 00027 f = rand() / 1E9 - 1; 00028 f = f / 5 + sin(i / 26.0); 00029 TFT.locate(0,10); 00030 TFT.printf("%c", f < 0 ? '-' : '+'); 00031 TFT.locate(33,10); 00032 TFT.printf("%7.5f", abs(f)); 00033 TFT.locate(250,10); 00034 // TFT.printf("}\x7f"); 00035 TFT.printf("}A"); 00036 TFT.line(i,150,i,150-f*50, f > 0 ? White : Red); 00037 wait_ms(j & 1 ? 80 : 300 00038 ); 00039 } 00040 } 00041 } 00042
Generated on Wed Jul 13 2022 10:24:42 by 1.7.2