Help add support for HT1632 in u8glib

Can you post a picture of the "garbage"? Could it be the upper part of "ABC". Maybe mirrored?
Can you also post the current sketch?

Oliver

This is what is currently shown on the display. You can see the uncleared part on the right and the garbage on the left. http://imgur.com/KsbFLz1

This is the sketch:

#include "U8glib.h"

u8g_t u8g;

void setup(void)
{
  u8g_Init(&u8g, &u8g_dev_ht1632_26x16);
}

void loop(void)
{
  u8g_FirstPage(&u8g);
  u8g_SetColorIndex(&u8g, 1);
  do  {
    u8g_SetFont(&u8g, u8g_font_7x13);
    u8g_DrawStr(&u8g, 0, 14, "ABCgdef");
  }while( u8g_NextPage(&u8g) );
  delay(1000);
}

Could you also post your current "u8g_dev_ht1632.c" file?
I assume that the data write will look similar to this code:

void ht1632_transfer_data(uint8_t page, uint8_t cnt, uint8_t *data)
{
  uint8_t addr;
  /* send data to the ht1632 */
  digitalWrite(CS_PIN, LOW);
  ht1632_write_data_MSB(3, HT1632_ID_WR, false); // Send "write to display" command
  ht1632_write_data_MSB(7, page*26, false); // Oliver: Not sure if this calculation is correct

  // Operating in progressive addressing mode
  for (addr = 0; addr < cnt; addr++)
  {
    ht1632_write_data(8, data[addr]);  
  }  
  digitalWrite(CS_PIN, HIGH);
}

How will the display change if you modify the code to this (only display the first page of u8glib)?

void ht1632_transfer_data(uint8_t page, uint8_t cnt, uint8_t *data)
{
  uint8_t addr;

  if ( page != 0 )
   return;
  /* send data to the ht1632 */
  digitalWrite(CS_PIN, LOW);
  ht1632_write_data_MSB(3, HT1632_ID_WR, false); // Send "write to display" command
  ht1632_write_data_MSB(7, page*26, false); // Oliver: Not sure if this calculation is correct

  // Operating in progressive addressing mode
  for (addr = 0; addr < cnt; addr++)
  {
    ht1632_write_data(8, data[addr]);  
  }  
  digitalWrite(CS_PIN, HIGH);
}

One big problem for me is, that i do not understand how the bits are mapped on the screen.
Maybe you could output the following pattern instead of 0xFF:

 // Fill the screen
  // #######################################
  digitalWrite(CS_PIN, LOW);
  ht1632_write_data_MSB(3, HT1632_ID_WR, false); // Send "write to display" command
  ht1632_write_data_MSB(7, 0, false);
  uint8_t i;
  for(i = 0; i<48; ++i)
  {
    ht1632_write_data(8,i);
  }
  digitalWrite(CS_PIN, HIGH);
  // #######################################

Maybe you can make another picture with this pattern, so that we can better understand how the bits are mapped to the screen.

Please excause asking for so many code and pictures, but remote programming sometimes seems to be very complicated...

Oliver

This is the file I'm using: /* u8g_dev_ht1632_26x16.c 1-Bit (BW) Driver for HT1632 controller - Pastebin.com

I changed page8 to page26 and this is the result: http://imgur.com/RTgFkhE

Changing both page*26 and adding the if-statement: http://imgur.com/JBJ5gut

The screen is filled from top left downwards. A byte will fill the first 8 pixels from 0,0 to 0,8, the second will fill 0,8 to 0,16! The picture makes it more clear though: http://imgur.com/0UILEN8

I'm more than happy to help you implement it, I asked it in the first place! :smiley: Thanks again for looking into this!

The screen is filled from top left downwards. A byte will fill the first 8 pixels from 0,0 to 0,8, the second will fill 0,8 to 0,16! The picture makes it more clear though: http://imgur.com/0UILEN8

