ucg_init.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. ucg_init.c
  3. Universal uC Color Graphics Library
  4. Copyright (c) 2013, 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. #include "ucg.h"
  28. #include <string.h> /* memset */
  29. #ifdef __AVR__
  30. uint8_t global_SREG_backup; // used by the atomic macros
  31. #endif
  32. void ucg_init_struct(ucg_t *ucg)
  33. {
  34. //memset(ucg, 0, sizeof(ucg_t));
  35. ucg->is_power_up = 0;
  36. ucg->rotate_chain_device_cb = 0;
  37. ucg->arg.scale = 1;
  38. //ucg->display_offset.x = 0;
  39. //ucg->display_offset.y = 0;
  40. ucg->font = 0;
  41. //ucg->font_mode = UCG_FONT_MODE_NONE; Old font procedures
  42. ucg->font_decode.is_transparent = 1; // new font procedures
  43. ucg->com_initial_change_sent = 0;
  44. ucg->com_status = 0;
  45. ucg->com_cfg_cd = 0;
  46. }
  47. ucg_int_t ucg_Init(ucg_t *ucg, ucg_dev_fnptr device_cb, ucg_dev_fnptr ext_cb, ucg_com_fnptr com_cb)
  48. {
  49. ucg_int_t r;
  50. ucg_init_struct(ucg);
  51. if ( ext_cb == (ucg_dev_fnptr)0 )
  52. ucg->ext_cb = ucg_ext_none;
  53. else
  54. ucg->ext_cb = ext_cb;
  55. ucg->device_cb = device_cb;
  56. ucg->com_cb = com_cb;
  57. ucg_SetFontPosBaseline(ucg);
  58. r = ucg_PowerUp(ucg);
  59. ucg_GetDimension(ucg);
  60. return r;
  61. }