• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Arduino UNO z PC na Arduino+Serial.read+LCD-TFT Riverdi
#1
Witam.
Jestem początkującym użytkownikiem i moja wiedza na temat programowania jest prawie zerowa, więc serdecznie proszę o wyrozumiałość.

Używałem Arduino UNO + LCD 2x16 znaków do wyświetlania temperatury CPU oraz obciążenia.
Kod Arduino:
Kod:
#include <LiquidCrystal.h>
#include <Wire.h>

#define width 16
#define height 2

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
 Serial.begin(115200);
 lcd.begin(width, height);
}

void loop() {
 if (Serial.read() == 2) {
   for (int row = 0; row < height; row++) {
     lcd.setCursor(0, row);
     for (int col = 0; col < width; col++) {
       lcd.print(char(Serial.read()));
     }
   }
 }
}
Wszystko działa super :-)

Wpadłem na pomysł, aby wyświetlać więcej danych więc zakupiłem:

ARDUINO RIVERDI TFT SHIELD + RVT43ULFNWC01 - Wyświetlacz LCD-TFT Riverdi (4.3-calowy, 480x272, kontroler FT801

I tu zaczęły się problemy podstawowy przykład na FT801 "HelloWorld" wyświetla się prawidłowo, ale bladego pojęcia nie mam jak go zmusić do wyświetlenia danych które wysyłam z PC na Arduino.

Serdecznie proszę o podpowiedz jak przerobić ten kawałek kodu, aby zamiast "Hello World" wyświetlały się informacje które wysyłam z PC:
Kod:
void HelloWorld()
{
    /* Change the below string for experimentation */
    const char Display_string[12] = "Hello World";
    
    /* Display list to display "Hello World" at the centre of display area */
    FTImpl.DLStart();//start the display list. Note DLStart and DLEnd are helper apis, Cmd_DLStart() and Display() can also be utilized.
    FTImpl.ColorRGB(0xFF,0xFF,0xFF);//set the color of the string to while color
    FTImpl.Cmd_Text(FT_DISPLAYWIDTH/2, FT_DISPLAYHEIGHT/2, 29, FT_OPT_CENTER, Display_string);//display "Hello World at the center of the screen using inbuilt font handle 29 "
    FTImpl.DLEnd();//end the display list
    FTImpl.Finish();//render the display list and wait for the completion of the DL
}
Moje próby nic nie dają

Kod:
#include "SPI.h"
#include "Wire.h"
#include "FT_VM801B43.h"
FT801IMPL_SPI FTImpl(FT_CS_PIN,FT_PDN_PIN,FT_INT_PIN);

String inputString = "";         // a String to hold incoming data
bool stringComplete = false;  // whether the string is complete

//*********************************************************
int16_t BootupConfigure()
{
 uint32_t chipid = 0;
 FTImpl.Init(FT_DISPLAY_RESOLUTION);//configure the display to the WQVGA

 delay(20);//for safer side
 chipid = FTImpl.Read32(FT_ROM_CHIPID);
   
 /* Identify the chip */
 if(FT801_CHIPID != chipid)
 {
   Serial.print("Error in chip id read ");
   Serial.println(chipid,HEX);
   return 1;
 }
 
 /* Set the Display & audio pins */
 FTImpl.SetDisplayEnablePin(FT_DISPENABLE_PIN);
 FTImpl.SetAudioEnablePin(FT_AUDIOENABLE_PIN);
 FTImpl.DisplayOn();  
 FTImpl.AudioOn();    
 return 0;
}
//***********************************************************


void setup() {
 BootupConfigure();
 // initialize serial:
 Serial.begin(9600);
 
 // reserve 200 bytes for the inputString:
 inputString.reserve(200);
}

void loop() {
 // print the string when a newline arrives:
 if (stringComplete) {
   Serial.println(inputString);
 
   // clear the string:
   inputString = "";
   stringComplete = false;
 }
 serialEvent();
}

/*
 SerialEvent occurs whenever a new data comes in the hardware serial RX. This
 routine is run between each time loop() runs, so using delay inside loop can
 delay response. Multiple bytes of data may be available.
*/
void serialEvent() {
 while (Serial.available()) {
   // get the new byte:
   char inChar = Serial.read();
   // add it to the inputString:
   inputString += inChar;
   // if the incoming character is a newline, set a flag so the main loop can
   // do something about it:
   if (inChar == '\n') {
     stringComplete = true;
//**********************************************************      
 //const char Display_string[12] = "Test";

 FTImpl.DLStart();
 FTImpl.ColorRGB(0xFF,0xFF,0xFF);
 FTImpl.Cmd_Text(FT_DISPLAYWIDTH/2, FT_DISPLAYHEIGHT/2, 29, FT_OPT_CENTER, inChar);
 //FTImpl.Cmd_Text(FT_DISPLAYWIDTH/2, FT_DISPLAYHEIGHT/2, 29, FT_OPT_CENTER, Display_string);
 FTImpl.DLEnd();
 FTImpl.Finish();
//**********************************************************    
   }
 }
}

Na wyświetlaczu widać jakieś zapalone pixele.
Jeszcze raz serdecznie proszę o pomoc.
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości