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.
Dependencies: mbed
main.cpp
00001 // ****** Henrique ****** 24/04/21 00002 // Escrevendo um sinal analógico ( Seno e Cosseno) no display TFT 00003 // obs. Nesse código não sendo usado a função para limpar o display. 00004 // ************** Display TFT- ILI9341 Versão V 4************** \\ 00005 00006 00007 00008 00009 #include "Arduino.h" 00010 #include <MCUFRIEND_kbv.h> 00011 AnalogIn var (A5); 00012 MCUFRIEND_kbv tft; 00013 Serial pc(SERIAL_TX, SERIAL_RX); 00014 00015 // Tabela de cores 00016 #define BLACK 0x0000 00017 #define BLUE 0x001F 00018 #define RED 0xF800 00019 #define GREEN 0x07E0 00020 #define CYAN 0x07FF 00021 #define MAGENTA 0xF81F 00022 #define YELLOW 0xFFE0 00023 #define WHITE 0xFFFF 00024 #define GRAY 0x8410 00025 00026 int deslc = 0; 00027 00028 void setup() 00029 { 00030 uint16_t ID = tft.readID(); // 00031 tft.begin(ID); 00032 } 00033 00034 // Função para criação das linhas 00035 void linhas () 00036 { 00037 00038 tft.drawLine(95,350,95,0,GRAY); // valores das coordenadas e inclinação 00039 00040 tft.drawLine(45,350,45,0,GRAY); 00041 00042 } 00043 00044 00045 00046 void signal() 00047 { 00048 00049 00050 00051 tft.fillScreen(BLACK); // Tela de Fundo 00052 linhas(); 00053 double s; // Variável s e L com ponto flutuante com precisão 00054 double L; 00055 00056 while (1) { 00057 00058 pc.printf ("valor %d\n\r",deslc); 00059 delay(0.5); 00060 for (int i=0; i<360; i++) { 00061 deslc = var.read()*360; 00062 s =20 * sin((long double) deslc / 10); // Sinal com amplitude 20 00063 // Variável de precição amostrando o valor do pot. Valor 10 refere-se a expessura do sinal 00064 00065 L=20 * cos((long double) deslc / 10); 00066 tft.drawPixel(70 + (int)s,deslc,RED); // Função Pixel responsável por " escrever "o sinal com vários pontos no display 00067 // s convertido para int ; valor 70 é a referência de início do sinal 00068 00069 tft.drawPixel(70 + (int)L,deslc,BLUE); 00070 } 00071 00072 00073 } 00074 00075 00076 } 00077 00078 00079 int main() 00080 { 00081 00082 setup(); 00083 signal(); 00084 while(2) { 00085 00086 00087 00088 } 00089 00090 }
Generated on Tue Jul 12 2022 18:37:38 by
1.7.2