Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Need help with i2c matrix display


  • Please log in to reply
3 replies to this topic

#1 Gino Geusens

Gino Geusens

    New Member

  • Members
  • Pip
  • 4 posts

Posted 07 May 2013 - 06:37 PM

Hello everyone,

 

Let me begin by saying that i:

  • am a complete beginner at programming and the entire duino familiy.
  • and i am not a native engish speaker, so i am sorry for any inconsistancies.
  • am not new to electronics, that is why i want to start with some more versatile sollutions as well.

i aquired several adafruit i2c matrix display's

 

http://learn.adafrui.../1-2-8x8-matrix

http://www.adafruit....051#Description

 

and am trying to make a driver that works with it, and failling horribly at it :)

 

i made this as simple as possible just to try and see if i can get the display to light up.

 

it doesnt work.

using System;using System.Net;using System.Net.Sockets;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace I2C_matrix_display_test{    public class Program    {        public static void Main()        {            var MatrixDisplay1 = new I2CDevice(new I2CDevice.Configuration(0x70,100));            byte Oscillator = 0x21; // turn on oscillator            byte SetDisplay = 0x81; //enable display, no blink            byte SetBrightness = 0xEF; //Full brightness            byte Address = 0x00; // first write adress            byte WriteData = 0xFF; // Display data            byte[] EnableOscillator = { Oscillator };            byte[] EnableDisplay = { SetDisplay };            byte[] Brightness = { SetBrightness };            byte[] WriteToFirstAddress = { Address };            byte[] WriteToDisplay = { WriteData };            I2CDevice.I2CTransaction[] ActionWrite = new I2CDevice.I2CTransaction[]            {                I2CDevice.CreateWriteTransaction(EnableOscillator),                I2CDevice.CreateWriteTransaction(EnableDisplay),                I2CDevice.CreateWriteTransaction(Brightness),                I2CDevice.CreateWriteTransaction(WriteToFirstAddress),                I2CDevice.CreateWriteTransaction(WriteToDisplay),                I2CDevice.CreateWriteTransaction(WriteToDisplay),                I2CDevice.CreateWriteTransaction(WriteToDisplay),                I2CDevice.CreateWriteTransaction(WriteToDisplay),                I2CDevice.CreateWriteTransaction(WriteToDisplay),                I2CDevice.CreateWriteTransaction(WriteToDisplay),                I2CDevice.CreateWriteTransaction(WriteToDisplay),                I2CDevice.CreateWriteTransaction(WriteToDisplay),            };            MatrixDisplay1.Execute(ActionWrite, 1000);        }    }}

according to the origina C++ source

https://github.com/a...ackpack-Library

i should in the following steps get something

  • enable oscillator
  • enable display
  • set brightness
  • point to the write address
  • fill with data

 

can someone point me in the right direction where to look next ? because im not very famlilar with c++ code as well :unsure:

 

or if someone knows of a pre existing driver (i searched but found nothing).

 

extra info:

 


    [*]i have a netduino plus 2 with the latest firmware update
    [*]the board seems to have internal pull ups,
    [*]i have connected it directly to the sc and sd pins.
    [/list]

     

    Thank you for any help you might be able to offer.

     

    Kind regards,



#2 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 07 May 2013 - 09:50 PM

i think you have to write each command seperate, not all at once like this.

 

best would be using a i2c library like netmf-toolbox'es or the one from the link in my signature.



#3 Gino Geusens

Gino Geusens

    New Member

  • Members
  • Pip
  • 4 posts

Posted 08 May 2013 - 09:50 PM

I got the display to light up, but no matter wat data i present, it looks like nothing but random leds on the display.

(always the same pattern no matter the data)

 

here is the code, i am still use the standard i2c library though

using System;using System.Net;using System.Net.Sockets;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace I2C_matrix_display_test{    public class Program    {        public static void Main()        {            var MatrixDisplay1 = new I2CDevice(new I2CDevice.Configuration(0x70,100));            byte Oscillator = 0x21; // turn on oscillator            byte SetDisplay = 0x81; //enable display, no blink            byte SetBrightness = 0xE4; //Full brightness            byte Address = 0x00; // first write adress            byte[] WriteDataArray = { 0x3C , 0x42 , 0xA5 , 0x81 , 0xA5 , 0x99 , 0x42 , 0x3C}; // data for display            byte[] EnableOscillator = { Oscillator };            byte[] EnableDisplay = { SetDisplay };            byte[] Brightness = { SetBrightness };            byte[] WriteToFirstAddress = { Address };            I2CDevice.I2CTransaction[] EnableOsc = new I2CDevice.I2CTransaction[]            {                I2CDevice.CreateWriteTransaction(EnableOscillator),            };            I2CDevice.I2CTransaction[] EnableDisp = new I2CDevice.I2CTransaction[]            {                I2CDevice.CreateWriteTransaction(EnableDisplay),            };            I2CDevice.I2CTransaction[] SetBright = new I2CDevice.I2CTransaction[]            {                I2CDevice.CreateWriteTransaction(Brightness),            };            I2CDevice.I2CTransaction[] SetFirstRegister = new I2CDevice.I2CTransaction[]            {                I2CDevice.CreateWriteTransaction(WriteToFirstAddress),            };            I2CDevice.I2CTransaction[] WriteDispData = new I2CDevice.I2CTransaction[]            {                I2CDevice.CreateWriteTransaction(WriteDataArray),            };            MatrixDisplay1.Execute(EnableOsc, 1000);            MatrixDisplay1.Execute(EnableDisp, 1000);            MatrixDisplay1.Execute(SetBright, 1000);            MatrixDisplay1.Execute(SetFirstRegister, 1000);            MatrixDisplay1.Execute(WriteDispData, 1000);        }    }}

What am i still doing wrong ?

 

 i guess i still need to convert this part to c#, but have no idea how to.

 

i am however presenting data so the leds should change...

//in the .h fileuint16_t displaybuffer[8]; //in the C++ file  for (uint8_t i=0; i<8; i++) {    Wire.write(displaybuffer[i] & 0xFF);    Wire.write(displaybuffer[i] >> 8);  }


#4 Gino Geusens

Gino Geusens

    New Member

  • Members
  • Pip
  • 4 posts

Posted 09 May 2013 - 09:17 AM

im now using the NETMF toolbox, however the result is the same

 

Here is the code i am using now

using System;using System.Net;using System.Net.Sockets;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;using Toolbox.NETMF.Hardware;namespace I2C_matrix_display_test{    public class Program    {        public static void Main()        {            MultiI2C MatrixTest = new MultiI2C(0x70, 100);            ushort[] WriteDataArray = new ushort[8] { 0x3C , 0x42 , 0xA5 , 0x81 , 0xA5 , 0x99 , 0x42 , 0x3C}; // data for display            MatrixTest.Write(new byte[] { 0x21 }); //turn on oscillator            MatrixTest.Write(new byte[] { 0x81 }); //0x81 = enable display with no blink            MatrixTest.Write(new byte[] { 0xE4 }); //set brightness            MatrixTest.Write(new byte[] { 0x00 }); //define first write register           for (byte i = 0; i < 8; i++)            {                MatrixTest.Write(WriteDataArray[i]);           };        }    }}

however i cannot write data, when i try to convert the c++ code it tells me

 

Error  1  The best overloaded method match for 'Toolbox.NETMF.Hardware.MultiI2C.Write(ushort[])' has some invalid arguments

Error  2  Argument 1: cannot convert from 'ushort' to 'ushort[]'

 

if i do it exactly like the c++ code

           for (byte i = 0; i < 8; i++)            {                MatrixTest.Write(WriteDataArray[i] & 0xFF);                MatrixTest.Write(WriteDataArray[i] >> 8);           };

i get the following errors

 

Error  1  The best overloaded method match for 'Toolbox.NETMF.Hardware.MultiI2C.Write(ushort[])' has some invalid arguments Error  2  Argument 1: cannot convert from 'int' to 'ushort[]' Error  3  The best overloaded method match for 'Toolbox.NETMF.Hardware.MultiI2C.Write(ushort[])' has some invalid arguments Error  4  Argument 1: cannot convert from 'int' to 'ushort[]'  

 

i can disable or enable the device, set brightness and make it blink, so it is accepting the commands i write to it.

however i cannot seem to write any data to it.

 

Any help would be greatly appriciated.

 

Kind regards,






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.