Show Posts
Pages: 1 [2] 3 4 ... 6
16  Using Arduino / Displays / Re: Help add support for HT1632 in u8glib on: May 31, 2013, 05:04:03 am
Display is working! Thank you very much!!!

You can remove this piece of code from the init function:
Code:
 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:
Code:
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.
17  Using Arduino / Displays / Re: Help add support for HT1632 in u8glib on: May 30, 2013, 04:45:13 pm
This is the file I'm using: http://pastebin.com/cWTa7B2a

I changed page*8 to page*26 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-grin Thanks again for looking into this!
18  Using Arduino / Displays / Re: Help add support for HT1632 in u8glib on: May 30, 2013, 03:58:11 pm
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:
Code:
#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);
}
19  Using Arduino / Displays / Re: Help add support for HT1632 in u8glib on: May 30, 2013, 03:43:20 pm
New post because my last one is a mess. I finally got it working! Data is being sent. After init finishes the whole display is lit up. When I uncomment the do statement (not the contents, just the statement) about half of the screen turns black. If I uncomment the contents of the screen garbage is written on the cleared part.
20  Using Arduino / Displays / Re: Help add support for HT1632 in u8glib on: May 30, 2013, 03:27:31 pm
This is my current sketch:
Code:
#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);
}

I am sure that the init procedure is called. I placed digitalWrite(13, HIGH) on the first and the LED lights up. It not bright as it should, for some reason it's dim. EDIT: Something might be using the SPI port on u8glib. I uploaded the Blink example and it's bright as it should. I don't have anything connected on pin 13.

Nothing is shown on the display. I still have my custom code to fill the graphics RAM (like my test sketch).

EDIT2:
Minor success! I'm not getting the full RAM filled again but I'm looking into it. That's what was missing.
Code:
 pinMode(DATA_PIN, OUTPUT);
  pinMode(WR_PIN, OUTPUT);
  pinMode(CS_PIN, OUTPUT);

  digitalWrite(DATA_PIN, HIGH);
  digitalWrite(WR_PIN, HIGH);
  digitalWrite(CS_PIN, HIGH);
smiley-cool
21  Using Arduino / Displays / Re: Help add support for HT1632 in u8glib on: May 30, 2013, 12:42:57 pm
Success! I have a complete sketch and I am able to send data on the display.

This is the working sketch, it flashes the screen on and off: http://pastebin.com/yrQtneA4

I have implemented the changes in my copy of u8glib but had no success in making it work. First of all, I did this change as we discussed:

Code:
[...]
switch(msg)
  {
    case U8G_DEV_MSG_INIT:
ht1632_init();
      break;
    case U8G_DEV_MSG_STOP:
      break;
[...]

To make sure that everything is ok, I changed the ht1632_init() procedure to:
Code:
void ht1632_init(void)
{
  digitalWrite(CS_PIN, LOW);
  /* init display once after startup */
  ht1632_write_data_MSB(3, HT1632_ID_CMD, false); // IDs are 3 bits
  ht1632_write_data_MSB(8, HT1632_CMD_SYSDIS, true); // 8 bits
  ht1632_write_data_MSB(8, HT1632_CMD_SYSON, true); // 8 bits
  ht1632_write_data_MSB(8, HT1632_CMD_COMS11, true); // 8 bits
  ht1632_write_data_MSB(8, HT1632_CMD_LEDON, true); // 8 bits
  ht1632_write_data_MSB(8, HT1632_CMD_BLOFF, true); // 8 bits
  ht1632_write_data_MSB(8, HT1632_CMD_PWM+15, true); // 8 bits 
  digitalWrite(CS_PIN, HIGH);

  // 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,0xFF);
  }
  digitalWrite(CS_PIN, HIGH);
  // #######################################
}

