Show Posts
|
|
Pages: [1] 2 3
|
|
1
|
Using Arduino / Programming Questions / Re: understanding touchLib.h
|
on: October 16, 2011, 08:18:50 am
|
In the ISR, the pointers do not exist, so you can't reference them. Sure, that's what I was expecting, but what would be an efficient approach to use them outside of the function?; i.e. the only way is to define them outside in the global scope of the program?
|
|
|
|
|
2
|
Using Arduino / Programming Questions / Re: understanding touchLib.h
|
on: October 16, 2011, 07:36:30 am
|
I am using the same library but encountered some difficulties trying to directly set several button functions. I would like to combine the Touchshield interaction with a rotary encoder. Hence, I need to toggle the Button state from within the arduino code (ideally triggered by an external interrupt!). As far as I understood, I would need to assign a pointer to the buttonAdd() function. Something like this:
[code] TouchButton *button1 = touch.buttonAdd( 10, 10, 80, 28, COLOR_BLUE, COLOR_RED, COLOR_WHITE, false, true, 1, 1, "Button1", 1);
// interrupt function ISR(INT1_vect) { // toggle current submenu if (touch.buttonDown(button1) == true) { touch.buttonSetDown(button1, false); } else { touch.buttonSetDown(button1, true); } }
The problem is that as soon as I put the pointer variable declaration inside of a function the code breaks. for example like this: void draw_main_screen() { TouchButton *button1 = touch.buttonAdd( 10, 10, 80, 28, COLOR_BLUE, COLOR_RED, COLOR_WHITE, false, true, 1, 1, "Button1", 1); TouchButton *button2 = touch.buttonAdd( 10, 50, 80, 28, COLOR_BLUE, COLOR_RED, COLOR_WHITE, false, true, 1, 1, "Button2", 2); TouchButton *button3 = touch.buttonAdd( 10, 90, 80, 28, COLOR_BLUE, COLOR_RED, COLOR_WHITE, false, true, 1, 1, "Button3", 3); }
draw_main_screen();
// interrupt function ISR(INT1_vect) { // toggle current submenu if (touch.buttonDown(button1) == true) { touch.buttonSetDown(button1, false); } else { touch.buttonSetDown(button1, true); } }
I also noticed some glitches for the toggle (using the buttonSetDown function). Sometimes part of the button remain in blue whereas the background below the font changes to red. I am not sure whether using the Touchlib library is a constraint to what I am planning to do. So, perhaps someone can't point out about the problematic with using pointers outside of void_functions and what are the flaws of such an approach!? thx![/code]
|
|
|
|
|
4
|
Forum 2005-2010 (read only) / Troubleshooting / serproxy - waiting for clients
|
on: May 31, 2006, 02:35:25 pm
|
|
hi!
the serproxy under win32 can´t find any clients. when i start serproxy it remains idle and says "Serproxy - (C)1999 Stefano Busti, (C)2005 David A. Mellis - Waiting for clients". i´m printing strings with printString("yo, brotha");. hmm. with realterm i get the messages without problem?! does anyone have experience with serproxy?!?!
|
|
|
|
|
6
|
Forum 2005-2010 (read only) / Troubleshooting / Re: Max/MSP - mutliple serial read
|
on: February 19, 2006, 01:33:14 pm
|
|
hej,
i experienced some glitches (value will jump to zero) while constantly reading the serial data with serial object in max/msp??! do you have any clue? and which metro-time do you use for banging the serial object?
meanwhile, i downloaded the code-sniplet by David Cuartielles, but i couldnt open it, neiter as text, nor as patch? does it contain errors? i´m using max 4.5.4?
|
|
|
|
|
8
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: Problem accessing large PROGMEM structure
|
on: March 07, 2009, 10:10:37 am
|
Hello all, I've tried the library with arduino and stripped down my whole setup to one max6960 chip driving two 8x8 monocolor displays. Instead of an 8MHz oscillator, I am using a 4.0MHz one. I've changed some lines in max696x_conf.h: #define NUMBER_OF_DRIVER_DEVICES (1) #define NUMBER_OF_DRIVERS_PER_ROW (1) #define MAX696x_OSC_FREQ (4000000) I removed the max696x.o file in [_your_arduino_path__]/hardware/libraries/max696x/ folder and compiled the arduino sketch. This recompiles max696x.cpp and you will have a new max696x.o file in your folder! This is my code for the Arduino: #include <max696x.h> #include <max696x_conf.h>
max696x Max696x;
byte fault;
void setup() { Serial.begin(9600); // (GLOBAL PANEL REGISTER 0x0D, PANEL INTENSITY 0x02, PIXEL_INTENSITY 0x01, GLOBAL DRIVER DEVICES 0x0e, GLOBAL DRIVER ROWS 0x0f, GLOBAL PLANE COUNTER 0x0b Max696x.init('0x01','0xff','0x00','0x00','0x01','0x00'); delay(250); //check display fault = Max696x.display_test(); Serial.print(fault,HEX); // print global register values Max696x.reg_dump(); }
void loop() { while (1) { delay(100); Max696x.indirect_mem_wr('0x80'); } }
The initialization of the chip happens here: Max696x.init('0x01','0xff','0x00','0x00','0x01','0x00'); GLOBAL PANEL REGISTER 0x0D -> 0x01 (sets shutdown mode bit) PANEL INTENSITY 0x02 -> 0xff (sets full brightness) PIXEL_INTENSITY 0x01 -> 0x00 (monocolor) GLOBAL DRIVER DEVICES 0x0e -> 0x00 (using only one device) GLOBAL DRIVER ROWS 0x0f -> 0x00 (using only one row) GLOBAL PLANE COUNTER 0x0b -> 0x00 (Manual selection to plane 0) This line: Max696x.indirect_mem_wr('0x80'); should actually light up the first/last row (depends on your displays) as far as i understood, but it doesn't really work (it always lights up the third and forth row..) Also, it appears that the global registers are not correctly set. This command reads all global register Max696x.reg_dump(); but my output looks like this: GLOBAL DRIVER INDIREST ADDRESS (0x08) : 0x0 GLOBAL DISPLAY INDIRECT ADDRESS LSB (0x09) : 0x0 GLOBAL DISPLAY INDIRECT ADDRESS MSB (0x0a) : 0x0 GLOBAL PLANE COUNTER (0x0b) : 0x30 CLEAR PLANES (0x0c) : 0x0 GLOBAL PANEL CONFIG (0x0d) : 0x31 GLOBAL DRIVER DEVICES (0x0e) : 0x2F GLOBAL DRIVER ROWS (0x0f) : 0x30
LOCAL REIGSTERS DRIVER ADDRESS (0x00) : 0x0 PIXEL INTENSITY SCALE (0x01) : 0x0 PANEL INTENSITY (0x02) : 0x66 DIGIT 0 INTENSITY (0x03) : 0xFF DIGIT 1 INTENSITY (0x04) : 0xFF FAULT (0x05) : 0x81
I am not sure, but it seems that the global registers are not correctly set during the initialization process. Still, the SPI communication IMHO should be setup correctly, because following code lights up all my LEDs on both displays!: Max696x.display_test(); Thus, "command_wr" and "command_rd" function work, because i can read the fault if some LEDs are not connected! I also tried switching between software and hardware SPI, but to no avail! Anyone had success with this issue? Thanks to all thinkers and tinkers and especially to letaage who made this possible. I was already thinking of dumping my whole max6960 setup, but the end seems very close now 
|
|
|
|
|
9
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: help interfacing with max6960 led matrix
|
on: November 28, 2008, 12:43:52 pm
|
Hi Eeddgar, I´m using the eval board from maxim. O.k. So, now i understand why you are setting up 4xMax6960 in the Cascaded Device Register. //Number of Cascaded Devices Register digitalWrite(SLAVESELECT,LOW); spi_transfer(0x0e); spi_transfer(0x03); digitalWrite(SLAVESELECT,HIGH);
I forgot to comment in the code the last write, but in fact, the last one, is a writing to light up two leds: oh, i c 8-) the max chip is still not showing anything on my display... maybe i should also get an evkit board for trying out the code ... they seem to be not really easy available. you can buy them only directly through maxim, isn't it? i was cleaning up your code a bit and put send/read functions for better overview.. could you try it out on your arduino? especially i am curious if the read functions are working! #define DATAOUT 11 //MOSI #define DATAIN 12 //MISO #define SPICLOCK 13 //SCK #define SLAVESELECT 10 //SS #define RESET 9 //Reset
byte clr;
void spi_transfer(volatile char data) { SPDR = data; // Start the transmission while (!(SPSR&_BV(SPIF))) { } }
uint8_t spi_receive() { uint8_t val = 0; SPDR = 0x00; // Start clock while (!(SPSR&_BV(SPIF))) { } val = SPDR; return val; }
void write8(uint8_t payload) { digitalWrite(SLAVESELECT,LOW); spi_transfer(payload); digitalWrite(SLAVESELECT,HIGH); }
void write16(uint16_t payload) { payload &= 0xEFFF; // zero out the factory reserved bit / datasheet page 11 digitalWrite(SLAVESELECT,LOW); spi_transfer(payload>>8); spi_transfer(payload&0xff); digitalWrite(SLAVESELECT,HIGH); }
void write24(uint32_t payload) { payload &= 0xEFFF; // zero out the factory reserved bit / datasheet page 11 digitalWrite(SLAVESELECT,LOW); spi_transfer(payload>>16); spi_transfer(payload>>8); spi_transfer(payload&0xff); digitalWrite(SLAVESELECT,HIGH); }
uint8_t read16(uint16_t payload) { write16(payload); return spi_receive(); }
uint8_t read24(uint32_t payload) { write24(payload); return spi_receive(); }
void setup() { Serial.begin(9600); Serial.println("booting..."); pinMode(DATAOUT, OUTPUT); pinMode(DATAIN, INPUT); pinMode(SPICLOCK,OUTPUT); pinMode(SLAVESELECT,OUTPUT); pinMode(RESET,OUTPUT);
// SPCR register // SPIE SPE DORD MSTR CPOL CPHA SPR1 SPR0 // D7 D6 D5 D4 D3 D2 D1 D0
//interrupt disabled,spi enabled,msb 1st,master,clk low when idle, //sample on leading edge of clk,system clock/4 rate (fastest) SPCR = (1<<SPE)|(1<<MSTR);
clr=SPSR; clr=SPDR; delay(10);
digitalWrite(SLAVESELECT,HIGH); digitalWrite(RESET,HIGH); delay(5); digitalWrite(RESET,LOW); delay(5); digitalWrite(RESET,HIGH); delay(200); //Panel Configuration Register write16(0x0d01);
//Panel Intensity Register write16(0x0230);
//Number of Cascaded Devices Register write16(0x0e03);
//Number of Display Rows Register write16(0x0f01); delay (500);
//light up two leds, the first and the fifth, of the first row of the matrix write24(0x000088); }
void loop() { while (1); { };
}
THUMBS UP ++ BIG THANKS for sharing your code  ritzdank
|
|
|
|
|
10
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: help interfacing with max6960 led matrix
|
on: November 27, 2008, 11:07:05 am
|
Thanks for sharing the code! I have tried to communicate with MAX6963 but to no avail. Do you actually know the difference between MAX6960/1/2/3 ? One important thing when hooking it up to the Arduino is that you should put voltage dividers on all lines going to the MAX6960 since it runs on 3.3 volts! Signals going back to the Arduino are being interpreted correctly since +3.3 equals 1 also for the Arduino. Did you work further on your code? As far as i can tell you are just initializing the chip. How would you actually light up the LEDs?? Would be good to receive also something from the chip itself.. like the device id for example: uint8_t devid = (read16(0x8500) & 0x60) >> 5; Thanks for your help bye
|
|
|
|
|
11
|
Forum 2005-2010 (read only) / Syntax & Programs / quad-encoder // comparing strings
|
on: July 31, 2006, 08:41:00 pm
|
hi! i´m working on a quad-encoder: http://www.mcmanis.com/chuck/robotics/projects/lab-x3/quadratrak.htmlsomething like this. as test surrounding i took 2 buttons and press them by hand. i´ve encountered a problem with string comparison or with bit-wise comparison int ledPin = 13;
int photopin1 = 7; int photopin2 = 8;
int value1 = 0; int value2 = 0; int value = 0; char stateprevious = '00'; char statenow = '00'; int rs232val = 0; int delaystate = HIGH;
void setup() { pinMode(photopin1, INPUT); pinMode(photopin2, INPUT); pinMode(ledPin, OUTPUT); beginSerial(19200); } void check_state() { delaystate = !delaystate;
if (value1 == HIGH && value2 == HIGH) { if (delaystate == HIGH) { stateprevious = '11'; } else { statenow = '11'; } } else if (value1 == LOW && value2 == HIGH) { if (delaystate == HIGH) { stateprevious = '01'; } else { statenow = '01'; } } else if (value1 == HIGH && value2 == LOW) { if (delaystate == HIGH) { stateprevious = '10'; } else { statenow = '10'; } } else if (value1 == LOW && value2 == LOW) { if (delaystate == HIGH) { stateprevious = '00'; } else { statenow = '00'; } } }
void loop() { value1 = digitalRead(photopin1); value2 = digitalRead(photopin2); check_state(); serialWrite(statenow); serialWrite(10); serialWrite(13); serialWrite(stateprevious); serialWrite(10); serialWrite(13);
} in serial monitor i cant see the correct state. it only prints one character per line?!?!!
|
|
|
|
|
12
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: Arduino and sleep settings
|
on: January 27, 2007, 03:21:08 pm
|
this topic is indeed a hot issue, when using the arduino stand-alone with battery-supply. i´ll try sleep_mode next days, but also throw up the question which battery supply do you prefer? for my last project, i was dealing with atmega8L working on 3,3V and 8Mhz supplied by cell-phone battery (3,7V) from an old nokia-phone. good thing about these batteries that they are really cheap NimH or even Lithium Ionen solutions and thousand times rechargeable, plus as an extra also very "handy" 
|
|
|
|
|
13
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: Counting hexadecimal / binary
|
on: January 29, 2007, 06:39:34 pm
|
yep, workaround is indeed an array, here´s the code byte reg_level0 = 0x01; byte reg_level1 = 0x02; byte reg_level2 = 0x03; byte reg_level3 = 0x04; byte reg_level4 = 0x05; byte reg_level[5] = { reg_level0, reg_level1, reg_level2, reg_level3, reg_level4 };
void test(int i) { for (i = 0; i < 5; i++) { function_blalba(reg_level[i], 0x40); delay(delaytime); } }
|
|
|
|
|
14
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: Counting hexadecimal / binary
|
on: January 29, 2007, 05:59:57 pm
|
sorry, you are right! but i´ve another question which is hard to find through all references. how can i "eval" within arduino language. for example, i have some registers called reg_level0, reg_level1, reg_level2 ... i want to set some bytes in a for-statement such as for (i = 0; i < 5; i++) { function_blablab(reg_level[i], 0x00); } of course above example couldnt be compiled as it interprets the square brackets as an array? do you know another syntaa for that? thanks
|
|
|
|
|