TL:DR version - use spi.mode = 3For an Internet radio project, I wanted to display "Now Playing" information on a beautiful Samsung VFD sourced from adafruit.com. Adafruit has provided a nice arduino library for this display which I used as a starter set to translate into/build a python SPI-VFD class for the raspberry Pi.
I'm a complete noob at python but I tackled the translation of C code to python without too much trouble. I got things going in fairly short order after some google searches, was able to print "Hello, World!" However, the VFD was behaving a bit oddly on a few commands, the cursor. Well, you have to have a cursor to get to the second line, right?
Initially, I found a very useful thread on the raspberry Pi forum from poster bgreat on setting up a Nokia LCD to work with the Pi. That didn't fit my use case because it used more connections for SPI than the Samsung's three wires. It did give me a model of how to code for SPI on the Pi in general, however. The posting thread is also good for getting background on how to install/activate hardware SPI on the Pi.
But I hit a wall for a couple of weeks on fixing the cursor. I did a lot of searches based on guesses as to what the problem was. TTL voltage? Tried a 74HCT244 TTL up converter, same cursor result. Under-current flakiness? Used a 2A power supply and separate, powered hub. Same. Some kind of SPI under-run, tried sending extra dummy bytes, still flakey. Think, think, think!
In my googling, I tripped over a posting reference to 3-WIRE mode in SPI. Hmn... The Samsung VFD uses only three SPI connections. Look at the data sheet, there's just a quick, passing reference to "three wire serial interface" and nothing else said. OK, let's experiment!
thinkng the mode is either on/off. The python interpreter accepts that, but I still get the same flakey results. Go back and look at the SPI test program again. There's a case statement for mode that clearly says "3 #3-wire mode". Doh! Missed that.
spi.mode = 3