Displays distance to start location on OLED screen.

Dependencies:   mbed

Committer:
iforce2d
Date:
Wed Mar 07 12:49:14 2018 +0000
Revision:
0:972874f31c98
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
iforce2d 0:972874f31c98 1 /*
iforce2d 0:972874f31c98 2
iforce2d 0:972874f31c98 3 u8g_rot.c
iforce2d 0:972874f31c98 4
iforce2d 0:972874f31c98 5 Universal 8bit Graphics Library
iforce2d 0:972874f31c98 6
iforce2d 0:972874f31c98 7 Copyright (c) 2011, olikraus@gmail.com
iforce2d 0:972874f31c98 8 All rights reserved.
iforce2d 0:972874f31c98 9
iforce2d 0:972874f31c98 10 Redistribution and use in source and binary forms, with or without modification,
iforce2d 0:972874f31c98 11 are permitted provided that the following conditions are met:
iforce2d 0:972874f31c98 12
iforce2d 0:972874f31c98 13 * Redistributions of source code must retain the above copyright notice, this list
iforce2d 0:972874f31c98 14 of conditions and the following disclaimer.
iforce2d 0:972874f31c98 15
iforce2d 0:972874f31c98 16 * Redistributions in binary form must reproduce the above copyright notice, this
iforce2d 0:972874f31c98 17 list of conditions and the following disclaimer in the documentation and/or other
iforce2d 0:972874f31c98 18 materials provided with the distribution.
iforce2d 0:972874f31c98 19
iforce2d 0:972874f31c98 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
iforce2d 0:972874f31c98 21 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
iforce2d 0:972874f31c98 22 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
iforce2d 0:972874f31c98 23 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
iforce2d 0:972874f31c98 24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
iforce2d 0:972874f31c98 25 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
iforce2d 0:972874f31c98 26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
iforce2d 0:972874f31c98 27 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
iforce2d 0:972874f31c98 28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
iforce2d 0:972874f31c98 29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
iforce2d 0:972874f31c98 30 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
iforce2d 0:972874f31c98 31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
iforce2d 0:972874f31c98 32 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
iforce2d 0:972874f31c98 33
iforce2d 0:972874f31c98 34
iforce2d 0:972874f31c98 35 */
iforce2d 0:972874f31c98 36
iforce2d 0:972874f31c98 37 #include "u8g.h"
iforce2d 0:972874f31c98 38
iforce2d 0:972874f31c98 39 uint8_t u8g_dev_rot90_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
iforce2d 0:972874f31c98 40 uint8_t u8g_dev_rot180_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
iforce2d 0:972874f31c98 41 uint8_t u8g_dev_rot270_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
iforce2d 0:972874f31c98 42
iforce2d 0:972874f31c98 43 u8g_dev_t u8g_dev_rot = { u8g_dev_rot90_fn, NULL, NULL };
iforce2d 0:972874f31c98 44
iforce2d 0:972874f31c98 45
iforce2d 0:972874f31c98 46 void u8g_UndoRotation(u8g_t *u8g)
iforce2d 0:972874f31c98 47 {
iforce2d 0:972874f31c98 48 if ( u8g->dev != &u8g_dev_rot )
iforce2d 0:972874f31c98 49 return;
iforce2d 0:972874f31c98 50 u8g->dev = u8g_dev_rot.dev_mem;
iforce2d 0:972874f31c98 51 u8g_UpdateDimension(u8g);
iforce2d 0:972874f31c98 52 }
iforce2d 0:972874f31c98 53
iforce2d 0:972874f31c98 54 void u8g_SetRot90(u8g_t *u8g)
iforce2d 0:972874f31c98 55 {
iforce2d 0:972874f31c98 56 if ( u8g->dev != &u8g_dev_rot )
iforce2d 0:972874f31c98 57 {
iforce2d 0:972874f31c98 58 u8g_dev_rot.dev_mem = u8g->dev;
iforce2d 0:972874f31c98 59 u8g->dev = &u8g_dev_rot;
iforce2d 0:972874f31c98 60 }
iforce2d 0:972874f31c98 61 u8g_dev_rot.dev_fn = u8g_dev_rot90_fn;
iforce2d 0:972874f31c98 62 u8g_UpdateDimension(u8g);
iforce2d 0:972874f31c98 63 }
iforce2d 0:972874f31c98 64
iforce2d 0:972874f31c98 65 void u8g_SetRot180(u8g_t *u8g)
iforce2d 0:972874f31c98 66 {
iforce2d 0:972874f31c98 67 if ( u8g->dev != &u8g_dev_rot )
iforce2d 0:972874f31c98 68 {
iforce2d 0:972874f31c98 69 u8g_dev_rot.dev_mem = u8g->dev;
iforce2d 0:972874f31c98 70 u8g->dev = &u8g_dev_rot;
iforce2d 0:972874f31c98 71 }
iforce2d 0:972874f31c98 72 u8g_dev_rot.dev_fn = u8g_dev_rot180_fn;
iforce2d 0:972874f31c98 73 u8g_UpdateDimension(u8g);
iforce2d 0:972874f31c98 74 }
iforce2d 0:972874f31c98 75
iforce2d 0:972874f31c98 76 void u8g_SetRot270(u8g_t *u8g)
iforce2d 0:972874f31c98 77 {
iforce2d 0:972874f31c98 78 if ( u8g->dev != &u8g_dev_rot )
iforce2d 0:972874f31c98 79 {
iforce2d 0:972874f31c98 80 u8g_dev_rot.dev_mem = u8g->dev;
iforce2d 0:972874f31c98 81 u8g->dev = &u8g_dev_rot;
iforce2d 0:972874f31c98 82 }
iforce2d 0:972874f31c98 83 u8g_dev_rot.dev_fn = u8g_dev_rot270_fn;
iforce2d 0:972874f31c98 84 u8g_UpdateDimension(u8g);
iforce2d 0:972874f31c98 85 }
iforce2d 0:972874f31c98 86
iforce2d 0:972874f31c98 87 uint8_t u8g_dev_rot90_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
iforce2d 0:972874f31c98 88 {
iforce2d 0:972874f31c98 89 u8g_dev_t *rotation_chain = (u8g_dev_t *)(dev->dev_mem);
iforce2d 0:972874f31c98 90 switch(msg)
iforce2d 0:972874f31c98 91 {
iforce2d 0:972874f31c98 92 default:
iforce2d 0:972874f31c98 93 /*
iforce2d 0:972874f31c98 94 case U8G_DEV_MSG_INIT:
iforce2d 0:972874f31c98 95 case U8G_DEV_MSG_STOP:
iforce2d 0:972874f31c98 96 case U8G_DEV_MSG_PAGE_FIRST:
iforce2d 0:972874f31c98 97 case U8G_DEV_MSG_PAGE_NEXT:
iforce2d 0:972874f31c98 98 case U8G_DEV_MSG_SET_COLOR_ENTRY:
iforce2d 0:972874f31c98 99 case U8G_DEV_MSG_SET_XY_CB:
iforce2d 0:972874f31c98 100 */
iforce2d 0:972874f31c98 101 return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 102 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
iforce2d 0:972874f31c98 103 case U8G_DEV_MSG_IS_BBX_INTERSECTION:
iforce2d 0:972874f31c98 104 {
iforce2d 0:972874f31c98 105 u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
iforce2d 0:972874f31c98 106 u8g_uint_t x, y, tmp;
iforce2d 0:972874f31c98 107
iforce2d 0:972874f31c98 108 /* transform the reference point */
iforce2d 0:972874f31c98 109 y = bbx->x;
iforce2d 0:972874f31c98 110 x = u8g->height;
iforce2d 0:972874f31c98 111 /* x = u8g_GetWidthLL(u8g, rotation_chain); */
iforce2d 0:972874f31c98 112 x -= bbx->y;
iforce2d 0:972874f31c98 113 x--;
iforce2d 0:972874f31c98 114
iforce2d 0:972874f31c98 115 /* adjust point to be the uppler left corner again */
iforce2d 0:972874f31c98 116 x -= bbx->h;
iforce2d 0:972874f31c98 117 x++;
iforce2d 0:972874f31c98 118
iforce2d 0:972874f31c98 119 /* swap box dimensions */
iforce2d 0:972874f31c98 120 tmp = bbx->w;
iforce2d 0:972874f31c98 121 bbx->w = bbx->h;
iforce2d 0:972874f31c98 122 bbx->h = tmp;
iforce2d 0:972874f31c98 123
iforce2d 0:972874f31c98 124 /* store x,y */
iforce2d 0:972874f31c98 125 bbx->x = x;
iforce2d 0:972874f31c98 126 bbx->y = y;
iforce2d 0:972874f31c98 127 }
iforce2d 0:972874f31c98 128 return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 129 #endif /* U8G_DEV_MSG_IS_BBX_INTERSECTION */
iforce2d 0:972874f31c98 130 case U8G_DEV_MSG_GET_PAGE_BOX:
iforce2d 0:972874f31c98 131 /* get page size from next device in the chain */
iforce2d 0:972874f31c98 132 u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 133 //printf("pre x: %3d..%3d y: %3d..%3d ", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
iforce2d 0:972874f31c98 134 {
iforce2d 0:972874f31c98 135 u8g_box_t new_box;
iforce2d 0:972874f31c98 136 //new_box.x0 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y1 - 1;
iforce2d 0:972874f31c98 137 //new_box.x1 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y0 - 1;
iforce2d 0:972874f31c98 138
iforce2d 0:972874f31c98 139 new_box.x0 = ((u8g_box_t *)arg)->y0;
iforce2d 0:972874f31c98 140 new_box.x1 = ((u8g_box_t *)arg)->y1;
iforce2d 0:972874f31c98 141 new_box.y0 = ((u8g_box_t *)arg)->x0;
iforce2d 0:972874f31c98 142 new_box.y1 = ((u8g_box_t *)arg)->x1;
iforce2d 0:972874f31c98 143 *((u8g_box_t *)arg) = new_box;
iforce2d 0:972874f31c98 144 //printf("post x: %3d..%3d y: %3d..%3d\n", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
iforce2d 0:972874f31c98 145 }
iforce2d 0:972874f31c98 146 break;
iforce2d 0:972874f31c98 147 case U8G_DEV_MSG_GET_WIDTH:
iforce2d 0:972874f31c98 148 *((u8g_uint_t *)arg) = u8g_GetHeightLL(u8g,rotation_chain);
iforce2d 0:972874f31c98 149 break;
iforce2d 0:972874f31c98 150 case U8G_DEV_MSG_GET_HEIGHT:
iforce2d 0:972874f31c98 151 *((u8g_uint_t *)arg) = u8g_GetWidthLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 152 break;
iforce2d 0:972874f31c98 153 case U8G_DEV_MSG_SET_PIXEL:
iforce2d 0:972874f31c98 154 case U8G_DEV_MSG_SET_TPIXEL:
iforce2d 0:972874f31c98 155 {
iforce2d 0:972874f31c98 156 u8g_uint_t x, y;
iforce2d 0:972874f31c98 157 y = ((u8g_dev_arg_pixel_t *)arg)->x;
iforce2d 0:972874f31c98 158 x = u8g_GetWidthLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 159 x -= ((u8g_dev_arg_pixel_t *)arg)->y;
iforce2d 0:972874f31c98 160 x--;
iforce2d 0:972874f31c98 161 ((u8g_dev_arg_pixel_t *)arg)->x = x;
iforce2d 0:972874f31c98 162 ((u8g_dev_arg_pixel_t *)arg)->y = y;
iforce2d 0:972874f31c98 163 }
iforce2d 0:972874f31c98 164 u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 165 break;
iforce2d 0:972874f31c98 166 case U8G_DEV_MSG_SET_8PIXEL:
iforce2d 0:972874f31c98 167 case U8G_DEV_MSG_SET_4TPIXEL:
iforce2d 0:972874f31c98 168 {
iforce2d 0:972874f31c98 169 u8g_uint_t x, y;
iforce2d 0:972874f31c98 170 //uint16_t x,y;
iforce2d 0:972874f31c98 171 y = ((u8g_dev_arg_pixel_t *)arg)->x;
iforce2d 0:972874f31c98 172 x = u8g_GetWidthLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 173 x -= ((u8g_dev_arg_pixel_t *)arg)->y;
iforce2d 0:972874f31c98 174 x--;
iforce2d 0:972874f31c98 175 ((u8g_dev_arg_pixel_t *)arg)->x = x;
iforce2d 0:972874f31c98 176 ((u8g_dev_arg_pixel_t *)arg)->y = y;
iforce2d 0:972874f31c98 177 ((u8g_dev_arg_pixel_t *)arg)->dir+=1;
iforce2d 0:972874f31c98 178 ((u8g_dev_arg_pixel_t *)arg)->dir &= 3;
iforce2d 0:972874f31c98 179 }
iforce2d 0:972874f31c98 180 u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 181 break;
iforce2d 0:972874f31c98 182 }
iforce2d 0:972874f31c98 183 return 1;
iforce2d 0:972874f31c98 184 }
iforce2d 0:972874f31c98 185
iforce2d 0:972874f31c98 186 uint8_t u8g_dev_rot180_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
iforce2d 0:972874f31c98 187 {
iforce2d 0:972874f31c98 188 u8g_dev_t *rotation_chain = (u8g_dev_t *)(dev->dev_mem);
iforce2d 0:972874f31c98 189 switch(msg)
iforce2d 0:972874f31c98 190 {
iforce2d 0:972874f31c98 191 default:
iforce2d 0:972874f31c98 192 /*
iforce2d 0:972874f31c98 193 case U8G_DEV_MSG_INIT:
iforce2d 0:972874f31c98 194 case U8G_DEV_MSG_STOP:
iforce2d 0:972874f31c98 195 case U8G_DEV_MSG_PAGE_FIRST:
iforce2d 0:972874f31c98 196 case U8G_DEV_MSG_PAGE_NEXT:
iforce2d 0:972874f31c98 197 case U8G_DEV_MSG_SET_COLOR_ENTRY:
iforce2d 0:972874f31c98 198 case U8G_DEV_MSG_SET_XY_CB:
iforce2d 0:972874f31c98 199 */
iforce2d 0:972874f31c98 200 return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 201 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
iforce2d 0:972874f31c98 202 case U8G_DEV_MSG_IS_BBX_INTERSECTION:
iforce2d 0:972874f31c98 203 {
iforce2d 0:972874f31c98 204 u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
iforce2d 0:972874f31c98 205 u8g_uint_t x, y;
iforce2d 0:972874f31c98 206
iforce2d 0:972874f31c98 207 /* transform the reference point */
iforce2d 0:972874f31c98 208 //y = u8g_GetHeightLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 209 y = u8g->height;
iforce2d 0:972874f31c98 210 y -= bbx->y;
iforce2d 0:972874f31c98 211 y--;
iforce2d 0:972874f31c98 212
iforce2d 0:972874f31c98 213 //x = u8g_GetWidthLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 214 x = u8g->width;
iforce2d 0:972874f31c98 215 x -= bbx->x;
iforce2d 0:972874f31c98 216 x--;
iforce2d 0:972874f31c98 217
iforce2d 0:972874f31c98 218 /* adjust point to be the uppler left corner again */
iforce2d 0:972874f31c98 219 y -= bbx->h;
iforce2d 0:972874f31c98 220 y++;
iforce2d 0:972874f31c98 221
iforce2d 0:972874f31c98 222 x -= bbx->w;
iforce2d 0:972874f31c98 223 x++;
iforce2d 0:972874f31c98 224
iforce2d 0:972874f31c98 225 /* store x,y */
iforce2d 0:972874f31c98 226 bbx->x = x;
iforce2d 0:972874f31c98 227 bbx->y = y;
iforce2d 0:972874f31c98 228 }
iforce2d 0:972874f31c98 229 return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 230 #endif /* U8G_DEV_MSG_IS_BBX_INTERSECTION */
iforce2d 0:972874f31c98 231 case U8G_DEV_MSG_GET_PAGE_BOX:
iforce2d 0:972874f31c98 232 /* get page size from next device in the chain */
iforce2d 0:972874f31c98 233 u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 234 //printf("pre x: %3d..%3d y: %3d..%3d ", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
iforce2d 0:972874f31c98 235 {
iforce2d 0:972874f31c98 236 u8g_box_t new_box;
iforce2d 0:972874f31c98 237
iforce2d 0:972874f31c98 238 new_box.x0 = u8g_GetWidthLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->x1 - 1;
iforce2d 0:972874f31c98 239 new_box.x1 = u8g_GetWidthLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->x0 - 1;
iforce2d 0:972874f31c98 240 new_box.y0 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y1 - 1;
iforce2d 0:972874f31c98 241 new_box.y1 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y0 - 1;
iforce2d 0:972874f31c98 242 *((u8g_box_t *)arg) = new_box;
iforce2d 0:972874f31c98 243 //printf("post x: %3d..%3d y: %3d..%3d\n", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
iforce2d 0:972874f31c98 244 }
iforce2d 0:972874f31c98 245 break;
iforce2d 0:972874f31c98 246 case U8G_DEV_MSG_GET_WIDTH:
iforce2d 0:972874f31c98 247 *((u8g_uint_t *)arg) = u8g_GetWidthLL(u8g,rotation_chain);
iforce2d 0:972874f31c98 248 break;
iforce2d 0:972874f31c98 249 case U8G_DEV_MSG_GET_HEIGHT:
iforce2d 0:972874f31c98 250 *((u8g_uint_t *)arg) = u8g_GetHeightLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 251 break;
iforce2d 0:972874f31c98 252 case U8G_DEV_MSG_SET_PIXEL:
iforce2d 0:972874f31c98 253 case U8G_DEV_MSG_SET_TPIXEL:
iforce2d 0:972874f31c98 254 {
iforce2d 0:972874f31c98 255 u8g_uint_t x, y;
iforce2d 0:972874f31c98 256
iforce2d 0:972874f31c98 257 y = u8g_GetHeightLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 258 y -= ((u8g_dev_arg_pixel_t *)arg)->y;
iforce2d 0:972874f31c98 259 y--;
iforce2d 0:972874f31c98 260
iforce2d 0:972874f31c98 261 x = u8g_GetWidthLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 262 x -= ((u8g_dev_arg_pixel_t *)arg)->x;
iforce2d 0:972874f31c98 263 x--;
iforce2d 0:972874f31c98 264
iforce2d 0:972874f31c98 265 ((u8g_dev_arg_pixel_t *)arg)->x = x;
iforce2d 0:972874f31c98 266 ((u8g_dev_arg_pixel_t *)arg)->y = y;
iforce2d 0:972874f31c98 267 }
iforce2d 0:972874f31c98 268 u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 269 break;
iforce2d 0:972874f31c98 270 case U8G_DEV_MSG_SET_8PIXEL:
iforce2d 0:972874f31c98 271 case U8G_DEV_MSG_SET_4TPIXEL:
iforce2d 0:972874f31c98 272 {
iforce2d 0:972874f31c98 273 u8g_uint_t x, y;
iforce2d 0:972874f31c98 274
iforce2d 0:972874f31c98 275 y = u8g_GetHeightLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 276 y -= ((u8g_dev_arg_pixel_t *)arg)->y;
iforce2d 0:972874f31c98 277 y--;
iforce2d 0:972874f31c98 278
iforce2d 0:972874f31c98 279 x = u8g_GetWidthLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 280 x -= ((u8g_dev_arg_pixel_t *)arg)->x;
iforce2d 0:972874f31c98 281 x--;
iforce2d 0:972874f31c98 282
iforce2d 0:972874f31c98 283 ((u8g_dev_arg_pixel_t *)arg)->x = x;
iforce2d 0:972874f31c98 284 ((u8g_dev_arg_pixel_t *)arg)->y = y;
iforce2d 0:972874f31c98 285 ((u8g_dev_arg_pixel_t *)arg)->dir+=2;
iforce2d 0:972874f31c98 286 ((u8g_dev_arg_pixel_t *)arg)->dir &= 3;
iforce2d 0:972874f31c98 287 }
iforce2d 0:972874f31c98 288 u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 289 break;
iforce2d 0:972874f31c98 290 }
iforce2d 0:972874f31c98 291 return 1;
iforce2d 0:972874f31c98 292 }
iforce2d 0:972874f31c98 293
iforce2d 0:972874f31c98 294 uint8_t u8g_dev_rot270_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
iforce2d 0:972874f31c98 295 {
iforce2d 0:972874f31c98 296 u8g_dev_t *rotation_chain = (u8g_dev_t *)(dev->dev_mem);
iforce2d 0:972874f31c98 297 switch(msg)
iforce2d 0:972874f31c98 298 {
iforce2d 0:972874f31c98 299 default:
iforce2d 0:972874f31c98 300 /*
iforce2d 0:972874f31c98 301 case U8G_DEV_MSG_INIT:
iforce2d 0:972874f31c98 302 case U8G_DEV_MSG_STOP:
iforce2d 0:972874f31c98 303 case U8G_DEV_MSG_PAGE_FIRST:
iforce2d 0:972874f31c98 304 case U8G_DEV_MSG_PAGE_NEXT:
iforce2d 0:972874f31c98 305 case U8G_DEV_MSG_SET_COLOR_ENTRY:
iforce2d 0:972874f31c98 306 case U8G_DEV_MSG_SET_XY_CB:
iforce2d 0:972874f31c98 307 */
iforce2d 0:972874f31c98 308 return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 309 #ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
iforce2d 0:972874f31c98 310 case U8G_DEV_MSG_IS_BBX_INTERSECTION:
iforce2d 0:972874f31c98 311 {
iforce2d 0:972874f31c98 312 u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
iforce2d 0:972874f31c98 313 u8g_uint_t x, y, tmp;
iforce2d 0:972874f31c98 314
iforce2d 0:972874f31c98 315 /* transform the reference point */
iforce2d 0:972874f31c98 316 x = bbx->y;
iforce2d 0:972874f31c98 317
iforce2d 0:972874f31c98 318 y = u8g->width;
iforce2d 0:972874f31c98 319 /* y = u8g_GetHeightLL(u8g, rotation_chain); */
iforce2d 0:972874f31c98 320 y -= bbx->x;
iforce2d 0:972874f31c98 321 y--;
iforce2d 0:972874f31c98 322
iforce2d 0:972874f31c98 323 /* adjust point to be the uppler left corner again */
iforce2d 0:972874f31c98 324 y -= bbx->w;
iforce2d 0:972874f31c98 325 y++;
iforce2d 0:972874f31c98 326
iforce2d 0:972874f31c98 327 /* swap box dimensions */
iforce2d 0:972874f31c98 328 tmp = bbx->w;
iforce2d 0:972874f31c98 329 bbx->w = bbx->h;
iforce2d 0:972874f31c98 330 bbx->h = tmp;
iforce2d 0:972874f31c98 331
iforce2d 0:972874f31c98 332 /* store x,y */
iforce2d 0:972874f31c98 333 bbx->x = x;
iforce2d 0:972874f31c98 334 bbx->y = y;
iforce2d 0:972874f31c98 335 }
iforce2d 0:972874f31c98 336 return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 337 #endif /* U8G_DEV_MSG_IS_BBX_INTERSECTION */
iforce2d 0:972874f31c98 338 case U8G_DEV_MSG_GET_PAGE_BOX:
iforce2d 0:972874f31c98 339 /* get page size from next device in the chain */
iforce2d 0:972874f31c98 340 u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 341 //printf("pre x: %3d..%3d y: %3d..%3d ", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
iforce2d 0:972874f31c98 342 {
iforce2d 0:972874f31c98 343 u8g_box_t new_box;
iforce2d 0:972874f31c98 344
iforce2d 0:972874f31c98 345 new_box.x0 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y1 - 1;
iforce2d 0:972874f31c98 346 new_box.x1 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y0 - 1;
iforce2d 0:972874f31c98 347 new_box.y0 = u8g_GetWidthLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->x1 - 1;
iforce2d 0:972874f31c98 348 new_box.y1 = u8g_GetWidthLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->x0 - 1;
iforce2d 0:972874f31c98 349 *((u8g_box_t *)arg) = new_box;
iforce2d 0:972874f31c98 350 //printf("post x: %3d..%3d y: %3d..%3d\n", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
iforce2d 0:972874f31c98 351 }
iforce2d 0:972874f31c98 352 break;
iforce2d 0:972874f31c98 353 case U8G_DEV_MSG_GET_WIDTH:
iforce2d 0:972874f31c98 354 *((u8g_uint_t *)arg) = u8g_GetHeightLL(u8g,rotation_chain);
iforce2d 0:972874f31c98 355 break;
iforce2d 0:972874f31c98 356 case U8G_DEV_MSG_GET_HEIGHT:
iforce2d 0:972874f31c98 357 *((u8g_uint_t *)arg) = u8g_GetWidthLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 358 break;
iforce2d 0:972874f31c98 359 case U8G_DEV_MSG_SET_PIXEL:
iforce2d 0:972874f31c98 360 case U8G_DEV_MSG_SET_TPIXEL:
iforce2d 0:972874f31c98 361 {
iforce2d 0:972874f31c98 362 u8g_uint_t x, y;
iforce2d 0:972874f31c98 363 x = ((u8g_dev_arg_pixel_t *)arg)->y;
iforce2d 0:972874f31c98 364
iforce2d 0:972874f31c98 365 y = u8g_GetHeightLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 366 y -= ((u8g_dev_arg_pixel_t *)arg)->x;
iforce2d 0:972874f31c98 367 y--;
iforce2d 0:972874f31c98 368
iforce2d 0:972874f31c98 369 /*
iforce2d 0:972874f31c98 370 x = u8g_GetWidthLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 371 x -= ((u8g_dev_arg_pixel_t *)arg)->y;
iforce2d 0:972874f31c98 372 x--;
iforce2d 0:972874f31c98 373 */
iforce2d 0:972874f31c98 374 ((u8g_dev_arg_pixel_t *)arg)->x = x;
iforce2d 0:972874f31c98 375 ((u8g_dev_arg_pixel_t *)arg)->y = y;
iforce2d 0:972874f31c98 376 }
iforce2d 0:972874f31c98 377 u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 378 break;
iforce2d 0:972874f31c98 379 case U8G_DEV_MSG_SET_8PIXEL:
iforce2d 0:972874f31c98 380 case U8G_DEV_MSG_SET_4TPIXEL:
iforce2d 0:972874f31c98 381 {
iforce2d 0:972874f31c98 382 u8g_uint_t x, y;
iforce2d 0:972874f31c98 383 x = ((u8g_dev_arg_pixel_t *)arg)->y;
iforce2d 0:972874f31c98 384
iforce2d 0:972874f31c98 385 y = u8g_GetHeightLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 386 y -= ((u8g_dev_arg_pixel_t *)arg)->x;
iforce2d 0:972874f31c98 387 y--;
iforce2d 0:972874f31c98 388
iforce2d 0:972874f31c98 389 /*
iforce2d 0:972874f31c98 390 x = u8g_GetWidthLL(u8g, rotation_chain);
iforce2d 0:972874f31c98 391 x -= ((u8g_dev_arg_pixel_t *)arg)->y;
iforce2d 0:972874f31c98 392 x--;
iforce2d 0:972874f31c98 393 */
iforce2d 0:972874f31c98 394 ((u8g_dev_arg_pixel_t *)arg)->x = x;
iforce2d 0:972874f31c98 395 ((u8g_dev_arg_pixel_t *)arg)->y = y;
iforce2d 0:972874f31c98 396 ((u8g_dev_arg_pixel_t *)arg)->dir+=3;
iforce2d 0:972874f31c98 397 ((u8g_dev_arg_pixel_t *)arg)->dir &= 3;
iforce2d 0:972874f31c98 398 }
iforce2d 0:972874f31c98 399 u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
iforce2d 0:972874f31c98 400 break;
iforce2d 0:972874f31c98 401 }
iforce2d 0:972874f31c98 402 return 1;
iforce2d 0:972874f31c98 403 }
iforce2d 0:972874f31c98 404
iforce2d 0:972874f31c98 405