Hi all,
I am having some problems converting a program from Panda III to Cobra III and I reckon I am missing something blindingly obvious that I just can’t see. I am hoping someone can help.
I use a 1.8" SPI LCD on a Panda III program that works well. It uses SPI1. Moving to the Cobra III, all the pins appear to be in the same place and the screen is identical, so I simply shift the pin references. But I can’t seem to get the display to show anything.
A quick demo code for the screen is below (in Cobra III form)
namespace NickLCDTest
{
using GHI.Pins;
using GHI.Processor;
using GHI.Utilities;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
using System.Threading;
public class Program
{
static SPI.Configuration MySPIConfig = new SPI.Configuration(FEZCobraIII.Gpio.D10, false, 0, 0, false, true, 40000, FEZCobraIII.SpiBus.Spi1);
static SPI MySPI = new SPI(MySPIConfig);
//static long StartMillis, EndMillis;
static Font smallFont = Resources.GetFont(Resources.FontResources.small);
static Font NinaFont = Resources.GetFont(Resources.FontResources.NinaB);
static Bitmap LogoBitmap = new Bitmap(Resources.GetBytes(Resources.BinaryResources.ReGenlogo), Bitmap.BitmapImageType.Gif);
static Bitmap bmp;
public static void Main()
{
Display.Type = Display.DisplayType.Spi;
Display.Width = 128;
Display.Height = 160;
Display.BitmapFormat = Bitmaps.Format.Bpp16RgbLe;
Display.CurrentRotation = Display.Rotation.Clockwise90;
//Display.CurrentRotation = Display.Rotation.Normal;
Display.SpiConfiguration = MySPIConfig;
Display.ControlPin = FEZCobraIII.Gpio.D9;
Display.ResetPin = FEZCobraIII.Gpio.D8;
Display.Save();
bmp = new Bitmap(160, 128);
ShowSplashScreen();
Thread.Sleep(3000);
ClearScreen();
ShowMainScreen();
}
public static void ClearScreen()
{
bmp.Clear();
bmp.Flush();
}
public static void ShowSplashScreen()
{
bmp.DrawRectangle(ColorUtility.ColorFromRGB(0, 0, 255), 5, 0, 0, 160, 128, 0, 0, ColorUtility.ColorFromRGB(255, 0, 0), 0, 0, ColorUtility.ColorFromRGB(0, 255, 0), 128, 160, 100);
bmp.DrawImage(55, 10, LogoBitmap, 0, 0, 50, 50);
bmp.Flush();
}
public static void ShowMainScreen()
{
bmp.DrawRectangle(ColorUtility.ColorFromRGB(0, 0, 255), 5, 0, 0, 160, 128, 0, 0, ColorUtility.ColorFromRGB(255, 0, 0), 0, 0, ColorUtility.ColorFromRGB(0, 255, 0), 128, 160, 100);
bmp.DrawImage(5, 5, LogoBitmap, 0, 0, 50, 50);
bmp.DrawText("A: Toggle CAN", smallFont, ColorUtility.ColorFromRGB(255, 255, 255), 60, 5);
bmp.DrawText("B: Run Var Config", smallFont, ColorUtility.ColorFromRGB(255, 255, 255), 60, 20);
bmp.DrawText("</>: PowerMode +/-", smallFont, ColorUtility.ColorFromRGB(255, 255, 255), 60, 35);
bmp.DrawText("Config:001X351SV12v5.iCAN", smallFont, ColorUtility.ColorFromRGB(255, 255, 255), 10, 60);
bmp.DrawText("CAN = Active", NinaFont, ColorUtility.ColorFromRGB(0, 0, 255), 10, 80);
//bmp.DrawText("B: Run Variant Config", NinaFont, ColorUtility.ColorFromRGB(0, 0, 255), 10, 90);
bmp.DrawText("PowerMode = 7", NinaFont, ColorUtility.ColorFromRGB(0, 0, 255), 10, 100);
bmp.Flush();
}
}
}
If I simply change the following lines
and
```cs
Display.ControlPin = FEZCobraIII.Gpio.D9;
Display.ResetPin = FEZCobraIII.Gpio.D8;
to
and
```cs
Display.ControlPin = FEZPandaIII.Gpio.D9;
Display.ResetPin = FEZPandaIII.Gpio.D8;
then it works perfectly on the Panda III.
Are there any differences in the SPI1 buses between the Panda III and Cobra III, that I may have missed?
Both are 3.3V logic. I am using 2016 R2 pre-release.
Any suggestions gratefully received!
Nick