Here it is. It's some code I found here and modified / added some features.
The amp is the SparkFun TPA2005D1
Attached Files
- scardinale likes this
  | ||||||||||||||
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.
Community Stats
5
Neutral
User ToolsFriendsdino4net hasn't added any friends yet. Latest Visitors#61375 Has anyone used the Sparkfun MP3 Player Shield or the MP3 Trigger Successfully?Posted by dino4net on 26 January 2015 - 11:40 AM Here it is. It's some code I found here and modified / added some features.
The amp is the SparkFun TPA2005D1 Attached Files
#58155 netduino driver for the AdaFruit SSD1306 OLED displayPosted by dino4net on 15 May 2014 - 03:46 PM Hello,
As the code here became a little hard to read and many asked for a complete solution.
Here it is ... with a tool to create the image array ... Attached Files
#53820 netduino driver for the AdaFruit SSD1306 OLED displayPosted by dino4net on 04 November 2013 - 04:37 PM public const int Width = 128; public const int Height = 32; private const int I2CTransactionTimeout = 1000; // ms public AdaFruitSSD1306(ushort I2C_ADDRESS = 0x3C, int I2C_ClockRateKHz = 400, Cpu.Pin reset = (Cpu.Pin) 54) { AutoRefreshScreen = false; I2c = new I2CDevice.Configuration(I2C_ADDRESS, I2C_ClockRateKHz); //SoftwareI2CBus i2cbus = new SoftwareI2CBus(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_A4, SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_A5); //I2c = i2cbus.CreateI2CDevice(new I2CDevice.Configuration(0x3C, I2CTransactionTimeout)); //Connect the RST pin of the display to this Netduino pin resetPin = new OutputPort(SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.GPIO_PIN_D10, false); //resetPin = new OutputPort(reset, false); } protected void SendCommand(Command cmd) { SpiBuffer[0] = (byte)cmd; if (Spi != null) Spi.Write(SpiBuffer); if (I2c != null) { I2CBus.GetInstance().Write(I2c, new byte[] {0x00, (byte)cmd}, I2CTransactionTimeout); } } public void InvertDisplay(bool cmd) { if (Spi != null) dcPin.Write(DisplayCommand); if (cmd) { SendCommand(Command.INVERTDISPLAY); } else { SendCommand(Command.NORMALDISPLAY); } if (Spi != null) dcPin.Write(Data); } public virtual void Refresh() { if (Spi != null) Spi.Write(displayBuffer); else if (I2c != null) { byte[] I2CCommand = new byte[displayBuffer.Length + 1]; I2CCommand[0] = 0x40; Array.Copy(displayBuffer, 0, I2CCommand, 1, displayBuffer.Length); I2CBus.GetInstance().Write(I2c, I2CCommand, I2CTransactionTimeout); } } public void Initialize(VccType vcctype = VccType.SWITCHCAPVCC) { if (Spi != null) { resetPin.Write(true); Thread.Sleep(1); // VDD (3.3V) goes high at start, lets just chill for a ms resetPin.Write(false); // bring reset low Thread.Sleep(10); // wait 10ms resetPin.Write(true); // bring out of reset dcPin.Write(DisplayCommand); SendCommand(Command.DISPLAYOFF); // 0xAE SendCommand(Command.SETLOWCOLUMN | (Command)0x0); // low col = 0 SendCommand(Command.SETHIGHCOLUMN | (Command)0x0); // hi col = 0 SendCommand(Command.SETSTARTLINE | (Command)0x0); // line #0 SendCommand(Command.SETCONTRAST); // 0x81 if (vcctype == VccType.EXTERNALVCC) { SendCommand((Command)0x9F); // external 9V } else { SendCommand((Command)0xCF); // chargepump } SendCommand((Command)0xA1); // setment remap 95 to 0 (?) SendCommand(Command.NORMALDISPLAY); // 0xA6 SendCommand(Command.DISPLAYALLON_RESUME); // 0xA4 SendCommand(Command.SETMULTIPLEX); // 0xA8 //SendCommand((Command)0x3F); // 0x3F 1/64 duty SendCommand((Command)0x1F); // 0x1F 1/32 duty SendCommand(Command.SETDISPLAYOFFSET); // 0xD3 SendCommand((Command)0x0); // no offset SendCommand(Command.SETDISPLAYCLOCKDIV); // 0xD5 SendCommand((Command)0x80); // the suggested ratio 0x80 SendCommand(Command.SETPRECHARGE); // 0xd9 if (vcctype == VccType.EXTERNALVCC) { SendCommand((Command)0x22); // external 9V } else { SendCommand((Command)0xF1); // DC/DC } SendCommand(Command.SETCOMPINS); // 0xDA //SendCommand((Command)0x12); // disable COM left/right remap SendCommand((Command)0x02); ////128_32 = 02 128_64 = 12 SendCommand(Command.SETVCOMDETECT); // 0xDB SendCommand((Command)0x40); // 0x20 is default? SendCommand(Command.MEMORYMODE); // 0x20 SendCommand((Command)0x00); // 0x0 act like ks0108 // left to right scan SendCommand(Command.SEGREMAP | (Command)0x1); //0xA0 SendCommand(Command.COMSCANDEC); //0xC8 SendCommand(Command.CHARGEPUMP); //0x8D if (vcctype == VccType.EXTERNALVCC) { SendCommand((Command)0x10); // disable } else { SendCommand((Command)0x14); // disable } SendCommand(Command.DISPLAYON);//--turn on oled panel // Switch to 'data' mode dcPin.Write(Data); } else { resetPin.Write(true); Thread.Sleep(1); // VDD (3.3V) goes high at start, lets just chill for a ms resetPin.Write(false); // bring reset low Thread.Sleep(10); // wait 10ms resetPin.Write(true); // bring out of reset byte[] intBuffer; if (Height == 32) { intBuffer = new byte[] { (byte)Command.DISPLAYOFF, //turn off display(RESET=OFF) 0x00,0x00, //low column nibble(RESET=0),high column nibble(RESET=0) 0xB0, //start page address(RESET=0) (byte)Command.MEMORYMODE,0x00, //memory address mode(RESET=02 [page]) (byte)Command.SETDISPLAYCLOCKDIV,0x80, //oscillator frequency and divider(RESET=80)00 (byte)Command.SETMULTIPLEX,0x1F, //mux ratio(RESET=3F [64 lines] (byte)Command.SETDISPLAYOFFSET,0x00, //display offset,COM vertical shift(RESET=0) (byte)Command.CHARGEPUMP,(byte)(vcctype == VccType.EXTERNALVCC? 0x10 : 0x14), //enable charge pump(RESET=10 [OFF]) 0xA1,0x00, //segment remap(RESET=SEG0, COL0) 00 mirror image (byte)Command.COMSCANDEC, //COM output scan(RESET=C0, C8 flips display) (byte)Command.SETCOMPINS,0x02, //COM pins hardware config(RESET=12[alternate]) (byte)Command.SETCONTRAST,0xCF, //contrast CF(RESET=7F) (byte)Command.SETPRECHARGE,(byte)(vcctype == VccType.EXTERNALVCC? 0x22 : 0xF1), //pre-charge period F1(RESET=22) (byte)Command.SETVCOMDETECT,0x30, //Vcom deselect(RESET=20) (byte)Command.DISPLAYALLON_RESUME, //turn all on ignore RAM A5/RAM A4(RESET=A4) (byte)Command.NORMALDISPLAY, //normal display A6/inverted A7(RESET=A6) (byte)Command.DISPLAYON}; //turn on display } else if (Height == 64) { intBuffer = new byte[] { (byte)Command.DISPLAYOFF, //turn off display(RESET=OFF) 0x00,0x00, //low column nibble(RESET=0),high column nibble(RESET=0) 0xB0, //start page address(RESET=0) (byte)Command.MEMORYMODE,0x00, //memory address mode(RESET=02 [page]) (byte)Command.SETDISPLAYCLOCKDIV,0x80, //oscillator frequency and divider(RESET=80)00 (byte)Command.SETMULTIPLEX,0x3F, //mux ratio(RESET=3F [64 lines] (byte)Command.SETDISPLAYOFFSET,0x00, //display offset,COM vertical shift(RESET=0) (byte)Command.CHARGEPUMP,(byte)(vcctype == VccType.EXTERNALVCC? 0x10 : 0x14), //enable charge pump(RESET=10 [OFF]) 0xA1,0x00, //segment remap(RESET=SEG0, COL0) 00 mirror image (byte)Command.COMSCANDEC, //COM output scan(RESET=C0, C8 flips display) (byte)Command.SETCOMPINS,0x12, //COM pins hardware config(RESET=12[alternate]) (byte)Command.SETCONTRAST,0xCF, //contrast CF(RESET=7F) (byte)Command.SETPRECHARGE,(byte)(vcctype == VccType.EXTERNALVCC? 0x22 : 0xF1), //pre-charge period F1(RESET=22) (byte)Command.SETVCOMDETECT,0x40, //Vcom deselect(RESET=20) (byte)Command.DISPLAYALLON_RESUME, //turn all on ignore RAM A5/RAM A4(RESET=A4) (byte)Command.NORMALDISPLAY, //normal display A6/inverted A7(RESET=A6) (byte)Command.DISPLAYON}; //turn on display } I2CBus.GetInstance().Write(I2c, intBuffer, I2CTransactionTimeout); } } Hey Fabien, I got this working with the I2C version and it's tested with 64 and 32 lines. Do you want to add it to your driver?
| ||||||||||||||
|
||||||||||||||
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ||||||||||||||