I found a few topics in this forum on the SSD1306 with code that works on the FEZ Feather, among others, so I decided I would give it a try on my FEZ Duino. I copied some code and adjusted it so it would technically work on my device, but it throws an error and I cannot figure out exactly why. Using the step-by-step debugger of Visual Studio it appears that the issue happens somewhere in the creation of a new SSD1306Controller object, but that does not help me (a beginner) much…
The error:
The thread '<No Name>' (2) has exited with code 0 (0x0).
#### Exception System.Exception - CLR_E_TIMEOUT (1) ####
#### Message:
#### GHIElectronics.TinyCLR.Devices.I2c.Provider.I2cControllerApiWrapper::WriteRead [IP: 0000] ####
#### GHIElectronics.TinyCLR.Devices.I2c.I2cDevice::WriteRead [IP: 0027] ####
#### GHIElectronics.TinyCLR.Devices.I2c.I2cDevice::Write [IP: 000c] ####
#### GHIElectronics.TinyCLR.Drivers.SolomonSystech.SSD1306.SSD1306Controller::SendCommand [IP: 0012] ####
#### GHIElectronics.TinyCLR.Drivers.SolomonSystech.SSD1306.SSD1306Controller::Initialize [IP: 0009] ####
#### TinyCLROLED.Program::Main [IP: 0024] ####
Exception thrown: 'System.Exception' in GHIElectronics.TinyCLR.Devices.I2c.dll
An unhandled exception of type 'System.Exception' occurred in GHIElectronics.TinyCLR.Devices.I2c.dll
The code:
using GHIElectronics.TinyCLR.Devices.I2c;
using GHIElectronics.TinyCLR.Drivers.BasicGraphics;
using GHIElectronics.TinyCLR.Drivers.SolomonSystech.SSD1306;
using GHIElectronics.TinyCLR.Pins;
namespace OLED_Test
{
internal class Program
{
static void Main()
{
uint white = 0x00ffffffU;
I2cConnectionSettings ics = new I2cConnectionSettings(0x78, I2cAddressFormat.SevenBit, 400_000U);
I2cController i2CController = I2cController.FromName(SC20100.I2cBus.I2c2);
I2cDevice device = i2CController.GetDevice(ics);
SSD1306Controller ctl = new SSD1306Controller(device);
var basicGfx = new BasicGraphics(128, 64, ColorFormat.OneBpp);
basicGfx.Clear();
basicGfx.DrawString("Test", white, 0, 0, 2, 8);
ctl.DrawBufferNative(basicGfx.Buffer);
}
}
}