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 3:2d8f54d22dbd, committed 2021-04-27
- Comitter:
- henriquer
- Date:
- Tue Apr 27 21:18:52 2021 +0000
- Parent:
- 2:f603020cd6ec
- Commit message:
- Escrevendo um sinal analogico ( Seno e Cosseno) no display TFT
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Apr 22 16:06:53 2021 +0000
+++ b/main.cpp Tue Apr 27 21:18:52 2021 +0000
@@ -1,18 +1,18 @@
-// ****** Henrique ****** 22/04/21
-// Testanto funções Display
-// ************** Display TFT- ILI9341 Versão V 2 ************** \\
+// ****** Henrique ****** 24/04/21
+// Escrevendo um sinal analógico ( Seno e Cosseno) no display TFT
+// obs. Nesse código não sendo usado a função para limpar o display.
+// ************** Display TFT- ILI9341 Versão V 4************** \\
#include "Arduino.h"
#include <MCUFRIEND_kbv.h>
-
+AnalogIn var (A5);
MCUFRIEND_kbv tft;
-
Serial pc(SERIAL_TX, SERIAL_RX);
-//
+// Tabela de cores
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
@@ -23,7 +23,7 @@
#define WHITE 0xFFFF
#define GRAY 0x8410
-
+int deslc = 0;
void setup()
{
@@ -31,26 +31,60 @@
tft.begin(ID);
}
-void loop()
+ // Função para criação das linhas
+void linhas ()
{
+ tft.drawLine(95,350,95,0,GRAY); // valores das coordenadas e inclinação
+
+ tft.drawLine(45,350,45,0,GRAY);
- tft.fillScreen(BLACK);
- tft.setTextColor(RED);;
- tft.setCursor(30, 160);
- tft.setTextSize(3);
- tft.print("INSPER-LSM ");
- delay(5000);
}
+void signal()
+{
+
+
+
+ tft.fillScreen(BLACK); // Tela de Fundo
+ linhas();
+ double s; // Variável s e L com ponto flutuante com precisão
+ double L;
+
+ while (1) {
+
+ pc.printf ("valor %d\n\r",deslc);
+ delay(0.5);
+ for (int i=0; i<360; i++) {
+ deslc = var.read()*360;
+ s =20 * sin((long double) deslc / 10); // Sinal com amplitude 20
+ // Variável de precição amostrando o valor do pot. Valor 10 refere-se a expessura do sinal
+
+ L=20 * cos((long double) deslc / 10);
+ tft.drawPixel(70 + (int)s,deslc,RED); // Função Pixel responsável por " escrever "o sinal com vários pontos no display
+ // s convertido para int ; valor 70 é a referência de início do sinal
+
+ tft.drawPixel(70 + (int)L,deslc,BLUE);
+ }
+
+
+ }
+
+
+}
int main()
{
+
setup();
- while (1) {
- loop();
+ signal();
+ while(2) {
+
+
+
}
+
}
\ No newline at end of file