├── Fonts ├── Font16.c ├── Font16.h ├── Font32rle.c ├── Font32rle.h ├── Font64rle.c ├── Font64rle.h ├── Font72rle.c ├── Font72rle.h ├── Font7srle.c ├── Font7srle.h └── glcdfont.c ├── README.md ├── README.txt ├── TFT_FastPin.h ├── TFT_ST7735.cpp ├── TFT_ST7735.h ├── User_Setup.h ├── examples ├── Arduino_Life │ └── Arduino_Life.ino ├── Flash_Bitmap2 │ ├── Alert.h │ ├── Close.h │ ├── Flash_Bitmap2.ino │ └── Info.h ├── Pong_v3 │ └── Pong_v3.ino ├── RLE_Font_test │ └── RLE_Font_test.ino ├── TFT_7735_Meter_5 │ └── TFT_7735_Meter_5.ino ├── TFT_Char_times │ └── TFT_Char_times.ino ├── TFT_Clock_Digital_ST7735 │ └── TFT_Clock_Digital_ST7735.ino ├── TFT_Clock_ST7735 │ └── TFT_Clock_ST7735.ino ├── TFT_Ellipse │ └── TFT_Ellipse.ino ├── TFT_Print_Test │ └── TFT_Print_Test.ino ├── TFT_Rainbow_ST7735 │ └── TFT_Rainbow_ST7735.ino ├── TFT_graphicstest_PDQ3 │ └── TFT_graphicstest_PDQ3.ino ├── TFT_graphicstest_small │ └── TFT_graphicstest_small.ino └── UTFT_demo_fast │ └── UTFT_demo_fast.ino ├── keywords.txt └── library.properties /Fonts/Font16.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f16 96 4 | #define chr_hgt_f16 16 5 | #define data_size_f16 8 6 | #define firstchr_f16 32 7 | 8 | extern const unsigned char widtbl_f16[96]; 9 | extern const unsigned char* const chrtbl_f16[96]; 10 | -------------------------------------------------------------------------------- /Fonts/Font32rle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f32 96 4 | #define chr_hgt_f32 26 5 | #define data_size_f32 8 6 | #define firstchr_f32 32 7 | 8 | extern const unsigned char widtbl_f32[96]; 9 | extern const unsigned char* const chrtbl_f32[96]; 10 | -------------------------------------------------------------------------------- /Fonts/Font64rle.c: -------------------------------------------------------------------------------- 1 | // Font size 6 is intended to display numbers and time 2 | // 3 | // This font has been 8 bit Run Length Encoded to save FLASH space 4 | // 5 | // This font only contains characters [space] 0 1 2 3 4 5 6 7 8 9 : - . a p m 6 | // The Pipe character | is a narrow space to aid formatting 7 | // All other characters print as a space 8 | 9 | 10 | #include 11 | 12 | 13 | PROGMEM const unsigned char widtbl_f64[96] = // character width table 14 | { 15 | 12, 12, 12, 12, 12, 12, 12, 12, // char 32 - 39 16 | 12, 12, 12, 12, 12, 17, 15, 12, // char 40 - 47 17 | 27, 27, 27, 27, 27, 27, 27, 27, // char 48 - 55 18 | 27, 27, 15, 12, 12, 12, 12, 12, // char 56 - 63 19 | 12, 12, 12, 12, 12, 12, 12, 12, // char 64 - 71 20 | 12, 12, 12, 12, 12, 12, 12, 12, // char 72 - 79 21 | 12, 12, 12, 12, 12, 12, 12, 12, // char 80 - 87 22 | 12, 12, 12, 12, 12, 12, 12, 12, // char 88 - 95 23 | 12, 27, 12, 12, 12, 12, 12, 12, // char 96 - 103 24 | 12, 12, 12, 12, 12, 42, 12, 12, // char 104 - 111 25 | 29, 12, 12, 12, 12, 12, 12, 12, // char 112 - 119 26 | 12, 12, 12, 12, 7, 12, 12, 12 // char 120 - 127 27 | }; 28 | 29 | PROGMEM const unsigned char chr_f64_20[] = 30 | { 31 | 0x7F, 0x7F, 0x7F, 0x7F, 0x3F 32 | }; 33 | 34 | PROGMEM const unsigned char chr_f64_2D[] = 35 | { 36 | 0x7F, 0x7F, 0x45, 0x8A, 0x05, 0x8A, 0x05, 0x8A, 37 | 0x05, 0x8A, 0x7F, 0x7F, 0x7F, 0x2B 38 | }; 39 | 40 | PROGMEM const unsigned char chr_f64_2E[] = 41 | { 42 | 0x7F, 0x7F, 0x7F, 0x55, 0x84, 0x09, 0x84, 0x09, 43 | 0x84, 0x09, 0x84, 0x09, 0x84, 0x7F, 0x38 44 | }; 45 | 46 | PROGMEM const unsigned char chr_f64_30[] = 47 | { 48 | 0x23, 0x87, 0x0F, 0x8D, 0x0B, 0x8F, 0x09, 0x91, 49 | 0x07, 0x86, 0x05, 0x86, 0x06, 0x84, 0x09, 0x84, 50 | 0x06, 0x83, 0x0B, 0x83, 0x05, 0x84, 0x0B, 0x84, 51 | 0x04, 0x83, 0x0D, 0x83, 0x04, 0x83, 0x0D, 0x83, 52 | 0x04, 0x83, 0x0D, 0x83, 0x03, 0x83, 0x0F, 0x83, 53 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 54 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 55 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 56 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 57 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 58 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 59 | 0x02, 0x83, 0x0F, 0x83, 0x03, 0x83, 0x0D, 0x83, 60 | 0x04, 0x83, 0x0D, 0x83, 0x04, 0x83, 0x0D, 0x83, 61 | 0x04, 0x84, 0x0B, 0x84, 0x05, 0x83, 0x0B, 0x83, 62 | 0x06, 0x84, 0x09, 0x84, 0x06, 0x86, 0x05, 0x86, 63 | 0x07, 0x91, 0x09, 0x8F, 0x0B, 0x8D, 0x0F, 0x87, 64 | 0x7F, 0x7F, 0x32 65 | }; 66 | 67 | PROGMEM const unsigned char chr_f64_31[] = 68 | { 69 | 0x29, 0x82, 0x17, 0x82, 0x16, 0x83, 0x16, 0x83, 70 | 0x15, 0x84, 0x14, 0x85, 0x12, 0x87, 0x0D, 0x8C, 71 | 0x0D, 0x8C, 0x0D, 0x87, 0x00, 0x83, 0x0D, 0x84, 72 | 0x03, 0x83, 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 73 | 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 74 | 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 75 | 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 76 | 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 77 | 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 78 | 0x16, 0x83, 0x7F, 0x7F, 0x4C 79 | }; 80 | 81 | PROGMEM const unsigned char chr_f64_32[] = 82 | { 83 | 0x24, 0x87, 0x10, 0x8C, 0x0B, 0x8F, 0x09, 0x91, 84 | 0x08, 0x85, 0x05, 0x86, 0x06, 0x84, 0x09, 0x84, 85 | 0x06, 0x84, 0x0A, 0x83, 0x06, 0x83, 0x0B, 0x84, 86 | 0x04, 0x84, 0x0C, 0x83, 0x04, 0x83, 0x0D, 0x83, 87 | 0x04, 0x83, 0x0D, 0x83, 0x04, 0x83, 0x0D, 0x83, 88 | 0x16, 0x83, 0x15, 0x84, 0x15, 0x84, 0x14, 0x84, 89 | 0x14, 0x85, 0x13, 0x85, 0x12, 0x86, 0x11, 0x87, 90 | 0x10, 0x88, 0x10, 0x88, 0x0F, 0x88, 0x10, 0x87, 91 | 0x11, 0x86, 0x12, 0x85, 0x13, 0x85, 0x14, 0x84, 92 | 0x14, 0x84, 0x15, 0x83, 0x16, 0x83, 0x15, 0x96, 93 | 0x03, 0x96, 0x03, 0x96, 0x03, 0x96, 0x7F, 0x7F, 94 | 0x45 95 | }; 96 | 97 | PROGMEM const unsigned char chr_f64_33[] = 98 | { 99 | 0x23, 0x87, 0x0F, 0x8D, 0x0B, 0x90, 0x08, 0x91, 100 | 0x07, 0x86, 0x05, 0x86, 0x06, 0x84, 0x09, 0x84, 101 | 0x05, 0x84, 0x0B, 0x84, 0x04, 0x84, 0x0B, 0x84, 102 | 0x04, 0x83, 0x0D, 0x83, 0x04, 0x83, 0x0D, 0x83, 103 | 0x04, 0x83, 0x0D, 0x83, 0x15, 0x84, 0x15, 0x84, 104 | 0x14, 0x84, 0x14, 0x85, 0x0D, 0x8B, 0x0E, 0x89, 105 | 0x10, 0x8B, 0x0E, 0x8C, 0x14, 0x86, 0x15, 0x84, 106 | 0x16, 0x84, 0x15, 0x84, 0x02, 0x83, 0x0F, 0x83, 107 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 108 | 0x02, 0x84, 0x0D, 0x84, 0x02, 0x84, 0x0C, 0x85, 109 | 0x03, 0x84, 0x0B, 0x84, 0x04, 0x85, 0x09, 0x85, 110 | 0x05, 0x86, 0x05, 0x86, 0x07, 0x91, 0x09, 0x8F, 111 | 0x0B, 0x8D, 0x0F, 0x87, 0x7F, 0x7F, 0x4D 112 | }; 113 | 114 | PROGMEM const unsigned char chr_f64_34[] = 115 | { 116 | 0x45, 0x83, 0x15, 0x84, 0x14, 0x85, 0x13, 0x86, 117 | 0x13, 0x86, 0x12, 0x87, 0x11, 0x83, 0x00, 0x83, 118 | 0x11, 0x83, 0x00, 0x83, 0x10, 0x83, 0x01, 0x83, 119 | 0x0F, 0x83, 0x02, 0x83, 0x0E, 0x84, 0x02, 0x83, 120 | 0x0E, 0x83, 0x03, 0x83, 0x0D, 0x83, 0x04, 0x83, 121 | 0x0C, 0x83, 0x05, 0x83, 0x0B, 0x84, 0x05, 0x83, 122 | 0x0B, 0x83, 0x06, 0x83, 0x0A, 0x83, 0x07, 0x83, 123 | 0x09, 0x84, 0x07, 0x83, 0x09, 0x83, 0x08, 0x83, 124 | 0x08, 0x83, 0x09, 0x83, 0x07, 0x83, 0x0A, 0x83, 125 | 0x07, 0x97, 0x02, 0x97, 0x02, 0x97, 0x02, 0x97, 126 | 0x11, 0x83, 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 127 | 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 128 | 0x16, 0x83, 0x7F, 0x7F, 0x4A 129 | }; 130 | 131 | PROGMEM const unsigned char chr_f64_35[] = 132 | { 133 | 0x3A, 0x91, 0x08, 0x91, 0x08, 0x91, 0x08, 0x91, 134 | 0x08, 0x82, 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 135 | 0x16, 0x82, 0x17, 0x82, 0x17, 0x82, 0x16, 0x83, 136 | 0x02, 0x87, 0x0B, 0x83, 0x00, 0x8B, 0x09, 0x91, 137 | 0x08, 0x92, 0x07, 0x86, 0x05, 0x86, 0x06, 0x84, 138 | 0x09, 0x85, 0x05, 0x83, 0x0B, 0x84, 0x16, 0x83, 139 | 0x16, 0x84, 0x16, 0x83, 0x16, 0x83, 0x16, 0x83, 140 | 0x16, 0x83, 0x16, 0x83, 0x03, 0x83, 0x0E, 0x83, 141 | 0x03, 0x83, 0x0D, 0x84, 0x03, 0x83, 0x0D, 0x83, 142 | 0x04, 0x84, 0x0B, 0x84, 0x05, 0x84, 0x09, 0x85, 143 | 0x05, 0x86, 0x05, 0x86, 0x07, 0x91, 0x09, 0x8F, 144 | 0x0B, 0x8D, 0x0F, 0x87, 0x7F, 0x7F, 0x32 145 | }; 146 | 147 | PROGMEM const unsigned char chr_f64_36[] = 148 | { 149 | 0x24, 0x86, 0x11, 0x8B, 0x0C, 0x8E, 0x0A, 0x90, 150 | 0x08, 0x86, 0x05, 0x85, 0x06, 0x85, 0x09, 0x84, 151 | 0x05, 0x84, 0x0B, 0x83, 0x05, 0x83, 0x0C, 0x84, 152 | 0x03, 0x84, 0x0D, 0x83, 0x03, 0x83, 0x0E, 0x83, 153 | 0x03, 0x83, 0x16, 0x83, 0x15, 0x83, 0x16, 0x83, 154 | 0x04, 0x86, 0x0A, 0x83, 0x02, 0x8B, 0x07, 0x83, 155 | 0x00, 0x8E, 0x06, 0x94, 0x05, 0x88, 0x05, 0x86, 156 | 0x04, 0x86, 0x09, 0x84, 0x04, 0x85, 0x0B, 0x84, 157 | 0x03, 0x84, 0x0D, 0x83, 0x03, 0x84, 0x0D, 0x84, 158 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 159 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 160 | 0x02, 0x83, 0x0F, 0x83, 0x03, 0x83, 0x0D, 0x84, 161 | 0x03, 0x83, 0x0D, 0x83, 0x04, 0x84, 0x0B, 0x84, 162 | 0x05, 0x84, 0x09, 0x85, 0x05, 0x86, 0x05, 0x86, 163 | 0x07, 0x91, 0x09, 0x8F, 0x0C, 0x8C, 0x0F, 0x88, 164 | 0x7F, 0x7F, 0x31 165 | }; 166 | 167 | PROGMEM const unsigned char chr_f64_37[] = 168 | { 169 | 0x37, 0x96, 0x03, 0x96, 0x03, 0x96, 0x03, 0x96, 170 | 0x16, 0x83, 0x15, 0x83, 0x15, 0x83, 0x15, 0x83, 171 | 0x15, 0x84, 0x14, 0x84, 0x14, 0x84, 0x15, 0x83, 172 | 0x15, 0x84, 0x14, 0x84, 0x15, 0x84, 0x14, 0x84, 173 | 0x15, 0x83, 0x15, 0x84, 0x15, 0x83, 0x15, 0x84, 174 | 0x15, 0x84, 0x15, 0x83, 0x15, 0x84, 0x15, 0x83, 175 | 0x16, 0x83, 0x15, 0x84, 0x15, 0x83, 0x16, 0x83, 176 | 0x16, 0x83, 0x16, 0x83, 0x15, 0x84, 0x15, 0x83, 177 | 0x16, 0x83, 0x16, 0x83, 0x7F, 0x7F, 0x53 178 | }; 179 | 180 | PROGMEM const unsigned char chr_f64_38[] = 181 | { 182 | 0x24, 0x85, 0x11, 0x8B, 0x0C, 0x8F, 0x09, 0x91, 183 | 0x07, 0x86, 0x05, 0x86, 0x06, 0x84, 0x09, 0x84, 184 | 0x05, 0x84, 0x0B, 0x84, 0x04, 0x84, 0x0B, 0x84, 185 | 0x04, 0x83, 0x0D, 0x83, 0x04, 0x83, 0x0D, 0x83, 186 | 0x04, 0x83, 0x0D, 0x83, 0x04, 0x84, 0x0B, 0x84, 187 | 0x05, 0x83, 0x0B, 0x83, 0x06, 0x84, 0x09, 0x84, 188 | 0x07, 0x85, 0x05, 0x85, 0x09, 0x8F, 0x0B, 0x8D, 189 | 0x0B, 0x8F, 0x09, 0x91, 0x07, 0x85, 0x07, 0x85, 190 | 0x05, 0x84, 0x0B, 0x84, 0x04, 0x83, 0x0D, 0x83, 191 | 0x03, 0x84, 0x0D, 0x84, 0x02, 0x83, 0x0F, 0x83, 192 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 193 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 194 | 0x02, 0x84, 0x0D, 0x84, 0x02, 0x84, 0x0D, 0x84, 195 | 0x03, 0x84, 0x0B, 0x84, 0x04, 0x86, 0x07, 0x86, 196 | 0x05, 0x93, 0x07, 0x91, 0x09, 0x8F, 0x0D, 0x89, 197 | 0x7F, 0x7F, 0x31 198 | }; 199 | 200 | PROGMEM const unsigned char chr_f64_39[] = 201 | { 202 | 0x22, 0x88, 0x0F, 0x8C, 0x0C, 0x8F, 0x09, 0x91, 203 | 0x07, 0x86, 0x05, 0x86, 0x05, 0x85, 0x09, 0x84, 204 | 0x05, 0x84, 0x0B, 0x84, 0x04, 0x83, 0x0D, 0x83, 205 | 0x03, 0x84, 0x0D, 0x83, 0x03, 0x83, 0x0F, 0x83, 206 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 207 | 0x02, 0x83, 0x0F, 0x83, 0x02, 0x83, 0x0F, 0x83, 208 | 0x02, 0x84, 0x0D, 0x84, 0x03, 0x83, 0x0D, 0x84, 209 | 0x03, 0x84, 0x0B, 0x85, 0x04, 0x84, 0x09, 0x86, 210 | 0x04, 0x86, 0x05, 0x88, 0x05, 0x94, 0x06, 0x8E, 211 | 0x00, 0x83, 0x07, 0x8B, 0x02, 0x83, 0x0A, 0x86, 212 | 0x04, 0x83, 0x16, 0x83, 0x15, 0x83, 0x16, 0x83, 213 | 0x03, 0x83, 0x0E, 0x83, 0x03, 0x83, 0x0D, 0x84, 214 | 0x03, 0x84, 0x0C, 0x83, 0x05, 0x83, 0x0B, 0x84, 215 | 0x05, 0x84, 0x09, 0x85, 0x06, 0x85, 0x05, 0x86, 216 | 0x08, 0x90, 0x0A, 0x8E, 0x0C, 0x8B, 0x11, 0x86, 217 | 0x7F, 0x7F, 0x33 218 | }; 219 | 220 | PROGMEM const unsigned char chr_f64_3A[] = 221 | { 222 | 0x7F, 0x1A, 0x84, 0x09, 0x84, 0x09, 0x84, 0x09, 223 | 0x84, 0x09, 0x84, 0x7F, 0x3D, 0x84, 0x09, 0x84, 224 | 0x09, 0x84, 0x09, 0x84, 0x09, 0x84, 0x7F, 0x74 225 | }; 226 | 227 | PROGMEM const unsigned char chr_f64_61[] = 228 | { 229 | 0x7F, 0x7B, 0x88, 0x0F, 0x8D, 0x0A, 0x90, 0x09, 230 | 0x91, 0x07, 0x85, 0x06, 0x85, 0x06, 0x84, 0x0A, 231 | 0x84, 0x05, 0x83, 0x0C, 0x83, 0x05, 0x83, 0x0C, 232 | 0x83, 0x05, 0x83, 0x0C, 0x83, 0x16, 0x83, 0x15, 233 | 0x84, 0x0E, 0x8B, 0x09, 0x90, 0x07, 0x92, 0x06, 234 | 0x8D, 0x01, 0x83, 0x05, 0x88, 0x07, 0x83, 0x05, 235 | 0x84, 0x0B, 0x83, 0x04, 0x84, 0x0C, 0x83, 0x04, 236 | 0x83, 0x0D, 0x83, 0x04, 0x83, 0x0D, 0x83, 0x04, 237 | 0x83, 0x0C, 0x84, 0x04, 0x83, 0x0B, 0x85, 0x04, 238 | 0x84, 0x09, 0x86, 0x05, 0x84, 0x06, 0x8A, 0x03, 239 | 0x8F, 0x01, 0x84, 0x04, 0x8D, 0x02, 0x84, 0x05, 240 | 0x8A, 0x05, 0x83, 0x07, 0x86, 0x7F, 0x7F, 0x35 241 | }; 242 | 243 | PROGMEM const unsigned char chr_f64_6D[] = 244 | { 245 | 0x7F, 0x7F, 0x7F, 0x05, 0x86, 0x07, 0x86, 0x0A, 246 | 0x83, 0x02, 0x89, 0x04, 0x8A, 0x08, 0x83, 0x00, 247 | 0x8C, 0x02, 0x8C, 0x07, 0x83, 0x00, 0x8D, 0x00, 248 | 0x8E, 0x06, 0x87, 0x05, 0x89, 0x05, 0x84, 0x06, 249 | 0x85, 0x08, 0x86, 0x08, 0x84, 0x05, 0x84, 0x0A, 250 | 0x84, 0x0A, 0x83, 0x05, 0x84, 0x0A, 0x84, 0x0A, 251 | 0x83, 0x05, 0x83, 0x0B, 0x83, 0x0B, 0x83, 0x05, 252 | 0x83, 0x0B, 0x83, 0x0B, 0x83, 0x05, 0x83, 0x0B, 253 | 0x83, 0x0B, 0x83, 0x05, 0x83, 0x0B, 0x83, 0x0B, 254 | 0x83, 0x05, 0x83, 0x0B, 0x83, 0x0B, 0x83, 0x05, 255 | 0x83, 0x0B, 0x83, 0x0B, 0x83, 0x05, 0x83, 0x0B, 256 | 0x83, 0x0B, 0x83, 0x05, 0x83, 0x0B, 0x83, 0x0B, 257 | 0x83, 0x05, 0x83, 0x0B, 0x83, 0x0B, 0x83, 0x05, 258 | 0x83, 0x0B, 0x83, 0x0B, 0x83, 0x05, 0x83, 0x0B, 259 | 0x83, 0x0B, 0x83, 0x05, 0x83, 0x0B, 0x83, 0x0B, 260 | 0x83, 0x05, 0x83, 0x0B, 0x83, 0x0B, 0x83, 0x05, 261 | 0x83, 0x0B, 0x83, 0x0B, 0x83, 0x05, 0x83, 0x0B, 262 | 0x83, 0x0B, 0x83, 0x05, 0x83, 0x0B, 0x83, 0x0B, 263 | 0x83, 0x05, 0x83, 0x0B, 0x83, 0x0B, 0x83, 0x05, 264 | 0x83, 0x0B, 0x83, 0x0B, 0x83, 0x05, 0x83, 0x0B, 265 | 0x83, 0x0B, 0x83, 0x7F, 0x7F, 0x7F, 0x7A 266 | }; 267 | 268 | PROGMEM const unsigned char chr_f64_70[] = 269 | { 270 | 0x7F, 0x7F, 0x10, 0x86, 0x0C, 0x83, 0x02, 0x8B, 271 | 0x09, 0x83, 0x01, 0x8D, 0x08, 0x83, 0x00, 0x8F, 272 | 0x07, 0x88, 0x05, 0x86, 0x06, 0x86, 0x09, 0x84, 273 | 0x06, 0x85, 0x0B, 0x84, 0x05, 0x84, 0x0D, 0x83, 274 | 0x05, 0x84, 0x0D, 0x83, 0x05, 0x84, 0x0D, 0x84, 275 | 0x04, 0x83, 0x0F, 0x83, 0x04, 0x83, 0x0F, 0x83, 276 | 0x04, 0x83, 0x0F, 0x83, 0x04, 0x83, 0x0F, 0x83, 277 | 0x04, 0x83, 0x0F, 0x83, 0x04, 0x83, 0x0F, 0x83, 278 | 0x04, 0x83, 0x0F, 0x83, 0x04, 0x83, 0x0F, 0x83, 279 | 0x04, 0x83, 0x0E, 0x84, 0x04, 0x84, 0x0D, 0x83, 280 | 0x05, 0x84, 0x0C, 0x84, 0x05, 0x85, 0x0B, 0x84, 281 | 0x05, 0x86, 0x09, 0x84, 0x06, 0x88, 0x05, 0x86, 282 | 0x06, 0x83, 0x00, 0x8F, 0x07, 0x83, 0x01, 0x8D, 283 | 0x08, 0x83, 0x02, 0x8B, 0x09, 0x83, 0x04, 0x86, 284 | 0x0C, 0x83, 0x18, 0x83, 0x18, 0x83, 0x18, 0x83, 285 | 0x18, 0x83, 0x18, 0x83, 0x18, 0x83, 0x18, 0x83, 286 | 0x18, 0x83, 0x18, 0x83, 0x32 287 | }; 288 | PROGMEM const unsigned char* const chrtbl_f64[96] = // character pointer table 289 | { 290 | chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, 291 | chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_2D, chr_f64_2E, chr_f64_20, 292 | chr_f64_30, chr_f64_31, chr_f64_32, chr_f64_33, chr_f64_34, chr_f64_35, chr_f64_36, chr_f64_37, 293 | chr_f64_38, chr_f64_39, chr_f64_3A, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, 294 | chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, 295 | chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, 296 | chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, 297 | chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, 298 | chr_f64_20, chr_f64_61, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, 299 | chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_6D, chr_f64_20, chr_f64_20, 300 | chr_f64_70, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, 301 | chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20, chr_f64_20 302 | }; 303 | -------------------------------------------------------------------------------- /Fonts/Font64rle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f64 96 4 | #define chr_hgt_f64 48 5 | #define data_size_f64 8 6 | #define firstchr_f64 32 7 | 8 | extern const unsigned char widtbl_f64[96]; 9 | extern const unsigned char* const chrtbl_f64[96]; 10 | -------------------------------------------------------------------------------- /Fonts/Font72rle.c: -------------------------------------------------------------------------------- 1 | // Font size 8 2 | // 3 | // This font has been 8 bit Run Length Encoded to save FLASH space 4 | // 5 | // It is a Arial 75 pixel height font intended to display large numbers 6 | // This font only contains characters [space] 0 1 2 3 4 5 6 7 8 9 0 : - . 7 | // All other characters print as a space 8 | 9 | #include 10 | 11 | 12 | PROGMEM const unsigned char widtbl_f72[96] = // character width table 13 | { 14 | 29, 29, 29, 29, 29, 29, 29, 29, // char 32 - 39 15 | 29, 29, 29, 29, 29, 29, 29, 29, // char 40 - 47 16 | 55, 55, 55, 55, 55, 55, 55, 55, // char 48 - 55 17 | 55, 55, 29, 29, 29, 29, 29, 29, // char 56 - 63 18 | 29, 29, 29, 29, 29, 29, 29, 29, // char 64 - 71 19 | 29, 29, 29, 29, 29, 29, 29, 29, // char 72 - 79 20 | 29, 29, 29, 29, 29, 29, 29, 29, // char 80 - 87 21 | 29, 29, 29, 29, 29, 29, 29, 29, // char 88 - 95 22 | 29, 29, 29, 29, 29, 29, 29, 29, // char 96 - 103 23 | 29, 29, 29, 29, 29, 29, 29, 29, // char 104 - 111 24 | 29, 29, 29, 29, 29, 29, 29, 29, // char 112 - 119 25 | 29, 29, 29, 29, 29, 29, 29, 29 // char 120 - 127 26 | }; 27 | 28 | // Row format, MSB left 29 | 30 | PROGMEM const unsigned char chr_f72_20[] = 31 | { 32 | 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 33 | 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 34 | 0x7E 35 | }; 36 | 37 | PROGMEM const unsigned char chr_f72_2D[] = 38 | { 39 | 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 40 | 0x36, 0x91, 0x0A, 0x91, 0x0A, 0x91, 0x0A, 0x91, 41 | 0x0A, 0x91, 0x0A, 0x91, 0x0A, 0x91, 0x7F, 0x7F, 42 | 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x07 43 | }; 44 | 45 | PROGMEM const unsigned char chr_f72_2E[] = 46 | { 47 | 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 48 | 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x48, 0x88, 49 | 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 50 | 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 51 | 0x44 52 | }; 53 | 54 | PROGMEM const unsigned char chr_f72_30[] = 55 | { 56 | 0x7F, 0x70, 0x8A, 0x28, 0x90, 0x23, 0x94, 0x1F, 57 | 0x98, 0x1C, 0x9A, 0x1A, 0x9C, 0x18, 0x9E, 0x16, 58 | 0xA0, 0x15, 0x8C, 0x06, 0x8C, 0x14, 0x8B, 0x0A, 59 | 0x8B, 0x12, 0x8A, 0x0E, 0x89, 0x12, 0x89, 0x10, 60 | 0x89, 0x11, 0x88, 0x12, 0x88, 0x10, 0x89, 0x12, 61 | 0x89, 0x0F, 0x88, 0x14, 0x88, 0x0E, 0x89, 0x14, 62 | 0x88, 0x0E, 0x88, 0x16, 0x88, 0x0D, 0x88, 0x16, 63 | 0x88, 0x0D, 0x88, 0x16, 0x88, 0x0C, 0x88, 0x18, 64 | 0x88, 0x0B, 0x88, 0x18, 0x88, 0x0B, 0x88, 0x18, 65 | 0x88, 0x0B, 0x88, 0x18, 0x88, 0x0B, 0x88, 0x18, 66 | 0x88, 0x0B, 0x88, 0x18, 0x88, 0x0A, 0x88, 0x1A, 67 | 0x88, 0x09, 0x88, 0x1A, 0x88, 0x09, 0x88, 0x1A, 68 | 0x88, 0x09, 0x88, 0x1A, 0x88, 0x09, 0x88, 0x1A, 69 | 0x88, 0x09, 0x88, 0x1A, 0x88, 0x09, 0x88, 0x1A, 70 | 0x88, 0x09, 0x88, 0x1A, 0x88, 0x09, 0x88, 0x1A, 71 | 0x88, 0x09, 0x88, 0x1A, 0x88, 0x09, 0x88, 0x1A, 72 | 0x88, 0x09, 0x88, 0x1A, 0x88, 0x09, 0x88, 0x1A, 73 | 0x88, 0x09, 0x88, 0x1A, 0x88, 0x09, 0x88, 0x1A, 74 | 0x88, 0x09, 0x88, 0x1A, 0x88, 0x09, 0x88, 0x1A, 75 | 0x88, 0x09, 0x88, 0x1A, 0x88, 0x09, 0x88, 0x1A, 76 | 0x88, 0x09, 0x88, 0x1A, 0x88, 0x0A, 0x88, 0x18, 77 | 0x88, 0x0B, 0x88, 0x18, 0x88, 0x0B, 0x88, 0x18, 78 | 0x88, 0x0B, 0x88, 0x18, 0x88, 0x0B, 0x88, 0x18, 79 | 0x88, 0x0B, 0x88, 0x18, 0x88, 0x0C, 0x88, 0x16, 80 | 0x88, 0x0D, 0x88, 0x16, 0x88, 0x0D, 0x88, 0x16, 81 | 0x88, 0x0D, 0x89, 0x14, 0x89, 0x0E, 0x88, 0x14, 82 | 0x88, 0x0F, 0x89, 0x12, 0x89, 0x10, 0x88, 0x12, 83 | 0x88, 0x11, 0x89, 0x10, 0x89, 0x11, 0x8A, 0x0E, 84 | 0x8A, 0x12, 0x8B, 0x0A, 0x8B, 0x14, 0x8C, 0x06, 85 | 0x8C, 0x15, 0xA0, 0x16, 0x9E, 0x18, 0x9C, 0x1A, 86 | 0x9A, 0x1C, 0x98, 0x1F, 0x94, 0x23, 0x90, 0x28, 87 | 0x8A, 0x4D 88 | }; 89 | 90 | PROGMEM const unsigned char chr_f72_31[] = 91 | { 92 | 0x7F, 0x78, 0x85, 0x2F, 0x86, 0x2F, 0x86, 0x2E, 93 | 0x87, 0x2D, 0x88, 0x2D, 0x88, 0x2C, 0x89, 0x2B, 94 | 0x8A, 0x2A, 0x8B, 0x29, 0x8C, 0x27, 0x8E, 0x26, 95 | 0x8F, 0x25, 0x90, 0x24, 0x91, 0x22, 0x93, 0x20, 96 | 0x95, 0x1E, 0x8D, 0x00, 0x88, 0x1D, 0x8C, 0x02, 97 | 0x88, 0x1D, 0x8B, 0x03, 0x88, 0x1D, 0x8A, 0x04, 98 | 0x88, 0x1D, 0x88, 0x06, 0x88, 0x1D, 0x87, 0x07, 99 | 0x88, 0x1D, 0x85, 0x09, 0x88, 0x1D, 0x83, 0x0B, 100 | 0x88, 0x1D, 0x81, 0x0D, 0x88, 0x2D, 0x88, 0x2D, 101 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 102 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 103 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 104 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 105 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 106 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 107 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 108 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 109 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 110 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 111 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x7F, 0x1 112 | }; 113 | 114 | PROGMEM const unsigned char chr_f72_32[] = 115 | { 116 | 0x7F, 0x6F, 0x8A, 0x27, 0x92, 0x21, 0x96, 0x1D, 117 | 0x9A, 0x1A, 0x9C, 0x18, 0x9E, 0x16, 0xA0, 0x14, 118 | 0xA2, 0x12, 0x8E, 0x07, 0x8D, 0x11, 0x8B, 0x0C, 119 | 0x8C, 0x0F, 0x8A, 0x10, 0x8A, 0x0F, 0x89, 0x12, 120 | 0x8A, 0x0D, 0x89, 0x14, 0x89, 0x0D, 0x89, 0x14, 121 | 0x89, 0x0D, 0x88, 0x16, 0x89, 0x0C, 0x88, 0x16, 122 | 0x89, 0x0B, 0x88, 0x18, 0x88, 0x0B, 0x88, 0x18, 123 | 0x88, 0x0B, 0x88, 0x18, 0x88, 0x0F, 0x84, 0x18, 124 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2C, 125 | 0x89, 0x2C, 0x88, 0x2C, 0x89, 0x2C, 0x89, 0x2B, 126 | 0x89, 0x2C, 0x89, 0x2B, 0x89, 0x2B, 0x8A, 0x2A, 127 | 0x8A, 0x2A, 0x8B, 0x29, 0x8B, 0x29, 0x8B, 0x29, 128 | 0x8B, 0x29, 0x8B, 0x29, 0x8C, 0x28, 0x8C, 0x28, 129 | 0x8C, 0x28, 0x8C, 0x28, 0x8C, 0x27, 0x8C, 0x28, 130 | 0x8C, 0x28, 0x8C, 0x28, 0x8C, 0x28, 0x8C, 0x27, 131 | 0x8D, 0x27, 0x8D, 0x27, 0x8C, 0x28, 0x8C, 0x28, 132 | 0x8C, 0x29, 0x8B, 0x29, 0x8B, 0x29, 0x8A, 0x2A, 133 | 0x8A, 0x2B, 0x89, 0x2B, 0x8A, 0x2B, 0x89, 0x2B, 134 | 0x89, 0x2C, 0xAA, 0x0A, 0xAB, 0x0A, 0xAB, 0x0A, 135 | 0xAB, 0x09, 0xAC, 0x09, 0xAC, 0x09, 0xAC, 0x09, 136 | 0xAC, 0x09, 0xAC, 0x74 137 | }; 138 | 139 | PROGMEM const unsigned char chr_f72_33[] = 140 | { 141 | 0x7F, 0x6F, 0x89, 0x29, 0x90, 0x23, 0x94, 0x1F, 142 | 0x97, 0x1D, 0x9A, 0x1A, 0x9C, 0x18, 0x9E, 0x16, 143 | 0xA0, 0x15, 0x8C, 0x06, 0x8C, 0x14, 0x8B, 0x0A, 144 | 0x8B, 0x12, 0x8A, 0x0E, 0x89, 0x12, 0x89, 0x10, 145 | 0x89, 0x11, 0x88, 0x12, 0x88, 0x10, 0x89, 0x12, 146 | 0x89, 0x0F, 0x88, 0x14, 0x88, 0x0F, 0x88, 0x14, 147 | 0x88, 0x0E, 0x89, 0x14, 0x88, 0x0E, 0x88, 0x15, 148 | 0x88, 0x12, 0x84, 0x15, 0x88, 0x2D, 0x88, 0x2D, 149 | 0x88, 0x2C, 0x88, 0x2D, 0x88, 0x2C, 0x89, 0x2B, 150 | 0x89, 0x2B, 0x89, 0x2A, 0x8B, 0x28, 0x8C, 0x23, 151 | 0x91, 0x24, 0x8F, 0x26, 0x8D, 0x28, 0x8F, 0x25, 152 | 0x92, 0x23, 0x94, 0x21, 0x95, 0x20, 0x81, 0x07, 153 | 0x8C, 0x2B, 0x8B, 0x2C, 0x8A, 0x2C, 0x89, 0x2D, 154 | 0x89, 0x2D, 0x89, 0x2C, 0x89, 0x2D, 0x88, 0x2D, 155 | 0x89, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 156 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x0D, 0x84, 0x1A, 157 | 0x88, 0x09, 0x88, 0x1A, 0x88, 0x09, 0x89, 0x18, 158 | 0x89, 0x09, 0x89, 0x18, 0x88, 0x0B, 0x88, 0x18, 159 | 0x88, 0x0B, 0x89, 0x16, 0x89, 0x0B, 0x89, 0x15, 160 | 0x89, 0x0D, 0x89, 0x14, 0x89, 0x0D, 0x8A, 0x12, 161 | 0x89, 0x0F, 0x8A, 0x10, 0x8A, 0x0F, 0x8B, 0x0D, 162 | 0x8B, 0x11, 0x8D, 0x07, 0x8D, 0x13, 0xA2, 0x14, 163 | 0xA0, 0x16, 0x9D, 0x19, 0x9B, 0x1B, 0x99, 0x1E, 164 | 0x95, 0x22, 0x91, 0x28, 0x89, 0x4E 165 | }; 166 | 167 | PROGMEM const unsigned char chr_f72_34[] = 168 | { 169 | 0x7F, 0x7F, 0x34, 0x86, 0x2E, 0x87, 0x2D, 0x88, 170 | 0x2C, 0x89, 0x2C, 0x89, 0x2B, 0x8A, 0x2A, 0x8B, 171 | 0x29, 0x8C, 0x28, 0x8D, 0x28, 0x8D, 0x27, 0x8E, 172 | 0x26, 0x8F, 0x25, 0x90, 0x25, 0x90, 0x24, 0x91, 173 | 0x23, 0x92, 0x22, 0x93, 0x22, 0x93, 0x21, 0x8A, 174 | 0x00, 0x88, 0x20, 0x8A, 0x01, 0x88, 0x1F, 0x8A, 175 | 0x02, 0x88, 0x1E, 0x8B, 0x02, 0x88, 0x1E, 0x8A, 176 | 0x03, 0x88, 0x1D, 0x8A, 0x04, 0x88, 0x1C, 0x8A, 177 | 0x05, 0x88, 0x1B, 0x8A, 0x06, 0x88, 0x1B, 0x8A, 178 | 0x06, 0x88, 0x1A, 0x8A, 0x07, 0x88, 0x19, 0x8A, 179 | 0x08, 0x88, 0x18, 0x8A, 0x09, 0x88, 0x18, 0x8A, 180 | 0x09, 0x88, 0x17, 0x8A, 0x0A, 0x88, 0x16, 0x8A, 181 | 0x0B, 0x88, 0x15, 0x8A, 0x0C, 0x88, 0x15, 0x8A, 182 | 0x0C, 0x88, 0x14, 0x8A, 0x0D, 0x88, 0x13, 0x8A, 183 | 0x0E, 0x88, 0x12, 0x8A, 0x0F, 0x88, 0x11, 0x8B, 184 | 0x0F, 0x88, 0x11, 0x8A, 0x10, 0x88, 0x10, 0x8A, 185 | 0x11, 0x88, 0x0F, 0x8A, 0x12, 0x88, 0x0E, 0x8A, 186 | 0x13, 0x88, 0x0E, 0xAF, 0x06, 0xAF, 0x06, 0xAF, 187 | 0x06, 0xAF, 0x06, 0xAF, 0x06, 0xAF, 0x06, 0xAF, 188 | 0x06, 0xAF, 0x06, 0xAF, 0x25, 0x88, 0x2D, 0x88, 189 | 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 190 | 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 191 | 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 192 | 0x2D, 0x88, 0x2D, 0x88, 0x7B 193 | }; 194 | 195 | PROGMEM const unsigned char chr_f72_35[] = 196 | { 197 | 0x7F, 0x7F, 0x1E, 0xA0, 0x15, 0xA0, 0x14, 0xA1, 198 | 0x14, 0xA1, 0x14, 0xA1, 0x14, 0xA1, 0x14, 0xA1, 199 | 0x13, 0xA2, 0x13, 0xA2, 0x13, 0x88, 0x2D, 0x88, 200 | 0x2D, 0x88, 0x2C, 0x89, 0x2C, 0x88, 0x2D, 0x88, 201 | 0x2D, 0x88, 0x2D, 0x88, 0x2C, 0x89, 0x2C, 0x88, 202 | 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2C, 0x89, 203 | 0x06, 0x88, 0x1C, 0x89, 0x03, 0x8E, 0x19, 0x88, 204 | 0x02, 0x92, 0x17, 0x88, 0x00, 0x96, 0x15, 0xA1, 205 | 0x13, 0xA3, 0x12, 0xA4, 0x11, 0xA5, 0x10, 0x8F, 206 | 0x07, 0x8E, 0x0F, 0x8C, 0x0D, 0x8C, 0x0D, 0x8B, 207 | 0x11, 0x8A, 0x0D, 0x8A, 0x13, 0x8A, 0x0C, 0x89, 208 | 0x15, 0x89, 0x10, 0x84, 0x17, 0x89, 0x2C, 0x89, 209 | 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x89, 0x2D, 0x88, 210 | 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 211 | 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 212 | 0x0D, 0x84, 0x1A, 0x88, 0x09, 0x88, 0x19, 0x88, 213 | 0x0A, 0x89, 0x18, 0x88, 0x0A, 0x89, 0x18, 0x88, 214 | 0x0B, 0x88, 0x17, 0x89, 0x0B, 0x89, 0x16, 0x88, 215 | 0x0C, 0x89, 0x15, 0x89, 0x0D, 0x89, 0x13, 0x89, 216 | 0x0E, 0x8A, 0x11, 0x8A, 0x0E, 0x8B, 0x0F, 0x8A, 217 | 0x10, 0x8B, 0x0D, 0x8A, 0x12, 0x8D, 0x07, 0x8D, 218 | 0x12, 0xA2, 0x14, 0xA0, 0x16, 0x9E, 0x19, 0x9B, 219 | 0x1B, 0x98, 0x1F, 0x95, 0x22, 0x90, 0x28, 0x8A, 220 | 0x4E 221 | }; 222 | 223 | PROGMEM const unsigned char chr_f72_36[] = 224 | { 225 | 0x7F, 0x72, 0x89, 0x28, 0x90, 0x23, 0x95, 0x1E, 226 | 0x98, 0x1C, 0x9A, 0x1A, 0x9C, 0x18, 0x9E, 0x16, 227 | 0xA0, 0x14, 0x8D, 0x06, 0x8D, 0x12, 0x8B, 0x0B, 228 | 0x8B, 0x12, 0x8A, 0x0E, 0x8A, 0x10, 0x89, 0x11, 229 | 0x89, 0x0F, 0x8A, 0x12, 0x89, 0x0E, 0x89, 0x13, 230 | 0x89, 0x0E, 0x88, 0x15, 0x88, 0x0D, 0x89, 0x15, 231 | 0x89, 0x0C, 0x88, 0x16, 0x89, 0x0B, 0x89, 0x17, 232 | 0x88, 0x0B, 0x88, 0x18, 0x84, 0x0F, 0x88, 0x2D, 233 | 0x87, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 234 | 0x88, 0x0A, 0x88, 0x19, 0x87, 0x08, 0x8E, 0x16, 235 | 0x87, 0x06, 0x92, 0x13, 0x88, 0x04, 0x96, 0x11, 236 | 0x88, 0x03, 0x98, 0x10, 0x88, 0x02, 0x9A, 0x0F, 237 | 0x88, 0x01, 0x9C, 0x0E, 0x88, 0x00, 0x9E, 0x0D, 238 | 0x92, 0x07, 0x8E, 0x0C, 0x90, 0x0C, 0x8C, 0x0B, 239 | 0x8E, 0x10, 0x8A, 0x0B, 0x8D, 0x12, 0x8A, 0x0A, 240 | 0x8C, 0x14, 0x89, 0x0A, 0x8B, 0x16, 0x89, 0x09, 241 | 0x8A, 0x17, 0x89, 0x09, 0x89, 0x19, 0x88, 0x09, 242 | 0x89, 0x19, 0x88, 0x09, 0x89, 0x19, 0x89, 0x08, 243 | 0x88, 0x1B, 0x88, 0x08, 0x88, 0x1B, 0x88, 0x08, 244 | 0x88, 0x1B, 0x88, 0x08, 0x88, 0x1B, 0x88, 0x09, 245 | 0x87, 0x1B, 0x88, 0x09, 0x87, 0x1B, 0x88, 0x09, 246 | 0x87, 0x1B, 0x88, 0x09, 0x87, 0x1B, 0x88, 0x09, 247 | 0x88, 0x1A, 0x88, 0x0A, 0x87, 0x19, 0x89, 0x0A, 248 | 0x87, 0x19, 0x88, 0x0B, 0x88, 0x18, 0x88, 0x0B, 249 | 0x88, 0x17, 0x89, 0x0C, 0x88, 0x16, 0x88, 0x0D, 250 | 0x88, 0x15, 0x89, 0x0E, 0x88, 0x14, 0x89, 0x0E, 251 | 0x89, 0x12, 0x89, 0x10, 0x89, 0x10, 0x8A, 0x10, 252 | 0x8B, 0x0C, 0x8B, 0x12, 0x8C, 0x07, 0x8D, 0x14, 253 | 0xA1, 0x15, 0x9F, 0x17, 0x9D, 0x19, 0x9B, 0x1C, 254 | 0x97, 0x1F, 0x95, 0x23, 0x8F, 0x29, 0x89, 0x4D 255 | }; 256 | 257 | PROGMEM const unsigned char chr_f72_37[] = 258 | { 259 | 0x7F, 0x7F, 0x17, 0xAB, 0x0A, 0xAB, 0x0A, 0xAB, 260 | 0x0A, 0xAB, 0x0A, 0xAB, 0x0A, 0xAB, 0x0A, 0xAB, 261 | 0x0A, 0xAB, 0x0A, 0xAA, 0x2E, 0x86, 0x2E, 0x86, 262 | 0x2E, 0x87, 0x2D, 0x87, 0x2D, 0x87, 0x2D, 0x87, 263 | 0x2E, 0x87, 0x2D, 0x87, 0x2D, 0x87, 0x2E, 0x87, 264 | 0x2D, 0x87, 0x2D, 0x88, 0x2D, 0x87, 0x2D, 0x87, 265 | 0x2D, 0x88, 0x2D, 0x87, 0x2D, 0x88, 0x2D, 0x87, 266 | 0x2D, 0x88, 0x2C, 0x88, 0x2D, 0x88, 0x2C, 0x88, 267 | 0x2D, 0x88, 0x2C, 0x88, 0x2D, 0x88, 0x2C, 0x88, 268 | 0x2D, 0x88, 0x2D, 0x88, 0x2C, 0x88, 0x2D, 0x88, 269 | 0x2C, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2C, 0x88, 270 | 0x2D, 0x88, 0x2D, 0x88, 0x2C, 0x88, 0x2D, 0x88, 271 | 0x2D, 0x88, 0x2C, 0x88, 0x2D, 0x88, 0x2D, 0x88, 272 | 0x2D, 0x88, 0x2C, 0x88, 0x2D, 0x88, 0x2D, 0x88, 273 | 0x2D, 0x88, 0x2C, 0x88, 0x2D, 0x88, 0x2D, 0x88, 274 | 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2C, 0x89, 275 | 0x2C, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 276 | 0x2D, 0x88, 0x7F, 0xC 277 | }; 278 | 279 | PROGMEM const unsigned char chr_f72_38[] = 280 | { 281 | 0x7F, 0x70, 0x89, 0x28, 0x91, 0x22, 0x95, 0x1E, 282 | 0x99, 0x1B, 0x9B, 0x19, 0x9D, 0x17, 0x9F, 0x15, 283 | 0xA1, 0x13, 0x8D, 0x07, 0x8C, 0x13, 0x8B, 0x0B, 284 | 0x8B, 0x11, 0x8A, 0x0F, 0x8A, 0x10, 0x89, 0x11, 285 | 0x89, 0x10, 0x88, 0x13, 0x88, 0x0F, 0x89, 0x13, 286 | 0x89, 0x0E, 0x88, 0x15, 0x88, 0x0E, 0x88, 0x15, 287 | 0x88, 0x0E, 0x88, 0x15, 0x88, 0x0E, 0x88, 0x15, 288 | 0x88, 0x0E, 0x88, 0x15, 0x88, 0x0E, 0x88, 0x15, 289 | 0x88, 0x0E, 0x88, 0x15, 0x88, 0x0F, 0x88, 0x13, 290 | 0x88, 0x10, 0x88, 0x13, 0x88, 0x10, 0x89, 0x11, 291 | 0x89, 0x11, 0x89, 0x0F, 0x89, 0x13, 0x89, 0x0D, 292 | 0x89, 0x15, 0x8B, 0x07, 0x8C, 0x16, 0x9D, 0x19, 293 | 0x9B, 0x1C, 0x97, 0x20, 0x93, 0x20, 0x96, 0x1D, 294 | 0x9A, 0x1A, 0x9D, 0x17, 0x9F, 0x15, 0x8C, 0x07, 295 | 0x8C, 0x13, 0x8A, 0x0C, 0x8B, 0x11, 0x8A, 0x0F, 296 | 0x8A, 0x0F, 0x8A, 0x11, 0x89, 0x0F, 0x89, 0x13, 297 | 0x89, 0x0D, 0x89, 0x15, 0x88, 0x0D, 0x89, 0x15, 298 | 0x89, 0x0C, 0x88, 0x17, 0x88, 0x0C, 0x88, 0x17, 299 | 0x88, 0x0B, 0x88, 0x19, 0x88, 0x0A, 0x88, 0x19, 300 | 0x88, 0x0A, 0x88, 0x19, 0x88, 0x0A, 0x88, 0x19, 301 | 0x88, 0x0A, 0x88, 0x19, 0x88, 0x0A, 0x88, 0x19, 302 | 0x88, 0x0A, 0x88, 0x19, 0x88, 0x0A, 0x88, 0x19, 303 | 0x88, 0x0A, 0x88, 0x19, 0x88, 0x0A, 0x89, 0x17, 304 | 0x89, 0x0B, 0x88, 0x17, 0x88, 0x0C, 0x89, 0x15, 305 | 0x89, 0x0C, 0x89, 0x15, 0x89, 0x0D, 0x89, 0x13, 306 | 0x89, 0x0E, 0x8A, 0x11, 0x8A, 0x0F, 0x8A, 0x0F, 307 | 0x8A, 0x10, 0x8C, 0x0C, 0x8B, 0x11, 0x8D, 0x07, 308 | 0x8D, 0x13, 0xA1, 0x15, 0x9F, 0x17, 0x9D, 0x19, 309 | 0x9B, 0x1B, 0x99, 0x1E, 0x95, 0x22, 0x91, 0x28, 310 | 0x89, 0x4E 311 | }; 312 | 313 | PROGMEM const unsigned char chr_f72_39[] = 314 | { 315 | 0x7F, 0x70, 0x88, 0x29, 0x90, 0x23, 0x94, 0x20, 316 | 0x97, 0x1C, 0x9A, 0x1A, 0x9C, 0x18, 0x9E, 0x16, 317 | 0xA0, 0x14, 0x8E, 0x07, 0x8B, 0x13, 0x8C, 0x0B, 318 | 0x8A, 0x11, 0x8B, 0x0F, 0x88, 0x11, 0x8A, 0x11, 319 | 0x88, 0x0F, 0x8A, 0x13, 0x88, 0x0E, 0x89, 0x14, 320 | 0x88, 0x0D, 0x89, 0x16, 0x87, 0x0D, 0x89, 0x17, 321 | 0x87, 0x0C, 0x88, 0x18, 0x87, 0x0C, 0x88, 0x18, 322 | 0x87, 0x0B, 0x89, 0x19, 0x87, 0x0A, 0x88, 0x1A, 323 | 0x87, 0x0A, 0x88, 0x1A, 0x87, 0x0A, 0x88, 0x1A, 324 | 0x87, 0x0A, 0x88, 0x1A, 0x87, 0x0A, 0x88, 0x1A, 325 | 0x87, 0x0A, 0x88, 0x1A, 0x88, 0x09, 0x88, 0x1A, 326 | 0x88, 0x09, 0x88, 0x1A, 0x88, 0x09, 0x88, 0x1A, 327 | 0x88, 0x09, 0x89, 0x18, 0x89, 0x0A, 0x88, 0x18, 328 | 0x89, 0x0A, 0x88, 0x18, 0x89, 0x0A, 0x89, 0x16, 329 | 0x8A, 0x0A, 0x89, 0x16, 0x8A, 0x0B, 0x89, 0x14, 330 | 0x8B, 0x0B, 0x8A, 0x12, 0x8C, 0x0C, 0x8A, 0x10, 331 | 0x8D, 0x0C, 0x8C, 0x0C, 0x8F, 0x0D, 0x8E, 0x07, 332 | 0x91, 0x0E, 0x9D, 0x00, 0x88, 0x0F, 0x9B, 0x01, 333 | 0x88, 0x10, 0x99, 0x02, 0x88, 0x11, 0x97, 0x03, 334 | 0x88, 0x12, 0x95, 0x04, 0x88, 0x13, 0x92, 0x06, 335 | 0x87, 0x16, 0x8E, 0x08, 0x87, 0x19, 0x88, 0x0A, 336 | 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 0x88, 0x2D, 337 | 0x87, 0x2D, 0x88, 0x10, 0x84, 0x17, 0x88, 0x0C, 338 | 0x88, 0x17, 0x88, 0x0C, 0x89, 0x15, 0x88, 0x0D, 339 | 0x89, 0x15, 0x88, 0x0E, 0x88, 0x14, 0x89, 0x0E, 340 | 0x89, 0x13, 0x88, 0x0F, 0x89, 0x12, 0x89, 0x10, 341 | 0x89, 0x10, 0x89, 0x11, 0x8A, 0x0E, 0x8A, 0x11, 342 | 0x8B, 0x0B, 0x8B, 0x13, 0x8C, 0x07, 0x8C, 0x15, 343 | 0x9F, 0x16, 0x9E, 0x18, 0x9C, 0x1A, 0x9A, 0x1D, 344 | 0x97, 0x1F, 0x94, 0x23, 0x90, 0x28, 0x89, 0x50 345 | }; 346 | 347 | PROGMEM const unsigned char chr_f72_3A[] = 348 | { 349 | 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x23, 0x88, 0x13, 350 | 0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 351 | 0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x7F, 352 | 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x33, 0x88, 353 | 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 354 | 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 0x13, 0x88, 355 | 0x44 356 | }; 357 | PROGMEM const unsigned char * const chrtbl_f72[96] = // character pointer table 358 | { 359 | chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, 360 | chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_2D, chr_f72_2E, chr_f72_20, 361 | chr_f72_30, chr_f72_31, chr_f72_32, chr_f72_33, chr_f72_34, chr_f72_35, chr_f72_36, chr_f72_37, 362 | chr_f72_38, chr_f72_39, chr_f72_3A, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, 363 | chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, 364 | chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, 365 | chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, 366 | chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, 367 | chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, 368 | chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, 369 | chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, 370 | chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20, chr_f72_20 371 | }; 372 | -------------------------------------------------------------------------------- /Fonts/Font72rle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f72 96 4 | #define chr_hgt_f72 75 5 | #define data_size_f72 8 6 | #define firstchr_f72 32 7 | 8 | extern const unsigned char widtbl_f72[96]; 9 | extern const unsigned char* const chrtbl_f72[96]; 10 | -------------------------------------------------------------------------------- /Fonts/Font7srle.c: -------------------------------------------------------------------------------- 1 | // Font size 7 2 | // 3 | // This font has been 8 bit Run Length Encoded to save FLASH space 4 | // 5 | // This is a 7 segment font intended to display numbers and time 6 | // This font only contains characters [space] 0 1 2 3 4 5 6 7 8 9 : . 7 | // All other characters print as a space 8 | 9 | #include 10 | 11 | 12 | PROGMEM const unsigned char widtbl_f7s[96] = // character width table 13 | { 14 | 12, 12, 12, 12, 12, 12, 12, 12, // char 32 - 39 15 | 12, 12, 12, 12, 12, 12, 12, 12, // char 40 - 47 16 | 32, 32, 32, 32, 32, 32, 32, 32, // char 48 - 55 17 | 32, 32, 12, 12, 12, 12, 12, 12, // char 56 - 63 18 | 12, 12, 12, 12, 12, 12, 12, 12, // char 64 - 71 19 | 12, 12, 12, 12, 12, 12, 12, 12, // char 72 - 79 20 | 12, 12, 12, 12, 12, 12, 12, 12, // char 80 - 87 21 | 12, 12, 12, 12, 12, 12, 12, 12, // char 88 - 95 22 | 12, 12, 12, 12, 12, 12, 12, 12, // char 96 - 103 23 | 12, 12, 12, 12, 12, 12, 12, 12, // char 104 - 111 24 | 12, 12, 12, 12, 12, 12, 12, 12, // char 112 - 119 25 | 12, 12, 12, 12, 12, 12, 12, 12 // char 120 - 127 26 | }; 27 | 28 | // Row format, MSB left 29 | 30 | PROGMEM const unsigned char chr_f7s_20[] = 31 | { 32 | 0x7F, 0x7F, 0x7F, 0x7F, 0x3F 33 | }; 34 | 35 | PROGMEM const unsigned char chr_f7s_2E[] = 36 | { 37 | 0x7F, 0x7F, 0x7F, 0x7B, 0x82, 0x07, 0x84, 0x06, 38 | 0x84, 0x06, 0x84, 0x07, 0x82, 0x10 39 | }; 40 | 41 | PROGMEM const unsigned char chr_f7s_30[] = 42 | { 43 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 44 | 0x01, 0x80, 0x08, 0x81, 0x01, 0x8E, 0x01, 0x82, 45 | 0x06, 0x83, 0x10, 0x84, 0x04, 0x85, 0x0E, 0x85, 46 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 47 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 48 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 49 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 50 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 51 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 52 | 0x04, 0x84, 0x10, 0x84, 0x04, 0x82, 0x14, 0x82, 53 | 0x04, 0x80, 0x18, 0x80, 0x24, 0x80, 0x1E, 0x82, 54 | 0x15, 0x81, 0x04, 0x84, 0x11, 0x83, 0x04, 0x85, 55 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 56 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 57 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 58 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 59 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 60 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 61 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x05, 0x83, 62 | 0x10, 0x83, 0x07, 0x81, 0x01, 0x8E, 0x01, 0x81, 63 | 0x0B, 0x90, 0x0D, 0x92, 0x0D, 0x90, 0x0F, 0x8E, 64 | 0x28 65 | }; 66 | 67 | PROGMEM const unsigned char chr_f7s_31[] = 68 | { 69 | 0x7F, 0x19, 0x80, 0x1D, 0x82, 0x1B, 0x84, 0x19, 70 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 71 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 72 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 73 | 0x85, 0x1B, 0x83, 0x1D, 0x81, 0x1E, 0x80, 0x5D, 74 | 0x81, 0x1B, 0x83, 0x19, 0x85, 0x19, 0x85, 0x19, 75 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 76 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 77 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x1A, 78 | 0x83, 0x1C, 0x81, 0x7F, 0x24 79 | }; 80 | 81 | PROGMEM const unsigned char chr_f7s_32[] = 82 | { 83 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 84 | 0x01, 0x80, 0x0C, 0x8E, 0x01, 0x82, 0x1B, 0x84, 85 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 86 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 87 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 88 | 0x19, 0x85, 0x1A, 0x84, 0x0A, 0x8E, 0x02, 0x82, 89 | 0x08, 0x92, 0x02, 0x80, 0x06, 0x96, 0x06, 0x80, 90 | 0x01, 0x94, 0x07, 0x82, 0x01, 0x90, 0x09, 0x84, 91 | 0x1A, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 92 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 93 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 94 | 0x19, 0x85, 0x19, 0x85, 0x1A, 0x83, 0x1C, 0x81, 95 | 0x01, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 96 | 0x0F, 0x8E, 0x28 97 | }; 98 | 99 | PROGMEM const unsigned char chr_f7s_33[] = 100 | { 101 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 102 | 0x01, 0x80, 0x0C, 0x8E, 0x01, 0x82, 0x1B, 0x84, 103 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 104 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 105 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 106 | 0x19, 0x85, 0x1A, 0x84, 0x0A, 0x8E, 0x02, 0x82, 107 | 0x08, 0x92, 0x02, 0x80, 0x06, 0x96, 0x09, 0x94, 108 | 0x0C, 0x90, 0x02, 0x81, 0x1B, 0x83, 0x19, 0x85, 109 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 110 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 111 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 112 | 0x19, 0x85, 0x1A, 0x83, 0x0B, 0x8E, 0x01, 0x81, 113 | 0x0B, 0x90, 0x0D, 0x92, 0x0D, 0x90, 0x0F, 0x8E, 114 | 0x28 115 | }; 116 | 117 | PROGMEM const unsigned char chr_f7s_34[] = 118 | { 119 | 0x7F, 0x19, 0x80, 0x08, 0x81, 0x12, 0x82, 0x06, 120 | 0x83, 0x10, 0x84, 0x04, 0x85, 0x0E, 0x85, 0x04, 121 | 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 122 | 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 123 | 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 124 | 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 125 | 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 126 | 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 127 | 0x84, 0x10, 0x84, 0x04, 0x82, 0x02, 0x8E, 0x02, 128 | 0x82, 0x04, 0x80, 0x02, 0x92, 0x02, 0x80, 0x06, 129 | 0x96, 0x09, 0x94, 0x0C, 0x90, 0x02, 0x81, 0x1B, 130 | 0x83, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 131 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 132 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 133 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x1A, 0x83, 0x1C, 134 | 0x81, 0x7F, 0x24 135 | }; 136 | 137 | PROGMEM const unsigned char chr_f7s_35[] = 138 | { 139 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 140 | 0x0B, 0x81, 0x01, 0x8E, 0x0B, 0x83, 0x1A, 0x85, 141 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 142 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 143 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 144 | 0x19, 0x84, 0x1A, 0x82, 0x02, 0x8E, 0x0A, 0x80, 145 | 0x02, 0x92, 0x0A, 0x96, 0x09, 0x94, 0x0C, 0x90, 146 | 0x02, 0x81, 0x1B, 0x83, 0x19, 0x85, 0x19, 0x85, 147 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 148 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 149 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 150 | 0x1A, 0x83, 0x0B, 0x8E, 0x01, 0x81, 0x0B, 0x90, 151 | 0x0D, 0x92, 0x0D, 0x90, 0x0F, 0x8E, 0x28 152 | }; 153 | 154 | PROGMEM const unsigned char chr_f7s_36[] = 155 | { 156 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 157 | 0x0B, 0x81, 0x01, 0x8E, 0x0B, 0x83, 0x1A, 0x85, 158 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 159 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 160 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 161 | 0x19, 0x84, 0x1A, 0x82, 0x02, 0x8E, 0x0A, 0x80, 162 | 0x02, 0x92, 0x0A, 0x96, 0x06, 0x80, 0x01, 0x94, 163 | 0x07, 0x82, 0x01, 0x90, 0x02, 0x81, 0x04, 0x84, 164 | 0x11, 0x83, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 165 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 166 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 167 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 168 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 169 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 170 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 171 | 0x0E, 0x85, 0x05, 0x83, 0x10, 0x83, 0x07, 0x81, 172 | 0x01, 0x8E, 0x01, 0x81, 0x0B, 0x90, 0x0D, 0x92, 173 | 0x0D, 0x90, 0x0F, 0x8E, 0x28 174 | }; 175 | 176 | PROGMEM const unsigned char chr_f7s_37[] = 177 | { 178 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 179 | 0x01, 0x80, 0x0C, 0x8E, 0x01, 0x82, 0x1B, 0x84, 180 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 181 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 182 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 183 | 0x19, 0x85, 0x1A, 0x84, 0x1C, 0x82, 0x1E, 0x80, 184 | 0x5D, 0x81, 0x1B, 0x83, 0x19, 0x85, 0x19, 0x85, 185 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 186 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 187 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 188 | 0x1A, 0x83, 0x1C, 0x81, 0x7F, 0x24 189 | }; 190 | 191 | PROGMEM const unsigned char chr_f7s_38[] = 192 | { 193 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 194 | 0x01, 0x80, 0x08, 0x81, 0x01, 0x8E, 0x01, 0x82, 195 | 0x06, 0x83, 0x10, 0x84, 0x04, 0x85, 0x0E, 0x85, 196 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 197 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 198 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 199 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 200 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 201 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 202 | 0x04, 0x84, 0x10, 0x84, 0x04, 0x82, 0x02, 0x8E, 203 | 0x02, 0x82, 0x04, 0x80, 0x02, 0x92, 0x02, 0x80, 204 | 0x06, 0x96, 0x06, 0x80, 0x01, 0x94, 0x07, 0x82, 205 | 0x01, 0x90, 0x02, 0x81, 0x04, 0x84, 0x11, 0x83, 206 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 207 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 208 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 209 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 210 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 211 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 212 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 213 | 0x05, 0x83, 0x10, 0x83, 0x07, 0x81, 0x01, 0x8E, 214 | 0x01, 0x81, 0x0B, 0x90, 0x0D, 0x92, 0x0D, 0x90, 215 | 0x0F, 0x8E, 0x28 216 | }; 217 | 218 | PROGMEM const unsigned char chr_f7s_39[] = 219 | { 220 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 221 | 0x01, 0x80, 0x08, 0x81, 0x01, 0x8E, 0x01, 0x82, 222 | 0x06, 0x83, 0x10, 0x84, 0x04, 0x85, 0x0E, 0x85, 223 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 224 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 225 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 226 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 227 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 228 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 229 | 0x04, 0x84, 0x10, 0x84, 0x04, 0x82, 0x02, 0x8E, 230 | 0x02, 0x82, 0x04, 0x80, 0x02, 0x92, 0x02, 0x80, 231 | 0x06, 0x96, 0x09, 0x94, 0x0C, 0x90, 0x02, 0x81, 232 | 0x1B, 0x83, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 233 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 234 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 235 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x1A, 0x83, 236 | 0x0B, 0x8E, 0x01, 0x81, 0x0B, 0x90, 0x0D, 0x92, 237 | 0x0D, 0x90, 0x0F, 0x8E, 0x28 238 | }; 239 | 240 | PROGMEM const unsigned char chr_f7s_3A[] = 241 | { 242 | 0x7F, 0x1F, 0x82, 0x07, 0x84, 0x06, 0x84, 0x06, 243 | 0x84, 0x07, 0x82, 0x7F, 0x18, 0x82, 0x07, 0x84, 244 | 0x06, 0x84, 0x06, 0x84, 0x07, 0x82, 0x7F, 0x20 245 | }; 246 | PROGMEM const unsigned char* const chrtbl_f7s[96] = // character pointer table 247 | { 248 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 249 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_2E, chr_f7s_20, 250 | chr_f7s_30, chr_f7s_31, chr_f7s_32, chr_f7s_33, chr_f7s_34, chr_f7s_35, chr_f7s_36, chr_f7s_37, 251 | chr_f7s_38, chr_f7s_39, chr_f7s_3A, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 252 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 253 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 254 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 255 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 256 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 257 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 258 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 259 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20 260 | }; 261 | -------------------------------------------------------------------------------- /Fonts/Font7srle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f7s 96 4 | #define chr_hgt_f7s 48 5 | #define data_size_f7s 8 6 | #define firstchr_f7s 32 7 | 8 | extern const unsigned char widtbl_f7s[96]; 9 | extern const unsigned char* const chrtbl_f7s[96]; 10 | -------------------------------------------------------------------------------- /Fonts/glcdfont.c: -------------------------------------------------------------------------------- 1 | // Original Adafruit 5x7 font 2 | 3 | #ifndef FONT5X7_H 4 | #define FONT5X7_H 5 | 6 | #include 7 | #include 8 | 9 | // Standard ASCII 5x7 font 10 | 11 | static const unsigned char font[] PROGMEM = { 12 | 0x00, 0x00, 0x00, 0x00, 0x00, 13 | 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 14 | 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 15 | 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 16 | 0x18, 0x3C, 0x7E, 0x3C, 0x18, 17 | 0x1C, 0x57, 0x7D, 0x57, 0x1C, 18 | 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 19 | 0x00, 0x18, 0x3C, 0x18, 0x00, 20 | 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 21 | 0x00, 0x18, 0x24, 0x18, 0x00, 22 | 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 23 | 0x30, 0x48, 0x3A, 0x06, 0x0E, 24 | 0x26, 0x29, 0x79, 0x29, 0x26, 25 | 0x40, 0x7F, 0x05, 0x05, 0x07, 26 | 0x40, 0x7F, 0x05, 0x25, 0x3F, 27 | 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 28 | 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 29 | 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 30 | 0x14, 0x22, 0x7F, 0x22, 0x14, 31 | 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 32 | 0x06, 0x09, 0x7F, 0x01, 0x7F, 33 | 0x00, 0x66, 0x89, 0x95, 0x6A, 34 | 0x60, 0x60, 0x60, 0x60, 0x60, 35 | 0x94, 0xA2, 0xFF, 0xA2, 0x94, 36 | 0x08, 0x04, 0x7E, 0x04, 0x08, 37 | 0x10, 0x20, 0x7E, 0x20, 0x10, 38 | 0x08, 0x08, 0x2A, 0x1C, 0x08, 39 | 0x08, 0x1C, 0x2A, 0x08, 0x08, 40 | 0x1E, 0x10, 0x10, 0x10, 0x10, 41 | 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 42 | 0x30, 0x38, 0x3E, 0x38, 0x30, 43 | 0x06, 0x0E, 0x3E, 0x0E, 0x06, 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x5F, 0x00, 0x00, 46 | 0x00, 0x07, 0x00, 0x07, 0x00, 47 | 0x14, 0x7F, 0x14, 0x7F, 0x14, 48 | 0x24, 0x2A, 0x7F, 0x2A, 0x12, 49 | 0x23, 0x13, 0x08, 0x64, 0x62, 50 | 0x36, 0x49, 0x56, 0x20, 0x50, 51 | 0x00, 0x08, 0x07, 0x03, 0x00, 52 | 0x00, 0x1C, 0x22, 0x41, 0x00, 53 | 0x00, 0x41, 0x22, 0x1C, 0x00, 54 | 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 55 | 0x08, 0x08, 0x3E, 0x08, 0x08, 56 | 0x00, 0x80, 0x70, 0x30, 0x00, 57 | 0x08, 0x08, 0x08, 0x08, 0x08, 58 | 0x00, 0x00, 0x60, 0x60, 0x00, 59 | 0x20, 0x10, 0x08, 0x04, 0x02, 60 | 0x3E, 0x51, 0x49, 0x45, 0x3E, 61 | 0x00, 0x42, 0x7F, 0x40, 0x00, 62 | 0x72, 0x49, 0x49, 0x49, 0x46, 63 | 0x21, 0x41, 0x49, 0x4D, 0x33, 64 | 0x18, 0x14, 0x12, 0x7F, 0x10, 65 | 0x27, 0x45, 0x45, 0x45, 0x39, 66 | 0x3C, 0x4A, 0x49, 0x49, 0x31, 67 | 0x41, 0x21, 0x11, 0x09, 0x07, 68 | 0x36, 0x49, 0x49, 0x49, 0x36, 69 | 0x46, 0x49, 0x49, 0x29, 0x1E, 70 | 0x00, 0x00, 0x14, 0x00, 0x00, 71 | 0x00, 0x40, 0x34, 0x00, 0x00, 72 | 0x00, 0x08, 0x14, 0x22, 0x41, 73 | 0x14, 0x14, 0x14, 0x14, 0x14, 74 | 0x00, 0x41, 0x22, 0x14, 0x08, 75 | 0x02, 0x01, 0x59, 0x09, 0x06, 76 | 0x3E, 0x41, 0x5D, 0x59, 0x4E, 77 | 0x7C, 0x12, 0x11, 0x12, 0x7C, 78 | 0x7F, 0x49, 0x49, 0x49, 0x36, 79 | 0x3E, 0x41, 0x41, 0x41, 0x22, 80 | 0x7F, 0x41, 0x41, 0x41, 0x3E, 81 | 0x7F, 0x49, 0x49, 0x49, 0x41, 82 | 0x7F, 0x09, 0x09, 0x09, 0x01, 83 | 0x3E, 0x41, 0x41, 0x51, 0x73, 84 | 0x7F, 0x08, 0x08, 0x08, 0x7F, 85 | 0x00, 0x41, 0x7F, 0x41, 0x00, 86 | 0x20, 0x40, 0x41, 0x3F, 0x01, 87 | 0x7F, 0x08, 0x14, 0x22, 0x41, 88 | 0x7F, 0x40, 0x40, 0x40, 0x40, 89 | 0x7F, 0x02, 0x1C, 0x02, 0x7F, 90 | 0x7F, 0x04, 0x08, 0x10, 0x7F, 91 | 0x3E, 0x41, 0x41, 0x41, 0x3E, 92 | 0x7F, 0x09, 0x09, 0x09, 0x06, 93 | 0x3E, 0x41, 0x51, 0x21, 0x5E, 94 | 0x7F, 0x09, 0x19, 0x29, 0x46, 95 | 0x26, 0x49, 0x49, 0x49, 0x32, 96 | 0x03, 0x01, 0x7F, 0x01, 0x03, 97 | 0x3F, 0x40, 0x40, 0x40, 0x3F, 98 | 0x1F, 0x20, 0x40, 0x20, 0x1F, 99 | 0x3F, 0x40, 0x38, 0x40, 0x3F, 100 | 0x63, 0x14, 0x08, 0x14, 0x63, 101 | 0x03, 0x04, 0x78, 0x04, 0x03, 102 | 0x61, 0x59, 0x49, 0x4D, 0x43, 103 | 0x00, 0x7F, 0x41, 0x41, 0x41, 104 | 0x02, 0x04, 0x08, 0x10, 0x20, 105 | 0x00, 0x41, 0x41, 0x41, 0x7F, 106 | 0x04, 0x02, 0x01, 0x02, 0x04, 107 | 0x40, 0x40, 0x40, 0x40, 0x40, 108 | 0x00, 0x03, 0x07, 0x08, 0x00, 109 | 0x20, 0x54, 0x54, 0x78, 0x40, 110 | 0x7F, 0x28, 0x44, 0x44, 0x38, 111 | 0x38, 0x44, 0x44, 0x44, 0x28, 112 | 0x38, 0x44, 0x44, 0x28, 0x7F, 113 | 0x38, 0x54, 0x54, 0x54, 0x18, 114 | 0x00, 0x08, 0x7E, 0x09, 0x02, 115 | 0x18, 0xA4, 0xA4, 0x9C, 0x78, 116 | 0x7F, 0x08, 0x04, 0x04, 0x78, 117 | 0x00, 0x44, 0x7D, 0x40, 0x00, 118 | 0x20, 0x40, 0x40, 0x3D, 0x00, 119 | 0x7F, 0x10, 0x28, 0x44, 0x00, 120 | 0x00, 0x41, 0x7F, 0x40, 0x00, 121 | 0x7C, 0x04, 0x78, 0x04, 0x78, 122 | 0x7C, 0x08, 0x04, 0x04, 0x78, 123 | 0x38, 0x44, 0x44, 0x44, 0x38, 124 | 0xFC, 0x18, 0x24, 0x24, 0x18, 125 | 0x18, 0x24, 0x24, 0x18, 0xFC, 126 | 0x7C, 0x08, 0x04, 0x04, 0x08, 127 | 0x48, 0x54, 0x54, 0x54, 0x24, 128 | 0x04, 0x04, 0x3F, 0x44, 0x24, 129 | 0x3C, 0x40, 0x40, 0x20, 0x7C, 130 | 0x1C, 0x20, 0x40, 0x20, 0x1C, 131 | 0x3C, 0x40, 0x30, 0x40, 0x3C, 132 | 0x44, 0x28, 0x10, 0x28, 0x44, 133 | 0x4C, 0x90, 0x90, 0x90, 0x7C, 134 | 0x44, 0x64, 0x54, 0x4C, 0x44, 135 | 0x00, 0x08, 0x36, 0x41, 0x00, 136 | 0x00, 0x00, 0x77, 0x00, 0x00, 137 | 0x00, 0x41, 0x36, 0x08, 0x00, 138 | 0x02, 0x01, 0x02, 0x04, 0x02, 139 | 0x3C, 0x26, 0x23, 0x26, 0x3C, 140 | 0x1E, 0xA1, 0xA1, 0x61, 0x12, 141 | 0x3A, 0x40, 0x40, 0x20, 0x7A, 142 | 0x38, 0x54, 0x54, 0x55, 0x59, 143 | 0x21, 0x55, 0x55, 0x79, 0x41, 144 | 0x21, 0x54, 0x54, 0x78, 0x41, 145 | 0x21, 0x55, 0x54, 0x78, 0x40, 146 | 0x20, 0x54, 0x55, 0x79, 0x40, 147 | 0x0C, 0x1E, 0x52, 0x72, 0x12, 148 | 0x39, 0x55, 0x55, 0x55, 0x59, 149 | 0x39, 0x54, 0x54, 0x54, 0x59, 150 | 0x39, 0x55, 0x54, 0x54, 0x58, 151 | 0x00, 0x00, 0x45, 0x7C, 0x41, 152 | 0x00, 0x02, 0x45, 0x7D, 0x42, 153 | 0x00, 0x01, 0x45, 0x7C, 0x40, 154 | 0xF0, 0x29, 0x24, 0x29, 0xF0, 155 | 0xF0, 0x28, 0x25, 0x28, 0xF0, 156 | 0x7C, 0x54, 0x55, 0x45, 0x00, 157 | 0x20, 0x54, 0x54, 0x7C, 0x54, 158 | 0x7C, 0x0A, 0x09, 0x7F, 0x49, 159 | 0x32, 0x49, 0x49, 0x49, 0x32, 160 | 0x32, 0x48, 0x48, 0x48, 0x32, 161 | 0x32, 0x4A, 0x48, 0x48, 0x30, 162 | 0x3A, 0x41, 0x41, 0x21, 0x7A, 163 | 0x3A, 0x42, 0x40, 0x20, 0x78, 164 | 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 165 | 0x39, 0x44, 0x44, 0x44, 0x39, 166 | 0x3D, 0x40, 0x40, 0x40, 0x3D, 167 | 0x3C, 0x24, 0xFF, 0x24, 0x24, 168 | 0x48, 0x7E, 0x49, 0x43, 0x66, 169 | 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 170 | 0xFF, 0x09, 0x29, 0xF6, 0x20, 171 | 0xC0, 0x88, 0x7E, 0x09, 0x03, 172 | 0x20, 0x54, 0x54, 0x79, 0x41, 173 | 0x00, 0x00, 0x44, 0x7D, 0x41, 174 | 0x30, 0x48, 0x48, 0x4A, 0x32, 175 | 0x38, 0x40, 0x40, 0x22, 0x7A, 176 | 0x00, 0x7A, 0x0A, 0x0A, 0x72, 177 | 0x7D, 0x0D, 0x19, 0x31, 0x7D, 178 | 0x26, 0x29, 0x29, 0x2F, 0x28, 179 | 0x26, 0x29, 0x29, 0x29, 0x26, 180 | 0x30, 0x48, 0x4D, 0x40, 0x20, 181 | 0x38, 0x08, 0x08, 0x08, 0x08, 182 | 0x08, 0x08, 0x08, 0x08, 0x38, 183 | 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 184 | 0x2F, 0x10, 0x28, 0x34, 0xFA, 185 | 0x00, 0x00, 0x7B, 0x00, 0x00, 186 | 0x08, 0x14, 0x2A, 0x14, 0x22, 187 | 0x22, 0x14, 0x2A, 0x14, 0x08, 188 | 0xAA, 0x00, 0x55, 0x00, 0xAA, 189 | 0xAA, 0x55, 0xAA, 0x55, 0xAA, 190 | 0x00, 0x00, 0x00, 0xFF, 0x00, 191 | 0x10, 0x10, 0x10, 0xFF, 0x00, 192 | 0x14, 0x14, 0x14, 0xFF, 0x00, 193 | 0x10, 0x10, 0xFF, 0x00, 0xFF, 194 | 0x10, 0x10, 0xF0, 0x10, 0xF0, 195 | 0x14, 0x14, 0x14, 0xFC, 0x00, 196 | 0x14, 0x14, 0xF7, 0x00, 0xFF, 197 | 0x00, 0x00, 0xFF, 0x00, 0xFF, 198 | 0x14, 0x14, 0xF4, 0x04, 0xFC, 199 | 0x14, 0x14, 0x17, 0x10, 0x1F, 200 | 0x10, 0x10, 0x1F, 0x10, 0x1F, 201 | 0x14, 0x14, 0x14, 0x1F, 0x00, 202 | 0x10, 0x10, 0x10, 0xF0, 0x00, 203 | 0x00, 0x00, 0x00, 0x1F, 0x10, 204 | 0x10, 0x10, 0x10, 0x1F, 0x10, 205 | 0x10, 0x10, 0x10, 0xF0, 0x10, 206 | 0x00, 0x00, 0x00, 0xFF, 0x10, 207 | 0x10, 0x10, 0x10, 0x10, 0x10, 208 | 0x10, 0x10, 0x10, 0xFF, 0x10, 209 | 0x00, 0x00, 0x00, 0xFF, 0x14, 210 | 0x00, 0x00, 0xFF, 0x00, 0xFF, 211 | 0x00, 0x00, 0x1F, 0x10, 0x17, 212 | 0x00, 0x00, 0xFC, 0x04, 0xF4, 213 | 0x14, 0x14, 0x17, 0x10, 0x17, 214 | 0x14, 0x14, 0xF4, 0x04, 0xF4, 215 | 0x00, 0x00, 0xFF, 0x00, 0xF7, 216 | 0x14, 0x14, 0x14, 0x14, 0x14, 217 | 0x14, 0x14, 0xF7, 0x00, 0xF7, 218 | 0x14, 0x14, 0x14, 0x17, 0x14, 219 | 0x10, 0x10, 0x1F, 0x10, 0x1F, 220 | 0x14, 0x14, 0x14, 0xF4, 0x14, 221 | 0x10, 0x10, 0xF0, 0x10, 0xF0, 222 | 0x00, 0x00, 0x1F, 0x10, 0x1F, 223 | 0x00, 0x00, 0x00, 0x1F, 0x14, 224 | 0x00, 0x00, 0x00, 0xFC, 0x14, 225 | 0x00, 0x00, 0xF0, 0x10, 0xF0, 226 | 0x10, 0x10, 0xFF, 0x10, 0xFF, 227 | 0x14, 0x14, 0x14, 0xFF, 0x14, 228 | 0x10, 0x10, 0x10, 0x1F, 0x00, 229 | 0x00, 0x00, 0x00, 0xF0, 0x10, 230 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 231 | 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 232 | 0xFF, 0xFF, 0xFF, 0x00, 0x00, 233 | 0x00, 0x00, 0x00, 0xFF, 0xFF, 234 | 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 235 | 0x38, 0x44, 0x44, 0x38, 0x44, 236 | 0x7C, 0x2A, 0x2A, 0x3E, 0x14, 237 | 0x7E, 0x02, 0x02, 0x06, 0x06, 238 | 0x02, 0x7E, 0x02, 0x7E, 0x02, 239 | 0x63, 0x55, 0x49, 0x41, 0x63, 240 | 0x38, 0x44, 0x44, 0x3C, 0x04, 241 | 0x40, 0x7E, 0x20, 0x1E, 0x20, 242 | 0x06, 0x02, 0x7E, 0x02, 0x02, 243 | 0x99, 0xA5, 0xE7, 0xA5, 0x99, 244 | 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 245 | 0x4C, 0x72, 0x01, 0x72, 0x4C, 246 | 0x30, 0x4A, 0x4D, 0x4D, 0x30, 247 | 0x30, 0x48, 0x78, 0x48, 0x30, 248 | 0xBC, 0x62, 0x5A, 0x46, 0x3D, 249 | 0x3E, 0x49, 0x49, 0x49, 0x00, 250 | 0x7E, 0x01, 0x01, 0x01, 0x7E, 251 | 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 252 | 0x44, 0x44, 0x5F, 0x44, 0x44, 253 | 0x40, 0x51, 0x4A, 0x44, 0x40, 254 | 0x40, 0x44, 0x4A, 0x51, 0x40, 255 | 0x00, 0x00, 0xFF, 0x01, 0x03, 256 | 0xE0, 0x80, 0xFF, 0x00, 0x00, 257 | 0x08, 0x08, 0x6B, 0x6B, 0x08, 258 | 0x36, 0x12, 0x36, 0x24, 0x36, 259 | 0x06, 0x0F, 0x09, 0x0F, 0x06, 260 | 0x00, 0x00, 0x18, 0x18, 0x00, 261 | 0x00, 0x00, 0x10, 0x10, 0x00, 262 | 0x30, 0x40, 0xFF, 0x01, 0x01, 263 | 0x00, 0x1F, 0x01, 0x01, 0x1E, 264 | 0x00, 0x19, 0x1D, 0x17, 0x12, 265 | 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 266 | 0x00, 0x00, 0x00, 0x00, 0x00 267 | }; 268 | #endif // FONT5X7_H 269 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TFT_ST7735 2 | 3 | An Arduino IDE compatible graphics and fonts library for AVR processors with a driver for the ST7735 based TFT displays. 4 | 5 | The library contains proportional fonts, different sizes can be enabled/disabled at compile time to optimise the use of FLASH memory. The library has been tested with the UNO, Mega (ATmega328 or ATmega2560 processor) and the Leonardo compatible boards (ATmega32u4 processor). 6 | 7 | The library is designed to be slim and fast. Typically a clear screen for a 160 x 128 TFT will complete in only 85ms. Images can be pulled from a SD Card and drawn in 200ms, not bad for a humble UNO! 8 | 9 | The library is based on the Adafruit GFX library and the aim is to retain compatibility. Significant additions have been made to the library to boost the speed for AVR processors (it is typically 3 to 10 times faster) and to add new features. The new graphics functions include different size proportional fonts and formatting features. There are a significant number of example sketches to demonstrate the different features. 10 | 11 | Configuration of the library font selections, pins used to interface with the TFT and other features is made by editting the User_Setup.h file in the library folder. Fonts and features can easily be disabled by commenting out lines. 12 | 13 | Example connections between the Arduino board and the TFT can be found here: 14 | 15 | http://www.instructables.com/id/Arduino-TFT-display-and-font-library/ 16 | 17 | Soon a dedicated Instructable will be available to document the library features, until then do explore the example sketches. 18 | Have fun! 19 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | This is a standalone library that contains both graphics functions 2 | and the TFT ST7735 driver library. 3 | 4 | This library has been derived from the Adafruit_GFX and driver library with 5 | further code from other authors. 6 | 7 | New functions have been added in particular it contains proportional fonts 8 | in addition to the original Adafruit font. 9 | 10 | Note: This version of the library might not be fully compatible with the original. 11 | 12 | 13 | =============================================================== 14 | Hereafter is the original README text for the Adafruit library: 15 | =============================================================== 16 | 17 | This is the core graphics library for all our displays, providing 18 | a common set of graphics primitives (points, lines, circles, etc.). 19 | 20 | It needs to be paired with a hardware-specific library for each 21 | display device we carry (to handle the lower-level functions). 22 | 23 | Adafruit invests time and resources providing this open source 24 | code, please support Adafruit and open-source hardware by 25 | purchasing products from Adafruit! 26 | 27 | Written by Limor Fried/Ladyada for Adafruit Industries. 28 | BSD license, check license.txt for more information. 29 | All text above must be included in any redistribution. 30 | 31 | =============================================================== 32 | -------------------------------------------------------------------------------- /TFT_FastPin.h: -------------------------------------------------------------------------------- 1 | // 2 | // This template library is from FastLED http://fastled.io 3 | // 4 | 5 | /* 6 | 7 | The MIT License (MIT) 8 | 9 | Copyright (c) 2013 FastLED 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy of 12 | this software and associated documentation files (the "Software"), to deal in 13 | the Software without restriction, including without limitation the rights to 14 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 | the Software, and to permit persons to whom the Software is furnished to do so, 16 | subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 23 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 24 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 25 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | 28 | */ 29 | 30 | #ifndef __INC_FASTPIN_H 31 | #define __INC_FASTPIN_H 32 | 33 | #include 34 | 35 | // Arduino.h needed for convinience functions digitalPinToPort/BitMask/portOutputRegister and the pinMode methods. 36 | #include 37 | 38 | #define NO_PIN 255 39 | 40 | // Class to ensure that a minimum amount of time has kicked since the last time run - and delay if not enough time has passed yet 41 | // this should make sure that chipsets that have 42 | template class CMinWait { 43 | long mLastMicros; 44 | public: 45 | CMinWait() { mLastMicros = 0; } 46 | 47 | void wait() { 48 | long diff = micros() - mLastMicros; 49 | while(diff < FASTPIN_WAIT) { 50 | diff = micros() - mLastMicros; 51 | } 52 | } 53 | 54 | void mark() { mLastMicros = micros(); } 55 | }; 56 | 57 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 58 | // 59 | // Pin access class - needs to tune for various platforms (naive fallback solution?) 60 | // 61 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 62 | 63 | #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 64 | #define _CYCLES(_PIN) (((_PIN >= 62 ) || (_PIN>=42 && _PIN<=49) || (_PIN>=14 && _PIN <=17) || (_PIN>=6 && _PIN <=9)) ? 2 : 1) 65 | #else 66 | #define _CYCLES(_PIN) ((_PIN >= 24) ? 2 : 1) 67 | #endif 68 | 69 | class Selectable { 70 | public: 71 | virtual void select() = 0; 72 | virtual void release() = 0; 73 | virtual bool isSelected() = 0; 74 | }; 75 | 76 | class Pin : public Selectable { 77 | uint8_t mPinMask; 78 | uint8_t mPin; 79 | volatile uint8_t *mPort; 80 | 81 | void _init() { 82 | mPinMask = digitalPinToBitMask(mPin); 83 | mPort = portOutputRegister(digitalPinToPort(mPin)); 84 | } 85 | public: 86 | Pin(int pin) : mPin(pin) { _init(); } 87 | 88 | typedef volatile uint8_t * port_ptr_t; 89 | typedef uint8_t port_t; 90 | 91 | inline void setOutput() { pinMode(mPin, OUTPUT); } 92 | inline void setInput() { pinMode(mPin, INPUT); } 93 | 94 | inline void hi() __attribute__ ((always_inline)) { *mPort |= mPinMask; } 95 | inline void lo() __attribute__ ((always_inline)) { *mPort &= ~mPinMask; } 96 | 97 | inline void strobe() __attribute__ ((always_inline)) { hi(); lo(); } 98 | 99 | inline void hi(register port_ptr_t port) __attribute__ ((always_inline)) { *port |= mPinMask; } 100 | inline void lo(register port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~mPinMask; } 101 | inline void set(register port_t val) __attribute__ ((always_inline)) { *mPort = val; } 102 | 103 | inline void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } 104 | 105 | port_t hival() __attribute__ ((always_inline)) { return *mPort | mPinMask; } 106 | port_t loval() __attribute__ ((always_inline)) { return *mPort & ~mPinMask; } 107 | port_ptr_t port() __attribute__ ((always_inline)) { return mPort; } 108 | port_t mask() __attribute__ ((always_inline)) { return mPinMask; } 109 | 110 | virtual void select() { hi(); } 111 | virtual void release() { lo(); } 112 | virtual bool isSelected() { return (*mPort & mPinMask) == mPinMask; } 113 | }; 114 | 115 | class OutputPin : public Pin { 116 | public: 117 | OutputPin(int pin) : Pin(pin) { setOutput(); } 118 | }; 119 | 120 | class InputPin : public Pin { 121 | public: 122 | InputPin(int pin) : Pin(pin) { setInput(); } 123 | }; 124 | 125 | /// The simplest level of Pin class. This relies on runtime functions durinig initialization to get the port/pin mask for the pin. Most 126 | /// of the accesses involve references to these static globals that get set up. This won't be the fastest set of pin operations, but it 127 | /// will provide pin level access on pretty much all arduino environments. In addition, it includes some methods to help optimize access in 128 | /// various ways. Namely, the versions of hi, lo, and fastset that take the port register as a passed in register variable (saving a global 129 | /// dereference), since these functions are aggressively inlined, that can help collapse out a lot of extraneous memory loads/dereferences. 130 | /// 131 | /// In addition, if, while writing a bunch of data to a pin, you know no other pins will be getting written to, you can get/cache a value of 132 | /// the pin's port register and use that to do a full set to the register. This results in one being able to simply do a store to the register, 133 | /// vs. the load, and/or, and store that would be done normally. 134 | /// 135 | /// There are platform specific instantiations of this class that provide direct i/o register access to pins for much higher speed pin twiddling. 136 | /// 137 | /// Note that these classes are all static functions. So the proper usage is Pin<13>::hi(); or such. Instantiating objects is not recommended, 138 | /// as passing Pin objects around will likely -not- have the effect you're expecting. 139 | template class FastPin { 140 | static uint8_t sPinMask; 141 | static volatile uint8_t *sPort; 142 | static void _init() { 143 | sPinMask = digitalPinToBitMask(PIN); 144 | sPort = portOutputRegister(digitalPinToPort(PIN)); 145 | } 146 | public: 147 | typedef volatile uint8_t * port_ptr_t; 148 | typedef uint8_t port_t; 149 | 150 | inline static void setOutput() { _init(); pinMode(PIN, OUTPUT); } 151 | inline static void setInput() { _init(); pinMode(PIN, INPUT); } 152 | 153 | inline static void hi() __attribute__ ((always_inline)) { *sPort |= sPinMask; } 154 | inline static void lo() __attribute__ ((always_inline)) { *sPort &= ~sPinMask; } 155 | 156 | inline static void strobe() __attribute__ ((always_inline)) { hi(); lo(); } 157 | 158 | inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { *port |= sPinMask; } 159 | inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~sPinMask; } 160 | inline static void set(register port_t val) __attribute__ ((always_inline)) { *sPort = val; } 161 | 162 | inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } 163 | 164 | static port_t hival() __attribute__ ((always_inline)) { return *sPort | sPinMask; } 165 | static port_t loval() __attribute__ ((always_inline)) { return *sPort & ~sPinMask; } 166 | static port_ptr_t port() __attribute__ ((always_inline)) { return sPort; } 167 | static port_t mask() __attribute__ ((always_inline)) { return sPinMask; } 168 | }; 169 | 170 | template uint8_t FastPin::sPinMask; 171 | template volatile uint8_t *FastPin::sPort; 172 | 173 | /// Class definition for a Pin where we know the port registers at compile time for said pin. This allows us to make 174 | /// a lot of optimizations, as the inlined hi/lo methods will devolve to a single io register write/bitset. 175 | template class _AVRPIN { 176 | public: 177 | typedef volatile uint8_t * port_ptr_t; 178 | typedef uint8_t port_t; 179 | 180 | inline static void setOutput() { _DDR::r() |= _MASK; } 181 | inline static void setInput() { _DDR::r() &= ~_MASK; } 182 | 183 | inline static void hi() __attribute__ ((always_inline)) { _PORT::r() |= _MASK; } 184 | inline static void lo() __attribute__ ((always_inline)) { _PORT::r() &= ~_MASK; } 185 | inline static void set(register uint8_t val) __attribute__ ((always_inline)) { _PORT::r() = val; } 186 | 187 | inline static void strobe() __attribute__ ((always_inline)) { hi(); lo(); } 188 | 189 | inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { hi(); } 190 | inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { lo(); } 191 | inline static void fastset(register port_ptr_t port, register uint8_t val) __attribute__ ((always_inline)) { set(val); } 192 | 193 | inline static port_t hival() __attribute__ ((always_inline)) { return _PORT::r() | _MASK; } 194 | inline static port_t loval() __attribute__ ((always_inline)) { return _PORT::r() & ~_MASK; } 195 | inline static port_ptr_t port() __attribute__ ((always_inline)) { return &_PORT::r(); } 196 | inline static port_t mask() __attribute__ ((always_inline)) { return _MASK; } 197 | }; 198 | 199 | /// Template definition for teensy 3.0 style ARM pins, providing direct access to the various GPIO registers. Note that this 200 | /// uses the full port GPIO registers. In theory, in some way, bit-band register access -should- be faster, however I have found 201 | /// that something about the way gcc does register allocation results in the bit-band code being slower. It will need more fine tuning. 202 | template class _ARMPIN { 203 | public: 204 | typedef volatile uint32_t * port_ptr_t; 205 | typedef uint32_t port_t; 206 | 207 | inline static void setOutput() { pinMode(PIN, OUTPUT); } // TODO: perform MUX config { _PDDR::r() |= _MASK; } 208 | inline static void setInput() { pinMode(PIN, INPUT); } // TODO: preform MUX config { _PDDR::r() &= ~_MASK; } 209 | 210 | inline static void hi() __attribute__ ((always_inline)) { _PSOR::r() = _MASK; } 211 | inline static void lo() __attribute__ ((always_inline)) { _PCOR::r() = _MASK; } 212 | inline static void set(register port_t val) __attribute__ ((always_inline)) { _PDOR::r() = val; } 213 | 214 | inline static void strobe() __attribute__ ((always_inline)) { toggle(); toggle(); } 215 | 216 | inline static void toggle() __attribute__ ((always_inline)) { _PTOR::r() = _MASK; } 217 | 218 | inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { hi(); } 219 | inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { lo(); } 220 | inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } 221 | 222 | inline static port_t hival() __attribute__ ((always_inline)) { return _PDOR::r() | _MASK; } 223 | inline static port_t loval() __attribute__ ((always_inline)) { return _PDOR::r() & ~_MASK; } 224 | inline static port_ptr_t port() __attribute__ ((always_inline)) { return &_PDOR::r(); } 225 | inline static port_t mask() __attribute__ ((always_inline)) { return _MASK; } 226 | }; 227 | 228 | /// Template definition for teensy 3.0 style ARM pins using bit banding, providing direct access to the various GPIO registers. GCC 229 | /// does a poor job of optimizing around these accesses so they are not being used just yet. 230 | template class _ARMPIN_BITBAND { 231 | public: 232 | typedef volatile uint32_t * port_ptr_t; 233 | typedef uint32_t port_t; 234 | 235 | inline static void setOutput() { pinMode(PIN, OUTPUT); } // TODO: perform MUX config { _PDDR::r() |= _MASK; } 236 | inline static void setInput() { pinMode(PIN, INPUT); } // TODO: preform MUX config { _PDDR::r() &= ~_MASK; } 237 | 238 | inline static void hi() __attribute__ ((always_inline)) { *_PDOR::template rx<_BIT>() = 1; } 239 | inline static void lo() __attribute__ ((always_inline)) { *_PDOR::template rx<_BIT>() = 0; } 240 | inline static void set(register port_t val) __attribute__ ((always_inline)) { *_PDOR::template rx<_BIT>() = val; } 241 | 242 | inline static void strobe() __attribute__ ((always_inline)) { toggle(); toggle(); } 243 | 244 | inline static void toggle() __attribute__ ((always_inline)) { *_PTOR::template rx<_BIT>() = 1; } 245 | 246 | inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { *port = 1; } 247 | inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { *port = 0; } 248 | inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } 249 | 250 | inline static port_t hival() __attribute__ ((always_inline)) { return 1; } 251 | inline static port_t loval() __attribute__ ((always_inline)) { return 0; } 252 | inline static port_ptr_t port() __attribute__ ((always_inline)) { return _PDOR::template rx<_BIT>(); } 253 | inline static port_t mask() __attribute__ ((always_inline)) { return 1; } 254 | }; 255 | 256 | /// AVR definitions for pins. Getting around the fact that I can't pass GPIO register addresses in as template arguments by instead creating 257 | /// a custom type for each GPIO register with a single, static, aggressively inlined function that returns that specific GPIO register. A similar 258 | /// trick is used a bit further below for the ARM GPIO registers (of which there are far more than on AVR!) 259 | typedef volatile uint8_t & reg8_t; 260 | #define _R(T) struct __gen_struct_ ## T 261 | #define _RD8(T) struct __gen_struct_ ## T { static inline reg8_t r() { return T; }}; 262 | #define _IO(L) _RD8(DDR ## L); _RD8(PORT ## L); _RD8(PIN ## L); 263 | #define _DEFPIN_AVR(PIN, MASK, L) template<> class FastPin : public _AVRPIN {}; 264 | 265 | // ARM definitions 266 | #define GPIO_BITBAND_ADDR(reg, bit) (((uint32_t)&(reg) - 0x40000000) * 32 + (bit) * 4 + 0x42000000) 267 | #define GPIO_BITBAND_PTR(reg, bit) ((uint32_t *)GPIO_BITBAND_ADDR((reg), (bit))) 268 | 269 | typedef volatile uint32_t & reg32_t; 270 | typedef volatile uint32_t * ptr_reg32_t; 271 | 272 | #define _RD32(T) struct __gen_struct_ ## T { static __attribute__((always_inline)) inline reg32_t r() { return T; } \ 273 | template static __attribute__((always_inline)) inline ptr_reg32_t rx() { return GPIO_BITBAND_PTR(T, BIT); } }; 274 | #define _IO32(L) _RD32(GPIO ## L ## _PDOR); _RD32(GPIO ## L ## _PSOR); _RD32(GPIO ## L ## _PCOR); _RD32(GPIO ## L ## _PTOR); _RD32(GPIO ## L ## _PDIR); _RD32(GPIO ## L ## _PDDR); 275 | 276 | #define _DEFPIN_ARM(PIN, BIT, L) template<> class FastPin : public _ARMPIN {}; 278 | 279 | // Don't use bit band'd pins for now, the compiler generates far less efficient code around them 280 | // #define _DEFPIN_ARM(PIN, BIT, L) template<> class Pin : public _ARMPIN_BITBAND {}; 282 | 283 | 284 | /////////////////////////////////////////////////////////////////////////////////////////////////////////// 285 | // 286 | // Pin definitions for AVR and ARM. If there are pin definitions supplied below for the platform being 287 | // built on, then much higher speed access will be possible, namely with direct GPIO register accesses. 288 | // 289 | /////////////////////////////////////////////////////////////////////////////////////////////////////////// 290 | #if defined(FORCE_SOFTWARE_PINS) 291 | #warning "Softwrae pin support forced pin access will be slightly slower. See fastpin.h for info." 292 | #define NO_HARDWARE_PIN_SUPPORT 293 | 294 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny45__) 295 | _IO(B); 296 | 297 | _DEFPIN_AVR(0, 0x01, B); _DEFPIN_AVR(1, 0x02, B); _DEFPIN_AVR(2, 0x04, B); _DEFPIN_AVR(3, 0x08, B); 298 | _DEFPIN_AVR(4, 0x10, B); _DEFPIN_AVR(5, 0x20, B); 299 | 300 | #elif(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) 301 | _IO(A); _IO(B); 302 | 303 | _DEFPIN_AVR(0, 0x01, A); _DEFPIN_AVR(1, 0x02, A); _DEFPIN_AVR(2, 0x04, A); _DEFPIN_AVR(3, 0x08, A); 304 | _DEFPIN_AVR(4, 0x10, A); _DEFPIN_AVR(5, 0x20, A); _DEFPIN_AVR(6, 0x40, A); _DEFPIN_AVR(7, 0x80, A); 305 | _DEFPIN_AVR(8, 0x04, B); _DEFPIN_AVR(9, 0x02, B); _DEFPIN_AVR(10, 0x01, B); 306 | 307 | #elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 308 | // Accelerated port definitions for arduino avrs 309 | _IO(D); _IO(B); _IO(C); 310 | _DEFPIN_AVR( 0, 0x01, D); _DEFPIN_AVR( 1, 0x02, D); _DEFPIN_AVR( 2, 0x04, D); _DEFPIN_AVR( 3, 0x08, D); 311 | _DEFPIN_AVR( 4, 0x10, D); _DEFPIN_AVR( 5, 0x20, D); _DEFPIN_AVR( 6, 0x40, D); _DEFPIN_AVR( 7, 0x80, D); 312 | _DEFPIN_AVR( 8, 0x01, B); _DEFPIN_AVR( 9, 0x02, B); _DEFPIN_AVR(10, 0x04, B); _DEFPIN_AVR(11, 0x08, B); 313 | _DEFPIN_AVR(12, 0x10, B); _DEFPIN_AVR(13, 0x20, B); _DEFPIN_AVR(14, 0x01, C); _DEFPIN_AVR(15, 0x02, C); 314 | _DEFPIN_AVR(16, 0x04, C); _DEFPIN_AVR(17, 0x08, C); _DEFPIN_AVR(18, 0x10, C); _DEFPIN_AVR(19, 0x20, C); 315 | 316 | #define SPI_DATA 11 317 | #define SPI_CLOCK 13 318 | #define SPI_SELECT 10 319 | #define AVR_HARDWARE_SPI 320 | 321 | #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) 322 | // megas 323 | 324 | _IO(A); _IO(B); _IO(C); _IO(D); _IO(E); _IO(F); _IO(G); _IO(H); _IO(J); _IO(K); _IO(L); 325 | 326 | _DEFPIN_AVR(0, 1, E); _DEFPIN_AVR(1, 2, E); _DEFPIN_AVR(2, 16, E); _DEFPIN_AVR(3, 32, E); 327 | _DEFPIN_AVR(4, 32, G); _DEFPIN_AVR(5, 8, E); _DEFPIN_AVR(6, 8, H); _DEFPIN_AVR(7, 16, H); 328 | _DEFPIN_AVR(8, 32, H); _DEFPIN_AVR(9, 64, H); _DEFPIN_AVR(10, 16, B); _DEFPIN_AVR(11, 32, B); 329 | _DEFPIN_AVR(12, 64, B); _DEFPIN_AVR(13, 128, B); _DEFPIN_AVR(14, 2, J); _DEFPIN_AVR(15, 1, J); 330 | _DEFPIN_AVR(16, 2, H); _DEFPIN_AVR(17, 1, H); _DEFPIN_AVR(18, 8, D); _DEFPIN_AVR(19, 4, D); 331 | _DEFPIN_AVR(20, 2, D); _DEFPIN_AVR(21, 1, D); _DEFPIN_AVR(22, 1, A); _DEFPIN_AVR(23, 2, A); 332 | _DEFPIN_AVR(24, 4, A); _DEFPIN_AVR(25, 8, A); _DEFPIN_AVR(26, 16, A); _DEFPIN_AVR(27, 32, A); 333 | _DEFPIN_AVR(28, 64, A); _DEFPIN_AVR(29, 128, A); _DEFPIN_AVR(30, 128, C); _DEFPIN_AVR(31, 64, C); 334 | _DEFPIN_AVR(32, 32, C); _DEFPIN_AVR(33, 16, C); _DEFPIN_AVR(34, 8, C); _DEFPIN_AVR(35, 4, C); 335 | _DEFPIN_AVR(36, 2, C); _DEFPIN_AVR(37, 1, C); _DEFPIN_AVR(38, 128, D); _DEFPIN_AVR(39, 4, G); 336 | _DEFPIN_AVR(40, 2, G); _DEFPIN_AVR(41, 1, G); _DEFPIN_AVR(42, 128, L); _DEFPIN_AVR(43, 64, L); 337 | _DEFPIN_AVR(44, 32, L); _DEFPIN_AVR(45, 16, L); _DEFPIN_AVR(46, 8, L); _DEFPIN_AVR(47, 4, L); 338 | _DEFPIN_AVR(48, 2, L); _DEFPIN_AVR(49, 1, L); _DEFPIN_AVR(50, 8, B); _DEFPIN_AVR(51, 4, B); 339 | _DEFPIN_AVR(52, 2, B); _DEFPIN_AVR(53, 1, B); _DEFPIN_AVR(54, 1, F); _DEFPIN_AVR(55, 2, F); 340 | _DEFPIN_AVR(56, 4, F); _DEFPIN_AVR(57, 8, F); _DEFPIN_AVR(58, 16, F); _DEFPIN_AVR(59, 32, F); 341 | _DEFPIN_AVR(60, 64, F); _DEFPIN_AVR(61, 128, F); _DEFPIN_AVR(62, 1, K); _DEFPIN_AVR(63, 2, K); 342 | _DEFPIN_AVR(64, 4, K); _DEFPIN_AVR(65, 8, K); _DEFPIN_AVR(66, 16, K); _DEFPIN_AVR(67, 32, K); 343 | _DEFPIN_AVR(68, 64, K); _DEFPIN_AVR(69, 128, K); 344 | 345 | #define SPI_DATA 51 346 | #define SPI_CLOCK 52 347 | #define SPI_SELECT 53 348 | #define AVR_HARDWARE_SPI 349 | 350 | #elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) 351 | // Xark: Add ATMega644,644P,1284 and 1284P (using pinout from http://maniacbug.wordpress.com/2011/11/27/arduino-on-atmega1284p-4/) 352 | 353 | _IO(A); _IO(B); _IO(C); _IO(D); 354 | 355 | _DEFPIN_AVR( 0, (1<<0), B); _DEFPIN_AVR( 1, (1<<1), B); _DEFPIN_AVR( 2, (1<<2), B); _DEFPIN_AVR( 3, (1<<3), B); 356 | _DEFPIN_AVR( 4, (1<<4), B); _DEFPIN_AVR( 5, (1<<5), B); _DEFPIN_AVR( 6, (1<<6), B); _DEFPIN_AVR( 7, (1<<7), B); 357 | 358 | _DEFPIN_AVR( 8, (1<<0), D); _DEFPIN_AVR( 9, (1<<1), D); _DEFPIN_AVR(10, (1<<2), D); _DEFPIN_AVR(11, (1<<3), D); 359 | _DEFPIN_AVR(12, (1<<4), D); _DEFPIN_AVR(13, (1<<5), D); _DEFPIN_AVR(14, (1<<6), D); _DEFPIN_AVR(15, (1<<7), D); 360 | 361 | _DEFPIN_AVR(16, (1<<0), C); _DEFPIN_AVR(17, (1<<1), C); _DEFPIN_AVR(18, (1<<2), C); _DEFPIN_AVR(19, (1<<3), C); 362 | _DEFPIN_AVR(20, (1<<4), C); _DEFPIN_AVR(21, (1<<5), C); _DEFPIN_AVR(22, (1<<6), C); _DEFPIN_AVR(23, (1<<7), C); 363 | 364 | _DEFPIN_AVR(24, (1<<0), A); _DEFPIN_AVR(25, (1<<1), A); _DEFPIN_AVR(26, (1<<2), A); _DEFPIN_AVR(27, (1<<3), A); 365 | _DEFPIN_AVR(28, (1<<4), A); _DEFPIN_AVR(29, (1<<5), A); _DEFPIN_AVR(30, (1<<6), A); _DEFPIN_AVR(31, (1<<7), A); 366 | 367 | #define SPI_DATA 5 368 | #define SPI_CLOCK 7 369 | #define SPI_SELECT 4 370 | #define AVR_HARDWARE_SPI 371 | 372 | // Leonardo, teensy, blinkm 373 | #elif defined(__AVR_ATmega32U4__) && defined(CORE_TEENSY) 374 | // Leonardo, teensy, blinkm 375 | #elif defined(__AVR_ATmega32U4__) && defined(CORE_TEENSY) 376 | 377 | // teensy defs 378 | _IO(B); _IO(C); _IO(D); _IO(E); _IO(F); 379 | 380 | _DEFPIN_AVR(0, 1, B); _DEFPIN_AVR(1, 2, B); _DEFPIN_AVR(2, 4, B); _DEFPIN_AVR(3, 8, B); 381 | _DEFPIN_AVR(4, 128, B); _DEFPIN_AVR(5, 1, D); _DEFPIN_AVR(6, 2, D); _DEFPIN_AVR(7, 4, D); 382 | _DEFPIN_AVR(8, 8, D); _DEFPIN_AVR(9, 64, C); _DEFPIN_AVR(10, 128, C); _DEFPIN_AVR(11, 64, D); 383 | _DEFPIN_AVR(12, 128, D); _DEFPIN_AVR(13, 16, B); _DEFPIN_AVR(14, 32, B); _DEFPIN_AVR(15, 64, B); 384 | _DEFPIN_AVR(16, 128, F); _DEFPIN_AVR(17, 64, F); _DEFPIN_AVR(18, 32, F); _DEFPIN_AVR(19, 16, F); 385 | _DEFPIN_AVR(20, 2, F); _DEFPIN_AVR(21, 1, F); _DEFPIN_AVR(22, 16, D); _DEFPIN_AVR(23, 32, D); 386 | 387 | #define SPI_DATA 2 388 | #define SPI_CLOCK 1 389 | #define SPI_SELECT 3 390 | #define AVR_HARDWARE_SPI 391 | 392 | #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) 393 | // teensy++ 2 defs 394 | 395 | _IO(A); _IO(B); _IO(C); _IO(D); _IO(E); _IO(F); 396 | 397 | _DEFPIN_AVR(0, 1, D); _DEFPIN_AVR(1, 2, D); _DEFPIN_AVR(2, 4, D); _DEFPIN_AVR(3, 8, D); 398 | _DEFPIN_AVR(4, 16, D); _DEFPIN_AVR(5, 32, D); _DEFPIN_AVR(6, 64, D); _DEFPIN_AVR(7, 128, D); 399 | _DEFPIN_AVR(8, 1, E); _DEFPIN_AVR(9, 2, E); _DEFPIN_AVR(10, 1, C); _DEFPIN_AVR(11, 2, C); 400 | _DEFPIN_AVR(12, 4, C); _DEFPIN_AVR(13, 8, C); _DEFPIN_AVR(14, 16, C); _DEFPIN_AVR(15, 32, C); 401 | _DEFPIN_AVR(16, 64, C); _DEFPIN_AVR(17, 128, C); _DEFPIN_AVR(18, 64, E); _DEFPIN_AVR(19, 128, E); 402 | _DEFPIN_AVR(20, 1, B); _DEFPIN_AVR(21, 2, B); _DEFPIN_AVR(22, 4, B); _DEFPIN_AVR(23, 8, B); 403 | _DEFPIN_AVR(24, 16, B); _DEFPIN_AVR(25, 32, B); _DEFPIN_AVR(26, 64, B); _DEFPIN_AVR(27, 128, B); 404 | _DEFPIN_AVR(28, 1, A); _DEFPIN_AVR(29, 2, A); _DEFPIN_AVR(30, 4, A); _DEFPIN_AVR(31, 8, A); 405 | _DEFPIN_AVR(32, 16, A); _DEFPIN_AVR(33, 32, A); _DEFPIN_AVR(34, 64, A); _DEFPIN_AVR(35, 128, A); 406 | _DEFPIN_AVR(36, 16, E); _DEFPIN_AVR(37, 32, E); _DEFPIN_AVR(38, 1, F); _DEFPIN_AVR(39, 2, F); 407 | _DEFPIN_AVR(40, 4, F); _DEFPIN_AVR(41, 8, F); _DEFPIN_AVR(42, 16, F); _DEFPIN_AVR(43, 32, F); 408 | _DEFPIN_AVR(44, 64, F); _DEFPIN_AVR(45, 128, F); 409 | 410 | #define SPI_DATA 22 411 | #define SPI_CLOCK 21 412 | #define SPI_SELECT 20 413 | #define AVR_HARDWARE_SPI 414 | 415 | #elif defined(__AVR_ATmega32U4__) 416 | 417 | // leonard defs 418 | _IO(B); _IO(C); _IO(D); _IO(E); _IO(F); 419 | 420 | _DEFPIN_AVR(0, 4, D); _DEFPIN_AVR(1, 8, D); _DEFPIN_AVR(2, 2, D); _DEFPIN_AVR(3, 1, D); 421 | _DEFPIN_AVR(4, 16, D); _DEFPIN_AVR(5, 64, C); _DEFPIN_AVR(6, 128, D); _DEFPIN_AVR(7, 64, E); 422 | _DEFPIN_AVR(8, 16, B); _DEFPIN_AVR(9, 32, B); _DEFPIN_AVR(10, 64, B); _DEFPIN_AVR(11, 128, B); 423 | _DEFPIN_AVR(12, 64, D); _DEFPIN_AVR(13, 128, C); _DEFPIN_AVR(14, 8, B); _DEFPIN_AVR(15, 2, B); 424 | _DEFPIN_AVR(16, 4, B); _DEFPIN_AVR(17, 1, B); _DEFPIN_AVR(18, 128, F); _DEFPIN_AVR(19, 64, F); 425 | _DEFPIN_AVR(20, 32, F); _DEFPIN_AVR(21, 16, F); _DEFPIN_AVR(22, 2, F); _DEFPIN_AVR(23, 0, F); 426 | 427 | #define SPI_DATA 16 428 | #define SPI_CLOCK 15 429 | #define AVR_HARDWARE_SPI 430 | 431 | #elif defined(__MK20DX128__) && defined(CORE_TEENSY) 432 | 433 | _IO32(A); _IO32(B); _IO32(C); _IO32(D); _IO32(E); 434 | 435 | _DEFPIN_ARM(0, 16, B); _DEFPIN_ARM(1, 17, B); _DEFPIN_ARM(2, 0, D); _DEFPIN_ARM(3, 12, A); 436 | _DEFPIN_ARM(4, 13, A); _DEFPIN_ARM(5, 7, D); _DEFPIN_ARM(6, 4, D); _DEFPIN_ARM(7, 2, D); 437 | _DEFPIN_ARM(8, 3, D); _DEFPIN_ARM(9, 3, C); _DEFPIN_ARM(10, 4, C); _DEFPIN_ARM(11, 6, C); 438 | _DEFPIN_ARM(12, 7, C); _DEFPIN_ARM(13, 5, C); _DEFPIN_ARM(14, 1, D); _DEFPIN_ARM(15, 0, C); 439 | _DEFPIN_ARM(16, 0, B); _DEFPIN_ARM(17, 1, B); _DEFPIN_ARM(18, 3, B); _DEFPIN_ARM(19, 2, B); 440 | _DEFPIN_ARM(20, 5, D); _DEFPIN_ARM(21, 6, D); _DEFPIN_ARM(22, 1, C); _DEFPIN_ARM(23, 2, C); 441 | _DEFPIN_ARM(24, 5, A); _DEFPIN_ARM(25, 19, B); _DEFPIN_ARM(26, 1, E); _DEFPIN_ARM(27, 9, C); 442 | _DEFPIN_ARM(28, 8, C); _DEFPIN_ARM(29, 10, C); _DEFPIN_ARM(30, 11, C); _DEFPIN_ARM(31, 0, E); 443 | _DEFPIN_ARM(32, 18, B); _DEFPIN_ARM(33, 4, A); 444 | 445 | #define SPI_DATA 11 446 | #define SPI_CLOCK 13 447 | #define ARM_HARDWARE_SPI 448 | 449 | #elif defined(__SAM3X8E__) 450 | 451 | DUE_IO32(A); 452 | DUE_IO32(B); 453 | DUE_IO32(C); 454 | DUE_IO32(D); 455 | 456 | _DEFPIN_DUE(0, 8, A); _DEFPIN_DUE(1, 9, A); _DEFPIN_DUE(2, 25, B); _DEFPIN_DUE(3, 28, C); 457 | _DEFPIN_DUE(4, 26, C); _DEFPIN_DUE(5, 25, C); _DEFPIN_DUE(6, 24, C); _DEFPIN_DUE(7, 23, C); 458 | _DEFPIN_DUE(8, 22, C); _DEFPIN_DUE(9, 21, C); _DEFPIN_DUE(10, 29, C); _DEFPIN_DUE(11, 7, D); 459 | _DEFPIN_DUE(12, 8, D); _DEFPIN_DUE(13, 27, B); _DEFPIN_DUE(14, 4, D); _DEFPIN_DUE(15, 5, D); 460 | _DEFPIN_DUE(16, 13, A); _DEFPIN_DUE(17, 12, A); _DEFPIN_DUE(18, 11, A); _DEFPIN_DUE(19, 10, A); 461 | _DEFPIN_DUE(20, 12, B); _DEFPIN_DUE(21, 13, B); _DEFPIN_DUE(22, 26, B); _DEFPIN_DUE(23, 14, A); 462 | _DEFPIN_DUE(24, 15, A); _DEFPIN_DUE(25, 0, D); _DEFPIN_DUE(26, 1, D); _DEFPIN_DUE(27, 2, D); 463 | _DEFPIN_DUE(28, 3, D); _DEFPIN_DUE(29, 6, D); _DEFPIN_DUE(30, 9, D); _DEFPIN_DUE(31, 7, A); 464 | _DEFPIN_DUE(32, 10, D); _DEFPIN_DUE(33, 1, C); _DEFPIN_DUE(34, 2, C); _DEFPIN_DUE(35, 3, C); 465 | _DEFPIN_DUE(36, 4, C); _DEFPIN_DUE(37, 5, C); _DEFPIN_DUE(38, 6, C); _DEFPIN_DUE(39, 7, C); 466 | _DEFPIN_DUE(40, 8, C); _DEFPIN_DUE(41, 9, C); _DEFPIN_DUE(42, 19, A); _DEFPIN_DUE(43, 20, A); 467 | _DEFPIN_DUE(44, 19, C); _DEFPIN_DUE(45, 18, C); _DEFPIN_DUE(46, 17, C); _DEFPIN_DUE(47, 16, C); 468 | _DEFPIN_DUE(48, 15, C); _DEFPIN_DUE(49, 14, C); _DEFPIN_DUE(50, 13, C); _DEFPIN_DUE(51, 12, C); 469 | _DEFPIN_DUE(52, 21, B); _DEFPIN_DUE(53, 14, B); _DEFPIN_DUE(54, 16, A); _DEFPIN_DUE(55, 24, A); 470 | _DEFPIN_DUE(56, 23, A); _DEFPIN_DUE(57, 22, A); _DEFPIN_DUE(58, 6, A); _DEFPIN_DUE(59, 4, A); 471 | _DEFPIN_DUE(60, 3, A); _DEFPIN_DUE(61, 2, A); _DEFPIN_DUE(62, 17, B); _DEFPIN_DUE(63, 18, B); 472 | _DEFPIN_DUE(64, 19, B); _DEFPIN_DUE(65, 20, B); _DEFPIN_DUE(66, 15, B); _DEFPIN_DUE(67, 16, B); 473 | _DEFPIN_DUE(68, 1, A); _DEFPIN_DUE(69, 0, A); _DEFPIN_DUE(70, 17, A); _DEFPIN_DUE(71, 18, A); 474 | _DEFPIN_DUE(72, 30, C); _DEFPIN_DUE(73, 21, A); _DEFPIN_DUE(74, 25, A); _DEFPIN_DUE(75, 26, A); 475 | _DEFPIN_DUE(76, 27, A); _DEFPIN_DUE(77, 28, A); _DEFPIN_DUE(78, 23, B); 476 | 477 | #else 478 | 479 | #warning "No pin/port mappings found, pin access will be slightly slower. See fastpin.h for info." 480 | #define NO_HARDWARE_PIN_SUPPORT 481 | 482 | #endif 483 | 484 | #endif 485 | -------------------------------------------------------------------------------- /TFT_ST7735.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | Arduino TFT graphics library targetted at the UNO 3 | and Mega boards. 4 | 5 | This library has been derived from the Adafruit_GFX 6 | library and the associated driver library. See text 7 | at the end of this file. 8 | 9 | This is a standalone library that contains the 10 | hardware driver, the graphics funtions and the 11 | proportional fonts. 12 | 13 | The larger fonts are Run Length Encoded to reduce 14 | their FLASH footprint. 15 | 16 | ****************************************************/ 17 | 18 | #define INITR_GREENTAB 0x0 19 | #define INITR_REDTAB 0x1 20 | #define INITR_BLACKTAB 0x2 21 | #define INITR_GREENTAB2 0x3 // Use if you get random pixels on two edges of green tab display 22 | #define INITB 0xB 23 | 24 | // Include header file that defines the fonts loaded and the pins to be used 25 | #include 26 | 27 | // Include header file from the FastLED library for fast pin toggling using direct port access 28 | #include 29 | 30 | // Stop fonts being loaded multiple times 31 | #ifndef _TFT_ST7735H_ 32 | #define _TFT_ST7735H_ 33 | 34 | // Only load the fonts defined in User_Setup.h (to save space) 35 | // Set flag so RLE rendering code is optionally compiled 36 | #ifdef LOAD_GLCD 37 | #include 38 | #endif 39 | 40 | #ifdef LOAD_FONT2 41 | #include 42 | #endif 43 | 44 | #ifdef LOAD_FONT4 45 | #include 46 | #define LOAD_RLE 47 | #endif 48 | 49 | #ifdef LOAD_FONT6 50 | #include 51 | #ifndef LOAD_RLE 52 | #define LOAD_RLE 53 | #endif 54 | #endif 55 | 56 | #ifdef LOAD_FONT7 57 | #include 58 | #ifndef LOAD_RLE 59 | #define LOAD_RLE 60 | #endif 61 | #endif 62 | 63 | #ifdef LOAD_FONT8 64 | #include 65 | #ifndef LOAD_RLE 66 | #define LOAD_RLE 67 | #endif 68 | #endif 69 | 70 | #include 71 | #include 72 | 73 | #include 74 | 75 | // Swap any type 76 | template static inline void 77 | tftswap(T& a, T& b) { T t = a; a = b; b = t; } 78 | 79 | //These define the ports and port bits used for the chip select (CS) and data/command (DC) lines 80 | #define TFT_CS_L FastPin::lo() 81 | #define TFT_DC_C FastPin::lo() 82 | #define TFT_CS_H FastPin::hi() 83 | #define TFT_DC_D FastPin::hi() 84 | 85 | //These enumerate the text plotting alignment (reference datum point) 86 | #define TL_DATUM 0 // Top left (default) 87 | #define TC_DATUM 1 // Top centre 88 | #define TR_DATUM 2 // Top right 89 | #define ML_DATUM 3 // Middle left 90 | #define CL_DATUM 3 // Centre left, same as above 91 | #define MC_DATUM 4 // Middle centre 92 | #define CC_DATUM 4 // Centre centre, same as above 93 | #define MR_DATUM 5 // Middle right 94 | #define CR_DATUM 5 // Centre right, same as above 95 | #define BL_DATUM 6 // Bottom left 96 | #define BC_DATUM 7 // Bottom centre 97 | #define BR_DATUM 8 // Bottom right 98 | 99 | 100 | // Change the width and height if required (defined in portrait mode) 101 | // or use the constructor to over-ride defaults 102 | #define ST7735_TFTWIDTH 128 103 | #define ST7735_TFTHEIGHT 160 104 | 105 | #define ST7735_INIT_DELAY 0x80 106 | 107 | // These are the ST7735 control registers 108 | // some flags for initR() :( 109 | 110 | #define ST7735_TFTWIDTH 128 111 | #define ST7735_TFTHEIGHT 160 112 | 113 | #define ST7735_NOP 0x00 114 | #define ST7735_SWRESET 0x01 115 | #define ST7735_RDDID 0x04 116 | #define ST7735_RDDST 0x09 117 | 118 | #define ST7735_SLPIN 0x10 119 | #define ST7735_SLPOUT 0x11 120 | #define ST7735_PTLON 0x12 121 | #define ST7735_NORON 0x13 122 | 123 | #define ST7735_INVOFF 0x20 124 | #define ST7735_INVON 0x21 125 | #define ST7735_DISPOFF 0x28 126 | #define ST7735_DISPON 0x29 127 | #define ST7735_CASET 0x2A 128 | #define ST7735_RASET 0x2B 129 | #define ST7735_RAMWR 0x2C 130 | #define ST7735_RAMRD 0x2E 131 | 132 | #define ST7735_PTLAR 0x30 133 | #define ST7735_COLMOD 0x3A 134 | #define ST7735_MADCTL 0x36 135 | 136 | #define ST7735_FRMCTR1 0xB1 137 | #define ST7735_FRMCTR2 0xB2 138 | #define ST7735_FRMCTR3 0xB3 139 | #define ST7735_INVCTR 0xB4 140 | #define ST7735_DISSET5 0xB6 141 | 142 | #define ST7735_PWCTR1 0xC0 143 | #define ST7735_PWCTR2 0xC1 144 | #define ST7735_PWCTR3 0xC2 145 | #define ST7735_PWCTR4 0xC3 146 | #define ST7735_PWCTR5 0xC4 147 | #define ST7735_VMCTR1 0xC5 148 | 149 | #define ST7735_RDID1 0xDA 150 | #define ST7735_RDID2 0xDB 151 | #define ST7735_RDID3 0xDC 152 | #define ST7735_RDID4 0xDD 153 | 154 | #define ST7735_PWCTR6 0xFC 155 | 156 | #define ST7735_GMCTRP1 0xE0 157 | #define ST7735_GMCTRN1 0xE1 158 | 159 | 160 | #define MADCTL_MY 0x80 161 | #define MADCTL_MX 0x40 162 | #define MADCTL_MV 0x20 163 | #define MADCTL_ML 0x10 164 | #define MADCTL_RGB 0x00 165 | #define MADCTL_BGR 0x08 166 | #define MADCTL_MH 0x04 167 | 168 | // New color definitions use for all my libraries 169 | #define TFT_BLACK 0x0000 /* 0, 0, 0 */ 170 | #define TFT_NAVY 0x000F /* 0, 0, 128 */ 171 | #define TFT_DARKGREEN 0x03E0 /* 0, 128, 0 */ 172 | #define TFT_DARKCYAN 0x03EF /* 0, 128, 128 */ 173 | #define TFT_MAROON 0x7800 /* 128, 0, 0 */ 174 | #define TFT_PURPLE 0x780F /* 128, 0, 128 */ 175 | #define TFT_OLIVE 0x7BE0 /* 128, 128, 0 */ 176 | #define TFT_LIGHTGREY 0xC618 /* 192, 192, 192 */ 177 | #define TFT_DARKGREY 0x7BEF /* 128, 128, 128 */ 178 | #define TFT_BLUE 0x001F /* 0, 0, 255 */ 179 | #define TFT_GREEN 0x07E0 /* 0, 255, 0 */ 180 | #define TFT_CYAN 0x07FF /* 0, 255, 255 */ 181 | #define TFT_RED 0xF800 /* 255, 0, 0 */ 182 | #define TFT_MAGENTA 0xF81F /* 255, 0, 255 */ 183 | #define TFT_YELLOW 0xFFE0 /* 255, 255, 0 */ 184 | #define TFT_WHITE 0xFFFF /* 255, 255, 255 */ 185 | #define TFT_ORANGE 0xFD20 /* 255, 165, 0 */ 186 | #define TFT_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ 187 | #define TFT_PINK 0xF81F 188 | 189 | // Color definitions for backwards compatibility 190 | #define ST7735_BLACK 0x0000 /* 0, 0, 0 */ 191 | #define ST7735_NAVY 0x000F /* 0, 0, 128 */ 192 | #define ST7735_DARKGREEN 0x03E0 /* 0, 128, 0 */ 193 | #define ST7735_DARKCYAN 0x03EF /* 0, 128, 128 */ 194 | #define ST7735_MAROON 0x7800 /* 128, 0, 0 */ 195 | #define ST7735_PURPLE 0x780F /* 128, 0, 128 */ 196 | #define ST7735_OLIVE 0x7BE0 /* 128, 128, 0 */ 197 | #define ST7735_LIGHTGREY 0xC618 /* 192, 192, 192 */ 198 | #define ST7735_DARKGREY 0x7BEF /* 128, 128, 128 */ 199 | #define ST7735_BLUE 0x001F /* 0, 0, 255 */ 200 | #define ST7735_GREEN 0x07E0 /* 0, 255, 0 */ 201 | #define ST7735_CYAN 0x07FF /* 0, 255, 255 */ 202 | #define ST7735_RED 0xF800 /* 255, 0, 0 */ 203 | #define ST7735_MAGENTA 0xF81F /* 255, 0, 255 */ 204 | #define ST7735_YELLOW 0xFFE0 /* 255, 255, 0 */ 205 | #define ST7735_WHITE 0xFFFF /* 255, 255, 255 */ 206 | #define ST7735_ORANGE 0xFD20 /* 255, 165, 0 */ 207 | #define ST7735_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ 208 | #define ST7735_PINK 0xF81F 209 | 210 | typedef struct { 211 | const unsigned char *chartbl; 212 | const unsigned char *widthtbl; 213 | unsigned char height; 214 | } fontinfo; 215 | 216 | // This is a structure to conveniently hold infomation on the fonts 217 | // Stores font character image address pointer, width table and height 218 | 219 | const PROGMEM fontinfo fontdata [] = { 220 | { 0, 0, 0 }, 221 | 222 | { 0, 0, 8 }, 223 | 224 | #ifdef LOAD_FONT2 225 | { (const unsigned char *)chrtbl_f16, widtbl_f16, chr_hgt_f16}, 226 | #else 227 | { 0, 0, 0 }, 228 | #endif 229 | 230 | { 0, 0, 0 }, 231 | 232 | #ifdef LOAD_FONT4 233 | { (const unsigned char *)chrtbl_f32, widtbl_f32, chr_hgt_f32}, 234 | #else 235 | { 0, 0, 0 }, 236 | #endif 237 | 238 | { 0, 0, 0 }, 239 | 240 | #ifdef LOAD_FONT6 241 | { (const unsigned char *)chrtbl_f64, widtbl_f64, chr_hgt_f64}, 242 | #else 243 | { 0, 0, 0 }, 244 | #endif 245 | 246 | #ifdef LOAD_FONT7 247 | { (const unsigned char *)chrtbl_f7s, widtbl_f7s, chr_hgt_f7s}, 248 | #else 249 | { 0, 0, 0 }, 250 | #endif 251 | 252 | #ifdef LOAD_FONT8 253 | { (const unsigned char *)chrtbl_f72, widtbl_f72, chr_hgt_f72} 254 | #else 255 | { 0, 0, 0 } 256 | #endif 257 | }; 258 | 259 | 260 | // Class functions and variables 261 | class TFT_ST7735 : public Print { 262 | 263 | public: 264 | 265 | TFT_ST7735(int16_t _W = ST7735_TFTWIDTH, int16_t _H = ST7735_TFTHEIGHT); 266 | 267 | void init(void), begin(void), // Same - begin included for backwards compatibility 268 | 269 | drawPixel(uint16_t x, uint16_t y, uint16_t color), 270 | 271 | drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t font), 272 | setAddrWindow(int16_t x0, int16_t y0, int16_t x1, int16_t y1), 273 | 274 | pushColor(uint16_t color), 275 | pushColor(uint16_t color, uint16_t len), 276 | 277 | pushColors(uint16_t *data, uint8_t len), 278 | pushColors(uint8_t *data, uint16_t len), 279 | 280 | fillScreen(uint16_t color), 281 | 282 | writeEnd(void), 283 | backupSPCR(void), 284 | restoreSPCR(void), 285 | 286 | drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color), 287 | drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), 288 | drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), 289 | 290 | drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 291 | fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 292 | drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color), 293 | fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color), 294 | 295 | setRotation(uint8_t r), 296 | invertDisplay(boolean i), 297 | 298 | drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 299 | drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color), 300 | fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 301 | fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color), 302 | 303 | drawEllipse(int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint16_t color), 304 | fillEllipse(int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint16_t color), 305 | 306 | drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color), 307 | fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color), 308 | 309 | drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color), 310 | 311 | setCursor(int16_t x, int16_t y), 312 | setCursor(int16_t x, int16_t y, uint8_t font), 313 | setTextColor(uint16_t color), 314 | setTextColor(uint16_t fgcolor, uint16_t bgcolor), 315 | setTextSize(uint8_t size), 316 | setTextFont(uint8_t font), 317 | setTextWrap(boolean wrap), 318 | setTextDatum(uint8_t datum), 319 | setTextPadding(uint16_t x_width), 320 | 321 | spiwrite(uint8_t), 322 | writecommand(uint8_t c), 323 | writedata(uint8_t d), 324 | commandList(const uint8_t *addr); 325 | 326 | uint8_t getRotation(void); 327 | 328 | uint16_t fontsLoaded(void), 329 | color565(uint8_t r, uint8_t g, uint8_t b); 330 | 331 | int16_t drawChar(unsigned int uniCode, int x, int y, int font), 332 | drawNumber(long long_num,int poX, int poY, int font), 333 | drawFloat(float floatNumber,int decimal,int poX, int poY, int font), 334 | 335 | drawString(char *string, int poX, int poY, int font), 336 | drawCentreString(char *string, int dX, int poY, int font), 337 | drawRightString(char *string, int dX, int poY, int font), 338 | 339 | height(void), 340 | width(void), 341 | textWidth(char *string, int font), 342 | fontHeight(int font); 343 | 344 | virtual size_t write(uint8_t); 345 | 346 | private: 347 | 348 | void setWindow(int16_t x0, int16_t y0, int16_t x1, int16_t y1); 349 | 350 | uint8_t tabcolor, 351 | colstart, rowstart; // some displays need this changed 352 | 353 | boolean hwSPI; 354 | 355 | uint8_t mySPCR, savedSPCR; 356 | 357 | int8_t _cs, _dc, _rst, _mosi, _miso, _sclk; 358 | 359 | 360 | protected: 361 | 362 | int16_t _width, _height, // Display w/h as modified by current rotation 363 | cursor_x, cursor_y, padX; 364 | 365 | uint16_t textcolor, textbgcolor, fontsloaded; 366 | 367 | uint8_t addr_row, addr_col; 368 | 369 | uint8_t textfont, 370 | textsize, 371 | textdatum, 372 | rotation; 373 | 374 | boolean textwrap; // If set, 'wrap' text at right edge of display 375 | 376 | }; 377 | 378 | #endif 379 | 380 | /*************************************************** 381 | 382 | ORIGINAL LIBRARY HEADER 383 | 384 | This is our library for the Adafruit ST7735 Breakout and Shield 385 | ----> http://www.adafruit.com/products/1651 386 | 387 | Check out the links above for our tutorials and wiring diagrams 388 | These displays use SPI to communicate, 4 or 5 pins are required to 389 | interface (RST is optional) 390 | Adafruit invests time and resources providing this open source code, 391 | please support Adafruit and open-source hardware by purchasing 392 | products from Adafruit! 393 | 394 | Written by Limor Fried/Ladyada for Adafruit Industries. 395 | MIT license, all text above must be included in any redistribution 396 | 397 | Updated with new functions by Bodmer 14/4/15 398 | ****************************************************/ 399 | -------------------------------------------------------------------------------- /User_Setup.h: -------------------------------------------------------------------------------- 1 | // USER DEFINED SETTINGS V16 2 | // Set fonts to be loaded, pins used and SPI control method 3 | 4 | // Define the type of display from the colour of the tab on the screen protector 5 | // Comment out all but one of these options 6 | 7 | //#define TAB_COLOUR INITB 8 | //#define TAB_COLOUR INITR_GREENTAB 9 | //#define TAB_COLOUR INITR_REDTAB 10 | //#define TAB_COLOUR INITR_BLACKTAB 11 | #define TAB_COLOUR INITR_GREENTAB2 12 | 13 | // ################################################################################## 14 | // 15 | // Define the pins that are used to interface with the display here 16 | // 17 | // ################################################################################## 18 | 19 | // We must use hardware SPI 20 | // FYI Mega SCK is pin 52, MOSI is 51, UNO/NanoPro micro etc SCK is pin 13 and MOSI is 11 21 | // Leonardo Pro micro SCK is pin 15 and MOSI is 16 22 | 23 | // ###### EDIT THE PIN NUMBERS IN THE 3 LINES FOLLOWING TO SUIT YOUR SETUP ###### 24 | 25 | #define TFT_CS 9 // Chip select control pin 26 | #define TFT_DC 8 // Data Command control pin 27 | #define TFT_RST 7 // Reset pin (could connect to Arduino RESET pin) 28 | 29 | 30 | // ################################################################################## 31 | // 32 | // Define the fonts that are to be used here 33 | // 34 | // ################################################################################## 35 | 36 | // Comment out the #defines below with // to stop that font being loaded 37 | // As supplied font 8 is disabled by commenting out 38 | // 39 | // If all fonts are loaded the extra FLASH space required is about 17000 bytes... 40 | // To save FLASH space only enable the fonts you need! 41 | 42 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 43 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 44 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 45 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 46 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 47 | //#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 48 | 49 | 50 | // ################################################################################## 51 | // 52 | // Define whether we want to use delays or SPIF flag to control SPI transactions 53 | // 54 | // ################################################################################## 55 | 56 | // If we define F_AS_T here then delays are used between SPI transactions 57 | // to speed up rendering, comment out to "wait" for the SPIF flag instead 58 | // Commenting out the line stops use of FastPin for control lines 59 | 60 | // BUG AWAITING FIX - DO NOT COMMENT OUT IN THIS VERSION 61 | #define F_AS_T 62 | 63 | 64 | // ################################################################################## 65 | // 66 | // Other speed up options 67 | // 68 | // ################################################################################## 69 | 70 | // Uncomment the following #define to invoke a 20% faster drawLine() function 71 | // This speeds up other funtions such as triangle outline drawing too 72 | // Code size penalty is about 72 bytes 73 | 74 | #define FAST_LINE 75 | 76 | // Comment out the following #define to stop boundary checking and clipping 77 | // for fillRectangle()and fastH/V lines. This speeds up other funtions such as text 78 | // rendering where size>1. Sketch then must not draw graphics/text outside screen 79 | // boundary. Code saving for no bounds check (i.e. commented out) is 316 bytes 80 | 81 | //#define CLIP_CHECK 82 | 83 | // Comment out the following #define if "SPI Transactions" do not need to be 84 | // supported. Tranaction support is required if other SPI devices use interrupts. 85 | // When commented out the code size will be ~700 bytes smaller and sketches will 86 | // run slightly faster, so leave it commented out unless you need it! 87 | // Transaction support is needed to work with SD libraru but not needed with TFT_SdFat 88 | 89 | // #define SUPPORT_TRANSACTIONS 90 | 91 | -------------------------------------------------------------------------------- /examples/Arduino_Life/Arduino_Life.ino: -------------------------------------------------------------------------------- 1 | //The Game of Life, also known simply as Life, is a cellular automaton 2 | //devised by the British mathematician John Horton Conway in 1970. 3 | // https://en.wikipedia.org/wiki/Conway's_Game_of_Life 4 | 5 | 6 | 7 | #include // Hardware-specific library 8 | #include 9 | 10 | TFT_ST7735 tft = TFT_ST7735(); // Invoke custom library 11 | 12 | #define GRIDX 32 13 | #define GRIDY 24 14 | #define CELLXY 5 15 | 16 | #define GEN_DELAY 0 17 | 18 | //Current grid 19 | uint8_t grid[GRIDX][GRIDY]; 20 | 21 | //The new grid for the next generation 22 | uint8_t newgrid[GRIDX][GRIDY]; 23 | 24 | //Number of generations 25 | uint16_t genCount = 0; 26 | 27 | void setup() { 28 | 29 | //Set up the display 30 | tft.init(); 31 | tft.setRotation(3); 32 | tft.fillScreen(TFT_BLACK); 33 | tft.setTextSize(1); 34 | tft.setTextColor(TFT_WHITE); 35 | tft.setCursor(0, 0); 36 | 37 | } 38 | 39 | void loop() { 40 | 41 | //Display a simple splash screen 42 | tft.fillScreen(TFT_BLACK); 43 | tft.setTextSize(2); 44 | tft.setTextColor(TFT_WHITE); 45 | tft.setCursor(40, 5); 46 | tft.println(F("Arduino")); 47 | tft.setCursor(35, 25); 48 | tft.println(F("Cellular")); 49 | tft.setCursor(35, 45); 50 | tft.println(F("Automata")); 51 | 52 | delay(1000); 53 | 54 | tft.fillScreen(TFT_BLACK); 55 | 56 | initGrid(); 57 | 58 | genCount = 300; 59 | 60 | drawGrid(); 61 | 62 | //Compute generations 63 | for (int gen = 0; gen < genCount; gen++) 64 | { 65 | computeCA(); 66 | drawGrid(); 67 | delay(GEN_DELAY); 68 | for (int16_t x = 1; x < GRIDX-1; x++) { 69 | for (int16_t y = 1; y < GRIDY-1; y++) { 70 | grid[x][y] = newgrid[x][y]; 71 | } 72 | } 73 | 74 | } 75 | } 76 | 77 | //Draws the grid on the display 78 | void drawGrid(void) { 79 | 80 | uint16_t color = TFT_WHITE; 81 | for (int16_t x = 1; x < GRIDX - 1; x++) { 82 | for (int16_t y = 1; y < GRIDY - 1; y++) { 83 | if ((grid[x][y]) != (newgrid[x][y])) { 84 | if (newgrid[x][y] == 1) color = 0xFFFF; //random(0xFFFF); 85 | else color = 0; 86 | tft.fillRect(CELLXY * x, CELLXY * y, CELLXY, CELLXY, color); 87 | } 88 | } 89 | } 90 | } 91 | 92 | //Initialise Grid 93 | void initGrid(void) { 94 | for (int16_t x = 0; x < GRIDX; x++) { 95 | for (int16_t y = 0; y < GRIDY; y++) { 96 | newgrid[x][y] = 0; 97 | 98 | if (x == 0 || x == GRIDX - 1 || y == 0 || y == GRIDY - 1) { 99 | grid[x][y] = 0; 100 | } 101 | else { 102 | if (random(3) == 1) 103 | grid[x][y] = 1; 104 | else 105 | grid[x][y] = 0; 106 | } 107 | 108 | } 109 | } 110 | } 111 | 112 | //Compute the CA. Basically everything related to CA starts here 113 | void computeCA() { 114 | for (int16_t x = 1; x < GRIDX; x++) { 115 | for (int16_t y = 1; y < GRIDY; y++) { 116 | int neighbors = getNumberOfNeighbors(x, y); 117 | if (grid[x][y] == 1 && (neighbors == 2 || neighbors == 3 )) 118 | { 119 | newgrid[x][y] = 1; 120 | } 121 | else if (grid[x][y] == 1) newgrid[x][y] = 0; 122 | if (grid[x][y] == 0 && (neighbors == 3)) 123 | { 124 | newgrid[x][y] = 1; 125 | } 126 | else if (grid[x][y] == 0) newgrid[x][y] = 0; 127 | } 128 | } 129 | } 130 | 131 | // Check the Moore neighborhood 132 | int getNumberOfNeighbors(int x, int y) { 133 | return grid[x - 1][y] + grid[x - 1][y - 1] + grid[x][y - 1] + grid[x + 1][y - 1] + grid[x + 1][y] + grid[x + 1][y + 1] + grid[x][y + 1] + grid[x - 1][y + 1]; 134 | } 135 | 136 | /* 137 | The MIT License (MIT) 138 | 139 | Copyright (c) 2016 RuntimeProjects.com 140 | 141 | Permission is hereby granted, free of charge, to any person obtaining a copy 142 | of this software and associated documentation files (the "Software"), to deal 143 | in the Software without restriction, including without limitation the rights 144 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 145 | copies of the Software, and to permit persons to whom the Software is 146 | furnished to do so, subject to the following conditions: 147 | 148 | The above copyright notice and this permission notice shall be included in all 149 | copies or substantial portions of the Software. 150 | 151 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 152 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 153 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 154 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 155 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 156 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 157 | SOFTWARE. 158 | */ 159 | -------------------------------------------------------------------------------- /examples/Flash_Bitmap2/Alert.h: -------------------------------------------------------------------------------- 1 | // We need this header file to use FLASH as storage with PROGMEM directive: 2 | #include 3 | 4 | // Icon width and height 5 | const uint16_t alertWidth = 32; 6 | const uint16_t alertHeight = 32; 7 | 8 | // The icon file can be created with the "UTFT ImageConverter 565" bitmap to .c file creation utility, more can be pasted in here 9 | const unsigned short alert[1024] PROGMEM={ 10 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0840,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 0, 32 pixels 11 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1080,0xAC66,0xEDE8,0xFE69,0xC4C6,0x2901,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 1, 64 pixels 12 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xBCC6,0xFE68,0xFE68,0xFE6A,0xFE68,0xEDE8,0x18A1,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 2, 96 pixels 13 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x8344,0xFE48,0xFE8C,0xFFDD,0xFFFF,0xFEF0,0xFE48,0xB466,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 3, 128 pixels 14 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1880,0xEDC7,0xFE48,0xFF99,0xFFBC,0xFF9B,0xFFBD,0xFE6A,0xFE48,0x5A23,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 4, 160 pixels 15 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x9BE5,0xFE28,0xFED0,0xFFBC,0xFF7A,0xFF9A,0xFF9B,0xFF35,0xFE28,0xBCA6,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 5, 192 pixels 16 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3962,0xFE28,0xFE28,0xFF9A,0xFF79,0xFF9A,0xFF9B,0xFF9A,0xFFBD,0xFE6B,0xFE28,0x72E3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 6, 224 pixels 17 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xB465,0xFE28,0xFEF2,0xFF7A,0xFF79,0xFF7A,0xFF9A,0xFF7A,0xFF7A,0xFF78,0xFE28,0xDD67,0x0860,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 7, 256 pixels 18 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x5A22,0xFE07,0xFE29,0xFF9B,0xFF37,0xFF58,0xFF79,0xFF79,0xFF79,0xFF58,0xFF9B,0xFEAE,0xFE07,0x93A4,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 8, 288 pixels 19 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xC4A5,0xFE07,0xFF15,0xFF37,0xFF36,0xAD11,0x2965,0x2965,0xCDF4,0xFF37,0xFF37,0xFF79,0xFE07,0xFE07,0x2901,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 9, 320 pixels 20 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7B03,0xFDE7,0xFE4B,0xFF79,0xFEF4,0xFF15,0xB552,0x2945,0x2945,0xDE55,0xFF16,0xFF15,0xFF58,0xFED1,0xFDE7,0xAC25,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 10, 352 pixels 21 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0840,0xDD26,0xFDE7,0xFF57,0xFED3,0xFED2,0xFEF4,0xBD93,0x2124,0x2124,0xDE75,0xFF14,0xFED3,0xFED3,0xFF7A,0xFE08,0xFDE7,0x49A2,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 11, 384 pixels 22 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x9BA4,0xFDC6,0xFE6E,0xFF36,0xFE90,0xFEB1,0xFED3,0xC592,0x2124,0x2124,0xE675,0xFED3,0xFEB2,0xFEB1,0xFEF3,0xFEF3,0xFDC6,0xBC45,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 12, 416 pixels 23 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3141,0xF5C6,0xF5C7,0xFF58,0xFE90,0xFE6F,0xFE8F,0xFEB1,0xCDB2,0x2104,0x2104,0xF6B4,0xFEB1,0xFE90,0xFE8F,0xFE90,0xFF58,0xFE0A,0xF5C6,0x72A3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 13, 448 pixels 24 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xABE4,0xF5A6,0xFEB1,0xFED3,0xFE4E,0xFE6E,0xFE6F,0xFE90,0xD5F2,0x18E3,0x18E3,0xFED4,0xFE90,0xFE6F,0xFE6F,0xFE6E,0xFE91,0xFF36,0xF5A6,0xCCA5,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 14, 480 pixels 25 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x5202,0xF5A6,0xF5C7,0xFF58,0xFE4D,0xFE4D,0xFE4D,0xFE4E,0xFE6F,0xDE11,0x18C3,0x18C3,0xFED3,0xFE6F,0xFE6E,0xFE4E,0xFE4D,0xFE4D,0xFF16,0xFE2C,0xF5A6,0x9363,0x0000,0x0000,0x0000,0x0000,0x0000, // row 15, 512 pixels 26 | 0x0000,0x0000,0x0000,0x0000,0x0000,0xBC44,0xF585,0xFED3,0xFE6F,0xFE2C,0xFE2C,0xFE2D,0xFE4D,0xFE4E,0xE630,0x10A2,0x2104,0xFED1,0xFE4E,0xFE4D,0xFE4D,0xFE2D,0xFE2C,0xFE4D,0xFF37,0xF586,0xF585,0x28E1,0x0000,0x0000,0x0000,0x0000, // row 16, 544 pixels 27 | 0x0000,0x0000,0x0000,0x0000,0x7282,0xF565,0xF5EA,0xFF16,0xFE0B,0xFE0B,0xFE0B,0xFE2C,0xFE2C,0xFE4D,0xF670,0x1082,0x2924,0xFEB0,0xFE2D,0xFE2C,0xFE2C,0xFE2C,0xFE0B,0xFE0B,0xFEB2,0xFE6F,0xF565,0xA383,0x0000,0x0000,0x0000,0x0000, // row 17, 576 pixels 28 | 0x0000,0x0000,0x0000,0x0840,0xD4C4,0xF565,0xFEF5,0xFE0C,0xFDE9,0xFDEA,0xFE0A,0xFE0B,0xFE0B,0xFE2C,0xFE8F,0x0861,0x2964,0xFE8F,0xFE2C,0xFE0B,0xFE0B,0xFE0B,0xFE0A,0xFDEA,0xFE0B,0xFF37,0xF586,0xF565,0x4181,0x0000,0x0000,0x0000, // row 18, 608 pixels 29 | 0x0000,0x0000,0x0000,0x9343,0xF545,0xF60C,0xFED3,0xFDC8,0xFDC8,0xFDC9,0xFDE9,0xFDEA,0xFDEA,0xFE0B,0xFE8E,0x0861,0x3184,0xFE6D,0xFE0B,0xFE0A,0xFDEA,0xFDEA,0xFDE9,0xFDC9,0xFDC9,0xFE4E,0xFEB2,0xF545,0xB3E3,0x0000,0x0000,0x0000, // row 19, 640 pixels 30 | 0x0000,0x0000,0x28E0,0xF544,0xF545,0xFF17,0xFDC8,0xFDA7,0xFDA7,0xFDC8,0xFDC8,0xFDC9,0xFDC9,0xFDE9,0xFE6C,0x10A2,0x39C4,0xFE4C,0xFDEA,0xFDE9,0xFDC9,0xFDC9,0xFDC8,0xFDC8,0xFDA7,0xFDA8,0xFF16,0xF588,0xF544,0x6222,0x0000,0x0000, // row 20, 672 pixels 31 | 0x0000,0x0000,0xA383,0xF524,0xF64E,0xFE4E,0xFD86,0xFD86,0xFD87,0xFDA7,0xFDA7,0xFDA8,0xFDC8,0xFDC8,0xFE2A,0xA469,0xB4EA,0xFE2A,0xFDC9,0xFDC8,0xFDC8,0xFDA8,0xFDA7,0xFDA7,0xFD87,0xFD86,0xFDEA,0xFED3,0xF524,0xC443,0x0000,0x0000, // row 21, 704 pixels 32 | 0x0000,0x51C1,0xF504,0xF546,0xFF16,0xF565,0xFD65,0xFD65,0xFD86,0xFD86,0xFD86,0xFDA7,0xFDA7,0xFDA7,0xFDE8,0xFE6A,0xFE4A,0xFDE8,0xFDA7,0xFDA7,0xFDA7,0xFDA7,0xFD86,0xFD86,0xFD86,0xFD65,0xFD65,0xFEB2,0xF5CA,0xF504,0x8AE2,0x0000, // row 22, 736 pixels 33 | 0x0000,0xB3A2,0xED03,0xFE92,0xFDC9,0xF543,0xF544,0xFD44,0xFD65,0xFD65,0xFD65,0xFD86,0xFD86,0xFD86,0xFDA7,0xFDC7,0xFDC7,0xFDA7,0xFD86,0xFD86,0xFD86,0xFD86,0xFD65,0xFD65,0xFD65,0xFD44,0xF544,0xFD86,0xFEF5,0xED03,0xE4C3,0x1880, // row 23, 768 pixels 34 | 0x7241,0xECE3,0xF567,0xFED3,0xF523,0xF523,0xF523,0xF543,0xF544,0xF544,0xFD65,0xFD65,0xFD65,0xFD65,0xD4E6,0x39C5,0x39A5,0xD4E6,0xFD86,0xFD65,0xFD65,0xFD65,0xFD65,0xF544,0xF544,0xF543,0xF523,0xF523,0xFE2E,0xF5EC,0xECE3,0x9B42, // row 24, 800 pixels 35 | 0xD443,0xECE3,0xFED4,0xF565,0xF502,0xF502,0xF522,0xF523,0xF523,0xF543,0xF544,0xF544,0xF544,0xFD65,0x8B64,0x18C3,0x18C3,0x8344,0xFD85,0xFD44,0xF544,0xF544,0xF544,0xF543,0xF523,0xF523,0xF522,0xF502,0xF523,0xFEF5,0xED04,0xECE3, // row 25, 832 pixels 36 | 0xECC3,0xF5AB,0xFE6F,0xF501,0xF4E1,0xF501,0xF502,0xF502,0xF522,0xF522,0xF523,0xF523,0xF523,0xFD84,0xC504,0x20E1,0x18E1,0xC4E4,0xFD84,0xF543,0xF523,0xF523,0xF523,0xF522,0xF522,0xF502,0xF502,0xF501,0xF501,0xFDC9,0xF62F,0xECC3, // row 26, 864 pixels 37 | 0xECC2,0xFE92,0xF523,0xF4E0,0xF4E0,0xF4E1,0xF4E1,0xF501,0xF501,0xF502,0xF502,0xF522,0xF522,0xF543,0xFDE3,0xFEA5,0xF6A4,0xFE04,0xF543,0xF522,0xF522,0xF522,0xF502,0xF502,0xF501,0xF501,0xF4E1,0xF4E1,0xF4E0,0xF4E1,0xFED4,0xECC2, // row 27, 896 pixels 38 | 0xECA2,0xF5EC,0xF4E0,0xF4C0,0xF4E0,0xF4E0,0xF4E0,0xF4E1,0xF4E1,0xF501,0xF501,0xF501,0xF502,0xF502,0xF542,0xFDA2,0xFDA2,0xF542,0xF502,0xF502,0xF502,0xF501,0xF501,0xF501,0xF4E1,0xF4E1,0xF4E0,0xF4E0,0xF4E0,0xF4C0,0xF5A9,0xECA2, // row 28, 928 pixels 39 | 0xECA2,0xECA2,0xECC2,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4E1,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xECC2,0xECC3,0xECA2, // row 29, 960 pixels 40 | 0x8AC1,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0x9B01, // row 30, 992 pixels 41 | 0x0000,0x1880,0x51A0,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x61E0,0x28E0,0x0000}; // row 31, 1024 pixels 42 | 43 | -------------------------------------------------------------------------------- /examples/Flash_Bitmap2/Close.h: -------------------------------------------------------------------------------- 1 | // We need this header file to use FLASH as storage with PROGMEM directive: 2 | #include 3 | 4 | // Icon width and height 5 | const uint16_t closeWidth = 32; 6 | const uint16_t closeHeight = 32; 7 | 8 | // The icon file can be created with the "UTFT ImageConverter 565" bitmap to .c file creation utility, more can be pasted in here 9 | const unsigned short close[1024] PROGMEM={ 10 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x30C3,0x4124,0x61C7,0x61C7,0x4124,0x30E3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 0, 32 pixels 11 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x48E3,0xA249,0xEB8E,0xFCB2,0xFD14,0xFD75,0xFD96,0xFD34,0xFCF3,0xEBEF,0xA28A,0x4904,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 1, 64 pixels 12 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x58E3,0xC228,0xFC10,0xFD34,0xFE18,0xFE59,0xFE79,0xFE9A,0xFE9A,0xFE9A,0xFE9A,0xFE59,0xFD75,0xFC51,0xC28A,0x5904,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 2, 96 pixels 13 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2041,0x8945,0xF34D,0xFD34,0xFDB6,0xFD75,0xFD55,0xFD55,0xFD96,0xFDD7,0xFDF7,0xFDF7,0xFDB6,0xFDB6,0xFDD7,0xFDF7,0xFD75,0xF38E,0x8965,0x2041,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 3, 128 pixels 14 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x4082,0xE208,0xF410,0xFD34,0xFC92,0xFBEF,0xFBAE,0xFBEF,0xFC71,0xFD14,0xFD75,0xFDB6,0xFD75,0xFD14,0xFC92,0xFC51,0xFC71,0xFCF3,0xFD75,0xFC30,0xEA28,0x40A2,0x0000,0x0000,0x0000,0x0000,0x0000, // row 4, 160 pixels 15 | 0x0000,0x0000,0x0000,0x0000,0x3861,0xE1E7,0xF451,0xFC92,0xFB4D,0xFA49,0xFA49,0xFAEB,0xFBAE,0xFC71,0xFD34,0xFDB6,0xFE18,0xFDB6,0xFD34,0xFC71,0xFBAE,0xFB0C,0xFAEB,0xFBAE,0xFCD3,0xFC71,0xE208,0x4082,0x0000,0x0000,0x0000,0x0000, // row 5, 192 pixels 16 | 0x0000,0x0000,0x0000,0x1020,0xD986,0xF430,0xFC30,0xFA28,0xF924,0xF965,0xFA8A,0xFB0C,0xFBAE,0xFC51,0xFD14,0xFD75,0xFDB6,0xFD75,0xFD14,0xFC51,0xFC71,0xFBEF,0xFA28,0xF9C7,0xFA8A,0xFC51,0xF430,0xD9A6,0x1020,0x0000,0x0000,0x0000, // row 6, 224 pixels 17 | 0x0000,0x0000,0x0000,0x78A2,0xEB6D,0xFC30,0xF9C7,0xF861,0xF8A2,0xFA08,0xFEDB,0xFD55,0xFB4D,0xFC10,0xFC92,0xFD14,0xFD34,0xFD14,0xFC92,0xFCB2,0xFF7D,0xFF7D,0xFB2C,0xF945,0xF8E3,0xF9E7,0xFC30,0xEB8E,0x78C3,0x0000,0x0000,0x0000, // row 7, 256 pixels 18 | 0x0000,0x0000,0x3841,0xD9E7,0xF492,0xF208,0xF041,0xF800,0xF945,0xFE9A,0xFFFF,0xFFFF,0xFD75,0xFB8E,0xFC10,0xFC51,0xFC71,0xFC51,0xFCB2,0xFF7D,0xFFFF,0xFFFF,0xFF3C,0xFA8A,0xF882,0xF841,0xFA08,0xFC92,0xDA08,0x3841,0x0000,0x0000, // row 8, 288 pixels 19 | 0x0000,0x0000,0x88A2,0xEBCF,0xF2EB,0xF061,0xF000,0xF8E3,0xFE79,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFD75,0xFB4D,0xFBAE,0xFBAE,0xFC71,0xFF7D,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFEFB,0xFA28,0xF800,0xF061,0xF2EB,0xEBEF,0x90C3,0x0000,0x0000, // row 9, 320 pixels 20 | 0x0000,0x2820,0xD1C7,0xF410,0xE945,0xE800,0xF000,0xFE9A,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFD34,0xFAEB,0xFBCF,0xFF5D,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFF1C,0xF986,0xF000,0xF145,0xF410,0xD1E7,0x2820,0x0000, // row 10, 352 pixels 21 | 0x0000,0x6841,0xDB2C,0xEACB,0xE041,0xE800,0xF000,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFD14,0xFF1C,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFBCF,0xF082,0xF000,0xE841,0xEACB,0xE34D,0x7061,0x0000, // row 11, 384 pixels 22 | 0x0000,0x9861,0xE3CF,0xE186,0xE000,0xE800,0xE800,0xF145,0xFEDB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFB8E,0xF000,0xF000,0xE800,0xE800,0xE986,0xEBCF,0xA082,0x0000, // row 12, 416 pixels 23 | 0x0800,0xB8A2,0xE3AE,0xD8A2,0xD800,0xE000,0xE800,0xE800,0xF145,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFB8E,0xF000,0xF000,0xE800,0xE800,0xE000,0xE0A2,0xEBAE,0xC0C3,0x0800, // row 13, 448 pixels 24 | 0x1800,0xC124,0xE30C,0xD020,0xD800,0xE000,0xE000,0xE800,0xE800,0xF145,0xFEDB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFB8E,0xF000,0xF000,0xE800,0xE800,0xE000,0xE000,0xD820,0xE30C,0xC124,0x1800, // row 14, 480 pixels 25 | 0x2800,0xC165,0xDAAA,0xC800,0xD000,0xD800,0xE000,0xE000,0xE800,0xE800,0xF124,0xFE79,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFB6D,0xF000,0xF000,0xE800,0xE800,0xE000,0xE000,0xD800,0xD000,0xDAAA,0xC165,0x2800, // row 15, 512 pixels 26 | 0x2000,0xB924,0xD269,0xC800,0xD000,0xD000,0xD800,0xE000,0xE000,0xE800,0xE924,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xF36D,0xE800,0xE800,0xE800,0xE000,0xE000,0xD800,0xD000,0xD000,0xDA69,0xC145,0x2800, // row 16, 544 pixels 27 | 0x1000,0xB0A2,0xD28A,0xC000,0xC800,0xD000,0xD000,0xD800,0xD800,0xE165,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xF3AE,0xE000,0xE000,0xD800,0xD800,0xD000,0xD000,0xC800,0xD28A,0xB8C3,0x1000, // row 17, 576 pixels 28 | 0x0000,0xA800,0xD2AA,0xB800,0xC000,0xC800,0xC800,0xD000,0xD965,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xEBAE,0xD800,0xD800,0xD000,0xC800,0xC800,0xC000,0xD2AA,0xB020,0x0000, // row 18, 608 pixels 29 | 0x0000,0x8000,0xCA69,0xB841,0xB800,0xC000,0xC800,0xD186,0xFEFB,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xEBCF,0xD000,0xC800,0xC800,0xC000,0xC041,0xCA69,0x8000,0x0000, // row 19, 640 pixels 30 | 0x0000,0x4800,0xC1C7,0xB8E3,0xB800,0xB800,0xC000,0xF69A,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xEBEF,0xFE79,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xE410,0xC841,0xC000,0xB800,0xC0E3,0xC1C7,0x4800,0x0000, // row 20, 672 pixels 31 | 0x0000,0x1000,0xB061,0xC1E7,0xB000,0xB000,0xB800,0xD269,0xFFBE,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xE38E,0xD000,0xD965,0xF69A,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xDB0C,0xC020,0xB800,0xB000,0xC1E7,0xB061,0x1000,0x0000, // row 21, 704 pixels 32 | 0x0000,0x0000,0x6000,0xB9C7,0xB061,0xB000,0xB000,0xB800,0xCA49,0xFF9E,0xFFFF,0xFFFF,0xFFFF,0xE38E,0xC800,0xC800,0xC800,0xD186,0xF69A,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xDB0C,0xB800,0xB800,0xB000,0xB061,0xC1C7,0x6000,0x0000,0x0000, // row 22, 736 pixels 33 | 0x0000,0x0000,0x1800,0xB041,0xB986,0xA800,0xA800,0xB000,0xB000,0xCA49,0xFF7D,0xFFFF,0xDB8E,0xC000,0xC000,0xC000,0xC000,0xC000,0xC986,0xF6DB,0xFFFF,0xFFFF,0xD30C,0xB800,0xB000,0xB000,0xA800,0xB986,0xB041,0x1800,0x0000,0x0000, // row 23, 768 pixels 34 | 0x0000,0x0000,0x0000,0x5800,0xB0E3,0xA8C3,0xA800,0xA800,0xA800,0xB000,0xCACB,0xD38E,0xB000,0xB800,0xB800,0xB800,0xB800,0xB800,0xB800,0xC145,0xF6DB,0xD34D,0xB000,0xB000,0xA800,0xA800,0xB0C3,0xB0E3,0x5800,0x0000,0x0000,0x0000, // row 24, 800 pixels 35 | 0x0000,0x0000,0x0000,0x0000,0x6000,0xB124,0xA882,0xA000,0xA800,0xA800,0xA800,0xA800,0xB000,0xB000,0xB000,0xB000,0xB000,0xB000,0xB000,0xB000,0xB000,0xA800,0xA800,0xA800,0xA800,0xA882,0xB124,0x6000,0x0000,0x0000,0x0000,0x0000, // row 25, 832 pixels 36 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x6000,0xB104,0xA882,0xA000,0xA000,0xA000,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA800,0xA000,0xA000,0xA882,0xB104,0x6000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 26, 864 pixels 37 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x6000,0xB0A2,0xA8C3,0xA020,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA000,0xA020,0xA8C3,0xB0A2,0x6000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 27, 896 pixels 38 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4800,0xA800,0xB0C3,0xA0A2,0x9800,0x9800,0x9800,0x9800,0xA000,0xA000,0xA000,0x9800,0x9800,0x9800,0xA082,0xB0E3,0xA800,0x4800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 28, 928 pixels 39 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x5800,0xA800,0xB0A2,0xA8E3,0xA0A2,0xA041,0x9800,0x9800,0xA041,0xA0A2,0xA8E3,0xB0A2,0xA800,0x5800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 29, 960 pixels 40 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3000,0x6000,0x8800,0xA000,0xA800,0xA800,0xA000,0x8800,0x6000,0x3000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 30, 992 pixels 41 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}; // row 31, 1024 pixels 42 | -------------------------------------------------------------------------------- /examples/Flash_Bitmap2/Flash_Bitmap2.ino: -------------------------------------------------------------------------------- 1 | // Code partly derived from ILI9341_Due library example 2 | 3 | // Draws the 3 icons across the middle of the screen and pauses. 4 | // Then draws 300 icons at random locations, clears screen and repeats 5 | // 6 | // This demonstrates drawing icons from FLASH 7 | 8 | // Icons are stored in tabs, e.g. Alert.h etc 9 | // more than one icon can be in a header file. 10 | 11 | /* 12 | This sketch demonstrates loading images from arrays stored in program (FLASH) memory. 13 | 14 | This sketch does not use/need any fonts at all... 15 | 16 | Arrays containing FLASH images can be created with UTFT library tool: 17 | (libraries\UTFT\Tools\ImageConverter565.exe) 18 | Convert to .c format then copy into a new tab 19 | 20 | The number and size of icons is limited by available FLASH memory. The icon array will 21 | use width x height x 2 bytes of FLASH, i.e. 32 x 32 icon uses ~2048 bytes 22 | 23 | */ 24 | #include // Graphics and font library for ST7735 driver chip 25 | #include 26 | 27 | TFT_ST7735 tft = TFT_ST7735(); // Invoke library, pins defined in User_Setup.h 28 | 29 | // Include the header files that contain the icons 30 | #include "alert.h" 31 | #include "Close.h" 32 | #include "Info.h" 33 | 34 | long count = 0; // Loop count 35 | 36 | void setup() 37 | { 38 | Serial.begin(115200); 39 | tft.init(); 40 | tft.setRotation(1); // landscape 41 | 42 | tft.fillScreen(TFT_BLACK); 43 | 44 | // Draw the icons 45 | drawIcon(info, (tft.width() - infoWidth)/2 - 50, (tft.height() - infoHeight)/2, infoWidth, infoHeight); 46 | drawIcon(alert, (tft.width() - alertWidth)/2, (tft.height() - alertHeight)/2, alertWidth, alertHeight); 47 | drawIcon(close, (tft.width() - closeWidth)/2 + 50, (tft.height() - closeHeight)/2, closeWidth, closeHeight); 48 | 49 | // Pause here to admire the icons! 50 | delay(4000); 51 | 52 | } 53 | 54 | void loop() 55 | { 56 | // Loop filling and clearing screen 57 | drawIcon(info, random(tft.width() - infoWidth), random(tft.height() - infoHeight), infoWidth, infoHeight); 58 | drawIcon(alert, random(tft.width() - alertWidth), random(tft.height() - alertHeight), alertWidth, alertHeight); 59 | drawIcon(close, random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight); 60 | 61 | // Clear screen after 100 x 3 = 300 icons drawn 62 | if (100 == count++) { 63 | count = 1; 64 | tft.setRotation(2 * random(2)); // Rotate randomly to clear display left>right or right>left to reduce monotony! 65 | tft.fillScreen(TFT_BLACK); 66 | tft.setRotation(1); 67 | Serial.println(millis()); 68 | } 69 | } 70 | 71 | 72 | //==================================================================================== 73 | // This is the function to draw the icon stored as an array in program memory (FLASH) 74 | //==================================================================================== 75 | 76 | // To speed up rendering we use a 64 pixel buffer 77 | #define BUFF_SIZE 64 78 | 79 | // Draw array "icon" of defined width and height at coordinate x,y 80 | // Maximum icon size is 255x255 pixels to avoid integer overflow 81 | 82 | void drawIcon(const unsigned short* icon, int16_t x, int16_t y, int8_t width, int8_t height) { 83 | 84 | uint16_t pix_buffer[BUFF_SIZE]; // Pixel buffer (16 bits per pixel) 85 | 86 | // Set up a window the right size to stream pixels into 87 | tft.setAddrWindow(x, y, x + width - 1, y + height - 1); 88 | 89 | // Work out the number whole buffers to send 90 | uint16_t nb = ((uint16_t)height * width) / BUFF_SIZE; 91 | 92 | // Fill and send "nb" buffers to TFT 93 | for (int i = 0; i < nb; i++) { 94 | for (int j = 0; j < BUFF_SIZE; j++) { 95 | pix_buffer[j] = pgm_read_word(&icon[i * BUFF_SIZE + j]); 96 | } 97 | tft.pushColors(pix_buffer, BUFF_SIZE); 98 | } 99 | 100 | // Work out number of pixels not yet sent 101 | uint16_t np = ((uint16_t)height * width) % BUFF_SIZE; 102 | 103 | // Send any partial buffer left over 104 | if (np) { 105 | for (int i = 0; i < np; i++) pix_buffer[i] = pgm_read_word(&icon[nb * BUFF_SIZE + i]); 106 | tft.pushColors(pix_buffer, np); 107 | } 108 | } 109 | 110 | -------------------------------------------------------------------------------- /examples/Flash_Bitmap2/Info.h: -------------------------------------------------------------------------------- 1 | // We need this header file to use FLASH as storage with PROGMEM directive: 2 | #include 3 | 4 | // Icon width and height 5 | const uint16_t infoWidth = 32; 6 | const uint16_t infoHeight = 32; 7 | 8 | // The icon file can be created with the "UTFT ImageConverter 565" bitmap to .c file creation utility, more can be pasted in here 9 | const unsigned short info[1024] PROGMEM={ 10 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 0, 32 pixels 11 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0861,0x4A69,0x8C71,0xA514,0xBDF7,0xBDF7,0xA514,0x8C71,0x4A69,0x0861,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 1, 64 pixels 12 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x39E7,0x9CF3,0xEF7D,0xF79E,0xFFDF,0xFFDF,0xFFDF,0xFFDF,0xFFDF,0xFFDF,0xF79E,0xEF7D,0x9CF3,0x39E7,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 2, 96 pixels 13 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2965,0x9492,0xF79E,0xFFDF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFDF,0xF79E,0x9492,0x2965,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 3, 128 pixels 14 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x630C,0xEF7D,0xFFDF,0xFFFF,0xFFFF,0xFFFF,0xD75F,0xB6BF,0x9E5F,0x963F,0x963F,0x9E5F,0xB6BF,0xD75F,0xFFFF,0xFFFF,0xFFFF,0xFFDF,0xEF7D,0x630C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 4, 160 pixels 15 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x73AE,0xEF7D,0xFFDF,0xFFFF,0xFFDF,0xBEDF,0x7DBF,0x7DBF,0x7DDF,0x7DDF,0x7DDF,0x7DDF,0x7DDF,0x7DBF,0x759F,0x7DBE,0xBEBF,0xFFDF,0xFFFF,0xFFDF,0xEF7D,0x73AE,0x0000,0x0000,0x0000,0x0000,0x0000, // row 5, 192 pixels 16 | 0x0000,0x0000,0x0000,0x0000,0x630C,0xEF7D,0xFFFF,0xFFFF,0xE77F,0x7DBE,0x759E,0x759F,0x7DBF,0x7DDF,0x7DDF,0x85FF,0x7DDF,0x7DDF,0x7DBF,0x759F,0x759E,0x6D7E,0x7DBE,0xDF7F,0xFFFF,0xFFFF,0xEF7D,0x630C,0x0000,0x0000,0x0000,0x0000, // row 6, 224 pixels 17 | 0x0000,0x0000,0x0000,0x31A6,0xEF5D,0xFFDF,0xFFFF,0xCF1E,0x6D7E,0x6D7E,0x759E,0x759F,0x7DBF,0x7DDF,0x8E1F,0xBEDF,0xC6FF,0x8DFF,0x75BF,0x759F,0x759E,0x6D7E,0x655E,0x655D,0xCF1E,0xFFFF,0xFFDF,0xEF5D,0x31A6,0x0000,0x0000,0x0000, // row 7, 256 pixels 18 | 0x0000,0x0000,0x0000,0x94B2,0xF7BE,0xFFFF,0xDF5E,0x655D,0x655D,0x6D7E,0x6D7E,0x759E,0x75BF,0x759F,0xEFBF,0xFFFF,0xFFFF,0xEFBF,0x759F,0x759E,0x6D7E,0x6D7E,0x655D,0x653D,0x653D,0xDF5E,0xFFFF,0xF7BE,0x94B2,0x0000,0x0000,0x0000, // row 8, 288 pixels 19 | 0x0000,0x0000,0x4228,0xEF7D,0xFFFF,0xF7BF,0x6D5D,0x653D,0x655D,0x6D5E,0x6D7E,0x759E,0x759E,0x85DF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8DFE,0x6D7E,0x6D7E,0x6D5E,0x655D,0x653D,0x5D1D,0x6D5D,0xF7BF,0xFFFF,0xEF7D,0x4228,0x0000,0x0000, // row 9, 320 pixels 20 | 0x0000,0x0000,0xA534,0xFFDF,0xFFDF,0xA65D,0x5D1D,0x5D1D,0x653D,0x655E,0x6D7E,0x6D7E,0x6D7E,0x651E,0xE77F,0xFFFF,0xFFFF,0xF7BF,0x5CFE,0x6D7E,0x6D7E,0x655E,0x653D,0x5D1D,0x5D1D,0x54FC,0xA65D,0xFFDF,0xFFDF,0xA534,0x0000,0x0000, // row 10, 352 pixels 21 | 0x0000,0x18E3,0xEF5D,0xFFFF,0xEF9E,0x5CFC,0x54FC,0x5D1D,0x5D3D,0x653D,0x655E,0x6D7E,0x6D7E,0x653E,0x6D3E,0xB67E,0xBEBE,0x755E,0x5D1E,0x6D5E,0x655E,0x653D,0x5D3D,0x5D1D,0x54FC,0x54DC,0x54FC,0xEF9E,0xFFFF,0xEF5D,0x18E3,0x0000, // row 11, 384 pixels 22 | 0x0000,0x630C,0xEF7D,0xFFDF,0xB69D,0x54DC,0x54FC,0x5CFC,0x5D1D,0x653D,0x653D,0x655E,0x6D5E,0x655E,0x5CFE,0x4C9D,0x4C7D,0x54DD,0x653E,0x655E,0x653D,0x653D,0x5D1D,0x5CFC,0x54FC,0x54DC,0x4CBC,0xB69D,0xFFDF,0xEF7D,0x630C,0x0000, // row 12, 416 pixels 23 | 0x0000,0x94B2,0xF7BE,0xFFDF,0x85BC,0x4CBC,0x54DC,0x54FC,0x5CFD,0x5D1D,0x5D3D,0x653D,0x655D,0x653D,0x85DE,0xC6FE,0xC6FE,0x85BE,0x653D,0x653D,0x5D3D,0x5D1D,0x5CFD,0x54FC,0x54DC,0x4CBC,0x4CBB,0x85BC,0xFFDF,0xF7BE,0x94B2,0x0000, // row 13, 448 pixels 24 | 0x0000,0xB5B6,0xFFDF,0xF7BE,0x651C,0x4CBB,0x4CBC,0x54DC,0x54FC,0x5CFC,0x5D1D,0x5D1D,0x653D,0x5D1D,0xE77E,0xFFDF,0xFFDF,0xEF9E,0x5CFD,0x5D1D,0x5D1D,0x5CFC,0x54FC,0x54DC,0x4CBC,0x4CBB,0x449B,0x651B,0xF7BE,0xFFDF,0xB5B6,0x0000, // row 14, 480 pixels 25 | 0x0000,0xC638,0xFFDF,0xF7BE,0x54DB,0x449B,0x4CBB,0x4CBC,0x54DC,0x54FC,0x54FC,0x5D1D,0x5D1D,0x7D7D,0xF7BE,0xF7BE,0xF7BE,0xF7BE,0x7D7D,0x5CFD,0x54FC,0x54FC,0x54DC,0x4CBC,0x4CBB,0x449B,0x447B,0x54BB,0xF7BE,0xFFDF,0xC638,0x0000, // row 15, 512 pixels 26 | 0x0000,0xC638,0xFFDF,0xF79E,0x4CBB,0x449B,0x449B,0x4CBB,0x4CBC,0x54DC,0x54DC,0x54FC,0x54DC,0x753C,0xF7BE,0xF7BE,0xF7BE,0xF7BE,0x753C,0x54DC,0x54DC,0x54DC,0x4CBC,0x4CBB,0x449B,0x449B,0x3C7B,0x4C9B,0xF79E,0xFFDF,0xC638,0x0000, // row 16, 544 pixels 27 | 0x0000,0xB5B6,0xFFDF,0xF7BE,0x5CFB,0x3C7B,0x447B,0x449B,0x4CBB,0x4CBC,0x4CBC,0x4CDC,0x4CBC,0x6D1C,0xF7BE,0xF7BE,0xF7BE,0xF7BE,0x6CFC,0x4CBC,0x4CBC,0x4CBC,0x4CBB,0x449B,0x447B,0x3C7B,0x3C5A,0x54DB,0xF7BE,0xFFDF,0xB5B6,0x0000, // row 17, 576 pixels 28 | 0x0000,0x94B2,0xF7BE,0xF7BE,0x755B,0x3C5A,0x3C7B,0x447B,0x449B,0x449B,0x4CBB,0x4CBB,0x4C9B,0x6CFB,0xF79E,0xF79E,0xF79E,0xF79E,0x64FB,0x449B,0x4CBB,0x449B,0x449B,0x447B,0x3C7B,0x3C5A,0x3C5A,0x753B,0xF7BE,0xF7BE,0x9CD3,0x0000, // row 18, 608 pixels 29 | 0x0000,0x6B4D,0xEF7D,0xF7BE,0xA61C,0x3C5A,0x3C5A,0x3C7B,0x447B,0x447B,0x449B,0x449B,0x447B,0x64DB,0xF79E,0xF79E,0xF79E,0xF79E,0x64DB,0x447B,0x449B,0x447B,0x447B,0x3C7B,0x3C5A,0x3C5A,0x343A,0xA61C,0xF7BE,0xEF7D,0x6B4D,0x0000, // row 19, 640 pixels 30 | 0x0000,0x2124,0xE71C,0xFFDF,0xDF3D,0x3C5A,0x343A,0x3C5A,0x3C5A,0x3C7B,0x3C7B,0x447B,0x3C5B,0x64BA,0xF79E,0xF79E,0xF79E,0xF79E,0x64BA,0x3C5B,0x3C7B,0x3C7B,0x3C5A,0x3C5A,0x343A,0x343A,0x343A,0xDF3D,0xFFDF,0xE71C,0x2124,0x0000, // row 20, 672 pixels 31 | 0x0000,0x0000,0xAD75,0xF7BE,0xF79E,0x859B,0x343A,0x343A,0x345A,0x3C5A,0x3C5A,0x3C5A,0x3C5A,0x5C9A,0xEF7D,0xEF7D,0xEF7D,0xEF7D,0x5C9A,0x3C3A,0x3C5A,0x3C5A,0x345A,0x343A,0x343A,0x341A,0x859B,0xF79E,0xF7BE,0xAD75,0x0000,0x0000, // row 21, 704 pixels 32 | 0x0000,0x0000,0x528A,0xE71C,0xFFDF,0xDF3D,0x3C5A,0x343A,0x343A,0x343A,0x343A,0x3C5A,0x343A,0x4C5A,0xEF7D,0xEF7D,0xEF7D,0xEF7D,0x4C59,0x343A,0x343A,0x343A,0x343A,0x343A,0x341A,0x3C5A,0xDF3D,0xFFDF,0xE71C,0x528A,0x0000,0x0000, // row 22, 736 pixels 33 | 0x0000,0x0000,0x0000,0x9CD3,0xF79E,0xF7BE,0xBE7C,0x3419,0x341A,0x341A,0x343A,0x343A,0x341A,0x2B99,0xC69C,0xEF7D,0xEF7D,0xD6DC,0x2398,0x341A,0x343A,0x341A,0x341A,0x2C19,0x2C19,0xBE7C,0xF7BE,0xF79E,0x9CD3,0x0000,0x0000,0x0000, // row 23, 768 pixels 34 | 0x0000,0x0000,0x0000,0x39E7,0xDEDB,0xFFDF,0xF79E,0x9DFB,0x2C19,0x2C19,0x2C1A,0x341A,0x341A,0x2BB9,0x2B57,0x6459,0x74B9,0x2337,0x2BB9,0x341A,0x2C1A,0x2C19,0x2C19,0x2C19,0x9DFB,0xF79E,0xFFDF,0xDEDB,0x39E7,0x0000,0x0000,0x0000, // row 24, 800 pixels 35 | 0x0000,0x0000,0x0000,0x0000,0x632C,0xDEFB,0xFFDF,0xEF7D,0xB65C,0x3C39,0x2BF9,0x2C19,0x2C19,0x2BF9,0x2398,0x1B58,0x1B37,0x2398,0x2BF9,0x2C19,0x2BF9,0x2BF9,0x3439,0xB65C,0xEF7D,0xFFDF,0xDEFB,0x632C,0x0000,0x0000,0x0000,0x0000, // row 25, 832 pixels 36 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x73AE,0xDEFB,0xF7BE,0xF79E,0xDF1C,0x7D5A,0x2BF9,0x2BF9,0x2BF9,0x2BF9,0x23D9,0x23D9,0x2BF9,0x2BF9,0x2BF9,0x2BF9,0x7D5A,0xDF1C,0xF79E,0xF7BE,0xDEFB,0x73AE,0x0000,0x0000,0x0000,0x0000,0x0000, // row 26, 864 pixels 37 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x632C,0xDEDB,0xF79E,0xFFDF,0xEF7D,0xD6FC,0x9DFB,0x5CDA,0x4C9A,0x3419,0x3419,0x4C9A,0x5CDA,0x9DFB,0xD6FC,0xEF7D,0xFFDF,0xF79E,0xDEDB,0x632C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 27, 896 pixels 38 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4208,0x94B2,0xDEFB,0xF7BE,0xFFDF,0xF7BE,0xF79E,0xEF7D,0xEF5D,0xEF5D,0xEF7D,0xF79E,0xF7BE,0xFFDF,0xF7BE,0xDEFB,0x94B2,0x4208,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 28, 928 pixels 39 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x528A,0xA534,0xDEDB,0xE73C,0xF79E,0xF7BE,0xF7BE,0xF7BE,0xF7BE,0xF79E,0xE73C,0xDEDB,0xA534,0x528A,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 29, 960 pixels 40 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x18C3,0x5AEB,0x8C71,0xAD55,0xBDD7,0xBDD7,0xAD55,0x8C71,0x5AEB,0x18C3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 30, 992 pixels 41 | 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}; // row 31, 1024 pixels 42 | -------------------------------------------------------------------------------- /examples/Pong_v3/Pong_v3.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Pong 3 | * Original Code from https://github.com/rparrett/pongclock 4 | * 5 | */ 6 | 7 | #define BLACK 0x0000 8 | #define WHITE 0xFFFF 9 | #define GREY 0x5AEB 10 | 11 | #include // Graphics and font library for ST7735 driver chip 12 | #include 13 | 14 | TFT_ST7735 tft = TFT_ST7735(); // Invoke library, pins defined in User_Setup.h 15 | 16 | int16_t h = 128; 17 | int16_t w = 160; 18 | 19 | int dly = 5; 20 | 21 | int16_t paddle_h = 25; 22 | int16_t paddle_w = 2; 23 | 24 | int16_t lpaddle_x = 0; 25 | int16_t rpaddle_x = w - paddle_w; 26 | 27 | int16_t lpaddle_y = 0; 28 | int16_t rpaddle_y = h - paddle_h; 29 | 30 | int16_t lpaddle_d = 1; 31 | int16_t rpaddle_d = -1; 32 | 33 | int16_t lpaddle_ball_t = w - w / 4; 34 | int16_t rpaddle_ball_t = w / 4; 35 | 36 | int16_t target_y = 0; 37 | 38 | int16_t ball_x = 2; 39 | int16_t ball_y = 2; 40 | int16_t oldball_x = 2; 41 | int16_t oldball_y = 2; 42 | 43 | int16_t ball_dx = 1; 44 | int16_t ball_dy = 1; 45 | 46 | int16_t ball_w = 4; 47 | int16_t ball_h = 4; 48 | 49 | int16_t dashline_h = 4; 50 | int16_t dashline_w = 2; 51 | int16_t dashline_n = h / dashline_h; 52 | int16_t dashline_x = w / 2 - 1; 53 | int16_t dashline_y = dashline_h / 2; 54 | 55 | int16_t lscore = 12; 56 | int16_t rscore = 4; 57 | 58 | void setup(void) { 59 | 60 | randomSeed(analogRead(0)*analogRead(1)); 61 | 62 | tft.init(); 63 | 64 | tft.setRotation(1); 65 | 66 | tft.fillScreen(BLACK); 67 | 68 | initgame(); 69 | 70 | tft.setTextColor(WHITE, BLACK); 71 | 72 | delay(2000); 73 | 74 | } 75 | 76 | void loop() { 77 | delay(dly); 78 | 79 | lpaddle(); 80 | rpaddle(); 81 | 82 | midline(); 83 | 84 | ball(); 85 | } 86 | 87 | void initgame() { 88 | lpaddle_y = random(0, h - paddle_h); 89 | rpaddle_y = random(0, h - paddle_h); 90 | 91 | // ball is placed on the center of the left paddle 92 | ball_y = lpaddle_y + (paddle_h / 2); 93 | 94 | calc_target_y(); 95 | 96 | midline(); 97 | 98 | tft.fillRect(0,h-26,w,h-1,BLACK); 99 | 100 | tft.setTextDatum(TC_DATUM); 101 | tft.setTextColor(WHITE,GREY); 102 | tft.drawString("TFT_ST7735 example", w/2, h-26 , 2); 103 | } 104 | 105 | void midline() { 106 | 107 | // If the ball is not on the line then don't redraw the line 108 | if ((ball_x dashline_x+dashline_w)) return; 109 | 110 | // Quick way to draw a dashed line 111 | tft.setAddrWindow(dashline_x,0,dashline_x+dashline_w-1,h); 112 | 113 | for(int16_t i = 0; i < dashline_n; i+=2) { 114 | tft.pushColor(WHITE, dashline_w*dashline_h); // push dash pixels 115 | tft.pushColor(BLACK, dashline_w*dashline_h); // push gap pixels 116 | } 117 | } 118 | 119 | void lpaddle() { 120 | 121 | if (lpaddle_d == 1) { 122 | tft.fillRect(lpaddle_x, lpaddle_y, paddle_w, 1, BLACK); 123 | } 124 | else if (lpaddle_d == -1) { 125 | tft.fillRect(lpaddle_x, lpaddle_y + paddle_h - 1, paddle_w, 1, BLACK); 126 | } 127 | 128 | lpaddle_y = lpaddle_y + lpaddle_d; 129 | 130 | if (ball_dx == 1) lpaddle_d = 0; 131 | else { 132 | if (lpaddle_y + paddle_h / 2 == target_y) lpaddle_d = 0; 133 | else if (lpaddle_y + paddle_h / 2 > target_y) lpaddle_d = -1; 134 | else lpaddle_d = 1; 135 | } 136 | 137 | if (lpaddle_y + paddle_h >= h && lpaddle_d == 1) lpaddle_d = 0; 138 | else if (lpaddle_y <= 0 && lpaddle_d == -1) lpaddle_d = 0; 139 | 140 | tft.fillRect(lpaddle_x, lpaddle_y, paddle_w, paddle_h, WHITE); 141 | } 142 | 143 | void rpaddle() { 144 | 145 | if (rpaddle_d == 1) { 146 | tft.fillRect(rpaddle_x, rpaddle_y, paddle_w, 1, BLACK); 147 | } 148 | else if (rpaddle_d == -1) { 149 | tft.fillRect(rpaddle_x, rpaddle_y + paddle_h - 1, paddle_w, 1, BLACK); 150 | } 151 | 152 | rpaddle_y = rpaddle_y + rpaddle_d; 153 | 154 | if (ball_dx == -1) rpaddle_d = 0; 155 | else { 156 | if (rpaddle_y + paddle_h / 2 == target_y) rpaddle_d = 0; 157 | else if (rpaddle_y + paddle_h / 2 > target_y) rpaddle_d = -1; 158 | else rpaddle_d = 1; 159 | } 160 | 161 | if (rpaddle_y + paddle_h >= h && rpaddle_d == 1) rpaddle_d = 0; 162 | else if (rpaddle_y <= 0 && rpaddle_d == -1) rpaddle_d = 0; 163 | 164 | tft.fillRect(rpaddle_x, rpaddle_y, paddle_w, paddle_h, WHITE); 165 | } 166 | 167 | void calc_target_y() { 168 | int16_t target_x; 169 | int16_t reflections; 170 | int16_t y; 171 | 172 | if (ball_dx == 1) { 173 | target_x = w - ball_w; 174 | } 175 | else { 176 | target_x = -1 * (w - ball_w); 177 | } 178 | 179 | y = abs(target_x * (ball_dy / ball_dx) + ball_y); 180 | 181 | reflections = floor(y / h); 182 | 183 | if (reflections % 2 == 0) { 184 | target_y = y % h; 185 | } 186 | else { 187 | target_y = h - (y % h); 188 | } 189 | } 190 | 191 | void ball() { 192 | ball_x = ball_x + ball_dx; 193 | ball_y = ball_y + ball_dy; 194 | 195 | if (ball_dx == -1 && ball_x == paddle_w && ball_y + ball_h >= lpaddle_y && ball_y <= lpaddle_y + paddle_h) { 196 | ball_dx = ball_dx * -1; 197 | dly = random(5); // change speed of ball after paddle contact 198 | calc_target_y(); 199 | } else if (ball_dx == 1 && ball_x + ball_w == w - paddle_w && ball_y + ball_h >= rpaddle_y && ball_y <= rpaddle_y + paddle_h) { 200 | ball_dx = ball_dx * -1; 201 | dly = random(5); // change speed of ball after paddle contact 202 | calc_target_y(); 203 | } else if ((ball_dx == 1 && ball_x >= w) || (ball_dx == -1 && ball_x + ball_w < 0)) { 204 | dly = 5; 205 | } 206 | 207 | if (ball_y > h - ball_w || ball_y < 0) { 208 | ball_dy = ball_dy * -1; 209 | ball_y += ball_dy; // Keep in bounds 210 | } 211 | 212 | //tft.fillRect(oldball_x, oldball_y, ball_w, ball_h, BLACK); 213 | tft.drawRect(oldball_x, oldball_y, ball_w, ball_h, BLACK); // Less TFT refresh aliasing than line above for large balls 214 | tft.fillRect( ball_x, ball_y, ball_w, ball_h, WHITE); 215 | oldball_x = ball_x; 216 | oldball_y = ball_y; 217 | } 218 | 219 | -------------------------------------------------------------------------------- /examples/RLE_Font_test/RLE_Font_test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Display all the fonts. 3 | 4 | This sketch uses the GLCD (font 1) and fonts 2, 4, 6, 7, 8 5 | 6 | Make sure all the required fonts are loaded by editting the 7 | User_Setup.h file in the TFT_ST7735 library folder. 8 | 9 | If using an UNO or Mega (ATmega328 or ATmega2560 processor) then for best 10 | performance use the F_AS_T option found in the User_Setup.h file in the 11 | TFT_ST7735 library folder. 12 | 13 | The library uses the hardware SPI pins only: 14 | For UNO, Nano, Micro Pro ATmega328 based processors 15 | MOSI = pin 11, SCK = pin 13 16 | For Mega: 17 | MOSI = pin 51, SCK = pin 52 18 | 19 | The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST) 20 | signal lines to the TFT must also be defined in the library User_Setup.h file. 21 | 22 | Sugested TFT connections for UNO and Atmega328 based boards 23 | sclk 13 // Don't change, this is the hardware SPI SCLK line 24 | mosi 11 // Don't change, this is the hardware SPI MOSI line 25 | cs 10 // Chip select for TFT display 26 | dc 9 // Data/command line 27 | rst 7 // Reset, you could connect this to the Arduino reset pin 28 | 29 | Suggested TFT connections for the MEGA and ATmega2560 based boards 30 | sclk 52 // Don't change, this is the hardware SPI SCLK line 31 | mosi 51 // Don't change, this is the hardware SPI MOSI line 32 | cs 47 // TFT chip select line 33 | dc 48 // TFT data/command line 34 | rst 44 // you could alternatively connect this to the Arduino reset 35 | 36 | ######################################################################### 37 | ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 38 | ###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ###### 39 | ######################################################################### 40 | */ 41 | 42 | // New background colour 43 | #define TFT_BROWN 0x38E0 44 | 45 | // Pause in milliseconds between screens, change to 0 to time font rendering 46 | #define WAIT 500 47 | 48 | #include // Graphics and font library for ST7735 driver chip 49 | #include 50 | 51 | TFT_ST7735 tft = TFT_ST7735(); // Invoke library, pins defined in User_Setup.h 52 | 53 | unsigned long targetTime = 0; // Used for testing draw times 54 | 55 | void setup(void) { 56 | tft.init(); 57 | tft.setRotation(1); 58 | } 59 | 60 | void loop() { 61 | targetTime = millis(); 62 | 63 | // First we test them with a background colour set 64 | tft.setTextSize(1); 65 | tft.fillScreen(TFT_BLACK); 66 | tft.setTextColor(TFT_GREEN, TFT_BLACK); 67 | 68 | tft.drawString(" !\"#$%&'()*+,-./0123456", 0, 0, 2); 69 | tft.drawString("789:;<=>?@ABCDEFGHIJKL", 0, 16, 2); 70 | tft.drawString("MNOPQRSTUVWXYZ[\\]^_`", 0, 32, 2); 71 | tft.drawString("abcdefghijklmnopqrstuvw", 0, 48, 2); 72 | int xpos = 0; 73 | xpos += tft.drawString("xyz{|}~", 0, 64, 2); 74 | tft.drawChar(127, xpos, 64, 2); 75 | delay(WAIT); 76 | 77 | tft.fillScreen(TFT_BLACK); 78 | tft.setTextColor(TFT_GREEN, TFT_BLACK); 79 | 80 | tft.drawString(" !\"#$%&'()*+,-.", 0, 0, 4); 81 | tft.drawString("/0123456789:;", 0, 26, 4); 82 | tft.drawString("<=>?@ABCDE", 0, 52, 4); 83 | tft.drawString("FGHIJKLMNO", 0, 78, 4); 84 | tft.drawString("PQRSTUVWX", 0, 104, 4); 85 | delay(WAIT); 86 | 87 | tft.fillScreen(TFT_BLACK); 88 | tft.drawString("YZ[\\]^_`abc", 0, 0, 4); 89 | tft.drawString("defghijklmno", 0, 26, 4); 90 | tft.drawString("pqrstuvwxyz", 0, 52, 4); 91 | xpos = 0; 92 | xpos += tft.drawString("{|}~", 0, 78, 4); 93 | tft.drawChar(127, xpos, 78, 4); 94 | delay(WAIT); 95 | 96 | tft.fillScreen(TFT_BLACK); 97 | tft.setTextColor(TFT_BLUE, TFT_BLACK); 98 | 99 | tft.drawString("012345", 0, 0, 6); 100 | tft.drawString("6789", 0, 40, 6); 101 | tft.drawString("apm-:.", 0, 80, 6); 102 | delay(WAIT); 103 | 104 | tft.fillScreen(TFT_BLACK); 105 | tft.setTextColor(TFT_RED, TFT_BLACK); 106 | 107 | tft.drawString("0123", 0, 0, 7); 108 | tft.drawString("4567", 0, 60, 7); 109 | delay(WAIT); 110 | 111 | tft.fillScreen(TFT_BLACK); 112 | tft.drawString("890:.", 0, 0, 7); 113 | tft.drawString("", 0, 60, 7); 114 | delay(WAIT); 115 | 116 | tft.fillScreen(TFT_BLACK); 117 | tft.setTextColor(TFT_YELLOW, TFT_BLACK); 118 | 119 | tft.drawString("01", 0, 0, 8); 120 | delay(WAIT); 121 | 122 | tft.drawString("23", 0, 0, 8); 123 | delay(WAIT); 124 | 125 | tft.drawString("45", 0, 0, 8); 126 | delay(WAIT); 127 | 128 | tft.drawString("67", 0, 0, 8); 129 | delay(WAIT); 130 | 131 | tft.drawString("89", 0, 0, 8); 132 | delay(WAIT); 133 | 134 | tft.drawString("0:.", 0, 0, 8); 135 | delay(WAIT); 136 | 137 | tft.setTextColor(TFT_MAGENTA); 138 | tft.drawNumber(millis() - targetTime, 0, 100, 4); 139 | delay(4000); 140 | 141 | // Now test them with transparent background 142 | targetTime = millis(); 143 | 144 | tft.setTextSize(1); 145 | tft.fillScreen(TFT_BROWN); 146 | tft.setTextColor(TFT_GREEN); 147 | 148 | tft.drawString(" !\"#$%&'()*+,-./0123456", 0, 0, 2); 149 | tft.drawString("789:;<=>?@ABCDEFGHIJKL", 0, 16, 2); 150 | tft.drawString("MNOPQRSTUVWXYZ[\\]^_`", 0, 32, 2); 151 | tft.drawString("abcdefghijklmnopqrstuvw", 0, 48, 2); 152 | xpos = 0; 153 | xpos += tft.drawString("xyz{|}~", 0, 64, 2); 154 | tft.drawChar(127, xpos, 64, 2); 155 | delay(WAIT); 156 | 157 | tft.fillScreen(TFT_BROWN); 158 | tft.setTextColor(TFT_GREEN); 159 | 160 | tft.drawString(" !\"#$%&'()*+,-.", 0, 0, 4); 161 | tft.drawString("/0123456789:;", 0, 26, 4); 162 | tft.drawString("<=>?@ABCDE", 0, 52, 4); 163 | tft.drawString("FGHIJKLMNO", 0, 78, 4); 164 | tft.drawString("PQRSTUVWX", 0, 104, 4); 165 | 166 | delay(WAIT); 167 | tft.fillScreen(TFT_BROWN); 168 | tft.drawString("YZ[\\]^_`abc", 0, 0, 4); 169 | tft.drawString("defghijklmno", 0, 26, 4); 170 | tft.drawString("pqrstuvwxyz", 0, 52, 4); 171 | xpos = 0; 172 | xpos += tft.drawString("{|}~", 0, 78, 4); 173 | tft.drawChar(127, xpos, 78, 4); 174 | delay(WAIT); 175 | 176 | tft.fillScreen(TFT_BROWN); 177 | tft.setTextColor(TFT_BLUE); 178 | 179 | tft.drawString("012345", 0, 0, 6); 180 | tft.drawString("6789", 0, 40, 6); 181 | tft.drawString("apm-:.", 0, 80, 6); 182 | delay(WAIT); 183 | 184 | tft.fillScreen(TFT_BROWN); 185 | tft.setTextColor(TFT_RED); 186 | 187 | tft.drawString("0123", 0, 0, 7); 188 | tft.drawString("4567", 0, 60, 7); 189 | delay(WAIT); 190 | 191 | tft.fillScreen(TFT_BROWN); 192 | tft.drawString("890:.", 0, 0, 7); 193 | tft.drawString("", 0, 60, 7); 194 | delay(WAIT); 195 | 196 | tft.fillScreen(TFT_BROWN); 197 | tft.setTextColor(TFT_YELLOW); 198 | 199 | tft.drawString("0123", 0, 0, 8); 200 | delay(WAIT); 201 | 202 | tft.fillScreen(TFT_BROWN); 203 | tft.drawString("4567", 0, 0, 8); 204 | delay(WAIT); 205 | 206 | tft.fillScreen(TFT_BROWN); 207 | tft.drawString("890:.", 0, 0, 8); 208 | delay(WAIT); 209 | 210 | tft.setTextColor(TFT_MAGENTA); 211 | 212 | tft.drawNumber(millis() - targetTime, 0, 100, 4); 213 | delay(4000);; 214 | } 215 | 216 | -------------------------------------------------------------------------------- /examples/TFT_7735_Meter_5/TFT_7735_Meter_5.ino: -------------------------------------------------------------------------------- 1 | /* 2 | An example analogue meter using a ST7735 TFT LCD screen 3 | 4 | This example uses the hardware SPI only 5 | Needs Font 2 (also Font 4 if using large scale label) 6 | 7 | Updated by Bodmer for variable meter size 8 | */ 9 | 10 | // Define meter size 11 | #define M_SIZE 0.667 12 | 13 | #include // Hardware-specific library 14 | #include 15 | 16 | TFT_ST7735 tft = TFT_ST7735(); // Invoke custom library 17 | 18 | #define ST7735_GREY 0x5AEB 19 | #define ST7735_ORANGE 0xFD20 /* 255, 165, 0 */ 20 | 21 | float ltx = 0; // Saved x coord of bottom of needle 22 | uint16_t osx = M_SIZE*120, osy = M_SIZE*120; // Saved x & y coords 23 | uint32_t updateTime = 0; // time for next update 24 | 25 | int old_analog = -999; // Value last displayed 26 | 27 | int value[6] = {0, 0, 0, 0, 0, 0}; 28 | int old_value[6] = { -1, -1, -1, -1, -1, -1}; 29 | int d = 0; 30 | 31 | void setup(void) { 32 | Serial.begin(57600); // For debug 33 | tft.init(); 34 | tft.setRotation(3); 35 | 36 | tft.fillScreen(ST7735_BLACK); 37 | 38 | analogMeter(); // Draw analogue meter 39 | 40 | updateTime = millis(); // Next update time 41 | } 42 | 43 | 44 | void loop() { 45 | if (updateTime <= millis()) { 46 | updateTime = millis() + 35; // Update meter every 35 milliseconds 47 | 48 | // Create a Sine wave for testing 49 | d += 4; if (d >= 360) d = 0; 50 | value[0] = 50 + 50 * sin((d + 0) * 0.0174532925); 51 | //value[0] = random(0,100); 52 | //unsigned long tt = millis(); 53 | plotNeedle(value[0], 0); // It takes between 2 and 14ms to replot the needle with zero delay 54 | //Serial.println(millis()-tt); 55 | } 56 | } 57 | 58 | 59 | // ######################################################################### 60 | // Draw the analogue meter on the screen 61 | // ######################################################################### 62 | void analogMeter() 63 | { 64 | 65 | // Meter outline 66 | tft.fillRect(0, 0, M_SIZE*239, M_SIZE*131, ST7735_GREY); 67 | tft.fillRect(1, M_SIZE*3, M_SIZE*234, M_SIZE*125, ST7735_WHITE); 68 | 69 | tft.setTextColor(ST7735_BLACK); // Text colour 70 | 71 | // Draw ticks every 5 degrees from -50 to +50 degrees (100 deg. FSD swing) 72 | for (int i = -50; i < 51; i += 5) { 73 | // Long scale tick length 74 | int tl = 15; 75 | 76 | // Coodinates of tick to draw 77 | float sx = cos((i - 90) * 0.0174532925); 78 | float sy = sin((i - 90) * 0.0174532925); 79 | uint16_t x0 = sx * (M_SIZE*100 + tl) + M_SIZE*120; 80 | uint16_t y0 = sy * (M_SIZE*100 + tl) + M_SIZE*150; 81 | uint16_t x1 = sx * M_SIZE*100 + M_SIZE*120; 82 | uint16_t y1 = sy * M_SIZE*100 + M_SIZE*150; 83 | 84 | // Coordinates of next tick for zone fill 85 | float sx2 = cos((i + 5 - 90) * 0.0174532925); 86 | float sy2 = sin((i + 5 - 90) * 0.0174532925); 87 | int x2 = sx2 * (M_SIZE*100 + tl) + M_SIZE*120; 88 | int y2 = sy2 * (M_SIZE*100 + tl) + M_SIZE*150; 89 | int x3 = sx2 * M_SIZE*100 + M_SIZE*120; 90 | int y3 = sy2 * M_SIZE*100 + M_SIZE*150; 91 | 92 | // Yellow zone limits 93 | //if (i >= -50 && i < 0) { 94 | // tft.fillTriangle(x0, y0, x1, y1, x2, y2, ST7735_YELLOW); 95 | // tft.fillTriangle(x1, y1, x2, y2, x3, y3, ST7735_YELLOW); 96 | //} 97 | 98 | // Green zone limits 99 | if (i >= 0 && i < 25) { 100 | tft.fillTriangle(x0, y0, x1, y1, x2, y2, ST7735_GREEN); 101 | tft.fillTriangle(x1, y1, x2, y2, x3, y3, ST7735_GREEN); 102 | } 103 | 104 | // Orange zone limits 105 | if (i >= 25 && i < 50) { 106 | tft.fillTriangle(x0, y0, x1, y1, x2, y2, ST7735_ORANGE); 107 | tft.fillTriangle(x1, y1, x2, y2, x3, y3, ST7735_ORANGE); 108 | } 109 | 110 | // Short scale tick length 111 | if (i % 25 != 0) tl = 8; 112 | 113 | // Recalculate coords incase tick lenght changed 114 | x0 = sx * (M_SIZE*100 + tl) + M_SIZE*120; 115 | y0 = sy * (M_SIZE*100 + tl) + M_SIZE*150; 116 | x1 = sx * M_SIZE*100 + M_SIZE*120; 117 | y1 = sy * M_SIZE*100 + M_SIZE*150; 118 | 119 | // Draw tick 120 | tft.drawLine(x0, y0, x1, y1, ST7735_BLACK); 121 | 122 | // Check if labels should be drawn, with position tweaks 123 | if (i % 25 == 0) { 124 | // Calculate label positions 125 | x0 = sx * (M_SIZE*100 + tl + 10) + M_SIZE*120; 126 | y0 = sy * (M_SIZE*100 + tl + 10) + M_SIZE*150; 127 | switch (i / 25) { 128 | case -2: tft.drawCentreString("0", x0+4, y0-4, 1); break; 129 | case -1: tft.drawCentreString("25", x0+2, y0, 1); break; 130 | case 0: tft.drawCentreString("50", x0, y0, 1); break; 131 | case 1: tft.drawCentreString("75", x0, y0, 1); break; 132 | case 2: tft.drawCentreString("100", x0-2, y0-4, 1); break; 133 | } 134 | } 135 | 136 | // Now draw the arc of the scale 137 | sx = cos((i + 5 - 90) * 0.0174532925); 138 | sy = sin((i + 5 - 90) * 0.0174532925); 139 | x0 = sx * M_SIZE*100 + M_SIZE*120; 140 | y0 = sy * M_SIZE*100 + M_SIZE*150; 141 | // Draw scale arc, don't draw the last part 142 | if (i < 50) tft.drawLine(x0, y0, x1, y1, ST7735_BLACK); 143 | } 144 | 145 | tft.drawString("%RH", M_SIZE*(3 + 230 - 40), M_SIZE*(119 - 20), 2); // Units at bottom right 146 | //tft.drawCentreString("%RH", M_SIZE*120, M_SIZE*75, 4); // Comment out to avoid font 4 147 | tft.drawRect(1, M_SIZE*3, M_SIZE*236, M_SIZE*126, ST7735_BLACK); // Draw bezel line 148 | 149 | plotNeedle(0, 0); // Put meter needle at 0 150 | } 151 | 152 | // ######################################################################### 153 | // Update needle position 154 | // This function is blocking while needle moves, time depends on ms_delay 155 | // 10ms minimises needle flicker if text is drawn within needle sweep area 156 | // Smaller values OK if text not in sweep area, zero for instant movement but 157 | // does not look realistic... (note: 100 increments for full scale deflection) 158 | // ######################################################################### 159 | void plotNeedle(int value, byte ms_delay) 160 | { 161 | tft.setTextColor(ST7735_BLACK, ST7735_WHITE); 162 | char buf[8]; dtostrf(value, 4, 0, buf); 163 | tft.drawRightString(buf, 33, M_SIZE*(119 - 20), 2); 164 | 165 | if (value < -10) value = -10; // Limit value to emulate needle end stops 166 | if (value > 110) value = 110; 167 | 168 | // Move the needle until new value reached 169 | while (!(value == old_analog)) { 170 | if (old_analog < value) old_analog++; 171 | else old_analog--; 172 | 173 | if (ms_delay == 0) old_analog = value; // Update immediately if delay is 0 174 | 175 | float sdeg = map(old_analog, -10, 110, -150, -30); // Map value to angle 176 | // Calculate tip of needle coords 177 | float sx = cos(sdeg * 0.0174532925); 178 | float sy = sin(sdeg * 0.0174532925); 179 | 180 | // Calculate x delta of needle start (does not start at pivot point) 181 | float tx = tan((sdeg + 90) * 0.0174532925); 182 | 183 | // Erase old needle image 184 | tft.drawLine(M_SIZE*(120 + 24 * ltx) - 1, M_SIZE*(150 - 24), osx - 1, osy, ST7735_WHITE); 185 | tft.drawLine(M_SIZE*(120 + 24 * ltx), M_SIZE*(150 - 24), osx, osy, ST7735_WHITE); 186 | tft.drawLine(M_SIZE*(120 + 24 * ltx) + 1, M_SIZE*(150 - 24), osx + 1, osy, ST7735_WHITE); 187 | 188 | // Re-plot text under needle 189 | tft.setTextColor(ST7735_BLACK, ST7735_WHITE); 190 | //tft.drawCentreString("%RH", M_SIZE*120, M_SIZE*75, 4); // // Comment out to avoid font 4 191 | 192 | // Store new needle end coords for next erase 193 | ltx = tx; 194 | osx = M_SIZE*(sx * 98 + 120); 195 | osy = M_SIZE*(sy * 98 + 150); 196 | 197 | // Draw the needle in the new postion, magenta makes needle a bit bolder 198 | // draws 3 lines to thicken needle 199 | tft.drawLine(M_SIZE*(120 + 24 * ltx) - 1, M_SIZE*(150 - 24), osx - 1, osy, ST7735_RED); 200 | tft.drawLine(M_SIZE*(120 + 24 * ltx), M_SIZE*(150 - 24), osx, osy, ST7735_MAGENTA); 201 | tft.drawLine(M_SIZE*(120 + 24 * ltx) + 1, M_SIZE*(150 - 24), osx + 1, osy, ST7735_RED); 202 | 203 | // Slow needle down slightly as it approaches new postion 204 | if (abs(old_analog - value) < 10) ms_delay += ms_delay / 5; 205 | 206 | // Wait before next update 207 | delay(ms_delay); 208 | } 209 | } 210 | 211 | -------------------------------------------------------------------------------- /examples/TFT_Char_times/TFT_Char_times.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Font draw speed and flicker test, draws all numbers 0-999 in each font 3 | (0-99 in font 8) 4 | Average time in milliseconds to draw a character is shown in red 5 | A total of 2890 characters are drawn in each font (190 in font 8) 6 | 7 | Needs fonts 2, 4, 6, 7 and 8 8 | 9 | Make sure all the required fonts are loaded by editting the 10 | User_Setup.h file in the TFT_ST7735 library folder. 11 | 12 | If using an UNO or Mega (ATmega328 or ATmega2560 processor) then for best 13 | performance use the F_AS_T option found in the User_Setup.h file in the 14 | TFT_ST7735 library folder. 15 | 16 | The library uses the hardware SPI pins only: 17 | For UNO, Nano, Micro Pro ATmega328 based processors 18 | MOSI = pin 11, SCK = pin 13 19 | For Mega: 20 | MOSI = pin 51, SCK = pin 52 21 | 22 | The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST) 23 | signal lines to the TFT must also be defined in the library User_Setup.h file. 24 | 25 | Sugested TFT connections for UNO and Atmega328 based boards 26 | sclk 13 // Don't change, this is the hardware SPI SCLK line 27 | mosi 11 // Don't change, this is the hardware SPI MOSI line 28 | cs 10 // Chip select for TFT display 29 | dc 9 // Data/command line 30 | rst 7 // Reset, you could connect this to the Arduino reset pin 31 | 32 | Suggested TFT connections for the MEGA and ATmega2560 based boards 33 | sclk 52 // Don't change, this is the hardware SPI SCLK line 34 | mosi 51 // Don't change, this is the hardware SPI MOSI line 35 | cs 47 // TFT chip select line 36 | dc 48 // TFT data/command line 37 | rst 44 // you could alternatively connect this to the Arduino reset 38 | 39 | ######################################################################### 40 | ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 41 | ###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ###### 42 | ######################################################################### 43 | */ 44 | 45 | 46 | #include // Graphics and font library for ILI9341 driver chip 47 | #include 48 | 49 | TFT_ST7735 tft = TFT_ST7735(); // Invoke library, pins defined in User_Setup.h 50 | 51 | unsigned long drawTime = 0; 52 | 53 | void setup(void) { 54 | tft.init(); 55 | tft.setRotation(1); 56 | } 57 | 58 | void loop() { 59 | 60 | tft.fillScreen(TFT_BLACK); 61 | tft.setTextColor(TFT_WHITE, TFT_BLACK); 62 | 63 | drawTime = millis(); 64 | 65 | for (int i = 0; i < 1000; i++) { 66 | tft.drawNumber(i, 0, 0, 1); 67 | } 68 | 69 | drawTime = millis() - drawTime; 70 | 71 | tft.setTextColor(TFT_RED, TFT_BLACK); 72 | tft.drawFloat(drawTime / 2890.0, 3, 0, 80, 4); 73 | if (drawTime < 100) tft.drawString("Font 1 not loaded!", 0, 108, 2); 74 | 75 | delay(4000); 76 | tft.fillScreen(TFT_BLACK); 77 | tft.setTextColor(TFT_WHITE, TFT_BLACK); 78 | drawTime = millis(); 79 | 80 | for (int i = 0; i < 1000; i++) { 81 | tft.drawNumber(i, 0, 0, 2); 82 | } 83 | 84 | drawTime = millis() - drawTime; 85 | 86 | tft.setTextColor(TFT_RED, TFT_BLACK); 87 | tft.drawFloat(drawTime / 2890.0, 3, 0, 80, 4); 88 | if (drawTime < 200) tft.drawString("Font 2 not loaded!", 0, 108, 2); 89 | 90 | delay(4000); 91 | tft.fillScreen(TFT_BLACK); 92 | tft.setTextColor(TFT_WHITE, TFT_BLACK); 93 | drawTime = millis(); 94 | 95 | for (int i = 0; i < 1000; i++) { 96 | tft.drawNumber(i, 0, 0, 4); 97 | } 98 | 99 | drawTime = millis() - drawTime; 100 | 101 | tft.setTextColor(TFT_RED, TFT_BLACK); 102 | tft.drawFloat(drawTime / 2890.0, 3, 0, 80, 4); 103 | if (drawTime < 200) tft.drawString("Font 4 not loaded!", 0, 108, 2); 104 | 105 | delay(4000); 106 | tft.fillScreen(TFT_BLACK); 107 | tft.setTextColor(TFT_WHITE, TFT_BLACK); 108 | drawTime = millis(); 109 | 110 | for (int i = 0; i < 1000; i++) { 111 | tft.drawNumber(i, 0, 0, 6); 112 | } 113 | 114 | drawTime = millis() - drawTime; 115 | 116 | tft.setTextColor(TFT_RED, TFT_BLACK); 117 | tft.drawFloat(drawTime / 2890.0, 3, 0, 80, 4); 118 | if (drawTime < 200) tft.drawString("Font 6 not loaded!", 0, 108, 2); 119 | 120 | delay(4000); 121 | tft.fillScreen(TFT_BLACK); 122 | tft.setTextColor(TFT_WHITE, TFT_BLACK); 123 | drawTime = millis(); 124 | 125 | for (int i = 0; i < 1000; i++) { 126 | tft.drawNumber(i, 0, 0, 7); 127 | } 128 | 129 | drawTime = millis() - drawTime; 130 | 131 | tft.setTextColor(TFT_RED, TFT_BLACK); 132 | tft.drawFloat(drawTime / 2890.0, 3, 0, 80, 4); 133 | if (drawTime < 200) tft.drawString("Font 7 not loaded!", 0, 108, 2); 134 | 135 | delay(4000); 136 | tft.fillScreen(TFT_BLACK); 137 | tft.setTextColor(TFT_WHITE, TFT_BLACK); 138 | drawTime = millis(); 139 | 140 | for (int i = 0; i < 100; i++) { 141 | tft.drawNumber(i, 0, 0, 8); 142 | } 143 | 144 | drawTime = millis() - drawTime; 145 | 146 | tft.setTextColor(TFT_RED, TFT_BLACK); 147 | tft.drawFloat(drawTime / 190.0, 3, 0, 80, 4); 148 | if (drawTime < 200) tft.drawString("Font 8 not loaded!", 0, 108, 2); 149 | 150 | delay(4000); 151 | } 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /examples/TFT_Clock_Digital_ST7735/TFT_Clock_Digital_ST7735.ino: -------------------------------------------------------------------------------- 1 | /* 2 | An example digital clock using a TFT LCD screen to show the time. 3 | Demonstrates use of the font printing routines. (Time updates but date does not.) 4 | 5 | For a more accurate clock, it would be better to use the RTClib library. 6 | But this is just a demo. 7 | 8 | This examples uses the hardware SPI only. Non-hardware SPI 9 | is just too slow (~8 times slower!) 10 | 11 | Based on clock sketch by Gilchrist 6/2/2014 1.0 12 | Updated by Bodmer 13 | A few colour codes: 14 | 15 | code color 16 | 0x0000 Black 17 | 0xFFFF White 18 | 0xBDF7 Light Gray 19 | 0x7BEF Dark Gray 20 | 0xF800 Red 21 | 0xFFE0 Yellow 22 | 0xFBE0 Orange 23 | 0x79E0 Brown 24 | 0x7E0 Green 25 | 0x7FF Cyan 26 | 0x1F Blue 27 | 0xF81F Pink 28 | 29 | */ 30 | 31 | #include // Graphics and font library for ST7735 driver chip 32 | #include 33 | 34 | TFT_ST7735 tft = TFT_ST7735(); // Invoke library, pins defined in User_Setup.h 35 | 36 | uint32_t targetTime = 0; // for next 1 second timeout 37 | 38 | byte omm = 99; 39 | boolean initial = 1; 40 | byte xcolon = 0; 41 | unsigned int colour = 0; 42 | 43 | static uint8_t conv2d(const char* p) { 44 | uint8_t v = 0; 45 | if ('0' <= *p && *p <= '9') 46 | v = *p - '0'; 47 | return 10 * v + *++p - '0'; 48 | } 49 | 50 | uint8_t hh=conv2d(__TIME__), mm=conv2d(__TIME__+3), ss=conv2d(__TIME__+6); // Get H, M, S from compile time 51 | 52 | void setup(void) { 53 | tft.init(); 54 | tft.setRotation(1); 55 | tft.fillScreen(ST7735_BLACK); 56 | 57 | tft.setTextColor(ST7735_YELLOW, ST7735_BLACK); // Note: the new fonts do not draw the background colour 58 | 59 | targetTime = millis() + 1000; 60 | } 61 | 62 | void loop() { 63 | if (targetTime < millis()) { 64 | targetTime = millis()+1000; 65 | ss++; // Advance second 66 | if (ss==60) { 67 | ss=0; 68 | omm = mm; 69 | mm++; // Advance minute 70 | if(mm>59) { 71 | mm=0; 72 | hh++; // Advance hour 73 | if (hh>23) { 74 | hh=0; 75 | } 76 | } 77 | } 78 | 79 | if (ss==0 || initial) { 80 | initial = 0; 81 | tft.setTextColor(ST7735_GREEN, ST7735_BLACK); 82 | tft.setCursor (8, 52); 83 | tft.print(__DATE__); // This uses the standard ADAFruit small font 84 | 85 | tft.setTextColor(ST7735_BLUE, ST7735_BLACK); 86 | tft.drawCentreString("It is windy",120,48,2); // Next size up font 2 87 | 88 | //tft.setTextColor(0xF81F, ST7735_BLACK); // Pink 89 | //tft.drawCentreString("12.34",80,100,6); // Large font 6 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 . : a p m 90 | } 91 | 92 | // Update digital time 93 | byte xpos = 6; 94 | byte ypos = 0; 95 | if (omm != mm) { // Only redraw every minute to minimise flicker 96 | // Uncomment ONE of the next 2 lines, using the ghost image demonstrates text overlay as time is drawn over it 97 | tft.setTextColor(0x39C4, ST7735_BLACK); // Leave a 7 segment ghost image, comment out next line! 98 | //tft.setTextColor(ST7735_BLACK, ST7735_BLACK); // Set font colour to back to wipe image 99 | // Font 7 is to show a pseudo 7 segment display. 100 | // Font 7 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 0 : . 101 | tft.drawString("88:88",xpos,ypos,7); // Overwrite the text to clear it 102 | tft.setTextColor(0xFBE0, ST7735_BLACK); // Orange 103 | omm = mm; 104 | 105 | if (hh<10) xpos+= tft.drawChar('0',xpos,ypos,7); 106 | xpos+= tft.drawNumber(hh,xpos,ypos,7); 107 | xcolon=xpos; 108 | xpos+= tft.drawChar(':',xpos,ypos,7); 109 | if (mm<10) xpos+= tft.drawChar('0',xpos,ypos,7); 110 | tft.drawNumber(mm,xpos,ypos,7); 111 | } 112 | 113 | if (ss%2) { // Flash the colon 114 | tft.setTextColor(0x39C4, ST7735_BLACK); 115 | xpos+= tft.drawChar(':',xcolon,ypos,7); 116 | tft.setTextColor(0xFBE0, ST7735_BLACK); 117 | } 118 | else { 119 | tft.drawChar(':',xcolon,ypos,7); 120 | colour = random(0xFFFF); 121 | // Erase the text with a rectangle 122 | tft.fillRect (0, 64, 160, 20, ST7735_BLACK); 123 | tft.setTextColor(colour); 124 | tft.drawRightString("Colour",75,64,4); // Right justified string drawing to x position 75 125 | String scolour = String(colour,HEX); 126 | scolour.toUpperCase(); 127 | char buffer[20]; 128 | scolour.toCharArray(buffer,20); 129 | tft.drawString(buffer,82,64,4); 130 | } 131 | } 132 | } 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /examples/TFT_Clock_ST7735/TFT_Clock_ST7735.ino: -------------------------------------------------------------------------------- 1 | /* 2 | An example analogue clock using a TFT LCD screen to show the time 3 | use of some of the drawing commands with the ST7735 library. 4 | For a more accurate clock, it would be better to use the RTClib library. 5 | But this is just a demo. 6 | 7 | This examples uses the hardware SPI only. Non-hardware SPI 8 | is just too slow (~8 times slower!) 9 | 10 | Gilchrist 6/2/2014 1.0 11 | Updated by Bodmer 12 | */ 13 | 14 | #include // Graphics and font library for ST7735 driver chip 15 | #include 16 | 17 | TFT_ST7735 tft = TFT_ST7735(); // Invoke library, pins defined in User_Setup.h 18 | 19 | #define ST7735_GREY 0xBDF7 20 | 21 | float sx = 0, sy = 1, mx = 1, my = 0, hx = -1, hy = 0; // Saved H, M, S x & y multipliers 22 | float sdeg=0, mdeg=0, hdeg=0; 23 | uint16_t osx=64, osy=64, omx=64, omy=64, ohx=64, ohy=64; // Saved H, M, S x & y coords 24 | uint16_t x0=0, x1=0, y0=0, y1=0; 25 | uint32_t targetTime = 0; // for next 1 second timeout 26 | 27 | static uint8_t conv2d(const char* p) { 28 | uint8_t v = 0; 29 | if ('0' <= *p && *p <= '9') 30 | v = *p - '0'; 31 | return 10 * v + *++p - '0'; 32 | } 33 | 34 | uint8_t hh=conv2d(__TIME__), mm=conv2d(__TIME__+3), ss=conv2d(__TIME__+6); // Get H, M, S from compile time 35 | 36 | boolean initial = 1; 37 | 38 | void setup(void) { 39 | tft.init(); 40 | tft.setRotation(0); 41 | tft.fillScreen(ST7735_GREY); 42 | tft.setTextColor(ST7735_GREEN, ST7735_GREY); // Adding a black background colour erases previous text automatically 43 | 44 | // Draw clock face 45 | tft.fillCircle(64, 64, 61, ST7735_BLUE); 46 | tft.fillCircle(64, 64, 57, ST7735_BLACK); 47 | 48 | // Draw 12 lines 49 | for(int i = 0; i<360; i+= 30) { 50 | sx = cos((i-90)*0.0174532925); 51 | sy = sin((i-90)*0.0174532925); 52 | x0 = sx*57+64; 53 | y0 = sy*57+64; 54 | x1 = sx*50+64; 55 | y1 = sy*50+64; 56 | 57 | tft.drawLine(x0, y0, x1, y1, ST7735_BLUE); 58 | } 59 | 60 | // Draw 60 dots 61 | for(int i = 0; i<360; i+= 6) { 62 | sx = cos((i-90)*0.0174532925); 63 | sy = sin((i-90)*0.0174532925); 64 | x0 = sx*53+64; 65 | y0 = sy*53+64; 66 | 67 | tft.drawPixel(x0, y0, ST7735_BLUE); 68 | if(i==0 || i==180) tft.fillCircle(x0, y0, 1, ST7735_CYAN); 69 | if(i==0 || i==180) tft.fillCircle(x0+1, y0, 1, ST7735_CYAN); 70 | if(i==90 || i==270) tft.fillCircle(x0, y0, 1, ST7735_CYAN); 71 | if(i==90 || i==270) tft.fillCircle(x0+1, y0, 1, ST7735_CYAN); 72 | } 73 | 74 | tft.fillCircle(65, 65, 3, ST7735_RED); 75 | 76 | // Draw text at position 64,125 using fonts 4 77 | // Only font numbers 2,4,6,7 are valid. Font 6 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 : . a p m 78 | // Font 7 is a 7 segment font and only contains characters [space] 0 1 2 3 4 5 6 7 8 9 : . 79 | tft.drawCentreString("Time flies",64,130,4); 80 | 81 | targetTime = millis() + 1000; 82 | } 83 | 84 | void loop() { 85 | if (targetTime < millis()) { 86 | targetTime = millis()+1000; 87 | ss++; // Advance second 88 | if (ss==60) { 89 | ss=0; 90 | mm++; // Advance minute 91 | if(mm>59) { 92 | mm=0; 93 | hh++; // Advance hour 94 | if (hh>23) { 95 | hh=0; 96 | } 97 | } 98 | } 99 | 100 | // Pre-compute hand degrees, x & y coords for a fast screen update 101 | sdeg = ss*6; // 0-59 -> 0-354 102 | mdeg = mm*6+sdeg*0.01666667; // 0-59 -> 0-360 - includes seconds 103 | hdeg = hh*30+mdeg*0.0833333; // 0-11 -> 0-360 - includes minutes and seconds 104 | hx = cos((hdeg-90)*0.0174532925); 105 | hy = sin((hdeg-90)*0.0174532925); 106 | mx = cos((mdeg-90)*0.0174532925); 107 | my = sin((mdeg-90)*0.0174532925); 108 | sx = cos((sdeg-90)*0.0174532925); 109 | sy = sin((sdeg-90)*0.0174532925); 110 | 111 | if (ss==0 || initial) { 112 | initial = 0; 113 | // Erase hour and minute hand positions every minute 114 | tft.drawLine(ohx, ohy, 65, 65, ST7735_BLACK); 115 | ohx = hx*33+65; 116 | ohy = hy*33+65; 117 | tft.drawLine(omx, omy, 65, 65, ST7735_BLACK); 118 | omx = mx*44+65; 119 | omy = my*44+65; 120 | } 121 | 122 | // Redraw new hand positions, hour and minute hands not erased here to avoid flicker 123 | tft.drawLine(osx, osy, 65, 65, ST7735_BLACK); 124 | tft.drawLine(ohx, ohy, 65, 65, ST7735_WHITE); 125 | tft.drawLine(omx, omy, 65, 65, ST7735_WHITE); 126 | osx = sx*47+65; 127 | osy = sy*47+65; 128 | tft.drawLine(osx, osy, 65, 65, ST7735_RED); 129 | 130 | tft.fillCircle(65, 65, 3, ST7735_RED); 131 | } 132 | } 133 | 134 | 135 | -------------------------------------------------------------------------------- /examples/TFT_Ellipse/TFT_Ellipse.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Ellipse drawing example 3 | 4 | This sketch does not use any fonts. 5 | */ 6 | 7 | #include // Hardware-specific library 8 | #include 9 | 10 | TFT_ST7735 tft = TFT_ST7735(); // Invoke custom library 11 | 12 | void setup(void) { 13 | tft.init(); 14 | 15 | tft.setRotation(1); 16 | 17 | } 18 | 19 | void loop() { 20 | 21 | tft.fillScreen(TFT_BLACK); 22 | 23 | // Draw some random circles 24 | for (int i = 0; i < 20; i++) 25 | { 26 | int rx = random(40); 27 | int ry = random(40); 28 | int x = rx + random(160 - rx - rx); 29 | int y = ry + random(128 - ry - ry); 30 | tft.fillEllipse(x, y, rx, ry, random(0xFFFF)); 31 | } 32 | 33 | delay(2000); 34 | tft.fillScreen(TFT_BLACK); 35 | 36 | for (int i = 0; i < 20; i++) 37 | { 38 | int rx = random(40); 39 | int ry = random(40); 40 | int x = rx + random(160 - rx - rx); 41 | int y = ry + random(128 - ry - ry); 42 | tft.drawEllipse(x, y, rx, ry, random(0xFFFF)); 43 | } 44 | 45 | delay(2000); 46 | } 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/TFT_Print_Test/TFT_Print_Test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Test the tft.print() viz embedded tft.write() function 3 | 4 | This sketch used font 2, 4, 7 5 | 6 | Make sure all the required fonts are loaded by editting the 7 | User_Setup.h file in the TFT_ST7735 library folder. 8 | 9 | The library uses the hardware SPI pins only: 10 | For UNO, Nano, Micro Pro ATmega328 based processors 11 | MOSI = pin 11, SCK = pin 13 12 | For Mega: 13 | MOSI = pin 51, SCK = pin 52 14 | 15 | The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST) 16 | signal lines to the TFT must also be defined in the library User_Setup.h file. 17 | 18 | Sugested TFT connections for UNO and Atmega328 based boards 19 | sclk 13 // Don't change, this is the hardware SPI SCLK line 20 | mosi 11 // Don't change, this is the hardware SPI MOSI line 21 | cs 10 // Chip select for TFT display 22 | dc 9 // Data/command line 23 | rst 7 // Reset, you could connect this to the Arduino reset pin 24 | 25 | Suggested TFT connections for the MEGA and ATmega2560 based boards 26 | sclk 52 // Don't change, this is the hardware SPI SCLK line 27 | mosi 51 // Don't change, this is the hardware SPI MOSI line 28 | cs 47 // TFT chip select line 29 | dc 48 // TFT data/command line 30 | rst 44 // you could alternatively connect this to the Arduino reset 31 | 32 | ######################################################################### 33 | ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 34 | ###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ###### 35 | ######################################################################### 36 | */ 37 | 38 | 39 | #include // Graphics and font library for ST7735 driver chip 40 | #include 41 | 42 | TFT_ST7735 tft = TFT_ST7735(); // Invoke library, pins defined in User_Setup.h 43 | 44 | #define TFT_GREY 0x5AEB // New colour 45 | 46 | void setup(void) { 47 | tft.init(); 48 | tft.setRotation(1); 49 | } 50 | 51 | void loop() { 52 | 53 | // Fill screen with grey so we can see the effect of printing with and without 54 | // a background colour defined 55 | tft.fillScreen(TFT_GREY); 56 | 57 | // Set "cursor" at top left corner of display (0,0) and select font 2 58 | // (cursor will move to next line automatically during printing with 'tft.println' 59 | // or stay on the line is there is room for the text with tft.print) 60 | tft.setCursor(0, 0, 2); 61 | // Set the font colour to be white with a black background, set text size multiplier to 1 62 | tft.setTextColor(TFT_WHITE,TFT_BLACK); tft.setTextSize(1); 63 | // We can now plot text on screen using the "print" class 64 | tft.println("Hello World!"); 65 | 66 | // Set the font colour to be yellow with no background, set to font 7 67 | tft.setTextColor(TFT_YELLOW); tft.setTextFont(2); 68 | tft.println(1234.56); 69 | 70 | // Set the font colour to be red with black background, set to font 4 71 | tft.setTextColor(TFT_RED,TFT_BLACK); tft.setTextFont(4); 72 | tft.println((long)3735928559, HEX); // Should print DEADBEEF 73 | 74 | // Set the font colour to be green with black background, set to font 2 75 | tft.setTextColor(TFT_GREEN,TFT_BLACK); 76 | tft.setTextFont(2); 77 | tft.println("Groop"); 78 | 79 | // Test some print formatting functions 80 | float fnumber = 123.45; 81 | // Set the font colour to be blue with no background, set to font 2 82 | tft.setTextColor(TFT_BLUE); tft.setTextFont(2); 83 | tft.print("Float = "); tft.println(fnumber); // Print floating point number 84 | tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary 85 | tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal 86 | while(1); 87 | } 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /examples/TFT_Rainbow_ST7735/TFT_Rainbow_ST7735.ino: -------------------------------------------------------------------------------- 1 | /* 2 | An example showing rainbow colours on a 1.8" TFT LCD screen 3 | and to show a basic example of font use. 4 | 5 | This examples uses the hardware SPI only. Non-hardware SPI 6 | is just too slow (~8 times slower!) 7 | 8 | Updated by Bodmer 9 | 10 | Colours: 11 | 12 | code color 13 | 0x0000 Black 14 | 0xFFFF White 15 | 0xBDF7 Light Gray 16 | 0x7BEF Dark Gray 17 | 0xF800 Red 18 | 0xFFE0 Yellow 19 | 0xFBE0 Orange 20 | 0x79E0 Brown 21 | 0x7E0 Green 22 | 0x7FF Cyan 23 | 0x1F Blue 24 | 0xF81F Pink 25 | 26 | */ 27 | 28 | #include // Graphics and font library for ST7735 driver chip 29 | #include 30 | 31 | TFT_ST7735 tft = TFT_ST7735(); // Invoke library, pins defined in User_Setup.h 32 | 33 | unsigned long targetTime = 0; 34 | byte red = 31; 35 | byte green = 0; 36 | byte blue = 0; 37 | byte state = 0; 38 | unsigned int colour = red << 11; 39 | 40 | void setup(void) { 41 | tft.init(); 42 | tft.setRotation(1); 43 | tft.fillScreen(ST7735_BLACK); 44 | 45 | targetTime = millis() + 1000; 46 | } 47 | 48 | void loop() { 49 | 50 | if (targetTime < millis()) { 51 | targetTime = millis()+10000; 52 | for (int i = 0; i<160; i++) { 53 | tft.drawFastVLine(i, 0, tft.height(), colour); 54 | switch (state) { 55 | case 0: 56 | green +=2; 57 | if (green == 64) { 58 | green=63; 59 | state = 1; 60 | } 61 | break; 62 | case 1: 63 | red--; 64 | if (red == 255) { 65 | red = 0; 66 | state = 2; 67 | } 68 | break; 69 | case 2: 70 | blue ++; 71 | if (blue == 32) { 72 | blue=31; 73 | state = 3; 74 | } 75 | break; 76 | case 3: 77 | green -=2; 78 | if (green ==255) { 79 | green=0; 80 | state = 4; 81 | } 82 | break; 83 | case 4: 84 | red ++; 85 | if (red == 32) { 86 | red = 31; 87 | state = 5; 88 | } 89 | break; 90 | case 5: 91 | blue --; 92 | if (blue == 255) { 93 | blue = 0; 94 | state = 0; 95 | } 96 | break; 97 | } 98 | colour = red<<11 | green<<5 | blue; 99 | } 100 | 101 | // The standard ADAFruit font still works as berfore 102 | tft.setTextColor(ST7735_BLACK, ST7735_BLACK); // Note these fonts do not plot the background colour 103 | tft.setCursor (12, 5); 104 | tft.print("Original ADAfruit font!"); 105 | 106 | // The new larger fonts do not use the .setCursor call, coords are embedded 107 | tft.setTextColor(ST7735_BLACK, ST7735_BLACK); // Do not plot the background colour 108 | // Overlay the black text on top of the rainbow plot (the advantage of not drawing the backgorund colour!) 109 | tft.drawCentreString("Font size 2",80,14,2); // Draw text centre at position 80, 12 using font 2 110 | //tft.drawCentreString("Font size 2",81,12,2); // Draw text centre at position 80, 12 using font 2 111 | tft.drawCentreString("Font size 4",80,30,4); // Draw text centre at position 80, 24 using font 4 112 | tft.drawCentreString("12.34",80,54,6); // Draw text centre at position 80, 24 using font 6 113 | tft.drawCentreString("12.34 is in font size 6",80,92,2); // Draw text centre at position 80, 90 using font 2 114 | // Note the x position is the top of the font! 115 | 116 | // draw a floating point number 117 | float pi = 3.14159; // Value to print 118 | int precision = 3; // Number of digits after decimal point 119 | int xpos = 50; // x position 120 | int ypos = 110; // y position 121 | int font = 2; // font number only 2,4,6,7 valid. Font 6 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 0 : a p m 122 | xpos+=tft.drawFloat(pi,precision,xpos,ypos,font); // Draw rounded number and return new xpos delta for next print position 123 | tft.drawString(" is pi",xpos,ypos,font); // Continue printing from new x position 124 | } 125 | } 126 | 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /examples/TFT_graphicstest_PDQ3/TFT_graphicstest_PDQ3.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Adapted from the Adafruit and Xark's PDQ graphicstest sketch. 3 | 4 | This sketch uses the GLCD font only. Disable other fonts to make 5 | the sketch fit in an UNO! 6 | 7 | Make sure all the required fonts are loaded by editting the 8 | User_Setup.h file in the TFT_ST7735 library folder. 9 | 10 | The library uses the hardware SPI pins only: 11 | For UNO, Nano, Micro Pro ATmega328 based processors 12 | MOSI = pin 11, SCK = pin 13 13 | For Mega: 14 | MOSI = pin 51, SCK = pin 52 15 | 16 | The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST) 17 | signal lines to the TFT must also be defined in the library User_Setup.h file. 18 | 19 | Sugested TFT connections for UNO and Atmega328 based boards 20 | sclk 13 // Don't change, this is the hardware SPI SCLK line 21 | mosi 11 // Don't change, this is the hardware SPI MOSI line 22 | cs 10 // Chip select for TFT display 23 | dc 9 // Data/command line 24 | rst 7 // Reset, you could connect this to the Arduino reset pin 25 | 26 | Suggested TFT connections for the MEGA and ATmega2560 based boards 27 | sclk 52 // Don't change, this is the hardware SPI SCLK line 28 | mosi 51 // Don't change, this is the hardware SPI MOSI line 29 | cs 47 // TFT chip select line 30 | dc 48 // TFT data/command line 31 | rst 44 // you could alternatively connect this to the Arduino reset 32 | 33 | ######################################################################### 34 | ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 35 | ###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ###### 36 | ######################################################################### 37 | */ 38 | 39 | 40 | #include // Hardware-specific library 41 | #include 42 | 43 | TFT_ST7735 tft = TFT_ST7735(); // Invoke custom library 44 | 45 | // These are used to get information about static SRAM and flash memory sizes 46 | extern "C" char __data_start[]; // start of SRAM data 47 | extern "C" char _end[]; // end of SRAM data (used to check amount of SRAM this program's variables use) 48 | extern "C" char __data_load_end[]; // end of FLASH (used to check amount of Flash this program's code and data uses) 49 | 50 | 51 | void setup() 52 | { 53 | Serial.begin(115200); 54 | 55 | Serial.println(F("TFT 1.8\" SPI TFT Test! ")); 56 | 57 | tft.init(); // initialize LCD 58 | } 59 | 60 | // NOTE: This demo should run, but may look odd on 128x128 LCD (vs 128x160) 61 | 62 | void loop(void) 63 | { 64 | Serial.print(F(__DATE__ " " __TIME__ " - Flash=0x")); 65 | Serial.print((uint16_t)__data_load_end, HEX); 66 | Serial.print(F(" RAM=0x")); 67 | Serial.println((uint16_t)_end - (uint16_t)__data_start, HEX); 68 | Serial.println(F("Benchmark Time (microseconds)")); 69 | 70 | uint32_t usecHaD = testHaD(); 71 | Serial.print(F("HaD pushColor ")); 72 | Serial.println(usecHaD); 73 | delay(100); 74 | 75 | 76 | uint32_t usecFillScreen = testFillScreen(); 77 | Serial.print(F("Screen fill ")); 78 | Serial.println(usecFillScreen); 79 | delay(100); 80 | 81 | tft.setRotation(1); 82 | uint32_t usecText = testText(); 83 | Serial.print(F("Text ")); 84 | Serial.println(usecText); 85 | delay(100); 86 | tft.setRotation(0); 87 | 88 | uint32_t usecPixels = testPixels(); 89 | Serial.print(F("Pixels ")); 90 | Serial.println(usecPixels); 91 | delay(100); 92 | 93 | uint32_t usecLines = testLines(TFT_BLUE); 94 | Serial.print(F("Lines ")); 95 | Serial.println(usecLines); 96 | delay(100); 97 | 98 | uint32_t usecFastLines = testFastLines(TFT_RED, TFT_BLUE); 99 | Serial.print(F("Horiz/Vert Lines ")); 100 | Serial.println(usecFastLines); 101 | delay(100); 102 | 103 | uint32_t usecRects = testRects(TFT_GREEN); 104 | Serial.print(F("Rectangles (outline) ")); 105 | Serial.println(usecRects); 106 | delay(100); 107 | 108 | uint32_t usecFilledRects = testFilledRects(TFT_YELLOW, TFT_MAGENTA); 109 | Serial.print(F("Rectangles (filled) ")); 110 | Serial.println(usecFilledRects); 111 | delay(100); 112 | 113 | uint32_t usecFilledCircles = testFilledCircles(10, TFT_MAGENTA); 114 | Serial.print(F("Circles (filled) ")); 115 | Serial.println(usecFilledCircles); 116 | delay(100); 117 | 118 | uint32_t usecCircles = testCircles(10, TFT_WHITE); 119 | Serial.print(F("Circles (outline) ")); 120 | Serial.println(usecCircles); 121 | delay(100); 122 | 123 | uint32_t usecTriangles = testTriangles(); 124 | Serial.print(F("Triangles (outline) ")); 125 | Serial.println(usecTriangles); 126 | delay(100); 127 | 128 | uint32_t usecFilledTrangles = testFilledTriangles(); 129 | Serial.print(F("Triangles (filled) ")); 130 | Serial.println(usecFilledTrangles); 131 | delay(100); 132 | 133 | uint32_t usecRoundRects = testRoundRects(); 134 | Serial.print(F("Rounded rects (outline) ")); 135 | Serial.println(usecRoundRects); 136 | delay(100); 137 | 138 | uint32_t usedFilledRoundRects = testFilledRoundRects(); 139 | Serial.print(F("Rounded rects (filled) ")); 140 | Serial.println(usedFilledRoundRects); 141 | delay(100); 142 | 143 | Serial.println(F("Done!")); 144 | 145 | uint16_t c = 4; 146 | int8_t d = 1; 147 | for (int32_t i = 0; i < tft.height(); i++) 148 | { 149 | tft.drawFastHLine(0, i, tft.width(), c); 150 | c += d; 151 | if (c <= 4 || c >= 11) 152 | d = -d; 153 | } 154 | 155 | tft.setCursor(0, 0); 156 | tft.setTextColor(TFT_MAGENTA); 157 | 158 | tft.println(F("Bodmer's TFT_ST7735")); 159 | 160 | tft.setTextSize(1); 161 | tft.setTextColor(TFT_WHITE); 162 | tft.print(F("SPI LCD on 328p")); 163 | tft.setTextColor(TFT_YELLOW); 164 | tft.print(F("@")); 165 | tft.setTextColor(TFT_WHITE); 166 | tft.print(F("16MHz")); 167 | tft.setTextSize(1); 168 | tft.setTextColor(tft.color565(0x80, 0x80, 0x80)); 169 | tft.print(F("Flash=0x")); 170 | tft.print((uint16_t)__data_load_end, HEX); 171 | tft.print(F(" RAM=0x")); 172 | tft.print((uint16_t)_end - (uint16_t)__data_start, HEX); 173 | 174 | tft.setTextColor(TFT_GREEN); 175 | tft.print(F("Benchmark usec")); 176 | 177 | tft.setTextColor(TFT_CYAN); 178 | tft.print(F("HaD logo ")); 179 | tft.setTextColor(TFT_YELLOW); 180 | printnice(usecHaD); 181 | 182 | tft.setTextColor(TFT_CYAN); 183 | tft.print(F("Clear ")); 184 | tft.setTextColor(TFT_YELLOW); 185 | printnice(usecFillScreen); 186 | 187 | tft.setTextColor(TFT_CYAN); 188 | tft.print(F("Text ")); 189 | tft.setTextColor(TFT_YELLOW); 190 | printnice(usecText); 191 | 192 | tft.setTextColor(TFT_CYAN); 193 | tft.print(F("Pixels ")); 194 | tft.setTextColor(TFT_YELLOW); 195 | printnice(usecPixels); 196 | 197 | tft.setTextColor(TFT_CYAN); 198 | tft.print(F("Lines ")); 199 | tft.setTextColor(TFT_YELLOW); 200 | printnice(usecLines); 201 | 202 | tft.setTextColor(TFT_CYAN); 203 | tft.print(F("H/V Lines ")); 204 | tft.setTextColor(TFT_YELLOW); 205 | printnice(usecFastLines); 206 | 207 | tft.setTextColor(TFT_CYAN); 208 | tft.print(F("Rectangles ")); 209 | tft.setTextColor(TFT_YELLOW); 210 | printnice(usecRects); 211 | 212 | tft.setTextColor(TFT_CYAN); 213 | tft.print(F("Rects-Fill ")); 214 | tft.setTextColor(TFT_YELLOW); 215 | printnice(usecFilledRects); 216 | 217 | tft.setTextColor(TFT_CYAN); 218 | tft.print(F("Circles ")); 219 | tft.setTextColor(TFT_YELLOW); 220 | printnice(usecCircles); 221 | 222 | tft.setTextColor(TFT_CYAN); 223 | tft.print(F("CircleFill ")); 224 | tft.setTextColor(TFT_YELLOW); 225 | printnice(usecFilledCircles); 226 | 227 | tft.setTextColor(TFT_CYAN); 228 | tft.print(F("Triangles ")); 229 | tft.setTextColor(TFT_YELLOW); 230 | printnice(usecTriangles); 231 | 232 | tft.setTextColor(TFT_CYAN); 233 | tft.print(F("Tris-Fill ")); 234 | tft.setTextColor(TFT_YELLOW); 235 | printnice(usecFilledTrangles); 236 | 237 | tft.setTextColor(TFT_CYAN); 238 | tft.print(F("Rnd-Rects ")); 239 | tft.setTextColor(TFT_YELLOW); 240 | printnice(usecRoundRects); 241 | 242 | tft.setTextColor(TFT_CYAN); 243 | tft.print(F("RRects-Fill")); 244 | tft.setTextColor(TFT_YELLOW); 245 | printnice(usedFilledRoundRects); 246 | 247 | tft.setTextSize(1); 248 | tft.println(F("")); 249 | tft.setTextColor(TFT_GREEN); 250 | tft.print(F("Benchmark Completed!")); 251 | 252 | delay(15 * 1000L); 253 | } 254 | 255 | void printnice(int32_t v) 256 | { 257 | char str[32] = { 0 }; 258 | sprintf(str, "%lu", v); 259 | for (char *p = (str+strlen(str))-3; p > str; p -= 3) 260 | { 261 | memmove(p+1, p, strlen(p)+1); 262 | *p = ','; 263 | 264 | } 265 | while (strlen(str) < 10) 266 | { 267 | memmove(str+1, str, strlen(str)+1); 268 | *str = ' '; 269 | } 270 | tft.print(str); 271 | } 272 | 273 | static inline uint32_t micros_start() __attribute__ ((always_inline)); 274 | static inline uint32_t micros_start() 275 | { 276 | uint8_t oms = millis(); 277 | while ((uint8_t)millis() == oms) 278 | ; 279 | return micros(); 280 | } 281 | 282 | uint32_t testHaD() 283 | { 284 | // pseudo-code for cheesy RLE 285 | // start with color1 286 | // while more input data remaining 287 | // count = 0nnnnnnn = 1 byte or 1nnnnnnn nnnnnnnn 2 bytes (0 - 32767) 288 | // repeat color count times 289 | // toggle color1/color2 290 | static const uint8_t HaD_128x160[] PROGMEM = 291 | { 292 | 0x85, 0x91, 0x09, 0x4b, 0x09, 0x24, 0x0a, 0x47, 0x09, 0x27, 0x0a, 0x44, 0x0a, 0x29, 0x0a, 0x42, 293 | 0x0a, 0x2b, 0x0a, 0x41, 0x0a, 0x2c, 0x0a, 0x3e, 0x0b, 0x2f, 0x09, 0x3d, 0x09, 0x32, 0x08, 0x3c, 294 | 0x09, 0x33, 0x09, 0x3b, 0x08, 0x33, 0x0a, 0x3a, 0x0a, 0x31, 0x0b, 0x3a, 0x0c, 0x1d, 0x01, 0x10, 295 | 0x0d, 0x39, 0x0c, 0x1d, 0x01, 0x10, 0x0d, 0x39, 0x0d, 0x0f, 0x01, 0x0c, 0x03, 0x0d, 0x0e, 0x39, 296 | 0x0e, 0x0c, 0x03, 0x0c, 0x04, 0x0b, 0x0f, 0x39, 0x0f, 0x0a, 0x04, 0x0c, 0x05, 0x09, 0x10, 0x39, 297 | 0x10, 0x08, 0x05, 0x0c, 0x06, 0x07, 0x11, 0x39, 0x11, 0x06, 0x06, 0x0d, 0x07, 0x04, 0x13, 0x37, 298 | 0x12, 0x05, 0x07, 0x0d, 0x08, 0x02, 0x15, 0x34, 0x15, 0x03, 0x08, 0x0d, 0x20, 0x32, 0x20, 0x0e, 299 | 0x21, 0x31, 0x20, 0x0f, 0x21, 0x2e, 0x22, 0x10, 0x22, 0x2b, 0x22, 0x12, 0x22, 0x12, 0x05, 0x12, 300 | 0x22, 0x14, 0x22, 0x0c, 0x0f, 0x0c, 0x22, 0x16, 0x22, 0x08, 0x15, 0x08, 0x22, 0x18, 0x22, 0x05, 301 | 0x19, 0x05, 0x21, 0x1c, 0x1f, 0x04, 0x1c, 0x05, 0x1f, 0x1f, 0x1c, 0x04, 0x1e, 0x04, 0x1d, 0x2b, 302 | 0x11, 0x04, 0x21, 0x03, 0x12, 0x36, 0x0f, 0x03, 0x24, 0x03, 0x10, 0x38, 0x0d, 0x03, 0x26, 0x03, 303 | 0x0d, 0x3b, 0x0b, 0x03, 0x28, 0x03, 0x0b, 0x3d, 0x0a, 0x03, 0x29, 0x03, 0x09, 0x40, 0x07, 0x03, 304 | 0x2b, 0x03, 0x07, 0x42, 0x05, 0x03, 0x2c, 0x04, 0x04, 0x45, 0x04, 0x03, 0x2d, 0x03, 0x04, 0x46, 305 | 0x02, 0x03, 0x2e, 0x03, 0x03, 0x48, 0x01, 0x03, 0x2f, 0x03, 0x01, 0x4c, 0x31, 0x4e, 0x32, 0x4e, 306 | 0x33, 0x4c, 0x34, 0x4c, 0x34, 0x4c, 0x35, 0x4b, 0x35, 0x4a, 0x0e, 0x03, 0x14, 0x04, 0x0d, 0x4a, 307 | 0x0b, 0x09, 0x0e, 0x0a, 0x0a, 0x4a, 0x0a, 0x0b, 0x0c, 0x0c, 0x09, 0x4a, 0x09, 0x0d, 0x0a, 0x0e, 308 | 0x09, 0x49, 0x08, 0x0f, 0x09, 0x0e, 0x09, 0x49, 0x08, 0x0f, 0x09, 0x0f, 0x08, 0x49, 0x08, 0x0f, 309 | 0x09, 0x0f, 0x08, 0x49, 0x07, 0x0f, 0x0a, 0x0f, 0x08, 0x49, 0x07, 0x0f, 0x0b, 0x0e, 0x08, 0x49, 310 | 0x07, 0x0d, 0x0e, 0x0d, 0x08, 0x49, 0x07, 0x0b, 0x13, 0x0a, 0x08, 0x49, 0x08, 0x07, 0x18, 0x08, 311 | 0x08, 0x49, 0x08, 0x06, 0x1b, 0x06, 0x08, 0x49, 0x09, 0x04, 0x1c, 0x05, 0x08, 0x4a, 0x09, 0x04, 312 | 0x1d, 0x04, 0x08, 0x4a, 0x0a, 0x03, 0x1d, 0x03, 0x09, 0x4b, 0x19, 0x02, 0x1a, 0x4b, 0x19, 0x03, 313 | 0x19, 0x4b, 0x18, 0x04, 0x18, 0x4d, 0x17, 0x05, 0x17, 0x4a, 0x01, 0x02, 0x17, 0x05, 0x16, 0x4a, 314 | 0x02, 0x02, 0x17, 0x05, 0x16, 0x02, 0x03, 0x44, 0x03, 0x03, 0x16, 0x02, 0x01, 0x02, 0x16, 0x02, 315 | 0x03, 0x43, 0x05, 0x03, 0x15, 0x01, 0x03, 0x01, 0x15, 0x03, 0x04, 0x41, 0x06, 0x03, 0x15, 0x01, 316 | 0x03, 0x01, 0x14, 0x03, 0x07, 0x3d, 0x09, 0x03, 0x2d, 0x03, 0x08, 0x3b, 0x0a, 0x04, 0x2b, 0x03, 317 | 0x0a, 0x39, 0x0c, 0x03, 0x2a, 0x04, 0x0b, 0x37, 0x0e, 0x03, 0x28, 0x03, 0x0e, 0x2e, 0x04, 0x03, 318 | 0x10, 0x03, 0x27, 0x03, 0x10, 0x03, 0x03, 0x24, 0x19, 0x03, 0x26, 0x03, 0x1a, 0x1e, 0x1d, 0x03, 319 | 0x24, 0x03, 0x1e, 0x19, 0x20, 0x04, 0x21, 0x03, 0x20, 0x17, 0x22, 0x04, 0x1f, 0x03, 0x22, 0x15, 320 | 0x22, 0x04, 0x21, 0x04, 0x21, 0x13, 0x22, 0x05, 0x15, 0x01, 0x0b, 0x05, 0x21, 0x12, 0x21, 0x06, 321 | 0x15, 0x01, 0x0b, 0x06, 0x21, 0x10, 0x21, 0x07, 0x0a, 0x01, 0x0a, 0x01, 0x0b, 0x07, 0x21, 0x0e, 322 | 0x20, 0x0a, 0x09, 0x02, 0x09, 0x02, 0x09, 0x09, 0x20, 0x0e, 0x08, 0x02, 0x15, 0x0b, 0x08, 0x03, 323 | 0x08, 0x03, 0x08, 0x0b, 0x15, 0x03, 0x08, 0x0d, 0x07, 0x04, 0x13, 0x0d, 0x06, 0x05, 0x06, 0x06, 324 | 0x05, 0x0d, 0x14, 0x04, 0x07, 0x0c, 0x07, 0x06, 0x11, 0x38, 0x12, 0x06, 0x06, 0x0c, 0x06, 0x08, 325 | 0x10, 0x39, 0x10, 0x08, 0x05, 0x0c, 0x04, 0x0b, 0x0f, 0x39, 0x0f, 0x0a, 0x04, 0x0c, 0x03, 0x0d, 326 | 0x0e, 0x39, 0x0e, 0x0c, 0x03, 0x0c, 0x02, 0x0e, 0x0e, 0x39, 0x0d, 0x0f, 0x01, 0x0c, 0x01, 0x10, 327 | 0x0d, 0x39, 0x0d, 0x0f, 0x01, 0x1e, 0x0c, 0x39, 0x0c, 0x30, 0x0a, 0x3a, 0x0a, 0x33, 0x09, 0x3b, 328 | 0x08, 0x34, 0x09, 0x3b, 0x09, 0x32, 0x09, 0x3c, 0x0a, 0x2f, 0x0a, 0x3e, 0x0a, 0x2d, 0x0b, 0x3f, 329 | 0x0a, 0x2b, 0x0b, 0x41, 0x0a, 0x29, 0x0b, 0x43, 0x0a, 0x27, 0x0a, 0x46, 0x0a, 0x25, 0x0a, 0x49, 330 | 0x09, 0x23, 0x08, 0x4e, 0x08, 0x96, 0x12 331 | }; 332 | 333 | tft.fillScreen(TFT_BLACK); 334 | 335 | uint32_t start = micros_start(); 336 | 337 | for (int i = 0; i < 0x10; i++) 338 | { 339 | tft.setAddrWindow(0, 0, tft.width()-1, tft.height()-1); 340 | 341 | uint16_t cnt = 0; 342 | uint16_t color = tft.color565((i << 4) | i, (i << 4) | i, (i << 4) | i); 343 | uint16_t curcolor = 0; 344 | 345 | const uint8_t *cmp = &HaD_128x160[0]; 346 | 347 | while (cmp < &HaD_128x160[sizeof(HaD_128x160)]) 348 | { 349 | cnt = pgm_read_byte(cmp++); 350 | if (cnt & 0x80) 351 | cnt = ((cnt & 0x7f) << 8) | pgm_read_byte(cmp++); 352 | 353 | tft.pushColor(curcolor, cnt); // PDQ_GFX has count 354 | 355 | curcolor ^= color; 356 | } 357 | } 358 | 359 | uint32_t t = micros() - start; 360 | 361 | tft.setTextColor(TFT_YELLOW); 362 | tft.setCursor(0, 145); 363 | tft.print(F(" http://hackaday.io/")); 364 | tft.print(F(" Xark")); 365 | 366 | delay(3 * 1000L); 367 | 368 | return t; 369 | } 370 | 371 | uint32_t testFillScreen() 372 | { 373 | uint32_t start = micros_start(); 374 | 375 | for (uint8_t i = 0; i < 12; i++) 376 | { 377 | tft.fillScreen(TFT_WHITE); 378 | tft.fillScreen(TFT_RED); 379 | tft.fillScreen(TFT_GREEN); 380 | tft.fillScreen(TFT_BLUE); 381 | tft.fillScreen(TFT_BLACK); 382 | } 383 | 384 | return micros() - start; 385 | } 386 | 387 | uint32_t testText() { 388 | tft.fillScreen(TFT_BLACK); 389 | uint32_t start = micros_start(); 390 | tft.setCursor(0, 0); 391 | tft.setTextColor(TFT_WHITE); tft.setTextSize(1); 392 | tft.println(F("Hello World!")); 393 | tft.setTextColor(tft.color565(0xff, 0x00, 0x00)); 394 | tft.print(F("RED ")); 395 | tft.setTextColor(tft.color565(0x00, 0xff, 0x00)); 396 | tft.print(F("GREEN ")); 397 | tft.setTextColor(tft.color565(0x00, 0x00, 0xff)); 398 | tft.println(F("BLUE")); 399 | tft.setTextColor(TFT_YELLOW); 400 | tft.println(1234.56); 401 | tft.setTextColor(TFT_RED); 402 | tft.println(0xDEADBEEF, HEX); 403 | tft.setTextColor(TFT_GREEN); 404 | tft.setTextSize(2); 405 | tft.println(F("Groop")); 406 | tft.println(F("I implore thee,")); 407 | tft.setTextSize(1); 408 | tft.println(F("my foonting turlingdromes.")); 409 | tft.println(F("And hooptiously drangle me")); 410 | tft.println(F("with crinkly bindlewurdles,")); 411 | tft.println(F("Or I will rend thee")); 412 | tft.println(F("in the gobberwarts")); 413 | tft.println(F("with my blurglecruncheon,")); 414 | tft.println(F("see if I don't!")); 415 | tft.println(F("")); 416 | tft.setTextColor(TFT_MAGENTA); 417 | tft.println(F("Woot!")); 418 | uint32_t t = micros() - start; 419 | delay(1000); 420 | return t; 421 | } 422 | 423 | uint32_t testPixels() 424 | { 425 | int32_t w = tft.width(); 426 | int32_t h = tft.height(); 427 | 428 | uint32_t start = micros_start(); 429 | 430 | for (uint16_t y = 0; y < h; y++) 431 | { 432 | for (uint16_t x = 0; x < w; x++) 433 | { 434 | tft.drawPixel(x, y, tft.color565(x<<3, y<<3, x*y)); 435 | } 436 | } 437 | 438 | return micros() - start; 439 | } 440 | 441 | 442 | uint32_t testLines(uint16_t color) 443 | { 444 | uint32_t start, t; 445 | int32_t x1, y1, x2, y2; 446 | int32_t w = tft.width(); 447 | int32_t h = tft.height(); 448 | 449 | tft.fillScreen(TFT_BLACK); 450 | 451 | x1 = y1 = 0; 452 | y2 = h - 1; 453 | 454 | start = micros_start(); 455 | 456 | for (x2 = 0; x2 < w; x2 += 6) 457 | { 458 | tft.drawLine(x1, y1, x2, y2, color); 459 | } 460 | 461 | x2 = w - 1; 462 | 463 | for (y2 = 0; y2 < h; y2 += 6) 464 | { 465 | tft.drawLine(x1, y1, x2, y2, color); 466 | } 467 | 468 | t = micros() - start; // fillScreen doesn't count against timing 469 | 470 | tft.fillScreen(TFT_BLACK); 471 | 472 | x1 = w - 1; 473 | y1 = 0; 474 | y2 = h - 1; 475 | 476 | start = micros_start(); 477 | 478 | for (x2 = 0; x2 < w; x2 += 6) 479 | { 480 | tft.drawLine(x1, y1, x2, y2, color); 481 | } 482 | 483 | x2 = 0; 484 | for (y2 = 0; y2 < h; y2 += 6) 485 | { 486 | tft.drawLine(x1, y1, x2, y2, color); 487 | } 488 | 489 | t += micros() - start; 490 | 491 | tft.fillScreen(TFT_BLACK); 492 | 493 | x1 = 0; 494 | y1 = h - 1; 495 | y2 = 0; 496 | 497 | start = micros_start(); 498 | 499 | for (x2 = 0; x2 < w; x2 += 6) 500 | { 501 | tft.drawLine(x1, y1, x2, y2, color); 502 | } 503 | x2 = w - 1; 504 | for (y2 = 0; y2 < h; y2 += 6) 505 | { 506 | tft.drawLine(x1, y1, x2, y2, color); 507 | } 508 | t += micros() - start; 509 | 510 | tft.fillScreen(TFT_BLACK); 511 | 512 | x1 = w - 1; 513 | y1 = h - 1; 514 | y2 = 0; 515 | 516 | start = micros_start(); 517 | 518 | for (x2 = 0; x2 < w; x2 += 6) 519 | { 520 | tft.drawLine(x1, y1, x2, y2, color); 521 | } 522 | 523 | x2 = 0; 524 | for (y2 = 0; y2 < h; y2 += 6) 525 | { 526 | tft.drawLine(x1, y1, x2, y2, color); 527 | } 528 | 529 | t += micros() - start; 530 | 531 | return t; 532 | } 533 | 534 | uint32_t testFastLines(uint16_t color1, uint16_t color2) 535 | { 536 | uint32_t start; 537 | int32_t x, y; 538 | int32_t w = tft.width(); 539 | int32_t h = tft.height(); 540 | 541 | tft.fillScreen(TFT_BLACK); 542 | 543 | start = micros_start(); 544 | 545 | for (y = 0; y < h; y += 5) 546 | tft.drawFastHLine(0, y, w, color1); 547 | for (x = 0; x < w; x += 5) 548 | tft.drawFastVLine(x, 0, h, color2); 549 | 550 | return micros() - start; 551 | } 552 | 553 | uint32_t testRects(uint16_t color) 554 | { 555 | uint32_t start; 556 | int32_t n, i, i2; 557 | int32_t cx = tft.width() / 2; 558 | int32_t cy = tft.height() / 2; 559 | 560 | tft.fillScreen(TFT_BLACK); 561 | n = min(tft.width(), tft.height()); 562 | start = micros_start(); 563 | for (i = 2; i < n; i += 6) 564 | { 565 | i2 = i / 2; 566 | tft.drawRect(cx-i2, cy-i2, i, i, color); 567 | } 568 | 569 | return micros() - start; 570 | } 571 | 572 | uint32_t testFilledRects(uint16_t color1, uint16_t color2) 573 | { 574 | uint32_t start, t = 0; 575 | int32_t n, i, i2; 576 | int32_t cx = tft.width() / 2 - 1; 577 | int32_t cy = tft.height() / 2 - 1; 578 | 579 | tft.fillScreen(TFT_BLACK); 580 | n = min(tft.width(), tft.height()); 581 | for (i = n; i > 0; i -= 6) 582 | { 583 | i2 = i / 2; 584 | 585 | start = micros_start(); 586 | 587 | tft.fillRect(cx-i2, cy-i2, i, i, color1); 588 | 589 | t += micros() - start; 590 | 591 | // Outlines are not included in timing results 592 | tft.drawRect(cx-i2, cy-i2, i, i, color2); 593 | } 594 | 595 | return t; 596 | } 597 | 598 | uint32_t testFilledCircles(uint8_t radius, uint16_t color) 599 | { 600 | uint32_t start; 601 | int32_t x, y, w = tft.width(), h = tft.height(), r2 = radius * 2; 602 | 603 | tft.fillScreen(TFT_BLACK); 604 | 605 | start = micros_start(); 606 | 607 | for (x = radius; x < w; x += r2) 608 | { 609 | for (y = radius; y < h; y += r2) 610 | { 611 | tft.fillCircle(x, y, radius, color); 612 | } 613 | } 614 | 615 | return micros() - start; 616 | } 617 | 618 | uint32_t testCircles(uint8_t radius, uint16_t color) 619 | { 620 | uint32_t start; 621 | int32_t x, y, r2 = radius * 2; 622 | int32_t w = tft.width() + radius; 623 | int32_t h = tft.height() + radius; 624 | 625 | // Screen is not cleared for this one -- this is 626 | // intentional and does not affect the reported time. 627 | start = micros_start(); 628 | 629 | for (x = 0; x < w; x += r2) 630 | { 631 | for (y = 0; y < h; y += r2) 632 | { 633 | tft.drawCircle(x, y, radius, color); 634 | } 635 | } 636 | 637 | return micros() - start; 638 | } 639 | 640 | uint32_t testTriangles() 641 | { 642 | uint32_t start; 643 | int32_t n, i; 644 | int32_t cx = tft.width()/ 2 - 1; 645 | int32_t cy = tft.height() / 2 - 1; 646 | 647 | tft.fillScreen(TFT_BLACK); 648 | n = min(cx, cy); 649 | 650 | start = micros_start(); 651 | 652 | for (i = 0; i < n; i += 5) 653 | { 654 | tft.drawTriangle( 655 | cx , cy - i, // peak 656 | cx - i, cy + i, // bottom left 657 | cx + i, cy + i, // bottom right 658 | tft.color565(0, 0, i)); 659 | } 660 | 661 | return micros() - start; 662 | } 663 | 664 | uint32_t testFilledTriangles() 665 | { 666 | uint32_t start, t = 0; 667 | int32_t i; 668 | int32_t cx = tft.width() / 2 - 1; 669 | int32_t cy = tft.height() / 2 - 1; 670 | 671 | tft.fillScreen(TFT_BLACK); 672 | 673 | start = micros_start(); 674 | 675 | for (i = min(cx,cy); i > 10; i -= 5) { 676 | start = micros_start(); 677 | tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, 678 | tft.color565(0, i, i)); 679 | t += micros() - start; 680 | tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, 681 | tft.color565(i, i, 0)); 682 | } 683 | 684 | return t; 685 | } 686 | 687 | uint32_t testRoundRects() 688 | { 689 | uint32_t start; 690 | int32_t w, i, i2; 691 | int32_t cx = tft.width() / 2 - 1; 692 | int32_t cy = tft.height() / 2 - 1; 693 | 694 | tft.fillScreen(TFT_BLACK); 695 | 696 | w = min(tft.width(), tft.height()); 697 | 698 | start = micros_start(); 699 | 700 | for (i = 0; i < w; i += 6) 701 | { 702 | i2 = i / 2; 703 | tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0)); 704 | } 705 | 706 | return micros() - start; 707 | } 708 | 709 | uint32_t testFilledRoundRects() 710 | { 711 | uint32_t start; 712 | int32_t i, i2; 713 | int32_t cx = tft.width() / 2 - 1; 714 | int32_t cy = tft.height() / 2 - 1; 715 | 716 | tft.fillScreen(TFT_BLACK); 717 | 718 | start = micros_start(); 719 | 720 | for (i = min(tft.width(), tft.height()); i > 20; i -= 6) 721 | { 722 | i2 = i / 2; 723 | tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0)); 724 | } 725 | 726 | return micros() - start; 727 | } 728 | -------------------------------------------------------------------------------- /examples/TFT_graphicstest_small/TFT_graphicstest_small.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Adapted from the Adafruit graphicstest sketch. 3 | 4 | This sketch uses the GLCD font (font 1) only. Disable other fonts to make 5 | the sketch fit in an UNO! 6 | 7 | Make sure all the required fonts are loaded by editting the 8 | User_Setup.h file in the TFT_ST7735 library folder. 9 | 10 | If using an UNO or Mega (ATmega328 or ATmega2560 processor) then for best 11 | performance use the F_AS_T option found in the User_Setup.h file in the 12 | TFT_ST7735 library folder. 13 | 14 | The library uses the hardware SPI pins only: 15 | For UNO, Nano, Micro Pro ATmega328 based processors 16 | MOSI = pin 11, SCK = pin 13 17 | For Mega: 18 | MOSI = pin 51, SCK = pin 52 19 | 20 | The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST) 21 | signal lines to the TFT must also be defined in the library User_Setup.h file. 22 | 23 | Sugested TFT connections for UNO and Atmega328 based boards 24 | sclk 13 // Don't change, this is the hardware SPI SCLK line 25 | mosi 11 // Don't change, this is the hardware SPI MOSI line 26 | cs 10 // Chip select for TFT display 27 | dc 9 // Data/command line 28 | rst 7 // Reset, you could connect this to the Arduino reset pin 29 | 30 | Suggested TFT connections for the MEGA and ATmega2560 based boards 31 | sclk 52 // Don't change, this is the hardware SPI SCLK line 32 | mosi 51 // Don't change, this is the hardware SPI MOSI line 33 | cs 47 // TFT chip select line 34 | dc 48 // TFT data/command line 35 | rst 44 // you could alternatively connect this to the Arduino reset 36 | 37 | ######################################################################### 38 | ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 39 | ###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ###### 40 | ######################################################################### 41 | */ 42 | 43 | 44 | #include // Hardware-specific library 45 | #include 46 | 47 | TFT_ST7735 tft = TFT_ST7735(); // Invoke custom library 48 | 49 | float p = 3.1415926; 50 | 51 | void setup(void) { 52 | Serial.begin(9600); 53 | Serial.print("Hello! ST7735 TFT Test"); 54 | 55 | // Use this initializer if you're using a 1.8" TFT 56 | tft.init(); // initialize a ST7735S chip 57 | 58 | Serial.println("Initialized"); 59 | 60 | uint16_t time = millis(); 61 | tft.fillScreen(ST7735_BLACK); 62 | time = millis() - time; 63 | 64 | Serial.println(time, DEC); 65 | delay(500); 66 | 67 | // large block of text 68 | tft.fillScreen(ST7735_BLACK); 69 | testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", ST7735_WHITE); 70 | delay(1000); 71 | 72 | // tft print function! 73 | tftPrintTest(); 74 | delay(4000); 75 | 76 | // a single pixel 77 | tft.drawPixel(tft.width()/2, tft.height()/2, ST7735_GREEN); 78 | delay(500); 79 | 80 | // line draw test 81 | testlines(ST7735_YELLOW); 82 | delay(500); 83 | 84 | // optimized lines 85 | testfastlines(ST7735_RED, ST7735_BLUE); 86 | delay(500); 87 | 88 | testdrawrects(ST7735_GREEN); 89 | delay(500); 90 | 91 | testfillrects(ST7735_YELLOW, ST7735_MAGENTA); 92 | delay(500); 93 | 94 | tft.fillScreen(ST7735_BLACK); 95 | testfillcircles(10, ST7735_BLUE); 96 | testdrawcircles(10, ST7735_WHITE); 97 | delay(500); 98 | 99 | testroundrects(); 100 | delay(500); 101 | 102 | testtriangles(); 103 | delay(500); 104 | 105 | mediabuttons(); 106 | delay(500); 107 | 108 | Serial.println("done"); 109 | delay(1000); 110 | } 111 | 112 | void loop() { 113 | tft.invertDisplay(true); 114 | delay(500); 115 | tft.invertDisplay(false); 116 | delay(500); 117 | } 118 | 119 | void testlines(uint16_t color) { 120 | tft.fillScreen(ST7735_BLACK); 121 | for (int16_t x=0; x < tft.width(); x+=6) { 122 | tft.drawLine(0, 0, x, tft.height()-1, color); 123 | } 124 | for (int16_t y=0; y < tft.height(); y+=6) { 125 | tft.drawLine(0, 0, tft.width()-1, y, color); 126 | } 127 | 128 | tft.fillScreen(ST7735_BLACK); 129 | for (int16_t x=0; x < tft.width(); x+=6) { 130 | tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color); 131 | } 132 | for (int16_t y=0; y < tft.height(); y+=6) { 133 | tft.drawLine(tft.width()-1, 0, 0, y, color); 134 | } 135 | 136 | tft.fillScreen(ST7735_BLACK); 137 | for (int16_t x=0; x < tft.width(); x+=6) { 138 | tft.drawLine(0, tft.height()-1, x, 0, color); 139 | } 140 | for (int16_t y=0; y < tft.height(); y+=6) { 141 | tft.drawLine(0, tft.height()-1, tft.width()-1, y, color); 142 | } 143 | 144 | tft.fillScreen(ST7735_BLACK); 145 | for (int16_t x=0; x < tft.width(); x+=6) { 146 | tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color); 147 | } 148 | for (int16_t y=0; y < tft.height(); y+=6) { 149 | tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color); 150 | } 151 | } 152 | 153 | void testdrawtext(char *text, uint16_t color) { 154 | tft.setCursor(0, 0); 155 | tft.setTextColor(color); 156 | tft.setTextWrap(true); 157 | tft.print(text); 158 | } 159 | 160 | void testfastlines(uint16_t color1, uint16_t color2) { 161 | tft.fillScreen(ST7735_BLACK); 162 | for (int16_t y=0; y < tft.height(); y+=5) { 163 | tft.drawFastHLine(0, y, tft.width(), color1); 164 | } 165 | for (int16_t x=0; x < tft.width(); x+=5) { 166 | tft.drawFastVLine(x, 0, tft.height(), color2); 167 | } 168 | } 169 | 170 | void testdrawrects(uint16_t color) { 171 | tft.fillScreen(ST7735_BLACK); 172 | for (int16_t x=0; x < tft.width(); x+=6) { 173 | tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color); 174 | } 175 | } 176 | 177 | void testfillrects(uint16_t color1, uint16_t color2) { 178 | tft.fillScreen(ST7735_BLACK); 179 | for (int16_t x=tft.width()-1; x > 6; x-=6) { 180 | tft.fillRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color1); 181 | tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color2); 182 | } 183 | } 184 | 185 | void testfillcircles(uint8_t radius, uint16_t color) { 186 | for (int16_t x=radius; x < tft.width(); x+=radius*2) { 187 | for (int16_t y=radius; y < tft.height(); y+=radius*2) { 188 | tft.fillCircle(x, y, radius, color); 189 | } 190 | } 191 | } 192 | 193 | void testdrawcircles(uint8_t radius, uint16_t color) { 194 | for (int16_t x=0; x < tft.width()+radius; x+=radius*2) { 195 | for (int16_t y=0; y < tft.height()+radius; y+=radius*2) { 196 | tft.drawCircle(x, y, radius, color); 197 | } 198 | } 199 | } 200 | 201 | void testtriangles() { 202 | tft.fillScreen(ST7735_BLACK); 203 | int color = 0xF800; 204 | int t; 205 | int w = tft.width()/2; 206 | int x = tft.height()-1; 207 | int y = 0; 208 | int z = tft.width(); 209 | for(t = 0 ; t <= 15; t+=1) { 210 | tft.drawTriangle(w, y, y, x, z, x, color); 211 | x-=4; 212 | y+=4; 213 | z-=4; 214 | color+=100; 215 | } 216 | } 217 | 218 | void testroundrects() { 219 | tft.fillScreen(ST7735_BLACK); 220 | int color = 100; 221 | int i; 222 | int t; 223 | for(t = 0 ; t <= 4; t+=1) { 224 | int x = 0; 225 | int y = 0; 226 | int w = tft.width()-2; 227 | int h = tft.height()-2; 228 | for(i = 0 ; i <= 16; i+=1) { 229 | tft.drawRoundRect(x, y, w, h, 5, color); 230 | x+=2; 231 | y+=3; 232 | w-=4; 233 | h-=6; 234 | color+=1100; 235 | } 236 | color+=100; 237 | } 238 | } 239 | 240 | void tftPrintTest() { 241 | tft.setTextWrap(false); 242 | tft.fillScreen(ST7735_BLACK); 243 | tft.setCursor(0, 30); 244 | tft.setTextColor(ST7735_RED); 245 | tft.setTextSize(1); 246 | tft.println("Hello World!"); 247 | tft.setTextColor(ST7735_YELLOW); 248 | tft.setTextSize(2); 249 | tft.println("Hello World!"); 250 | tft.setTextColor(ST7735_GREEN); 251 | tft.setTextSize(3); 252 | tft.println("Hello World!"); 253 | tft.setTextColor(ST7735_BLUE); 254 | tft.setTextSize(4); 255 | tft.print(1234.567); 256 | delay(1500); 257 | tft.setCursor(0, 0); 258 | tft.fillScreen(ST7735_BLACK); 259 | tft.setTextColor(ST7735_WHITE); 260 | tft.setTextSize(0); 261 | tft.println("Hello World!"); 262 | tft.setTextSize(1); 263 | tft.setTextColor(ST7735_GREEN); 264 | tft.print(p, 6); 265 | tft.println(" Want pi?"); 266 | tft.println(" "); 267 | tft.print(8675309, HEX); // print 8,675,309 out in HEX! 268 | tft.println(" Print HEX!"); 269 | tft.println(" "); 270 | tft.setTextColor(ST7735_WHITE); 271 | tft.println("Sketch has been"); 272 | tft.println("running for: "); 273 | tft.setTextColor(ST7735_MAGENTA); 274 | tft.print(millis() / 1000); 275 | tft.setTextColor(ST7735_WHITE); 276 | tft.print(" seconds."); 277 | } 278 | 279 | void mediabuttons() { 280 | // play 281 | tft.fillScreen(ST7735_BLACK); 282 | tft.fillRoundRect(25, 10, 78, 60, 8, ST7735_WHITE); 283 | tft.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_RED); 284 | delay(500); 285 | // pause 286 | tft.fillRoundRect(25, 90, 78, 60, 8, ST7735_WHITE); 287 | tft.fillRoundRect(39, 98, 20, 45, 5, ST7735_GREEN); 288 | tft.fillRoundRect(69, 98, 20, 45, 5, ST7735_GREEN); 289 | delay(500); 290 | // play color 291 | tft.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_BLUE); 292 | delay(50); 293 | // pause color 294 | tft.fillRoundRect(39, 98, 20, 45, 5, ST7735_RED); 295 | tft.fillRoundRect(69, 98, 20, 45, 5, ST7735_RED); 296 | // play color 297 | tft.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_GREEN); 298 | } 299 | 300 | -------------------------------------------------------------------------------- /examples/UTFT_demo_fast/UTFT_demo_fast.ino: -------------------------------------------------------------------------------- 1 | // Demo based on: 2 | // UTFT_Demo_320x240 by Henning Karlsen 3 | // web: http://www.henningkarlsen.com/electronics 4 | // 5 | /* 6 | 7 | This sketch uses the GLCD and font 2 only. Disable other fonts to make 8 | the sketch fit in an UNO! 9 | 10 | Make sure all the required fonts are loaded by editting the 11 | User_Setup.h file in the TFT_ST7735 library folder. 12 | 13 | The library uses the hardware SPI pins only: 14 | For UNO, Nano, Micro Pro ATmega328 based processors 15 | MOSI = pin 11, SCK = pin 13 16 | For Mega: 17 | MOSI = pin 51, SCK = pin 52 18 | 19 | The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST) 20 | signal lines to the TFT must also be defined in the library User_Setup.h file. 21 | 22 | Sugested TFT connections for UNO and Atmega328 based boards 23 | sclk 13 // Don't change, this is the hardware SPI SCLK line 24 | mosi 11 // Don't change, this is the hardware SPI MOSI line 25 | cs 10 // Chip select for TFT display 26 | dc 9 // Data/command line 27 | rst 7 // Reset, you could connect this to the Arduino reset pin 28 | 29 | Suggested TFT connections for the MEGA and ATmega2560 based boards 30 | sclk 52 // Don't change, this is the hardware SPI SCLK line 31 | mosi 51 // Don't change, this is the hardware SPI MOSI line 32 | cs 47 // TFT chip select line 33 | dc 48 // TFT data/command line 34 | rst 44 // you could alternatively connect this to the Arduino reset 35 | 36 | ######################################################################### 37 | ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 38 | ###### TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE ###### 39 | ######################################################################### 40 | */ 41 | 42 | #include // Graphics and font library for ST7735 driver chip 43 | #include 44 | 45 | TFT_ST7735 myGLCD = TFT_ST7735(); // Invoke library, pins defined in User_Setup.h 46 | 47 | #define DELAY 500 48 | 49 | #define TFT_GREY 0x7BEF 50 | #define TFT_W 160 51 | #define TFT_H 128 52 | 53 | unsigned long runTime = 0; 54 | void setup() 55 | { 56 | randomSeed(analogRead(A0)); 57 | pinMode(7, OUTPUT); 58 | digitalWrite(7, LOW); 59 | delay(10); 60 | digitalWrite(7, HIGH); 61 | // Setup the LCD 62 | myGLCD.init(); 63 | myGLCD.setRotation(1); 64 | } 65 | 66 | void loop() 67 | { 68 | randomSeed(millis()); 69 | //randomSeed(1234); // This ensure test is repeatable with exact same draws each loop 70 | int buf[TFT_W-2]; 71 | int x, x2; 72 | int y, y2; 73 | int r; 74 | runTime = millis(); 75 | // Clear the screen and draw the frame 76 | myGLCD.fillScreen(TFT_BLACK); 77 | 78 | 79 | myGLCD.fillRect(0, 0, TFT_W-1, 14,TFT_RED); 80 | 81 | myGLCD.fillRect(0, TFT_H-14, TFT_W-1, 14,TFT_GREY); 82 | 83 | myGLCD.setTextColor(TFT_BLACK,TFT_RED); 84 | myGLCD.drawCentreString("* TFT_S6D02A1 *", TFT_W/2, 4, 1); 85 | myGLCD.setTextColor(TFT_YELLOW,TFT_GREY); 86 | myGLCD.drawCentreString("Adapted by Bodmer", TFT_W/2, TFT_H-12,1); 87 | 88 | myGLCD.drawRect(0, 14, TFT_W-1, TFT_H-28, TFT_BLUE); 89 | 90 | // Draw crosshairs 91 | myGLCD.drawLine(TFT_W/2-1, 15, TFT_W/2-1, TFT_H-16,TFT_BLUE); 92 | myGLCD.drawLine(1, TFT_H/2-1, TFT_W-2, TFT_H/2-1,TFT_BLUE); 93 | for (int i=9; iTFT_W-2) 133 | { 134 | if ((x==TFT_W/2-1)||(buf[x-1]==TFT_H/2-1)) 135 | col = TFT_BLUE; 136 | else 137 | myGLCD.drawPixel(x,buf[x-1],TFT_BLACK); 138 | } 139 | y=TFT_H/2 +(sin(((i*2.2)*3.14)/180)*(49-(i / 100))); 140 | myGLCD.drawPixel(x,y,TFT_BLUE); 141 | buf[x-1]=y; 142 | } 143 | 144 | delay(DELAY); 145 | 146 | myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK); 147 | 148 | // Draw some filled rectangles 149 | for (int i=1; i<6; i++) 150 | { 151 | switch (i) 152 | { 153 | case 1: 154 | col = TFT_MAGENTA; 155 | break; 156 | case 2: 157 | col = TFT_RED; 158 | break; 159 | case 3: 160 | col = TFT_GREEN; 161 | break; 162 | case 4: 163 | col = TFT_BLUE; 164 | break; 165 | case 5: 166 | col = TFT_YELLOW; 167 | break; 168 | } 169 | myGLCD.fillRect(30+(i*10), 20+(i*10), 30, 30,col); 170 | } 171 | 172 | delay(DELAY); 173 | 174 | myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK); 175 | 176 | // Draw some filled, rounded rectangles 177 | for (int i=1; i<6; i++) 178 | { 179 | switch (i) 180 | { 181 | case 1: 182 | col = TFT_MAGENTA; 183 | break; 184 | case 2: 185 | col = TFT_RED; 186 | break; 187 | case 3: 188 | col = TFT_GREEN; 189 | break; 190 | case 4: 191 | col = TFT_BLUE; 192 | break; 193 | case 5: 194 | col = TFT_YELLOW; 195 | break; 196 | } 197 | myGLCD.fillRoundRect(TFT_W/2+20-(i*10), 20+(i*10), 30,30, 3,col); 198 | } 199 | 200 | delay(DELAY); 201 | 202 | myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK); 203 | 204 | // Draw some filled circles 205 | for (int i=1; i<6; i++) 206 | { 207 | switch (i) 208 | { 209 | case 1: 210 | col = TFT_MAGENTA; 211 | break; 212 | case 2: 213 | col = TFT_RED; 214 | break; 215 | case 3: 216 | col = TFT_GREEN; 217 | break; 218 | case 4: 219 | col = TFT_BLUE; 220 | break; 221 | case 5: 222 | col = TFT_YELLOW; 223 | break; 224 | } 225 | myGLCD.fillCircle(45+(i*10),30+(i*10), 15,col); 226 | } 227 | 228 | delay(DELAY); 229 | 230 | myGLCD.fillRect(1,15,TFT_W-3,TFT_H-31,TFT_BLACK); 231 | 232 | // Draw some lines in a pattern 233 | 234 | for (int i=15; i15; i-=5) 240 | { 241 | myGLCD.drawLine(TFT_W-3, i, (i*1.44)-11, 15,TFT_RED); 242 | } 243 | 244 | for (int i=TFT_H-17; i>15; i-=5) 245 | { 246 | myGLCD.drawLine(1, i, TFT_W+11-(i*1.44), 15,TFT_CYAN); 247 | } 248 | 249 | for (int i=15; i