ucg_dev_msg_api.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. ucg_dev_msg_api.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 <stddef.h>
  29. void ucg_PowerDown(ucg_t *ucg)
  30. {
  31. if ( ucg->is_power_up != 0 )
  32. {
  33. ucg->device_cb(ucg, UCG_MSG_DEV_POWER_DOWN, NULL);
  34. ucg->is_power_up = 0;
  35. }
  36. }
  37. ucg_int_t ucg_PowerUp(ucg_t *ucg)
  38. {
  39. ucg_int_t r;
  40. /* power down first. will do nothing if power is already down */
  41. ucg_PowerDown(ucg);
  42. /* now try to power up the display */
  43. r = ucg->device_cb(ucg, UCG_MSG_DEV_POWER_UP, NULL);
  44. if ( r != 0 )
  45. {
  46. ucg->is_power_up = 1;
  47. }
  48. return r;
  49. }
  50. void ucg_SetClipBox(ucg_t *ucg, ucg_box_t *clip_box)
  51. {
  52. ucg->device_cb(ucg, UCG_MSG_SET_CLIP_BOX, (void *)(clip_box));
  53. }
  54. void ucg_SetClipRange(ucg_t *ucg, ucg_int_t x, ucg_int_t y, ucg_int_t w, ucg_int_t h)
  55. {
  56. ucg_box_t clip_box;
  57. clip_box.ul.x = x;
  58. clip_box.ul.y = y;
  59. clip_box.size.w = w;
  60. clip_box.size.h = h;
  61. ucg_SetClipBox(ucg, &clip_box);
  62. }
  63. void ucg_SetMaxClipRange(ucg_t *ucg)
  64. {
  65. ucg_box_t new_clip_box;
  66. new_clip_box.size = ucg->dimension;
  67. new_clip_box.ul.x = 0;
  68. new_clip_box.ul.y = 0;
  69. ucg_SetClipBox(ucg, &new_clip_box);
  70. }
  71. /*
  72. Query the display dimension from the driver, reset clip window to maximum
  73. new dimension
  74. */
  75. void ucg_GetDimension(ucg_t *ucg)
  76. {
  77. ucg->device_cb(ucg, UCG_MSG_GET_DIMENSION, &(ucg->dimension));
  78. ucg_SetMaxClipRange(ucg);
  79. }
  80. void ucg_DrawPixelWithArg(ucg_t *ucg)
  81. {
  82. ucg->device_cb(ucg, UCG_MSG_DRAW_PIXEL, NULL);
  83. }
  84. void ucg_DrawL90FXWithArg(ucg_t *ucg)
  85. {
  86. ucg->device_cb(ucg, UCG_MSG_DRAW_L90FX, &(ucg->arg));
  87. }
  88. #ifdef UCG_MSG_DRAW_L90TC
  89. void ucg_DrawL90TCWithArg(ucg_t *ucg)
  90. {
  91. ucg->device_cb(ucg, UCG_MSG_DRAW_L90TC, &(ucg->arg));
  92. }
  93. #endif /* UCG_MSG_DRAW_L90TC */
  94. #ifdef UCG_MSG_DRAW_L90BF
  95. void ucg_DrawL90BFWithArg(ucg_t *ucg)
  96. {
  97. ucg->device_cb(ucg, UCG_MSG_DRAW_L90BF, &(ucg->arg));
  98. }
  99. #endif /* UCG_MSG_DRAW_L90BF */
  100. void ucg_DrawL90SEWithArg(ucg_t *ucg)
  101. {
  102. ucg->device_cb(ucg, UCG_MSG_DRAW_L90SE, &(ucg->arg));
  103. }
  104. /*
  105. void ucg_DrawL90RLWithArg(ucg_t *ucg)
  106. {
  107. ucg->device_cb(ucg, UCG_MSG_DRAW_L90RL, &(ucg->arg));
  108. }
  109. */