hadif azli / Mbed 2 deprecated TEST123

Dependencies:   mbed Blynk

Committer:
lixianyu
Date:
Mon Jun 13 02:21:11 2016 +0000
Revision:
1:0e75de2a5d21
Parent:
0:d8f4c441e032
u8glib???????????????????????????Adafruit_GFX????OLED????????bitmap??????

Who changed what in which revision?

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