u8x8_d_stdio.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. u8x8_d_stdio.c
  3. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
  4. Copyright (c) 2016, olikraus@gmail.com
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without modification,
  7. are permitted provided that the following conditions are met:
  8. * Redistributions of source code must retain the above copyright notice, this list
  9. of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above copyright notice, this
  11. list of conditions and the following disclaimer in the documentation and/or other
  12. materials provided with the distribution.
  13. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  14. CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  15. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  16. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  18. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  20. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  23. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  25. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #if 0
  28. #include "u8x8.h"
  29. #include <stdio.h>
  30. #define W 8
  31. #define H 2
  32. uint8_t bitmap[W*H*8];
  33. void bitmap_place_tile(uint8_t x, uint8_t y, uint8_t *tile)
  34. {
  35. uint8_t i;
  36. for(i = 0; i < 8; i++ )
  37. bitmap[x*8+y*W*8+i] = tile[i];
  38. }
  39. void bitmap_show(void)
  40. {
  41. int x, y;
  42. for( y = 0; y < H*8; y++ )
  43. {
  44. for( x = 0; x < W*8; x++ )
  45. {
  46. if ( (bitmap[x+(y/8)*W*8] & (1<<((y&7)))) != 0 )
  47. {
  48. printf("*");
  49. }
  50. else
  51. {
  52. printf(".");
  53. }
  54. }
  55. printf("\n");
  56. }
  57. }
  58. uint8_t u8x8_d_stdio(U8X8_UNUSED u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  59. {
  60. switch(msg)
  61. {
  62. case U8X8_MSG_DISPLAY_INIT:
  63. break;
  64. case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
  65. if ( arg_int == 0 )
  66. bitmap_show();
  67. break;
  68. case U8X8_MSG_DISPLAY_SET_CONTRAST:
  69. break;
  70. case U8X8_MSG_DISPLAY_DRAW_TILE:
  71. bitmap_place_tile(((u8x8_tile_t *)arg_ptr)->x_pos, ((u8x8_tile_t *)arg_ptr)->y_pos, ((u8x8_tile_t *)arg_ptr)->tile_ptr);
  72. break;
  73. default:
  74. break;
  75. }
  76. return 1;
  77. }
  78. void u8x8_SetupStdio(u8x8_t *u8x8)
  79. {
  80. u8x8_SetupDefaults(u8x8);
  81. u8x8->display_cb = u8x8_d_stdio;
  82. }
  83. #endif