├── DigiFont.cpp ├── DigiFont.h ├── LICENSE ├── README.md ├── README.txt ├── examples ├── DigiFont_lib_All_Styles_ST7789 │ └── DigiFont_lib_All_Styles_ST7789.ino ├── DigiFont_lib_clock_HX1230 │ └── DigiFont_lib_clock_HX1230.ino ├── DigiFont_lib_clock_ST7567 │ └── DigiFont_lib_clock_ST7567.ino ├── DigiFont_lib_clock_ST7789 │ └── DigiFont_lib_clock_ST7789.ino ├── DigiFont_lib_demo_HX1230 │ └── DigiFont_lib_demo_HX1230.ino ├── DigiFont_lib_demo_ST7789 │ └── DigiFont_lib_demo_ST7789.ino ├── DigiFont_lib_float_ST7789 │ └── DigiFont_lib_float_ST7789.ino ├── DigiFont_lib_special_look_HX1230 │ └── DigiFont_lib_special_look_HX1230.ino ├── DigiFont_lib_special_look_ST7567 │ └── DigiFont_lib_special_look_ST7567.ino ├── DigiFont_lib_styles_HX1230 │ └── DigiFont_lib_styles_HX1230.ino ├── DigiFont_lib_styles_ST7789 │ └── DigiFont_lib_styles_ST7789.ino ├── DigiFont_lib_thermometer_HX1230 │ └── DigiFont_lib_thermometer_HX1230.ino ├── DigiFont_lib_thermometer_ST7567 │ └── DigiFont_lib_thermometer_ST7567.ino ├── DigiFont_lib_thermometer_ST7789 │ └── DigiFont_lib_thermometer_ST7789.ino ├── DigiFont_lib_ultimate7seg_HX1230 │ └── DigiFont_lib_ultimate7seg_HX1230.ino ├── DigiFont_lib_ultimate7seg_ST7789 │ └── DigiFont_lib_ultimate7seg_ST7789.ino └── ST7789_font_mem_usage │ └── ST7789_font_mem_usage.ino ├── images ├── allstyles.jpg ├── st1.jpg ├── st2.jpg ├── st2c.jpg ├── st3.jpg ├── st4.jpg ├── st5.jpg ├── st7.jpg ├── stFr.jpg └── style7.jpg ├── keywords.txt └── library.properties /DigiFont.cpp: -------------------------------------------------------------------------------- 1 | // 7-segment and outline font rendering library 2 | // (c) 2020-24 by Pawel A. Hernik 3 | 4 | #include "DigiFont.h" 5 | 6 | // ---------------------------------------------------------------- 7 | DigiFont::DigiFont(void (*_linehFun)(int x0,int x1, int y, int c), 8 | void (*_linevFun)(int x, int y0,int y1, int c), 9 | void (*_rectFun)(int x, int y,int w, int h, int c)) 10 | { 11 | init(_linehFun,_linevFun,_rectFun); 12 | setSize1(10,20,5); 13 | setColors(1,0); 14 | spacing = 1; 15 | clearBg = 1; 16 | frWd = frHt = 4; 17 | } 18 | // ---------------------------------------------------------------- 19 | // linehFun,_linevFun and rectFun callbacks are necessary to initialize the library 20 | void DigiFont::init(void (*_linehFun)(int x0,int x1, int y, int c), 21 | void (*_linevFun)(int x, int y0,int y1, int c), 22 | void (*_rectFun)(int x, int y,int w, int h, int c)) 23 | { 24 | linehFun = _linehFun; 25 | linevFun = _linevFun; 26 | rectFun = _rectFun; 27 | } 28 | 29 | void DigiFont::setFrame(int wd, int ht) 30 | { 31 | frWd = wd; 32 | frHt = ht; 33 | } 34 | 35 | void DigiFont::setSize1(int wd, int ht, int th) 36 | { 37 | digWd = wd; 38 | digHt = ht; 39 | segThick = th; 40 | segWd = wd-2; 41 | segHt = (ht-3)/2; 42 | //Serial.print(segWd); Serial.print("x"); Serial.println(segHt); 43 | } 44 | 45 | // segThick should be an odd value for the best appearance 46 | void DigiFont::setSize2(int wd, int ht, int th) 47 | { 48 | digWd = wd; 49 | digHt = ht; 50 | segThick = th; 51 | segWd = wd-th/2-th/2-2; 52 | segHt = (ht-th-2)/2; 53 | //Serial.print(segWd); Serial.print("x"); Serial.println(segHt); 54 | } 55 | 56 | void DigiFont::setSize3(int wd, int ht, int th) 57 | { 58 | digWd = wd; 59 | digHt = ht; 60 | segThick = th; 61 | //segWd = wd-th*2; 62 | //segHt = (ht-th*3)/2; 63 | segWd = wd-th*2-2; 64 | segHt = (ht-th/2-th/2)/2-1; 65 | //Serial.print(segWd); Serial.print("x"); Serial.println(segHt); 66 | } 67 | 68 | // rectangular style 69 | void DigiFont::setSizeF(int wd, int ht, int th) 70 | { 71 | digWd = wd; 72 | digHt = ht; 73 | segThick = th; 74 | segWd = wd; 75 | segHt = (ht-th*3)/2; 76 | //Serial.print(segWd); Serial.print("x"); Serial.println(segHt); 77 | } 78 | 79 | // outline style 80 | void DigiFont::setSizeO(int wd, int ht, int th) 81 | { 82 | digWd = wd; 83 | digHt = ht; 84 | segThick = th; 85 | segWd = wd; 86 | segHt = (ht-th*3)/2; 87 | //Serial.print(segWd); Serial.print("x"); Serial.println(segHt); 88 | } 89 | 90 | // Style #7 can replace styles #1 and #2 91 | // segThick value should be an odd value for the best appearance 92 | // segSt should be from 0 to int(segThick/2) for the best results 93 | // for example for segThick=7 valid segSt is 0,1,2,3 94 | void DigiFont::setSize7(int wd, int ht, int th, int st) 95 | { 96 | digWd = wd; 97 | digHt = ht; 98 | segThick = th; 99 | segSt = st; 100 | segWd = wd-(segSt+1)*2; 101 | segHt = (ht-segSt*2-3)/2; 102 | } 103 | 104 | void DigiFont::setSegment(int wd, int ht, int th) 105 | { 106 | segThick = th; 107 | segWd = wd; 108 | segHt = ht; 109 | } 110 | 111 | void DigiFont::drawSeg1(int seg, int x, int y, int c) 112 | { 113 | if(!c && !clearBg) return; 114 | int i,ofs=segThick/2; 115 | switch(seg) { 116 | case 0: // top 117 | for(i=0;i='A'?ch-'A'+10:ch; 262 | s=digits[ch&0xf]; 263 | } 264 | drawSeg1(0,x+1, y+0, s&0b0000001); 265 | drawSeg1(1,x+segWd+2-segThick,y+1, s&0b0000010); 266 | drawSeg1(2,x+segWd+2-segThick,y+segHt+2, s&0b0000100); 267 | drawSeg1(3,x+1, y+segHt+2+segHt-segThick+1,s&0b0001000); 268 | drawSeg1(4,x+0, y+segHt+2, s&0b0010000); 269 | drawSeg1(5,x+0, y+1, s&0b0100000); 270 | drawSeg1(6,x+1, y+segHt-segThick/2+1, s&0b1000000); 271 | return digWd; 272 | } 273 | 274 | int DigiFont::drawDigit2(int ch, int x, int y) 275 | { 276 | int s,ofs=1+segThick/2; 277 | switch(ch) { 278 | case '.': 279 | (*rectFun)(x,y+segHt+segHt+2,segThick,segThick,colOn); return segThick; 280 | case '\'': 281 | (*rectFun)(x,y,segThick,segThick,colOn); return segThick; 282 | case ':': 283 | //(*rectFun)(x,y+ofs+(segHt-segThick)/2,segThick,segThick,colOn); 284 | //(*rectFun)(x,y+segHt+1+ofs+(segHt-segThick)/2,segThick,segThick,colOn); 285 | (*rectFun)(x,y+ 1+ofs+(segHt-segThick)/2,segThick,segThick,colOn); 286 | (*rectFun)(x,y+segHt+1+ofs+(segHt-segThick)/2,segThick,segThick,colOn); 287 | return segThick; 288 | case ' ': 289 | s=0; break; 290 | case '-': 291 | s=0b1000000; break; 292 | default: 293 | ch=ch>='A'?ch-'A'+10:ch; 294 | s=digits[ch&0xf]; 295 | } 296 | drawSeg2(0,x+ofs, y+0, s&0b0000001); 297 | drawSeg2(1,x+segWd+1, y+ofs, s&0b0000010); 298 | drawSeg2(2,x+segWd+1, y+ofs+segHt+1, s&0b0000100); 299 | drawSeg2(3,x+ofs, y+segHt+segHt+2,s&0b0001000); 300 | drawSeg2(4,x+0, y+ofs+segHt+1, s&0b0010000); 301 | drawSeg2(5,x+0, y+ofs, s&0b0100000); 302 | drawSeg2(6,x+ofs, y+segHt+1, s&0b1000000); 303 | return digWd; 304 | } 305 | 306 | int DigiFont::drawDigit2c(int ch, int x, int y) 307 | { 308 | int s,ofs=1+segThick/2; 309 | switch(ch) { 310 | case '.': 311 | (*rectFun)(x,y+segHt+segHt+2,segThick,segThick,colOn); 312 | (*rectFun)(x,y+segHt+segHt+2+segThick/2,segThick,segThick-segThick/2,colOn2); 313 | return segThick; 314 | case '\'': 315 | (*rectFun)(x,y,segThick,segThick/2,colOn); 316 | (*rectFun)(x,y+segThick/2,segThick,segThick/2,colOn2); 317 | return segThick; 318 | case ':': 319 | (*rectFun)(x,y+ofs+(segHt-segThick)/2,segThick,segThick/2,colOn); 320 | (*rectFun)(x,y+ofs+(segHt-segThick)/2+segThick/2,segThick,segThick-segThick/2,colOn2); 321 | (*rectFun)(x,y+segHt+1+ofs+(segHt-segThick)/2,segThick,segThick,colOn); 322 | (*rectFun)(x,y+segHt+1+ofs+(segHt-segThick)/2+segThick/2,segThick,segThick-segThick/2,colOn2); 323 | return segThick; 324 | case ' ': 325 | s=0; break; 326 | case '-': 327 | s=0b1000000; break; 328 | default: 329 | ch=ch>='A'?ch-'A'+10:ch; 330 | s=digits[ch&0xf]; 331 | } 332 | drawSeg2c(0,x+ofs, y+0, s&0b0000001); 333 | drawSeg2c(1,x+segWd+1, y+ofs, s&0b0000010); 334 | drawSeg2c(2,x+segWd+1, y+ofs+segHt+1, s&0b0000100); 335 | drawSeg2c(3,x+ofs, y+segHt+segHt+2,s&0b0001000); 336 | drawSeg2c(4,x+0, y+ofs+segHt+1, s&0b0010000); 337 | drawSeg2c(5,x+0, y+ofs, s&0b0100000); 338 | drawSeg2c(6,x+ofs, y+segHt+1, s&0b1000000); 339 | return digWd; 340 | } 341 | 342 | int DigiFont::drawDigit3(int ch, int x, int y) 343 | { 344 | int s,ofs=segThick/2; 345 | switch(ch) { 346 | case '.': 347 | (*rectFun)(x,y+digHt-1-segThick,segThick,segThick,colOn); return segThick; 348 | case '\'': 349 | (*rectFun)(x,y,segThick,segThick,colOn); return segThick; 350 | case ':': 351 | //(*rectFun)(x,y+segThick+(segHt-segThick)/2,segThick,segThick,colOn); 352 | //(*rectFun)(x,y+segHt+segThick*2+(segHt-segThick)/2,segThick,segThick,colOn); 353 | (*rectFun)(x,y+(digHt/2-segThick)/2+1,segThick,segThick,colOn); 354 | (*rectFun)(x,y+digHt-1-(digHt/2-segThick)/2-segThick-1,segThick,segThick,colOn); 355 | return segThick; 356 | case ' ': 357 | s=0; break; 358 | case '-': 359 | s=0b1000000; break; 360 | default: 361 | ch=ch>='A'?ch-'A'+10:ch; 362 | s=digits[ch&0xf]; 363 | } 364 | drawSeg3(0,x+segThick+1, y+0, s&0b0000001); 365 | drawSeg3(1,x+segThick+segWd+2, y+ofs, s&0b0000010); 366 | drawSeg3(2,x+segThick+segWd+2, y+digHt-1-ofs-segHt, s&0b0000100); 367 | drawSeg3(3,x+segThick+1, y+digHt-1-segThick, s&0b0001000); 368 | drawSeg3(4,x+0, y+digHt-1-ofs-segHt, s&0b0010000); 369 | drawSeg3(5,x+0, y+ofs, s&0b0100000); 370 | drawSeg3(6,x+segThick+1, y+(digHt-segThick)/2,s&0b1000000); 371 | return digWd; 372 | } 373 | 374 | int DigiFont::drawDigit7(int ch, int x, int y) 375 | { 376 | int s,offs=segSt+1; 377 | switch(ch) { 378 | case '.': 379 | (*rectFun)(x,y+segHt+segHt+offs-segThick+segSt+2,segThick,segThick,colOn); return segThick; 380 | case '\'': 381 | (*rectFun)(x,y,segThick,segThick,colOn); return segThick; 382 | case ':': 383 | (*rectFun)(x,y+ offs+1+(segHt-segThick)/2,segThick,segThick,colOn); 384 | (*rectFun)(x,y+segHt+offs+1+(segHt-segThick)/2,segThick,segThick,colOn); 385 | return segThick; 386 | case ' ': 387 | s=0; break; 388 | case '-': 389 | s=0b1000000; break; 390 | default: 391 | ch=ch>='A'?ch-'A'+10:ch; 392 | s=digits[ch&0xf]; 393 | } 394 | drawSeg7(0,x+offs, y, s&0b0000001); 395 | drawSeg7(1,x+digWd-segThick, y+offs, s&0b0000010); 396 | drawSeg7(2,x+digWd-segThick, y+offs+segHt+1, s&0b0000100); 397 | drawSeg7(3,x+offs, y+segHt+segHt+offs-segThick+segSt+2, s&0b0001000); 398 | drawSeg7(4,x, y+offs+segHt+1, s&0b0010000); 399 | drawSeg7(5,x, y+offs, s&0b0100000); 400 | drawSeg7(6,x+offs, y+segHt+offs, s&0b1000000); 401 | return digWd; 402 | } 403 | 404 | void DigiFont::clearField(int ch, int x, int y) 405 | { 406 | int hc=(digHt-segThick*3)/2; 407 | switch(ch) { 408 | case '.': 409 | (*rectFun)(x,y,segThick,digHt-segThick,colOff); break; 410 | case '\'': 411 | (*rectFun)(x,y+segThick,segThick,digHt-segThick,colOff); break; 412 | case ':': 413 | (*rectFun)(x,y,segThick,(hc+segThick*2-segThick)/2,colOff); 414 | (*rectFun)(x,y+(hc+segThick*2-segThick)/2+segThick,segThick,digHt-(digHt-hc-segThick-segThick)/2-segThick-((hc+segThick*2-segThick)/2+segThick),colOff); 415 | (*rectFun)(x,y+digHt-(digHt-hc-segThick-segThick)/2,segThick,digHt-(digHt-(digHt-hc-segThick-segThick)/2),colOff); 416 | break; 417 | case ' ': 418 | (*rectFun)(x,y,digWd-segThick,digHt,colOff); break; 419 | case '-': 420 | (*rectFun)(x,y, digWd,hc+segThick,colOff); 421 | (*rectFun)(x,y+hc+segThick*2, digWd,digHt-hc-segThick*2,colOff); 422 | break; 423 | case 'C': 424 | case 'c': 425 | (*rectFun)(x+segThick, y+segThick, digWd-segThick,digHt-segThick*2,colOff); break; 426 | case '0': 427 | (*rectFun)(x+segThick,y+segThick, digWd-segThick*2,digHt-segThick*2,colOff); 428 | break; 429 | case '1': 430 | (*rectFun)(x,y, digWd-segThick,digHt,colOff); break; 431 | case '2': 432 | (*rectFun)(x, y+segThick, digWd-segThick, hc,colOff); 433 | (*rectFun)(x+segThick, y+hc+segThick*2, digWd-segThick, digHt-hc-segThick*3,colOff); 434 | break; 435 | case '3': 436 | (*rectFun)(x, y+segThick, digWd-segThick,hc,colOff); 437 | (*rectFun)(x, y+hc+segThick, digWd/3,segThick,colOff); // for 2/3 width 438 | (*rectFun)(x, y+hc+segThick*2, digWd-segThick,digHt-hc-segThick*3,colOff); 439 | break; 440 | case '4': 441 | (*rectFun)(x+segThick, y, digWd-segThick*2,hc+segThick,colOff); 442 | (*rectFun)(x, y+hc+segThick*2, digWd-segThick,digHt-hc-segThick*2,colOff); 443 | break; 444 | case '5': 445 | (*rectFun)(x+segThick, y+segThick, digWd-segThick, hc,colOff); 446 | (*rectFun)(x, y+hc+segThick*2, digWd-segThick, digHt-hc-segThick*3,colOff); 447 | break; 448 | case '6': 449 | (*rectFun)(x+segThick, y+segThick, digWd-segThick, hc,colOff); 450 | (*rectFun)(x+segThick, y+hc+segThick*2, digWd-segThick*2, digHt-hc-segThick*3,colOff); 451 | break; 452 | case '7': 453 | (*rectFun)(x,y+segThick, digWd-segThick,digHt-segThick,colOff); break; 454 | break; 455 | case '8': 456 | (*rectFun)(x+segThick, y+segThick, digWd-segThick*2, hc,colOff); 457 | (*rectFun)(x+segThick, y+hc+segThick*2, digWd-segThick*2, digHt-hc-segThick*3,colOff); 458 | break; 459 | case '9': 460 | (*rectFun)(x+segThick, y+segThick, digWd-segThick*2, hc,colOff); 461 | (*rectFun)(x, y+hc+segThick*2, digWd-segThick, digHt-hc-segThick*3,colOff); 462 | break; 463 | } 464 | } 465 | 466 | void DigiFont::clearFO(int ch, int x, int y) 467 | { 468 | int hc=(digHt-segThick*3)/2; 469 | switch(ch) { 470 | /* 471 | case '.': 472 | (*rectFun)(x,y,segThick,digHt-segThick,colOff); break; 473 | case '\'': 474 | (*rectFun)(x,y+segThick,segThick,digHt-segThick,colOff); break; 475 | case ':': 476 | (*rectFun)(x,y,segThick,(hc+segThick*2-segThick)/2,colOff); 477 | (*rectFun)(x,y+(hc+segThick*2-segThick)/2+segThick,segThick,digHt-(digHt-hc-segThick-segThick)/2-segThick-((hc+segThick*2-segThick)/2+segThick),colOff); 478 | (*rectFun)(x,y+digHt-(digHt-hc-segThick-segThick)/2,segThick,digHt-(digHt-(digHt-hc-segThick-segThick)/2),colOff); 479 | break; 480 | */ 481 | case ' ': 482 | (*rectFun)(x, y,segThick,digHt,colOff); 483 | (*rectFun)(x+digWd-segThick,y,segThick,digHt,colOff); 484 | (*rectFun)(x+segThick,y, digWd-segThick*2,segThick,colOff); 485 | (*rectFun)(x+segThick,y+digHt-segThick,digWd-segThick*2,segThick,colOff); 486 | (*rectFun)(x+segThick,y+hc+segThick, digWd-segThick*2,segThick,colOff); 487 | case '-': 488 | (*rectFun)(x,y, digWd,hc+segThick,colOff); 489 | (*rectFun)(x,y+hc+segThick*2, digWd,digHt-hc-segThick*2,colOff); 490 | break; 491 | case 'C': 492 | case 'c': 493 | (*rectFun)(x+segThick, y+hc+segThick, digWd-segThick*2,segThick,colOff); 494 | (*rectFun)(x+digWd-segThick, y+segThick, segThick, digHt-segThick*2, colOff); 495 | break; 496 | case '0': 497 | (*rectFun)(x+segThick,y+hc+segThick, digWd-segThick*2,segThick,colOff); 498 | break; 499 | case '1': 500 | (*rectFun)(x, y, segThick,digHt,colOff); 501 | (*rectFun)(x+segThick,y, digWd-segThick*2,segThick,colOff); 502 | (*rectFun)(x+segThick,y+hc+segThick, digWd-segThick*2,segThick,colOff); 503 | (*rectFun)(x+segThick,y+digHt-segThick,digWd-segThick*2,segThick,colOff); 504 | break; 505 | case '2': 506 | (*rectFun)(x, y+segThick, segThick,hc,colOff); 507 | (*rectFun)(x+digWd-segThick,y+segThick*2+hc,segThick,digHt-hc-segThick*3,colOff); 508 | break; 509 | case '3': 510 | (*rectFun)(x, y+segThick, segThick,digHt-segThick*2,colOff); 511 | (*rectFun)(x+segThick,y+hc+segThick, digWd/3-segThick,segThick,colOff); // for 2/3 width 512 | break; 513 | case '4': 514 | (*rectFun)(x, y+segThick*2+hc, segThick,digHt-segThick*2-hc,colOff); 515 | (*rectFun)(x+segThick,y, digWd-segThick*2,segThick,colOff); 516 | (*rectFun)(x+segThick,y+digHt-segThick, digWd-segThick*2,segThick,colOff); 517 | break; 518 | case '5': 519 | (*rectFun)(x+digWd-segThick,y+segThick, segThick,hc,colOff); 520 | (*rectFun)(x, y+segThick*2+hc,segThick,digHt-hc-segThick*3,colOff); 521 | break; 522 | case '6': 523 | (*rectFun)(x+digWd-segThick,y+segThick, segThick,hc,colOff); 524 | break; 525 | case '7': 526 | (*rectFun)(x, y+segThick, segThick,digHt-segThick,colOff); 527 | (*rectFun)(x+segThick,y+hc+segThick, digWd-segThick*2,segThick,colOff); 528 | (*rectFun)(x+segThick,y+digHt-segThick,digWd-segThick*2,segThick,colOff); 529 | break; 530 | case '8': 531 | break; 532 | case '9': 533 | (*rectFun)(x, y+hc+segThick*2,segThick,digHt-hc-segThick*3,colOff); 534 | break; 535 | } 536 | } 537 | 538 | int DigiFont::drawDigitF(int ch, int x, int y) 539 | { 540 | int hc=(digHt-segThick*3)/2; 541 | switch(ch) { 542 | case '.': 543 | (*rectFun)(x,y+digHt-segThick,segThick,segThick,colOn); return segThick; 544 | case '\'': 545 | (*rectFun)(x,y,segThick,segThick,colOn); return segThick; 546 | case ':': 547 | //(*rectFun)(x,y+digHt-digHt/2-segThick*2,segThick,segThick,colOn); 548 | //(*rectFun)(x,y+digHt-digHt/2+segThick*1,segThick,segThick,colOn); 549 | (*rectFun)(x,y+(hc+segThick*2-segThick)/2,segThick,segThick,colOn); // middle of top part 550 | (*rectFun)(x,y+digHt-(digHt-hc-segThick-segThick)/2-segThick,segThick,segThick,colOn); // middle of bottom part 551 | return segThick; 552 | case ' ': 553 | break; 554 | case '-': 555 | (*rectFun)(x,y+hc+segThick, digWd,segThick,colOn); 556 | break; 557 | case 'C': 558 | case 'c': 559 | (*rectFun)(x, y, segThick,digHt, colOn); 560 | (*rectFun)(x+segThick, y,digWd-segThick,segThick, colOn); 561 | (*rectFun)(x+segThick, y+digHt-segThick,digWd-segThick,segThick,colOn); 562 | break; 563 | case '0': 564 | (*rectFun)(x, y,segThick,digHt,colOn); 565 | (*rectFun)(x+digWd-segThick,y,segThick,digHt,colOn); 566 | (*rectFun)(x+segThick,y, digWd-segThick*2,segThick,colOn); 567 | (*rectFun)(x+segThick,y+digHt-segThick,digWd-segThick*2,segThick,colOn); 568 | break; 569 | case '1': 570 | (*rectFun)(x+digWd-segThick,y,segThick,digHt,colOn); 571 | break; 572 | case '2': 573 | (*rectFun)(x,y, digWd,segThick,colOn); 574 | (*rectFun)(x,y+hc+segThick, digWd,segThick,colOn); 575 | (*rectFun)(x,y+digHt-segThick,digWd,segThick,colOn); 576 | (*rectFun)(x, y+segThick*2+hc,segThick,digHt-hc-segThick*3,colOn); 577 | (*rectFun)(x+digWd-segThick,y+segThick, segThick,hc,colOn); 578 | break; 579 | case '3': 580 | (*rectFun)(x,y, digWd-segThick,segThick,colOn); 581 | //(*rectFun)(x+segThick,y+hc+segThick, digWd-segThick*1,segThick,colOn); 582 | //(*rectFun)(x,y+hc+segThick, digWd-segThick,segThick,colOn); // full width 583 | (*rectFun)(x+digWd/3,y+hc+segThick, digWd-segThick-digWd/3,segThick,colOn); // 2/3 width 584 | (*rectFun)(x,y+digHt-segThick,digWd-segThick,segThick,colOn); 585 | (*rectFun)(x+digWd-segThick,y, segThick,digHt,colOn); 586 | break; 587 | case '4': 588 | (*rectFun)(x+digWd-segThick,y, segThick,digHt,colOn); 589 | (*rectFun)(x, y, segThick,hc+segThick*2,colOn); 590 | (*rectFun)(x+segThick, y+hc+segThick, digWd-segThick*2,segThick,colOn); 591 | //(*rectFun)(x+digWd-segThick,y+segThick, segThick,digHt-segThick,colOn); 592 | //(*rectFun)(x,y, segThick,hc+segThick*3,colOn); 593 | //(*rectFun)(x+segThick,y+hc+segThick*2, digWd-segThick*2,segThick,colOn); 594 | break; 595 | case '5': 596 | (*rectFun)(x,y, digWd,segThick,colOn); 597 | (*rectFun)(x,y+hc+segThick, digWd,segThick,colOn); 598 | (*rectFun)(x,y+digHt-segThick,digWd,segThick,colOn); 599 | (*rectFun)(x, y+segThick, segThick,hc,colOn); 600 | (*rectFun)(x+digWd-segThick,y+segThick*2+hc,segThick,digHt-hc-segThick*3,colOn); 601 | break; 602 | case '6': 603 | (*rectFun)(x,y, digWd,segThick,colOn); 604 | (*rectFun)(x+segThick,y+hc+segThick, digWd-segThick,segThick,colOn); 605 | (*rectFun)(x,y+digHt-segThick, digWd,segThick,colOn); 606 | (*rectFun)(x, y+segThick, segThick,digHt-segThick*2,colOn); 607 | (*rectFun)(x+digWd-segThick,y+hc+segThick*2, segThick,digHt-hc-segThick*3,colOn); 608 | break; 609 | case '7': 610 | (*rectFun)(x+digWd-segThick,y,segThick, digHt,colOn); 611 | (*rectFun)(x, y,digWd-segThick,segThick,colOn); 612 | break; 613 | case '8': 614 | (*rectFun)(x, y,segThick,digHt,colOn); 615 | (*rectFun)(x+digWd-segThick,y,segThick,digHt,colOn); 616 | (*rectFun)(x+segThick,y, digWd-segThick*2,segThick,colOn); 617 | (*rectFun)(x+segThick,y+digHt-segThick,digWd-segThick*2,segThick,colOn); 618 | (*rectFun)(x+segThick,y+hc+segThick, digWd-segThick*2,segThick,colOn); 619 | break; 620 | case '9': 621 | (*rectFun)(x, y, segThick,hc+segThick*2,colOn); 622 | (*rectFun)(x+digWd-segThick,y, segThick,digHt,colOn); 623 | (*rectFun)(x+segThick, y, digWd-segThick*2,segThick,colOn); 624 | (*rectFun)(x+segThick, y+hc+segThick, digWd-segThick*2,segThick,colOn); 625 | (*rectFun)(x, y+digHt-segThick, digWd-segThick,segThick,colOn); 626 | break; 627 | } 628 | return digWd; 629 | } 630 | 631 | void DigiFont::rect(int x, int y, int w, int h, int col) 632 | { 633 | (*linehFun)(x, x+w-1, y+h-1,col); 634 | (*linehFun)(x, x+w-1, y, col); 635 | (*linevFun)(x, y+1, y+h-2,col); 636 | (*linevFun)(x+w-1,y+1, y+h-2,col); 637 | } 638 | 639 | int DigiFont::drawDigitO(int ch, int x, int y) 640 | { 641 | int hc=(digHt-segThick*3)/2; 642 | if(clearBg) { 643 | clearFO(ch,x,y); 644 | // cleaning up leftover after previous digits - should it be avoided in case of [.:] ? 645 | (*rectFun)(x+1,y+1, segThick-1,segThick-1,colOff); 646 | (*rectFun)(x+digWd-segThick,y+1, segThick-1,segThick-1,colOff); 647 | (*rectFun)(x+digWd-segThick,y+digHt-segThick, segThick-1,segThick-1,colOff); 648 | (*rectFun)(x+digWd-segThick,y+hc+segThick, segThick-1,segThick,colOff); 649 | (*rectFun)(x+1,y+hc+segThick, segThick-1,segThick,colOff); 650 | (*rectFun)(x+1,y+digHt-segThick, segThick-1,segThick-1,colOff); 651 | //(*linevFun)(x+segThick, y+segThick+hc+1, y+segThick+hc+1+segThick-2, colOff); // le-mid-short '3' 652 | (*linevFun)(x+digWd/3-1, y+segThick+hc+1, y+segThick+hc+1+segThick-2, colOff); // le-mid-short '3' 653 | (*linehFun)(x+1,x+segThick-1, y+digHt-segThick, colOff); // bot-left 654 | } 655 | switch(ch) { 656 | case '.': 657 | rect(x,y+digHt-segThick,segThick,segThick,colOn); return segThick; 658 | case '\'': 659 | rect(x,y,segThick,segThick,colOn); return segThick; 660 | case ':': 661 | //rect(x,y+(digHt/2-segThick)/2+2,segThick,segThick,colOn); 662 | //rect(x,y+digHt-1-(digHt/2-segThick)/2-segThick-1,segThick,segThick,colOn); 663 | rect(x,y+(hc+segThick*2-segThick)/2,segThick,segThick,colOn); // middle of top part 664 | rect(x,y+digHt-(digHt-hc-segThick-segThick)/2-segThick,segThick,segThick,colOn); // middle of bottom part 665 | return segThick; 666 | case ' ': 667 | break; 668 | case '-': 669 | rect(x,y+hc+segThick, digWd,segThick,colOn); 670 | break; 671 | case 'C': 672 | case 'c': 673 | (*linehFun)(x, x+digWd-1, y, colOn); // top 674 | (*linehFun)(x, x+digWd-1, y+digHt-1, colOn); // bottom 675 | (*linevFun)(x, y+1, y+digHt-2, colOn); // left 676 | (*linevFun)(x+digWd-1, y+1, y+segThick-2, colOn); // short top 677 | (*linevFun)(x+digWd-1, y+digHt-segThick+1, y+digHt-1, colOn); // short bottom 678 | (*linevFun)(x+segThick-1, y+segThick, y+digHt-segThick-1, colOn); // inside 679 | (*linehFun)(x+segThick-1, x+digWd-1, y+segThick-1, colOn); // top 680 | (*linehFun)(x+segThick-1, x+digWd-1, y+digHt-segThick, colOn); // bottom 681 | break; 682 | case '0': 683 | rect(x,y,digWd,digHt,colOn); 684 | rect(x+segThick-1,y+segThick-1,digWd-segThick*2+2,digHt-segThick*2+2,colOn); 685 | break; 686 | case '1': 687 | rect(x+digWd-segThick,y,segThick,digHt,colOn); 688 | break; 689 | case '2': 690 | (*linehFun)(x, x+digWd-1, y, colOn); // top 691 | (*linehFun)(x, x+digWd-segThick, y+segThick-1, colOn); // top2 692 | (*linehFun)(x, x+digWd-1, y+digHt-1, colOn); // bottom 693 | (*linehFun)(x+segThick, x+digWd-1, y+digHt-segThick, colOn); // bottom2 694 | (*linehFun)(x, x+digWd-segThick, y+segThick+hc, colOn); // mid 695 | (*linehFun)(x+segThick, x+digWd-1, y+segThick+hc+segThick-1, colOn); // mid2 696 | (*linevFun)(x+digWd-1, y+1, y+hc+segThick*2-1, colOn); // rt 697 | (*linevFun)(x+digWd-segThick, y+segThick-1, y+hc+segThick, colOn); // rt le 698 | (*linevFun)(x, y+hc+segThick+1, y+digHt-2, colOn); // le 699 | (*linevFun)(x+segThick-1, y+hc+segThick*2-1, y+digHt-segThick, colOn); // le rt 700 | (*linevFun)(x, y+1, y+segThick-2, colOn); // le short 701 | (*linevFun)(x+digWd-1, y+digHt-segThick+1, y+digHt-2, colOn); // rt short 702 | break; 703 | case '3': 704 | (*linehFun)(x, x+digWd-1, y, colOn); // top 705 | (*linehFun)(x, x+digWd-1, y+digHt-1, colOn); // bottom 706 | (*linehFun)(x, x+digWd-segThick, y+segThick-1, colOn); // top2 707 | (*linehFun)(x, x+digWd-segThick, y+digHt-segThick, colOn); // bottom2 708 | //(*linehFun)(x+segThick, x+digWd-segThick, y+segThick+hc, colOn); // mid1 709 | //(*linehFun)(x+segThick, x+digWd-segThick, y+segThick*2+hc-1, colOn); // mid2 710 | //(*linehFun)(x, x+digWd-segThick, y+segThick+hc, colOn); // mid1 full width 711 | //(*linehFun)(x, x+digWd-segThick, y+segThick*2+hc-1, colOn); // mid2 full width 712 | (*linehFun)(x+digWd/3, x+digWd-segThick, y+segThick+hc, colOn); // mid1 2/3 width 713 | (*linehFun)(x+digWd/3, x+digWd-segThick, y+segThick*2+hc-1, colOn); // mid2 2/3 width 714 | (*linevFun)(x+digWd-1, y+1, y+digHt-2, colOn); // rt-long 715 | (*linevFun)(x, y+1, y+segThick-2, colOn); // le-top-short 716 | (*linevFun)(x, y+digHt-segThick+1, y+digHt-2, colOn); // le-bot-short 717 | //(*linevFun)(x+segThick, y+segThick+hc+1, y+segThick+hc+1+segThick-2, colOn); // le-mid-short 718 | //(*linevFun)(x, y+segThick+hc+1, y+segThick+hc+1+segThick-2, colOn); // le-mid-short full width 719 | (*linevFun)(x+digWd/3-1, y+segThick+hc+0, y+segThick+hc+1+segThick-2, colOn); // le-mid-short 2/3 width 720 | (*linevFun)(x+digWd-segThick, y+segThick, y+segThick+1+hc-1, colOn); //le-top 721 | (*linevFun)(x+digWd-segThick, y+segThick*2+hc, y+segThick*2+hc+1+hc-1, colOn); //le-bot 722 | break; 723 | case '4': 724 | (*linehFun)(x, x+segThick-1, y, colOn); // top short1 725 | (*linehFun)(x+digWd-segThick, x+digWd-1, y, colOn); // top short2 726 | (*linehFun)(x+digWd-segThick, x+digWd-1, y+digHt-1, colOn); // bottom short 727 | (*linehFun)(x+segThick, x+digWd-segThick, y+segThick+hc, colOn); // mid1 728 | (*linehFun)(x, x+digWd-segThick, y+segThick+hc+segThick-1, colOn); // mid2 729 | (*linevFun)(x+digWd-1, y+1, y+digHt-2, colOn); // rt-long 730 | (*linevFun)(x+digWd-segThick, y+1, y+segThick+hc-1, colOn); //rt-left-top 731 | (*linevFun)(x+digWd-segThick, y+hc+segThick*2, y+digHt-2, colOn); //rt-left-bot 732 | (*linevFun)(x, y+1, y+segThick*2+hc-1, colOn); //le-le 733 | (*linevFun)(x+segThick-1, y+1, y+segThick+hc, colOn); //le-rt 734 | break; 735 | case '5': 736 | (*linehFun)(x, x+digWd-1, y, colOn); // top 737 | (*linehFun)(x+segThick, x+digWd-1, y+segThick-1, colOn); // top2 738 | (*linehFun)(x, x+digWd-1, y+digHt-1, colOn); // bottom 739 | (*linehFun)(x, x+digWd-segThick, y+digHt-segThick, colOn); // bottom2 740 | (*linehFun)(x+segThick, x+digWd-1, y+segThick+hc, colOn); // mid 741 | (*linehFun)(x, x+digWd-segThick, y+segThick+hc+segThick-1, colOn); // mid2 742 | (*linevFun)(x, y+1, y+hc+segThick*2-1, colOn); // le 743 | (*linevFun)(x+segThick-1, y+segThick-1, y+hc+segThick, colOn); // le rt 744 | (*linevFun)(x+digWd-1, y+hc+segThick+1, y+digHt-2, colOn); // rt 745 | (*linevFun)(x+digWd-segThick, y+hc+segThick*2, y+digHt-segThick-1, colOn); // rt le 746 | (*linevFun)(x+digWd-1, y+1, y+segThick-2, colOn); // rt short 747 | (*linevFun)(x, y+digHt-segThick+1, y+digHt-2, colOn); // le short 748 | break; 749 | case '6': 750 | rect(x+segThick-1,y+hc+segThick*2-1,digWd-segThick*2+2,digHt-hc-segThick*3+2,colOn); 751 | (*linehFun)(x, x+digWd-1, y, colOn); // top 752 | (*linehFun)(x+segThick, x+digWd-1, y+segThick-1, colOn); // top2 753 | (*linehFun)(x, x+digWd-1, y+digHt-1, colOn); // bottom 754 | (*linehFun)(x+segThick, x+digWd-1, y+segThick+hc, colOn); // mid 755 | (*linevFun)(x, y+1, y+digHt-2, colOn); // le long 756 | (*linevFun)(x+segThick-1, y+segThick-1, y+hc+segThick, colOn); // le rt 757 | (*linevFun)(x+digWd-1, y+hc+segThick+1, y+digHt-2, colOn); // rt 758 | (*linevFun)(x+digWd-1, y+1, y+segThick-2, colOn); // rt short 759 | break; 760 | case '7': 761 | (*linehFun)(x, x+digWd-1, y, colOn); // top 762 | (*linehFun)(x+digWd-segThick, x+digWd-1, y+digHt-1, colOn); // bottom 763 | (*linehFun)(x, x+digWd-1-segThick, y+segThick-1, colOn); // bottom2 764 | (*linevFun)(x+digWd-1, y+1, y+digHt-2, colOn); // rt-long 765 | (*linevFun)(x, y+1, y+segThick-2, colOn); // le-short 766 | (*linevFun)(x+digWd-segThick, y+segThick-1, y+digHt-1, colOn); // rt-le-long 767 | break; 768 | case '8': 769 | rect(x,y,digWd,digHt,colOn); 770 | rect(x+segThick-1,y+segThick-1, digWd-segThick*2+2,hc+2,colOn); 771 | rect(x+segThick-1,y+hc+segThick*2-1,digWd-segThick*2+2,digHt-hc-segThick*3+2,colOn); 772 | break; 773 | case '9': 774 | rect(x+segThick-1,y+segThick-1, digWd-segThick*2+2,hc+2,colOn); 775 | (*linehFun)(x, x+digWd-1, y, colOn); // top 776 | (*linehFun)(x, x+digWd-1, y+digHt-1, colOn); // bot 777 | (*linehFun)(x, x+digWd-1-segThick, y+segThick*2+hc-1, colOn); // mid 778 | (*linehFun)(x, x+digWd-1-segThick, y+digHt-segThick, colOn); // bot-higher 779 | (*linevFun)(x+digWd-1, y+1, y+digHt-2, colOn); // rt-long 780 | (*linevFun)(x, y+1, y+hc+segThick*2-2, colOn); // le-top 781 | (*linevFun)(x, y+digHt-segThick+1, y+digHt-2, colOn); // le-bot-short 782 | (*linevFun)(x+digWd-segThick, y+hc+segThick*2-1, y+digHt-segThick, colOn); // rt-le-bot 783 | break; 784 | } 785 | return digWd; 786 | } 787 | 788 | int DigiFont::printNumber1(char *txt, int x, int y) 789 | { 790 | while(*txt) x+=drawDigit1(*txt++,x,y)+spacing; 791 | return x-spacing; 792 | } 793 | 794 | int DigiFont::printNumber2(char *txt, int x, int y) 795 | { 796 | while(*txt) x+=drawDigit2(*txt++,x,y)+spacing; 797 | return x-spacing; 798 | } 799 | 800 | int DigiFont::printNumber2c(char *txt, int x, int y) 801 | { 802 | while(*txt) x+=drawDigit2c(*txt++,x,y)+spacing; 803 | return x-spacing; 804 | } 805 | 806 | int DigiFont::printNumber3(char *txt, int x, int y) 807 | { 808 | while(*txt) x+=drawDigit3(*txt++,x,y)+spacing; 809 | return x-spacing; 810 | } 811 | 812 | int DigiFont::printNumberF(char *txt, int x, int y) 813 | { 814 | while(*txt) { 815 | if(clearBg) clearFO(*txt,x,y); 816 | x+=drawDigitF(*txt++,x,y)+spacing; 817 | } 818 | return x-spacing; 819 | } 820 | 821 | int DigiFont::printNumberFr(char *txt, int x, int y) 822 | { 823 | int xf=x-frWd; 824 | while(*txt) { 825 | if(clearBg) clearField(*txt,x,y); 826 | x+=drawDigitF(*txt++,x,y)+spacing; 827 | if(*txt && clearBg) (*rectFun)(x-spacing,y, spacing,digHt,colOff); 828 | } 829 | if(clearBg) { 830 | (*rectFun)(xf,y-frHt, x-spacing+frWd-xf,frHt,colOff); 831 | (*rectFun)(xf,y+digHt, x-spacing+frWd-xf,frHt,colOff); 832 | (*rectFun)(xf,y, frWd,digHt,colOff); 833 | (*rectFun)(x-spacing,y, frWd,digHt,colOff); 834 | } 835 | return x-spacing; 836 | } 837 | 838 | int DigiFont::printNumberO(char *txt, int x, int y) 839 | { 840 | while(*txt) x+=drawDigitO(*txt++,x,y)+spacing; 841 | return x-spacing; 842 | } 843 | 844 | int DigiFont::printNumber7(char *txt, int x, int y) 845 | { 846 | while(*txt) x+=drawDigit7(*txt++,x,y)+spacing; 847 | return x-spacing; 848 | } 849 | 850 | int DigiFont::getNumberWidth(char *txt) 851 | { 852 | int wd=0; 853 | while(*txt) { wd+=((*txt=='.' || *txt==':' || *txt=='\'')?segThick:digWd)+spacing; txt++; } 854 | return wd-spacing; 855 | } 856 | 857 | // --------------------------------- 858 | -------------------------------------------------------------------------------- /DigiFont.h: -------------------------------------------------------------------------------- 1 | // 7-segment and outline font rendering library 2 | // (c) 2020-24 by Pawel A. Hernik 3 | 4 | #ifndef _DIGI_FONT_H 5 | #define _DIGI_FONT_H 6 | 7 | // --------------------------------- 8 | class DigiFont { 9 | public: 10 | DigiFont(void (*_linehFun)(int x0,int x1, int y, int c), 11 | void (*_linevFun)(int x, int y0,int y1, int c), 12 | void (*_rectFun)(int x, int y,int w, int h, int c)); 13 | void init(void (*_linehFun)(int x0,int x1, int y, int c), 14 | void (*_linevFun)(int x, int y0,int y1, int c), 15 | void (*_rectFun)(int x, int y,int w, int h, int c)); 16 | 17 | // separate method for each style to save program memory 18 | void drawSeg1(int seg, int x, int y, int c); 19 | void drawSeg2(int seg, int x, int y, int c); 20 | void drawSeg2c(int seg, int x, int y, int c); 21 | void drawSeg3(int seg, int x, int y, int c); 22 | void drawSeg7(int seg, int x, int y, int c); 23 | 24 | int drawDigit1(int ch, int x, int y); 25 | int drawDigit2(int ch, int x, int y); 26 | int drawDigit2c(int ch, int x, int y); 27 | int drawDigit3(int ch, int x, int y); 28 | int drawDigitF(int ch, int x, int y); 29 | int drawDigitO(int ch, int x, int y); 30 | int drawDigit4(int ch, int x, int y) { return drawDigitF(ch,x,y); } 31 | int drawDigit5(int ch, int x, int y) { return drawDigitO(ch,x,y); } 32 | int drawDigit7(int ch, int x, int y); 33 | 34 | int printNumber1(char *txt, int x, int y); 35 | int printNumber2(char *txt, int x, int y); 36 | int printNumber2c(char *txt, int x, int y); 37 | int printNumber3(char *txt, int x, int y); 38 | int printNumberF(char *txt, int x, int y); 39 | int printNumberFr(char *txt, int x, int y); 40 | int printNumberO(char *txt, int x, int y); 41 | int printNumber4(char *txt, int x, int y) { return printNumberF(txt,x,y); } 42 | int printNumber5(char *txt, int x, int y) { return printNumberO(txt,x,y); } 43 | int printNumber7(char *txt, int x, int y); 44 | void clearFO(int ch, int x, int y); 45 | void clearField(int ch, int x, int y); 46 | 47 | void setSize1(int wd, int ht, int th); 48 | void setSize2(int wd, int ht, int th); 49 | void setSize2c(int wd, int ht, int th) { setSize2(wd,ht,th); } 50 | void setSize3(int wd, int ht, int th); 51 | void setSizeF(int wd, int ht, int th); 52 | void setSizeO(int wd, int ht, int th); 53 | void setSize4(int wd, int ht, int th) { setSizeF(wd,ht,th); } 54 | void setSize5(int wd, int ht, int th) { setSizeO(wd,ht,th); } 55 | void setSize7(int wd, int ht, int th, int st); 56 | void setFrame(int wd, int ht); 57 | 58 | // common for all styles 59 | void setSegment(int wd, int ht, int th); 60 | void setSpacing(int sp) { spacing = sp; } 61 | void setClearBg(int cl) { clearBg = cl; } 62 | void setColors(int c1, int c0) { colOn=colOn2=c1; colOff=c0; } 63 | void setColors(int c1, int c2, int c0) { colOn=c1; colOn2=c2; colOff=c0; } 64 | int getWidth() { return digWd; } 65 | int getHeight() { return digHt; } 66 | int getNumberWidth(char *txt); 67 | void rect(int x, int y, int w, int h, int col); 68 | 69 | // callbacks 70 | void (*linehFun)(int x0,int x1, int y, int c); 71 | void (*linevFun)(int x, int y0,int y1, int c); 72 | void (*rectFun)(int x, int y,int w, int h, int c); 73 | 74 | static unsigned char digits[16]; 75 | int digWd, digHt; 76 | int segWd, segHt; 77 | int segThick, segSt; 78 | int colOn,colOn2,colOff; 79 | int spacing; 80 | int clearBg; 81 | int frWd, frHt; // frame around number field for style F 82 | }; 83 | #endif 84 | 85 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![license-badge][]][license] ![version] ![hit-count] [![github-issues][]][issues] 2 | 3 | # DigiFont 4 | 5 | A library that allows to render nice, scalable 7-segment digits using the Arduino GFX library. 6 | 7 | |All Styles|Style7 Variations| 8 | |--|--| 9 | | || 10 | 11 | YouTube videos: 12 | 13 | https://youtu.be/X6PjfhcNE98 14 | 15 | https://youtu.be/Z_YCfJZn_bA 16 | 17 | 18 | ## Features 19 | - very fast rendering even on AVR Arduino 20 | - no bitmap data is necessary - only rendering routines 21 | - each number can have different width, height and segment thickness 22 | - should work with any Arduino graphic library with user defined callbacks for drawLine() and fillRect() 23 | - 3 styles of 7-segment font variation 24 | - additional pseudo 3D look for color displays (style 2c) 25 | - simple fast rectangular and outline styles 26 | - each digit clears the necessary segments only, so clearing and refreshing the entire screen is not necessary (important for good performance on high-resolution LCD displays) 27 | - examples for monochrome HX1230, ST7567 and color ST7789 IPS 28 | - each style has separate methods/functions to save program memory 29 | - if necessary only 3-4 functions can be used separately (setSize,drawSeg,drawDigit,printNumber) without the library 30 | - special look with multi-layer rendering is possible: https://youtu.be/OPq9aBJP-pc 31 | - new 7-segment style #7, int which the appearance of the segment can be defined using an additional parameter (can replace styles #1 and #2) 32 | 33 | ## Last changes 34 | - styles 1 and 2/2c are now obsolete, use them only if you need lower memory usage, use style 7 instead 35 | - style 7 supports now 2 colors similar to style 2c 36 | - setSize7(50,100,13,6) is equivalent for setSize2(50,100,13) 37 | - setSize7(50,100,13,0) is equivalent for setSize1(50,100,13) but setSize7(50,100,13,2) gives better appearance 38 | - style 4 and 5 are renamed to F (filled) and O (outline) but old names left for compatibility 39 | - new feature: setFrame(),printNumberFr() to render simple non-flickering numbers on any background with a frame around it 40 | 41 | ## Program memory usage and examples 42 | |Style|Usage|Info|Example| 43 | |--|--|--|--| 44 | |style 1|1650|7-segment style #1|| 45 | |style 2|1452|7-segment style #2|| 46 | |style 2c|1714|2-color version for pseudo 3D appearance|| 47 | |style 3|1270|simple rectangle segments for low memory applications|| 48 | |style F/4|3378|filled|| 49 | |style Fr|3570|filled, with a frame around|| 50 | |style O/5|5924|outline|| 51 | |style 7|1870|versatile replacement for style 1 and 2/2c|| 52 | 53 | If you find it useful and want to buy me a coffee or a beer: 54 | 55 | https://buycoffee.to/cbm80 56 | 57 | https://www.paypal.me/cbm80amiga 58 | 59 | [license-badge]: https://img.shields.io/badge/License-GPLv3-blue.svg 60 | [license]: https://choosealicense.com/licenses/gpl-3.0/ 61 | [version]: https://img.shields.io/badge/Version-1.1.1-green.svg 62 | [hit-count]: https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fcbm80amiga%2FDigiFont&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false 63 | [github-issues]: https://img.shields.io/github/issues/cbm80amiga/DigiFont.svg 64 | [issues]: https://github.com/cbm80amiga/DigiFont/issues/ 65 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | This is a library for nice, scalable 7-segment digits rendered using any Arduino GFX library 2 | Requires "drawLine()" and "fillRect()" functions callbacks 3 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_All_Styles_ST7789/DigiFont_lib_All_Styles_ST7789.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // All styles on ST7789 IPS display 3 | // (c) 2020-24 Pawel A. Hernik 4 | 5 | /* 6 | ST7789 240x240 1.3" IPS (without CS pin) - only 4+2 wires required: 7 | #01 GND -> GND 8 | #02 VCC -> VCC (3.3V only!) 9 | #03 SCL -> D13/SCK 10 | #04 SDA -> D11/MOSI 11 | #05 RES -> D9 /PA0 or any digital (HW RESET is required to properly initialize LCD without CS) 12 | #06 DC -> D10/PA1 or any digital 13 | #07 BLK -> NC 14 | 15 | ST7789 240x280 1.69" IPS - only 4+2 wires required: 16 | #01 GND -> GND 17 | #02 VCC -> VCC (3.3V only!) 18 | #03 SCL -> D13/SCK 19 | #04 SDA -> D11/MOSI 20 | #05 RES -> optional 21 | #06 DC -> D10 or any digital 22 | #07 CS -> D9 or any digital 23 | #08 BLK -> VCC 24 | 25 | ST7789 170x320 1.9" IPS - only 4+2 wires required: 26 | #01 GND -> GND 27 | #02 VCC -> VCC (3.3V only!) 28 | #03 SCL -> D13/SCK 29 | #04 SDA -> D11/MOSI 30 | #05 RES -> optional 31 | #06 DC -> D10 or any digital 32 | #07 CS -> D9 or any digital 33 | #08 BLK -> VCC 34 | 35 | ST7789 240x320 2.0" IPS - only 4+2 wires required: 36 | #01 GND -> GND 37 | #02 VCC -> VCC (3.3V only!) 38 | #03 SCL -> D13/SCK 39 | #04 SDA -> D11/MOSI 40 | #05 RES -> optional 41 | #06 DC -> D10 or any digital 42 | #07 CS -> D9 or any digital 43 | */ 44 | 45 | #include 46 | #include 47 | #include "ST7789_AVR.h" 48 | 49 | #define SCR_WD 240 50 | #define SCR_HT 320 51 | //#define SCR_HT 240 52 | 53 | #define TFT_DC 10 54 | #define TFT_CS 9 // with CS 55 | #define TFT_RST -1 // with CS 56 | ST7789_AVR lcd = ST7789_AVR(TFT_DC, TFT_RST, TFT_CS); 57 | 58 | // ----------------- 59 | #include "DigiFont.h" 60 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 61 | void customLineH(int x0,int x1, int y, int c) { lcd.drawFastHLine(x0,y,x1-x0+1,c); } 62 | void customLineV(int x, int y0,int y1, int c) { lcd.drawFastVLine(x,y0,y1-y0+1,c); } 63 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 64 | DigiFont digi(customLineH,customLineV,customRect); 65 | // ----------------- 66 | 67 | char buf[20],buf2[10]; 68 | long long v=-99999; 69 | unsigned long ms,demoTime=10000; 70 | 71 | void setup(void) 72 | { 73 | Serial.begin(9600); 74 | lcd.init(SCR_WD,SCR_HT); 75 | lcd.fillScreen(BLACK); 76 | } 77 | 78 | void style7() 79 | { 80 | int x=0,y=0,hi=9,ht=44,w=24,h=40; 81 | lcd.fillScreen(BLACK); 82 | digi.setSpacing(2); 83 | lcd.setTextColor(WHITE); 84 | lcd.setTextSize(1); 85 | 86 | lcd.setCursor(0,y); lcd.println("setSize7(24,40,7,3)"); y+=hi; 87 | //digi.setColors(RGBto565(250,50,250),RGBto565(200,20,200),RGBto565(40,0,40)); 88 | digi.setColors(RGBto565(0,250,250),RGBto565(0,190,190),RGBto565(0,40,40)); 89 | digi.setSize7(24,40,7,3); 90 | x=digi.printNumber7("23:45",x,y); x=digi.printNumber7("6.78'C",x+10,y); 91 | y+=ht; x=0; 92 | 93 | lcd.setCursor(0,y); lcd.println("setSize7(24,40,7,2)"); y+=hi; 94 | digi.setColors(RGBto565(250,50,250),RGBto565(190,20,190),RGBto565(60,0,60)); 95 | digi.setSize7(24,40,7,2); 96 | x=digi.printNumber7("23:45",x,y); x=digi.printNumber7("6.78'C",x+10,y); 97 | y+=ht; x=0; 98 | 99 | lcd.setCursor(0,y); lcd.println("setSize7(24,40,7,0)"); y+=hi; 100 | //digi.setColors(RGBto565(50,250,50),RGBto565(0,40,0)); 101 | digi.setColors(RGBto565(250,0,0),RGBto565(80,0,0)); 102 | digi.setSize7(24,40,7,0); 103 | x=digi.printNumber7("23:45",x,y); x=digi.printNumber7("6.78'C",x+10,y); 104 | y+=ht; x=0; 105 | 106 | lcd.setCursor(0,y); lcd.println("setSize7(24,40,7,1)"); y+=hi; 107 | digi.setSize7(24,40,7,1); 108 | x=digi.printNumber7("23:45",x,y); x=digi.printNumber7("6.78'C",x+10,y); 109 | y+=ht; x=0; 110 | 111 | lcd.setCursor(0,y); lcd.println("setSize7(24,40,7,2)"); y+=hi; 112 | digi.setSize7(24,40,7,2); 113 | x=digi.printNumber7("23:45",x,y); x=digi.printNumber7("6.78'C",x+10,y); 114 | y+=ht; x=0; 115 | 116 | lcd.setCursor(0,y); lcd.println("setSize7(24,40,7,3)"); y+=hi; 117 | digi.setSize7(24,40,7,3); 118 | x=digi.printNumber7("23:45",x,y); x=digi.printNumber7("6.78'C",x+10,y); 119 | y+=ht; x=0; 120 | 121 | delay(demoTime); 122 | } 123 | 124 | void style7var() 125 | { 126 | int x=0,y=0,ht=44+9,hi=44+9; 127 | lcd.fillScreen(BLACK); 128 | digi.setSpacing(2); 129 | lcd.setTextColor(WHITE); 130 | lcd.setTextSize(1); 131 | lcd.setCursor(0,y); lcd.println("setSize7(24,40,7,3)"); y+=hi; 132 | lcd.setCursor(0,y); lcd.println("setSize7(24,40,7,2)"); y+=hi; 133 | lcd.setCursor(0,y); lcd.println("setSize7(24,40,7,0)"); y+=hi; 134 | lcd.setCursor(0,y); lcd.println("setSize7(24,40,7,1)"); y+=hi; 135 | lcd.setCursor(0,y); lcd.println("setSize7(24,40,7,2)"); y+=hi; 136 | lcd.setCursor(0,y); lcd.println("setSize7(24,40,7,3)"); y+=hi; 137 | 138 | ms = millis(); 139 | while(millis()-ms 23 | HX1230_FB lcd(LCD_RST, LCD_CS); 24 | 25 | // ----------------- 26 | #include "DigiFont.h" 27 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 28 | void customLineH(int x0,int x1, int y, int c) { lcd.drawLineHfast(x0,x1,y,c); } 29 | void customLineV(int x, int y0,int y1, int c) { lcd.drawLineVfast(x,y0,y1,c); } 30 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 31 | DigiFont font(customLineH,customLineV,customRect); 32 | // ----------------- 33 | 34 | void setup(void) 35 | { 36 | Serial.begin(9600); 37 | pinMode(LCD_BL, OUTPUT); 38 | digitalWrite(LCD_BL, HIGH); 39 | lcd.init(); 40 | lcd.cls(); 41 | lcd.display(); 42 | font.setColors(1,0); 43 | } 44 | 45 | unsigned long ms; 46 | 47 | void demoClock1(int t) 48 | { 49 | int w=22; 50 | font.setSize1(w-1,40,t); 51 | int y=(SCR_HT-40)/2; 52 | ms=millis(); 53 | while(millis()-ms<5000) { 54 | lcd.cls(); 55 | font.drawDigit1(random(0,3),0*w,y); 56 | font.drawDigit1(random(0,4),1*w,y); 57 | font.drawDigit1(':',1+2*w,y); 58 | font.drawDigit1(random(0,6),t+3+2*w,y); 59 | font.drawDigit1(random(0,10),t+3+3*w,y); 60 | lcd.display(); 61 | delay(600); 62 | } 63 | } 64 | 65 | void demoClock2(int t) 66 | { 67 | int w=21; 68 | font.setSize2(w-1,40,t); 69 | int y=(SCR_HT-40)/2; 70 | ms=millis(); 71 | while(millis()-ms<5000) { 72 | lcd.cls(); 73 | font.drawDigit2(random(0,3),0*w,y); 74 | font.drawDigit2(random(0,4),1*w,y); 75 | font.drawDigit2(':',1+2*w,y); 76 | font.drawDigit2(random(0,6),t+3+2*w,y); 77 | font.drawDigit2(random(0,10),t+3+3*w,y); 78 | lcd.display(); 79 | delay(600); 80 | } 81 | } 82 | 83 | void loop() 84 | { 85 | demoClock1(5); 86 | demoClock2(7); 87 | demoClock2(5); 88 | } 89 | 90 | 91 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_clock_ST7567/DigiFont_lib_clock_ST7567.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // Digital clock example on ST7567 LCD 3 | // (c) 2020 Pawel A. Hernik 4 | 5 | /* 6 | 128x64 ST7567 connections in SPI mode (only 5-6 wires between LCD and MCU): 7 | 8 | #01 LED -> D6, GND or any pin via resistor 9 | #02 RST -> D9 or any pin 10 | #03 CS -> D10 or any pin 11 | #04 DC -> D8 or any pin 12 | #05 SCK -> D13/SCK 13 | #06 SDI -> D11/MOSI 14 | #07 3V3 -> VCC (3.3V) 15 | #08 GND -> GND 16 | */ 17 | 18 | #define LCD_BL 6 19 | #define LCD_CS 10 20 | #define LCD_DC 8 21 | #define LCD_RST 9 22 | 23 | #include "ST7567_FB.h" 24 | #include 25 | ST7567_FB lcd(LCD_DC, LCD_RST, LCD_CS); 26 | 27 | // ----------------- 28 | #include "DigiFont.h" 29 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 30 | void customLineH(int x0,int x1, int y, int c) { lcd.drawLineHfast(x0,x1,y,c); } 31 | void customLineV(int x, int y0,int y1, int c) { lcd.drawLineVfast(x,y0,y1,c); } 32 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 33 | DigiFont font(customLineH,customLineV,customRect); 34 | // ----------------- 35 | 36 | void setup(void) 37 | { 38 | Serial.begin(9600); 39 | pinMode(LCD_BL, OUTPUT); 40 | digitalWrite(LCD_BL, LOW); 41 | lcd.init(); 42 | lcd.cls(); 43 | lcd.display(); 44 | font.setColors(1,0); 45 | } 46 | 47 | unsigned long ms; 48 | 49 | void demoClock1(int t) 50 | { 51 | int w=29; 52 | font.setSize1(w-1,60,t); 53 | int y=(SCR_HT-60)/2; 54 | ms=millis(); 55 | while(millis()-ms<5000) { 56 | lcd.cls(); 57 | font.drawDigit1(random(0,3),0*w,y); 58 | font.drawDigit1(random(0,4),1*w,y); 59 | font.drawDigit1(':',1+2*w,y); 60 | font.drawDigit1(random(0,6),t+3+2*w,y); 61 | font.drawDigit1(random(0,10),t+3+3*w,y); 62 | lcd.display(); 63 | delay(600); 64 | } 65 | } 66 | 67 | void demoClock2(int t) 68 | { 69 | int w=29; 70 | font.setSize2(w-1,60,t); 71 | int y=(SCR_HT-60)/2; 72 | ms=millis(); 73 | while(millis()-ms<5000) { 74 | lcd.cls(); 75 | font.drawDigit2(random(0,3),0*w,y); 76 | font.drawDigit2(random(0,4),1*w,y); 77 | font.drawDigit2(':',1+2*w,y); 78 | font.drawDigit2(random(0,6),t+3+2*w,y); 79 | font.drawDigit2(random(0,10),t+3+3*w,y); 80 | lcd.display(); 81 | delay(600); 82 | } 83 | } 84 | 85 | void loop() 86 | { 87 | demoClock1(5); 88 | demoClock2(7); 89 | demoClock2(5); 90 | } 91 | 92 | 93 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_clock_ST7789/DigiFont_lib_clock_ST7789.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // Digital clock example on ST7789 IPS display 3 | // (c) 2020-24 Pawel A. Hernik 4 | 5 | /* 6 | ST7789 240x240 1.3" IPS (without CS pin) - only 4+2 wires required: 7 | #01 GND -> GND 8 | #02 VCC -> VCC (3.3V only!) 9 | #03 SCL -> D13/SCK 10 | #04 SDA -> D11/MOSI 11 | #05 RES -> D9 /PA0 or any digital (HW RESET is required to properly initialize LCD without CS) 12 | #06 DC -> D10/PA1 or any digital 13 | #07 BLK -> NC 14 | 15 | ST7789 240x280 1.69" IPS - only 4+2 wires required: 16 | #01 GND -> GND 17 | #02 VCC -> VCC (3.3V only!) 18 | #03 SCL -> D13/SCK 19 | #04 SDA -> D11/MOSI 20 | #05 RES -> optional 21 | #06 DC -> D10 or any digital 22 | #07 CS -> D9 or any digital 23 | #08 BLK -> VCC 24 | 25 | ST7789 170x320 1.9" IPS - only 4+2 wires required: 26 | #01 GND -> GND 27 | #02 VCC -> VCC (3.3V only!) 28 | #03 SCL -> D13/SCK 29 | #04 SDA -> D11/MOSI 30 | #05 RES -> optional 31 | #06 DC -> D10 or any digital 32 | #07 CS -> D9 or any digital 33 | #08 BLK -> VCC 34 | 35 | ST7789 240x320 2.0" IPS - only 4+2 wires required: 36 | #01 GND -> GND 37 | #02 VCC -> VCC (3.3V only!) 38 | #03 SCL -> D13/SCK 39 | #04 SDA -> D11/MOSI 40 | #05 RES -> optional 41 | #06 DC -> D10 or any digital 42 | #07 CS -> D9 or any digital 43 | */ 44 | 45 | #include 46 | #include 47 | #include "ST7789_AVR.h" 48 | 49 | #define SCR_WD 240 50 | #define SCR_HT 240 51 | //#define SCR_HT 320 52 | 53 | #define TFT_DC 10 54 | #define TFT_CS 9 // with CS 55 | #define TFT_RST -1 // with CS 56 | ST7789_AVR lcd = ST7789_AVR(TFT_DC, TFT_RST, TFT_CS); 57 | 58 | // ----------------- 59 | #include "DigiFont.h" 60 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 61 | void customLineH(int x0,int x1, int y, int c) { lcd.drawFastHLine(x0,y,x1-x0+1,c); } 62 | void customLineV(int x, int y0,int y1, int c) { lcd.drawFastVLine(x,y0,y1-y0+1,c); } 63 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 64 | DigiFont font(customLineH,customLineV,customRect); 65 | // ----------------- 66 | 67 | void setup(void) 68 | { 69 | Serial.begin(9600); 70 | lcd.init(); 71 | lcd.fillScreen(BLACK); 72 | } 73 | 74 | unsigned long ms; 75 | 76 | void demoClock1(int t) 77 | { 78 | lcd.fillScreen(BLACK); 79 | font.setColors(RED,RGBto565(60,0,0)); 80 | int w=(SCR_HT-t-10)/4; 81 | font.setSize1(w-3,w*2,t); 82 | int y=(SCR_HT-w*2)/2; 83 | ms=millis(); 84 | while(millis()-ms<5000) { 85 | font.drawDigit1(random(0,3),0*w,y); 86 | font.drawDigit1(random(0,4),1*w,y); 87 | font.drawDigit1(':',2*w+5-3,y); 88 | font.drawDigit1(random(0,6),t+10-3+2*w,y); 89 | font.drawDigit1(random(0,10),t+10-3+3*w,y); 90 | delay(600); 91 | } 92 | } 93 | 94 | void demoClock2(int t) 95 | { 96 | lcd.fillScreen(BLACK); 97 | font.setColors(GREEN,RGBto565(0,40,0)); 98 | int w=(SCR_HT-t-10)/4; 99 | font.setSize2(w-3,w*2,t); 100 | int y=(SCR_HT-w*2)/2; 101 | ms=millis(); 102 | while(millis()-ms<5000) { 103 | font.drawDigit2(random(0,3),0*w,y); 104 | font.drawDigit2(random(0,4),1*w,y); 105 | font.drawDigit2(':',2*w+5-3,y); 106 | font.drawDigit2(random(0,6),t+10-3+2*w,y); 107 | font.drawDigit2(random(0,10),t+10-3+3*w,y); 108 | delay(600); 109 | } 110 | } 111 | 112 | void demoClock2c(int t) 113 | { 114 | lcd.fillScreen(BLACK); 115 | font.setColors(CYAN,RGBto565(0,190,190),RGBto565(0,40,40)); 116 | int w=(SCR_HT-t-10)/4; 117 | font.setSize2(w-3,w*2,t); 118 | int y=(SCR_HT-w*2)/2; 119 | ms=millis(); 120 | while(millis()-ms<5000) { 121 | font.drawDigit2c(random(0,3),0*w,y); 122 | font.drawDigit2c(random(0,4),1*w,y); 123 | font.drawDigit2c(':',2*w+5-3,y); 124 | font.drawDigit2c(random(0,6),t+10-3+2*w,y); 125 | font.drawDigit2c(random(0,10),t+10-3+3*w,y); 126 | delay(600); 127 | } 128 | } 129 | 130 | void loop() 131 | { 132 | demoClock1(10); 133 | demoClock2(14); 134 | demoClock2c(14); 135 | demoClock2(10); 136 | demoClock2c(10); 137 | } 138 | 139 | 140 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_demo_HX1230/DigiFont_lib_demo_HX1230.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // Demo on HX1230 LCD 3 | // (c) 2020 Pawel A. Hernik 4 | // YouTube video: https://youtu.be/X6PjfhcNE98 5 | 6 | /* 7 | HX1230 96x68 LCD connections (header on bottom, from left): 8 | #1 RST - D6 or any digital 9 | #2 CE - D7 or any digital 10 | #3 N/C 11 | #4 DIN - D11/MOSI 12 | #5 CLK - D13/SCK 13 | #6 VCC - 3V3 14 | #7 BL - 3V3 or any digital 15 | #8 GND - GND 16 | */ 17 | 18 | #define LCD_RST 6 19 | #define LCD_CS 7 20 | #define LCD_BL 8 21 | 22 | #include "HX1230_FB.h" 23 | #include 24 | HX1230_FB lcd(LCD_RST, LCD_CS); 25 | 26 | // ----------------- 27 | #include "DigiFont.h" 28 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 29 | void customLineH(int x0,int x1, int y, int c) { lcd.drawLineHfast(x0,x1,y,c); } 30 | void customLineV(int x, int y0,int y1, int c) { lcd.drawLineVfast(x,y0,y1,c); } 31 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 32 | DigiFont font(customLineH,customLineV,customRect); 33 | // ----------------- 34 | 35 | void setup(void) 36 | { 37 | Serial.begin(9600); 38 | pinMode(LCD_BL, OUTPUT); 39 | digitalWrite(LCD_BL, HIGH); 40 | lcd.init(); 41 | lcd.cls(); 42 | lcd.display(); 43 | font.setColors(1,0); 44 | } 45 | 46 | unsigned long ms; 47 | char buf[20]; 48 | 49 | void demoClock1(int t) 50 | { 51 | int w=22; 52 | font.setSize1(w-1,40,t); 53 | int y=(SCR_HT-40)/2; 54 | ms=millis(); 55 | while(millis()-ms<5000) { 56 | lcd.cls(); 57 | font.drawDigit1(random(0,3),0*w,y); 58 | font.drawDigit1(random(0,4),1*w,y); 59 | font.drawDigit1(':',1+2*w,y); 60 | font.drawDigit1(random(0,6),t+3+2*w,y); 61 | font.drawDigit1(random(0,10),t+3+3*w,y); 62 | lcd.display(); 63 | delay(600); 64 | } 65 | } 66 | 67 | void demoClock2(int t) 68 | { 69 | int w=21; 70 | font.setSize2(w-1,40,t); 71 | int y=(SCR_HT-40)/2; 72 | ms=millis(); 73 | while(millis()-ms<5000) { 74 | lcd.cls(); 75 | font.drawDigit2(random(0,3),0*w,y); 76 | font.drawDigit2(random(0,4),1*w,y); 77 | font.drawDigit2(':',1+2*w,y); 78 | font.drawDigit2(random(0,6),t+3+2*w,y); 79 | font.drawDigit2(random(0,10),t+3+3*w,y); 80 | lcd.display(); 81 | delay(600); 82 | } 83 | } 84 | 85 | void demoClock3(int t) 86 | { 87 | int w=21; 88 | font.setSize3(w-1,40,t); 89 | int y=(SCR_HT-40)/2; 90 | ms=millis(); 91 | while(millis()-ms<4000) { 92 | lcd.cls(); 93 | font.drawDigit3(random(0,3),0*w,y); 94 | font.drawDigit3(random(0,4),1*w,y); 95 | font.drawDigit3(':',1+2*w,y); 96 | font.drawDigit3(random(0,6),t+3+2*w,y); 97 | font.drawDigit3(random(0,10),t+3+3*w,y); 98 | lcd.display(); 99 | delay(600); 100 | } 101 | } 102 | 103 | void demoClock5(int t) 104 | { 105 | int w=21; 106 | font.setSize5(w-2,40,t); 107 | int y=(SCR_HT-40)/2; 108 | ms=millis(); 109 | while(millis()-ms<5000) { 110 | lcd.cls(); 111 | font.drawDigit5(random(0,3),0*w,y); 112 | font.drawDigit5(random(0,4),1*w,y); 113 | font.drawDigit5(':',1+2*w,y); 114 | font.drawDigit5(random(0,6),t+3+2*w,y); 115 | font.drawDigit5(random(0,10),t+3+3*w,y); 116 | lcd.display(); 117 | delay(600); 118 | } 119 | } 120 | 121 | void demoBig() 122 | { 123 | lcd.cls(); 124 | int i=0; 125 | int w=SCR_WD/3; 126 | ms=millis(); 127 | while(millis()-ms<6000) { 128 | font.setSize1(w-2,SCR_HT,5); 129 | font.drawDigit1(i,0*w,0); 130 | font.setSize2(w-2,SCR_HT,5); 131 | font.drawDigit2(i,1*w,0); 132 | font.setSize5(w-2,SCR_HT,10); 133 | font.drawDigit5(i,2*w,0); 134 | lcd.display(); 135 | delay(300); 136 | if(++i>9) i=0; 137 | } 138 | } 139 | 140 | void demoCounter(int t1,int t2) 141 | { 142 | lcd.cls(); 143 | font.setColors(1,0); 144 | int w=SCR_WD/6; 145 | int y1=(SCR_HT/2-w*2)/2; 146 | int y2=(SCR_HT/2-w*2)/2+SCR_HT/2; 147 | ms=millis(); 148 | while(millis()-ms<5000) { 149 | font.setSize1(w-2,w*2,t1); 150 | for(int i=0;i<6;i++) font.drawDigit1(random(0,10),2+i*w,y1); 151 | font.setSize2(w-2,w*2,t2); 152 | for(int i=0;i<6;i++) font.drawDigit2(random(0,10),2+i*w,y2); 153 | lcd.display(); 154 | delay(200); 155 | } 156 | } 157 | 158 | void demoCounterSize1() 159 | { 160 | lcd.cls(); 161 | int mw=SCR_WD/4; 162 | int t,cnt=0; 163 | for(int i=0;i<10;i++) { 164 | int w=random(10,mw+1); 165 | t=w/4; 166 | font.setSize1(w-2,w*2,t); 167 | font.setSpacing(2); 168 | ms=millis(); 169 | int x=random(0,SCR_WD-w*4),y=random(0,SCR_HT-w*2); 170 | font.setColors(1,0); 171 | while(millis()-ms<800) { 172 | snprintf(buf,9,"%04d",cnt); 173 | font.printNumber1(buf,x,y); 174 | lcd.display(); 175 | delay(150); 176 | cnt+=121; 177 | if(cnt>9999) cnt=0; 178 | } 179 | font.setColors(0,0); 180 | font.printNumber1(buf,x,y); 181 | lcd.display(); 182 | } 183 | } 184 | 185 | void demoCounterSize2() 186 | { 187 | lcd.cls(); 188 | int mw=SCR_WD/4; 189 | int t,cnt=0; 190 | for(int i=0;i<10;i++) { 191 | int w=random(10,mw+1); 192 | t=w/4; 193 | font.setSize2(w-2,w*8/5,t); 194 | font.setSpacing(2); 195 | ms=millis(); 196 | int x=random(0,SCR_WD-w*4),y=random(0,SCR_HT-w*2); 197 | font.setColors(1,0); 198 | while(millis()-ms<800) { 199 | snprintf(buf,9,"%04d",cnt); 200 | font.printNumber2(buf,x,y); 201 | lcd.display(); 202 | delay(150); 203 | cnt+=121; 204 | if(cnt>9999) cnt=0; 205 | } 206 | font.setColors(0,0); 207 | font.printNumber2(buf,x,y); 208 | lcd.display(); 209 | } 210 | } 211 | 212 | void demoCounterSize5() 213 | { 214 | lcd.cls(); 215 | int mw=SCR_WD/4; 216 | int t,cnt=0; 217 | for(int i=0;i<10;i++) { 218 | int w=random(10,mw+1); 219 | t=w/3; 220 | font.setSize5(w-2,w*2,t); 221 | font.setSpacing(2); 222 | ms=millis(); 223 | int x=random(0,SCR_WD-w*4),y=random(0,SCR_HT-w*2); 224 | font.setColors(1,0); 225 | while(millis()-ms<800) { 226 | lcd.cls(); 227 | snprintf(buf,9,"%04d",cnt); 228 | font.printNumber5(buf,x,y); 229 | lcd.display(); 230 | delay(150); 231 | cnt+=121; 232 | if(cnt>9999) cnt=0; 233 | } 234 | //font.setColors(0,0); 235 | //font.printNumber2(buf,x,y); 236 | //lcd.display(); 237 | } 238 | } 239 | 240 | void demoCounterThick1(int numdig) 241 | { 242 | lcd.cls(); 243 | int w=SCR_WD/numdig; 244 | for(int t=3;t<=10;t++) { 245 | font.setSize1(w-2,SCR_HT,t); 246 | ms=millis(); 247 | font.setColors(1,0); 248 | while(millis()-ms<900) { 249 | for(int i=0;i999999) v=-99999; 357 | delay(150); 358 | } 359 | } 360 | 361 | void loop() 362 | { 363 | demoBig(); 364 | 365 | demoClock1(5); 366 | demoClock2(5); 367 | demoClock3(5); 368 | demoClock5(7); 369 | 370 | demoCounter(3,3); 371 | 372 | demoCounterSize1(); 373 | demoCounterSize2(); 374 | demoCounterSize5(); 375 | 376 | demoCounterThick1(3); 377 | demoCounterThick2(3); 378 | demoCounterThick3(3); 379 | demoCounterThick4(3); 380 | demoCounterThick5(3); 381 | 382 | ///demoCounterThick1(2); 383 | ///demoCounterThick2(2); 384 | demoCounterThick3(2); 385 | demoCounterThick4(2); 386 | demoCounterThick5(2); 387 | 388 | demoFloat(); 389 | } 390 | 391 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_demo_ST7789/DigiFont_lib_demo_ST7789.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // Demo on ST7789 IPS display 3 | // (c) 2020-24 Pawel A. Hernik 4 | // YouTube video: https://youtu.be/X6PjfhcNE98 5 | 6 | /* 7 | ST7789 240x240 1.3" IPS (without CS pin) - only 4+2 wires required: 8 | #01 GND -> GND 9 | #02 VCC -> VCC (3.3V only!) 10 | #03 SCL -> D13/SCK 11 | #04 SDA -> D11/MOSI 12 | #05 RES -> D9 /PA0 or any digital (HW RESET is required to properly initialize LCD without CS) 13 | #06 DC -> D10/PA1 or any digital 14 | #07 BLK -> NC 15 | 16 | ST7789 240x280 1.69" IPS - only 4+2 wires required: 17 | #01 GND -> GND 18 | #02 VCC -> VCC (3.3V only!) 19 | #03 SCL -> D13/SCK 20 | #04 SDA -> D11/MOSI 21 | #05 RES -> optional 22 | #06 DC -> D10 or any digital 23 | #07 CS -> D9 or any digital 24 | #08 BLK -> VCC 25 | 26 | ST7789 170x320 1.9" IPS - only 4+2 wires required: 27 | #01 GND -> GND 28 | #02 VCC -> VCC (3.3V only!) 29 | #03 SCL -> D13/SCK 30 | #04 SDA -> D11/MOSI 31 | #05 RES -> optional 32 | #06 DC -> D10 or any digital 33 | #07 CS -> D9 or any digital 34 | #08 BLK -> VCC 35 | 36 | ST7789 240x320 2.0" IPS - only 4+2 wires required: 37 | #01 GND -> GND 38 | #02 VCC -> VCC (3.3V only!) 39 | #03 SCL -> D13/SCK 40 | #04 SDA -> D11/MOSI 41 | #05 RES -> optional 42 | #06 DC -> D10 or any digital 43 | #07 CS -> D9 or any digital 44 | */ 45 | 46 | #include 47 | #include 48 | #include "ST7789_AVR.h" 49 | 50 | #define SCR_WD 240 51 | #define SCR_HT 240 52 | //#define SCR_HT 320 53 | 54 | #define TFT_DC 10 55 | #define TFT_CS 9 // with CS 56 | #define TFT_RST -1 // with CS 57 | ST7789_AVR lcd = ST7789_AVR(TFT_DC, TFT_RST, TFT_CS); 58 | 59 | // ----------------- 60 | #include "DigiFont.h" 61 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 62 | void customLineH(int x0,int x1, int y, int c) { lcd.drawFastHLine(x0,y,x1-x0+1,c); } 63 | void customLineV(int x, int y0,int y1, int c) { lcd.drawFastVLine(x,y0,y1-y0+1,c); } 64 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 65 | DigiFont font(customLineH,customLineV,customRect); 66 | // ----------------- 67 | 68 | void setup(void) 69 | { 70 | Serial.begin(9600); 71 | lcd.init(SCR_WD,SCR_HT); 72 | lcd.fillScreen(BLACK); 73 | font.setColors(RED,RGBto565(40,0,0)); 74 | } 75 | 76 | unsigned long ms; 77 | char buf[20]; 78 | 79 | void demoClock1(int t) 80 | { 81 | font.setColors(RED,RGBto565(40,0,0)); 82 | int s1=4,s2=8; 83 | lcd.fillScreen(BLACK); 84 | int w=(SCR_HT-t-s2*2)/4; 85 | font.setSize1(w-s1,w*2,t); 86 | int y=(SCR_HT-w*2)/2; 87 | ms=millis(); 88 | while(millis()-ms<5000) { 89 | font.drawDigit1(random(0,3),0*w,y); 90 | font.drawDigit1(random(0,4),1*w,y); 91 | font.drawDigit1(':',2*w+s2-s1,y); 92 | font.drawDigit1(random(0,6),t+2*s2-s1+2*w,y); 93 | font.drawDigit1(random(0,10),t+2*s2-s1+3*w,y); 94 | delay(500); 95 | } 96 | } 97 | 98 | void demoClock2(int t) 99 | { 100 | font.setColors(GREEN,RGBto565(0,40,0)); 101 | int s1=4,s2=8; 102 | lcd.fillScreen(BLACK); 103 | int w=(SCR_HT-t-s2*2)/4; 104 | font.setSize2(w-s1,w*2,t); 105 | int y=(SCR_HT-w*2)/2; 106 | ms=millis(); 107 | while(millis()-ms<5000) { 108 | font.drawDigit2(random(0,3),0*w,y); 109 | font.drawDigit2(random(0,4),1*w,y); 110 | font.drawDigit2(':',2*w+s2-s1,y); 111 | font.drawDigit2(random(0,6),t+2*s2-s1+2*w,y); 112 | font.drawDigit2(random(0,10),t+2*s2-s1+3*w,y); 113 | delay(500); 114 | } 115 | } 116 | 117 | void demoClock2c(int t) 118 | { 119 | font.setColors(RGBto565(0,250,0),RGBto565(0,180,0),RGBto565(0,40,0)); 120 | int s1=4,s2=8; 121 | lcd.fillScreen(BLACK); 122 | int w=(SCR_HT-t-s2*2)/4; 123 | font.setSize2(w-s1,w*2,t); 124 | int y=(SCR_HT-w*2)/2; 125 | ms=millis(); 126 | while(millis()-ms<5000) { 127 | font.drawDigit2c(random(0,3),0*w,y); 128 | font.drawDigit2c(random(0,4),1*w,y); 129 | font.drawDigit2c(':',2*w+s2-s1,y); 130 | font.drawDigit2c(random(0,6),t+2*s2-s1+2*w,y); 131 | font.drawDigit2c(random(0,10),t+2*s2-s1+3*w,y); 132 | delay(500); 133 | } 134 | } 135 | 136 | void demoBig() 137 | { 138 | lcd.fillScreen(BLACK); 139 | int i=0; 140 | int w=SCR_WD/3; 141 | ms=millis(); 142 | while(millis()-ms<6000) { 143 | font.setColors(RED,RGBto565(50,0,0)); 144 | font.setSize1(w-8,SCR_HT,10); 145 | font.drawDigit1(i%10,0*w,0); 146 | font.setSize2(w-8,SCR_HT,12); 147 | font.setColors(GREEN,RGBto565(0,40,0)); 148 | font.drawDigit2(i%10,1*w,0); 149 | font.setSize2(w-8,SCR_HT,17); 150 | font.setColors(RGBto565(230,230,0),RGBto565(180,180,0),RGBto565(40,40,0)); 151 | font.drawDigit2c(i%10,2*w,0); 152 | delay(100); 153 | i++; 154 | } 155 | } 156 | 157 | void demoCounter(int t1,int t2) 158 | { 159 | lcd.fillScreen(RGBto565(160,160,160)); 160 | font.setColors(RGBto565(40,40,40),RGBto565(140,140,140)); 161 | int w=SCR_WD/6; 162 | int y1=(SCR_HT/2-w*2)/2; 163 | int y2=(SCR_HT/2-w*2)/2+SCR_HT/2; 164 | ms=millis(); 165 | while(millis()-ms<5000) { 166 | font.setSize1(w-4,w*2,t1); 167 | for(int i=0;i<6;i++) font.drawDigit1(random(0,10),2+i*w,y1); 168 | font.setSize2(w-4,w*2,t2); 169 | for(int i=0;i<6;i++) font.drawDigit2(random(0,10),2+i*w,y2); 170 | //delay(50); 171 | } 172 | } 173 | 174 | void demoCounterSize1() 175 | { 176 | lcd.fillScreen(BLACK); 177 | int mw=SCR_WD/4; 178 | int t=8; 179 | int cnt=0; 180 | for(int i=0;i<12;i++) { 181 | int w=random(15,mw+1); 182 | //if(w>21) t=7; else 183 | //if(w>17) t=6; else 184 | //if(w>15) t=5; else 185 | //if(w>12) t=4; else t=3; 186 | t=w/4; 187 | font.setSize1(w-4,w*2,t); 188 | ms=millis(); 189 | int x=random(0,SCR_WD-w*4),y=random(0,SCR_HT-w*2); 190 | while(millis()-ms<800) { 191 | font.setColors(MAGENTA,RGBto565(40,0,40)); 192 | font.setSpacing(4); 193 | snprintf(buf,9,"%04d",cnt); 194 | font.printNumber1(buf,x,y); 195 | delay(50); 196 | cnt+=121; 197 | if(cnt>9999) cnt=0; 198 | } 199 | font.setColors(BLACK,BLACK); 200 | font.printNumber1(buf,x,y); 201 | } 202 | } 203 | 204 | void demoCounterSize2c() 205 | { 206 | lcd.fillScreen(BLACK); 207 | int mw=SCR_WD/4; 208 | int t=8; 209 | int cnt=0; 210 | for(int i=0;i<12;i++) { 211 | int w=random(15,mw+1); 212 | //if(w>21) t=7; else 213 | //if(w>15) t=5; else t=3; 214 | t=w/4; 215 | font.setSize2(w-4,w*2,t); 216 | ms=millis(); 217 | int x=random(0,SCR_WD-w*4),y=random(0,SCR_HT-w*2); 218 | font.setColors(RGBto565(250,250,250),RGBto565(180,180,180),RGBto565(40,40,40)); 219 | while(millis()-ms<1000) { 220 | font.setSpacing(4); 221 | snprintf(buf,9,"%04d",cnt); 222 | font.printNumber2c(buf,x,y); 223 | delay(50); 224 | cnt+=121; 225 | if(cnt>9999) cnt=0; 226 | } 227 | font.setColors(BLACK,BLACK); 228 | font.printNumber2(buf,x,y); 229 | } 230 | } 231 | 232 | void demoCounterThick1() 233 | { 234 | lcd.fillScreen(BLACK); 235 | int w=SCR_WD/3; 236 | for(int t=5;t<17;t++) { 237 | font.setSize1(w-8,w*2,t); 238 | ms=millis(); 239 | font.setColors(RED,RGBto565(50,0,0)); 240 | while(millis()-ms<500) { 241 | for(int i=0;i<3;i++) font.drawDigit1(random(0,10),i*w,(SCR_HT-w*2)/2); 242 | delay(50); 243 | } 244 | font.setColors(0,0); 245 | for(int i=0;i<3;i++) font.drawDigit1(8,i*w,(SCR_HT-w*2)/2); 246 | } 247 | } 248 | 249 | void demoCounterThick2() 250 | { 251 | lcd.fillScreen(BLACK); 252 | int w=SCR_WD/3; 253 | for(int t=5;t<=21;t+=2) { 254 | font.setSize2(w-8,w*2,t); 255 | ms=millis(); 256 | font.setColors(GREEN,RGBto565(0,40,0)); 257 | while(millis()-ms<500) { 258 | for(int i=0;i<3;i++) font.drawDigit2(random(0,10),i*w,(SCR_HT-w*2)/2); 259 | delay(100); 260 | } 261 | font.setColors(0,0); 262 | for(int i=0;i<3;i++) font.drawDigit2(8,i*w,(SCR_HT-w*2)/2); 263 | } 264 | } 265 | 266 | void demoCounterThick2c() 267 | { 268 | lcd.fillScreen(BLACK); 269 | int w=SCR_WD/3; 270 | for(int t=5;t<=25;t+=2) { 271 | font.setSize2(w-8,w*2,t); 272 | ms=millis(); 273 | font.setColors(RGBto565(0,240,240),RGBto565(0,180,180),RGBto565(0,40,40)); 274 | while(millis()-ms<600) { 275 | for(int i=0;i<3;i++) font.drawDigit2c(random(0,10),i*w,(SCR_HT-w*2)/2); 276 | delay(100); 277 | } 278 | font.setColors(0,0,0); 279 | for(int i=0;i<3;i++) font.drawDigit2c(8,i*w,(SCR_HT-w*2)/2); 280 | } 281 | } 282 | 283 | 284 | void demoFloat() 285 | { 286 | lcd.fillScreen(BLACK); 287 | lcd.fillRect(0,2*SCR_HT/3,SCR_WD,SCR_HT/3,RGBto565(150,150,150)); 288 | int w=SCR_WD/7; 289 | long v=-99999; 290 | ms=millis(); 291 | font.setSpacing(6); 292 | while(millis()-ms<5000) { 293 | dtostrf((float)v/100.0,7,2,buf); 294 | font.setColors(RED,RGBto565(60,0,0)); 295 | font.setSize1(w-4,w*2,7); 296 | font.printNumber1(buf,4,0); 297 | 298 | font.setColors(GREEN,RGBto565(0,50,0)); 299 | font.setSize2(w-4,w*2,7); 300 | font.printNumber2(buf,4,w*2+15); 301 | 302 | font.setColors(RGBto565(30,30,30),RGBto565(130,130,130)); 303 | font.setSize2(w-4,w*2,7); 304 | font.printNumber2(buf,4,w*4+30); 305 | v+=4901; 306 | if(v>999999) v=-99999; 307 | //delay(50); 308 | } 309 | } 310 | 311 | void loop() 312 | { 313 | demoBig(); 314 | 315 | demoClock1(10); 316 | demoClock2(11); 317 | demoClock2c(13); 318 | 319 | demoCounter(9,9); 320 | 321 | demoCounterSize1(); 322 | demoCounterSize2c(); 323 | 324 | demoCounterThick1(); 325 | demoCounterThick2(); 326 | demoCounterThick2c(); 327 | 328 | demoFloat(); 329 | } 330 | 331 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_float_ST7789/DigiFont_lib_float_ST7789.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // Floating point values on ST7789 IPS display 3 | // (c) 2020-24 Pawel A. Hernik 4 | 5 | /* 6 | ST7789 240x240 1.3" IPS (without CS pin) - only 4+2 wires required: 7 | #01 GND -> GND 8 | #02 VCC -> VCC (3.3V only!) 9 | #03 SCL -> D13/SCK 10 | #04 SDA -> D11/MOSI 11 | #05 RES -> D9 /PA0 or any digital (HW RESET is required to properly initialize LCD without CS) 12 | #06 DC -> D10/PA1 or any digital 13 | #07 BLK -> NC 14 | 15 | ST7789 240x280 1.69" IPS - only 4+2 wires required: 16 | #01 GND -> GND 17 | #02 VCC -> VCC (3.3V only!) 18 | #03 SCL -> D13/SCK 19 | #04 SDA -> D11/MOSI 20 | #05 RES -> optional 21 | #06 DC -> D10 or any digital 22 | #07 CS -> D9 or any digital 23 | #08 BLK -> VCC 24 | 25 | ST7789 170x320 1.9" IPS - only 4+2 wires required: 26 | #01 GND -> GND 27 | #02 VCC -> VCC (3.3V only!) 28 | #03 SCL -> D13/SCK 29 | #04 SDA -> D11/MOSI 30 | #05 RES -> optional 31 | #06 DC -> D10 or any digital 32 | #07 CS -> D9 or any digital 33 | #08 BLK -> VCC 34 | 35 | ST7789 240x320 2.0" IPS - only 4+2 wires required: 36 | #01 GND -> GND 37 | #02 VCC -> VCC (3.3V only!) 38 | #03 SCL -> D13/SCK 39 | #04 SDA -> D11/MOSI 40 | #05 RES -> optional 41 | #06 DC -> D10 or any digital 42 | #07 CS -> D9 or any digital 43 | */ 44 | 45 | #include 46 | #include 47 | #include "ST7789_AVR.h" 48 | 49 | #define SCR_WD 240 50 | #define SCR_HT 320 51 | //#define SCR_HT 240 52 | 53 | #define TFT_DC 10 54 | #define TFT_CS 9 // with CS 55 | #define TFT_RST -1 // with CS 56 | ST7789_AVR lcd = ST7789_AVR(TFT_DC, TFT_RST, TFT_CS); 57 | 58 | // ----------------- 59 | #include "DigiFont.h" 60 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 61 | void customLineH(int x0,int x1, int y, int c) { lcd.drawFastHLine(x0,y,x1-x0+1,c); } 62 | void customLineV(int x, int y0,int y1, int c) { lcd.drawFastVLine(x,y0,y1-y0+1,c); } 63 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 64 | DigiFont digi(customLineH,customLineV,customRect); 65 | // ----------------- 66 | 67 | char buf[20]; 68 | long v=-99999; 69 | int w=SCR_WD/7; // 34 for 240px screen 70 | 71 | void setup(void) 72 | { 73 | Serial.begin(9600); 74 | lcd.init(SCR_WD,SCR_HT); 75 | lcd.fillScreen(BLACK); 76 | digi.setColors(RED,RGBto565(40,0,0)); 77 | lcd.fillRect(0,w*4+30-6,SCR_WD,w*2+12,RGBto565(150,150,150)); 78 | } 79 | 80 | // 14,320 bytes in PROGMEM - style 2/2c mixed 81 | void demoFloat() 82 | { 83 | digi.setSpacing(6); 84 | dtostrf((float)v/100.0,7,2,buf); 85 | 86 | //digi.setColors(RED,RGBto565(70,0,0)); 87 | //digi.setSize1(w-4,w*2,7); 88 | //digi.printNumber1(buf,6,0); 89 | 90 | digi.setColors(RGBto565(250,50,50),RGBto565(160,20,20),RGBto565(40,0,0)); 91 | //digi.setColors(GREEN,RGBto565(0,50,0)); 92 | //digi.setSize2(w-4,w*2,7); 93 | digi.setSize2(w-4,w*2,9); 94 | digi.printNumber2c(buf,6,0); 95 | 96 | digi.setColors(GREEN,RGBto565(0,50,0)); 97 | digi.setSize2(w-4,w*2,7); 98 | digi.printNumber2(buf,6,w*2+15); 99 | 100 | digi.setColors(RGBto565(30,30,30),RGBto565(130,130,130)); 101 | digi.setSize2(w-4,w*2,7); 102 | digi.printNumber2(buf,6,w*4+30); 103 | 104 | #if SCR_HT==320 105 | digi.setColors(RGBto565(0,250,250),RGBto565(0,160,160),RGBto565(0,40,40)); 106 | digi.setSize2(40,68,11); 107 | digi.printNumber2c("22.3'C",6,w*6+45); 108 | #endif 109 | 110 | v+=4901; 111 | if(v>999999) v=-99999; 112 | } 113 | 114 | // 13,456 bytes in PROGMEM - only style 7 115 | void demoFloat7() 116 | { 117 | digi.setSpacing(6); 118 | dtostrf((float)v/100.0,7,2,buf); 119 | 120 | digi.setColors(RGBto565(250,50,50),RGBto565(200,20,20),RGBto565(40,0,0)); 121 | digi.setSize7(w-4,w*2,9,3); 122 | digi.printNumber7(buf,6,0); 123 | 124 | digi.setColors(GREEN,RGBto565(0,50,0)); 125 | digi.setSize7(w-4,w*2,7,2); 126 | digi.printNumber7(buf,6,w*2+15); 127 | 128 | digi.setColors(RGBto565(30,30,30),RGBto565(130,130,130)); 129 | digi.setSize7(w-4,w*2,7,2); 130 | digi.printNumber7(buf,6,w*4+30); 131 | 132 | #if SCR_HT==320 133 | digi.setColors(RGBto565(0,250,250),RGBto565(0,190,190),RGBto565(0,40,40)); 134 | digi.setSize7(40,68,11,4); 135 | digi.printNumber7("23.4'C",6,w*6+45); 136 | #endif 137 | 138 | v+=4901; 139 | if(v>999999) v=-99999; 140 | } 141 | 142 | void loop() 143 | { 144 | demoFloat7(); 145 | } 146 | 147 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_special_look_HX1230/DigiFont_lib_special_look_HX1230.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // Special mixed modes / HX1230 LCD 3 | // (c) 2020 Pawel A. Hernik 4 | 5 | /* 6 | HX1230 96x68 LCD connections (header on bottom, from left): 7 | #1 RST - D6 or any digital 8 | #2 CE - D7 or any digital 9 | #3 N/C 10 | #4 DIN - D11/MOSI 11 | #5 CLK - D13/SCK 12 | #6 VCC - 3V3 13 | #7 BL - 3V3 or any digital 14 | #8 GND - GND 15 | */ 16 | 17 | #define LCD_RST 6 18 | #define LCD_CS 7 19 | #define LCD_BL 8 20 | 21 | #include "HX1230_FB.h" 22 | #include 23 | HX1230_FB lcd(LCD_RST, LCD_CS); 24 | 25 | // ----------------- 26 | #include "DigiFont.h" 27 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 28 | void customLineH(int x0,int x1, int y, int c) { lcd.drawLineHfast(x0,x1,y,c); } 29 | void customLineV(int x, int y0,int y1, int c) { lcd.drawLineVfast(x,y0,y1,c); } 30 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 31 | void customRectD(int x, int y,int w,int h, int c) { lcd.fillRectD(x,y,w,h,c); } 32 | DigiFont font(customLineH,customLineV,customRect); 33 | // ----------------- 34 | 35 | void setup(void) 36 | { 37 | Serial.begin(9600); 38 | pinMode(LCD_BL, OUTPUT); 39 | digitalWrite(LCD_BL, HIGH); 40 | lcd.init(); 41 | lcd.cls(); 42 | lcd.display(); 43 | font.setColors(1,0); 44 | } 45 | 46 | int cnt=0; 47 | void special() 48 | { 49 | //lcd.cls(); 50 | //lcd.fillRectD(0,0,96,68,1); 51 | int w=SCR_WD/4,h=50; 52 | font.setClearBg(1); 53 | font.setSize5(w-2,h,8); 54 | font.drawDigit5(cnt,0,0); 55 | font.setClearBg(0); 56 | font.setSize4(w-2-4,h-4,4); 57 | font.drawDigit4(cnt,2,2); 58 | 59 | font.setClearBg(1); 60 | font.setSize5(w-2,h,8); 61 | font.drawDigit5(cnt,w*1,0); 62 | font.setClearBg(0); 63 | font.setSize4(w-2-2,h-2,8-2); 64 | lcd.setDither(4); 65 | font.init(customLineH,customLineV,customRectD); 66 | font.drawDigit4(cnt,w*1+1,1); 67 | font.init(customLineH,customLineV,customRect); 68 | 69 | font.setClearBg(1); 70 | font.setSize5(w-2,h,9); 71 | font.drawDigit5(cnt,w*2,0); 72 | font.setClearBg(0); 73 | font.setSize4(w-2-2,h-2,9-2); 74 | lcd.setDither(8); 75 | font.init(customLineH,customLineV,customRectD); 76 | font.drawDigit4(cnt,w*2+1,1); 77 | font.init(customLineH,customLineV,customRect); 78 | 79 | font.setClearBg(1); 80 | font.setSize5(w-2,h,9); 81 | font.drawDigit5(cnt,w*3,0); 82 | font.setClearBg(0); 83 | font.setSize4(w-2-2,h-2,9-2); 84 | lcd.setDither(12); 85 | font.init(customLineH,customLineV,customRectD); 86 | font.drawDigit4(cnt,w*3+1,1); 87 | font.init(customLineH,customLineV,customRect); 88 | 89 | if(++cnt>9) cnt=0; 90 | lcd.display(); 91 | delay(500); 92 | } 93 | 94 | 95 | void loop() 96 | { 97 | special(); 98 | } 99 | 100 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_special_look_ST7567/DigiFont_lib_special_look_ST7567.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // Special mixed mode / ST7567 LCD 3 | // (c) 2020 Pawel A. Hernik 4 | // YouTube videos: 5 | // https://youtu.be/X6PjfhcNE98 6 | // https://youtu.be/OPq9aBJP-pc 7 | 8 | /* 9 | 128x64 ST7567 connections in SPI mode (only 5-6 wires between LCD and MCU): 10 | 11 | #01 LED -> D6, GND or any pin via resistor 12 | #02 RST -> D9 or any pin 13 | #03 CS -> D10 or any pin 14 | #04 DC -> D8 or any pin 15 | #05 SCK -> D13/SCK 16 | #06 SDI -> D11/MOSI 17 | #07 3V3 -> VCC (3.3V) 18 | #08 GND -> GND 19 | */ 20 | 21 | #define LCD_BL 6 22 | #define LCD_CS 10 23 | #define LCD_DC 8 24 | #define LCD_RST 9 25 | 26 | #include "ST7567_FB.h" 27 | #include 28 | ST7567_FB lcd(LCD_DC, LCD_RST, LCD_CS); 29 | 30 | // ----------------- 31 | #include "DigiFont.h" 32 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 33 | void customLineH(int x0,int x1, int y, int c) { lcd.drawLineHfast(x0,x1,y,c); } 34 | void customLineV(int x, int y0,int y1, int c) { lcd.drawLineVfast(x,y0,y1,c); } 35 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 36 | void customRectD(int x, int y,int w,int h, int c) { lcd.fillRectD(x,y,w,h,c); } 37 | DigiFont font(customLineH,customLineV,customRect); 38 | // ----------------- 39 | 40 | void setup(void) 41 | { 42 | Serial.begin(9600); 43 | pinMode(LCD_BL, OUTPUT); 44 | digitalWrite(LCD_BL, LOW); 45 | lcd.init(); 46 | lcd.cls(); 47 | lcd.display(); 48 | font.setColors(1,0); 49 | } 50 | 51 | int cnt=0; 52 | void special() 53 | { 54 | lcd.cls(); 55 | //lcd.fillRectD(0,0,96,68,1); 56 | int w=SCR_WD/4,h=50; 57 | font.setClearBg(1); 58 | font.setSize5(w-2,h,8); 59 | font.drawDigit5(cnt,0,0); 60 | font.setClearBg(0); 61 | font.setSize4(w-2-4,h-4,4); 62 | font.drawDigit4(cnt,2,2); 63 | 64 | font.setClearBg(1); 65 | font.setSize5(w-2,h,8); 66 | font.drawDigit5(cnt,w*1,0); 67 | font.setClearBg(0); 68 | font.setSize4(w-2-2,h-2,8-2); 69 | lcd.setDither(4); 70 | font.init(customLineH,customLineV,customRectD); 71 | font.drawDigit4(cnt,w*1+1,1); 72 | font.init(customLineH,customLineV,customRect); 73 | 74 | font.setClearBg(1); 75 | font.setSize5(w-2,h,9); 76 | font.drawDigit5(cnt,w*2,0); 77 | font.setClearBg(0); 78 | font.setSize4(w-2-2,h-2,9-2); 79 | lcd.setDither(8); 80 | font.init(customLineH,customLineV,customRectD); 81 | font.drawDigit4(cnt,w*2+1,1); 82 | font.init(customLineH,customLineV,customRect); 83 | 84 | font.setClearBg(1); 85 | font.setSize5(w-2,h,9); 86 | font.drawDigit5(cnt,w*3,0); 87 | font.setClearBg(0); 88 | font.setSize4(w-2-2,h-2,9-2); 89 | lcd.setDither(12); 90 | font.init(customLineH,customLineV,customRectD); 91 | font.drawDigit4(cnt,w*3+1,1); 92 | font.init(customLineH,customLineV,customRect); 93 | 94 | if(++cnt>9) cnt=0; 95 | lcd.display(); 96 | delay(500); 97 | } 98 | 99 | 100 | void loop() 101 | { 102 | special(); 103 | } 104 | 105 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_styles_HX1230/DigiFont_lib_styles_HX1230.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // Styles demo on HX1230 LCD 3 | // (c) 2020 Pawel A. Hernik 4 | // YouTube video: https://youtu.be/X6PjfhcNE98 5 | 6 | /* 7 | HX1230 96x68 LCD connections (header on bottom, from left): 8 | #1 RST - D6 or any digital 9 | #2 CE - D7 or any digital 10 | #3 N/C 11 | #4 DIN - D11/MOSI 12 | #5 CLK - D13/SCK 13 | #6 VCC - 3V3 14 | #7 BL - 3V3 or any digital 15 | #8 GND - GND 16 | */ 17 | 18 | #define LCD_RST 6 19 | #define LCD_CS 7 20 | #define LCD_BL 8 21 | 22 | #include "HX1230_FB.h" 23 | #include 24 | HX1230_FB lcd(LCD_RST, LCD_CS); 25 | 26 | #include "c64enh_font.h" 27 | 28 | // ----------------- 29 | #include "DigiFont.h" 30 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 31 | void customLineH(int x0,int x1, int y, int c) { lcd.drawLineHfast(x0,x1,y,c); } 32 | void customLineV(int x, int y0,int y1, int c) { lcd.drawLineVfast(x,y0,y1,c); } 33 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 34 | DigiFont font(customLineH,customLineV,customRect); 35 | // ----------------- 36 | 37 | void setup(void) 38 | { 39 | Serial.begin(9600); 40 | pinMode(LCD_BL, OUTPUT); 41 | digitalWrite(LCD_BL, HIGH); 42 | lcd.init(); 43 | lcd.cls(); 44 | lcd.display(); 45 | font.setColors(1,0); 46 | } 47 | 48 | unsigned long ms; 49 | char buf[20]; 50 | 51 | void style1() 52 | { 53 | long cnt = 23456; 54 | lcd.cls(); 55 | lcd.setFont(c64enh); 56 | font.setColors(1,0); 57 | font.setSpacing(2); 58 | lcd.printStr(ALIGN_CENTER, 0, "Style #1"); 59 | ms=millis(); 60 | while(millis()-ms<5000) { 61 | snprintf(buf,6,"%05ld",cnt); 62 | font.setSize1(30,68-10,7); 63 | font.printNumber1(buf+4,0,10); 64 | font.setSize1(17,35,5); 65 | font.printNumber1("6:45",34,10); 66 | font.setSize1(10,20,3); 67 | font.printNumber1(buf,34,48); 68 | lcd.display(); 69 | delay(300); 70 | cnt+=111; 71 | } 72 | } 73 | 74 | void style2() 75 | { 76 | long cnt = 23456; 77 | lcd.cls(); 78 | lcd.setFont(c64enh); 79 | font.setColors(1,0); 80 | font.setSpacing(2); 81 | lcd.printStr(ALIGN_CENTER, 0, "Style #2"); 82 | ms=millis(); 83 | while(millis()-ms<5000) { 84 | snprintf(buf,6,"%05ld",cnt); 85 | font.setSize2(30,68-10,7); 86 | font.printNumber2(buf+4,0,10); 87 | font.setSize2(17,35,5); 88 | font.printNumber2("6:45",34,10); 89 | font.setSize2(10,20,3); 90 | font.printNumber2(buf,34,48); 91 | lcd.display(); 92 | delay(300); 93 | cnt+=111; 94 | } 95 | } 96 | 97 | void style3() 98 | { 99 | long cnt = 23456; 100 | lcd.cls(); 101 | lcd.setFont(c64enh); 102 | font.setColors(1,0); 103 | font.setSpacing(2); 104 | lcd.printStr(ALIGN_CENTER, 0, "Style #3"); 105 | ms=millis(); 106 | while(millis()-ms<5000) { 107 | snprintf(buf,6,"%05ld",cnt); 108 | font.setSize3(30,68-10,6); 109 | font.printNumber3(buf+4,0,10); 110 | font.setSize3(17,35,3); 111 | font.printNumber3("6:45",34,10); 112 | font.setSize3(10,20,2); 113 | font.printNumber3(buf,34,48); 114 | lcd.display(); 115 | delay(300); 116 | cnt+=111; 117 | } 118 | } 119 | 120 | void style4() 121 | { 122 | long cnt = 23456; 123 | lcd.cls(); 124 | lcd.setFont(c64enh); 125 | font.setColors(1,0); 126 | font.setSpacing(2); 127 | lcd.printStr(ALIGN_CENTER, 0, "Style #4"); 128 | ms=millis(); 129 | while(millis()-ms<5000) { 130 | snprintf(buf,6,"%05ld",cnt); 131 | font.setSize4(30,68-10,9); 132 | font.printNumber4(buf+4,0,10); 133 | font.setSize4(17,35,5); 134 | font.printNumber4("6:45",34,10); 135 | font.setSize4(10,20,3); 136 | font.printNumber4(buf,34,48); 137 | lcd.display(); 138 | delay(300); 139 | cnt+=111; 140 | } 141 | } 142 | 143 | void style5() 144 | { 145 | long cnt = 23456; 146 | lcd.cls(); 147 | lcd.setFont(c64enh); 148 | font.setColors(1,0); 149 | font.setSpacing(2); 150 | ms=millis(); 151 | while(millis()-ms<5000) { 152 | lcd.printStr(ALIGN_CENTER, 0, "Style #5"); 153 | snprintf(buf,6,"%05ld",cnt); 154 | font.setSize5(30,68-10,10); 155 | font.printNumber5(buf+4,0,10); 156 | font.setSize5(17,35,5); 157 | font.printNumber5("6:45",34,10); 158 | font.setSize5(10,20,4); 159 | font.printNumber5(buf,34,48); 160 | lcd.display(); 161 | delay(300); 162 | cnt+=111; 163 | } 164 | } 165 | 166 | void loop() 167 | { 168 | style1(); 169 | style2(); 170 | style3(); 171 | style4(); 172 | style5(); 173 | } 174 | 175 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_styles_ST7789/DigiFont_lib_styles_ST7789.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // Styles demo on ST7789 LCD 3 | // (c) 2020-24 Pawel A. Hernik 4 | // YouTube video: https://youtu.be/X6PjfhcNE98 5 | 6 | /* 7 | ST7789 240x240 1.3" IPS (without CS pin) - only 4+2 wires required: 8 | #01 GND -> GND 9 | #02 VCC -> VCC (3.3V only!) 10 | #03 SCL -> D13/SCK 11 | #04 SDA -> D11/MOSI 12 | #05 RES -> D9 /PA0 or any digital (HW RESET is required to properly initialize LCD without CS) 13 | #06 DC -> D10/PA1 or any digital 14 | #07 BLK -> NC 15 | 16 | ST7789 240x280 1.69" IPS - only 4+2 wires required: 17 | #01 GND -> GND 18 | #02 VCC -> VCC (3.3V only!) 19 | #03 SCL -> D13/SCK 20 | #04 SDA -> D11/MOSI 21 | #05 RES -> optional 22 | #06 DC -> D10 or any digital 23 | #07 CS -> D9 or any digital 24 | #08 BLK -> VCC 25 | 26 | ST7789 170x320 1.9" IPS - only 4+2 wires required: 27 | #01 GND -> GND 28 | #02 VCC -> VCC (3.3V only!) 29 | #03 SCL -> D13/SCK 30 | #04 SDA -> D11/MOSI 31 | #05 RES -> optional 32 | #06 DC -> D10 or any digital 33 | #07 CS -> D9 or any digital 34 | #08 BLK -> VCC 35 | 36 | ST7789 240x320 2.0" IPS - only 4+2 wires required: 37 | #01 GND -> GND 38 | #02 VCC -> VCC (3.3V only!) 39 | #03 SCL -> D13/SCK 40 | #04 SDA -> D11/MOSI 41 | #05 RES -> optional 42 | #06 DC -> D10 or any digital 43 | #07 CS -> D9 or any digital 44 | */ 45 | 46 | #include 47 | #include 48 | #include "ST7789_AVR.h" 49 | 50 | #define SCR_WD 240 51 | #define SCR_HT 240 52 | //#define SCR_HT 320 53 | 54 | #define TFT_DC 10 55 | #define TFT_CS 9 // with CS 56 | #define TFT_RST -1 // with CS 57 | ST7789_AVR lcd = ST7789_AVR(TFT_DC, TFT_RST, TFT_CS); 58 | 59 | // ----------------- 60 | #include "DigiFont.h" 61 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 62 | void customLineH(int x0,int x1, int y, int c) { lcd.drawFastHLine(x0,y,x1-x0+1,c); } 63 | void customLineV(int x, int y0,int y1, int c) { lcd.drawFastVLine(x,y0,y1-y0+1,c); } 64 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 65 | DigiFont digi(customLineH,customLineV,customRect); 66 | // ----------------- 67 | 68 | void setup(void) 69 | { 70 | Serial.begin(9600); 71 | lcd.init(SCR_WD,SCR_HT); 72 | lcd.fillScreen(BLACK); 73 | lcd.setTextColor(WHITE); 74 | lcd.setTextSize(2); 75 | digi.setSpacing(4); 76 | } 77 | 78 | unsigned long ms,demoTime=5000; 79 | char buf[20]; 80 | 81 | void style1() 82 | { 83 | long cnt = 23456; 84 | lcd.fillScreen(BLACK); 85 | lcd.setCursor(0,0); 86 | lcd.println("Style 1 or 7"); 87 | ms=millis(); 88 | int x,y=30; 89 | while(millis()-ms 23 | HX1230_FB lcd(LCD_RST, LCD_CS); 24 | 25 | // ----------------- 26 | #include "DigiFont.h" 27 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 28 | void customLineH(int x0,int x1, int y, int c) { lcd.drawLineHfast(x0,x1,y,c); } 29 | void customLineV(int x, int y0,int y1, int c) { lcd.drawLineVfast(x,y0,y1,c); } 30 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 31 | DigiFont font(customLineH,customLineV,customRect); 32 | // ----------------- 33 | 34 | void setup(void) 35 | { 36 | Serial.begin(9600); 37 | pinMode(LCD_BL, OUTPUT); 38 | digitalWrite(LCD_BL, HIGH); 39 | lcd.init(); 40 | lcd.cls(); 41 | lcd.display(); 42 | font.setColors(1,0); 43 | } 44 | 45 | unsigned long ms; 46 | char buf[20]; 47 | 48 | float readIntTemp() 49 | { 50 | long result; 51 | // Read temperature sensor against 1.1V reference 52 | ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX3); 53 | delay(2); // Wait for Vref to settle 54 | ADCSRA |= _BV(ADSC); // Convert 55 | while (bit_is_set(ADCSRA, ADSC)); 56 | result = ADCL; 57 | result |= ADCH << 8; 58 | result = (result - 125) * 1075; 59 | return result/10000.0; 60 | } 61 | 62 | void show2() 63 | { 64 | lcd.cls(); 65 | font.setColors(1,0); 66 | int w=29,h=52,y=8,t=7; 67 | ms=millis(); 68 | while(millis()-ms<9000) { 69 | float temp=readIntTemp(); 70 | dtostrf(temp,2,0,buf); 71 | font.setSize7(w-2,h,t,2); 72 | font.drawDigit7(buf[0],w*0,y); 73 | font.drawDigit7(buf[1],w*1,y); 74 | lcd.fillRect(w*2,y,t,t,1); 75 | font.drawDigit7(10+'c'-'a',w*2+t+2,y); 76 | lcd.display(); 77 | delay(500); 78 | } 79 | } 80 | 81 | void show2_1() 82 | { 83 | lcd.cls(); 84 | font.setColors(1,0); 85 | int w=21,h=50,y=9,t=5; 86 | ms=millis(); 87 | while(millis()-ms<9000) { 88 | float temp=readIntTemp(); 89 | dtostrf(temp,2,1,buf); 90 | font.setSize7(w-2,h,t,1); 91 | font.drawDigit7(buf[0],w*0,y); 92 | font.drawDigit7(buf[1],w*1,y); 93 | font.drawDigit7('.',w*2,y); 94 | font.drawDigit7(buf[3],w*2+t+2,y); 95 | lcd.fillRect(w*3+t+2,y,t,t,1); 96 | font.drawDigit7(10+'c'-'a',w*3+(t+2)*2,y); 97 | lcd.display(); 98 | delay(500); 99 | } 100 | } 101 | 102 | void loop() 103 | { 104 | show2(); 105 | show2_1(); 106 | } 107 | 108 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_thermometer_ST7567/DigiFont_lib_thermometer_ST7567.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // Temperature display on ST7567 LCD 3 | // (c) 2020 Pawel A. Hernik 4 | 5 | /* 6 | 128x64 ST7567 connections in SPI mode (only 5-6 wires between LCD and MCU): 7 | 8 | #01 LED -> D6, GND or any pin via resistor 9 | #02 RST -> D9 or any pin 10 | #03 CS -> D10 or any pin 11 | #04 DC -> D8 or any pin 12 | #05 SCK -> D13/SCK 13 | #06 SDI -> D11/MOSI 14 | #07 3V3 -> VCC (3.3V) 15 | #08 GND -> GND 16 | */ 17 | 18 | #define LCD_BL 6 19 | #define LCD_CS 10 20 | #define LCD_DC 8 21 | #define LCD_RST 9 22 | 23 | #include "ST7567_FB.h" 24 | #include 25 | ST7567_FB lcd(LCD_DC, LCD_RST, LCD_CS); 26 | 27 | // ----------------- 28 | #include "DigiFont.h" 29 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 30 | void customLineH(int x0,int x1, int y, int c) { lcd.drawLineHfast(x0,x1,y,c); } 31 | void customLineV(int x, int y0,int y1, int c) { lcd.drawLineVfast(x,y0,y1,c); } 32 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 33 | DigiFont font(customLineH,customLineV,customRect); 34 | // ----------------- 35 | 36 | void setup(void) 37 | { 38 | Serial.begin(9600); 39 | pinMode(LCD_BL, OUTPUT); 40 | digitalWrite(LCD_BL, LOW); 41 | lcd.init(); 42 | lcd.cls(); 43 | lcd.display(); 44 | font.setColors(1,0); 45 | } 46 | 47 | unsigned long ms; 48 | char buf[20]; 49 | 50 | float readIntTemp() 51 | { 52 | long result; 53 | // Read temperature sensor against 1.1V reference 54 | ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX3); 55 | delay(2); // Wait for Vref to settle 56 | ADCSRA |= _BV(ADSC); // Convert 57 | while (bit_is_set(ADCSRA, ADSC)); 58 | result = ADCL; 59 | result |= ADCH << 8; 60 | result = (result - 125) * 1075; 61 | return result/10000.0; 62 | } 63 | 64 | void show2() 65 | { 66 | lcd.cls(); 67 | font.setColors(1,0); 68 | int w=40,h=64,y=0,t=7; 69 | ms=millis(); 70 | while(millis()-ms<9000) { 71 | float temp=readIntTemp(); 72 | dtostrf(temp,2,0,buf); 73 | font.setSize7(w-2,h,t,2); 74 | font.drawDigit7(buf[0],w*0,y); 75 | font.drawDigit7(buf[1],w*1,y); 76 | lcd.fillRect(w*2,y,t,t,1); 77 | font.drawDigit7(10+'c'-'a',w*2+t+2,y); 78 | lcd.display(); 79 | delay(500); 80 | } 81 | } 82 | 83 | void show2_1() 84 | { 85 | lcd.cls(); 86 | font.setColors(1,0); 87 | int w=28,h=64,y=0,t=7; 88 | ms=millis(); 89 | while(millis()-ms<9000) { 90 | float temp=readIntTemp(); 91 | dtostrf(temp,2,1,buf); 92 | font.setSize7(w-2,h,t,1); 93 | font.drawDigit7(buf[0],w*0,y); 94 | font.drawDigit7(buf[1],w*1,y); 95 | font.drawDigit7('.',w*2,y); 96 | font.drawDigit7(buf[3],w*2+t+2,y); 97 | lcd.fillRect(w*3+t+2,y,t,t,1); 98 | font.drawDigit7(10+'c'-'a',w*3+(t+2)*2,y); 99 | lcd.display(); 100 | delay(500); 101 | } 102 | } 103 | 104 | void loop() 105 | { 106 | show2(); 107 | show2_1(); 108 | } 109 | 110 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_thermometer_ST7789/DigiFont_lib_thermometer_ST7789.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // Temperature display on ST7789 IPS 3 | // (c) 2020-24 Pawel A. Hernik 4 | 5 | /* 6 | ST7789 240x240 1.3" IPS (without CS pin) - only 4+2 wires required: 7 | #01 GND -> GND 8 | #02 VCC -> VCC (3.3V only!) 9 | #03 SCL -> D13/SCK 10 | #04 SDA -> D11/MOSI 11 | #05 RES -> D9 /PA0 or any digital (HW RESET is required to properly initialize LCD without CS) 12 | #06 DC -> D10/PA1 or any digital 13 | #07 BLK -> NC 14 | 15 | ST7789 240x280 1.69" IPS - only 4+2 wires required: 16 | #01 GND -> GND 17 | #02 VCC -> VCC (3.3V only!) 18 | #03 SCL -> D13/SCK 19 | #04 SDA -> D11/MOSI 20 | #05 RES -> optional 21 | #06 DC -> D10 or any digital 22 | #07 CS -> D9 or any digital 23 | #08 BLK -> VCC 24 | 25 | ST7789 170x320 1.9" IPS - only 4+2 wires required: 26 | #01 GND -> GND 27 | #02 VCC -> VCC (3.3V only!) 28 | #03 SCL -> D13/SCK 29 | #04 SDA -> D11/MOSI 30 | #05 RES -> optional 31 | #06 DC -> D10 or any digital 32 | #07 CS -> D9 or any digital 33 | #08 BLK -> VCC 34 | 35 | ST7789 240x320 2.0" IPS - only 4+2 wires required: 36 | #01 GND -> GND 37 | #02 VCC -> VCC (3.3V only!) 38 | #03 SCL -> D13/SCK 39 | #04 SDA -> D11/MOSI 40 | #05 RES -> optional 41 | #06 DC -> D10 or any digital 42 | #07 CS -> D9 or any digital 43 | */ 44 | 45 | #include 46 | #include 47 | #include "ST7789_AVR.h" 48 | 49 | #define SCR_WD 240 50 | #define SCR_HT 240 51 | //#define SCR_HT 320 52 | 53 | #define TFT_DC 10 54 | #define TFT_CS 9 // with CS 55 | #define TFT_RST -1 // with CS 56 | ST7789_AVR lcd = ST7789_AVR(TFT_DC, TFT_RST, TFT_CS); 57 | 58 | // ----------------- 59 | #include "DigiFont.h" 60 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 61 | void customLineH(int x0,int x1, int y, int c) { lcd.drawFastHLine(x0,y,x1-x0+1,c); } 62 | void customLineV(int x, int y0,int y1, int c) { lcd.drawFastVLine(x,y0,y1-y0+1,c); } 63 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 64 | DigiFont digi(customLineH,customLineV,customRect); 65 | // ----------------- 66 | 67 | void setup(void) 68 | { 69 | Serial.begin(9600); 70 | lcd.init(SCR_WD,SCR_HT); 71 | lcd.fillScreen(BLACK); 72 | } 73 | 74 | unsigned long ms,demoTime=5000; 75 | char buf[20]; 76 | 77 | float readIntTemp() 78 | { 79 | long result; 80 | // Read temperature sensor against 1.1V reference 81 | ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX3); 82 | delay(2); // Wait for Vref to settle 83 | ADCSRA |= _BV(ADSC); // Convert 84 | while (bit_is_set(ADCSRA, ADSC)); 85 | result = ADCL; 86 | result |= ADCH << 8; 87 | result = (result - 125) * 1075; 88 | return result/10000.0; 89 | } 90 | 91 | void show2_1() 92 | { 93 | int w=50,h=90,x=0,y=75,t=13; 94 | lcd.fillScreen(BLACK); 95 | digi.setColors(RGBto565(250,0,250),RGBto565(200,0,200),RGBto565(40,0,40)); 96 | digi.setSize7(w-2,h,t,t/2); 97 | digi.setSpacing(4); 98 | ms=millis(); 99 | while(millis()-ms 26 | HX1230_FB lcd(LCD_RST, LCD_CS); 27 | 28 | #include "c64enh_font.h" 29 | 30 | // ----------------- 31 | #include "DigiFont.h" 32 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 33 | void customLineH(int x0,int x1, int y, int c) { lcd.drawLineHfast(x0,x1,y,c); } 34 | void customLineV(int x, int y0,int y1, int c) { lcd.drawLineVfast(x,y0,y1,c); } 35 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 36 | DigiFont font(customLineH,customLineV,customRect); 37 | // ----------------- 38 | 39 | void setup(void) 40 | { 41 | Serial.begin(9600); 42 | pinMode(LCD_BL, OUTPUT); 43 | digitalWrite(LCD_BL, HIGH); 44 | lcd.init(); 45 | lcd.cls(); 46 | lcd.display(); 47 | font.setColors(1,0); 48 | } 49 | 50 | unsigned long ms; 51 | char buf[20]; 52 | 53 | void style7(int st) 54 | { 55 | long cnt = 23456; 56 | lcd.cls(); 57 | lcd.setFont(c64enh); 58 | font.setColors(1,0); 59 | font.setSpacing(2); 60 | ms=millis(); 61 | while(millis()-ms<5000) { 62 | snprintf(buf,19,"Style #7 s=%d",st); 63 | lcd.printStr(ALIGN_CENTER, 0, buf); 64 | snprintf(buf,6,"%05ld",cnt); 65 | font.setSize7(30,68-10,9,st); 66 | font.printNumber7(buf+4,0,10); 67 | font.setSize7(17,35,5,st>2?2:st); 68 | font.printNumber7("6:45",34,10); 69 | font.setSize7(10,20,3,st>1?1:st); 70 | font.printNumber7(buf,34,48); 71 | lcd.display(); 72 | delay(300); 73 | cnt+=111; 74 | } 75 | } 76 | 77 | void misc_3() 78 | { 79 | long cnt = 0; 80 | lcd.cls(); 81 | font.setColors(1,0); 82 | font.setSpacing(2); 83 | ms=millis(); 84 | int w=SCR_WD/3,h=60; 85 | while(millis()-ms<5000) { 86 | for(int i=0;i<3;i++) { font.setSize7(w-2,h,9,i+1); font.drawDigit7(cnt,w*i,0); } 87 | if(++cnt>9) cnt=0; 88 | lcd.display(); 89 | delay(400); 90 | } 91 | } 92 | 93 | void misc_4_5() 94 | { 95 | long cnt = 0; 96 | lcd.cls(); 97 | font.setColors(1,0); 98 | font.setSpacing(2); 99 | ms=millis(); 100 | int w=SCR_WD/4,h=38; 101 | int w2=SCR_WD/5,h2=29; 102 | while(millis()-ms<5000) { 103 | //h=50; cnt=8; 104 | for(int i=0;i<4;i++) { font.setSize7(w-2,h,7,i); font.drawDigit7(cnt,w*i,0); } 105 | for(int i=0;i<5;i++) { font.setSize7(w2-2,h2,5,i>2?2:i); font.drawDigit7(cnt,w2*i,68-h2); } 106 | if(++cnt>9) cnt=0; 107 | lcd.display(); 108 | delay(400); 109 | } 110 | } 111 | 112 | void demo() 113 | { 114 | lcd.cls(); 115 | lcd.setFont(c64enh); 116 | font.setColors(1,0); 117 | font.setSpacing(2); 118 | int w=SCR_WD/4,h=48; 119 | lcd.printStr(ALIGN_CENTER, 0, "segThick=7"); 120 | for(int i=0;i<4;i++) { 121 | font.setSize7(w-2,h,7,i); 122 | font.drawDigit7(8,w*i,68-h); 123 | snprintf(buf,19,"s=%d",i); 124 | lcd.printStr(i*w, 10, buf); 125 | } 126 | lcd.display(); 127 | delay(9000); 128 | } 129 | 130 | void loop() 131 | { 132 | demo(); 133 | style7(0); 134 | style7(1); 135 | style7(2); 136 | style7(3); 137 | style7(4); 138 | misc_3(); 139 | misc_4_5(); 140 | } 141 | 142 | -------------------------------------------------------------------------------- /examples/DigiFont_lib_ultimate7seg_ST7789/DigiFont_lib_ultimate7seg_ST7789.ino: -------------------------------------------------------------------------------- 1 | // DigiFont library example 2 | // Ultimate 7-segment demo on ST7789 3 | // (c) 2020-24 Pawel A. Hernik 4 | // YouTube videos: 5 | // https://youtu.be/X6PjfhcNE98 6 | // https://youtu.be/Z_YCfJZn_bA 7 | 8 | /* 9 | ST7789 240x240 1.3" IPS (without CS pin) - only 4+2 wires required: 10 | #01 GND -> GND 11 | #02 VCC -> VCC (3.3V only!) 12 | #03 SCL -> D13/SCK 13 | #04 SDA -> D11/MOSI 14 | #05 RES -> D9 /PA0 or any digital (HW RESET is required to properly initialize LCD without CS) 15 | #06 DC -> D10/PA1 or any digital 16 | #07 BLK -> NC 17 | 18 | ST7789 240x280 1.69" IPS - only 4+2 wires required: 19 | #01 GND -> GND 20 | #02 VCC -> VCC (3.3V only!) 21 | #03 SCL -> D13/SCK 22 | #04 SDA -> D11/MOSI 23 | #05 RES -> optional 24 | #06 DC -> D10 or any digital 25 | #07 CS -> D9 or any digital 26 | #08 BLK -> VCC 27 | 28 | ST7789 170x320 1.9" IPS - only 4+2 wires required: 29 | #01 GND -> GND 30 | #02 VCC -> VCC (3.3V only!) 31 | #03 SCL -> D13/SCK 32 | #04 SDA -> D11/MOSI 33 | #05 RES -> optional 34 | #06 DC -> D10 or any digital 35 | #07 CS -> D9 or any digital 36 | #08 BLK -> VCC 37 | 38 | ST7789 240x320 2.0" IPS - only 4+2 wires required: 39 | #01 GND -> GND 40 | #02 VCC -> VCC (3.3V only!) 41 | #03 SCL -> D13/SCK 42 | #04 SDA -> D11/MOSI 43 | #05 RES -> optional 44 | #06 DC -> D10 or any digital 45 | #07 CS -> D9 or any digital 46 | */ 47 | 48 | #include 49 | #include 50 | #include "ST7789_AVR.h" 51 | 52 | #define SCR_WD 240 53 | #define SCR_HT 240 54 | //#define SCR_HT 320 55 | 56 | #define TFT_DC 10 57 | #define TFT_CS 9 // with CS 58 | #define TFT_RST -1 // with CS 59 | ST7789_AVR lcd = ST7789_AVR(TFT_DC, TFT_RST, TFT_CS); 60 | 61 | // ----------------- 62 | #include "DigiFont.h" 63 | // needed for DigiFont library initialization, define your customLineH, customLineV and customRect 64 | void customLineH(int x0,int x1, int y, int c) { lcd.drawFastHLine(x0,y,x1-x0+1,c); } 65 | void customLineV(int x, int y0,int y1, int c) { lcd.drawFastVLine(x,y0,y1-y0+1,c); } 66 | void customRect(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 67 | DigiFont digi(customLineH,customLineV,customRect); 68 | // ----------------- 69 | 70 | void setup(void) 71 | { 72 | Serial.begin(9600); 73 | lcd.init(SCR_WD,SCR_HT); 74 | lcd.fillScreen(BLACK); 75 | lcd.setTextColor(WHITE); 76 | lcd.setTextSize(2); 77 | digi.setColors(RED,RGBto565(40,0,0)); 78 | } 79 | 80 | unsigned long ms; 81 | char buf[20]; 82 | 83 | void style7(int st) 84 | { 85 | long cnt = 23456; 86 | lcd.fillScreen(BLACK); 87 | digi.setColors(RED,RGBto565(40,0,0)); 88 | digi.setSpacing(2); 89 | ms=millis(); 90 | int x,y=30; 91 | while(millis()-ms<5000) { 92 | snprintf(buf,19,"Style #7 s=%d",st); 93 | lcd.setCursor(0,0); 94 | lcd.print(buf); 95 | snprintf(buf,6,"%05ld",cnt); 96 | digi.setColors(GREEN,RGBto565(0,40,0)); 97 | digi.setSize7(64,140,13,st); 98 | x=digi.printNumber7(buf+4,0,y); 99 | digi.setColors(RGBto565(250,0,250),RGBto565(40,0,40)); 100 | digi.setSize7(44,78,9,st); 101 | digi.printNumber7("6:45",x+10,y); 102 | digi.setColors(RED,RGBto565(40,0,0)); 103 | digi.setSize7(30,50,5,st>2?2:st); 104 | digi.printNumber7(buf,x+10,120); 105 | delay(300); 106 | cnt+=111; 107 | } 108 | } 109 | 110 | void misc_3() 111 | { 112 | long cnt = 0; 113 | lcd.fillScreen(BLACK); 114 | digi.setColors(GREEN,RGBto565(0,40,0)); 115 | digi.setSpacing(4); 116 | ms=millis(); 117 | int w=SCR_WD/3,h=140; 118 | while(millis()-ms<5000) { 119 | for(int i=0;i<3;i++) { digi.setSize7(w-4,h,11,i+1); digi.drawDigit7(cnt,w*i,0); } 120 | if(++cnt>9) cnt=0; 121 | delay(400); 122 | } 123 | } 124 | 125 | void misc_4_5() 126 | { 127 | long cnt = 0; 128 | lcd.fillScreen(BLACK); 129 | digi.setColors(GREEN,RGBto565(0,40,0)); 130 | digi.setSpacing(4); 131 | ms=millis(); 132 | int w=SCR_WD/4,h=80; 133 | int w2=SCR_WD/5,h2=65; 134 | while(millis()-ms<5000) { 135 | //h=50; cnt=8; 136 | for(int i=0;i<4;i++) { digi.setSize7(w-4,h,9,i); digi.drawDigit7(cnt,w*i,0); } 137 | for(int i=0;i<5;i++) { digi.setSize7(w2-4,h2,7,i>2?2:i); digi.drawDigit7(cnt,w2*i,90); } 138 | if(++cnt>9) cnt=0; 139 | delay(400); 140 | } 141 | } 142 | 143 | void demo() 144 | { 145 | lcd.fillScreen(BLACK); 146 | digi.setColors(GREEN,RGBto565(0,40,0)); 147 | digi.setSpacing(4); 148 | int w=SCR_WD/4,h=100; 149 | lcd.setCursor((240-10*12)/2,0); 150 | lcd.print("segThick=7"); 151 | for(int i=0;i<4;i++) { 152 | digi.setSize7(w-4,h,9,i); 153 | digi.drawDigit7(8,w*i,40); 154 | snprintf(buf,19,"s=%d",i); 155 | lcd.setCursor(w*i+10,20); 156 | lcd.print(buf); 157 | } 158 | delay(9000); 159 | } 160 | 161 | void loop() 162 | { 163 | demo(); 164 | for(int i=0;i<=4;i++) style7(i); 165 | misc_3(); 166 | misc_4_5(); 167 | } 168 | 169 | -------------------------------------------------------------------------------- /examples/ST7789_font_mem_usage/ST7789_font_mem_usage.ino: -------------------------------------------------------------------------------- 1 | // ST7789 library example 2 | // flash mem usage 3 | // (c) 2020 Pawel A. Hernik 4 | 5 | /* 6 | ST7789 240x240 IPS (without CS pin) connections (only 6 wires required): 7 | 8 | #01 GND -> GND 9 | #02 VCC -> VCC (3.3V only!) 10 | #03 SCL -> D13/PA5/SCK 11 | #04 SDA -> D11/PA7/MOSI 12 | #05 RES -> D9 /PA0 or any digital 13 | #06 DC -> D10/PA1 or any digital 14 | #07 BLK -> NC 15 | */ 16 | 17 | #include 18 | #include 19 | #if (__STM32F1__) // bluepill 20 | #define TFT_DC PA1 21 | #define TFT_RST PA0 22 | //#include 23 | #else 24 | #define TFT_DC 10 25 | #define TFT_RST 9 26 | #include 27 | #endif 28 | 29 | #define SCR_WD 240 30 | #define SCR_HT 240 31 | Arduino_ST7789 lcd = Arduino_ST7789(TFT_DC, TFT_RST); 32 | 33 | // ----------- 34 | #define USE_RRE 0 35 | #define USE_PROP 0 36 | #define USE_DIGI 1 37 | // ----------- 38 | 39 | 40 | #if USE_RRE==1 41 | #include "RREFont.h" 42 | #include "rre_term_10x16.h" 43 | RREFont rre; 44 | void customRectRRE(int x, int y, int w, int h, int c) { return lcd.fillRect(x, y, w, h, c); } 45 | #endif 46 | 47 | #if USE_PROP==1 48 | #include "PropFont.h" 49 | #include "term8x14_font.h" 50 | PropFont font; 51 | void customPixel(int x, int y, int c) { lcd.drawPixel(x, y, c); } 52 | void customRect(int x, int y, int w, int h, int c) { lcd.fillRect(x, y, w, h, c); } 53 | #endif 54 | 55 | #if USE_DIGI==1 56 | #include "DigiFont.h" 57 | void customLineH(int x0,int x1, int y, int c) { lcd.drawFastHLine(x0,y,x1-x0+1,c); } 58 | void customLineV(int x, int y0,int y1, int c) { lcd.drawFastVLine(x,y0,y1-y0+1,c); } 59 | void customRectD(int x, int y,int w,int h, int c) { lcd.fillRect(x,y,w,h,c); } 60 | DigiFont digi(customLineH,customLineV,customRectD); 61 | #endif 62 | 63 | 64 | //----------------------------------------------------------------------------- 65 | /* 66 | Memory tests - Arduino IDE 1.6.5 67 | Empty, only lcd.fillScreen(BLUE) 68 | 8932 69 | RRE + term 10x16 70 | 16524 7592b 71 | RRE + term 10x16 ENABLE_RRE_16B only 72 | 12354 3422b 73 | Prop + term 8x14PL (288 bytes for PL) 74 | 13160 75 | Digi 1: 10508 1576b 76 | Digi 2: 10330 1398b 77 | Digi 2c: 10560 1628b 78 | Digi 3: 10160 1228b (7seg rect) 79 | Digi 4: 11992 3060b (fill) 80 | Digi 5: 14198 5266b (outline) 81 | Digi 7: 10722 ---- (7seg utlimate old) 82 | Digi 7: 10770 1838b(7seg utlimate with 2 colors) 83 | */ 84 | 85 | #define RGBIto565(r,g,b,i) ((((((r)*(i))/255) & 0xF8) << 8) | ((((g)*(i)/255) & 0xFC) << 3) | ((((b)*(i)/255) & 0xFC) >> 3)) 86 | 87 | void setup() 88 | { 89 | Serial.begin(9600); 90 | lcd.init(SCR_WD, SCR_HT); 91 | lcd.fillScreen(RGBto565(80,0,80)); 92 | 93 | #if USE_RRE==1 94 | rre.init(customRectRRE, SCR_WD, SCR_HT); // custom fillRect function and screen width and height values 95 | rre.setFont(&rre_term_10x16); 96 | rre.setScale(2); 97 | rre.setColor(YELLOW); 98 | rre.printStr(10,10,"Test"); 99 | #endif 100 | 101 | #if USE_PROP==1 102 | font.init(customPixel, customRect, SCR_WD, SCR_HT); // custom drawPixel and fillRect function and screen width and height values 103 | font.setFont(Term8x14PL); 104 | font.setScale(2); 105 | font.setSpacing(2); 106 | font.setColor(YELLOW); 107 | font.printStr(10,50,"Test"); 108 | #endif 109 | 110 | #if USE_DIGI==1 111 | digi.setColors(RGBIto565(250,250,50,255),RGBIto565(250,250,50,180),RGBIto565(250,250,50,50)); 112 | //digi.setColors(RGBIto565(250,250,50,255),RGBIto565(250,250,50,50)); 113 | digi.setSpacing(4); 114 | 115 | //digi.setSize1(50,100,13); 116 | //digi.setSize2(50,100,13); 117 | //digi.setSize3(50,100,13); 118 | //digi.setSize4(50,100,13); //digi.setClearBg(0); // obsolete 119 | //digi.setSize5(50,100,13); //digi.setClearBg(0); // obsolete 120 | //digi.setSizeF(50,100,13); //digi.setClearBg(0); 121 | //digi.setSizeO(50,100,13); //digi.setClearBg(0); 122 | digi.setSize7(50,100,13,6); 123 | 124 | //digi.printNumber1("1234",10,120); 125 | //digi.printNumber2("1234",10,120); 126 | //digi.printNumber2c("1234",10,120); 127 | //digi.printNumber3("1234",10,120); 128 | //digi.printNumber4("1234",10,120); // obsolete 129 | //digi.printNumber5("1234",10,120); // obsolete 130 | //digi.printNumberF("1234",10,120); 131 | //digi.printNumberO("1234",10,120); 132 | digi.printNumber7("1284",10,120); 133 | //digi.setSize2(50,100,13); digi.printNumber2c("1284",10,0); 134 | #endif 135 | } 136 | 137 | 138 | void loop() 139 | { 140 | } 141 | 142 | -------------------------------------------------------------------------------- /images/allstyles.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbm80amiga/DigiFont/15749eb834e84bf0157cdd695f45e1512a4c8d99/images/allstyles.jpg -------------------------------------------------------------------------------- /images/st1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbm80amiga/DigiFont/15749eb834e84bf0157cdd695f45e1512a4c8d99/images/st1.jpg -------------------------------------------------------------------------------- /images/st2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbm80amiga/DigiFont/15749eb834e84bf0157cdd695f45e1512a4c8d99/images/st2.jpg -------------------------------------------------------------------------------- /images/st2c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbm80amiga/DigiFont/15749eb834e84bf0157cdd695f45e1512a4c8d99/images/st2c.jpg -------------------------------------------------------------------------------- /images/st3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbm80amiga/DigiFont/15749eb834e84bf0157cdd695f45e1512a4c8d99/images/st3.jpg -------------------------------------------------------------------------------- /images/st4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbm80amiga/DigiFont/15749eb834e84bf0157cdd695f45e1512a4c8d99/images/st4.jpg -------------------------------------------------------------------------------- /images/st5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbm80amiga/DigiFont/15749eb834e84bf0157cdd695f45e1512a4c8d99/images/st5.jpg -------------------------------------------------------------------------------- /images/st7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbm80amiga/DigiFont/15749eb834e84bf0157cdd695f45e1512a4c8d99/images/st7.jpg -------------------------------------------------------------------------------- /images/stFr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbm80amiga/DigiFont/15749eb834e84bf0157cdd695f45e1512a4c8d99/images/stFr.jpg -------------------------------------------------------------------------------- /images/style7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbm80amiga/DigiFont/15749eb834e84bf0157cdd695f45e1512a4c8d99/images/style7.jpg -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | DigiFont KEYWORD3 2 | 3 | init KEYWORD2 4 | setColors KEYWORD2 5 | setSpacing KEYWORD2 6 | setClearBg KEYWORD2 7 | setFrame KEYWORD2 8 | getWidth KEYWORD2 9 | getHeight KEYWORD2 10 | getNumberWidth KEYWORD2 11 | setSize1 KEYWORD2 12 | setSize2 KEYWORD2 13 | setSize2c KEYWORD2 14 | setSize3 KEYWORD2 15 | setSizeF KEYWORD2 16 | setSizeO KEYWORD2 17 | setSize7 KEYWORD2 18 | setSegment KEYWORD2 19 | drawDigit1 KEYWORD2 20 | drawDigit2 KEYWORD2 21 | drawDigit2c KEYWORD2 22 | drawDigit3 KEYWORD2 23 | drawDigitF KEYWORD2 24 | drawDigitO KEYWORD2 25 | drawDigit7 KEYWORD2 26 | printNumber1 KEYWORD2 27 | printNumber2 KEYWORD2 28 | printNumber2c KEYWORD2 29 | printNumber3 KEYWORD2 30 | printNumberF KEYWORD2 31 | printNumberFr KEYWORD2 32 | printNumberO KEYWORD2 33 | printNumber7 KEYWORD2 34 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=DigiFont 2 | version=1.1.1 3 | author=Pawel A. Hernik 4 | maintainer=Pawel A. Hernik 5 | sentence=Scalable 7-segment font 6 | paragraph=All digits 0..9 and additional characters are rendered using lines or rectangles 7 | category=Display 8 | url=https://github.com/cbm80amiga/DigiFont 9 | architectures=* 10 | depends=Adafruit GFX Library 11 | --------------------------------------------------------------------------------