Show Posts
Pages: [1] 2 3 ... 11
1  Using Arduino / Displays / Re: SSD1306 can only write to part of screen (U8Glib works, AdaFruit not) on: September 08, 2014, 02:51:02 pm
Oliver,

that was a great help! I had already been over that piece of code, but without the extra explanation I didn't really get what you were doing. I think I have it almost working now. My findings up till now:

AdaFruit uses Horizontal Addressing Mode (command 0x20, then send 0x00)
U8Glib uses Page Addressing Mode (command 0x20, then send 0x10)

Now display (1) works with both, but display (2) only works in Page Addressing Mode. Go figure.

The horizontal addressing can use commands to set column start and end (0x21) and page start and end (0x22), but this only works in horizontal or vertical addressing mode.

For page addressing you have to use command 0xB0~0xB7 to set the right page, and 0x00~0x0F to set lower nibble of column start address and 0x10~0x1F to set higher nibble of column start address.

Experimentally I found that when you switch to a new page you have to reset the column address to where you want. I do not understand entirely why this is. I have no idea whether this address is actually a pointer that gets increased when you write to the screen, but now that I'm writing this out loud (I bash on my keys smiley-wink ): yes it is. But it runs to 132 instead of 128 before rolling over, so pixels tend to get displaced after writing an entire row. So better reset this when you select a new page.

Code will follow as soon as I have cleaned it.

Many thanks for your quick replies.

Jack
2  Using Arduino / Displays / Re: SSD1306 can only write to part of screen (U8Glib works, AdaFruit not) on: September 08, 2014, 04:16:40 am
Alright, I have been chasing pointers for the past few hours and I'm lost:

drawglyph functions point to drawpixel which points to u8g_call_dev_fn which sort of puts a dev_fn in dev to work

I stand in awe of the beauty of the generalizations of the code, but I can't seem to answer my own question: how do you put 1 pixel on the screen ? What are the actual commands you send to the screen? Because somewhere in there is the answer to why the library *can* get a good output on both my screens, but my code just on the one. I /think/ I have the same init sequence, unless more commands are issued after the u8g_dev_ssd1306_128x64_adafruit3_init_seq[] from the u8g_dev_ssd1306_128x64.c file.

Cheers,

Jack
3  Using Arduino / Displays / Re: SSD1306 can only write to part of screen (U8Glib works, AdaFruit not) on: September 08, 2014, 01:45:19 am
Oliver,

thank you for your reply.

Yes, this might be a SH1106 driver, I'm getting the idea on eBay you can get any of both. My display (1) is sold as SH1106 in the description, both are called SSD1306.

Weirdly, both work with U8Glib, and the init sequence is the same. So there must be a difference in the writing to the screen. However, the library being so generic, I have trouble finding how data is actually written to the display. In what portion of the code should I dig to find this? Your help is greatly appreciated.

Cheers,

Jack
4  Using Arduino / Displays / Re: SSD1306 can only write to part of screen (U8Glib works, AdaFruit not) on: September 07, 2014, 05:07:20 pm
ssd1306_1.h
Code:
/*
  Defines for SSD1306 OLED display from Adafruit library
*/

#define BLACK 0
#define WHITE 1

#define SSD1306_LCDWIDTH                  128
#define SSD1306_LCDHEIGHT                 64

#define SSD1306_SETCONTRAST 0x81
#define SSD1306_DISPLAYALLON_RESUME 0xA4
#define SSD1306_DISPLAYALLON 0xA5
#define SSD1306_NORMALDISPLAY 0xA6
#define SSD1306_INVERTDISPLAY 0xA7
#define SSD1306_DISPLAYOFF 0xAE
#define SSD1306_DISPLAYON 0xAF

#define SSD1306_SETDISPLAYOFFSET 0xD3
#define SSD1306_SETCOMPINS 0xDA

#define SSD1306_SETVCOMDETECT 0xDB

#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
#define SSD1306_SETPRECHARGE 0xD9

#define SSD1306_SETMULTIPLEX 0xA8

#define SSD1306_SETLOWCOLUMN 0x00
#define SSD1306_SETHIGHCOLUMN 0x10

