I have tried to port Arduino library for this LCD with success. Only the LCD part works, not the joystick due to maximum 3.3v netduino use on Analogue pin.
Here is the library (Nokia3310.cs) :
using System; using System.Threading; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace Shield { class Nokia3310 { public byte[][] font6_8 = new byte[][] { new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // sp new byte[] { 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 }, // ! new byte[] { 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 }, // " new byte[] { 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 }, // # new byte[] { 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, // $ new byte[] { 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 }, // % new byte[] { 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 }, // & new byte[] { 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 }, // ' new byte[] { 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 }, // ( new byte[] { 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 }, // ) new byte[] { 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, // * new byte[] { 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, // + new byte[] { 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, // , new byte[] { 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, // - new byte[] { 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, // . new byte[] { 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, // / new byte[] { 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E }, // 0 new byte[] { 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 }, // 1 new byte[] { 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 }, // 2 new byte[] { 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 }, // 3 new byte[] { 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 }, // 4 new byte[] { 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 }, // 5 new byte[] { 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 }, // 6 new byte[] { 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 }, // 7 new byte[] { 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 }, // 8 new byte[] { 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E }, // 9 new byte[] { 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 }, // : new byte[] { 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 }, // ; new byte[] { 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 }, // < new byte[] { 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 }, // = new byte[] { 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 }, // > new byte[] { 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 }, // ? new byte[] { 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E }, // @ new byte[] { 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C }, // A new byte[] { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 }, // B new byte[] { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 }, // C new byte[] { 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C }, // D new byte[] { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 }, // E new byte[] { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 }, // F new byte[] { 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A }, // G new byte[] { 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F }, // H new byte[] { 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 }, // I new byte[] { 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 }, // J new byte[] { 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 }, // K new byte[] { 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 }, // L new byte[] { 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F }, // M new byte[] { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F }, // N new byte[] { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E }, // O new byte[] { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 }, // P new byte[] { 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E }, // Q new byte[] { 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 }, // R new byte[] { 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 }, // S new byte[] { 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 }, // T new byte[] { 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F }, // U new byte[] { 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F }, // V new byte[] { 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F }, // W new byte[] { 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 }, // X new byte[] { 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 }, // Y new byte[] { 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 }, // Z new byte[] { 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 }, // [ new byte[] { 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 }, // 55 new byte[] { 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 }, // ] new byte[] { 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 }, // ^ new byte[] { 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 }, // _ new byte[] { 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 }, // ' new byte[] { 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 }, // a new byte[] { 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 }, // b new byte[] { 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 }, // c new byte[] { 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F }, // d new byte[] { 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 }, // e new byte[] { 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 }, // f new byte[] { 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C }, // g new byte[] { 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 }, // h new byte[] { 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 }, // i new byte[] { 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 }, // j new byte[] { 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 }, // k new byte[] { 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 }, // l new byte[] { 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 }, // m new byte[] { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 }, // n new byte[] { 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 }, // o new byte[] { 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 }, // p new byte[] { 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC }, // q new byte[] { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 }, // r new byte[] { 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 }, // s new byte[] { 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 }, // t new byte[] { 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C }, // u new byte[] { 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C }, // v new byte[] { 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C }, // w new byte[] { 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 }, // x new byte[] { 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C }, // y new byte[] { 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 }, // z new byte[] { 0x00,0x00, 0x06, 0x09, 0x09, 0x06 } // horiz lines }; public SPI.Configuration conf; public SPI SPI_port; public OutputPort RST = new OutputPort(Pins.GPIO_PIN_D9, false); public OutputPort DC = new OutputPort(Pins.GPIO_PIN_D8, false); public OutputPort BL = new OutputPort(Pins.GPIO_PIN_D7, false); public Nokia3310() { Init(); } void Init() { conf = new SPI.Configuration(Pins.GPIO_PIN_D10, false, 0, 0, false, true, 1000, SPI.SPI_module.SPI1); SPI_port = new SPI(conf); Reset(); Write_Cmd(new byte[1] { 0x21 }); Write_Cmd(new byte[1] { 0xc0 }); Write_Cmd(new byte[1] { 0x06 }); Write_Cmd(new byte[1] { 0x13 }); Write_Cmd(new byte[1] { 0x20 }); Clear(); Write_Cmd(new byte[1] { 0x0c }); } public void Leds(bool On) { BL.Write(On); } void Write_Cmd(byte[] Cmd) { DC.Write(false); SPI_port.Write(Cmd); } void Write_Data(byte[] Data) { DC.Write(true); SPI_port.Write(Data); } void Reset() { RST.Write(false); Thread.Sleep(200); RST.Write(true); Thread.Sleep(200); } public void Clear() { ushort i; Set_XY(0, 0); for (i = 0; i < 504; i++) Write_Data(new byte[1] {0x00}); Set_XY(0, 0); } public void Set_XY(byte X, byte Y) { Write_Cmd(new Byte[1] { (byte)(0x40 | Y) }); // column Write_Cmd(new Byte[1] { (byte)(0x80 | X) }); // row } public void Write_Char(char c, bool highlight) { byte line; byte ch; byte a = (byte)((byte)c - 32); for (line = 0; line < 6; line++) { ch = font6_8[a][line]; ch = highlight ? ch : (byte)(ch ^ (byte)0xff); Write_Data(new byte[1] { ch }); } } public void Draw_Bmp_Pixel(byte X, byte Y, byte[] map, byte Pix_x, byte Pix_y) { ushort i, n; byte row; if (Pix_y % 8 == 0) row = (byte)(Pix_y / 8); else row = (byte)(Pix_y / 8 + 1); for (n = 0; n < row; n++) { Set_XY(X, Y); for (i = 0; i < Pix_x; i++) { Write_Data(new byte[1] { map[i + n * Pix_x] }); } Y++; } } } }
Here a the sample of use (Program.cs) :
using System.Threading; namespace NetduinoNokia3310 { public class Program { static byte[] AVR_bmp = { 0x00,0x00,0x00,0x00,0x80,0xE0,0xFC,0xFF,0xFF,0xFF,0x7F,0xFF,0xFE,0xFC,0xF0,0xC1, 0x0F,0x7F,0xFF,0xFF,0xFE,0xF0,0xC0,0x00,0x00,0x00,0xC0,0xF8,0xFE,0xFF,0xFF,0x3F, 0x07,0xC1,0xF0,0xFE,0xFF,0xFF,0xFF,0x1F,0x07,0x8F,0xCF,0xFF,0xFF,0xFF,0xFE,0xFC, 0x00,0x80,0xF0,0xFC,0xFF,0xFF,0xFF,0x7F,0x7F,0x78,0x78,0x79,0x7F,0x7F,0xFF,0xFF, 0xFC,0xF0,0xC1,0x07,0x1F,0xFF,0xFF,0xFE,0xFC,0xFF,0xFF,0xFF,0x1F,0x07,0xC1,0xF0, 0xFE,0xFF,0xFF,0x3F,0x0F,0x0F,0x7F,0xFF,0xFF,0xFF,0xFF,0xE7,0x07,0x03,0x01,0x00, 0x02,0x03,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0x03,0x03,0x03,0x03,0x00,0x00,0x03,0x1F,0x3F,0x1F,0x07,0x00,0x00,0x02,0x03,0x03, 0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x00,0x00,0x00 }; public static void Main() { Shield.Nokia3310 LCD = new Shield.Nokia3310(); LCD.Leds(true); byte i, j; for (i = 0; i < 6; i++) { for (j = 0; j < 14; j++) { LCD.Set_XY((byte)(j * 6), (byte)i); LCD.Write_Char((char)((byte)(i * 14 + j + 32)), true); } } Thread.Sleep(5000); LCD.Clear(); LCD.Draw_Bmp_Pixel(20, 1, AVR_bmp, 48, 24); Thread.Sleep(5000); LCD.Leds(false); } } }
It would nice to have a Netduino bmp instead of AVR
Enjoy,
Pascal