main.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. this example was written to debug a problem with a display width, which
  3. is not multiple of 8.
  4. the display width is set to 102 for this purpose
  5. this is also used to do more clip testing.
  6. any assertion indicates a bug.
  7. */
  8. #include "u8g2.h"
  9. #include <stdio.h>
  10. u8g2_t u8g2;
  11. void draw(void)
  12. {
  13. u8g2_SetFont(&u8g2, u8g2_font_ncenB24_tf);
  14. u8g2_DrawHLine(&u8g2, u8g2_GetDisplayWidth(&u8g2)-1, 2, 4);
  15. u8g2_SetFontDirection(&u8g2, 0);
  16. u8g2_DrawStr(&u8g2, -4, 20, "Clip/////");
  17. u8g2_DrawStr(&u8g2, -5, 50, "Clip/////");
  18. u8g2_DrawStr(&u8g2, -6, 80, "Clip/////");
  19. u8g2_DrawStr(&u8g2, -6, 110, "Clip/////");
  20. u8g2_SetFontDirection(&u8g2, 0);
  21. u8g2_SetFont(&u8g2, u8g2_font_ncenB12_tf);
  22. u8g2_DrawStr(&u8g2, 40, 40, "F");
  23. u8g2_SetFontDirection(&u8g2, 1);
  24. u8g2_DrawStr(&u8g2, 40, 40, "F");
  25. u8g2_SetFontDirection(&u8g2, 2);
  26. u8g2_DrawStr(&u8g2, 40, 40, "F");
  27. u8g2_SetFontDirection(&u8g2, 3);
  28. u8g2_DrawStr(&u8g2, 40, 40, "F");
  29. }
  30. int main(void)
  31. {
  32. u8g2_SetupBuffer_Utf8(&u8g2, U8G2_R0);
  33. u8g2_InitDisplay(&u8g2);
  34. u8g2_SetPowerSave(&u8g2, 0);
  35. u8g2_SetFontDirection(&u8g2, 0);
  36. //u8g2_SetClipWindow(&u8g2, 10, 10, 50, 60 );
  37. u8g2_SetDisplayRotation(&u8g2, U8G2_R0);
  38. u8g2_FirstPage(&u8g2);
  39. do
  40. {
  41. draw();
  42. } while( u8g2_NextPage(&u8g2) );
  43. puts("=======================================");
  44. utf8_show();
  45. u8g2_SetDisplayRotation(&u8g2, U8G2_R1);
  46. u8g2_FirstPage(&u8g2);
  47. do
  48. {
  49. draw();
  50. } while( u8g2_NextPage(&u8g2) );
  51. puts("=======================================");
  52. utf8_show();
  53. u8g2_SetDisplayRotation(&u8g2, U8G2_R2);
  54. u8g2_FirstPage(&u8g2);
  55. do
  56. {
  57. draw();
  58. } while( u8g2_NextPage(&u8g2) );
  59. puts("=======================================");
  60. utf8_show();
  61. u8g2_SetDisplayRotation(&u8g2, U8G2_R3);
  62. u8g2_FirstPage(&u8g2);
  63. do
  64. {
  65. draw();
  66. } while( u8g2_NextPage(&u8g2) );
  67. puts("=======================================");
  68. utf8_show();
  69. u8g2_SetDisplayRotation(&u8g2, U8G2_MIRROR);
  70. u8g2_FirstPage(&u8g2);
  71. do
  72. {
  73. draw();
  74. } while( u8g2_NextPage(&u8g2) );
  75. puts("=======================================");
  76. utf8_show();
  77. printf("DisplayWidth = %d\n", u8g2_GetDisplayWidth(&u8g2));
  78. return 0;
  79. }