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

Why is this not working? V C# 2010 with Netduino 2.


  • Please log in to reply
4 replies to this topic

#1 david98xp

david98xp

    Advanced Member

  • Members
  • PipPipPip
  • 57 posts

Posted 05 December 2014 - 07:16 PM

Link:http://netduinohelpe...er:AdaFruit7565

Error on the public class with this AdaFruitSSD1306 thingy here...

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

namespace netduino.helpers.Hardware {
    // Based on https://github.com/adafruit/ST7565-LCD
    public class AdaFruit7565 : AdaFruitSSD1306 {
        new public enum Command {
            DisplayOff = 0xAE,
            DisplayOn = 0xAF,
            DisplayStartLine = 0x40,
            PageAddress = 0xB0,
            ColumnAddressHigh = 0x10,
            ColumnAddressLow = 0x00,
            AdcSelectNormal = 0xA0, // X axis flip OFF
            AdcSelectReverse = 0xA1, // X axis flip ON
            DisplayVideoNormal = 0xA6,
            DisplayVideoReverse = 0xA7,
            AllPixelsOff = 0xA4,
            AllPixelsOn = 0xA5,
            LcdVoltageBias9 = 0xA2,
            LcdVoltageBias7 = 0xA3,
            EnterReadModifyWriteMode = 0xE0,
            ClearReadModifyWriteMode = 0xEE,
            ResetLcdModule = 0xE2,
            ShlSelectNormal = 0xC0, // Y axis flip OFF
            ShlSelectReverse = 0xC8, // Y axis flip ON
            PowerControl = 0x28,
            RegulatorResistorRatio = 0x20,
            ContrastRegister = 0x81,
            ContrastValue = 0x00,
            NoOperation = 0xE3
        }

        public AdaFruit7565(Cpu.Pin dc, Cpu.Pin reset, Cpu.Pin chipSelect, SPI.SPI_module spiModule = SPI.SPI_module.SPI1, uint speedKHz = 10000)
            : base(dc, reset, chipSelect, spiModule, speedKHz) {
        }

        public void Initialize() {
            resetPin.Write(false);
            Thread.Sleep(50);
            resetPin.Write(true);

            dcPin.Write(DisplayCommand);

            SendCommand((AdaFruitSSD1306.Command)AdaFruit7565.Command.LcdVoltageBias7);
            SendCommand((AdaFruitSSD1306.Command)AdaFruit7565.Command.AdcSelectNormal);
            SendCommand((AdaFruitSSD1306.Command)AdaFruit7565.Command.ShlSelectReverse);
            SendCommand((AdaFruitSSD1306.Command)((int)(AdaFruit7565.Command.DisplayStartLine) | 0x00));
            
            SendCommand((AdaFruitSSD1306.Command) ((int)(AdaFruit7565.Command.PowerControl) | 0x04)); // turn on voltage converter (VC=1, VR=0, VF=0)
            Thread.Sleep(50);
            SendCommand((AdaFruitSSD1306.Command)((int)(AdaFruit7565.Command.PowerControl) | 0x06)); // turn on voltage regulator (VC=1, VR=1, VF=0)
            Thread.Sleep(50);
            SendCommand((AdaFruitSSD1306.Command)((int)(AdaFruit7565.Command.PowerControl) | 0x07)); // turn on voltage follower (VC=1, VR=1, VF=1)
            Thread.Sleep(50);

            SendCommand((AdaFruitSSD1306.Command)((int)(AdaFruit7565.Command.RegulatorResistorRatio) | 0x06)); // set lcd operating voltage (regulator resistor, ref voltage resistor)

            SendCommand((AdaFruitSSD1306.Command)AdaFruit7565.Command.DisplayOn);
            SendCommand((AdaFruitSSD1306.Command)AdaFruit7565.Command.AllPixelsOff);
        }

        public const uint ContrastHigh = 34;
        public const uint ContrastMedium = 24;
        public const uint ContrastLow = 15;

        // 0-63
        public void SetContrast(uint contrast) {
            dcPin.Write(DisplayCommand);
            SendCommand((AdaFruitSSD1306.Command)AdaFruit7565.Command.ContrastRegister);
            SendCommand((AdaFruitSSD1306.Command)((int)(AdaFruit7565.Command.ContrastValue) | (contrast & 0x3f)));
        }

        new public void InvertDisplay(bool cmd) {
            dcPin.Write(DisplayCommand);
            if (cmd) {
                SendCommand((AdaFruitSSD1306.Command)AdaFruit7565.Command.DisplayVideoReverse);
            } else {
                SendCommand((AdaFruitSSD1306.Command)AdaFruit7565.Command.DisplayVideoNormal);
            }
        }

        public void PowerSaveMode() {
            dcPin.Write(DisplayCommand);
            SendCommand((AdaFruitSSD1306.Command)AdaFruit7565.Command.DisplayOff);
            SendCommand((AdaFruitSSD1306.Command)AdaFruit7565.Command.AllPixelsOn);
        }

        protected const int StartColumnOffset = 1;

        public override void Refresh() {
            for (int page = 0; page < 8; page++) {
                dcPin.Write(DisplayCommand);
                SendCommand((AdaFruitSSD1306.Command)((int)(AdaFruit7565.Command.PageAddress) | pageReference[page]));
                SendCommand((AdaFruitSSD1306.Command)((int)(AdaFruit7565.Command.ColumnAddressLow) | (StartColumnOffset & 0x0F)));
                SendCommand((AdaFruitSSD1306.Command)((int)(AdaFruit7565.Command.ColumnAddressHigh) | 0));
                SendCommand((AdaFruitSSD1306.Command)((int)(AdaFruit7565.Command.EnterReadModifyWriteMode)));
                dcPin.Write(Data);
                Array.Copy(displayBuffer, Width * page, pageBuffer, 0, pageSize);
                Spi.Write(pageBuffer);
            }
        }

        protected const int pageSize = 128;
        protected int[] pageReference = new int[] { 4, 5, 6, 7, 0, 1, 2, 3 };
        protected byte[] pageBuffer = new byte[pageSize];
    }
}



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 December 2014 - 12:34 AM

Hi david,

What error are you getting, exactly? Any chance you can simplify the solution down a bit and we can try to help bug hunt here...?

Chris

#3 david98xp

david98xp

    Advanced Member

  • Members
  • PipPipPip
  • 57 posts

Posted 06 December 2014 - 10:58 PM

Hi david,

What error are you getting, exactly? Any chance you can simplify the solution down a bit and we can try to help bug hunt here...?

Chris

Actually here's the problem! I own a netduino 2 and a st7565 negative GLCD. I'm now trying to run Fabien Royer's AdaFruit7565 test program. It says it won't work with 4.2 as it's written in 4.1. I went to Project Propeties>Application>Target>I changed it from 4.1 to 4.2. Now it has this "Rebooting error". As well as "an error has occured, please check your hardware."

 

I'm very much in a rush and I need some way to get my LCD Working.



#4 KiwiDev

KiwiDev

    Advanced Member

  • Members
  • PipPipPip
  • 100 posts
  • LocationNew Zealand

Posted 09 December 2014 - 09:16 AM

Hi,

 

Could you share a cut back version of your solution which exhibits the problem (code. projects etc.) ?

 

Bryn



#5 david98xp

david98xp

    Advanced Member

  • Members
  • PipPipPip
  • 57 posts

Posted 09 December 2014 - 03:22 PM

Umm.. It's not just one part. Check out my newer post on backwards .




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.