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.
Okay, I moved the bitmap code into its own class (BMap), added a Rect() procedure and cleaned it up a bit and removed any code that was not relevant to the task at hand.
Hey Alfred,
I was wondering how I could change an (x,y) directly to the index of the byte[504] where that would fall.... I've been trying to figure it out but I cant. so (0,0) would return 0, (83, 0) would return 83, (0, 1) would return 0 ... and (83, 47) would return 504. any clue? I'm still working on it, but I can't get it to work!
Hi I'd just like to thank the above users for working out how to get this display to work - Mine arrived yesterday and works perfectly for text. I'm playing with BMPs now..
AlfredBr and OMAR,
i have been using this LCD for a while now it it works great. Thanks for all that hard work you have done to get it working!!
have a question though. does anyone know of a way to release D12 from the SPI since it is not being used by the LCD? I have been working on a project for a while and just discovered that I really need that I/O port (cause all the others are full )
Also I would like to avoid having to get an I/O Shield but if do, can you set interrupts on those pins or only those pis native tot he netduino?
Thanks,
Jarrod
have a question though. does anyone know of a way to release D12 from the SPI since it is not being used by the LCD? I have been working on a project for a while and just discovered that I really need that I/O port (cause all the others are full )
You _might_ be able to modify the core C firmware to support this. We've never tried that...
Also I would like to avoid having to get an I/O Shield but if do, can you set interrupts on those pins or only those pis native tot he netduino?
It depends on the I/O shield and its driver. If the I/O shield has an "interrupt pin" and the interrupt functionality is included in the driver, then you should be set.
Just a quick fyi guys - I've managed to brick my 5110 LCD whilst soldering header pins on. I'm assuming the heat did it, but I've never had this happen to me before.
I didn't realise the LCD came off the breakout board as easily as it does (just the 4 metal tabs on the casing) until after it stopped working , but it may be an idea to remove it whilst soldering if anyone is considering this.
Alex
Just a quick fyi guys - I've managed to brick my 5110 LCD whilst soldering header pins on. I'm assuming the heat did it, but I've never had this happen to me before.
Wow - it's really hard to imagine that enough heat would make it down the thin PCB traces and onto the LCD to damage anything like that. Unless one or more traces just flat out broke maybe?
Now, on the other hand, static could certainly do that...
I didn't realise the LCD came off the breakout board as easily as it does (just the 4 metal tabs on the casing) until after it stopped working , but it may be an idea to remove it whilst soldering if anyone is considering this.
I haven't taken mine off the board yet - I'm imagining it has one of those spongy-foam type elatomeric connectors between the LCD glass and the breakout board, is that right? I also notice (and someone here or elsewhere commented) that the board "bows" away from the LCD glass along the "upper" edge of the LCD. I'm assuming this is the edge nearest the elastomeric strip, and this is what's putting the bowing force on the breakout board. I wish they had added one more hold-down tab to the metal bracket/frame along that top edge, which would have mitigated the bowing. I know a couple of signal traces run straight through there, but they could have routed around the tab.
Alfred - my thanks to you and others who figured out these details - your work helped me get mine going.
Two comments about this initialization sequence:
(1) I find that the 0x0C byte I have marked with "NOTE 1" in your listing above is spurious, and has no effect. At this time in your init sequence, you are in extended command mode, and according to the Table 1 instruction set in the PDC8544 datasheet, a 0x0C command in the H=1 extended command mode falls under a "Reserved - do not use" function. (Any byte of binary 0b00001XXX.) It probably doesn't hurt, but it is marked as a reserved command under this command set. It's the 0x0C you send after going back to the basic instruction set (with the 0x20 byte) that properly ensures the display is in normal mode.
(2) For anyone trying to get this display going with this command string, if you try it and still don't see anything on the display, try varying the LCD Vop parameter (shown as 0xBf in the sequence above.) Operating around VDD=3.20 V, and after what I thought was a proper initialization sequence, my display had appeared almost completely blank with the 0xBF parameter - I was just barely able to see a little flickering of the entire display area with a bright light reflecting off it at a high angle - but at least this gave me hope that something was going on. Trying different Vop values got it dialed in, and in my case, I found Vop=0xB3 to give me a very nice contrast display.
So, if your display is intializing to all-black or all-blank, try playing with that Vop parameter.
Hi Shannon,
Are you running your code in the emulator or in Visual Studio?
It appears that Visual Studio is looking for the PWM managed code source. You can download that from the downloads page to make it happy if you'd like Not sure why it would want that--but you should be able to skip it as well.
Welcome to the Netduino community,
Chris
Are you running your code in the emulator or in Visual Studio?
It appears that Visual Studio is looking for the PWM managed code source. You can download that from the downloads page to make it happy if you'd like Not sure why it would want that--but you should be able to skip it as well.
Welcome to the Netduino community,
Chris
Chris,
I am running the code in Visual Studio and sending it to the netduino.
On downloads page it states:
● pwm beta C++ code coming soon
There is not a link. Am I not looking in the correct spot?
Need help. I am using pcd8544 lcd from nokia 3310. i get text to lcd, but it shows to dark. how contrast is adjusted? tried to set Vop to 0x80 (10000000), didn't helped..
if i adjust Vcc to ~ 3V, lcd has good contrast. but i think it should work from 3.3V :/
I made it out.. destroyed another nokia and new lcd works great, i can control contrast.. well who could know..
In following AlfredBr's code [HERE] I have this board wired like this:
Nokia Pin 1: Netduino Gnd
Nokia Pin 2: Netduino 3.3v
Nokia Pin 3: Empty
Nokia Pin 4: Empty
Nokia Pin 5: D1
Nokia Pin 6: D8
Nokia Pin 7: D1
Nokia Pin 8: D5
I am no longer getting the PWM.cs error, but I still cannot get this display to work. I do see the backlight come on when I load the program to debug, but nothing is being drawn on the screen.
Is there anything else I should be looking at? This hardware stuff is totally new to me.
@K0demonkey
It seems your wiring is not quite correct.
Pins 3 and 4 on the LCD are the clock pin and the data pin, you definitely need those to send data to the display.
They need to be connected to the SPI clock pin (Netduino PIN 13) and the SPI MOSI pin (Netduino PIN 11).
It seems your wiring is not quite correct.
Pins 3 and 4 on the LCD are the clock pin and the data pin, you definitely need those to send data to the display.
They need to be connected to the SPI clock pin (Netduino PIN 13) and the SPI MOSI pin (Netduino PIN 11).
THANK YOU!
My next question is ... how do I print text to the screen?
I've tried Omar's code,
public class Nokia_5110
{
private bool[] _offRow = new bool[84];
private readonly byte[] _pow = new byte[] { 1, 2, 4, 8, 16, 32, 64, 128 };
private OutputPort _resetPort, _daComPin;
private PWM _backlightPort;
private SPI _dataPort;
public bool[][] _pixelMap = new bool[48][];
private byte[] _byteMap = new byte[504];
private uint _backlight = 0;
private bool _invd = false, _autoRefresh = true;
public Nokia_5110(Cpu.Pin chipSelect = Pins.GPIO_PIN_D3, Cpu.Pin backlight = Pins.GPIO_PIN_D9,
Cpu.Pin reset = Pins.GPIO_PIN_D7, Cpu.Pin dataCommand = Pins.GPIO_PIN_D8)
{
SPI.Configuration spiConfiguration = new SPI.Configuration(
chipSelect, // chip select port
false, // IC is accessed when chip select is low
0, // setup time 1 ms
0, // hold chip select 1 ms after transfer
false, // clock line is low if device is not selected
true, // data is sampled at leading edge of clock
2000, // clockrate is 15 MHz
SPI.SPI_module.SPI1 // use first SPI bus
);
_dataPort = new SPI(spiConfiguration);
_backlightPort = new PWM(backlight);
_resetPort = new OutputPort(reset, true);
_daComPin = new OutputPort(dataCommand, true);
Initialize();
Clear();
}
private void Initialize()
{
_resetPort.Write(false);
_resetPort.Write(true);
DataMode = false;
_dataPort.Write(new byte[] { 0x21, 0xBF, 0x04, 0x14, 0x0C, 0x20, 0x0C });
DataMode = true;
Clear();
}
public void SetCursor(float x, float y)
{
DataMode = false;
_dataPort.Write(new byte[] { (byte)(0x80 | (int)(x * 4)), (byte)(0x40 | (int)(y)) });
DataMode = true;
}
public void WriteText(string text, bool noSpace = true)
{
DataMode = true;
if (noSpace)
foreach (char c in text.ToCharArray())
_dataPort.Write(NokiaCharacters.ASCII[c - 0x20]);
else
{
byte[] letter = new byte[6];
foreach (char c in text.ToCharArray())
{
for (int i = 0; i < 5; i++)
letter[i] = NokiaCharacters.ASCII[c - 0x20][i];
letter[5] = 0x00;
_dataPort.Write(letter);
}
}
}
public void DrawRectangle(int x, int y, int width, int height, bool filled)
{
// thats what lines are for! oh right... I need to make a Draw line method...
if (width <= 1 || height <= 1)
return;
int endX = x + width, endY = y + height - 2;
bool[] line = new bool[84];
for (int p = x; p < endX; p++)
line[p] = true;
_pixelMap[y] = line;
_pixelMap[endY] = line;
if (!filled)
{
line = new bool[84];
line[x] = true;
line[endX - 1] = true;
}
for (int h = y + 1; h < endY; h++)
_pixelMap[h] = line;
if (AutoRefresh)
Refresh();
}
public void Refresh()
{
int byteID = 0;
for (int y = 0; y < 6; y++)
{
for (int x = 0; x < 84; x++)
{
_byteMap[byteID] = ConvertToByte(_pixelMap[y * 8][x], _pixelMap[y * 8 + 1][x],
_pixelMap[y * 8 + 2][x], _pixelMap[y * 8 + 3][x], _pixelMap[y * 8 + 4][x],
_pixelMap[y * 8 + 5][x], _pixelMap[y * 8 + 6][x], _pixelMap[y * 8 + 7][x]);
byteID++;
}
}
_dataPort.Write(_byteMap);
SetCursor(0, 0);
}
private byte ConvertToByte(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7)
{
byte result = 0;
result += (byte)((b7) ? _pow[7] : 0);
result += (byte)((b6) ? _pow[6] : 0);
result += (byte)((b5) ? _pow[5] : 0);
result += (byte)((b4) ? _pow[4] : 0);
result += (byte)((b3) ? _pow[3] : 0);
result += (byte)((b2) ? _pow[2] : 0);
result += (byte)((b1) ? _pow[1] : 0);
result += (byte)((b0) ? _pow[0] : 0);
return result;
}
public void Clear()
{
for (int r = 0; r < 48; r++)
_pixelMap[r] = _offRow;
if (_autoRefresh)
Refresh();
}
private void Inverse(bool inverse)
{
_invd = inverse;
DataMode = false;
_dataPort.Write(inverse ? new byte[] { 0x0D } : new byte[] { 0x0C });
DataMode = true;
}
public bool InverseColors
{
get { return _invd; }
set { Inverse(value); }
}
private bool DataMode
{
get { return _daComPin.Read(); }
set { _daComPin.Write(value); }
}
public uint BacklightBrightness
{
get
{ return _backlight; }
set
{
if (value > 100)
value = 100;
_backlightPort.SetDutyCycle(value);
_backlight = 100;
}
}
public bool AutoRefresh
{
get { return _autoRefresh; }
set { _autoRefresh = value; }
}
}
but the dev environment is complaining that NokiaCharacters does not exist in the current context.