#define SSD1306_SETSTARTLINE 0x40

#define SSD1306_MEMORYMODE 0x20
#define SSD1306_COLUMNADDR 0x21
#define SSD1306_PAGEADDR   0x22

#define SSD1306_COMSCANINC 0xC0
#define SSD1306_COMSCANDEC 0xC8

#define SSD1306_SEGREMAP 0xA0

#define SSD1306_CHARGEPUMP 0x8D

#define SSD1306_EXTERNALVCC 0x1
#define SSD1306_SWITCHCAPVCC 0x2

// Scrolling #defines
#define SSD1306_ACTIVATE_SCROLL 0x2F
#define SSD1306_DEACTIVATE_SCROLL 0x2E
#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A

Jack
5  Using Arduino / Displays / Re: SSD1306 can only write to part of screen (U8Glib works, AdaFruit not) on: September 07, 2014, 05:06:59 pm
For completeness, the header files:

glcdfont.h
Code:
#ifndef FONT5X7_H
#define FONT5X7_H

#ifdef __AVR__
 #include <avr/io.h>
 #include <avr/pgmspace.h>
#else
 #define PROGMEM
#endif
 
// Standard ASCII 5x7 font

static const unsigned char font[] PROGMEM = {
        0x00, 0x00, 0x00, 0x00, 0x00,
0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
0x18, 0x3C, 0x7E, 0x3C, 0x18,
0x1C, 0x57, 0x7D, 0x57, 0x1C,
0x1C, 0x5E, 0x7F, 0x5E, 0x1C,
0x00, 0x18, 0x3C, 0x18, 0x00,
0xFF, 0xE7, 0xC3, 0xE7, 0xFF,
0x00, 0x18, 0x24, 0x18, 0x00,
0xFF, 0xE7, 0xDB, 0xE7, 0xFF,
0x30, 0x48, 0x3A, 0x06, 0x0E,
0x26, 0x29, 0x79, 0x29, 0x26,
0x40, 0x7F, 0x05, 0x05, 0x07,
0x40, 0x7F, 0x05, 0x25, 0x3F,
0x5A, 0x3C, 0xE7, 0x3C, 0x5A,
0x7F, 0x3E, 0x1C, 0x1C, 0x08,
0x08, 0x1C, 0x1C, 0x3E, 0x7F,
0x14, 0x22, 0x7F, 0x22, 0x14,
0x5F, 0x5F, 0x00, 0x5F, 0x5F,
0x06, 0x09, 0x7F, 0x01, 0x7F,
0x00, 0x66, 0x89, 0x95, 0x6A,
0x60, 0x60, 0x60, 0x60, 0x60,
0x94, 0xA2, 0xFF, 0xA2, 0x94,
0x08, 0x04, 0x7E, 0x04, 0x08,
0x10, 0x20, 0x7E, 0x20, 0x10,
0x08, 0x08, 0x2A, 0x1C, 0x08,
0x08, 0x1C, 0x2A, 0x08, 0x08,
0x1E, 0x10, 0x10, 0x10, 0x10,
0x0C, 0x1E, 0x0C, 0x1E, 0x0C,
0x30, 0x38, 0x3E, 0x38, 0x30,
0x06, 0x0E, 0x3E, 0x0E, 0x06,
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x5F, 0x00, 0x00,
0x00, 0x07, 0x00, 0x07, 0x00,
0x14, 0x7F, 0x14, 0x7F, 0x14,
0x24, 0x2A, 0x7F, 0x2A, 0x12,
0x23, 0x13, 0x08, 0x64, 0x62,
0x36, 0x49, 0x56, 0x20, 0x50,
0x00, 0x08, 0x07, 0x03, 0x00,
0x00, 0x1C, 0x22, 0x41, 0x00,
0x00, 0x41, 0x22, 0x1C, 0x00,
0x2A, 0x1C, 0x7F, 0x1C, 0x2A,
0x08, 0x08, 0x3E, 0x08, 0x08,
0x00, 0x80, 0x70, 0x30, 0x00,
0x08, 0x08, 0x08, 0x08, 0x08,
0x00, 0x00, 0x60, 0x60, 0x00,
0x20, 0x10, 0x08, 0x04, 0x02,
0x3E, 0x51, 0x49, 0x45, 0x3E,
0x00, 0x42, 0x7F, 0x40, 0x00,
0x72, 0x49, 0x49, 0x49, 0x46,
0x21, 0x41, 0x49, 0x4D, 0x33,
0x18, 0x14, 0x12, 0x7F, 0x10,
0x27, 0x45, 0x45, 0x45, 0x39,
0x3C, 0x4A, 0x49, 0x49, 0x31,
0x41, 0x21, 0x11, 0x09, 0x07,
0x36, 0x49, 0x49, 0x49, 0x36,
0x46, 0x49, 0x49, 0x29, 0x1E,
0x00, 0x00, 0x14, 0x00, 0x00,
0x00, 0x40, 0x34, 0x00, 0x00,
0x00, 0x08, 0x14, 0x22, 0x41,
0x14, 0x14, 0x14, 0x14, 0x14,
0x00, 0x41, 0x22, 0x14, 0x08,
0x02, 0x01, 0x59, 0x09, 0x06,
0x3E, 0x41, 0x5D, 0x59, 0x4E,
0x7C, 0x12, 0x11, 0x12, 0x7C,
0x7F, 0x49, 0x49, 0x49, 0x36,
0x3E, 0x41, 0x41, 0x41, 0x22,
0x7F, 0x41, 0x41, 0x41, 0x3E,
0x7F, 0x49, 0x49, 0x49, 0x41,
0x7F, 0x09, 0x09, 0x09, 0x01,
0x3E, 0x41, 0x41, 0x51, 0x73,
0x7F, 0x08, 0x08, 0x08, 0x7F,
0x00, 0x41, 0x7F, 0x41, 0x00,
0x20, 0x40, 0x41, 0x3F, 0x01,
0x7F, 0x08, 0x14, 0x22, 0x41,
0x7F, 0x40, 0x40, 0x40, 0x40,
0x7F, 0x02, 0x1C, 0x02, 0x7F,
0x7F, 0x04, 0x08, 0x10, 0x7F,
0x3E, 0x41, 0x41, 0x41, 0x3E,
0x7F, 0x09, 0x09, 0x09, 0x06,
0x3E, 0x41, 0x51, 0x21, 0x5E,
0x7F, 0x09, 0x19, 0x29, 0x46,
0x26, 0x49, 0x49, 0x49, 0x32,
0x03, 0x01, 0x7F, 0x01, 0x03,
0x3F, 0x40, 0x40, 0x40, 0x3F,
0x1F, 0x20, 0x40, 0x20, 0x1F,
0x3F, 0x40, 0x38, 0x40, 0x3F,
0x63, 0x14, 0x08, 0x14, 0x63,
0x03, 0x04, 0x78, 0x04, 0x03,
0x61, 0x59, 0x49, 0x4D, 0x43,
0x00, 0x7F, 0x41, 0x41, 0x41,
0x02, 0x04, 0x08, 0x10, 0x20,
0x00, 0x41, 0x41, 0x41, 0x7F,
0x04, 0x02, 0x01, 0x02, 0x04,
0x40, 0x40, 0x40, 0x40, 0x40,
0x00, 0x03, 0x07, 0x08, 0x00,
0x20, 0x54, 0x54, 0x78, 0x40,
0x7F, 0x28, 0x44, 0x44, 0x38,
0x38, 0x44, 0x44, 0x44, 0x28,
0x38, 0x44, 0x44, 0x28, 0x7F,
0x38, 0x54, 0x54, 0x54, 0x18,
0x00, 0x08, 0x7E, 0x09, 0x02,
0x18, 0xA4, 0xA4, 0x9C, 0x78,
0x7F, 0x08, 0x04, 0x04, 0x78,
0x00, 0x44, 0x7D, 0x40, 0x00,
0x20, 0x40, 0x40, 0x3D, 0x00,
0x7F, 0x10, 0x28, 0x44, 0x00,
0x00, 0x41, 0x7F, 0x40, 0x00,
0x7C, 0x04, 0x78, 0x04, 0x78,
0x7C, 0x08, 0x04, 0x04, 0x78,
0x38, 0x44, 0x44, 0x44, 0x38,
0xFC, 0x18, 0x24, 0x24, 0x18,
0x18, 0x24, 0x24, 0x18, 0xFC,
0x7C, 0x08, 0x04, 0x04, 0x08,
0x48, 0x54, 0x54, 0x54, 0x24,
0x04, 0x04, 0x3F, 0x44, 0x24,
0x3C, 0x40, 0x40, 0x20, 0x7C,
0x1C, 0x20, 0x40, 0x20, 0x1C,
0x3C, 0x40, 0x30, 0x40, 0x3C,
0x44, 0x28, 0x10, 0x28, 0x44,
0x4C, 0x90, 0x90, 0x90, 0x7C,
0x44, 0x64, 0x54, 0x4C, 0x44,
0x00, 0x08, 0x36, 0x41, 0x00,
0x00, 0x00, 0x77, 0x00, 0x00,
0x00, 0x41, 0x36, 0x08, 0x00,
0x02, 0x01, 0x02, 0x04, 0x02,
0x3C, 0x26, 0x23, 0x26, 0x3C,
0x1E, 0xA1, 0xA1, 0x61, 0x12,
0x3A, 0x40, 0x40, 0x20, 0x7A,
0x38, 0x54, 0x54, 0x55, 0x59,
0x21, 0x55, 0x55, 0x79, 0x41,
0x21, 0x54, 0x54, 0x78, 0x41,
0x21, 0x55, 0x54, 0x78, 0x40,
0x20, 0x54, 0x55, 0x79, 0x40,
0x0C, 0x1E, 0x52, 0x72, 0x12,
0x39, 0x55, 0x55, 0x55, 0x59,
0x39, 0x54, 0x54, 0x54, 0x59,
0x39, 0x55, 0x54, 0x54, 0x58,
0x00, 0x00, 0x45, 0x7C, 0x41,
0x00, 0x02, 0x45, 0x7D, 0x42,
0x00, 0x01, 0x45, 0x7C, 0x40,
0xF0, 0x29, 0x24, 0x29, 0xF0,
0xF0, 0x28, 0x25, 0x28, 0xF0,
0x7C, 0x54, 0x55, 0x45, 0x00,
0x20, 0x54, 0x54, 0x7C, 0x54,
0x7C, 0x0A, 0x09, 0x7F, 0x49,
0x32, 0x49, 0x49, 0x49, 0x32,
0x32, 0x48, 0x48, 0x48, 0x32,
0x32, 0x4A, 0x48, 0x48, 0x30,
0x3A, 0x41, 0x41, 0x21, 0x7A,
0x3A, 0x42, 0x40, 0x20, 0x78,
0x00, 0x9D, 0xA0, 0xA0, 0x7D,
0x39, 0x44, 0x44, 0x44, 0x39,
0x3D, 0x40, 0x40, 0x40, 0x3D,
0x3C, 0x24, 0xFF, 0x24, 0x24,
0x48, 0x7E, 0x49, 0x43, 0x66,
0x2B, 0x2F, 0xFC, 0x2F, 0x2B,
0xFF, 0x09, 0x29, 0xF6, 0x20,
0xC0, 0x88, 0x7E, 0x09, 0x03,
0x20, 0x54, 0x54, 0x79, 0x41,
0x00, 0x00, 0x44, 0x7D, 0x41,
0x30, 0x48, 0x48, 0x4A, 0x32,
0x38, 0x40, 0x40, 0x22, 0x7A,
0x00, 0x7A, 0x0A, 0x0A, 0x72,
0x7D, 0x0D, 0x19, 0x31, 0x7D,
0x26, 0x29, 0x29, 0x2F, 0x28,
0x26, 0x29, 0x29, 0x29, 0x26,
0x30, 0x48, 0x4D, 0x40, 0x20,
0x38, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x38,
0x2F, 0x10, 0xC8, 0xAC, 0xBA,
0x2F, 0x10, 0x28, 0x34, 0xFA,
0x00, 0x00, 0x7B, 0x00, 0x00,
0x08, 0x14, 0x2A, 0x14, 0x22,
0x22, 0x14, 0x2A, 0x14, 0x08,
0xAA, 0x00, 0x55, 0x00, 0xAA,
0xAA, 0x55, 0xAA, 0x55, 0xAA,
0x00, 0x00, 0x00, 0xFF, 0x00,
0x10, 0x10, 0x10, 0xFF, 0x00,
0x14, 0x14, 0x14, 0xFF, 0x00,
0x10, 0x10, 0xFF, 0x00, 0xFF,
0x10, 0x10, 0xF0, 0x10, 0xF0,
0x14, 0x14, 0x14, 0xFC, 0x00,
0x14, 0x14, 0xF7, 0x00, 0xFF,
0x00, 0x00, 0xFF, 0x00, 0xFF,
0x14, 0x14, 0xF4, 0x04, 0xFC,
0x14, 0x14, 0x17, 0x10, 0x1F,
0x10, 0x10, 0x1F, 0x10, 0x1F,
0x14, 0x14, 0x14, 0x1F, 0x00,
0x10, 0x10, 0x10, 0xF0, 0x00,
0x00, 0x00, 0x00, 0x1F, 0x10,
0x10, 0x10, 0x10, 0x1F, 0x10,
0x10, 0x10, 0x10, 0xF0, 0x10,
0x00, 0x00, 0x00, 0xFF, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0xFF, 0x10,
0x00, 0x00, 0x00, 0xFF, 0x14,
0x00, 0x00, 0xFF, 0x00, 0xFF,
0x00, 0x00, 0x1F, 0x10, 0x17,
0x00, 0x00, 0xFC, 0x04, 0xF4,
0x14, 0x14, 0x17, 0x10, 0x17,
0x14, 0x14, 0xF4, 0x04, 0xF4,
0x00, 0x00, 0xFF, 0x00, 0xF7,
0x14, 0x14, 0x14, 0x14, 0x14,
0x14, 0x14, 0xF7, 0x00, 0xF7,
0x14, 0x14, 0x14, 0x17, 0x14,
0x10, 0x10, 0x1F, 0x10, 0x1F,
0x14, 0x14, 0x14, 0xF4, 0x14,
0x10, 0x10, 0xF0, 0x10, 0xF0,
0x00, 0x00, 0x1F, 0x10, 0x1F,
0x00, 0x00, 0x00, 0x1F, 0x14,
0x00, 0x00, 0x00, 0xFC, 0x14,
0x00, 0x00, 0xF0, 0x10, 0xF0,
0x10, 0x10, 0xFF, 0x10, 0xFF,
0x14, 0x14, 0x14, 0xFF, 0x14,
0x10, 0x10, 0x10, 0x1F, 0x00,
0x00, 0x00, 0x00, 0xF0, 0x10,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
0xFF, 0xFF, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0xFF,
0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
0x38, 0x44, 0x44, 0x38, 0x44,
0x7C, 0x2A, 0x2A, 0x3E, 0x14,
0x7E, 0x02, 0x02, 0x06, 0x06,
0x02, 0x7E, 0x02, 0x7E, 0x02,
0x63, 0x55, 0x49, 0x41, 0x63,
0x38, 0x44, 0x44, 0x3C, 0x04,
0x40, 0x7E, 0x20, 0x1E, 0x20,
0x06, 0x02, 0x7E, 0x02, 0x02,
0x99, 0xA5, 0xE7, 0xA5, 0x99,
0x1C, 0x2A, 0x49, 0x2A, 0x1C,
0x4C, 0x72, 0x01, 0x72, 0x4C,
0x30, 0x4A, 0x4D, 0x4D, 0x30,
0x30, 0x48, 0x78, 0x48, 0x30,
0xBC, 0x62, 0x5A, 0x46, 0x3D,
0x3E, 0x49, 0x49, 0x49, 0x00,
0x7E, 0x01, 0x01, 0x01, 0x7E,
0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
0x44, 0x44, 0x5F, 0x44, 0x44,
0x40, 0x51, 0x4A, 0x44, 0x40,
0x40, 0x44, 0x4A, 0x51, 0x40,
0x00, 0x00, 0xFF, 0x01, 0x03,
0xE0, 0x80, 0xFF, 0x00, 0x00,
0x08, 0x08, 0x6B, 0x6B, 0x08,
0x36, 0x12, 0x36, 0x24, 0x36,
0x06, 0x0F, 0x09, 0x0F, 0x06,
0x00, 0x00, 0x18, 0x18, 0x00,
0x00, 0x00, 0x10, 0x10, 0x00,
0x30, 0x40, 0xFF, 0x01, 0x01,
0x00, 0x1F, 0x01, 0x01, 0x1E,
0x00, 0x19, 0x1D, 0x17, 0x12,
0x00, 0x3C, 0x3C, 0x3C, 0x3C,
0x00, 0x00, 0x00, 0x00, 0x00
};
#endif // FONT5X7_H
6  Using Arduino / Displays / SSD1306 can only write to part of screen (U8Glib works, AdaFruit not) on: September 07, 2014, 04:20:25 pm
Dear all,

