main.c 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423
  1. /*
  2. main.c
  3. Generate pictures for the u8g2 reference manual.
  4. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
  5. Copyright (c) 2016, olikraus@gmail.com
  6. All rights reserved.
  7. Redistribution and use in source and binary forms, with or without modification,
  8. are permitted provided that the following conditions are met:
  9. * Redistributions of source code must retain the above copyright notice, this list
  10. of conditions and the following disclaimer.
  11. * Redistributions in binary form must reproduce the above copyright notice, this
  12. list of conditions and the following disclaimer in the documentation and/or other
  13. materials provided with the distribution.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  15. CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  16. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  17. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  19. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  24. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  25. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  26. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. #include <string.h>
  29. #include <stdlib.h>
  30. #include <stdio.h>
  31. #include "u8x8.h"
  32. #include "u8g2.h"
  33. extern uint8_t tga_is_transparent;
  34. extern uint8_t tga_desc_fg_r;
  35. extern uint8_t tga_desc_fg_g;
  36. extern uint8_t tga_desc_fg_b;
  37. extern uint8_t tga_desc_bg_r;
  38. extern uint8_t tga_desc_bg_g;
  39. extern uint8_t tga_desc_bg_b;
  40. extern uint8_t tga_lcd_fg_r;
  41. extern uint8_t tga_lcd_fg_g;
  42. extern uint8_t tga_lcd_fg_b;
  43. extern uint8_t tga_lcd_bg_r;
  44. extern uint8_t tga_lcd_bg_g;
  45. extern uint8_t tga_lcd_bg_b;
  46. extern void tga_save_png(const char *name);
  47. u8x8_t u8x8;
  48. u8g2_t u8g2;
  49. u8g2_t desc;
  50. #define u8g2_logo_97x51_width 97
  51. #define u8g2_logo_97x51_height 51
  52. static unsigned char u8g2_logo_97x51_bits[] = {
  53. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  54. 0x00, 0x3c, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00,
  55. 0x00, 0x00, 0x3c, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe,
  56. 0x03, 0x00, 0x00, 0x3c, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  57. 0xff, 0x03, 0x00, 0x00, 0x3c, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
  58. 0x80, 0xcf, 0x07, 0x00, 0x00, 0x3c, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00,
  59. 0x00, 0x80, 0x83, 0x07, 0x00, 0x00, 0x3c, 0x80, 0x07, 0xf8, 0x00, 0x00,
  60. 0x00, 0x00, 0x00, 0x81, 0x07, 0x00, 0x00, 0x3c, 0x80, 0x07, 0xfc, 0x03,
  61. 0x1c, 0x00, 0x3e, 0x1c, 0xc0, 0x03, 0x00, 0x00, 0x3c, 0x80, 0x07, 0xff,
  62. 0x07, 0x7f, 0x80, 0xff, 0x3f, 0xe0, 0x01, 0x00, 0x00, 0x3c, 0x80, 0x07,
  63. 0xff, 0x8f, 0xff, 0xc1, 0xff, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x3c, 0x80,
  64. 0x87, 0xff, 0xdf, 0xff, 0xc1, 0xc3, 0x07, 0x7c, 0x00, 0x00, 0x00, 0x3c,
  65. 0x80, 0x87, 0x0f, 0xfe, 0xff, 0xe3, 0x81, 0x03, 0x1e, 0x00, 0x00, 0x00,
  66. 0x3c, 0x80, 0xc7, 0x07, 0xfc, 0xe3, 0xe3, 0x81, 0x07, 0x0f, 0x00, 0x00,
  67. 0x00, 0x3c, 0x80, 0xc7, 0x07, 0xf8, 0xc1, 0xe7, 0x81, 0x87, 0xff, 0x07,
  68. 0x00, 0x00, 0x3c, 0x80, 0xc7, 0x03, 0xf0, 0x80, 0xe7, 0xc3, 0x87, 0xff,
  69. 0x07, 0x00, 0x00, 0x3c, 0x80, 0xc7, 0x03, 0x70, 0x80, 0xc7, 0xe7, 0x83,
  70. 0xff, 0x07, 0x00, 0x00, 0x3c, 0x80, 0xc7, 0x03, 0x78, 0x80, 0xc7, 0xff,
  71. 0x03, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x80, 0xc7, 0x03, 0xf8, 0xc0, 0x87,
  72. 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x80, 0xc7, 0x07, 0xfc, 0xc1,
  73. 0xc7, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xc0, 0x87, 0x0f, 0xfe,
  74. 0xff, 0xe3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xc0, 0x83, 0xff,
  75. 0xdf, 0xff, 0xe3, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xf1, 0x03,
  76. 0xff, 0x8f, 0xff, 0xe1, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
  77. 0x01, 0xfe, 0x0f, 0xff, 0xc0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xe0,
  78. 0xff, 0x00, 0xfc, 0x03, 0x7c, 0xc0, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
  79. 0x80, 0x3f, 0x00, 0xf8, 0x01, 0x00, 0xe0, 0x01, 0x1e, 0x00, 0x00, 0x00,
  80. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x1e, 0x00, 0x00,
  81. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x1e, 0x00,
  82. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xf0, 0xc7, 0x0f,
  83. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xe0, 0xff,
  84. 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xc0,
  85. 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff,
  86. 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff,
  87. 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  88. 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  89. 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  90. 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  91. 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  92. 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  93. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  94. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
  95. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
  96. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  97. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  98. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  99. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  100. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x24, 0x20, 0x00,
  101. 0x00, 0x08, 0x46, 0x02, 0x00, 0x80, 0xc0, 0x40, 0x00, 0x0c, 0x6e, 0x6a,
  102. 0xc0, 0xa4, 0x48, 0x04, 0xaa, 0xac, 0x8c, 0xaa, 0xac, 0x00, 0x6a, 0xa4,
  103. 0xaa, 0x20, 0xea, 0xa4, 0x64, 0x66, 0xaa, 0x46, 0x4a, 0x8a, 0x00, 0x4c,
  104. 0xa4, 0xaa, 0x20, 0xaa, 0xa2, 0x44, 0x2a, 0xaa, 0x28, 0xaa, 0x4c, 0x00,
  105. 0xe8, 0xa8, 0x6c, 0xc4, 0xa4, 0x42, 0xee, 0x2a, 0xcc, 0x26, 0x6c, 0xe8,
  106. 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  107. 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  108. 0x00, 0x00, 0x00 };
  109. void ra(uint16_t tx, uint16_t ty, const char *s)
  110. {
  111. int x,y, i, w;
  112. x = tx*3+64*3 + 0;
  113. y = ty*3+32*3 + 1;
  114. for( i = 0; i < 6; i++)
  115. {
  116. u8g2_DrawHVLine(&desc, x-2*i, y-i, 1+2*i, 1);
  117. u8g2_DrawHVLine(&desc, x-2*i-1, y-i, 1+2*i, 1);
  118. }
  119. u8g2_DrawHVLine(&desc, x-30, y-1, 28, 0);
  120. u8g2_DrawHVLine(&desc, x-30, y, 20, 0);
  121. u8g2_DrawHVLine(&desc, x-30, y+1, 28, 0);
  122. w = u8g2_GetStrWidth(&desc, s);
  123. u8g2_DrawStr(&desc, x-34-w, y+u8g2_GetAscent(&desc)/2, s);
  124. }
  125. /* vertical measure */
  126. /* tx,ty: lower point */
  127. void vm(uint16_t tx, uint16_t ty, uint16_t dy)
  128. {
  129. char s[10];
  130. int x,y, i, w;
  131. x = tx*3+64*3 + 1;
  132. y = ty*3+32*3 +3;
  133. u8g2_DrawHVLine(&desc, x-3, y-1, 7, 0);
  134. u8g2_DrawHVLine(&desc, x, y-dy*3, dy*3, 1);
  135. u8g2_DrawHVLine(&desc, x-3, y-dy*3, 7, 0);
  136. sprintf(s, "%d", dy);
  137. w = u8g2_GetStrWidth(&desc, s);
  138. u8g2_DrawStr(&desc, x+6, y-(dy*3)/2+u8g2_GetAscent(&desc)/2, s);
  139. }
  140. /* horizontal measure */
  141. /* tx,ty: left point */
  142. void hm(uint16_t tx, uint16_t ty, uint16_t dx)
  143. {
  144. char s[10];
  145. int x,y, i, w;
  146. x = tx*3+64*3 + 1;
  147. y = ty*3+32*3 +3;
  148. u8g2_DrawHVLine(&desc, x-1, y-3, 7, 1);
  149. u8g2_DrawHVLine(&desc, x, y, dx*3-1, 0);
  150. u8g2_DrawHVLine(&desc, x+(dx-1)*3+1, y-3, 7, 1);
  151. sprintf(s, "%d", dx);
  152. w = u8g2_GetStrWidth(&desc, s);
  153. u8g2_DrawStr(&desc, x+(dx*3)/2-w/2, y+6+u8g2_GetAscent(&desc), s);
  154. }
  155. int main(void)
  156. {
  157. /*
  158. tga_desc_fg_r = 100;
  159. tga_desc_fg_g = 118;
  160. tga_desc_fg_b = 135;
  161. */
  162. tga_desc_fg_r = 76;
  163. tga_desc_fg_g = 0;
  164. tga_desc_fg_b = 205;
  165. tga_desc_bg_r = 255;
  166. tga_desc_bg_g = 255;
  167. tga_desc_bg_b = 255;
  168. tga_lcd_fg_r = 0;
  169. tga_lcd_fg_g = 0;
  170. tga_lcd_fg_b = 0;
  171. tga_lcd_bg_r = 250;
  172. tga_lcd_bg_g = 193;
  173. tga_lcd_bg_b = 50;
  174. /*
  175. u8x8_Setup_TGA_DESC(&desc);
  176. u8x8_InitDisplay(&desc);
  177. u8x8_SetPowerSave(&desc, 0);
  178. u8x8_ClearDisplay(&desc);
  179. u8x8_SetFont(&desc, u8x8_font_amstrad_cpc_extended_r);
  180. u8x8_DrawString(&desc, 0, 0, "Description");
  181. */
  182. u8g2_SetupBuffer_TGA_DESC(&desc, &u8g2_cb_r0);
  183. u8g2_InitDisplay(&desc);
  184. u8g2_SetPowerSave(&desc, 0);
  185. u8g2_ClearDisplay(&desc);
  186. u8g2_SetupBuffer_TGA_LCD(&u8g2, &u8g2_cb_r0);
  187. u8g2_InitDisplay(&u8g2);
  188. u8g2_SetPowerSave(&u8g2, 0);
  189. u8g2_ClearDisplay(&u8g2);
  190. u8g2_FirstPage(&u8g2);
  191. do
  192. {
  193. u8g2_SetFont(&u8g2, u8g2_font_ncenB14_tf);
  194. u8g2_DrawStr(&u8g2, 0, 15, "Hello World!");
  195. } while( u8g2_NextPage(&u8g2) );
  196. tga_is_transparent = 1;
  197. u8g2_FirstPage(&desc);
  198. do
  199. {
  200. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  201. ra(0,15, "x=0, y=15");
  202. } while( u8g2_NextPage(&desc) );
  203. tga_is_transparent = 0;
  204. tga_save_png("u8g2_hello_world.png");
  205. /*=========================================*/
  206. /* u8g2_ascent_descent.png */
  207. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  208. u8g2_FirstPage(&u8g2);
  209. do
  210. {
  211. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  212. u8g2_DrawStr(&u8g2, 5, 20, "A gi");
  213. } while( u8g2_NextPage(&u8g2) );
  214. tga_is_transparent = 1;
  215. u8g2_FirstPage(&desc);
  216. do
  217. {
  218. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  219. ra(5,20, "x=5, y=20");
  220. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  221. vm(25,19, u8g2_GetAscent(&u8g2));
  222. /* descent usually is negative */
  223. vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  224. } while( u8g2_NextPage(&desc) );
  225. tga_is_transparent = 0;
  226. tga_save_png("u8g2_ascent_descent.png");
  227. /*=========================================*/
  228. /* u8g2_pos_center.png */
  229. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  230. u8g2_SetFontPosCenter(&u8g2);
  231. u8g2_FirstPage(&u8g2);
  232. do
  233. {
  234. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  235. u8g2_DrawStr(&u8g2, 5, 20, "Agi");
  236. } while( u8g2_NextPage(&u8g2) );
  237. tga_is_transparent = 1;
  238. u8g2_FirstPage(&desc);
  239. do
  240. {
  241. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  242. ra(5,20, "x=5, y=20");
  243. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  244. /* descent usually is negative */
  245. vm(48,19+u8g2.font_calc_vref(&u8g2)-u8g2_GetDescent(&u8g2), u8g2_GetAscent(&u8g2)-u8g2_GetDescent(&u8g2));
  246. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  247. } while( u8g2_NextPage(&desc) );
  248. tga_is_transparent = 0;
  249. u8g2_SetFontPosBaseline(&u8g2);
  250. tga_save_png("u8g2_pos_center.png");
  251. /*=========================================*/
  252. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  253. u8g2_FirstPage(&u8g2);
  254. do
  255. {
  256. u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
  257. u8g2_DrawGlyph(&u8g2, 5, 20, 0x2603);
  258. } while( u8g2_NextPage(&u8g2) );
  259. tga_is_transparent = 1;
  260. u8g2_FirstPage(&desc);
  261. do
  262. {
  263. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  264. ra(5,20, "x=5, y=20");
  265. } while( u8g2_NextPage(&desc) );
  266. tga_is_transparent = 0;
  267. tga_save_png("u8g2_snowman_glyph.png");
  268. /*=========================================*/
  269. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  270. u8g2_FirstPage(&u8g2);
  271. do
  272. {
  273. u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
  274. u8g2_DrawUTF8(&u8g2, 5, 20, "Snowman: ☃");
  275. } while( u8g2_NextPage(&u8g2) );
  276. tga_is_transparent = 1;
  277. u8g2_FirstPage(&desc);
  278. do
  279. {
  280. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  281. ra(5,20, "x=5, y=20");
  282. } while( u8g2_NextPage(&desc) );
  283. tga_is_transparent = 0;
  284. tga_save_png("u8g2_snowman_utf8.png");
  285. /*=========================================*/
  286. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  287. u8g2_FirstPage(&u8g2);
  288. do
  289. {
  290. u8g2_SetFontMode(&u8g2, 1); /* transparent */
  291. u8g2_SetFontDirection(&u8g2, 0);
  292. u8g2_SetFont(&u8g2, u8g2_font_inb24_mf);
  293. u8g2_DrawStr(&u8g2, 0, 30, "U");
  294. u8g2_SetFontDirection(&u8g2, 1);
  295. u8g2_SetFont(&u8g2, u8g2_font_inb30_mr);
  296. u8g2_DrawStr(&u8g2, 21, 8,"8");
  297. u8g2_SetFont(&u8g2, u8g2_font_inb24_mf);
  298. u8g2_SetFontDirection(&u8g2, 0);
  299. u8g2_DrawStr(&u8g2, 51,30,"g");
  300. u8g2_DrawStr(&u8g2, 67,30,"\xb2");
  301. u8g2_DrawHLine(&u8g2, 2, 35, 47);
  302. u8g2_DrawHLine(&u8g2, 3, 36, 47);
  303. u8g2_DrawVLine(&u8g2, 45, 32, 12);
  304. u8g2_DrawVLine(&u8g2, 46, 33, 12);
  305. u8g2_SetFont(&u8g2, u8g2_font_4x6_tr);
  306. u8g2_DrawStr(&u8g2, 1,54,"github.com/olikraus/u8g2");
  307. } while( u8g2_NextPage(&u8g2) );
  308. u8g2_SetFontDirection(&u8g2, 0);
  309. tga_is_transparent = 1;
  310. u8g2_FirstPage(&desc);
  311. do
  312. {
  313. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  314. } while( u8g2_NextPage(&desc) );
  315. tga_is_transparent = 0;
  316. tga_save_png("u8g2_logo.png");
  317. /*=========================================*/
  318. /* u8g2_box.png */
  319. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  320. u8g2_SetFontPosCenter(&u8g2);
  321. u8g2_FirstPage(&u8g2);
  322. do
  323. {
  324. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  325. u8g2_DrawBox(&u8g2, 3, 7, 25, 15);
  326. //u8g2_DrawFrame(&u8g2, 60, 40, 16, 9);
  327. } while( u8g2_NextPage(&u8g2) );
  328. tga_is_transparent = 1;
  329. u8g2_FirstPage(&desc);
  330. do
  331. {
  332. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  333. ra(3,7, "x=3, y=7");
  334. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  335. /* descent usually is negative */
  336. vm(3+25+2,7+15-1, 15);
  337. hm(3, 7+15+1, 25);
  338. //ra(60,40, "x=60, y=40");
  339. //vm(60+16+2,40+9-1, 9);
  340. //hm(60, 40+9+1, 16);
  341. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  342. } while( u8g2_NextPage(&desc) );
  343. tga_is_transparent = 0;
  344. u8g2_SetFontPosBaseline(&u8g2);
  345. tga_save_png("u8g2_box.png");
  346. /*=========================================*/
  347. /* u8g2_frame.png */
  348. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  349. u8g2_SetFontPosCenter(&u8g2);
  350. u8g2_FirstPage(&u8g2);
  351. do
  352. {
  353. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  354. u8g2_DrawFrame(&u8g2, 3, 7, 25, 15);
  355. //u8g2_DrawFrame(&u8g2, 60, 40, 16, 9);
  356. } while( u8g2_NextPage(&u8g2) );
  357. tga_is_transparent = 1;
  358. u8g2_FirstPage(&desc);
  359. do
  360. {
  361. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  362. ra(3,7, "x=3, y=7");
  363. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  364. /* descent usually is negative */
  365. vm(3+25+2,7+15-1, 15);
  366. hm(3, 7+15+1, 25);
  367. //ra(60,40, "x=60, y=40");
  368. //vm(60+16+2,40+9-1, 9);
  369. //hm(60, 40+9+1, 16);
  370. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  371. } while( u8g2_NextPage(&desc) );
  372. tga_is_transparent = 0;
  373. u8g2_SetFontPosBaseline(&u8g2);
  374. tga_save_png("u8g2_frame.png");
  375. /*=========================================*/
  376. /* u8g2_c_frame.png */
  377. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  378. u8g2_SetFont(&u8g2, u8g2_font_helvR08_tr);
  379. {
  380. char *s = "Cage";
  381. u8g2_uint_t w = u8g2_GetStrWidth(&u8g2, s);
  382. u8g2_uint_t h = u8g2_GetAscent(&u8g2)-u8g2_GetDescent(&u8g2);
  383. u8g2_uint_t x = 5;
  384. u8g2_uint_t y = 11;
  385. u8g2_SetFontPosBaseline(&u8g2);
  386. u8g2_FirstPage(&u8g2);
  387. do
  388. {
  389. u8g2_DrawStr(&u8g2, x, y, s);
  390. u8g2_DrawFrame(&u8g2, x-1,y-u8g2_GetAscent(&u8g2)-1, w+2, h+2);
  391. } while( u8g2_NextPage(&u8g2) );
  392. tga_is_transparent = 1;
  393. u8g2_FirstPage(&desc);
  394. do
  395. {
  396. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  397. ra(x,y, "x=5, y=11");
  398. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  399. /* descent usually is negative */
  400. vm(x-1+w+2+2,y-9+h+2-1, h+2);
  401. hm(x-1, y-8+h+2+1+10, w+2);
  402. hm(x, y-8+h+2+1, w);
  403. //ra(60,40, "x=60, y=40");
  404. //vm(60+16+2,40+9-1, 9);
  405. //hm(60, 40+9+1, 16);
  406. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  407. } while( u8g2_NextPage(&desc) );
  408. }
  409. tga_is_transparent = 0;
  410. u8g2_SetFontPosBaseline(&u8g2);
  411. tga_save_png("u8g2_c_frame.png");
  412. /*=========================================*/
  413. /* u8g2_button1.png */
  414. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  415. u8g2_SetFont(&u8g2, u8g2_font_helvR08_tr);
  416. {
  417. char *s = "Btn";
  418. u8g2_uint_t w = u8g2_GetStrWidth(&u8g2, s);
  419. u8g2_uint_t h = u8g2_GetAscent(&u8g2)-u8g2_GetDescent(&u8g2);
  420. u8g2_uint_t x = 62;
  421. u8g2_uint_t y = 20;
  422. u8g2_SetFontPosBaseline(&u8g2);
  423. u8g2_FirstPage(&u8g2);
  424. do
  425. {
  426. u8g2_DrawButtonUTF8(&u8g2, x, y, U8G2_BTN_BW2, 0, 2, 2, s );
  427. } while( u8g2_NextPage(&u8g2) );
  428. tga_is_transparent = 1;
  429. u8g2_FirstPage(&desc);
  430. do
  431. {
  432. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  433. ra(x,y, "x=62, y=20");
  434. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  435. /* descent usually is negative */
  436. vm(x-1+w+2+4,y-9+h+2-1+1, h+4);
  437. hm(x-2, y-8+h+2+3, w+4);
  438. //hm(x, y-8+h+2+3, w);
  439. //ra(60,40, "x=60, y=40");
  440. //vm(60+16+2,40+9-1, 9);
  441. //hm(60, 40+9+1, 16);
  442. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  443. } while( u8g2_NextPage(&desc) );
  444. }
  445. tga_is_transparent = 0;
  446. u8g2_SetFontPosBaseline(&u8g2);
  447. tga_save_png("u8g2_button1.png");
  448. /*=========================================*/
  449. /* u8g2_button2.png */
  450. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  451. u8g2_SetFont(&u8g2, u8g2_font_helvR08_tr);
  452. {
  453. char *s = "Btn";
  454. u8g2_uint_t w = u8g2_GetStrWidth(&u8g2, s);
  455. u8g2_uint_t h = u8g2_GetAscent(&u8g2)-u8g2_GetDescent(&u8g2);
  456. u8g2_uint_t x = 62;
  457. u8g2_uint_t y = 20;
  458. u8g2_SetFontPosBaseline(&u8g2);
  459. u8g2_FirstPage(&u8g2);
  460. do
  461. {
  462. u8g2_DrawButtonUTF8(&u8g2, x, y, U8G2_BTN_HCENTER|U8G2_BTN_BW2, 34, 2, 2, s );
  463. } while( u8g2_NextPage(&u8g2) );
  464. tga_is_transparent = 1;
  465. u8g2_FirstPage(&desc);
  466. do
  467. {
  468. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  469. ra(x,y, "x=62, y=20");
  470. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  471. /* descent usually is negative */
  472. vm(x-1+w+2+5,y-9+h+2-1+1, h+4);
  473. hm(x-19, y-8+h+2+3,34+4);
  474. //hm(x, y-8+h+2+3, w);
  475. //ra(60,40, "x=60, y=40");
  476. //vm(60+16+2,40+9-1, 9);
  477. //hm(60, 40+9+1, 16);
  478. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  479. } while( u8g2_NextPage(&desc) );
  480. }
  481. tga_is_transparent = 0;
  482. u8g2_SetFontPosBaseline(&u8g2);
  483. tga_save_png("u8g2_button2.png");
  484. /*=========================================*/
  485. /* u8g2_button3.png */
  486. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  487. u8g2_SetFont(&u8g2, u8g2_font_helvR08_tr);
  488. {
  489. char *s = "Btn";
  490. u8g2_uint_t w = u8g2_GetStrWidth(&u8g2, s);
  491. u8g2_uint_t h = u8g2_GetAscent(&u8g2)-u8g2_GetDescent(&u8g2);
  492. u8g2_uint_t x = 62;
  493. u8g2_uint_t y = 20;
  494. u8g2_SetFontPosBaseline(&u8g2);
  495. u8g2_FirstPage(&u8g2);
  496. do
  497. {
  498. u8g2_DrawButtonUTF8(&u8g2, x, y, U8G2_BTN_SHADOW1|U8G2_BTN_HCENTER|U8G2_BTN_BW2, 34, 2, 2, s );
  499. } while( u8g2_NextPage(&u8g2) );
  500. tga_is_transparent = 1;
  501. u8g2_FirstPage(&desc);
  502. do
  503. {
  504. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  505. ra(x,y, "x=62, y=20");
  506. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  507. /* descent usually is negative */
  508. vm(x-1+w+2+8,y-9+h+2-1+1, h+4);
  509. hm(x-19, y-8+h+2+6,34+4);
  510. //hm(x, y-8+h+2+3, w);
  511. //ra(60,40, "x=60, y=40");
  512. //vm(60+16+2,40+9-1, 9);
  513. //hm(60, 40+9+1, 16);
  514. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  515. } while( u8g2_NextPage(&desc) );
  516. }
  517. tga_is_transparent = 0;
  518. u8g2_SetFontPosBaseline(&u8g2);
  519. tga_save_png("u8g2_button3.png");
  520. /*=========================================*/
  521. /* u8g2_inv_button1.png */
  522. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  523. u8g2_SetFont(&u8g2, u8g2_font_helvR08_tr);
  524. {
  525. char *s = "Btn";
  526. u8g2_uint_t w = u8g2_GetStrWidth(&u8g2, s);
  527. u8g2_uint_t h = u8g2_GetAscent(&u8g2)-u8g2_GetDescent(&u8g2);
  528. u8g2_uint_t x = 62;
  529. u8g2_uint_t y = 20;
  530. u8g2_SetFontPosBaseline(&u8g2);
  531. u8g2_FirstPage(&u8g2);
  532. do
  533. {
  534. u8g2_DrawButtonUTF8(&u8g2, x, y, U8G2_BTN_INV, 0, 2, 2, s );
  535. } while( u8g2_NextPage(&u8g2) );
  536. tga_is_transparent = 1;
  537. u8g2_FirstPage(&desc);
  538. do
  539. {
  540. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  541. ra(x,y, "x=62, y=20");
  542. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  543. /* descent usually is negative */
  544. vm(x-1+w+2+4,y-9+h+2-1+1, h+4);
  545. hm(x-2, y-8+h+2+3, w+4);
  546. //hm(x, y-8+h+2+3, w);
  547. //ra(60,40, "x=60, y=40");
  548. //vm(60+16+2,40+9-1, 9);
  549. //hm(60, 40+9+1, 16);
  550. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  551. } while( u8g2_NextPage(&desc) );
  552. }
  553. tga_is_transparent = 0;
  554. u8g2_SetFontPosBaseline(&u8g2);
  555. tga_save_png("u8g2_inv_button1.png");
  556. /*=========================================*/
  557. /* u8g2_inv_button2.png */
  558. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  559. u8g2_SetFont(&u8g2, u8g2_font_helvR08_tr);
  560. {
  561. char *s = "Btn";
  562. u8g2_uint_t w = u8g2_GetStrWidth(&u8g2, s);
  563. u8g2_uint_t h = u8g2_GetAscent(&u8g2)-u8g2_GetDescent(&u8g2);
  564. u8g2_uint_t x = 62;
  565. u8g2_uint_t y = 20;
  566. u8g2_SetFontPosBaseline(&u8g2);
  567. u8g2_FirstPage(&u8g2);
  568. do
  569. {
  570. u8g2_DrawButtonUTF8(&u8g2, x, y, U8G2_BTN_INV|U8G2_BTN_BW2, 0, 2, 2, s );
  571. } while( u8g2_NextPage(&u8g2) );
  572. tga_is_transparent = 1;
  573. u8g2_FirstPage(&desc);
  574. do
  575. {
  576. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  577. ra(x,y, "x=62, y=20");
  578. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  579. /* descent usually is negative */
  580. vm(x-1+w+2+4,y-9+h+2-1+1, h+4);
  581. hm(x-2, y-8+h+2+3, w+4);
  582. //hm(x, y-8+h+2+3, w);
  583. //ra(60,40, "x=60, y=40");
  584. //vm(60+16+2,40+9-1, 9);
  585. //hm(60, 40+9+1, 16);
  586. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  587. } while( u8g2_NextPage(&desc) );
  588. }
  589. tga_is_transparent = 0;
  590. u8g2_SetFontPosBaseline(&u8g2);
  591. tga_save_png("u8g2_inv_button2.png");
  592. /*=========================================*/
  593. /* u8g2_inv_button3.png */
  594. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  595. u8g2_SetFont(&u8g2, u8g2_font_helvR08_tr);
  596. {
  597. char *s = "Btn";
  598. u8g2_uint_t w = u8g2_GetStrWidth(&u8g2, s);
  599. u8g2_uint_t h = u8g2_GetAscent(&u8g2)-u8g2_GetDescent(&u8g2);
  600. u8g2_uint_t x = 5;
  601. u8g2_uint_t y = 20;
  602. u8g2_SetFontPosBaseline(&u8g2);
  603. u8g2_FirstPage(&u8g2);
  604. do
  605. {
  606. u8g2_DrawButtonUTF8(&u8g2, x, y, U8G2_BTN_INV, u8g2_GetDisplayWidth(&u8g2)-x*2, x, 2, s );
  607. } while( u8g2_NextPage(&u8g2) );
  608. tga_is_transparent = 1;
  609. u8g2_FirstPage(&desc);
  610. do
  611. {
  612. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  613. ra(x,y, "x=5, y=20");
  614. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  615. /* descent usually is negative */
  616. vm(x-1+w+2+4,y-9+h+2-1+1, h+4);
  617. //hm(x-2, y-8+h+2+3, w+4);
  618. //hm(x, y-8+h+2+3, w);
  619. //ra(60,40, "x=60, y=40");
  620. //vm(60+16+2,40+9-1, 9);
  621. //hm(60, 40+9+1, 16);
  622. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  623. } while( u8g2_NextPage(&desc) );
  624. }
  625. tga_is_transparent = 0;
  626. u8g2_SetFontPosBaseline(&u8g2);
  627. tga_save_png("u8g2_inv_button3.png");
  628. /*=========================================*/
  629. /* u8g2_ellipse.png */
  630. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  631. u8g2_SetFontPosCenter(&u8g2);
  632. u8g2_FirstPage(&u8g2);
  633. do
  634. {
  635. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  636. //u8g2_DrawEllipse(&u8g2, 20, 25, 15, 10, U8G2_DRAW_UPPER_RIGHT|U8G2_DRAW_LOWER_LEFT|U8G2_DRAW_LOWER_RIGHT);
  637. u8g2_DrawEllipse(&u8g2, 20, 25, 15, 10, U8G2_DRAW_ALL);
  638. } while( u8g2_NextPage(&u8g2) );
  639. tga_is_transparent = 1;
  640. u8g2_FirstPage(&desc);
  641. do
  642. {
  643. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  644. ra(20,25, "x=20, y=25");
  645. /* descent usually is negative */
  646. vm(20+15+1, 25-1, 10);
  647. vm(20+15+1+13, 25+10, 21);
  648. hm(20+1, 25+10+1, 15);
  649. hm(20-15, 25+10+1+11, 31);
  650. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  651. } while( u8g2_NextPage(&desc) );
  652. tga_is_transparent = 0;
  653. u8g2_SetFontPosBaseline(&u8g2);
  654. tga_save_png("u8g2_ellipse.png");
  655. /*=========================================*/
  656. /* u8g2_circle.png */
  657. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  658. u8g2_SetFontPosCenter(&u8g2);
  659. u8g2_FirstPage(&u8g2);
  660. do
  661. {
  662. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  663. //u8g2_DrawEllipse(&u8g2, 20, 25, 15, 10, U8G2_DRAW_UPPER_RIGHT|U8G2_DRAW_LOWER_LEFT|U8G2_DRAW_LOWER_RIGHT);
  664. u8g2_DrawCircle(&u8g2, 20, 25, 10, U8G2_DRAW_ALL);
  665. } while( u8g2_NextPage(&u8g2) );
  666. tga_is_transparent = 1;
  667. u8g2_FirstPage(&desc);
  668. do
  669. {
  670. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  671. ra(20,25, "x=20, y=25");
  672. /* descent usually is negative */
  673. vm(20+15+1, 25-1, 10);
  674. vm(20+15+1+13, 25+10, 21);
  675. hm(20+1, 25+10+1, 10);
  676. hm(20-10, 25+10+1+11, 21);
  677. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  678. } while( u8g2_NextPage(&desc) );
  679. tga_is_transparent = 0;
  680. u8g2_SetFontPosBaseline(&u8g2);
  681. tga_save_png("u8g2_circle.png");
  682. /*=========================================*/
  683. /* u8g2_rframe.png */
  684. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  685. u8g2_SetFontPosCenter(&u8g2);
  686. u8g2_FirstPage(&u8g2);
  687. do
  688. {
  689. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  690. //u8g2_DrawEllipse(&u8g2, 20, 25, 15, 10, U8G2_DRAW_UPPER_RIGHT|U8G2_DRAW_LOWER_LEFT|U8G2_DRAW_LOWER_RIGHT);
  691. u8g2_DrawRFrame(&u8g2, 20, 15, 30, 22, 7);
  692. } while( u8g2_NextPage(&u8g2) );
  693. tga_is_transparent = 1;
  694. u8g2_FirstPage(&desc);
  695. do
  696. {
  697. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  698. ra(20,15, "x=20, y=15");
  699. /* descent usually is negative */
  700. vm(20+30+1, 15+22-1, 7);
  701. vm(20+30+1+8, 15+22-1, 22);
  702. hm(20+30-7, 15+22+1, 7);
  703. hm(20, 15+22+1+11, 30);
  704. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  705. } while( u8g2_NextPage(&desc) );
  706. tga_is_transparent = 0;
  707. u8g2_SetFontPosBaseline(&u8g2);
  708. tga_save_png("u8g2_rframe.png");
  709. /*=========================================*/
  710. /* u8g2_triangle.png */
  711. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  712. u8g2_SetFontPosCenter(&u8g2);
  713. u8g2_FirstPage(&u8g2);
  714. do
  715. {
  716. u8g2_SetFont(&u8g2, u8g2_font_ncenB18_tf);
  717. u8g2_DrawTriangle(&u8g2, 20, 5, 27, 50, 5, 32);
  718. } while( u8g2_NextPage(&u8g2) );
  719. tga_is_transparent = 1;
  720. u8g2_FirstPage(&desc);
  721. do
  722. {
  723. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  724. ra(20,5, "x=20, y=5");
  725. ra(27,50, "x=27, y=50");
  726. ra(5,32, "x=5, y=32");
  727. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  728. } while( u8g2_NextPage(&desc) );
  729. tga_is_transparent = 0;
  730. u8g2_SetFontPosBaseline(&u8g2);
  731. tga_save_png("u8g2_triangle.png");
  732. /*=========================================*/
  733. /* u8g2_line.png */
  734. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  735. u8g2_SetFontPosCenter(&u8g2);
  736. u8g2_FirstPage(&u8g2);
  737. do
  738. {
  739. u8g2_DrawLine(&u8g2, 20, 5, 5, 32);
  740. } while( u8g2_NextPage(&u8g2) );
  741. tga_is_transparent = 1;
  742. u8g2_FirstPage(&desc);
  743. do
  744. {
  745. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  746. ra(20,5, "x=20, y=5");
  747. ra(5,32, "x=5, y=32");
  748. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  749. } while( u8g2_NextPage(&desc) );
  750. tga_is_transparent = 0;
  751. u8g2_SetFontPosBaseline(&u8g2);
  752. tga_save_png("u8g2_line.png");
  753. /*=========================================*/
  754. /* u8g2_font_direction.png */
  755. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  756. u8g2_SetFontPosBaseline(&u8g2);
  757. u8g2_FirstPage(&u8g2);
  758. do
  759. {
  760. u8g2_SetFont(&u8g2, u8g2_font_ncenB14_tf);
  761. u8g2_SetFontDirection(&u8g2, 0);
  762. u8g2_DrawStr(&u8g2, 15, 20, "Abc");
  763. u8g2_SetFontDirection(&u8g2, 1);
  764. u8g2_DrawStr(&u8g2, 15, 20, "Abc");
  765. } while( u8g2_NextPage(&u8g2) );
  766. tga_is_transparent = 1;
  767. u8g2_FirstPage(&desc);
  768. do
  769. {
  770. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  771. ra(15,20, "x=15, y=20");
  772. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  773. } while( u8g2_NextPage(&desc) );
  774. tga_is_transparent = 0;
  775. u8g2_SetFontPosBaseline(&u8g2);
  776. u8g2_SetFontDirection(&u8g2, 0);
  777. tga_save_png("u8g2_font_direction.png");
  778. /*=========================================*/
  779. /* u8g2_xor.png */
  780. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  781. u8g2_SetFontMode(&u8g2, 1);
  782. u8g2_SetFontPosBaseline(&u8g2);
  783. u8g2_SetFontDirection(&u8g2, 0);
  784. u8g2_FirstPage(&u8g2);
  785. do
  786. {
  787. u8g2_SetDrawColor(&u8g2, 1);
  788. u8g2_DrawBox(&u8g2, 22, 2, 35, 50);
  789. u8g2_SetFont(&u8g2, u8g2_font_ncenB14_tf);
  790. u8g2_SetDrawColor(&u8g2, 0);
  791. u8g2_DrawStr(&u8g2, 5, 18, "abcd");
  792. u8g2_SetDrawColor(&u8g2, 1);
  793. u8g2_DrawStr(&u8g2, 5, 33, "abcd");
  794. u8g2_SetDrawColor(&u8g2, 2);
  795. u8g2_DrawStr(&u8g2, 5, 48, "abcd");
  796. } while( u8g2_NextPage(&u8g2) );
  797. u8g2_SetDrawColor(&u8g2, 1);
  798. tga_is_transparent = 1;
  799. u8g2_FirstPage(&desc);
  800. do
  801. {
  802. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  803. ra(5,15, "color 0");
  804. ra(5,30, "color 1");
  805. ra(5,45, "color 2");
  806. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  807. } while( u8g2_NextPage(&desc) );
  808. tga_is_transparent = 0;
  809. u8g2_SetFontPosBaseline(&u8g2);
  810. u8g2_SetFontDirection(&u8g2, 0);
  811. tga_save_png("u8g2_xor.png");
  812. /*=========================================*/
  813. /* u8g2_bitmap_solid.png */
  814. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  815. u8g2_SetFontMode(&u8g2, 1);
  816. u8g2_SetFontPosBaseline(&u8g2);
  817. u8g2_SetFontDirection(&u8g2, 0);
  818. u8g2_FirstPage(&u8g2);
  819. do
  820. {
  821. u8g2_SetDrawColor(&u8g2, 1);
  822. u8g2_SetBitmapMode(&u8g2, 0);
  823. u8g2_DrawXBM(&u8g2, 4,3, u8g2_logo_97x51_width, u8g2_logo_97x51_height, u8g2_logo_97x51_bits);
  824. u8g2_DrawXBM(&u8g2, 12,11, u8g2_logo_97x51_width, u8g2_logo_97x51_height, u8g2_logo_97x51_bits);
  825. } while( u8g2_NextPage(&u8g2) );
  826. u8g2_SetDrawColor(&u8g2, 1);
  827. tga_is_transparent = 1;
  828. u8g2_FirstPage(&desc);
  829. do
  830. {
  831. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  832. ra(4,3, "(4, 3)");
  833. ra(12,11, "(12, 11)");
  834. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  835. } while( u8g2_NextPage(&desc) );
  836. tga_is_transparent = 0;
  837. u8g2_SetFontPosBaseline(&u8g2);
  838. u8g2_SetFontDirection(&u8g2, 0);
  839. tga_save_png("u8g2_bitmap_solid.png");
  840. /*=========================================*/
  841. /* u8g2_bitmap_transparent.png */
  842. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  843. u8g2_SetFontMode(&u8g2, 1);
  844. u8g2_SetFontPosBaseline(&u8g2);
  845. u8g2_SetFontDirection(&u8g2, 0);
  846. u8g2_FirstPage(&u8g2);
  847. do
  848. {
  849. u8g2_SetDrawColor(&u8g2, 1);
  850. u8g2_SetBitmapMode(&u8g2, 1);
  851. u8g2_DrawXBM(&u8g2, 4,3, u8g2_logo_97x51_width, u8g2_logo_97x51_height, u8g2_logo_97x51_bits);
  852. u8g2_DrawXBM(&u8g2, 12,11, u8g2_logo_97x51_width, u8g2_logo_97x51_height, u8g2_logo_97x51_bits);
  853. } while( u8g2_NextPage(&u8g2) );
  854. u8g2_SetDrawColor(&u8g2, 1);
  855. tga_is_transparent = 1;
  856. u8g2_FirstPage(&desc);
  857. do
  858. {
  859. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  860. ra(4,3, "(4, 3)");
  861. ra(12,11, "(12, 11)");
  862. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  863. } while( u8g2_NextPage(&desc) );
  864. tga_is_transparent = 0;
  865. u8g2_SetFontPosBaseline(&u8g2);
  866. u8g2_SetFontDirection(&u8g2, 0);
  867. tga_save_png("u8g2_bitmap_transparent.png");
  868. /*=========================================*/
  869. /* u8g2_color.png */
  870. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  871. u8g2_SetFontPosCenter(&u8g2);
  872. u8g2_FirstPage(&u8g2);
  873. do
  874. {
  875. u8g2_uint_t x,y;
  876. u8g2_SetDrawColor(&u8g2, 1);
  877. for( y = 0; y < u8g2_GetDisplayHeight(&u8g2); y++ )
  878. for( x = 0; x < u8g2_GetDisplayWidth(&u8g2); x++ )
  879. if ( (x ^ y) & 1 )
  880. u8g2_DrawPixel(&u8g2, x, y);
  881. u8g2_SetFont(&u8g2, u8g2_font_9x15B_mf);
  882. u8g2_SetDrawColor(&u8g2, 1);
  883. u8g2_DrawStr(&u8g2, 3, 20, "Color = 1");
  884. u8g2_SetDrawColor(&u8g2, 0);
  885. u8g2_DrawStr(&u8g2, 3, 40, "Color = 0");
  886. } while( u8g2_NextPage(&u8g2) );
  887. u8g2_SetDrawColor(&u8g2, 1);
  888. tga_is_transparent = 1;
  889. u8g2_FirstPage(&desc);
  890. do
  891. {
  892. ra(3,20, "x=3, y=20");
  893. ra(3,40, "x=3, y=40");
  894. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  895. } while( u8g2_NextPage(&desc) );
  896. tga_is_transparent = 0;
  897. u8g2_SetFontPosBaseline(&u8g2);
  898. tga_save_png("u8g2_color.png");
  899. /*=========================================*/
  900. /* u8g2_fontmode.png */
  901. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  902. u8g2_SetFontPosCenter(&u8g2);
  903. u8g2_FirstPage(&u8g2);
  904. do
  905. {
  906. u8g2_uint_t x,y;
  907. u8g2_SetDrawColor(&u8g2, 1);
  908. for( y = 0; y < u8g2_GetDisplayHeight(&u8g2); y++ )
  909. for( x = 0; x < u8g2_GetDisplayWidth(&u8g2); x++ )
  910. if ( (x ^ y) & 1 )
  911. u8g2_DrawPixel(&u8g2, x, y);
  912. u8g2_SetFont(&u8g2, u8g2_font_8x13B_mf);
  913. u8g2_SetFontMode(&u8g2, 0);
  914. u8g2_SetDrawColor(&u8g2, 1);
  915. u8g2_DrawStr(&u8g2, 3, 15, "Color=1, Mode 0");
  916. u8g2_SetDrawColor(&u8g2, 0);
  917. u8g2_DrawStr(&u8g2, 3, 30, "Color=0, Mode 0");
  918. u8g2_SetFontMode(&u8g2, 1);
  919. u8g2_SetDrawColor(&u8g2, 1);
  920. u8g2_DrawStr(&u8g2, 3, 45, "Color=1, Mode 1");
  921. u8g2_SetDrawColor(&u8g2, 0);
  922. u8g2_DrawStr(&u8g2, 3, 60, "Color=0, Mode 1");
  923. } while( u8g2_NextPage(&u8g2) );
  924. u8g2_SetDrawColor(&u8g2, 1);
  925. u8g2_SetFontMode(&u8g2, 1);
  926. tga_is_transparent = 1;
  927. u8g2_FirstPage(&desc);
  928. do
  929. {
  930. ra(3,15, "x=3, y=15");
  931. ra(3,30, "x=3, y=30");
  932. ra(3,45, "x=3, y=45");
  933. ra(3,60, "x=3, y=60");
  934. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  935. } while( u8g2_NextPage(&desc) );
  936. tga_is_transparent = 0;
  937. u8g2_SetFontPosBaseline(&u8g2);
  938. tga_save_png("u8g2_fontmode.png");
  939. /*=========================================*/
  940. /* u8g2_message.png */
  941. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  942. u8g2_SetFontPosBaseline(&u8g2);
  943. u8g2_SetFont(&u8g2, u8g2_font_6x10_tf);
  944. u8g2_SetFontRefHeightAll(&u8g2); /* this will add some extra space for the text inside the buttons */
  945. u8g2_FirstPage(&u8g2);
  946. do
  947. {
  948. u8g2_UserInterfaceMessage(&u8g2, "Title1", "Title2", "Title3", " Ok \n Cancel ");
  949. } while( u8g2_NextPage(&u8g2) );
  950. tga_is_transparent = 1;
  951. u8g2_FirstPage(&desc);
  952. do
  953. {
  954. } while( u8g2_NextPage(&desc) );
  955. tga_is_transparent = 0;
  956. u8g2_SetFontPosBaseline(&u8g2);
  957. u8g2_SetFontRefHeightText(&u8g2);
  958. tga_save_png("u8g2_message.png");
  959. /*=========================================*/
  960. /* u8g2_selection_list.png */
  961. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  962. u8g2_SetFontPosBaseline(&u8g2);
  963. u8g2_SetFont(&u8g2, u8g2_font_6x10_tf);
  964. u8g2_SetFontRefHeightAll(&u8g2); /* this will add some extra space for the text inside the buttons */
  965. u8g2_UserInterfaceSelectionList(&u8g2, "Title", 1, "abcdef\nghijkl\nmnopqr");
  966. tga_is_transparent = 1;
  967. u8g2_FirstPage(&desc);
  968. do
  969. {
  970. /*
  971. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  972. ra(20,5, "x=20, y=5");
  973. ra(27,50, "x=27, y=50");
  974. ra(5,32, "x=5, y=32");
  975. */
  976. } while( u8g2_NextPage(&desc) );
  977. tga_is_transparent = 0;
  978. u8g2_SetFontPosBaseline(&u8g2);
  979. u8g2_SetFontRefHeightText(&u8g2);
  980. tga_save_png("u8g2_selection_list.png");
  981. /*=========================================*/
  982. /* u8g2_input_value.png */
  983. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  984. u8g2_SetFontPosBaseline(&u8g2);
  985. u8g2_SetFont(&u8g2, u8g2_font_6x10_tf);
  986. u8g2_SetFontRefHeightAll(&u8g2); /* this will add some extra space for the text inside the buttons */
  987. {
  988. uint8_t v = 4;
  989. u8g2_UserInterfaceInputValue(&u8g2, "Select Voltage", "DAC= ", &v, 0, 5, 1, " V");
  990. }
  991. tga_is_transparent = 1;
  992. u8g2_FirstPage(&desc);
  993. do
  994. {
  995. /*
  996. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  997. ra(20,5, "x=20, y=5");
  998. ra(27,50, "x=27, y=50");
  999. ra(5,32, "x=5, y=32");
  1000. */
  1001. } while( u8g2_NextPage(&desc) );
  1002. tga_is_transparent = 0;
  1003. u8g2_SetFontPosBaseline(&u8g2);
  1004. u8g2_SetFontRefHeightText(&u8g2);
  1005. tga_save_png("u8g2_input_value.png");
  1006. /*=========================================*/
  1007. /* u8g2_clip_window.png */
  1008. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  1009. u8g2_SetFontPosBaseline(&u8g2);
  1010. u8g2_SetFont(&u8g2, u8g2_font_ncenB24_tf);
  1011. u8g2_SetClipWindow(&u8g2, 10, 10, 85, 30);
  1012. u8g2_SetDrawColor(&u8g2, 1);
  1013. u8g2_FirstPage(&u8g2);
  1014. do
  1015. {
  1016. u8g2_DrawStr(&u8g2, 3, 32, "U8g2");
  1017. } while( u8g2_NextPage(&u8g2) );
  1018. tga_is_transparent = 1;
  1019. u8g2_FirstPage(&desc);
  1020. do
  1021. {
  1022. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  1023. ra(10,10, "(10, 10)");
  1024. ra(85,30, "(85, 30)");
  1025. ra(3,32, "(3, 32)");
  1026. hm(10, 35, 75);
  1027. vm(88, 29, 20);
  1028. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  1029. } while( u8g2_NextPage(&desc) );
  1030. tga_is_transparent = 0;
  1031. u8g2_SetFontPosBaseline(&u8g2);
  1032. u8g2_SetFontDirection(&u8g2, 0);
  1033. u8g2_SetMaxClipWindow(&u8g2);
  1034. tga_save_png("u8g2_clip_window.png");
  1035. /*=========================================*/
  1036. /* u8g2_tile_row.png */
  1037. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  1038. u8g2_FirstPage(&u8g2);
  1039. do
  1040. {
  1041. } while( u8g2_NextPage(&u8g2) );
  1042. u8g2_SetFontPosBaseline(&u8g2);
  1043. u8g2_SetDrawColor(&u8g2, 1);
  1044. u8g2_SetBufferCurrTileRow(&u8g2, 0);
  1045. u8g2_SetFont(&u8g2, u8g2_font_helvB08_tr);
  1046. u8g2_DrawStr(&u8g2, 2, 8, "abcdefg");
  1047. u8g2_SetBufferCurrTileRow(&u8g2, 2);
  1048. u8g2_SendBuffer(&u8g2);
  1049. u8g2_SetBufferCurrTileRow(&u8g2, 4);
  1050. u8g2_SendBuffer(&u8g2);
  1051. tga_is_transparent = 1;
  1052. u8g2_FirstPage(&desc);
  1053. do
  1054. {
  1055. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  1056. ra(2,8, "(2, 8)");
  1057. ra(2,24, "(2, 24)");
  1058. ra(2,40, "(2, 40)");
  1059. //hm(10, 35, 75);
  1060. //vm(88, 29, 20);
  1061. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  1062. } while( u8g2_NextPage(&desc) );
  1063. tga_is_transparent = 0;
  1064. u8g2_SetFontPosBaseline(&u8g2);
  1065. u8g2_SetFontDirection(&u8g2, 0);
  1066. tga_save_png("u8g2_tile_row.png");
  1067. /*=========================================*/
  1068. /* u8g2_x_offset.png */
  1069. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  1070. u8g2_FirstPage(&u8g2);
  1071. do
  1072. {
  1073. u8g2_SetFontPosBaseline(&u8g2);
  1074. u8g2_SetDrawColor(&u8g2, 1);
  1075. u8g2_SetFont(&u8g2, u8g2_font_helvR08_te);
  1076. u8g2_DrawUTF8(&u8g2, 6, 12, "A helvR08");
  1077. u8g2_DrawUTF8(&u8g2, 6, 24, "C helvR08");
  1078. u8g2_DrawUTF8(&u8g2, 6, 36, "Ĉ helvR08");
  1079. u8g2_SetFont(&u8g2, u8g2_font_ncenB08_te);
  1080. u8g2_DrawUTF8(&u8g2, 6, 48, "A ncenB08");
  1081. } while( u8g2_NextPage(&u8g2) );
  1082. tga_is_transparent = 1;
  1083. u8g2_FirstPage(&desc);
  1084. do
  1085. {
  1086. u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
  1087. ra(6,12, "0 (6, 12)");
  1088. ra(6,24, "+1 (6, 24)");
  1089. ra(6,36, "+1 (6, 36)");
  1090. ra(6,48, "-1 (6, 48)");
  1091. //hm(2, 37, 1);
  1092. //vm(88, 29, 20);
  1093. //vm(62,19-u8g2_GetDescent(&u8g2), -u8g2_GetDescent(&u8g2));
  1094. } while( u8g2_NextPage(&desc) );
  1095. tga_is_transparent = 0;
  1096. u8g2_SetFontPosBaseline(&u8g2);
  1097. u8g2_SetFontDirection(&u8g2, 0);
  1098. tga_save_png("u8g2_x_offset.png");
  1099. /*=========================================*/
  1100. u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
  1101. return 0;
  1102. }