Show Posts
Pages: 1 2 [3] 4 5 ... 239
31  Development / Other Software Development / Re: New peek function for HardwareSerial on: August 16, 2014, 04:20:52 pm
Well if you think about, all we need to do is access the buffer. The only problem that I can't seem to figure out is how to access the buffer

From HardwareSerial.cpp file.
Quote
struct ring_buffer
{
  unsigned char buffer[SERIAL_BUFFER_SIZE];
  volatile unsigned int head;
  volatile unsigned int tail;
};

Is there any way to access this struct outside the library?
32  Using Arduino / Programming Questions / Re: TFT TouchScreen V1.0 seeedstudio !!!HELP ME!!! on: August 16, 2014, 04:03:07 pm
You mean this line here?

Quote
#include <TouchScreenMenu.h>
#include <TouchScreen.h>
#include <TFT_old.h>
#include <cstddef.h>

// create the array of items for the first sub menu
TouchScreenMenuItem subMenuItems[] = {
  TouchScreenMenuItem("<- Main Menu"),
  TouchScreenMenuItem("Left Justify"),
  TouchScreenMenuItem("Right Justify"),
  TouchScreenMenuItem("Small Font"),
  TouchScreenMenuItem("Spacing"),
  TouchScreenMenuItem("Padding"),
  TouchScreenMenuItem("ENDOFMENU")
};
33  Development / Other Software Development / New peek function for HardwareSerial on: August 16, 2014, 03:55:26 pm
I was trying to help out a new user with his project, but the solution I though would work turned out to only work once.

Users post
The user wanted to send a string from his phone to control a RGB led(s), and the code I gave him was:

Code:
char * strings[3] = {
  "RED", "GREEN", "BLUE"};
byte i = 0;

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  if(Serial.available())
  {
    while(i < 3)
    {
      if(Serial.find(strings[i]))
      {
        Serial.print("Found ");
        Serial.println(strings[i]);
        i = 0;
        break;
      }
      Serial.println(i);
      i++;
    }
    if( i >= 3)
    {
      Serial.println("not found");
      i = 0;
    }
  }
}

This code should check the buffer and see if a string is found, and if not increment the index and check again.

It will find RED if typed in because it is in the first index of the strings array, but it won't find anything else. Upon further investigation, I found out that read() pops the ints (look at the .h and .cpp files for HWS) out of the buffer when it is called so this prevents my code from working. However another function peek() only looks at the first index of the buffer and doesn't move unless read is called.

I would like to add a new peek() function that allows the user to look through the buffer freely without popping anything out, thus allowing my code to work.

I have made an equivalent code that does what I want using the normal HWS library, but it is not very elegant. I'm sure I am not the only person this new function would help, so I am asking if it can be added.

New peek function, simple right?
Code:
int HardwareSerial::peek(uint8_t position)
{
  if (_rx_buffer->head == _rx_buffer->tail) {
    return -1;
  } else {
    return _rx_buffer->buffer[position];
  }
}
34  Using Arduino / Programming Questions / Re: TFT TouchScreen V1.0 seeedstudio !!!HELP ME!!! on: August 16, 2014, 03:15:54 pm
Oh, I put in the wrong file in, sorry.  smiley-lol

Try this one. Same sketches and unpacking procedure.
35  Using Arduino / Project Guidance / Re: 12 Button Keypad Minimal Matrix on: August 16, 2014, 02:50:05 pm
You don't have to use those exact resistor values, but it does take only 2 different values.

example:
1000 and 4700

You can play around with the resistors to give you a better range if needed.
36  Using Arduino / Project Guidance / Re: 12 Button Keypad Minimal Matrix on: August 16, 2014, 01:21:10 pm
True it's not pretty but it works good. If the picture is too big, I am sorry.
37  Using Arduino / Project Guidance / Re: 12 Button Keypad Minimal Matrix on: August 16, 2014, 01:13:35 pm
I made a library for this very problem. Check it out.
Pay close attention as to how the keypad is wired, and the resistor configuration.

OneWireKeypad
38  Using Arduino / Programming Questions / Re: TFT TouchScreen V1.0 seeedstudio !!!HELP ME!!! on: August 16, 2014, 10:22:01 am
You should have a folder called "libraries" located in your arduino sketch folder.
39  Using Arduino / Programming Questions / Re: sending a word on: August 15, 2014, 11:05:41 am
edit:

The code didn't work at all.
40  Using Arduino / Project Guidance / Re: Controlling LED arrays - Not sure where to start on: August 15, 2014, 10:39:53 am
Take a look at this link.
https://learn.adafruit.com/rgb-led-strips/usage
41  Using Arduino / Programming Questions / Re: Pass const char [4][20] PROGMEM into function on: August 14, 2014, 09:53:06 pm
If you have the full code, please post it. Also what do you expect to be on the screen, can you provide an example?
42  Using Arduino / Project Guidance / Re: two-wheeled differential-drive robot rotation (one or two wheels) on: August 14, 2014, 01:46:27 pm
It's basically skid steering, which can be written and controlled easily. What do you plan on controlling it with?

Edit:
Quote
i'd like to use the robot to track a curve aided by a camera located at the ceiling of my room.
This might be a little more difficult and require more hardware and smarter software.
43  Using Arduino / Programming Questions / Re: Morse Code on: August 13, 2014, 11:25:17 pm
I just don't understand how the code will know it has reached the "start" bit. (Actually it wouldn't be a start bit, it would be an end bit, because you read a byte from LSB to MSB) 1 = dit, 0 = dah

But I'm too tired to argue about best methods or try to figure out this method, so I'm going to bed.

Good night all.

Edit: one more thing before I actually go.
If the code ignores the first bit, then how does it know when to stop and start a new letter?
44  Using Arduino / Programming Questions / Re: Morse Code on: August 13, 2014, 10:49:08 pm
That's why in my first example I had a value and the byte. The value would tell the code when to stop going through the byte. You can use a simple FOR loop and bitRead() to show the morse code patterns. 1 = dit and 0 = dah (or vice versa).

It's not that hard and it will work with numbers too.
45  Using Arduino / Programming Questions / Re: Morse Code on: August 13, 2014, 09:55:38 pm
Don't you also need to have a leading value to tell the code how many bits to cycle through? Because if you don't, how would you know which letter is being coded?

example:
byte tab[] = {
2, B01, // A
4, B1000,// B
4, B1010, // C
3, B100, //D
. . .
4, B1100 // Z
}
Now when a letter to be shown comes in, the code looks at the leading value and then cycles through the correct number of bits.

OR
you can make both into one byte and separate the byte into nibbles.(Actually better, and takes up less memory)
Pages: 1 2 [3] 4 5 ... 239