I have two versions of what I believe to be SSD1306 displays

1) HelTec, CS is already connected to GND, this is the OLD version of the HelTec
http://www.ebay.com/itm/201009010892?_trksid=p2059210.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

2)  Another brand, CS is brought out as a pin, reason I bought it
http://www.ebay.com/itm/291168368309?_trksid=p2059210.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

Now both displays work with U8Glib, I used the OLED_Scale example with this constructor:

Code:
U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9, 2); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9

Display (1) seems to work fine with the AdaFruit libraries for the SSD1306, however display (2) only works partially with this code. I want to understand why (in order to write a few very simple functions for my display).

My code taken from the AdaFruit example:

Code:
#include <SPI.h>
#include "ssd1306_1.h"
#include "Arduino.h"
#include "glcdfont.h"

typedef volatile uint8_t PortReg;
typedef uint8_t PortMask;

PortReg *mosiport, *clkport, *csport, *dcport;
PortMask mosipinmask, clkpinmask, cspinmask, dcpinmask;

int8_t vccstate, sid, sclk, dc, rst, cs;

void setup()
{
  Serial.begin(9600);

  dc  = 9;
  rst = 2;
  cs  = 10;
 
  vccstate = SSD1306_SWITCHCAPVCC;

  pinMode(dc, OUTPUT);
  pinMode(cs, OUTPUT);
  pinMode(rst, OUTPUT);

  csport      = portOutputRegister(digitalPinToPort(cs));
  cspinmask   = digitalPinToBitMask(cs);
  dcport      = portOutputRegister(digitalPinToPort(dc));
  dcpinmask   = digitalPinToBitMask(dc);

  SPI.begin ();
  SPI.setClockDivider (SPI_CLOCK_DIV2); // 8 MHz

  // Setup reset pin direction (used by both SPI and I2C) 
  digitalWrite(rst, HIGH);
  // VDD (3.3V) goes high at start, lets just chill for a ms
  delay(1);
  // bring reset low
  digitalWrite(rst, LOW);
  // wait 10ms
  delay(10);
  // bring out of reset
  digitalWrite(rst, HIGH);
  // turn on VCC (9V?)

  // Init sequence for 128x64 OLED module
  ssd1306_command(SSD1306_DISPLAYOFF);                    // 0xAE
  ssd1306_command(SSD1306_SETDISPLAYCLOCKDIV);            // 0xD5
  ssd1306_command(0x80);                                  // the suggested ratio 0x80
  ssd1306_command(SSD1306_SETMULTIPLEX);                  // 0xA8
  ssd1306_command(0x3F);
  ssd1306_command(SSD1306_SETDISPLAYOFFSET);              // 0xD3
  ssd1306_command(0x0);                                   // no offset
  ssd1306_command(SSD1306_SETSTARTLINE | 0x0);            // line #0
  ssd1306_command(SSD1306_CHARGEPUMP);                    // 0x8D
  if (vccstate == SSD1306_EXTERNALVCC)
    { ssd1306_command(0x10); }
  else
    { ssd1306_command(0x14); }
  ssd1306_command(SSD1306_MEMORYMODE);                    // 0x20
  ssd1306_command(0x00);                                  // 0x0 act like ks0108
  ssd1306_command(SSD1306_SEGREMAP | 0x1);
  ssd1306_command(SSD1306_COMSCANDEC);
  ssd1306_command(SSD1306_SETCOMPINS);                    // 0xDA
  ssd1306_command(0x12);
  ssd1306_command(SSD1306_SETCONTRAST);                   // 0x81
  if (vccstate == SSD1306_EXTERNALVCC)
    { ssd1306_command(0x9F); }
  else
    { ssd1306_command(0xCF); }
  ssd1306_command(SSD1306_SETPRECHARGE);                  // 0xd9
  if (vccstate == SSD1306_EXTERNALVCC)
    { ssd1306_command(0x22); }
  else
    { ssd1306_command(0xF1); }
  ssd1306_command(SSD1306_SETVCOMDETECT);                 // 0xDB
  ssd1306_command(0x40);
 
  ssd1306_command(SSD1306_DISPLAYALLON_RESUME);           // 0xA4
  ssd1306_command(SSD1306_NORMALDISPLAY);                 // 0xA6 

  ssd1306_command(SSD1306_DISPLAYON);//--turn on oled panel


  /* fill screen with alternating black and white pixels */
 
  ssd1306_command(SSD1306_COLUMNADDR);
  ssd1306_command(0);   // Column start address (0 = reset)
  ssd1306_command(127); // Column end address (127 = reset)

  ssd1306_command(SSD1306_PAGEADDR);
  ssd1306_command(0); // Page start address (0 = reset)
  ssd1306_command((SSD1306_LCDHEIGHT == 64) ? 7 : 3); // Page end address

  // SPI
  *csport |= cspinmask;
  *dcport |= dcpinmask;
  *csport &= ~cspinmask;

  for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++)
  {
    (void)SPI.transfer(B10101010);
  }
  *csport |= cspinmask; 

}


