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

4-digit shield


  • Please log in to reply
18 replies to this topic

#1 Jonny Wire

Jonny Wire

    Member

  • Members
  • PipPip
  • 19 posts

Posted 15 November 2011 - 07:16 PM

Hi,

second post, first question...
I bought a 4-digit-shield and its a great device.

I want to set single LEDs. Its not so simple because the only way to do this are custom fonts.
OK, i wrote the .NET code after i read the arduino code.

Arduino:
                Wire.beginTransmission(_address); // transmit to device
                Wire.send(0x05);
                Wire.send(0x80);  //this is the address of the first custom character.  There are 24 of these.

                //each digit is 5x7
                Wire.send(B1000000);  //col1  show only 1 led this is what the 1 is for
                Wire.send(B0000000); //col2
                Wire.send(B0000000);
                Wire.send(B0000000);
                Wire.send(B0000000);//col5 all leds off

Netduino:
                byte[] fontA = new byte[]
                                        {
                                            0x05,
                                            0x80,
                                            40,

                                        };
                ds.device.Execute(new I2CDevice.I2CTransaction[] {
                I2CDevice.CreateWriteTransaction(fontA)
            }, ds.i2ctimeout);

                ds.device.Execute(new I2CDevice.I2CTransaction[] 
                                {
                                    I2CDevice.CreateWriteTransaction(new byte[] { (byte)MatrixUnit.A, 0x80 })
                                }, ds.i2ctimeout);

The Problem is, i dont know how to send the binary code-command.

Have anyone ideas?
Here a few examples using the 4-digit-shield:
dennisdel.com
Channel9

Thanks.

Greets Jonny

#2 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 15 November 2011 - 09:51 PM

You just need to translate the binary literals to decimal or hex literals - B1000000 is 0x40/64 (as you already have), the rest are zero, add those to the data array that you have (although i don't see the reason for your second execute - that doesn't have an analogy in the arduino part).
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#3 Jonny Wire

Jonny Wire

    Member

  • Members
  • PipPip
  • 19 posts

Posted 16 November 2011 - 06:50 AM

thx.

i found the same way, but i think its not the best...
i use a mapping table for hex <> binary. I wrote down the 7 (!) values of the state of the column.

byte[] font = new byte[]
                    {
                        0x05, // set font
                        0x80, // font RAM
                        0x63, // col 1
                        0x5D, // col 2 
                        0x3B, // col 3
                        0x5D, // col 4
                        0x63  // col 5
                    };

// set font
ds.device.Execute(new I2CDevice.I2CTransaction[]
                        {
                            I2CDevice.CreateWriteTransaction(font)
                        }, ds.i2ctimeout);

// set font to Unit
ds.device.Execute(new I2CDevice.I2CTransaction[]
                        {
                            I2CDevice.CreateWriteTransaction(new byte[] {(byte) MatrixUnit.A, 0x80})
                        }, ds.i2ctimeout);

Is there anyway to convert binary to hex? in this case its simpler.

But i got it to work to show my girlfriend hearts on the 4-digit at 2am ... :/

Hearts

Attached Files



#4 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 16 November 2011 - 11:15 AM

binary<->hex conversion is pretty simple, you take groups of 4 binary digits and convert them - you don't need to make a table for the whole byte - 0x78 is 0111 1000 in binary (you can convert the 7 and 8 seperately - works because 16 is a power of 2).
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#5 Jonny Wire

Jonny Wire

    Member

  • Members
  • PipPip
  • 19 posts

Posted 16 November 2011 - 11:35 AM

yes thats true and i know that ... but i dont know how to write down binary digits (bits) in C# and send to the driver.
I dont want to use hex ... because the digits have binary states.

for example, i want this arduino code in C# :)
Wire.send(B0000000);

thx.

Jonny

#6 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 16 November 2011 - 12:16 PM

but i dont know how to write down binary digits (bits) in C# and send to the driver.

Unfortunately, it is not possible to write binary numbers in C# directly - if you don't want to use hex, you can define constants like const byte B000000 = 0, const byte B00001111 = 0x0F etc. (or you can use enum).

#7 Jonny Wire

Jonny Wire

    Member

  • Members
  • PipPip
  • 19 posts

Posted 16 November 2011 - 01:18 PM

ok, i write a mapping class :) thx, i will post my result.

#8 Jonny Wire

Jonny Wire

    Member

  • Members
  • PipPip
  • 19 posts

Posted 16 November 2011 - 05:44 PM

