main.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include "u8g2.h"
  2. #include <stdio.h>
  3. u8g2_t u8g2;
  4. int main(void)
  5. {
  6. int x, y;
  7. int k;
  8. int i;
  9. u8g2_SetupBuffer_SDL_128x64_1(&u8g2, &u8g2_cb_r0);
  10. u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
  11. u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
  12. x = 2;
  13. y = 8;
  14. for(;;)
  15. {
  16. /*
  17. u8g2_ClearBuffer(&u8g2);
  18. u8g2_SetFontDirection(&u8g2, 0);
  19. u8g2_DrawStr(&u8g2, x, y, "ABC");
  20. u8g2_SetFontDirection(&u8g2, 1);
  21. u8g2_DrawStr(&u8g2, x, y, "abc");
  22. u8g2_SetFontDirection(&u8g2, 2);
  23. u8g2_DrawStr(&u8g2, x, y, "abc");
  24. u8g2_SetFontDirection(&u8g2, 3);
  25. u8g2_DrawStr(&u8g2, x, y, "abc");
  26. u8g2_SendBuffer(&u8g2);
  27. */
  28. u8g2_SetBufferCurrTileRow(&u8g2, 0);
  29. u8g2_ClearBuffer(&u8g2);
  30. u8g2_SetFont(&u8g2, u8g2_font_helvB08_tr);
  31. u8g2_DrawStr(&u8g2, x, y, "ABC def");
  32. u8g2_SendBuffer(&u8g2);
  33. u8g2_SetBufferCurrTileRow(&u8g2, 4);
  34. u8g2_SendBuffer(&u8g2);
  35. do
  36. {
  37. k = u8g_sdl_get_key();
  38. } while( k < 0 );
  39. if ( k == 273 ) y -= 7;
  40. if ( k == 274 ) y += 7;
  41. if ( k == 276 ) x -= 7;
  42. if ( k == 275 ) x += 7;
  43. if ( k == 'e' ) y -= 1;
  44. if ( k == 'x' ) y += 1;
  45. if ( k == 's' ) x -= 1;
  46. if ( k == 'd' ) x += 1;
  47. if ( k == 'q' ) break;
  48. if ( k == 't' )
  49. u8x8_SaveBitmapTGA(u8g2_GetU8x8(&u8g2), "screenshot.tga");
  50. }
  51. //u8x8_Set8x8Font(u8g2_GetU8x8(&u8g2), bdf_font);
  52. //u8x8_Draw8x8String(u8g2_GetU8x8(&u8g2), 0, 0, "Hello World!");
  53. return 0;
  54. }