void loop()
{
}


void ssd1306_command(uint8_t c)
{
  // SPI
  //digitalWrite(cs, HIGH);
  *csport |= cspinmask;
  //digitalWrite(dc, LOW);
  *dcport &= ~dcpinmask;
  //digitalWrite(cs, LOW);
  *csport &= ~cspinmask;
  (void)SPI.transfer(c);
  //digitalWrite(cs, HIGH);
  *csport |= cspinmask;
}


void ssd1306_data(uint8_t c)
{
  // SPI
  //digitalWrite(cs, HIGH);
  *csport |= cspinmask;
  //digitalWrite(dc, HIGH);
  *dcport |= dcpinmask;
  //digitalWrite(cs, LOW);
  *csport &= ~cspinmask;
  (void)SPI.transfer(c);
  //digitalWrite(cs, HIGH);
  *csport |= cspinmask;
}

The code is supposed to print alternating black and white lines on the screen. I get the following results:



If I run my own (adafruit-based) code first, I get images (1A) en (2A): a lot of trash on screen (2). Running the U8Glib code yields good results: (1B) and (2B). If I then flash my Arduino to my own code and run it, I get (1C) (good again) and (2C): it seems I can only write to part of the screen. (I ran the tests in the order 1A, 1B, 1C, 2A, 2B, 2C)