Ah, i see the problem. I was assuming, that the first byte goes to 0,0 to 0,8 and the second byte goes to 1,0 to 1,8.
B0 -> B1 -> B2-> ... -> B23
B24 -> B25-> ... -> B47
However, memory structure is like this:
B0 B2 B4 ...
B1 B3 B5 ...

I fixed this in the code and also integrated your other modifications (including the renaming to 24x16) into a new prerelase (attached pre6).
So the question is again: What will you see?

Oliver

u8glib_arduino_v1.13pre6.zip (1020 KB)

Display is working! Thank you very much!!!

You can remove this piece of code from the init function:

  digitalWrite(CS_PIN, LOW);
  ht1632_write_data_MSB(3, HT1632_ID_WR, false); // Send "write to display" command
  ht1632_write_data_MSB(7, 0, false);
  for(i = 0; i<48; ++i)
  {
    ht1632_write_data(8, 0xFF);
  }
  digitalWrite(CS_PIN, HIGH);

One last thing! The display support 16 levels of brightness. Do you think that should be added as contrast in u8glib? I did a start:

case U8G_DEV_MSG_CONTRAST:
  digitalWrite(CS_PIN, LOW);
  ht1632_write_data_MSB(3, HT1632_ID_CMD, false);
  ht1632_write_data_MSB(8, HT1632_CMD_PWM + pwmValue, true);
  digitalWrite(CS_PIN, HIGH);
  return 1;

But I'm not sure how the brightness value is passed and if return 1 should be removed. pwmValue should be a uint8_t between 0 and 15.

Great.

I will implement the set contrast feature. Additionally i will also try to make pin handling more flexible.
Would it be possible to make another picture from your device for my gallery page (Google Code Archive - Long-term storage for Google Code Project Hosting.)? This would be cool.

Thanks so far.
Oliver

I have 4 of these displays and I'm planning on using them as one, 48x32 display. Do you want a picture of the big one or the small 24x16 one? It's hard to display anything readable on the 24x16 display.

Again, thanks for making this possible!

Anything is fine, but I think a picture of your current 24x16 will be sufficient.

Thanks a lot.

Oliver

Here you go: http://imgur.com/QNmhuju

Thanks for the cooperation! Keep up the good work :smiley:

Great picture. Thanks!
I have updated the u8glib gallery page.

Some additional work will be required to completly integrate HT1632 support into u8glib...

Oliver

If you need testing, I'll be glad to help!

By the way, the framerate seems unbelievable. Drawing white and then balck fullscreen boxes makes the screen tear due to the chip's refresh rate.

Just a quick question: Doesn't u8glib support multiple displays? I'm pretty sure I have seen an example that multiple displays are used at once as one! I can't find it on the wiki though.

Multiple Displays: Yes, you can have multiple u8g structs/objects. You can also combine these u8g structs/objects to a larger "virtual" area. See the wiki entry for "virtual screen": Google Code Archive - Long-term storage for Google Code Project Hosting.

Oliver

Thank you! I'm really excited to get this working :smiley: When do you plan to release a new version with the driver included? I want to map custom pins but don't know what changes I should make to the driver file.

Hi

I am working on this.
The device has already been updated:
http://code.google.com/p/u8glib/source/browse/csrc/u8g_dev_ht1632.c

Oliver

Hi

The HT1632 has now been integrated into U8glib. I have added the new constructor to HelloWorld and GraphicsTest examples (other examples will be updated for the final v1.13 release)

U8GLIB_HT1632_24X16 u8g(3, 2, 4);		// WR = 3, DATA = 2, CS = 4

You should be able to change the Arduino pin numbers to whatever is required.
I have attached a prerelease with the new constructor call. Please let me know if this constructor call works correctly.
The virtual screen feature (combination of four screens to one huge screen) should also be possible now.

Thanks, Oliver

u8glib_arduino_v1.13pre7.zip (1020 KB)

Everything works fine! I also setup multiple display (just tested 2 displays for now) and everything seems fine.

Great, I will close this issue for now. Let me know if you find some additional issues.

Oliver