Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
asymmetricPart.h
00001 /***************************************************************************//** 00002 * @file asymmetricPart.h 00003 * @brief class for an asymmetric head object for gecko.h 00004 ******************************************************************************* 00005 * @section License 00006 * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b> 00007 ******************************************************************************* 00008 * 00009 * Permission is granted to anyone to use this software for any purpose, 00010 * including commercial applications, and to alter it and redistribute it 00011 * freely, subject to the following restrictions: 00012 * 00013 * 1. The origin of this software must not be misrepresented; you must not 00014 * claim that you wrote the original software. 00015 * 2. Altered source versions must be plainly marked as such, and must not be 00016 * misrepresented as being the original software. 00017 * 3. This notice may not be removed or altered from any source distribution. 00018 * 00019 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no 00020 * obligation to support this Software. Silicon Labs is providing the 00021 * Software "AS IS", with no express or implied warranties of any kind, 00022 * including, but not limited to, any implied warranties of merchantability 00023 * or fitness for any particular purpose or warranties against infringement 00024 * of any proprietary rights of a third party. 00025 * 00026 * Silicon Labs will not be liable for any consequential, incidental, or 00027 * special damages, or any other relief, or for any claim by any third party, 00028 * arising from your use of this Software. 00029 * 00030 ******************************************************************************/ 00031 00032 #include "settings.h" 00033 #include "LS013B7DH03.h" 00034 00035 /* Bitfield containing the position of the top left corner of the part and the orientation 00036 * The minimum number of bits to store x, y and orientation is 10 bits (there are 255 tiles). 00037 * Since this will be expanded to 16 bits the x and y values are stored in 7 bits each. 00038 * */ 00039 00040 struct positionAndDirection{ 00041 uint8_t x:7; 00042 uint8_t y:7; 00043 uint8_t direction:2; 00044 }; 00045 00046 class asymmetricPart{ 00047 private: 00048 positionAndDirection _posAndDir; 00049 const uint8_t *_px_map; 00050 uint8_t _nPix; 00051 00052 /* Private member functions */ 00053 void draw(silabs::LS013B7DH03 &display, uint8_t color) const; 00054 public: 00055 asymmetricPart(); 00056 asymmetricPart(uint8_t x, uint8_t y, Direction dir, const uint8_t *px_map, uint8_t nPix); 00057 00058 /* Set all member variables */ 00059 void init(uint8_t x, uint8_t y, Direction dir, const uint8_t *px_map, uint8_t nPix); 00060 00061 /* Draw the part on the screen */ 00062 void draw(silabs::LS013B7DH03 &display) const {draw(display, Black);}; 00063 00064 /* Erase the part from the screen */ 00065 void remove(silabs::LS013B7DH03 &display) const {draw(display, White);}; 00066 00067 /* Get member variables */ 00068 uint8_t getX() const {return _posAndDir.x;}; 00069 uint8_t getY() const {return _posAndDir.y;}; 00070 uint8_t getDir() const {return _posAndDir.direction;}; 00071 00072 /* Set member variables */ 00073 void setX(uint8_t x) {_posAndDir.x = x&0x7F;}; 00074 void setY(uint8_t y) {_posAndDir.y = y&0x7F;}; 00075 void setDir(Direction dir) {_posAndDir.direction = static_cast<int>(dir)&0x0003;}; 00076 }; 00077
Generated on Thu Jul 14 2022 05:54:03 by
1.7.2