Now the U8Glib code is done very nicely, but I find it hard to track what is happening. As far as I can tell it uses the same initialization sequence as AdaFruit (the code says so). Display (2) does work, just not with my code. There must be something I'm missing, but I have no clue. I have worked through the datasheet of the SSD1306, but found no extra clues.

I hope someone (mayhaps even Oliver) can shed some light on this and give me a pointer where to look.

Cheers,

Jack
7  Using Arduino / Networking, Protocols, and Devices / Re: RFM69HCW: no range at all on: June 25, 2014, 08:10:38 am
We have contact !

It had nothing to do with the antenna, though I will be trying several setups to see how they affect performance.

I use the RadioHead library. It is meant for all modules RFM69xxx. I'm using the HCW variant, as opposed to the older W or CW. I think the C designates the formfactor, the H stands for High Power (up to +20dBm). Now in order to use the H variant you have to set a specific register to use the high power boosters. The RadioHead library has not implemented this for the H-version. Without setting this it does not work.

My current range is 10 meters line of sight, but I still have to check all register settings and mount a decent antenna. Seeing that people almost squeeze a 1000 meters out of a 17cm wire I have to be able to do better. I have to look into the data rate I'm using now. I will get back on this.

I'll inform the guys at RadioHead about my findings.

Cheers,

