Moin Moin!
Ich möchte an meinem Raspi 3 dieses Display zum Laufen bringen: https://learn.adafruit.com/graphic-128x64-vfd / https://cdn-shop.adafruit.com/datasheets/GP9002A+Appnote.pdf Es ist ein vollgrafikfähiges VF-Display von Futaba, angesteuert via SPI und einen GPIO-Ausgang zum Ändern der Betriebsart (Kommando / Daten empfangen). Ein passendes Kabel habe ich gemäß o.a. Anleitung fabriziert (auch wenn sie sich auf einen Arduino bezieht) und ein wenig C++-Code geschrieben:
/* This program controls the Futaba GP9002A01A graphic VFD attached to the host via SPI link. */
#include <iostream>
#include <errno.h>
#include <wiringPi.h>
#include <wiringPiSPI.h>
#include <unistd.h>
using namespace std;
class vfd {
private:
static const int CHANNEL = 0; // SPI channel 0 means that we use pin CE0_N (#24) to address the display.
static const int CD_PIN = 0; // Additionally, our VFD requireds an extra GPIO input (here it's pin #11 aka WiringPi #0).
public:
// Initializes the display.
static int Initialize ()
{
int fd_spi;
int fd_gpio;
int result;
unsigned char buffer [100];
result = 0;
cout << "Initializing..." << endl ;
fd_gpio = wiringPiSetup();
if (fd_gpio == -1) cout << "GPIO setup error!! errno: " << errno << endl ;
else cout << "GPIO setup done. Handler: " << fd_gpio << endl;
fd_spi = wiringPiSPISetup(CHANNEL, 500000);
if (fd_spi == -1) cout << "SPI setup error!! errno: " << errno << endl ;
else cout << "SPI setup done. Handler: " << fd_spi << endl;
pinMode (CD_PIN, OUTPUT);
digitalWrite (CD_PIN, HIGH);
buffer [0] = 0x14; // Sets the operating mode of the display.
result = wiringPiSPIDataRW(CHANNEL, buffer, 1);
cout << "Verb: Display mode. Result: " << buffer << endl;
digitalWrite (CD_PIN, LOW);
buffer [0] = 0x10; // Green-white without grayscale.
wiringPiSPIDataRW(CHANNEL, buffer, 1);
cout << "Noun: Green-white. Result: " << buffer << endl;
digitalWrite (CD_PIN, HIGH);
buffer [0] = 0x06; // Clears the display.
wiringPiSPIDataRW(CHANNEL, buffer, 1);
cout << "Verb: Clear. Result: " << buffer << endl;
buffer [0] = 0x01; // Activates display buffer #1.
wiringPiSPIDataRW(CHANNEL, buffer, 1);
cout << "Verb: Activate buffer #1. Result: " << buffer << endl;
buffer [0] = 0x0E; // Sets the lower portion of the pixel address.
wiringPiSPIDataRW(CHANNEL, buffer, 1);
cout << "Verb: Set lower portion of pixel address. Result: " << buffer << endl;
digitalWrite (CD_PIN, LOW);
buffer [0] = 0x48; // address
wiringPiSPIDataRW(CHANNEL, buffer, 1);
cout << "Noun: 0x48. Result: " << buffer << endl;
buffer [0] = 0x0F; // Sets the upper portion of the pixel address.
wiringPiSPIDataRW(CHANNEL, buffer, 1);
cout << "Verb: Set upper portion of pixel address. Result: " << buffer << endl;
digitalWrite (CD_PIN, LOW);
buffer [0] = 0x00; // address
wiringPiSPIDataRW(CHANNEL, buffer, 1);
cout << "Noun: 0x00. Result: " << buffer << endl;
buffer [0] = 0x08; // Illuminates the selected pixel.
wiringPiSPIDataRW(CHANNEL, buffer, 1);
cout << "Verb: Illuminate the pixel. Result: " << buffer << endl;
digitalWrite (CD_PIN, LOW);
buffer [0] = 0x10; // pixel
wiringPiSPIDataRW(CHANNEL, buffer, 1);
cout << "Noun: 0x10. Result: " << buffer << endl;
if (fd_spi > -1 && fd_gpio > -1) cout << "Display ready." << endl ;
result = 0;
sleep (5);
return result;
}
static int DisplayChar ()
{
return 0;
}
static int DisplayPixel ()
{
return 0;
}
};
// Here we start runing the app.
int main ()
{
int ret;
ret = vfd::Initialize ();
return ret;
}
Alles anzeigen
Nur: Das Display zeigt nichts an! Ich habe schon die Pinbelegung und natürlich die SW gecheckt, doch alles, was ich zurückbekomme, ist ein unlesbarer Wust (8 Bytes) an Daten, welche mir der SPI-Anschluss zurückliefert. Der Trafo des Displays wird warm (die Kathoden werden also aufgeheizt), doch angezeigt wird nix. Könnte es vielleicht ein elektrisches Problem sein? Die +5V Vcc bekommt das Display über eine StromPi-Platine und ein zerlegtes USB-Kabel. Die habe ich verifizieren können: 5,6 V, von denen ~4,8 V am Display-Eingang ankommen. Ist vielleicht die Spannung vom SPI und GPIO-Anschluss das Problem? Der Raspi hat ja 3,3 V, der Arduino aber 5 V. Das Datenblatt des Displays nennt als min. High-Level 0,7 × Vcc, also 3,5 Volt. Knapp daneben also?!
Brauche ich damit einen Pegelwandler, um aus den 3,3-V-Signalen des Raspis 5-V-Signale zu machen? Diesen etwa: http://www.watterott.com/de/Level-Shifter Danke für jeden zweckdienlichen Tipp!