| 1 | /* |
| 2 | |
| 3 | u8log_u8x8.c |
| 4 | |
| 5 | |
| 6 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) |
| 7 | |
| 8 | Copyright (c) 2018, olikraus@gmail.com |
| 9 | All rights reserved. |
| 10 | |
| 11 | Redistribution and use in source and binary forms, with or without modification, |
| 12 | are permitted provided that the following conditions are met: |
| 13 | |
| 14 | * Redistributions of source code must retain the above copyright notice, this list |
| 15 | of conditions and the following disclaimer. |
| 16 | |
| 17 | * Redistributions in binary form must reproduce the above copyright notice, this |
| 18 | list of conditions and the following disclaimer in the documentation and/or other |
| 19 | materials provided with the distribution. |
| 20 | |
| 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
| 22 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
| 23 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 24 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
| 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 27 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 28 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 31 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 32 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 33 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | |
| 35 | */ |
| 36 | |
| 37 | #include "u8x8.h" |
| 38 | |
| 39 | static void u8x8_DrawLogLine(u8x8_t *u8x8, uint8_t disp_x, uint8_t disp_y, uint8_t buf_y, u8log_t *u8log) U8X8_NOINLINE; |
| 40 | static void u8x8_DrawLogLine(u8x8_t *u8x8, uint8_t disp_x, uint8_t disp_y, uint8_t buf_y, u8log_t *u8log) |
| 41 | { |
| 42 | uint8_t buf_x; |
| 43 | uint8_t c; |
| 44 | for( buf_x = 0; buf_x < u8log->width; buf_x++ ) |
| 45 | { |
| 46 | c = u8log->screen_buffer[buf_y * u8log->width + buf_x]; |
| 47 | u8x8_DrawGlyph(u8x8, disp_x, disp_y, c); |
| 48 | disp_x++; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | void u8x8_DrawLog(u8x8_t *u8x8, uint8_t x, uint8_t y, u8log_t *u8log) |
| 53 | { |
| 54 | uint8_t buf_y; |
| 55 | for( buf_y = 0; buf_y < u8log->height; buf_y++ ) |
| 56 | { |
| 57 | u8x8_DrawLogLine(u8x8, x, y, buf_y, u8log); |
| 58 | y++; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | |
| 63 | void u8log_u8x8_cb(u8log_t * u8log) |
| 64 | { |
| 65 | u8x8_t *u8x8 = (u8x8_t *)(u8log->aux_data); |
| 66 | if ( u8log->is_redraw_all ) |
| 67 | { |
| 68 | u8x8_DrawLog(u8x8, 0, 0, u8log); |
| 69 | } |
| 70 | else if ( u8log->is_redraw_line ) |
| 71 | { |
| 72 | u8x8_DrawLogLine(u8x8, 0, u8log->redraw_line, u8log->redraw_line, u8log); |
| 73 | } |
| 74 | } |
| 75 | |