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.
Revision 0:4d6ee7be56aa, committed 2020-12-10
- Comitter:
- nz
- Date:
- Thu Dec 10 16:32:55 2020 +0000
- Child:
- 1:eb2a62ab9e2f
- Commit message:
- Demo-Clock
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FT800-480x272.lib Thu Dec 10 16:32:55 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/nz/code/FT800-480x272/#e078da558903
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Dec 10 16:32:55 2020 +0000
@@ -0,0 +1,132 @@
+/*
+* Author: Nikolai Zimfer, 2020
+*
+* HARDWARE:
+* Board FRDM-K64F - https://os.mbed.com/platforms/FRDM-K64F/
+* Display 4.3" 480 x 272 (RVT43ULFNWC03) - https://riverdi.com/product/rvt43ulfnwc0x/
+* Break Out Board 20 - https://riverdi.com/product/break-out-board-20/
+* Cable FFC, 0.5mm pitch, 20 pin, 150 mm - https://riverdi.com/product/ffc0520150/
+*
+* WIRING:
+* -----------------------------------
+* FRDM-K64F Break Out Board
+* -----------------------------------
+* +3.3V --- Pin 1 VDD, Pin 17 BLVDD
+* GND --- Pin 2 GND
+* D13 (PTD1) SCLK --- Pin 3 SPI SCLK
+* D12 (PTD3) MISO --- Pin 4 MISO
+* D11 (PTD2) MOSI --- PIN 5 MOSI
+* D10 (PTD0) --- Pin 6 CS
+* D9 (PTC4) --- Pin 7 INT
+* D8 (PTC12) --- Pin 8 PD
+* -----------------------------------
+*/
+
+#include "mbed.h"
+#include "FT800.h"
+
+/*
+FT800 TFT(MOSI,MISO, SCK, CS, INT, PD); */
+FT800 TFT( D11, D12, D13, D10, D9, D8); // FRDM-K64F
+
+int16_t ox = 240, oy = 135; // center and size of clock
+int16_t i, x, y;
+uint16_t hurs, mins, secs;
+float rads;
+const float pi = 3.141592;
+char textbuff[32];
+char timebuff[32];
+
+int main()
+{
+ //printf("Mbed OS %d.%d.%d.\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
+
+ TFT.Init();
+
+ set_time(1577869200); // Set RTC time to 9:00:00, date to 01.01.2020
+
+ while(1)
+ {
+ time_t seconds = time(NULL);
+
+ strftime(timebuff, 3,"%H", localtime(&seconds));
+ hurs = atoi(timebuff);
+ strftime(timebuff, 3,"%M", localtime(&seconds));
+ mins = atoi(timebuff);
+ strftime(timebuff, 3,"%S", localtime(&seconds));
+ secs = atoi(timebuff);
+
+ TFT.DLstart(WHITE,100); // Start Display List
+
+ // Draw the Minute ticks, angle difference is 6 degree
+ for (i = 0; i < 60; i++)
+ {
+ rads = (pi * i*6) / 180; // radians
+ x = (int16_t)(ox + (129 * cos(rads)));
+ y = (int16_t)(oy + (129 * sin(rads)));
+ TFT.drawLine(ox, oy, x, y, BLACK, 1);
+ }
+ TFT.drawPoint(ox, oy, WHITE, 124);
+
+ // Draw the 5 min ticks, 5*6=30 degree
+ for (i = 0; i < 12; i++)
+ {
+ rads = (pi * i*30) / 180; // radians
+ x = (int16_t)(ox + (131 * cos(rads)));
+ y = (int16_t)(oy + (131 * sin(rads)));
+ TFT.drawLine(ox, oy, x, y, BLACK, 2);
+ }
+ TFT.drawPoint(ox, oy, WHITE, 121);
+
+ TFT.drawNumber(ox + 103, oy, 31, BLACK, OPT_CENTER, 3);
+ TFT.drawNumber(ox - 103, oy, 31, BLACK, OPT_CENTER, 9);
+ TFT.drawNumber(ox, oy + 100, 31, BLACK, OPT_CENTER, 6);
+ TFT.drawNumber(ox, oy - 100, 31, BLACK, OPT_CENTER, 12);
+
+ // Draw hour hand // часовая стрелка
+ rads = (pi * (hurs*(-30) - mins*0.5)) / 180;
+ x = (int16_t)(ox + (84 * sin(rads) * (-1)));
+ y = (int16_t)(oy + (84 * cos(rads) * (-1)));
+ TFT.drawLine(ox, oy, x, y, BLACK, 3);
+ x = (int16_t)(ox + (20 * sin(rads)));
+ y = (int16_t)(oy + (20 * cos(rads)));
+ TFT.drawLine(ox, oy, x, y, BLACK, 3);
+
+ // Draw minute hand // минутная стрелка
+ rads = (pi * mins*(-6)) / 180;
+ x = (int16_t)(ox + (114 * sin(rads) * (-1)));
+ y = (int16_t)(oy + (115 * cos(rads) * (-1)));
+ TFT.drawLine(ox, oy, x, y, BLACK, 3);
+ x = (int16_t)(ox + (20 * sin(rads)));
+ y = (int16_t)(oy + (20 * cos(rads)));
+ TFT.drawLine(ox, oy, x, y, BLACK, 3);
+
+ // Draw second hand // секундная стрелка
+ rads = (pi * secs*(-6)) / 180;
+ x = (int16_t)(ox + (110 * sin(rads) * (-1)));
+ y = (int16_t)(oy + (110 * cos(rads) * (-1)));
+ TFT.drawLine(ox, oy, x, y, RED, 1);
+ x = (int16_t)(ox + (20 * sin(rads)));
+ y = (int16_t)(oy + (20 * cos(rads)));
+ TFT.drawLine(ox, oy, x, y, RED, 1);
+ TFT.drawPoint(ox, oy, BLACK, 6);
+ TFT.drawPoint(ox, oy, WHITE, 4);
+
+ // Draw Time & Date // Время и дата
+ strftime(timebuff, 32, "%X", localtime(&seconds)); // Time
+ TFT.drawText(240,170, 29, DARKBLUE, OPT_CENTERX, timebuff);
+
+ strftime(timebuff, 32, "%A", localtime(&seconds)); // Weekday
+ TFT.drawText(420,25, 27, BLACK, OPT_CENTERX, timebuff);
+
+ strftime(timebuff, 32, "%d.%m.%Y", localtime(&seconds));// Date
+ TFT.drawText(420,50, 27, BLACK, OPT_CENTERX, timebuff);
+
+ sprintf(textbuff, "Mbed OS %d.%d.%d.", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
+ TFT.drawText(10, 25, 27, BLACK, OPT_FLAT, textbuff); // Mbed Version
+
+ TFT.DLend();
+
+ thread_sleep_for(1000); // 1000 ms
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Dec 10 16:32:55 2020 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#f2278567d09b9ae9f4843e1d9d393526b9462783
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json Thu Dec 10 16:32:55 2020 +0000
@@ -0,0 +1,8 @@
+{
+ "target_overrides": {
+ "*": {
+ "target.printf_lib" : "std",
+ "platform.stdio-convert-newlines" : 1
+ }
+ }
+}
\ No newline at end of file