Show Posts
Pages: [1] 2
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: Parse string as Hex? on: August 26, 2010, 01:52:01 am
Memory isn't a major issue.

And assume that I need to do it that way because I'm getting the strings from an input that I don't have control over, so I don't have a choice.
2  Forum 2005-2010 (read only) / Syntax & Programs / Parse string as Hex? on: August 25, 2010, 05:36:52 pm
I'm trying to clean up entry of some Hex strings in a project I'm working on, and am running up against what I'm sure is a pretty simple problem that's just slightly beyond my comprehension of C at this point.

Right now, I'm declaring the data as an array, such as:

byte PressNext[]={
  0x90, 0x02, 0x7F};

And then, when I need to send that out the serial port, I do a sizeof on the array to get it's length (since the length may vary), then loop a

Serial.print(PressNext, BYTE);

to send each byte of the array.

I'm trying to figure out a more streamlined/elegant way to do this, so that I can enter the string as a straight string without the 0x indicator and the comma delimiter, so I guess I'm trying to treat an ASCII char string as hex values?

In other words, I want to be able to declare the string as

"90 02 7F"

Instead of having to format it as "0x90, 0x02, 0x7F"

So, the twofold question is how do I parse that char string into the proper Hex values, and then is my Serial.print loop the best way to do it, or can I print it as a string in one piece without having to worry about getting the length and looping?

I think what I need to do is parse it into the Hex array, and then convert that back to a char string? Or am I overthinking?

Thanks,
Andy
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: Ethernet shield: setting MAC/IP from outside on: December 01, 2009, 10:40:56 pm
Could you do it like a wireless router setup, where there's a default MAC and IP, you connect to that IP via a web browser, where you edit the values in a form, and then those values get saved to EEPROM and take effect when you reset?
4  Forum 2005-2010 (read only) / Syntax & Programs / Arduino equivalent to ReadString/ReadStringUntil? on: August 22, 2009, 10:36:51 pm
That pretty much sums it up...is there an Arduino equivalent of the Processing ReadString and ReadStringUntil functions? I know you can do it the long way with For loops, but with the code abstracted in Processing, it certainly is a little cleaner and more efficient on the writing end of it. Came across that on a browse of a Processing book to satisfy some curiousity about it, and it struck me that I had never seen a similar function abstraction in Arduino.

--Andy
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: Assiging contents of one array to another? on: April 30, 2009, 02:44:45 am
Great, I was hoping it'd be that simple, but didn't know enough to be sure! Thanks :-)
6  Forum 2005-2010 (read only) / Syntax & Programs / Assiging contents of one array to another? on: April 30, 2009, 01:35:30 am
Perhaps a stupid question....can I assign the contents of one array to another in one single line, or do I need to do it position by position in a loop?

I've got a program with a dozen or so arrays, and at various points I need to serial.print the contents of those arrays, and I'm trying to simplify this to a single function, rather than have to repeat the code a dozen times.

So, can I declare the function like this:
Code:
void sendMsg(byte msgString[])
and then call it like this:
Code:
sendMsg(array_name_here)
?

Will that plug the entire contents of the array in as the contents of msgString, or not? If not, is there another way to do this easily/efficiently?

Thanks,
Andy
7  Forum 2005-2010 (read only) / Syntax & Programs / Scroll a list of stored values on LCD on: February 24, 2009, 11:48:25 pm
Hey everybody,
I can't believe this hasn't been discussed before, but I can't for the life of me figure out what to search for if it has, so forgiveness if it's redundant!

I'm trying to figure out how to read in a list of values from the serial port (MIDI messages, specifically, presumably using the new-ish MIDI library, so I don't have to reinvent the wheel smiley), and then display those messages on the screen as a scrollable list.

I'm basically trying to create a standalone equivalent of the Mac program MIDI Monitor, if that helps. (http://www.snoize.com/MIDIMonitor/)

There are a couple existing similar projects with other processors, but I'd like to figure it out with Arduino, both for the sake of learning how to do it, and because I want to add some other features to it, as well.

Any guidance is appreciated!

