Welcome! Log In Create A New Profile

Advanced

DIY Tiny OLED I2C full graphics controller

Posted by enif 
Re: DIY Tiny OLED I2C full graphics controller
December 11, 2017 02:12AM
The SCAD file is commented - but I am sorry, no other explanations for it are available.

And I admit that the technique I used here is somewhat untypical for OpenScad: Essentially, each object consists just of two arrays of blocks, the first one are additive blocks, the second one cavities that are to be cut out. A normal "cube" type block consists just of two entries: the origin point and the size. A cylindrical block consist of the origin followed by an array [direction, radius, height] where direction is (-1 for X, -2 for Y, -3 for Z). Finally there are also optional 3rd , 4th and 5th entries in each block which can be used to specify the value of $fn (i.e. the number of corners used to approximate the cylinder), the level of the block (lower levels are generated/subtracted first) and a condition string (allowing blocks to be only generated under certain conditions).
With this information and the comments in the block list you should at least be able to understand the structure of the objects.

While this is a rather efficient way of coding, I am not sure if it is a good starting point for someone just beginning to learn OpenScad. In this case traditional coding with explicit
calls to cube(), cylinder(), translate(), difference(), etc. is probably much easier...
Re: DIY Tiny OLED I2C full graphics controller
December 29, 2017 03:00AM
Quote
enif
As for the I2C problem on the Arduino Due that caused some conflict when activating simultaneously the I2C OLED (using the U8glib I2C routines) and the I2C EEPROM (using Arduino's Wire.h), I have made some progress:

I removed the '//' from the (3 each) commented out statements "//u8g->pin_list[U8G_PI_SET_A0] = 1;" and "// u8g_i2c_stop();" in file U8glib/utility/u8g_com_arduino_ssd_i2c.c :

$diff u8g_com_arduino_ssd_i2c.c.ori u8g_com_arduino_ssd_i2c.c
125c125
<       //u8g->pin_list[U8G_PI_SET_A0] = 1;
---
>       u8g->pin_list[U8G_PI_SET_A0] = 1;
130c130
<       // u8g_i2c_stop();
---
>       u8g_i2c_stop();
134c134
<       //u8g->pin_list[U8G_PI_SET_A0] = 1;
---
>       u8g->pin_list[U8G_PI_SET_A0] = 1;
146c146
<       // u8g_i2c_stop();
---
>       u8g_i2c_stop();
150c150
<       //u8g->pin_list[U8G_PI_SET_A0] = 1;
---
>       u8g->pin_list[U8G_PI_SET_A0] = 1;
163c163
<       // u8g_i2c_stop();
---
>       u8g_i2c_stop();

After recompiling Marlin4Due with this change the Arduino Due the conflict seems resolved and it can now access the I2C EEPROM (after having it activated in Configuration.h of course) while using the I2C OLED display - so far without any problem smiling smiley


I tried this with marlin 2.0 bugfix and ramps_fd_v2 (tinyoled uncommented), but display and eeprom are not working at the same time. Eeprom only is working. Display only is not working, but it is working for a second when i press disconnect and connect in pronterface. then it goes black again.

Does anyone have this working with Due?
Re: DIY Tiny OLED I2C full graphics controller
July 10, 2018 05:20AM
Hi all,

I've solved the issue for the EEPROM I2C on Arduino Due (RAMPS4DUE project) in a very easy way.

I've simply moved the EEPROM on the 2nd I2C port available on the Due ( SCL1 SDA1) and made few modification on the Marlin4due firmware:

- Connect the EEPROM on the 2nd I2C, dont' forget to add a couple of 1.5K pull up resistors between SCL1 to 3.3v and SDA1 to 3.3v (the pull up resistors are already implemented on the 1st I2C (D20 and D21) of the Due board.
SDA1        3.3V       SCL1
 |           |          |
 |           |          |
 o--[1.5k]---o          |
             |          |
             |          |
             o--[1.5k]--o

- Modify the Configuration.h to add the option for the 2nd I2C, the red one, in the EEPROM section:

#ifdef EEPROM_SETTINGS
  // To disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out:
  #define EEPROM_CHITCHAT // Please keep turned on if you can.
  #define EEPROM_ON_2ND_I2C // EEPROM CHIP ON second I2C for Arduino Due
  #endif

- Now you have to modify the HAL.ccp to add the new option for the 2nd I2C (in few words we have to use wire1 instead of wire to address the EEOROM on 2nd I2C). Replace the lines between the "//eeprom" and "//Timers" and put the below code:

// --------------------------------------------------------------------------
// eeprom
// --------------------------------------------------------------------------


static bool eeprom_initialised = false;
static uint8_t eeprom_device_address = 0x50;

#ifdef EEPROM_ON_2ND_I2C

static void eeprom_init(void) {
	if (!eeprom_initialised) {
		Wire1.begin();
		eeprom_initialised = true;
	}
}

void eeprom_write_byte(unsigned char *pos, unsigned char value) {
	unsigned eeprom_address = (unsigned) pos;

	eeprom_init();

	Wire1.beginTransmission(eeprom_device_address);
	Wire1.write((int)(eeprom_address >> 8));   // MSB
	Wire1.write((int)(eeprom_address & 0xFF)); // LSB
  Wire1.write(value);
	Wire1.endTransmission();

	// wait for write cycle to complete
	// this could be done more efficiently with "acknowledge polling"
	delay(5);
}


unsigned char eeprom_read_byte(unsigned char *pos) {
	byte data = 0xFF;
	unsigned eeprom_address = (unsigned) pos;

	eeprom_init ();

	Wire1.beginTransmission(eeprom_device_address);
	Wire1.write((int)(eeprom_address >> 8));   // MSB
	Wire1.write((int)(eeprom_address & 0xFF)); // LSB
	Wire1.endTransmission();
	Wire1.requestFrom(eeprom_device_address, (byte)1);
	if (Wire1.available())
		data = Wire1.read();
	return data;
}

#else

static void eeprom_init(void) {
	if (!eeprom_initialised) {
		Wire.begin();
		eeprom_initialised = true;
	}
}

void eeprom_write_byte(unsigned char *pos, unsigned char value) {
	unsigned eeprom_address = (unsigned) pos;

	eeprom_init();

	Wire.beginTransmission(eeprom_device_address);
	Wire.write((int)(eeprom_address >> 8));   // MSB
	Wire.write((int)(eeprom_address & 0xFF)); // LSB
    Wire.write(value);
	Wire.endTransmission();

	// wait for write cycle to complete
	// this could be done more efficiently with "acknowledge polling"
	delay(5);
}


unsigned char eeprom_read_byte(unsigned char *pos) {
	byte data = 0xFF;
	unsigned eeprom_address = (unsigned) pos;

	eeprom_init ();

	Wire.beginTransmission(eeprom_device_address);
	Wire.write((int)(eeprom_address >> 8));   // MSB
	Wire.write((int)(eeprom_address & 0xFF)); // LSB
	Wire.endTransmission();
	Wire.requestFrom(eeprom_device_address, (byte)1);
	if (Wire.available())
		data = Wire.read();
	return data;
}
#endif

// --------------------------------------------------------------------------
// Timers
// --------------------------------------------------------------------------


Now you can use both I2C OLED and I2C EEPROM at the same time.
Bye

Edited 1 time(s). Last edit at 07/11/2018 01:30AM by Skytter.


- Geeetech I3 Pro B "Tuning" GT2560 A+ con terzo Stepper Driver - Doppio Alimentatore e Scheda Mosfet per l'HeatBed - Dondolo per I3 Pro B - Diamond HotEnd color mixing - Mk8 Extruder 0.2 nozzle.
- TronXY X5S.
- Progetto "MiniMaker" full stroke 200x200x180 printer in a 300x300x300 cube.

My Thingiverse: [www.thingiverse.com]
Sorry, only registered users may post in this forum.

Click here to login