Jack

8  Using Arduino / Networking, Protocols, and Devices / Re: RFM69HCW: no range at all on: June 25, 2014, 04:50:50 am
I have connected the MOSI, SCK, NSS, through a CD4050 level converter, MISO and DIO0 connect directly to UNO. Source is 3v3.

I'm pretty sure SPI is working all right, because I can read all registry values from the module and the results make sense, I compared them to the data sheet.
9  Using Arduino / Networking, Protocols, and Devices / Re: RFM69HCW: no range at all on: June 25, 2014, 03:04:44 am
This is my design for the breakout board, as simple as possible, SMA as close to the RFM69HCW module as I could manage.



The entire bottom of the PCB is groundplane.

I don't know whether there is a risk of a short with the bottom of the RFM module, so I kept that area clear of copper.

Cheers,

Jack
10  Using Arduino / Networking, Protocols, and Devices / Re: RFM69HCW: no range at all on: June 24, 2014, 02:59:10 pm
Well just to be sure I added some code to read all registers from the module, and that works without problem. The radiohead library states it is intended for use with this module, so I guess changes for a software problem are very small.
11  Using Arduino / Networking, Protocols, and Devices / Re: RFM69HCW: no range at all on: June 24, 2014, 02:41:31 pm
I'm amazed, because most 433 MHz units are way smaller than 17x17 cm, and still have good range. I don't even think I have a pcb that large. Ofcourse, I can create a bigger square with aluminum foil for effect, see what it does. I do hope the soldering on a pcb will do the trick. Tomorrow will be etching day.

