SSD1306 OLED display driver  1.7.1
This library is developed to control SSD1306/SSD1331/SSD1351/IL9163/PCD8554 RGB i2c/spi LED displays
point.h
Go to the documentation of this file.
1 /*
2  MIT License
3 
4  Copyright (c) 2018, Alexey Dynda
5 
6  Permission is hereby granted, free of charge, to any person obtaining a copy
7  of this software and associated documentation files (the "Software"), to deal
8  in the Software without restriction, including without limitation the rights
9  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  copies of the Software, and to permit persons to whom the Software is
11  furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in all
14  copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  SOFTWARE.
23 */
29 #ifndef _NANO_POINT_H_
30 #define _NANO_POINT_H_
31 
32 #include "ssd1306_hal/io.h"
33 
35 typedef struct _NanoPoint
36 {
38  lcdint_t x;
40  lcdint_t y;
41 
47  void setPoint(lcdint_t px, lcdint_t py) { x=px; y=py; };
48 
53  _NanoPoint& operator>>=(const uint8_t bits)
54  {
55  x >>= bits;
56  y >>= bits;
57  return *this;
58  }
59 
64  _NanoPoint& operator<<=(const uint8_t bits)
65  {
66  x <<= bits;
67  y <<= bits;
68  return *this;
69  }
70 
76  {
77  x += p.x;
78  y += p.y;
79  return *this;
80  };
81 
87  {
88  x -= p.x;
89  y -= p.y;
90  return *this;
91  };
92 
98  {
99  return { static_cast<lcdint_t>(x - p.x),
100  static_cast<lcdint_t>(y - p.y) };
101  };
102 
108  {
109  return { static_cast<lcdint_t>(x + p.x),
110  static_cast<lcdint_t>(y + p.y) };
111  };
112 
117  _NanoPoint operator>>(const uint8_t bits)
118  {
119  return { static_cast<lcdint_t>(x >> bits),
120  static_cast<lcdint_t>(y >> bits) };
121  };
122 
127  _NanoPoint operator<<(const uint8_t bits)
128  {
129  return { static_cast<lcdint_t>(x << bits),
130  static_cast<lcdint_t>(y << bits) };
131  };
132 
137  _NanoPoint operator/(const int16_t d)
138  {
139  return { static_cast<lcdint_t>(x / d),
140  static_cast<lcdint_t>(y / d) };
141  };
142 
143 } NanoPoint;
144 
145 #endif
146 
_NanoPoint operator-(const _NanoPoint &p)
Definition: point.h:97
void setPoint(lcdint_t px, lcdint_t py)
Definition: point.h:47
_NanoPoint operator+(const _NanoPoint &p)
Definition: point.h:107
_NanoPoint operator>>(const uint8_t bits)
Definition: point.h:117
_NanoPoint & operator<<=(const uint8_t bits)
Definition: point.h:64
_NanoPoint & operator>>=(const uint8_t bits)
Definition: point.h:53
lcdint_t y
Definition: point.h:40
_NanoPoint & operator+=(const _NanoPoint &p)
Definition: point.h:75
_NanoPoint operator/(const int16_t d)
Definition: point.h:137
_NanoPoint & operator-=(const _NanoPoint &p)
Definition: point.h:86
struct _NanoPoint NanoPoint
lcdint_t x
Definition: point.h:38
_NanoPoint operator<<(const uint8_t bits)
Definition: point.h:127