Programme complet de bâton de marche sauf capteur cardiaque

Dependencies:   mbed SimpleBLE X_NUCLEO_IDB0XA1 SDFileSystem MBed_Adafruit-GPS-Library Arduino USBDevice

Committer:
zmoutaou
Date:
Mon Jan 27 12:04:30 2020 +0000
Revision:
0:6e330c197193
BMC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
zmoutaou 0:6e330c197193 1 /***********************************
zmoutaou 0:6e330c197193 2 This is a our graphics core library, for all our displays.
zmoutaou 0:6e330c197193 3 We'll be adapting all the
zmoutaou 0:6e330c197193 4 existing libaries to use this core to make updating, support
zmoutaou 0:6e330c197193 5 and upgrading easier!
zmoutaou 0:6e330c197193 6
zmoutaou 0:6e330c197193 7 Adafruit invests time and resources providing this open source code,
zmoutaou 0:6e330c197193 8 please support Adafruit and open-source hardware by purchasing
zmoutaou 0:6e330c197193 9 products from Adafruit!
zmoutaou 0:6e330c197193 10
zmoutaou 0:6e330c197193 11 Written by Limor Fried/Ladyada for Adafruit Industries.
zmoutaou 0:6e330c197193 12 BSD license, check license.txt for more information
zmoutaou 0:6e330c197193 13 All text above must be included in any redistribution
zmoutaou 0:6e330c197193 14 ****************************************/
zmoutaou 0:6e330c197193 15
zmoutaou 0:6e330c197193 16 /*
zmoutaou 0:6e330c197193 17 * Modified by Neal Horman 7/14/2012 for use in mbed
zmoutaou 0:6e330c197193 18 */
zmoutaou 0:6e330c197193 19
zmoutaou 0:6e330c197193 20 #ifndef _ADAFRUIT_GFX_H_
zmoutaou 0:6e330c197193 21 #define _ADAFRUIT_GFX_H_
zmoutaou 0:6e330c197193 22
zmoutaou 0:6e330c197193 23 #include "Adafruit_GFX_Config.h"
zmoutaou 0:6e330c197193 24
zmoutaou 0:6e330c197193 25 static inline void swap(int16_t &a, int16_t &b)
zmoutaou 0:6e330c197193 26 {
zmoutaou 0:6e330c197193 27 int16_t t = a;
zmoutaou 0:6e330c197193 28
zmoutaou 0:6e330c197193 29 a = b;
zmoutaou 0:6e330c197193 30 b = t;
zmoutaou 0:6e330c197193 31 }
zmoutaou 0:6e330c197193 32
zmoutaou 0:6e330c197193 33 #ifndef _BV
zmoutaou 0:6e330c197193 34 #define _BV(bit) (1<<(bit))
zmoutaou 0:6e330c197193 35 #endif
zmoutaou 0:6e330c197193 36
zmoutaou 0:6e330c197193 37 #define BLACK 0
zmoutaou 0:6e330c197193 38 #define WHITE 1
zmoutaou 0:6e330c197193 39
zmoutaou 0:6e330c197193 40 /**
zmoutaou 0:6e330c197193 41 * This is a Text and Graphics element drawing class.
zmoutaou 0:6e330c197193 42 * These functions draw to the display buffer.
zmoutaou 0:6e330c197193 43 *
zmoutaou 0:6e330c197193 44 * Display drivers should be derived from here.
zmoutaou 0:6e330c197193 45 * The Display drivers push the display buffer to the
zmoutaou 0:6e330c197193 46 * hardware based on application control.
zmoutaou 0:6e330c197193 47 *
zmoutaou 0:6e330c197193 48 */
zmoutaou 0:6e330c197193 49 class Adafruit_GFX : public Stream
zmoutaou 0:6e330c197193 50 {
zmoutaou 0:6e330c197193 51 public:
zmoutaou 0:6e330c197193 52 Adafruit_GFX(int16_t w, int16_t h)
zmoutaou 0:6e330c197193 53 : _rawWidth(w)
zmoutaou 0:6e330c197193 54 , _rawHeight(h)
zmoutaou 0:6e330c197193 55 , _width(w)
zmoutaou 0:6e330c197193 56 , _height(h)
zmoutaou 0:6e330c197193 57 , cursor_x(0)
zmoutaou 0:6e330c197193 58 , cursor_y(0)
zmoutaou 0:6e330c197193 59 , textcolor(WHITE)
zmoutaou 0:6e330c197193 60 , textbgcolor(BLACK)
zmoutaou 0:6e330c197193 61 , textsize(1)
zmoutaou 0:6e330c197193 62 , rotation(0)
zmoutaou 0:6e330c197193 63 , wrap(true)
zmoutaou 0:6e330c197193 64 {};
zmoutaou 0:6e330c197193 65
zmoutaou 0:6e330c197193 66 /// Paint one BLACK or WHITE pixel in the display buffer
zmoutaou 0:6e330c197193 67 // this must be defined by the subclass
zmoutaou 0:6e330c197193 68 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
zmoutaou 0:6e330c197193 69 // this is optional
zmoutaou 0:6e330c197193 70 virtual void invertDisplay(bool i) {};
zmoutaou 0:6e330c197193 71
zmoutaou 0:6e330c197193 72 // Stream implementation - provides printf() interface
zmoutaou 0:6e330c197193 73 // You would otherwise be forced to use writeChar()
zmoutaou 0:6e330c197193 74 virtual int _putc(int value) { return writeChar(value); };
zmoutaou 0:6e330c197193 75 virtual int _getc() { return -1; };
zmoutaou 0:6e330c197193 76
zmoutaou 0:6e330c197193 77 #ifdef GFX_WANT_ABSTRACTS
zmoutaou 0:6e330c197193 78 // these are 'generic' drawing functions, so we can share them!
zmoutaou 0:6e330c197193 79
zmoutaou 0:6e330c197193 80 /** Draw a Horizontal Line
zmoutaou 0:6e330c197193 81 * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 82 */
zmoutaou 0:6e330c197193 83 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
zmoutaou 0:6e330c197193 84 /** Draw a rectangle
zmoutaou 0:6e330c197193 85 * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 86 */
zmoutaou 0:6e330c197193 87 virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
zmoutaou 0:6e330c197193 88 /** Fill the entire display
zmoutaou 0:6e330c197193 89 * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 90 */
zmoutaou 0:6e330c197193 91 virtual void fillScreen(uint16_t color);
zmoutaou 0:6e330c197193 92
zmoutaou 0:6e330c197193 93 /** Draw a circle
zmoutaou 0:6e330c197193 94 * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 95 */
zmoutaou 0:6e330c197193 96 void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
zmoutaou 0:6e330c197193 97 void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color);
zmoutaou 0:6e330c197193 98
zmoutaou 0:6e330c197193 99 /** Draw and fill a circle
zmoutaou 0:6e330c197193 100 * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 101 */
zmoutaou 0:6e330c197193 102 void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
zmoutaou 0:6e330c197193 103 void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color);
zmoutaou 0:6e330c197193 104
zmoutaou 0:6e330c197193 105 /** Draw a triangle
zmoutaou 0:6e330c197193 106 * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 107 */
zmoutaou 0:6e330c197193 108 void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
zmoutaou 0:6e330c197193 109 /** Draw and fill a triangle
zmoutaou 0:6e330c197193 110 * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 111 */
zmoutaou 0:6e330c197193 112 void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
zmoutaou 0:6e330c197193 113
zmoutaou 0:6e330c197193 114 /** Draw a rounded rectangle
zmoutaou 0:6e330c197193 115 * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 116 */
zmoutaou 0:6e330c197193 117 void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
zmoutaou 0:6e330c197193 118 /** Draw and fill a rounded rectangle
zmoutaou 0:6e330c197193 119 * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 120 */
zmoutaou 0:6e330c197193 121 void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
zmoutaou 0:6e330c197193 122 /** Draw a bitmap
zmoutaou 0:6e330c197193 123 * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 124 */
zmoutaou 0:6e330c197193 125 void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);
zmoutaou 0:6e330c197193 126 #endif
zmoutaou 0:6e330c197193 127
zmoutaou 0:6e330c197193 128 #if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT)
zmoutaou 0:6e330c197193 129 /** Draw a line
zmoutaou 0:6e330c197193 130 * @note GFX_WANT_ABSTRACTS or GFX_SIZEABLE_TEXT must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 131 */
zmoutaou 0:6e330c197193 132 virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
zmoutaou 0:6e330c197193 133 /** Draw a vertical line
zmoutaou 0:6e330c197193 134 * @note GFX_WANT_ABSTRACTS or GFX_SIZEABLE_TEXT must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 135 */
zmoutaou 0:6e330c197193 136 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
zmoutaou 0:6e330c197193 137 /** Draw and fill a rectangle
zmoutaou 0:6e330c197193 138 * @note GFX_WANT_ABSTRACTS or GFX_SIZEABLE_TEXT must be defined in Adafruit_GFX_config.h
zmoutaou 0:6e330c197193 139 */
zmoutaou 0:6e330c197193 140 virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
zmoutaou 0:6e330c197193 141 #endif
zmoutaou 0:6e330c197193 142
zmoutaou 0:6e330c197193 143 /// Draw a text character at a specified pixel location
zmoutaou 0:6e330c197193 144 void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size);
zmoutaou 0:6e330c197193 145 /// Draw a text character at the text cursor location
zmoutaou 0:6e330c197193 146 size_t writeChar(uint8_t);
zmoutaou 0:6e330c197193 147
zmoutaou 0:6e330c197193 148 /// Get the width of the display in pixels
zmoutaou 0:6e330c197193 149 inline int16_t width(void) { return _width; };
zmoutaou 0:6e330c197193 150 /// Get the height of the display in pixels
zmoutaou 0:6e330c197193 151 inline int16_t height(void) { return _height; };
zmoutaou 0:6e330c197193 152
zmoutaou 0:6e330c197193 153 /// Set the text cursor location, based on the size of the text
zmoutaou 0:6e330c197193 154 inline void setTextCursor(int16_t x, int16_t y) { cursor_x = x; cursor_y = y; };
zmoutaou 0:6e330c197193 155 #if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT)
zmoutaou 0:6e330c197193 156 /** Set the size of the text to be drawn
zmoutaou 0:6e330c197193 157 * @note Make sure to enable either GFX_SIZEABLE_TEXT or GFX_WANT_ABSTRACTS
zmoutaou 0:6e330c197193 158 */
zmoutaou 0:6e330c197193 159 inline void setTextSize(uint8_t s) { textsize = (s > 0) ? s : 1; };
zmoutaou 0:6e330c197193 160 #endif
zmoutaou 0:6e330c197193 161 /// Set the text foreground and background colors to be the same
zmoutaou 0:6e330c197193 162 inline void setTextColor(uint16_t c) { textcolor = c; textbgcolor = c; }
zmoutaou 0:6e330c197193 163 /// Set the text foreground and background colors independantly
zmoutaou 0:6e330c197193 164 inline void setTextColor(uint16_t c, uint16_t b) { textcolor = c; textbgcolor = b; };
zmoutaou 0:6e330c197193 165 /// Set text wraping mode true or false
zmoutaou 0:6e330c197193 166 inline void setTextWrap(bool w) { wrap = w; };
zmoutaou 0:6e330c197193 167
zmoutaou 0:6e330c197193 168 /// Set the display rotation, 1, 2, 3, or 4
zmoutaou 0:6e330c197193 169 void setRotation(uint8_t r);
zmoutaou 0:6e330c197193 170 /// Get the current rotation
zmoutaou 0:6e330c197193 171 inline uint8_t getRotation(void) { rotation %= 4; return rotation; };
zmoutaou 0:6e330c197193 172
zmoutaou 0:6e330c197193 173 protected:
zmoutaou 0:6e330c197193 174 int16_t _rawWidth, _rawHeight; // this is the 'raw' display w/h - never changes
zmoutaou 0:6e330c197193 175 int16_t _width, _height; // dependent on rotation
zmoutaou 0:6e330c197193 176 int16_t cursor_x, cursor_y;
zmoutaou 0:6e330c197193 177 uint16_t textcolor, textbgcolor;
zmoutaou 0:6e330c197193 178 uint8_t textsize;
zmoutaou 0:6e330c197193 179 uint8_t rotation;
zmoutaou 0:6e330c197193 180 bool wrap; // If set, 'wrap' text at right edge of display
zmoutaou 0:6e330c197193 181 };
zmoutaou 0:6e330c197193 182
zmoutaou 0:6e330c197193 183 #endif