I use RadioHead library, the module is RFM69HCW. Seeing that other people make do with 17 cm of cable I keep wondering whether I do something else wrong.

Cheers,

Jack
12  Using Arduino / Networking, Protocols, and Devices / Re: RFM69HCW: no range at all on: June 24, 2014, 02:09:05 pm
Does the soda can act as ground plane ?
13  Using Arduino / Networking, Protocols, and Devices / Re: RFM69HCW: no range at all on: June 24, 2014, 12:35:16 pm
Alright,

I'll design a breakout board for the module, with the SMA connector soldered to the PCB, the center pin in a straight line to the ANT of the module, as close as possible. The bottom side of the PCB will act as ground plane entirely, on the top side everything I don't need will be ground as well.

* Is it okay if I solder the outside pins of the SMA connector to the bottom part of the PCB ?
* "has to be as big square as the antenna is long", so for my 17 cm antenna a 4 cm x 4 cm board would do ?

Cheers,

Jack
14  Using Arduino / Networking, Protocols, and Devices / Re: Do I need to add an antenna? on: June 24, 2014, 02:34:28 am
Yes, you do need to add an antenna for increased range, I'm having my own struggles now with a different type of 433 MHz module. Some people have good results with soldering a 17 cm piece of wire to ANT. Most likely your receiver has a similar hole, refer to the datasheet to be sure.

Cheers,

Jack
15  Using Arduino / Networking, Protocols, and Devices / Re: RFM69HCW: no range at all on: June 23, 2014, 05:37:54 am
Right,

I fear one of the answers to my own question regarding the use of wires to connect the sma connector is: microstrip. You can't use regular wires, and need either something coaxial or such, or build something that resembles this on a pcb.

However: this doesn't explain why some people still get great results with only a piece of wire attached to the module.

Jack
Pages: [1] 2 3 ... 11