Best,
Andy
8  Forum 2005-2010 (read only) / Interfacing / Re: Which platform? Java? Flash? REALbasic? on: August 19, 2009, 01:38:36 am
Any recommendations for crash courses in getting up to speed in java enough to do that sort of thing, LOL?
9  Forum 2005-2010 (read only) / Interfacing / Which platform? Java? Flash? REALbasic? on: August 18, 2009, 08:54:57 pm
Hey guys,
I need to put together a pretty straightforward "editor" for my Arduino project. I've got an Arduino based button box that spits out MIDI messages for press and release of each of 7 buttons, and I want an easy way for the end user to reprogram it. I think the simplest way is to create a GUI editor where they can edit the strings, and then send them to the device via USB, where the Arduino stores it to EEPROM, and then reads the strings back in from EEPROM as part of setup.

I'm just trying to figure out the best platform to do this. I want the user to be able to select the type of MIDI message for each button/state, input values as appropriate, and input the full string if it's a SysEx message. When done, they'd connect the Arduino via USB, hit a button in the GUI, and it'd send the data over to the Arduino, I guess as a string of start/ID, message, stop byte, next_start/ID, etc

 Whichever platform I use to develop this, I'm starting from scratch, so I'm looking for pointers on the most efficient/easiest.

I used to do a little bit of Flash programming (y'know, the typical late '90s "all Flash, all the time!" website), but it's been almost a decade, and I dabbled with Visual Basic back in jr high, but again that's been 15+ years. So I'm basically starting from scratch, with only my relatively new knowlege of programming for the Arduino to build on.

Ideally I'd like it to be cross-platform, since I'm a Mac user, and the end users are a mix of Mac and Windows. I'm not overly concerned with Linux.

TIA,
Andy
10  Forum 2005-2010 (read only) / Interfacing / Re: Dedicated sketch uploader/installer on: April 12, 2009, 01:39:11 am
Quote
Your MIDI goes through the same Rx/Tx pins? Are you using same Tx/Rx for both MIDI and sketch upload?

Well, MIDI comes out the serial pins, which while different physical pins are the same serial output as what the USB is connected to, right? Or am I just totally misunderstanding?

If I can segregate these functions programmatically, it shouldn't be an issue functionally, because the "programming" operation will never have to take place simultaneously with the MIDI mode. It would be a distinct process, before it's put into use.

Quote
In terms of programming effort, writing to eeprom is not more complicated than calling a function (or assigning values to variables). The only requirement is a delay of 5ms after a byte is written.

But don't I need to specifically address it to a given physical location in EEPROM? As opposed to just telling the Arduino "store 'XYZ123ABC' as 'StringA'" and then just letting it do its own thing with where to store that? So if I were dealing with a fixed amount of data, I could do EEPROM, but since I don't know whether each of the 7 strings the user could program would be 3 bytes, or 8 bytes, or whatever, I don't have a reliable way to either address them when writing, or to read them back.

Thinking out loud, I can see theoretically how I could have the PC program include a specific start and end byte for each string, so that the Arduino could just read/write them into EEPROM sequentially, and keep reading till it hits the next end byte, etc, I just have noooo idea how to implement reading that back into variables on the Arduino side of life.
11  Forum 2005-2010 (read only) / Interfacing / Re: Dedicated sketch uploader/installer on: April 11, 2009, 08:19:37 pm
Nope, not oversimplifying, just overlooking the part where I'm trying to NOT include this in the main loop, and to essentially make it an ancillary function that's only called if initiated immediately upon powering the Arduino.

I need to do this for two reasons:

1)Primarily, because the normal function of this project is to send and receive MIDI, and so it's already listening to the serial port normally, and needs to be able to discriminate these programming messages from MIDI

2)Overhead. I'd like to avoid even the simple overhead of having to check the serial port every time it loops were #1 not the case, but that being the case, if it were to listen to the code to distinguish MIDI from programming messages every time, it'd add a great deal of undesired overhead to the loop, potentially slowing things down.

That all said, I think I really need to pursue the other approach, of wholesale reuploading the sketch, since I had forgotten that EEPROM needs to be explicitly addressed, and since I can't know in advance how long the strings the end user will want to store will be, I can't easily store them in EEPROM, right?

So, can anybody gently guide me towards how to, for lack of a better way to describe it, create a self-installing sketch? That is to say, a file/program/script I can give the end user, and after he inserts his desired strings into it via whatever method I end up using (editing a text file that becomes part of the sketch, or using a GUI editor to do  it more transparently), it will upload itself?

