2015-11-07 04:07:14 +08:00
|
|
|
/*
|
|
|
|
|
|
|
|
u8g2_setup.c
|
2016-01-01 16:35:22 +08:00
|
|
|
|
2016-01-04 00:10:50 +08:00
|
|
|
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
2016-01-01 16:35:22 +08:00
|
|
|
|
|
|
|
Copyright (c) 2016, olikraus@gmail.com
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright notice, this list
|
|
|
|
of conditions and the following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
|
|
list of conditions and the following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
|
|
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2015-11-07 04:07:14 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "u8g2.h"
|
|
|
|
#include <string.h>
|
2018-10-27 23:29:10 +08:00
|
|
|
#include <assert.h>
|
|
|
|
|
2015-11-07 04:07:14 +08:00
|
|
|
|
2018-10-28 04:44:42 +08:00
|
|
|
/*============================================*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
2018-10-28 06:02:15 +08:00
|
|
|
|
2018-10-28 04:44:42 +08:00
|
|
|
void u8g2_SetMaxClipWindow(u8g2_t *u8g2)
|
|
|
|
{
|
|
|
|
u8g2->clip_x0 = 0;
|
|
|
|
u8g2->clip_y0 = 0;
|
|
|
|
u8g2->clip_x1 = (u8g2_uint_t)~(u8g2_uint_t)0;
|
|
|
|
u8g2->clip_y1 = (u8g2_uint_t)~(u8g2_uint_t)0;
|
2018-10-28 14:59:04 +08:00
|
|
|
|
|
|
|
u8g2->cb->update_page_win(u8g2);
|
2018-10-28 04:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void u8g2_SetClipWindow(u8g2_t *u8g2, u8g2_uint_t clip_x0, u8g2_uint_t clip_y0, u8g2_uint_t clip_x1, u8g2_uint_t clip_y1 )
|
|
|
|
{
|
|
|
|
u8g2->clip_x0 = clip_x0;
|
|
|
|
u8g2->clip_y0 = clip_y0;
|
|
|
|
u8g2->clip_x1 = clip_x1;
|
|
|
|
u8g2->clip_y1 = clip_y1;
|
2018-10-28 14:59:04 +08:00
|
|
|
u8g2->cb->update_page_win(u8g2);
|
2018-10-28 04:44:42 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-11-07 04:07:14 +08:00
|
|
|
/*============================================*/
|
2016-08-13 20:25:57 +08:00
|
|
|
/*
|
|
|
|
This procedure is called after setting up the display (u8x8 structure).
|
|
|
|
--> This is the central init procedure for u8g2 object
|
|
|
|
*/
|
2016-02-23 01:51:48 +08:00
|
|
|
void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, u8g2_draw_ll_hvline_cb ll_hvline_cb, const u8g2_cb_t *u8g2_cb)
|
2015-11-07 04:07:14 +08:00
|
|
|
{
|
2016-08-13 20:25:57 +08:00
|
|
|
u8g2->font = NULL;
|
2016-08-16 04:02:23 +08:00
|
|
|
//u8g2->kerning = NULL;
|
|
|
|
//u8g2->get_kerning_cb = u8g2_GetNullKerning;
|
2016-08-13 20:25:57 +08:00
|
|
|
|
2016-02-23 01:51:48 +08:00
|
|
|
//u8g2->ll_hvline = u8g2_ll_hvline_vertical_top_lsb;
|
|
|
|
u8g2->ll_hvline = ll_hvline_cb;
|
2016-02-18 05:12:19 +08:00
|
|
|
|
2015-11-07 04:07:14 +08:00
|
|
|
u8g2->tile_buf_ptr = buf;
|
|
|
|
u8g2->tile_buf_height = tile_buf_height;
|
|
|
|
|
|
|
|
u8g2->tile_curr_row = 0;
|
2017-12-04 12:11:57 +08:00
|
|
|
|
|
|
|
u8g2->font_decode.is_transparent = 0; /* issue 443 */
|
|
|
|
u8g2->bitmap_transparency = 0;
|
|
|
|
|
2022-12-11 16:24:32 +08:00
|
|
|
u8g2->font_height_mode = 0; /* issue 2046 */
|
2015-11-07 04:07:14 +08:00
|
|
|
u8g2->draw_color = 1;
|
2016-11-27 06:12:55 +08:00
|
|
|
u8g2->is_auto_page_clear = 1;
|
2015-11-07 04:07:14 +08:00
|
|
|
|
|
|
|
u8g2->cb = u8g2_cb;
|
2018-10-28 14:59:04 +08:00
|
|
|
u8g2->cb->update_dimension(u8g2);
|
2018-10-28 04:44:42 +08:00
|
|
|
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
2018-10-28 06:02:15 +08:00
|
|
|
u8g2_SetMaxClipWindow(u8g2); /* assign a clip window and call the update() procedure */
|
|
|
|
#else
|
2018-10-28 14:59:04 +08:00
|
|
|
u8g2->cb->update_page_win(u8g2);
|
2018-10-28 06:02:15 +08:00
|
|
|
#endif
|
2015-11-07 04:07:14 +08:00
|
|
|
|
2017-02-15 02:34:32 +08:00
|
|
|
u8g2_SetFontPosBaseline(u8g2); /* issue 195 */
|
|
|
|
|
2015-11-07 04:07:14 +08:00
|
|
|
#ifdef U8G2_WITH_FONT_ROTATION
|
|
|
|
u8g2->font_decode.dir = 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-05-05 00:56:42 +08:00
|
|
|
/*
|
|
|
|
Usually the display rotation is set initially, but it could be done later also
|
|
|
|
u8g2_cb can be U8G2_R0..U8G2_R3
|
|
|
|
*/
|
|
|
|
void u8g2_SetDisplayRotation(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
|
|
|
|
{
|
|
|
|
u8g2->cb = u8g2_cb;
|
2018-10-28 14:59:04 +08:00
|
|
|
u8g2->cb->update_dimension(u8g2);
|
|
|
|
u8g2->cb->update_page_win(u8g2);
|
2016-05-05 00:56:42 +08:00
|
|
|
}
|
|
|
|
|
2020-01-26 16:47:24 +08:00
|
|
|
/*============================================*/
|
|
|
|
|
|
|
|
void u8g2_SendF(u8g2_t * u8g2, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
va_start(va, fmt);
|
|
|
|
u8x8_cad_vsendf(u8g2_GetU8x8(u8g2), fmt, va);
|
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
2015-11-07 04:07:14 +08:00
|
|
|
|
|
|
|
/*============================================*/
|
|
|
|
/*
|
|
|
|
update dimension:
|
|
|
|
calculate the following variables:
|
|
|
|
u8g2_uint_t buf_x0; left corner of the buffer
|
2016-04-20 11:51:08 +08:00
|
|
|
u8g2_uint_t buf_x1; right corner of the buffer (excluded)
|
2015-11-07 04:07:14 +08:00
|
|
|
u8g2_uint_t buf_y0;
|
2016-04-18 03:40:34 +08:00
|
|
|
u8g2_uint_t buf_y1;
|
2015-11-07 04:07:14 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void u8g2_update_dimension_common(u8g2_t *u8g2)
|
|
|
|
{
|
2018-10-28 04:44:42 +08:00
|
|
|
const u8x8_display_info_t *display_info = u8g2_GetU8x8(u8g2)->display_info;
|
2015-11-07 04:07:14 +08:00
|
|
|
u8g2_uint_t t;
|
|
|
|
|
|
|
|
t = u8g2->tile_buf_height;
|
|
|
|
t *= 8;
|
|
|
|
u8g2->pixel_buf_height = t;
|
|
|
|
|
2018-10-28 04:44:42 +08:00
|
|
|
t = display_info->tile_width;
|
2016-09-30 03:08:36 +08:00
|
|
|
#ifndef U8G2_16BIT
|
|
|
|
if ( t >= 32 )
|
|
|
|
t = 31;
|
|
|
|
#endif
|
2016-01-04 01:30:19 +08:00
|
|
|
t *= 8;
|
2015-11-07 04:07:14 +08:00
|
|
|
u8g2->pixel_buf_width = t;
|
|
|
|
|
|
|
|
t = u8g2->tile_curr_row;
|
|
|
|
t *= 8;
|
|
|
|
u8g2->pixel_curr_row = t;
|
|
|
|
|
|
|
|
t = u8g2->tile_buf_height;
|
|
|
|
/* handle the case, where the buffer is larger than the (remaining) part of the display */
|
2018-10-28 04:44:42 +08:00
|
|
|
if ( t + u8g2->tile_curr_row > display_info->tile_height )
|
|
|
|
t = display_info->tile_height - u8g2->tile_curr_row;
|
2015-11-07 04:07:14 +08:00
|
|
|
t *= 8;
|
|
|
|
|
|
|
|
u8g2->buf_y0 = u8g2->pixel_curr_row;
|
|
|
|
u8g2->buf_y1 = u8g2->buf_y0;
|
|
|
|
u8g2->buf_y1 += t;
|
|
|
|
|
2016-09-30 03:08:36 +08:00
|
|
|
|
|
|
|
#ifdef U8G2_16BIT
|
2018-10-28 04:44:42 +08:00
|
|
|
u8g2->width = display_info->pixel_width;
|
|
|
|
u8g2->height = display_info->pixel_height;
|
2016-09-30 03:08:36 +08:00
|
|
|
#else
|
|
|
|
u8g2->width = 240;
|
2018-10-28 04:44:42 +08:00
|
|
|
if ( display_info->pixel_width <= 240 )
|
|
|
|
u8g2->width = display_info->pixel_width;
|
|
|
|
u8g2->height = display_info->pixel_height;
|
2016-09-30 03:08:36 +08:00
|
|
|
#endif
|
|
|
|
|
2015-11-07 04:07:14 +08:00
|
|
|
}
|
|
|
|
|
2018-10-28 04:44:42 +08:00
|
|
|
/*==========================================================*/
|
|
|
|
/* apply clip window */
|
|
|
|
|
|
|
|
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
|
|
static void u8g2_apply_clip_window(u8g2_t *u8g2)
|
|
|
|
{
|
|
|
|
/* check aganst the current user_??? window */
|
|
|
|
if ( u8g2_IsIntersection(u8g2, u8g2->clip_x0, u8g2->clip_y0, u8g2->clip_x1, u8g2->clip_y1) == 0 )
|
|
|
|
{
|
|
|
|
u8g2->is_page_clip_window_intersection = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
u8g2->is_page_clip_window_intersection = 1;
|
|
|
|
|
|
|
|
if ( u8g2->user_x0 < u8g2->clip_x0 )
|
|
|
|
u8g2->user_x0 = u8g2->clip_x0;
|
|
|
|
if ( u8g2->user_x1 > u8g2->clip_x1 )
|
|
|
|
u8g2->user_x1 = u8g2->clip_x1;
|
|
|
|
if ( u8g2->user_y0 < u8g2->clip_y0 )
|
|
|
|
u8g2->user_y0 = u8g2->clip_y0;
|
|
|
|
if ( u8g2->user_y1 > u8g2->clip_y1 )
|
|
|
|
u8g2->user_y1 = u8g2->clip_y1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
|
|
|
|
|
|
|
|
/*==========================================================*/
|
|
|
|
|
|
|
|
|
2015-11-07 04:07:14 +08:00
|
|
|
void u8g2_update_dimension_r0(u8g2_t *u8g2)
|
|
|
|
{
|
2018-10-28 14:59:04 +08:00
|
|
|
u8g2_update_dimension_common(u8g2);
|
|
|
|
}
|
2015-11-07 04:07:14 +08:00
|
|
|
|
2018-10-28 14:59:04 +08:00
|
|
|
void u8g2_update_page_win_r0(u8g2_t *u8g2)
|
|
|
|
{
|
2015-11-07 04:07:14 +08:00
|
|
|
u8g2->user_x0 = 0;
|
2018-11-02 16:01:40 +08:00
|
|
|
u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */
|
2015-11-07 04:07:14 +08:00
|
|
|
|
|
|
|
u8g2->user_y0 = u8g2->buf_y0;
|
|
|
|
u8g2->user_y1 = u8g2->buf_y1;
|
|
|
|
|
2018-10-28 04:44:42 +08:00
|
|
|
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
|
|
u8g2_apply_clip_window(u8g2);
|
|
|
|
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
|
2015-11-07 04:07:14 +08:00
|
|
|
}
|
|
|
|
|
2018-10-28 14:59:04 +08:00
|
|
|
|
2015-11-07 04:07:14 +08:00
|
|
|
void u8g2_update_dimension_r1(u8g2_t *u8g2)
|
|
|
|
{
|
|
|
|
u8g2_update_dimension_common(u8g2);
|
|
|
|
|
2016-01-04 01:30:19 +08:00
|
|
|
u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_width;
|
|
|
|
u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_height;
|
|
|
|
|
2018-10-28 14:59:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void u8g2_update_page_win_r1(u8g2_t *u8g2)
|
|
|
|
{
|
2015-11-07 04:07:14 +08:00
|
|
|
u8g2->user_x0 = u8g2->buf_y0;
|
|
|
|
u8g2->user_x1 = u8g2->buf_y1;
|
|
|
|
|
|
|
|
u8g2->user_y0 = 0;
|
2016-05-03 03:17:46 +08:00
|
|
|
u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (which is the real pixel width) */
|
2015-11-07 04:07:14 +08:00
|
|
|
|
2018-10-28 04:44:42 +08:00
|
|
|
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
|
|
u8g2_apply_clip_window(u8g2);
|
|
|
|
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
|
2015-11-07 04:07:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void u8g2_update_dimension_r2(u8g2_t *u8g2)
|
|
|
|
{
|
|
|
|
u8g2_update_dimension_common(u8g2);
|
2018-10-28 14:59:04 +08:00
|
|
|
}
|
2015-11-07 04:07:14 +08:00
|
|
|
|
2018-10-28 14:59:04 +08:00
|
|
|
void u8g2_update_page_win_r2(u8g2_t *u8g2)
|
|
|
|
{
|
2015-11-07 04:07:14 +08:00
|
|
|
u8g2->user_x0 = 0;
|
2016-05-02 00:01:45 +08:00
|
|
|
u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */
|
2015-11-07 04:07:14 +08:00
|
|
|
|
2018-02-19 02:43:40 +08:00
|
|
|
/* there are ases where the height is not a multiple of 8. */
|
|
|
|
/* in such a case u8g2->buf_y1 might be heigher than u8g2->height */
|
|
|
|
u8g2->user_y0 = 0;
|
|
|
|
if ( u8g2->height >= u8g2->buf_y1 )
|
|
|
|
u8g2->user_y0 = u8g2->height - u8g2->buf_y1;
|
2015-11-07 04:07:14 +08:00
|
|
|
u8g2->user_y1 = u8g2->height - u8g2->buf_y0;
|
2016-04-18 03:40:34 +08:00
|
|
|
|
2018-10-28 04:44:42 +08:00
|
|
|
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
|
|
u8g2_apply_clip_window(u8g2);
|
|
|
|
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
|
2015-11-07 04:07:14 +08:00
|
|
|
}
|
|
|
|
|
2018-10-28 14:59:04 +08:00
|
|
|
|
2015-11-07 04:07:14 +08:00
|
|
|
void u8g2_update_dimension_r3(u8g2_t *u8g2)
|
|
|
|
{
|
|
|
|
u8g2_update_dimension_common(u8g2);
|
|
|
|
|
2016-01-04 01:30:19 +08:00
|
|
|
u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_width;
|
|
|
|
u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_height;
|
2015-11-07 04:07:14 +08:00
|
|
|
|
2018-10-28 14:59:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void u8g2_update_page_win_r3(u8g2_t *u8g2)
|
|
|
|
{
|
2018-02-19 02:43:40 +08:00
|
|
|
/* there are ases where the height is not a multiple of 8. */
|
|
|
|
/* in such a case u8g2->buf_y1 might be heigher than u8g2->width */
|
|
|
|
u8g2->user_x0 = 0;
|
|
|
|
if ( u8g2->width >= u8g2->buf_y1 )
|
|
|
|
u8g2->user_x0 = u8g2->width - u8g2->buf_y1;
|
2016-01-04 01:30:19 +08:00
|
|
|
u8g2->user_x1 = u8g2->width - u8g2->buf_y0;
|
2015-11-07 04:07:14 +08:00
|
|
|
|
|
|
|
u8g2->user_y0 = 0;
|
2016-05-03 03:17:46 +08:00
|
|
|
u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (pixel_width) */
|
2016-04-18 03:40:34 +08:00
|
|
|
|
2018-10-28 04:44:42 +08:00
|
|
|
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
|
|
|
|
u8g2_apply_clip_window(u8g2);
|
|
|
|
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
|
2015-11-07 04:07:14 +08:00
|
|
|
}
|
|
|
|
|
2018-10-28 14:59:04 +08:00
|
|
|
|
2015-11-07 04:07:14 +08:00
|
|
|
/*============================================*/
|
2018-10-27 23:29:10 +08:00
|
|
|
extern void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir);
|
2015-11-07 04:07:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
void u8g2_draw_l90_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
|
|
{
|
2018-10-27 23:29:10 +08:00
|
|
|
#ifdef __unix
|
|
|
|
assert( dir <= 1 );
|
|
|
|
#endif
|
|
|
|
u8g2_draw_hv_line_2dir(u8g2, x, y, len, dir);
|
2015-11-07 04:07:14 +08:00
|
|
|
}
|
|
|
|
|
2016-10-16 14:57:47 +08:00
|
|
|
void u8g2_draw_l90_mirrorr_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
|
|
{
|
|
|
|
u8g2_uint_t xx;
|
|
|
|
xx = u8g2->width;
|
|
|
|
xx -= x;
|
|
|
|
if ( (dir & 1) == 0 )
|
|
|
|
{
|
|
|
|
xx -= len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xx--;
|
|
|
|
}
|
2018-10-27 23:29:10 +08:00
|
|
|
u8g2_draw_hv_line_2dir(u8g2, xx, y, len, dir);
|
2016-10-16 14:57:47 +08:00
|
|
|
}
|
|
|
|
|
2021-04-19 00:25:41 +08:00
|
|
|
void u8g2_draw_mirror_vertical_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
|
|
{
|
|
|
|
u8g2_uint_t yy;
|
|
|
|
yy = u8g2->height;
|
|
|
|
yy -= y;
|
2021-04-19 10:43:07 +08:00
|
|
|
if ( (dir & 1) == 1 )
|
2021-04-19 00:25:41 +08:00
|
|
|
{
|
|
|
|
yy -= len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
yy--;
|
|
|
|
}
|
|
|
|
u8g2_draw_hv_line_2dir(u8g2, x, yy, len, dir);
|
|
|
|
}
|
|
|
|
|
2018-10-27 23:29:10 +08:00
|
|
|
/* dir = 0 or 1 */
|
2015-11-07 04:07:14 +08:00
|
|
|
void u8g2_draw_l90_r1(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
|
|
{
|
|
|
|
u8g2_uint_t xx, yy;
|
2018-10-27 23:29:10 +08:00
|
|
|
|
|
|
|
#ifdef __unix
|
|
|
|
assert( dir <= 1 );
|
|
|
|
#endif
|
2015-11-07 04:07:14 +08:00
|
|
|
|
|
|
|
yy = x;
|
|
|
|
|
|
|
|
xx = u8g2->height;
|
|
|
|
xx -= y;
|
|
|
|
xx--;
|
|
|
|
|
|
|
|
dir ++;
|
2018-10-27 23:29:10 +08:00
|
|
|
if ( dir == 2 )
|
|
|
|
{
|
|
|
|
xx -= len;
|
|
|
|
xx++;
|
|
|
|
dir = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir);
|
2015-11-07 04:07:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void u8g2_draw_l90_r2(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
|
|
{
|
|
|
|
u8g2_uint_t xx, yy;
|
|
|
|
|
2018-10-27 23:29:10 +08:00
|
|
|
/*
|
2015-11-07 04:07:14 +08:00
|
|
|
yy = u8g2->height;
|
|
|
|
yy -= y;
|
|
|
|
yy--;
|
|
|
|
|
|
|
|
xx = u8g2->width;
|
|
|
|
xx -= x;
|
|
|
|
xx--;
|
|
|
|
|
2018-10-27 23:29:10 +08:00
|
|
|
if ( dir == 0 )
|
|
|
|
{
|
|
|
|
xx -= len;
|
|
|
|
xx++;
|
|
|
|
}
|
|
|
|
else if ( dir == 1 )
|
|
|
|
{
|
|
|
|
yy -= len;
|
|
|
|
yy++;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
yy = u8g2->height;
|
|
|
|
yy -= y;
|
|
|
|
|
|
|
|
xx = u8g2->width;
|
|
|
|
xx -= x;
|
|
|
|
|
|
|
|
if ( dir == 0 )
|
|
|
|
{
|
|
|
|
yy--;
|
|
|
|
xx -= len;
|
|
|
|
}
|
|
|
|
else if ( dir == 1 )
|
|
|
|
{
|
|
|
|
xx--;
|
|
|
|
yy -= len;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir);
|
2015-11-07 04:07:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void u8g2_draw_l90_r3(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
|
|
|
|
{
|
|
|
|
u8g2_uint_t xx, yy;
|
|
|
|
|
|
|
|
xx = y;
|
|
|
|
|
2016-01-04 01:30:19 +08:00
|
|
|
yy = u8g2->width;
|
2015-11-07 04:07:14 +08:00
|
|
|
yy -= x;
|
|
|
|
|
2018-10-27 23:29:10 +08:00
|
|
|
if ( dir == 0 )
|
|
|
|
{
|
|
|
|
yy--;
|
|
|
|
yy -= len;
|
|
|
|
yy++;
|
|
|
|
dir = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
yy--;
|
|
|
|
dir = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir);
|
2015-11-07 04:07:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*============================================*/
|
2018-10-28 14:59:04 +08:00
|
|
|
const u8g2_cb_t u8g2_cb_r0 = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_l90_r0 };
|
|
|
|
const u8g2_cb_t u8g2_cb_r1 = { u8g2_update_dimension_r1, u8g2_update_page_win_r1, u8g2_draw_l90_r1 };
|
|
|
|
const u8g2_cb_t u8g2_cb_r2 = { u8g2_update_dimension_r2, u8g2_update_page_win_r2, u8g2_draw_l90_r2 };
|
|
|
|
const u8g2_cb_t u8g2_cb_r3 = { u8g2_update_dimension_r3, u8g2_update_page_win_r3, u8g2_draw_l90_r3 };
|
2015-11-07 04:07:14 +08:00
|
|
|
|
2018-10-28 14:59:04 +08:00
|
|
|
const u8g2_cb_t u8g2_cb_mirror = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_l90_mirrorr_r0 };
|
2021-04-19 00:25:41 +08:00
|
|
|
const u8g2_cb_t u8g2_cb_mirror_vertical = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_mirror_vertical_r0 };
|
2015-11-07 04:07:14 +08:00
|
|
|
|
2018-02-17 23:27:06 +08:00
|
|
|
/*============================================*/
|
|
|
|
/* setup for the null device */
|
|
|
|
|
|
|
|
/* setup for the null (empty) device */
|
|
|
|
void u8g2_Setup_null(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
|
|
|
|
{
|
|
|
|
static uint8_t buf[8];
|
|
|
|
u8g2_SetupDisplay(u8g2, u8x8_d_null_cb, u8x8_cad_empty, byte_cb, gpio_and_delay_cb);
|
|
|
|
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_ll_hvline_vertical_top_lsb, rotation);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-07 04:07:14 +08:00
|
|
|
|
|
|
|
|