I got it to run... for one digit :( I set one custom font for each digit... and then i set the custom font to the digit... But only the custom digit with adress 0x80 (first) runs. Set the 0x80 to an other digit it runs for this digit. I attached the project. Thx for response. Greets Jonny

Attached Files



#9 Jonny Wire

Jonny Wire

    Member

  • Members
  • PipPip
  • 19 posts

Posted 19 November 2011 - 07:49 PM

I don't get it to work. Only the first custom font is correct. All others shows single digits when i send 1111111. Anyone who have a 4-digit-shild? Thx Jonny

#10 ShieldStudio

ShieldStudio

    New Member

  • Members
  • Pip
  • 4 posts

Posted 28 November 2011 - 03:41 AM

Your loading of custom characters seem correct. The problems when you display the newly created characters the address is not 0x80, 0x85, 0x8A and 0x8F but rather RAM0x00 to RAM0x03 or to display the inverse use 0x80 to 0x83. The reason address 0x80 works because it is displaying your custom character at Font Address 0x00 with inverse set. For your code when you write 0x85 it displays junk in RAM05 - actually the inverse graphic of this. Same for 0x8A will display RAM10 which is a default font character. Let me know how it goes

#11 Jonny Wire

Jonny Wire

    Member

  • Members
  • PipPip
  • 19 posts

Posted 28 November 2011 - 08:07 AM

Thx for your help. But i dont know how to set the RAM for the Shield. I know only the way to set hex-adress which is not the font-adress. Have you a little samplecode how to load the font ram correctly? Greets from Bavaria/Germany. Jonny

#12 ShieldStudio

ShieldStudio

    New Member

  • Members
  • Pip
  • 4 posts

Posted 29 November 2011 - 01:23 AM

Jonny, Modify your ledmatrix.cs to look like this. I've added RAMAddres in the code below. So now RAM0 will write to MatrixUnit.Am RAM1 will write to MatrixUnit.B etc... public void WriteCustomFont(BinaryCode col1, BinaryCode col2, BinaryCode col3, BinaryCode col4, BinaryCode col5, MatrixUnit panel) { // select font for panel byte fontRam = new byte(); byte RAMAddress = 0; switch(panel) { case MatrixUnit.A: fontRam = 0x80; // custom font 1 RAMAddress = 0x00; break; case MatrixUnit.B: fontRam = 0x85; // custom font 2 RAMAddress = 0x01; break; case MatrixUnit.C: fontRam = 0x8A; // custom font 3 RAMAddress = 0x02; break; case MatrixUnit.D: fontRam = 0x8F; // custom font 4 RAMAddress = 0x03; break; } byte[] buffer = new byte[7]; buffer[0] = 0x05; // set font buffer[1] = fontRam; // font RAM buffer[2] = (byte)col1; // col 1 buffer[3] = (byte)col2; // col 2 buffer[4] = (byte)col3; // col 3 buffer[5] = (byte)col4; // col 4 buffer[6] = (byte)col5; // col 5 // initialisize font device.Execute(new I2CDevice.I2CTransaction[] { I2CDevice.CreateWriteTransaction(buffer) }, i2ctimeout); // set font device.Execute(new I2CDevice.I2CTransaction[] { I2CDevice.CreateWriteTransaction(new byte[] {(byte) panel, RAMAddress}) }, i2ctimeout); }

#13 Jonny Wire

Jonny Wire

    Member

  • Members
  • PipPip
  • 19 posts

Posted 29 November 2011 - 11:09 AM

Hi, thx a lot. Its looking to easy to be true :) I test it in the evening and give you feedback. thx. greets Jonny

#14 Jonny Wire

Jonny Wire

    Member

  • Members
  • PipPip
  • 19 posts

Posted 29 November 2011 - 08:16 PM

Hi,

sorry, its not working. i use your methode and set matrix A to:
ds.WriteCustomFont(BinaryCode.B1010101, BinaryCode.B1010101, BinaryCode.B1010101, BinaryCode.B1010101, BinaryCode.B1010101, MatrixUnit.A);

The shield is off.

When i read the documentation i understand it the other way (my first way to initialisize.
Driver documentation
--> page 18: this table i dont understand how i use it.

I hope i (we) get it to work.

Thx
Greets
Jonny

#15 ShieldStudio

ShieldStudio

    New Member

  • Members
  • Pip
  • 4 posts

Posted 30 November 2011 - 03:19 AM

I've posted a quick(not pretty) example for you to demonstrate how to use the Custom Font RAM. Please go the the download section on ShieldStudio.com Under the heading "ShieldStudio 4-digit Shield with Netduino" you will find "How to create custom characters using Netduino" Please let me know how it goes?

#16 Jonny Wire

Jonny Wire

    Member

  • Members
  • PipPip
  • 19 posts

Posted 30 November 2011 - 05:30 PM

Big THX. Its working with my code. I write a class to use it. I want to donate but you have no flattr/paypal. So i buy another 4-digit-shield :) Greets Jonny

#17 Jonny Wire

Jonny Wire

    Member

  • Members
  • PipPip
  • 19 posts

Posted 30 November 2011 - 09:09 PM

First example with animations :)

#18 ShieldStudio

ShieldStudio

    New Member

  • Members
  • Pip
  • 4 posts

Posted 01 December 2011 - 01:17 AM

Big THX.
Its working with my code.
I write a class to use it.

I want to donate but you have no flattr/paypal. So i buy another 4-digit-shield :)

Greets
Jonny


Glad I could help.

#19 Jonny Wire

Jonny Wire

    Member

  • Members
  • PipPip
  • 19 posts

Posted 05 December 2011 - 02:09 PM

I finished the first (quick n dirty) version of my Class.
Can be found here with example video --> Suplanus.de

I have few more ideas for coming versions :)

Greets
Johann




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.