I know it should be possible with the command line loader, I just don't know enough to understand how exactly that works, nor how to script that so it requires the least effort from the end user, ie, he just runs an installer, runs the program, and clicks "send program" and it uploads the modified sketch to the Arduino, without him having to muck around in the IDE.

TIA,
Andy
12  Forum 2005-2010 (read only) / Interfacing / Re: Dedicated sketch uploader/installer on: April 11, 2009, 06:53:56 pm
That's getting me closer. Question, and it may be a stupid newbie question, can I put code outside of the main loop, either in setup or elsewhere, so that it'll only go into the routine that does the serial read, eeprom, etc if that button is held down while the Arduino is first powered up?

I basically want to be able to put it into "editing" mode only when connected to the computer, be it by holding that button or sensing that it's connected to USB, but I don't want to have to add an additional button beyond the ones needed for normal operation, and I don't want the additional overhead of having to run that routine, or the check for the button to run that routine, every time it loops.

TIA,
Andy
13  Forum 2005-2010 (read only) / Interfacing / Re: Dedicated sketch uploader/installer on: April 11, 2009, 06:01:52 pm
Nope, you misunderstand.

In normal operation, my program is not connected to a computer at all, it just spits out MIDI. But I want to provide the option (typically as a one time "setup") for my end user (who doesn't speak Arduino and I'd like to avoid having to make them putter around in the IDE) to change the values of a number of variables I declare in the beginning of the sketch permanently.

So I need to either give them a more automated way to reload the sketch onto the Arduino after they run a script that edits those values, or I need to have a way for the Arduino to tell that it's connected via USB, rather than MIDI (and this can even be as simple as holding a button down on boot, as long as the button can otherwise function as a normal input), and then to have the PC/Mac program send it those strings, and write them to EEPROM.

I fully understand the basics of how to get it to talk over serial, my issue is either booting the Arduino into an alternate "programming/editing" mode, in which case the program on the PC can send it those values, and the Arduino will write them to EEPROM, or to make a completely idiot-proof way to install the Arduino's drivers and have an automated "installer" to upload the sketch to the Arduino.

Does that explain what I need any more clearly?
14  Forum 2005-2010 (read only) / Interfacing / Dedicated sketch uploader/installer on: April 11, 2009, 12:49:18 am
Hey guys,
So, I'm a complete idiot when it comes to more than basic Arduino programming, but trying to dive in deeper. For a particular application I have in mind, I want to give end users the ability to easily edit a number of variables, so that they can define what serial strings are sent when a given button is pressed.

Can anybody offer guidance on how to create a standalone editor/loader that would let them either edit these strings directly in said program, or read them in from a text file the user edited, and then send these to the Arduino in some non-volatile format?

I can see two possible approaches, and am fine with either, I just don't know how to implement either:

1) The editor edits the actual strings in the sketch, and then reloads the entire sketch to the the Arduino, so it's actually modifying the sketch. I imagine this would somehow use the command line loader, but I'm definitely in over my head sorting that out.

2) The editor communicates via serial with the Arduino, and the sketch on the Arduino receives just these strings from the editor,and stores them in EEPROM. To do this, the Arduino would have to sense whether or not it was connected via USB, I think, since otherwise I'm using the serial out to output MIDI.

In either case, I'm also trying to sort out the easiest way to install the appropriate drivers on the user's computer; do I need to have them install the whole IDE package, and then just use this editor to "program" the Arduino, or can I make a streamlined installer that would just install my editor and the necessary drivers. I want to make it as idiot proof as possible, since the end users will know even less about Arduino than I do!

I'd love something that is both Win and Mac friendly, but if I have to pick one, I'd go with Win, since that can run in Fusion or Boot Camp on Macs. Much as it pains me, being a Mac user myself :-1

Thanks in advance for any help, hand-holding, etc you can provide!

--Andy
15  Forum 2005-2010 (read only) / Interfacing / Re: Cross-platform reading of a text file into Arduino on: February 28, 2009, 09:38:16 pm
Here's a crazy thought...

Is there a way to get the Arduino to let you use the EEPROM as a USB drive? If I could figure out a way to just connect it to the computer via USB, drag a text file(s) with the variables in it, and then read that from the program, that would be perfect.

I could do the same thing with an SD card and an external reader to write the card, but I'd love to do it all self-contained, and ideally avoiding the need for the SD card/other external memory.


Pages: [1] 2