This is a fork of a functional ILI9341 display with a functional Seeed touch screen library.

Dependencies:   BMP180 UniGraphic mbed BNO055_fusionI_fixed HTU21D GPSISR Compass Fonts uGUI

Fork of TFT_test_NUCLEO-F411RE by Motoo Tanaka

/media/uploads/trevieze/win_20170427_21_31_20_pro.jpg

Had to move sensors to a remote board because of interference. Added spi burst mode to supported displays.

To do.... ugui buttons are slow. will need to add rtos to project. Finish other way points screen. Will have to rewrite portions of the touch screen class. Sense touch, delay, read values and then average, touch released, is the sequence. Add cadence input and logic to program for computer screen.

Committer:
trevieze
Date:
Fri Mar 03 02:56:25 2017 +0000
Revision:
13:4f0ebc5a4f00
Parent:
12:1a9c0f9d7128
Child:
14:b174ec6e3ca0
Replaced the BNO055 Library with a more complete one from Github.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:cd5e3d371b54 1 /* mbed main.cpp to test adafruit 2.8" TFT LCD shiled w Touchscreen
Rhyme 0:cd5e3d371b54 2 * Copyright (c) 2014, 2015 Motoo Tanaka @ Design Methodology Lab
Rhyme 0:cd5e3d371b54 3 *
Rhyme 0:cd5e3d371b54 4 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Rhyme 0:cd5e3d371b54 5 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Rhyme 0:cd5e3d371b54 6 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Rhyme 0:cd5e3d371b54 7 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Rhyme 0:cd5e3d371b54 8 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Rhyme 0:cd5e3d371b54 9 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Rhyme 0:cd5e3d371b54 10 * THE SOFTWARE.
Rhyme 0:cd5e3d371b54 11 */
Rhyme 0:cd5e3d371b54 12
Rhyme 0:cd5e3d371b54 13 /*
Rhyme 0:cd5e3d371b54 14 * Note: This program is derived from the SeeeStudioTFTv2 program.
Rhyme 0:cd5e3d371b54 15 * Although both program share same ILI9341 TFT driver,
Rhyme 0:cd5e3d371b54 16 * the touch sensor was not same with the Display I purchased from Akizuki.
Rhyme 0:cd5e3d371b54 17 * http://akizukidenshi.com/catalog/g/gM-07747/
Rhyme 0:cd5e3d371b54 18 * The touch sensor on the display is STMPE610,
Rhyme 0:cd5e3d371b54 19 * so I hacked the minimum spi driver for it (polling mode only).
Rhyme 0:cd5e3d371b54 20 */
Rhyme 0:cd5e3d371b54 21
Rhyme 0:cd5e3d371b54 22 #include "mbed.h"
Rhyme 0:cd5e3d371b54 23 #include <math.h>
Rhyme 0:cd5e3d371b54 24 #include "ILI9341.h"
trevieze 2:c5085faf2aa5 25 #include "SeeedStudioTFTv2.h"
trevieze 5:6eb4b9322931 26 #include "BNO055.h"
trevieze 5:6eb4b9322931 27 #include "HTU21D.h"
trevieze 5:6eb4b9322931 28 #include "BMP180.h"
trevieze 7:8aa9cdab4a07 29 #include "SDFileSystem.h"
trevieze 7:8aa9cdab4a07 30 #include "GPSISR.h"
trevieze 12:1a9c0f9d7128 31 #include "nav.h"
trevieze 8:855884782f67 32
trevieze 5:6eb4b9322931 33
trevieze 10:869a102dd31c 34 #include "ArialR16x17.h"
trevieze 10:869a102dd31c 35 #include "Arial24x23i.h"
trevieze 10:869a102dd31c 36 #include "Arial28x28.h"
trevieze 10:869a102dd31c 37 #include "Neu44x36.h"
trevieze 10:869a102dd31c 38 #include "SCProSB31x55.h"
Rhyme 0:cd5e3d371b54 39 #include "Arial12x12.h"
trevieze 10:869a102dd31c 40 #include "ArialR20x20.h"
Rhyme 0:cd5e3d371b54 41
trevieze 7:8aa9cdab4a07 42 //#define PIN_CS_TSC PA_9
trevieze 7:8aa9cdab4a07 43 //#define PIN_TSC_INTR PA_8
Rhyme 0:cd5e3d371b54 44 #define PIN_RESET_TFT PC_13 /* place holder */
trevieze 7:8aa9cdab4a07 45 //ILI9341 SPI PINS
trevieze 1:e265e7245ab8 46 #define PIN_XP A3
trevieze 1:e265e7245ab8 47 #define PIN_XM A1
trevieze 1:e265e7245ab8 48 #define PIN_YP A2
trevieze 1:e265e7245ab8 49 #define PIN_YM A0
trevieze 7:8aa9cdab4a07 50 #define PIN_MOSI_SPI1 D11 //SPI 1 MOSI
trevieze 7:8aa9cdab4a07 51 #define PIN_MISO_SPI1 D12 //SPI 1 MISO
trevieze 7:8aa9cdab4a07 52 #define PIN_SCLK_SPI1 D13 //SPI 1 SLCK
trevieze 7:8aa9cdab4a07 53 #define PIN_CS_SPI1 D5 // SPI CS D10 Was D5
trevieze 1:e265e7245ab8 54 #define PIN_DC_TFT D6
trevieze 1:e265e7245ab8 55 #define PIN_CS_SD D4
trevieze 5:6eb4b9322931 56 #define PIN_RESET D7
trevieze 7:8aa9cdab4a07 57 // SD Card on GPS shield PINS
trevieze 7:8aa9cdab4a07 58 #define PIN_MOSI_SPI3 PB_15 //SPI 1 MOSI
trevieze 7:8aa9cdab4a07 59 #define PIN_MISO_SPI3 PB_14 //SPI 1 MISO
trevieze 7:8aa9cdab4a07 60 #define PIN_SCLK_SPI3 PB_13 //SPI 1 SLCK
trevieze 7:8aa9cdab4a07 61 #define PIN_CS_SPI3 D2 // SPI CS
trevieze 7:8aa9cdab4a07 62 #define PIN_RX_GPS PA_12 //GPS Shield RX pin
trevieze 7:8aa9cdab4a07 63 #define PIN_TX_GPS PA_11 //GPS Shield TX pin
trevieze 7:8aa9cdab4a07 64
trevieze 10:869a102dd31c 65 #define PI 3.14159265358979f
trevieze 10:869a102dd31c 66
Rhyme 0:cd5e3d371b54 67 #define DEVICE_NAME "F411RE"
Rhyme 0:cd5e3d371b54 68
Rhyme 0:cd5e3d371b54 69 #ifndef TARGET_NECLEO_F411RE
Rhyme 0:cd5e3d371b54 70 #define TARGET_NECLEO_F411RE
Rhyme 0:cd5e3d371b54 71 #endif
Rhyme 0:cd5e3d371b54 72
trevieze 6:b78ff34209e5 73 //DigitalOut backlight(PB_3) ;
trevieze 5:6eb4b9322931 74 // DigitalOut tsc_cs(PA_9, 1) ;
trevieze 5:6eb4b9322931 75 // DigitalOut tft_cs(PB_6, 1) ;
Rhyme 0:cd5e3d371b54 76
trevieze 7:8aa9cdab4a07 77 Serial pc(USBTX, USBRX);
trevieze 7:8aa9cdab4a07 78
trevieze 5:6eb4b9322931 79 // Display
Rhyme 0:cd5e3d371b54 80 ILI9341 TFT(SPI_8, 10000000,
trevieze 7:8aa9cdab4a07 81 PIN_MOSI_SPI1, PIN_MISO_SPI1, PIN_SCLK_SPI1,
trevieze 7:8aa9cdab4a07 82 PIN_CS_SPI1, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8") ;
trevieze 5:6eb4b9322931 83
trevieze 5:6eb4b9322931 84 // TouchScreen
trevieze 2:c5085faf2aa5 85 TouchScreen TSC(PIN_XP, PIN_XM, PIN_YP, PIN_YM);
Rhyme 0:cd5e3d371b54 86
trevieze 5:6eb4b9322931 87 // 3 Axis IMU
trevieze 13:4f0ebc5a4f00 88 BNO055 imu(I2C_SDA, I2C_SCL); // New Library Adafruit
trevieze 5:6eb4b9322931 89
trevieze 5:6eb4b9322931 90 // Humidity and Temperature
trevieze 10:869a102dd31c 91 HTU21D humid(I2C_SDA, I2C_SCL);
trevieze 5:6eb4b9322931 92
trevieze 5:6eb4b9322931 93 // Pressure
trevieze 6:b78ff34209e5 94 BMP180 bmp180(I2C_SDA, I2C_SCL);
trevieze 5:6eb4b9322931 95
trevieze 7:8aa9cdab4a07 96 // SD Card Reader On Adafruit GPS Shield
trevieze 7:8aa9cdab4a07 97 SDFileSystem sd(PIN_MOSI_SPI3, PIN_MISO_SPI3, PIN_SCLK_SPI3, PIN_CS_SPI3, "sd"); // the pinout on the mbed Cool Components workshop board
trevieze 7:8aa9cdab4a07 98
trevieze 8:855884782f67 99 // Set up serial interrupe service handler for gps characters.
trevieze 7:8aa9cdab4a07 100 GPS MyGPS(PIN_TX_GPS,PIN_RX_GPS, 9600);
trevieze 8:855884782f67 101
trevieze 12:1a9c0f9d7128 102 //Navigation Class.
trevieze 12:1a9c0f9d7128 103 NAV nav;
trevieze 12:1a9c0f9d7128 104 double plat = 42.826420;
trevieze 12:1a9c0f9d7128 105 double plon = -84.219413;
trevieze 12:1a9c0f9d7128 106
trevieze 10:869a102dd31c 107 void Draw_Compass_Rose(void);
trevieze 10:869a102dd31c 108 void arrow(int x2, int y2, int x1, int y1, int alength, int awidth, int colour);
Rhyme 0:cd5e3d371b54 109
trevieze 10:869a102dd31c 110 const int centreX = 120;
trevieze 10:869a102dd31c 111 const int centreY = 150;
trevieze 10:869a102dd31c 112 const int radius = 40;
trevieze 11:49600de70963 113 float last_dx;
trevieze 11:49600de70963 114 float last_dy;
Rhyme 0:cd5e3d371b54 115
Rhyme 0:cd5e3d371b54 116 int main()
Rhyme 0:cd5e3d371b54 117 {
trevieze 9:a3cb458d7b1c 118 TFT.BusEnable(true) ;
trevieze 9:a3cb458d7b1c 119 TFT.FastWindow(true) ;
trevieze 9:a3cb458d7b1c 120 wait(0.1);
trevieze 9:a3cb458d7b1c 121 TFT.cls();
trevieze 9:a3cb458d7b1c 122 wait(0.1);
trevieze 7:8aa9cdab4a07 123 Timer refresh_Timer; //sets up a timer for use in loop; how often do we print GPS info?
trevieze 9:a3cb458d7b1c 124 const int refresh_Time = 2000; //refresh time in ms
trevieze 7:8aa9cdab4a07 125 refresh_Timer.start(); //starts the clock on the timer
trevieze 7:8aa9cdab4a07 126 //backlight = 0 ;
trevieze 10:869a102dd31c 127 TFT.set_font((unsigned char*) Arial24x23i);
trevieze 9:a3cb458d7b1c 128 TFT.fillrect(2, 2, 237, 317, White);
trevieze 9:a3cb458d7b1c 129 TFT.foreground(Blue);
trevieze 9:a3cb458d7b1c 130 TFT.background(White);
trevieze 9:a3cb458d7b1c 131 wait(0.1);
trevieze 12:1a9c0f9d7128 132
trevieze 10:869a102dd31c 133 Draw_Compass_Rose();
trevieze 10:869a102dd31c 134
trevieze 7:8aa9cdab4a07 135 while (1) {
trevieze 10:869a102dd31c 136
trevieze 13:4f0ebc5a4f00 137 TFT.set_font((unsigned char*) ArialR20x20);
trevieze 13:4f0ebc5a4f00 138 //check if we recieved a new message from GPS, if so, attempt to parse it,
trevieze 7:8aa9cdab4a07 139 if (refresh_Timer.read_ms() >= refresh_Time) {
trevieze 7:8aa9cdab4a07 140 refresh_Timer.reset();
trevieze 9:a3cb458d7b1c 141
trevieze 13:4f0ebc5a4f00 142 if (bmp180.init() != 0) {
trevieze 13:4f0ebc5a4f00 143 //pc.printf("Error communicating with BMP180\n");
trevieze 13:4f0ebc5a4f00 144 } else {
trevieze 13:4f0ebc5a4f00 145 //pc.printf("Initialized BMP180\n");
trevieze 13:4f0ebc5a4f00 146 bmp180.startTemperature();
trevieze 13:4f0ebc5a4f00 147 wait(0.1); // Wait for conversion to complete
trevieze 13:4f0ebc5a4f00 148 float temp;
trevieze 13:4f0ebc5a4f00 149 if(bmp180.getTemperature(&temp) != 0) {
trevieze 13:4f0ebc5a4f00 150 //pc.printf("Error getting temperature\n");
trevieze 13:4f0ebc5a4f00 151 }
trevieze 13:4f0ebc5a4f00 152 //pc.printf("Temperature is : %f", temp);
trevieze 13:4f0ebc5a4f00 153 TFT.locate(4, 26) ;
trevieze 13:4f0ebc5a4f00 154 TFT.printf("%.1fF", ((temp* 9.0) / 5.0 + 32));
trevieze 13:4f0ebc5a4f00 155 }
trevieze 13:4f0ebc5a4f00 156 int ftemp = humid.sample_ftemp();
trevieze 13:4f0ebc5a4f00 157 int humidity = humid.sample_humid();
trevieze 13:4f0ebc5a4f00 158 TFT.locate(140, 26) ;
trevieze 13:4f0ebc5a4f00 159 TFT.printf("%d%%RH",humidity);
trevieze 13:4f0ebc5a4f00 160 //pc.printf("HTU21D Temp: %d",ftemp);
trevieze 13:4f0ebc5a4f00 161 //pc.printf("HTU21D Humidity: %d",humidity);
trevieze 11:49600de70963 162
trevieze 13:4f0ebc5a4f00 163 if (imu.check() == 0){
trevieze 13:4f0ebc5a4f00 164 pc.printf("Bosch BNO055 is NOT avirable!!\r\n");
trevieze 13:4f0ebc5a4f00 165 } else {
trevieze 13:4f0ebc5a4f00 166 //printf("Cal %d", imu.read_calib_status());
trevieze 13:4f0ebc5a4f00 167 imu.get_calib();
trevieze 13:4f0ebc5a4f00 168 if (imu.cal.system > 0x0){
trevieze 13:4f0ebc5a4f00 169 TFT.foreground(White);
trevieze 13:4f0ebc5a4f00 170 TFT.locate(4, 260) ;
trevieze 13:4f0ebc5a4f00 171 TFT.printf("No Data");
trevieze 13:4f0ebc5a4f00 172 TFT.foreground(Blue);
trevieze 13:4f0ebc5a4f00 173 imu.get_angles();
trevieze 13:4f0ebc5a4f00 174 TFT.locate(4, 260) ;
trevieze 13:4f0ebc5a4f00 175 TFT.printf("%.1f",imu.euler.yaw);
trevieze 13:4f0ebc5a4f00 176 //pc.printf("H %.1f",euler_angles.h);
trevieze 13:4f0ebc5a4f00 177 //pc.printf("R %.1f",euler_angles.r);
trevieze 13:4f0ebc5a4f00 178 //pc.printf("P %.1f",euler_angles.p);
trevieze 13:4f0ebc5a4f00 179
trevieze 10:869a102dd31c 180 } else {
trevieze 13:4f0ebc5a4f00 181 TFT.locate(4, 260) ;
trevieze 13:4f0ebc5a4f00 182 TFT.printf("No Data");
trevieze 13:4f0ebc5a4f00 183 }
trevieze 13:4f0ebc5a4f00 184 }
trevieze 11:49600de70963 185
trevieze 13:4f0ebc5a4f00 186 float angle = int(imu.euler.yaw); // * 180/PI); // Convert radians to degrees for more a more usual result
trevieze 13:4f0ebc5a4f00 187 // For the screen -X = up and +X = down and -Y = left and +Y = right, so does not follow coordinate conventions
trevieze 13:4f0ebc5a4f00 188 float dx = (0.7*radius * cos((angle-90)*PI/180)) + centreX; // calculate X position for the screen coordinates - can be confusing!
trevieze 10:869a102dd31c 189 float dy = (0.7*radius * sin((angle-90)*PI/180)) + centreY; // calculate Y position for the screen coordinates - can be confusing!
trevieze 10:869a102dd31c 190 arrow(last_dx,last_dy, centreX, centreY, 2,2,White); // Erase last arrow
trevieze 10:869a102dd31c 191 arrow(dx,dy, centreX, centreY, 2, 2,Blue); // Draw arrow in new position
trevieze 10:869a102dd31c 192 last_dx = dx;
trevieze 10:869a102dd31c 193 last_dy = dy;
trevieze 10:869a102dd31c 194
trevieze 9:a3cb458d7b1c 195 if (MyGPS.dataready()) {
trevieze 9:a3cb458d7b1c 196 MyGPS.read();
trevieze 10:869a102dd31c 197 //pc.printf("NMEA has valid data");
trevieze 10:869a102dd31c 198 //pc.printf("Sats : %d \n", MyGPS.buffer.satellites);
trevieze 10:869a102dd31c 199 //pc.printf("%d-%d-%d\n", MyGPS.buffer.month, MyGPS.buffer.day, MyGPS.buffer.year);
trevieze 10:869a102dd31c 200 //pc.printf("%d:%d:%d\n", MyGPS.buffer.hours, MyGPS.buffer.minutes, MyGPS.buffer.seconds);
trevieze 9:a3cb458d7b1c 201
trevieze 13:4f0ebc5a4f00 202 TFT.foreground(White);
trevieze 13:4f0ebc5a4f00 203 TFT.locate(4, 2) ;
trevieze 13:4f0ebc5a4f00 204 TFT.printf("No Data");
trevieze 10:869a102dd31c 205 TFT.foreground(Blue);
trevieze 10:869a102dd31c 206 TFT.locate(4, 2) ;
trevieze 9:a3cb458d7b1c 207 TFT.printf("%d-%d-%d", MyGPS.buffer.month, MyGPS.buffer.day, MyGPS.buffer.year);
trevieze 13:4f0ebc5a4f00 208 TFT.locate(4, 50) ;
trevieze 13:4f0ebc5a4f00 209 double waypoint = nav.CalculateDistance(MyGPS.buffer.latitude,MyGPS.buffer.longitude,plat,plon)/double(1609.344);
trevieze 13:4f0ebc5a4f00 210 TFT.printf("%.1fMI From Perry", waypoint);
trevieze 10:869a102dd31c 211 TFT.locate(140, 2) ;
trevieze 9:a3cb458d7b1c 212 TFT.printf("%d:%d:%d", MyGPS.buffer.hours, MyGPS.buffer.minutes, MyGPS.buffer.seconds);
trevieze 13:4f0ebc5a4f00 213 TFT.locate(140, 260) ;
trevieze 10:869a102dd31c 214 TFT.printf("%.1fft", MyGPS.buffer.altitude/0.3048);
trevieze 13:4f0ebc5a4f00 215 TFT.locate(4, 280) ;
trevieze 13:4f0ebc5a4f00 216 int degree;
trevieze 13:4f0ebc5a4f00 217 int minutes;
trevieze 13:4f0ebc5a4f00 218 int seconds;
trevieze 13:4f0ebc5a4f00 219 degree = (int)abs(MyGPS.buffer.longitude);
trevieze 12:1a9c0f9d7128 220 minutes = (int) ( (abs(MyGPS.buffer.longitude) - (double)degree) * 60.0);
trevieze 12:1a9c0f9d7128 221 seconds = (int) ( (abs(MyGPS.buffer.longitude) - (double)degree - (double)minutes / 60.0) * 60.0 * 60.0 );
trevieze 12:1a9c0f9d7128 222 TFT.printf("%d %d' %d\" %c lon", degree, minutes,seconds, MyGPS.buffer.lonc);
trevieze 13:4f0ebc5a4f00 223 TFT.locate(4, 300) ;
trevieze 12:1a9c0f9d7128 224 degree = (int)abs(MyGPS.buffer.latitude);
trevieze 12:1a9c0f9d7128 225 minutes = (int) ( (abs(MyGPS.buffer.latitude) - (double)degree) * 60.0);
trevieze 12:1a9c0f9d7128 226 seconds = (int) ( (abs(MyGPS.buffer.latitude) - (double)degree - (double)minutes / 60.0) * 60.0 * 60.0 );
trevieze 12:1a9c0f9d7128 227 TFT.printf("%d %d' %d\" %c lat", degree, minutes,seconds, MyGPS.buffer.latc);
trevieze 13:4f0ebc5a4f00 228 TFT.set_font((unsigned char*) SCProSB31x55);
trevieze 10:869a102dd31c 229 TFT.locate(120, 200) ;
trevieze 10:869a102dd31c 230 TFT.printf("%.1f", MyGPS.buffer.speed);
trevieze 13:4f0ebc5a4f00 231
trevieze 13:4f0ebc5a4f00 232 //pc.printf("Dist to Perry %.4f ", nav.CalculateDistance(MyGPS.buffer.latitude,MyGPS.buffer.longitude,plat,plon));
trevieze 12:1a9c0f9d7128 233
trevieze 8:855884782f67 234 }
trevieze 8:855884782f67 235 else {
trevieze 13:4f0ebc5a4f00 236 TFT.locate(4, 2) ;
trevieze 13:4f0ebc5a4f00 237 TFT.printf("No Data");
trevieze 10:869a102dd31c 238 //pc.printf("NMEA has no valid data");
trevieze 8:855884782f67 239 }
trevieze 7:8aa9cdab4a07 240 }
trevieze 7:8aa9cdab4a07 241 }
trevieze 10:869a102dd31c 242 }
trevieze 10:869a102dd31c 243
trevieze 10:869a102dd31c 244 void arrow(int x2, int y2, int x1, int y1, int alength, int awidth, int colour) {
trevieze 10:869a102dd31c 245 float distance;
trevieze 10:869a102dd31c 246 int dx, dy, x2o,y2o,x3,y3,x4,y4,k;
trevieze 10:869a102dd31c 247 distance = sqrt(pow((double)(x1 - x2),2) + pow((double)(y1 - y2), 2));
trevieze 10:869a102dd31c 248 dx = x2 + (x1 - x2) * alength / distance;
trevieze 10:869a102dd31c 249 dy = y2 + (y1 - y2) * alength / distance;
trevieze 10:869a102dd31c 250 k = awidth / alength;
trevieze 10:869a102dd31c 251 x2o = x2 - dx;
trevieze 10:869a102dd31c 252 y2o = dy - y2;
trevieze 10:869a102dd31c 253 x3 = y2o * k + dx;
trevieze 10:869a102dd31c 254 y3 = x2o * k + dy;
trevieze 10:869a102dd31c 255 x4 = dx - y2o * k;
trevieze 10:869a102dd31c 256 y4 = dy - x2o * k;
trevieze 10:869a102dd31c 257 TFT.line(x1, y1, x2, y2, colour);
trevieze 10:869a102dd31c 258 TFT.line(x1, y1, dx, dy, colour);
trevieze 10:869a102dd31c 259 TFT.line(x3, y3, x4, y4, colour);
trevieze 10:869a102dd31c 260 TFT.line(x3, y3, x2, y2, colour);
trevieze 10:869a102dd31c 261 TFT.line(x2, y2, x4, y4, colour);
trevieze 12:1a9c0f9d7128 262 TFT.set_font((unsigned char*) Arial12x12);
trevieze 11:49600de70963 263 TFT.foreground(Blue);
trevieze 11:49600de70963 264 TFT.background(White);
trevieze 12:1a9c0f9d7128 265 TFT.locate((centreX-2),(centreY-24));
trevieze 11:49600de70963 266 TFT.printf("N");
trevieze 11:49600de70963 267 TFT.locate((centreX-2),(centreY+17));
trevieze 11:49600de70963 268 TFT.printf("S");
trevieze 11:49600de70963 269 TFT.locate((centreX+19),(centreY-3));
trevieze 11:49600de70963 270 TFT.printf("E");
trevieze 11:49600de70963 271 TFT.locate((centreX-23),(centreY-3));
trevieze 11:49600de70963 272 TFT.printf("W");
trevieze 12:1a9c0f9d7128 273 TFT.set_font((unsigned char*) ArialR20x20);
trevieze 10:869a102dd31c 274 }
Rhyme 0:cd5e3d371b54 275
trevieze 10:869a102dd31c 276 void Draw_Compass_Rose(void) {
trevieze 10:869a102dd31c 277 int dxo, dyo, dxi, dyi;
trevieze 10:869a102dd31c 278 TFT.circle(centreX,centreY,radius,Blue); // Draw compass circle
trevieze 10:869a102dd31c 279 for (float i = 0; i <360; i = i + 22.5) {
trevieze 10:869a102dd31c 280 dxo = radius * cos(i*3.14/180);
trevieze 10:869a102dd31c 281 dyo = radius * sin(i*3.14/180);
trevieze 10:869a102dd31c 282 dxi = dxo * 0.95;
trevieze 10:869a102dd31c 283 dyi = dyo * 0.95;
trevieze 10:869a102dd31c 284 TFT.line(dxi+centreX,dyi+centreY,dxo+centreX,dyo+centreY,Blue);
trevieze 10:869a102dd31c 285 }
trevieze 10:869a102dd31c 286 TFT.set_font((unsigned char*) Arial12x12);
trevieze 10:869a102dd31c 287 TFT.foreground(Blue);
trevieze 10:869a102dd31c 288 TFT.background(White);
trevieze 10:869a102dd31c 289 TFT.locate((centreX-2),(centreY-24));
trevieze 10:869a102dd31c 290 TFT.printf("N");
trevieze 10:869a102dd31c 291 TFT.locate((centreX-2),(centreY+17));
trevieze 10:869a102dd31c 292 TFT.printf("S");
trevieze 10:869a102dd31c 293 TFT.locate((centreX+19),(centreY-3));
trevieze 10:869a102dd31c 294 TFT.printf("E");
trevieze 10:869a102dd31c 295 TFT.locate((centreX-23),(centreY-3));
trevieze 10:869a102dd31c 296 TFT.printf("W");
trevieze 9:a3cb458d7b1c 297 }