Clock with sensors for temperature, humidity and air pressure. TFT 2.2inch 320x240 SPI with SDCard socket. Sensors: DHT22 aka AM2302, SHT11, BMP180 RTC: DS3231 with 24C32 EEPROM on board.
Dependencies: BMP180 DS3231 RHT03 SDFileSystem SPI_TFT_ILI9341 _24LCXXX mbed SHTx
Clock and environmental display
Used a Nucleo L152RE, cheap display with QVGA 320x240 resolution and SPI bus plus SDCARD socket and a bunch of cheap board from Chinese dealers:
- DS3231 RTC with on board EEPROM 4k Byte
- BMP180 pressure sensor
- SHT11 temperature and humidity sensor
- TTP224 capacitive switch buttons with 4 pads
Simple weather forecast regarding the pressure. Not very reliable. Still searching for infos.
Data will be stored every ten minutes for statistics into EEPROM and on SDCARD EEPROM data is used for statistics display. The text file on SDCARD can be used for importing into some programs on PC.
Backlit control is done by a Pololu 3.3V step-down converter (I was to lazy to search for a transistor ;-) ).
SHT11 uses not the normal I2C protocol. I set it up for second I2C port (PB_11, PB_10). I used a AM2302 sensor, but sensor or lib were not very reliable and the update was hanging several hours. These combined temperature and humidity sensors with digital interface are not very cheap.
Update 1st June 2014
Some major changes. Now using SHT11 temperature humidity sensor. Code for AM2302 and DHT22 still available. Display changed to landscape orientation and inverted to white letters on black background. I use a TTP224 touch module with 4 buttons. Backlit control with a Pololu 3.3V step down converter (#2097) using the SHDN pin. A little bit bigger weather icons (95*85 pixel)
Normal display
Stats display
New media files for icons on black background:
------------------------------
Text for previous version
Now my little clock is running a few day and shows a little issue. It seems, the DHT22/AM2302 sensor is not very reliable and sometime the program hangs getting the data. I will show up with an workaround next days. Later on it is planned to change the sensor. I already ordered a SHT11 sensor which has I²C bus.
Weather symbols converted to RGB565 bmp files with size of 72x72. Put these files on a SDcard
May, 18: Now guessing weather. First splash screen disabled. Changed the reading of temp sensor. If after 5 tries no luck, take old values. The AM2302 reading is not very reliable.
Not really happy with the layout, but a good beginning. :)
Diff: main.cpp
- Revision:
- 0:7e22a0e87f8e
- Child:
- 1:5c0b32a77708
diff -r 000000000000 -r 7e22a0e87f8e main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 12 21:04:00 2014 +0000 @@ -0,0 +1,584 @@ +/************************************************************************ + * Simple indoor weather station with TFT display + * + * Sensors: AM2302 aka DHT22 hygrometer thermometer + * BMP180 barometer atmospheric pressure + * + * Real time clock: DS3231 + * Storage: 24c32 (on rtc board) + * + * Board: ST NUCLEO-L152RE + * cheap 2.2inch 320x240 TFT with SPI-Interface and SDCard socket. + * + * Data stored every 10 minutes into file and 8K byte EEPROM + * + * EEPROM storage: + * 576 values of temp, hygro and barometer (about 4 days) + * Format: day, hour, min, temp, humidity, preasure + * pressure will cover 940hpa to 1060hpa + * + * Similar program exists for a E-Paper display and Seeduino Arch Pro. + * will release this code later. + ************************************************************************/ + +//#define NO_DMA + +#include "stdio.h" +#include "mbed.h" +#include "string" + +// TFT and SDCard +#include "SDFileSystem.h" +#include "SPI_TFT_ILI9341.h" + +// RTC, EEPROM sensors +#include "DS3231.h" +#include "_24LCXXX.h" +#include "BMP180.h" +#include "RHT03.h" //AM2303 + +// some fonts +#include "Courier9x15.h" +#include "Arial12x12.h" +#include "Times_New_Roman28x27.h" + +// my functions +void drawClock(void); +void drawAnalogTime(void); +void drawDigitalTime(void); +void drawTemp(void); +void drawPressure(void); +void SetTime(void); +void UpdateDisplay(void); +void storeData(void); +void showGraph(void); +int map (int ,int , int , int , int); + +char store_temp, store_humidity, store_pressure; + +extern unsigned char p1[]; // the mbed logo + +// analog clock size and locate +#define CLOCK_RADIUS 64 // radius of clock face +#define CLOCK_CENTER_X 68 // If you adjust the radius, you'll probably want to adjust this +#define CLOCK_CENTER_Y 68 // If you adjust the radius, you'll probably want to adjust this + +// Maximum of stored value into eeprom +#define max_datastorage 576 // 576 * 6 = 3456 +#define COUNTERADDRESS 4000 // The counter for ring buffer will be stored here + +// the TFT is connected to SPI +SPI_TFT_ILI9341 TFT(PA_7, PA_6, PA_5, PB_6, PA_9, PC_7,"TFT"); // NUCLEO mosi, miso, sclk, cs, reset, dc + +// SDCard on SPI2 at morpho connectors +SDFileSystem sd(PB_15, PB_14, PB_13, PB_12, "sd"); // MOSI, MISO, SCLK, SSEL + +I2C i2c(PB_9, PB_8); // sda, scl +BMP180 bmp(PB_9, PB_8); +DS3231 rtc(PB_9,PB_8); +_24LCXXX eeprom(&i2c, 0x57); +RHT03 humtemp(PA_10); //Initalise the RHT03 (change pin number to the pin its connected to) + +// set interrupts +InterruptIn RTCInt(PB_4); +InterruptIn ShowGraphInt(PB_5); + +int main() +{ + char Control; + //unsigned int y; + + // Test if SD-Card works + //FILE *fp = fopen("/sd/mbed.txt", "a"); + //fprintf(fp, "Hello World!\n"); + //fclose(fp); + + TFT.set_orientation(0); + TFT.claim(stdout); // send stdout to the TFT display + TFT.claim(stderr); // send stderr to the TFT display + TFT.background(White); // set background to black + TFT.foreground(Black); // set chars to white + TFT.cls(); // clear the screen + + //y= 0; + //TFT.background(Black); + //TFT.cls(); + + TFT.set_font((unsigned char*) Arial12x12); + int err = TFT.BMP_16(9,12,"/sd/Carina.bmp"); // load test.bmp from external SD-card + TFT.locate(10,120); + if (err != 1) TFT.printf(" - Err: %d",err); + wait(2); + + TFT.cls(); // clear the screen + TFT.locate(0,0); + printf(" Hello Mbed "); + TFT.Bitmap(20,20,172,55,p1); + + // set the DS3231 for alarm every minute. + rtc.writeRegister(DS3231_Alarm2_Minutes,0x80); + rtc.writeRegister(DS3231_Alarm2_Hours,0x80); + rtc.writeRegister(DS3231_Alarm_2_Day_Date,0x80); + + Control = rtc.readRegister(DS3231_Control); + Control = Control|DS3231_bit_A2IE; + Control = Control|DS3231_bit_INTCN; + rtc.writeRegister(DS3231_Control,Control); + + Control=rtc.readRegister(DS3231_Control_Status)&0xFC; + rtc.writeRegister(DS3231_Control_Status,Control); + + + wait(1); // wait two seconds + + UpdateDisplay(); + + RTCInt.fall(&UpdateDisplay); // interrupt for display update every minute called by rtc alarm + + ShowGraphInt.fall(&showGraph); // interrupt for showing value history diagram. called by a button or capacitive touch switch + + while(1) { + wait(10.0); + } +} + + +void UpdateDisplay(void) +{ + + //led2 = 0; + + TFT.cls(); + + TFT.fillrect(237,317,239,319,Red); // Just for status: during update there is a small red dot at the bottom right corner + + drawClock(); + drawAnalogTime(); + drawDigitalTime(); + + drawPressure(); + + drawTemp(); + + storeData(); + + TFT.fillrect(237,317,239,319,White); + + // Reset clock alarm + char Control=rtc.readRegister(DS3231_Control_Status)& 0xFC; + rtc.writeRegister(DS3231_Control_Status,Control); + + //led2 = 1; + +} + +// store every ten minute values into file and eeprom +void storeData(void) +{ + int date, month, year, hour, minute, second, dayOfWeek; + unsigned int store_address; + char b[6]; + + //led1=0; + + rtc.readDateTime(&dayOfWeek,&date,&month,&year,&hour,&minute,&second); + + // Save only every 10 minutes + if ( minute%10 == 0) { + + /* Store into EEPROM */ + eeprom.nbyte_read( COUNTERADDRESS, &store_address, sizeof(int) ); + + if ( store_address > (max_datastorage * 6)) { + store_address = 0; + } + + b[0] = date; + b[1] = hour; + b[2] = minute; + b[3] = store_temp; + b[4] = store_humidity; + b[5] = store_pressure; + + eeprom.nbyte_write( store_address, &b, 6); + + store_address += 6; + + eeprom.nbyte_write(COUNTERADDRESS,&store_address,sizeof(int)); + + // Store into file + FILE *fp = fopen("/sd/stored_data.txt", "a"); + fprintf(fp, "%02i %02i %02i:%02i %02i %cC %02i %% %04i hPa\n",month, date, hour, minute, store_temp, 176, store_humidity, (store_pressure+1880) * 50 / 100); + fclose(fp); + + } + + //led1=1; +} + +// show grap of stored data (at the moment landscape oriented. not yet changed to potrait display) +void showGraph(void) +{ + unsigned int store_address,i; + char b[6]; + char temp_arr[204], temp_min, temp_max; + char humidity_arr[204], hum_min, hum_max; + int pressure_arr[204], press_min, press_max; + + eeprom.nbyte_read( COUNTERADDRESS, &store_address, sizeof(int) ); + + TFT.set_font((unsigned char*) Courier9x15); + + TFT.set_orientation(1); + TFT.cls(); + TFT.line(58,8,58,50,0); + TFT.line(56,48,263,48,0); + TFT.line(58,60,58,102,0); + TFT.line(56,100,263,100,0); + TFT.line(58,112,58,154,0); + TFT.line(56,152,263,152,0); + + // store_address is allways one step ahead of last stored values + if ( store_address == 0) + store_address = max_datastorage * 6; + else + store_address -= 6; + + // read from eeprom, store into array, find min and max values + temp_min = 100; + hum_min = 99; + press_min = 1150; + temp_max = 0; + hum_max = 0; + press_max = 0; + + // Read from EEPROM storage into arrays + for (i=0; i<204; i++) { + eeprom.nbyte_read( store_address, &b, 6); + + // draw every 2 hour an line + if ( b[2] == 0 && (b[1]%4 == 0 || b[1] == 0) ) { + TFT.line(263-i,46,263-i,50,1); + TFT.line(263-i,98,263-i,102,1); + TFT.line(263-i,150,263-i,154,1); + TFT.locate(254-i,158); + if ( i > 15 ) // do not write at the right border + printf("%2i",b[1]); + } + + // store temp into array and check min max + temp_arr[i] = b[3]; + if ( b[3] < temp_min ) + temp_min = b[3]; + if ( b[3] > temp_max ) + temp_max = b[3]; + + // store humidity into array and check min max + humidity_arr[i] = b[4]; + if ( b[4] < hum_min ) + hum_min = b[4]; + if ( b[4] > hum_max ) + hum_max = b[4]; + + // store pressure into array and check min max + pressure_arr[i] = (b[5]+1880) * 50 / 100; // calculate pressure to Pascal and hektoPascal + if ( pressure_arr[i] < 990 ) + pressure_arr[i] = 1000; + + if ( pressure_arr[i] < press_min ) + press_min = pressure_arr[i]; + if ( pressure_arr[i] > press_max ) + press_max = pressure_arr[i]; + + if ( store_address == 0) + store_address = max_datastorage * 6; + else + store_address -= 6; + } + + // rounding min and max to 5 + temp_min -= 1; + temp_min = temp_min - (temp_min%5); + temp_max += 1; + temp_max = temp_max + (5 - (temp_max%5)); + TFT.locate(0,2); + printf("%i%cC",temp_max,127); + TFT.locate(0,40); + printf("%i%cC",temp_min,127); + + hum_min -= 1; + hum_min = hum_min - (hum_min%5); + hum_max += 1; + hum_max = hum_max + (5 - (hum_max%5)); + TFT.locate(0,54); + printf("%i%%",hum_max); + TFT.locate(0,92); + printf("%i%%",hum_min); + + press_min -= 1; + press_min = press_min - (press_min%5); + press_max += 1; + press_max = press_max + (5 - (press_max%5)); + TFT.locate(0,106); + printf("%ihPa",press_max); + TFT.locate(0,144); + printf("%ihPa",press_min); + + // drawing lines + for (i=0; i<204; i++) { + // temp line + TFT.pixel(263-i,map(temp_arr[i],temp_min,temp_max,48,8),Red); + // humidity line + TFT.pixel(263-i,map(humidity_arr[i],hum_min,hum_max,100,60),Blue); + // pressure line + TFT.pixel(263-i,map(pressure_arr[i],press_min,press_max,152,112),Green); + + } + + //epaper.write_disp(); // update screen + TFT.set_orientation(0); + +} + +// draw temp and humidity +void drawTemp(void) +{ + int done=0; + float temp,hum; + while(!done) { //Loop keeps running until RHT03 is read succesfully + wait(2.2); //Needed to make sure the sensor has time to initalise and so its not polled too quickly + if(humtemp.readData() == RHT_ERROR_NONE) done=1; //Request data from the RHT03 + } + + temp = humtemp.getTemperatureC(); //Gets the current temperature in centigrade + store_temp = temp; + hum = humtemp.getHumidity(); //Gets the current humidity in percentage + store_humidity = hum; + + TFT.set_font((unsigned char*) Times_New_Roman28x27); // select the font + TFT.locate(156,0); + printf("%2.0f%cC",temp,127); + TFT.locate(156,31); + printf("%2.0f%%",hum); + +} + +// read and draw air pressure. later calculate symbol for wheather guess regarding pressure change. +void drawPressure(void) +{ + long Pressure, BMP180_Temperature; + + bmp.readTP(&BMP180_Temperature,&Pressure,OVERSAMPLING_STANDARD); + + store_pressure = char((Pressure / 50) - 1880); + + TFT.set_font((unsigned char*) Times_New_Roman28x27); // select the font + TFT.locate(0,138); + printf("%4dhPa",Pressure / 100); + TFT.set_font((unsigned char*) Courier9x15); + TFT.locate(0,168); + printf("%i,%1i%cC",BMP180_Temperature/10,BMP180_Temperature%10,127); + + // Draw some weather icons for test + int err ; + err = TFT.BMP_16(2,190,"/sd/rain.bmp"); // load test.bmp from external SD-card + if (err != 1) TFT.printf(" - Err: %d",err); + + err = TFT.BMP_16(76,190,"/sd/cloud.bmp"); // load test.bmp from external SD-card + if (err != 1) TFT.printf(" - Err: %d",err); + + err = TFT.BMP_16(150,190,"/sd/sun.bmp"); // load test.bmp from external SD-card + if (err != 1) TFT.printf(" - Err: %d",err); + +} + +// draw digital date and time. +void drawDigitalTime() +{ + //SetTime(); // Call only once to set date and time on DS3231 + + int date, month, year, hour, minute, second, dayOfWeek; + + rtc.readDateTime(&dayOfWeek,&date,&month,&year,&hour,&minute,&second); + + TFT.set_font((unsigned char*) Times_New_Roman28x27); // select the font + TFT.locate(0,290); + + if (date > 0) { + printf("%02i.%02i.%i %02i:%02d",date,month,year,hour,minute); + } else { + printf("Error read RTC"); + } + +} + +// guess what ;-) +void SetTime() +{ + // DS3231 + // hour,minute,second + rtc.setTime(23,39,0); + // dayofweek,day,month,year + rtc.setDate(3,10,5,2014); + +} + +// draw hands into analog clock +void drawAnalogTime() +{ + int x1, x2, y1, y2, x3, y3, m, h, midHours, second; + + rtc.readTime(&h,&m,&second); + + // Draw minute hand + midHours = m/12; + m -= 30; + if ( m < 0 ) + m += 60; + + m = map(m,0,60,360,0); + + // Center for single line hand + // double line hand + x1 = CLOCK_CENTER_X + 3 * sin(3.14 * ((double) (m - 90))/180); + y1 = CLOCK_CENTER_Y + 3 * cos(3.14 * ((double) (m - 90))/180); + x3 = CLOCK_CENTER_X + 3 * sin(3.14 * ((double) (m + 90))/180); + y3 = CLOCK_CENTER_Y + 3 * cos(3.14 * ((double) (m + 90))/180); + x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 20) * sin(3.14 * ((double) m)/180); + y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 20) * cos(3.14 * ((double) m)/180); + TFT.line(x1,y1,x2,y2,0x001F); + TFT.line(x3,y3,x2,y2,0x001F); + TFT.line(x1,y1,x3,y3,0x001F); + + // Draw hour hand + + // Calc from 24 to 12 hour + if ( h > 11 ) + h -= 12; + + // Rotate 180°. Otherwise clock will be printed upside down + h = h - 6; + if ( h < 0 ) + h += 12; + + // minute correction for hour hand + h *= 5; + h += midHours; + + h = map(h,0,60,360,0); + + x1 = CLOCK_CENTER_X + 3 * sin(3.14 * ((double) (h - 90))/180); + y1 = CLOCK_CENTER_Y + 3 * cos(3.14 * ((double) (h - 90))/180); + x3 = CLOCK_CENTER_X + 3 * sin(3.14 * ((double) (h + 90))/180); + y3 = CLOCK_CENTER_Y + 3 * cos(3.14 * ((double) (h + 90))/180); + x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 32) * sin(3.14 * ((double) h)/180); + y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 32) * cos(3.14 * ((double) h)/180); + TFT.line(x1,y1,x2,y2,0xF400); + TFT.line(x3,y3,x2,y2,0xF400); + TFT.line(x1,y1,x3,y3,0xF400); + +} + + +// Draw analog clock w/o hands +void drawClock(void) +{ + int x1, x2, y1, y2; + + TFT.background(White); // set background to black + TFT.foreground(Black); // set chars to white + TFT.set_font((unsigned char*) Arial12x12); + + TFT.fillcircle(CLOCK_CENTER_X,CLOCK_CENTER_Y,CLOCK_RADIUS,0x0000); + TFT.fillcircle(CLOCK_CENTER_X,CLOCK_CENTER_Y,CLOCK_RADIUS-4,0xFFFF); + + /* + TFT.locate( CLOCK_CENTER_X - 8, CLOCK_CENTER_Y - CLOCK_RADIUS + 6); + printf("12"); + TFT.locate( CLOCK_CENTER_X - CLOCK_RADIUS + 6, CLOCK_CENTER_Y - 6); + printf("9"); + TFT.locate( CLOCK_CENTER_X + CLOCK_RADIUS - 12, CLOCK_CENTER_Y - 6); + printf("3"); + TFT.locate( CLOCK_CENTER_X - 2, CLOCK_CENTER_Y + CLOCK_RADIUS - 15); + printf("6"); + */ + + x1 = CLOCK_CENTER_X - 1; + y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 16); + x2 = CLOCK_CENTER_X + 1; + y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6); + TFT.fillrect(x1,y1,x2,y2,0x0000); + + x1 = CLOCK_CENTER_X - 1; + y1 = CLOCK_CENTER_Y - (CLOCK_RADIUS - 6); + x2 = CLOCK_CENTER_X + 1; + y2 = CLOCK_CENTER_Y - (CLOCK_RADIUS - 16); + TFT.fillrect(x1,y1,x2,y2,0x0000); + + x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 16); + y1 = CLOCK_CENTER_Y - 1; + x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6); + y2 = CLOCK_CENTER_Y + 1; + TFT.fillrect(x1,y1,x2,y2,0x0000); + + x1 = CLOCK_CENTER_X - (CLOCK_RADIUS - 6); + y1 = CLOCK_CENTER_Y - 1; + x2 = CLOCK_CENTER_X - (CLOCK_RADIUS - 16); + y2 = CLOCK_CENTER_Y + 1; + TFT.fillrect(x1,y1,x2,y2,0x0000); + + x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 30)/180); + y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 30)/180); + x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 30)/180); + y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 30)/180); + TFT.line(x1,y1,x2,y2,0x0000); + + x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 60)/180); + y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 60)/180); + x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 60)/180); + y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 60)/180); + TFT.line(x1,y1,x2,y2,0x0000); + + x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 120)/180); + y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 120)/180); + x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 120)/180); + y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 120)/180); + TFT.line(x1,y1,x2,y2,0x0000); + + x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 150)/180); + y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 150)/180); + x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 150)/180); + y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 150)/180); + TFT.line(x1,y1,x2,y2,0x0000); + + x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 210)/180); + y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 210)/180); + x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 210)/180); + y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 210)/180); + TFT.line(x1,y1,x2,y2,0x0000); + + x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 240)/180); + y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 240)/180); + x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 240)/180); + y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 240)/180); + TFT.line(x1,y1,x2,y2,0x0000); + + x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 300)/180); + y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 300)/180); + x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 300)/180); + y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 300)/180); + TFT.line(x1,y1,x2,y2,0x0000); + + x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 330)/180); + y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 330)/180); + x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 330)/180); + y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 330)/180); + TFT.line(x1,y1,x2,y2,0x0000); + +} + +// Map funktion copied from Arduino code +int map (int x, int in_min, int in_max, int out_min, int out_max) +{ + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} \ No newline at end of file