I also did made change to the sketch in order to have only to invoke only the init function:
Code:
void loop(void)
{
  u8g_t u8g;
 
  u8g_Init(&u8g, &u8g_dev_ht1632_26x16);
  /*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);
}

What should I do now?
22  Using Arduino / Programming Questions / Re: Program only works correctly after re-uploading at each start-up. Why? on: May 30, 2013, 12:33:31 pm
Abfahrt's suggestion seems like a good one - I suggest you look to see what initialisation the test sketch is doing that your game sketch is not doing.

I had similar experiences in the past smiley-lol

Something else worth mentioning is that some boards (especially those that have capacitors on them) might store enough power to keep the electronics powered for some seconds even though you unplug the cord. You will either have to wait a little longer or short the power rails using a resistor (after you unplug the power).
23  Using Arduino / Displays / Re: Help add support for HT1632 in u8glib on: May 30, 2013, 11:45:22 am
Yes I did. I moved out the communication specific parts to a seperate sketch and I'm doing tests. I am trying to fill the display with data (fill the whole LED RAM). Something is broken and only three columns light up, but I hope I'll sort this out really soon!
24  Using Arduino / Programming Questions / Re: Timer 1 on ATtiny25/45/85 (CTC mode) on: May 30, 2013, 10:08:46 am
Without actually trying it, I'm not sure this is possible. The largest clock prescaler is 16384, so with a 16.5 MHz system clock and using the overflow interrupt, the slowest the ISR could run would be

16,500,000 / 16,384 / 256 = 3.934 Hz

I might not use a web page that calculates ATmega timer values for an ATtiny.

Yes you are correct.

Well, you probably can't get the hardware to call your ISR at one second intervals, but you could set up a counter in your ISR that calculates when a one second interval is, and calls your code accordingly.

I think the standard 328 core uses a FRACT calculation because it uses the standard 256 top and prescaler of 64.  That doesn't divide evenly into 16,000,000.  It's close to a millisecond, but not exact.  So they have to calculate how far off it is every time so there isn't any drift.

If all you want is one second timer, you could set up your timer interrupt with a top of 250 and a prescaler of 8.  Then you could count down to 20625 and your code would be called at exact one second intervals.

Thanks! I'll try to implement this and post results.
25  Using Arduino / Programming Questions / Re: Program only works correctly after re-uploading at each start-up. Why? on: May 30, 2013, 04:32:57 am
A wild guess is that you missed a setup function for your game, a function that setups the accelerometer accordingly. That's why you need to upload the testing sketch first, it setups the hardware. Configuration is lost at power cycles.
26  Using Arduino / Programming Questions / Re: Timer 1 on ATtiny25/45/85 (CTC mode) on: May 30, 2013, 04:31:12 am

Core?
For this testing I'm not using a core just to be sure nothing is messing with the Timers! I'm aware some cores use Timer1 for millis() and similar functions.

I believe the ATtiny25/45/85 timer1 is an 8 bit timer.  In CTC mode you don't use OCR1A as the top.  Here's what the spec sheet says:

Quote
• Bit 7 – CTC1 : Clear Timer/Counter on Compare Match
When the CTC1 control bit is set (one), Timer/Counter1 is reset to $00 in the CPU clock cycle after a compare
match with OCR1C register value. If the control bit is cleared, Timer/Counter1 continues counting and is unaffected
by a compare match.

Maybe you should try using OCR1C instead of OCR1A.  And use a value that is less than 256.

Yes. You are absolutely correct! I tried various values but nothing changed. I'm trying to make the ISR run at 1s intervals.

Should I just cheat and see how the ATtiny cores handle millis() etc using Timer1 or figure it myself? smiley-razz
27  Using Arduino / Programming Questions / Timer 1 on ATtiny25/45/85 (CTC mode) on: May 29, 2013, 07:33:37 pm
I'm currently trying to make a simple ISR that counts how many seconds have passed. I have to use Timer1 because Timer0 is used for PWM on my project and I can't swap pins that easily. For some reason Timer1 on the ATtinyX5 chips is really weird. This is my implementation but it doesn't work and I can't figure why. Has anyone experience on this?

The system is running at 16.5MHz (with V-USB -- disabled it for testing just in case). I used http://www.et06.dk/atmega_timers/ to calculate timer values.

Code:
DDRB |= (1 << PB0); // output
PORTB |= (1 << PB0); // high

OCR1A = 64453;            // compare match register
TCCR1 |= (1 << CTC1);   // CTC mode
TCCR1 |= (1 << CS13);    // 256 prescaler
TCCR1 |= (1 << CS10);    // 256 prescaler
TIMSK |= (1 << OCIE1A);

Code:
ISR(TIM1_COMPA_vect) { // also tried TIMER1_COMPA_vect
  PORTB ^= (1 << PB0);
}

Thanks!
28  Using Arduino / Displays / Re: Help add support for HT1632 in u8glib on: May 28, 2013, 10:18:22 am
I fixed that myself but didn't make any difference. How can I start debugging this?
29  Using Arduino / Displays / Re: Help add support for HT1632 in u8glib on: May 28, 2013, 06:24:21 am
I did test the code but unfortunately it doesn't work. I did a quick review but I couldn't spot anything wrong. I will check later when I have more time. A quick question: Where does ht1632_init gets called? Shouldn't it be inside U8G_DEV_MSG_INIT?
30  Using Arduino / Displays / Re: Help add support for HT1632 in u8glib on: May 27, 2013, 05:54:45 pm
I have some other issues with the code.
ID values are missing. I assume
Code:
#define HT1632_ID_CMD 0x04
#define HT1632_ID_WR 0x05

Oops! I forgot to include them!

Code:
#define HT1632_ID_CMD 4 /* ID = 100 - Commands */
#define HT1632_ID_RD 6 /* ID = 110 - Read RAM */
#define HT1632_ID_WR 5 /* ID = 101 - Write RAM */

Then: You used
Code:
writeDataMSB(3, HT1632_ID_WR); // Send "write to display" command
writeDataMSB(7, 0); // Send initial address
but writeDataMSB() requires three arguments. What will be the third argument?

Oliver

This is how the signature of the procedure:
Code:
void writeDataMSB(byte cnt, byte data, bool extra = false);

I will test the code as soon as possible! Thanks a lot!

EDIT: One last thing! u8g_dev_ht1632_26x16.c should be u8g_dev_ht1632_24x16.c! The panel is 24x16!
Pages: 1 [2] 3 4 ... 6